blob: fd4ef3c40e4054ba9f23dec2198b650ef53e4cae [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * linux/fs/affs/inode.c
3 *
4 * (c) 1996 Hans-Joachim Widmaier - Rewritten
5 *
6 * (C) 1993 Ray Burr - Modified for Amiga FFS filesystem.
7 *
8 * (C) 1992 Eric Youngdale Modified for ISO9660 filesystem.
9 *
10 * (C) 1991 Linus Torvalds - minix filesystem
11 */
Alexey Dobriyane8edc6e2007-05-21 01:22:52 +040012#include <linux/sched.h>
Ingo Molnar5b825c32017-02-02 17:54:15 +010013#include <linux/cred.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090014#include <linux/gfp.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070015#include "affs.h"
16
David Howells210f8552008-02-07 00:15:29 -080017struct inode *affs_iget(struct super_block *sb, unsigned long ino)
Linus Torvalds1da177e2005-04-16 15:20:36 -070018{
Linus Torvalds1da177e2005-04-16 15:20:36 -070019 struct affs_sb_info *sbi = AFFS_SB(sb);
20 struct buffer_head *bh;
Linus Torvalds1da177e2005-04-16 15:20:36 -070021 struct affs_tail *tail;
David Howells210f8552008-02-07 00:15:29 -080022 struct inode *inode;
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 u32 block;
24 u32 size;
25 u32 prot;
26 u16 id;
27
David Howells210f8552008-02-07 00:15:29 -080028 inode = iget_locked(sb, ino);
29 if (!inode)
30 return ERR_PTR(-ENOMEM);
31 if (!(inode->i_state & I_NEW))
32 return inode;
33
Fabian Frederick9606d9a2014-06-06 14:37:25 -070034 pr_debug("affs_iget(%lu)\n", inode->i_ino);
Linus Torvalds1da177e2005-04-16 15:20:36 -070035
36 block = inode->i_ino;
37 bh = affs_bread(sb, block);
38 if (!bh) {
39 affs_warning(sb, "read_inode", "Cannot read block %d", block);
40 goto bad_inode;
41 }
42 if (affs_checksum_block(sb, bh) || be32_to_cpu(AFFS_HEAD(bh)->ptype) != T_SHORT) {
43 affs_warning(sb,"read_inode",
44 "Checksum or type (ptype=%d) error on inode %d",
45 AFFS_HEAD(bh)->ptype, block);
46 goto bad_inode;
47 }
48
Linus Torvalds1da177e2005-04-16 15:20:36 -070049 tail = AFFS_TAIL(sb, bh);
50 prot = be32_to_cpu(tail->protect);
51
52 inode->i_size = 0;
Miklos Szeredibfe86842011-10-28 14:13:29 +020053 set_nlink(inode, 1);
Linus Torvalds1da177e2005-04-16 15:20:36 -070054 inode->i_mode = 0;
55 AFFS_I(inode)->i_extcnt = 1;
56 AFFS_I(inode)->i_ext_last = ~1;
57 AFFS_I(inode)->i_protect = prot;
Roman Zippeldca3c332008-04-29 17:02:20 +020058 atomic_set(&AFFS_I(inode)->i_opencnt, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 AFFS_I(inode)->i_blkcnt = 0;
60 AFFS_I(inode)->i_lc = NULL;
61 AFFS_I(inode)->i_lc_size = 0;
62 AFFS_I(inode)->i_lc_shift = 0;
63 AFFS_I(inode)->i_lc_mask = 0;
64 AFFS_I(inode)->i_ac = NULL;
65 AFFS_I(inode)->i_ext_bh = NULL;
66 AFFS_I(inode)->mmu_private = 0;
67 AFFS_I(inode)->i_lastalloc = 0;
68 AFFS_I(inode)->i_pa_cnt = 0;
69
Fabian Frederick79bda4d2015-04-16 12:48:24 -070070 if (affs_test_opt(sbi->s_flags, SF_SETMODE))
Linus Torvalds1da177e2005-04-16 15:20:36 -070071 inode->i_mode = sbi->s_mode;
72 else
Fabian Frederickc1618202017-02-27 14:27:54 -080073 inode->i_mode = affs_prot_to_mode(prot);
Linus Torvalds1da177e2005-04-16 15:20:36 -070074
75 id = be16_to_cpu(tail->uid);
Fabian Frederick79bda4d2015-04-16 12:48:24 -070076 if (id == 0 || affs_test_opt(sbi->s_flags, SF_SETUID))
Linus Torvalds1da177e2005-04-16 15:20:36 -070077 inode->i_uid = sbi->s_uid;
Fabian Frederick79bda4d2015-04-16 12:48:24 -070078 else if (id == 0xFFFF && affs_test_opt(sbi->s_flags, SF_MUFS))
Eric W. Biederman8fed10b2012-02-07 16:20:16 -080079 i_uid_write(inode, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 else
Eric W. Biederman8fed10b2012-02-07 16:20:16 -080081 i_uid_write(inode, id);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082
83 id = be16_to_cpu(tail->gid);
Fabian Frederick79bda4d2015-04-16 12:48:24 -070084 if (id == 0 || affs_test_opt(sbi->s_flags, SF_SETGID))
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 inode->i_gid = sbi->s_gid;
Fabian Frederick79bda4d2015-04-16 12:48:24 -070086 else if (id == 0xFFFF && affs_test_opt(sbi->s_flags, SF_MUFS))
Eric W. Biederman8fed10b2012-02-07 16:20:16 -080087 i_gid_write(inode, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070088 else
Eric W. Biederman8fed10b2012-02-07 16:20:16 -080089 i_gid_write(inode, id);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090
91 switch (be32_to_cpu(tail->stype)) {
92 case ST_ROOT:
93 inode->i_uid = sbi->s_uid;
94 inode->i_gid = sbi->s_gid;
95 /* fall through */
96 case ST_USERDIR:
97 if (be32_to_cpu(tail->stype) == ST_USERDIR ||
Fabian Frederick79bda4d2015-04-16 12:48:24 -070098 affs_test_opt(sbi->s_flags, SF_SETMODE)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -070099 if (inode->i_mode & S_IRUSR)
100 inode->i_mode |= S_IXUSR;
101 if (inode->i_mode & S_IRGRP)
102 inode->i_mode |= S_IXGRP;
103 if (inode->i_mode & S_IROTH)
104 inode->i_mode |= S_IXOTH;
105 inode->i_mode |= S_IFDIR;
106 } else
107 inode->i_mode = S_IRUGO | S_IXUGO | S_IWUSR | S_IFDIR;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 /* Maybe it should be controlled by mount parameter? */
109 //inode->i_mode |= S_ISVTX;
110 inode->i_op = &affs_dir_inode_operations;
111 inode->i_fop = &affs_dir_operations;
112 break;
113 case ST_LINKDIR:
114#if 0
115 affs_warning(sb, "read_inode", "inode is LINKDIR");
116 goto bad_inode;
117#else
118 inode->i_mode |= S_IFDIR;
Al Viroc765d472008-12-04 09:50:55 -0500119 /* ... and leave ->i_op and ->i_fop pointing to empty */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 break;
121#endif
122 case ST_LINKFILE:
123 affs_warning(sb, "read_inode", "inode is LINKFILE");
124 goto bad_inode;
125 case ST_FILE:
126 size = be32_to_cpu(tail->size);
127 inode->i_mode |= S_IFREG;
128 AFFS_I(inode)->mmu_private = inode->i_size = size;
129 if (inode->i_size) {
130 AFFS_I(inode)->i_blkcnt = (size - 1) /
131 sbi->s_data_blksize + 1;
132 AFFS_I(inode)->i_extcnt = (AFFS_I(inode)->i_blkcnt - 1) /
133 sbi->s_hashsize + 1;
134 }
135 if (tail->link_chain)
Miklos Szeredibfe86842011-10-28 14:13:29 +0200136 set_nlink(inode, 2);
Fabian Frederick79bda4d2015-04-16 12:48:24 -0700137 inode->i_mapping->a_ops = affs_test_opt(sbi->s_flags, SF_OFS) ?
Fabian Fredericka0016ff2015-04-16 12:48:15 -0700138 &affs_aops_ofs : &affs_aops;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 inode->i_op = &affs_file_inode_operations;
140 inode->i_fop = &affs_file_operations;
141 break;
142 case ST_SOFTLINK:
Fabian Frederickf1bf9072017-04-15 08:54:36 +0200143 inode->i_size = strlen((char *)AFFS_HEAD(bh)->table);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700144 inode->i_mode |= S_IFLNK;
Al Viro21fc61c2015-11-17 01:07:57 -0500145 inode_nohighmem(inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700146 inode->i_op = &affs_symlink_inode_operations;
147 inode->i_data.a_ops = &affs_symlink_aops;
148 break;
149 }
150
151 inode->i_mtime.tv_sec = inode->i_atime.tv_sec = inode->i_ctime.tv_sec
152 = (be32_to_cpu(tail->change.days) * (24 * 60 * 60) +
153 be32_to_cpu(tail->change.mins) * 60 +
154 be32_to_cpu(tail->change.ticks) / 50 +
155 ((8 * 365 + 2) * 24 * 60 * 60)) +
156 sys_tz.tz_minuteswest * 60;
157 inode->i_mtime.tv_nsec = inode->i_ctime.tv_nsec = inode->i_atime.tv_nsec = 0;
158 affs_brelse(bh);
David Howells210f8552008-02-07 00:15:29 -0800159 unlock_new_inode(inode);
160 return inode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161
162bad_inode:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 affs_brelse(bh);
David Howells210f8552008-02-07 00:15:29 -0800164 iget_failed(inode);
165 return ERR_PTR(-EIO);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700166}
167
168int
Christoph Hellwiga9185b42010-03-05 09:21:37 +0100169affs_write_inode(struct inode *inode, struct writeback_control *wbc)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170{
171 struct super_block *sb = inode->i_sb;
172 struct buffer_head *bh;
173 struct affs_tail *tail;
174 uid_t uid;
175 gid_t gid;
176
Fabian Frederick9606d9a2014-06-06 14:37:25 -0700177 pr_debug("write_inode(%lu)\n", inode->i_ino);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178
179 if (!inode->i_nlink)
180 // possibly free block
181 return 0;
182 bh = affs_bread(sb, inode->i_ino);
183 if (!bh) {
184 affs_error(sb,"write_inode","Cannot read block %lu",inode->i_ino);
185 return -EIO;
186 }
187 tail = AFFS_TAIL(sb, bh);
188 if (tail->stype == cpu_to_be32(ST_ROOT)) {
Fabian Frederickc1618202017-02-27 14:27:54 -0800189 affs_secs_to_datestamp(inode->i_mtime.tv_sec,
190 &AFFS_ROOT_TAIL(sb, bh)->root_change);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 } else {
192 tail->protect = cpu_to_be32(AFFS_I(inode)->i_protect);
193 tail->size = cpu_to_be32(inode->i_size);
Fabian Frederickc1618202017-02-27 14:27:54 -0800194 affs_secs_to_datestamp(inode->i_mtime.tv_sec, &tail->change);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 if (!(inode->i_ino == AFFS_SB(sb)->s_root_block)) {
Eric W. Biederman8fed10b2012-02-07 16:20:16 -0800196 uid = i_uid_read(inode);
197 gid = i_gid_read(inode);
Fabian Frederick79bda4d2015-04-16 12:48:24 -0700198 if (affs_test_opt(AFFS_SB(sb)->s_flags, SF_MUFS)) {
Eric W. Biederman8fed10b2012-02-07 16:20:16 -0800199 if (uid == 0 || uid == 0xFFFF)
200 uid = uid ^ ~0;
201 if (gid == 0 || gid == 0xFFFF)
202 gid = gid ^ ~0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203 }
Fabian Frederick79bda4d2015-04-16 12:48:24 -0700204 if (!affs_test_opt(AFFS_SB(sb)->s_flags, SF_SETUID))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 tail->uid = cpu_to_be16(uid);
Fabian Frederick79bda4d2015-04-16 12:48:24 -0700206 if (!affs_test_opt(AFFS_SB(sb)->s_flags, SF_SETGID))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 tail->gid = cpu_to_be16(gid);
208 }
209 }
210 affs_fix_checksum(sb, bh);
211 mark_buffer_dirty_inode(bh, inode);
212 affs_brelse(bh);
213 affs_free_prealloc(inode);
214 return 0;
215}
216
217int
218affs_notify_change(struct dentry *dentry, struct iattr *attr)
219{
David Howells2b0143b2015-03-17 22:25:59 +0000220 struct inode *inode = d_inode(dentry);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 int error;
222
Fabian Frederick9606d9a2014-06-06 14:37:25 -0700223 pr_debug("notify_change(%lu,0x%x)\n", inode->i_ino, attr->ia_valid);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700224
Jan Kara31051c82016-05-26 16:55:18 +0200225 error = setattr_prepare(dentry, attr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 if (error)
227 goto out;
228
Fabian Fredericka0016ff2015-04-16 12:48:15 -0700229 if (((attr->ia_valid & ATTR_UID) &&
Fabian Frederick79bda4d2015-04-16 12:48:24 -0700230 affs_test_opt(AFFS_SB(inode->i_sb)->s_flags, SF_SETUID)) ||
Fabian Fredericka0016ff2015-04-16 12:48:15 -0700231 ((attr->ia_valid & ATTR_GID) &&
Fabian Frederick79bda4d2015-04-16 12:48:24 -0700232 affs_test_opt(AFFS_SB(inode->i_sb)->s_flags, SF_SETGID)) ||
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 ((attr->ia_valid & ATTR_MODE) &&
Fabian Fredericka0016ff2015-04-16 12:48:15 -0700234 (AFFS_SB(inode->i_sb)->s_flags &
235 (AFFS_MOUNT_SF_SETMODE | AFFS_MOUNT_SF_IMMUTABLE)))) {
Fabian Frederick79bda4d2015-04-16 12:48:24 -0700236 if (!affs_test_opt(AFFS_SB(inode->i_sb)->s_flags, SF_QUIET))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 error = -EPERM;
238 goto out;
239 }
240
Christoph Hellwig10257742010-06-04 11:30:02 +0200241 if ((attr->ia_valid & ATTR_SIZE) &&
242 attr->ia_size != i_size_read(inode)) {
Marco Stornelli1dc18342012-12-15 11:51:53 +0100243 error = inode_newsize_ok(inode, attr->ia_size);
Christoph Hellwig10257742010-06-04 11:30:02 +0200244 if (error)
245 return error;
Marco Stornelli1dc18342012-12-15 11:51:53 +0100246
247 truncate_setsize(inode, attr->ia_size);
248 affs_truncate(inode);
Christoph Hellwig10257742010-06-04 11:30:02 +0200249 }
250
251 setattr_copy(inode, attr);
252 mark_inode_dirty(inode);
253
254 if (attr->ia_valid & ATTR_MODE)
Fabian Frederickc1618202017-02-27 14:27:54 -0800255 affs_mode_to_prot(inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256out:
257 return error;
258}
259
260void
Al Virof053ddd2010-06-06 10:16:41 -0400261affs_evict_inode(struct inode *inode)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262{
Roman Zippeldca3c332008-04-29 17:02:20 +0200263 unsigned long cache_page;
Fabian Frederick9606d9a2014-06-06 14:37:25 -0700264 pr_debug("evict_inode(ino=%lu, nlink=%u)\n",
265 inode->i_ino, inode->i_nlink);
Johannes Weiner91b0abe2014-04-03 14:47:49 -0700266 truncate_inode_pages_final(&inode->i_data);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700267
Al Virof053ddd2010-06-06 10:16:41 -0400268 if (!inode->i_nlink) {
269 inode->i_size = 0;
270 affs_truncate(inode);
271 }
Roman Zippeldca3c332008-04-29 17:02:20 +0200272
Al Virof053ddd2010-06-06 10:16:41 -0400273 invalidate_inode_buffers(inode);
Jan Karadbd57682012-05-03 14:48:02 +0200274 clear_inode(inode);
Roman Zippeldca3c332008-04-29 17:02:20 +0200275 affs_free_prealloc(inode);
276 cache_page = (unsigned long)AFFS_I(inode)->i_lc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 if (cache_page) {
Fabian Frederick9606d9a2014-06-06 14:37:25 -0700278 pr_debug("freeing ext cache\n");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279 AFFS_I(inode)->i_lc = NULL;
280 AFFS_I(inode)->i_ac = NULL;
281 free_page(cache_page);
282 }
283 affs_brelse(AFFS_I(inode)->i_ext_bh);
284 AFFS_I(inode)->i_ext_last = ~1;
285 AFFS_I(inode)->i_ext_bh = NULL;
Al Virof053ddd2010-06-06 10:16:41 -0400286
287 if (!inode->i_nlink)
288 affs_free_block(inode->i_sb, inode->i_ino);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289}
290
291struct inode *
292affs_new_inode(struct inode *dir)
293{
294 struct super_block *sb = dir->i_sb;
295 struct inode *inode;
296 u32 block;
297 struct buffer_head *bh;
298
299 if (!(inode = new_inode(sb)))
300 goto err_inode;
301
302 if (!(block = affs_alloc_block(dir, dir->i_ino)))
303 goto err_block;
304
305 bh = affs_getzeroblk(sb, block);
306 if (!bh)
307 goto err_bh;
308 mark_buffer_dirty_inode(bh, inode);
309 affs_brelse(bh);
310
David Howells21559982008-11-14 10:38:45 +1100311 inode->i_uid = current_fsuid();
312 inode->i_gid = current_fsgid();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700313 inode->i_ino = block;
Miklos Szeredibfe86842011-10-28 14:13:29 +0200314 set_nlink(inode, 1);
Deepa Dinamani02027d42016-09-14 07:48:05 -0700315 inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
Roman Zippeldca3c332008-04-29 17:02:20 +0200316 atomic_set(&AFFS_I(inode)->i_opencnt, 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 AFFS_I(inode)->i_blkcnt = 0;
318 AFFS_I(inode)->i_lc = NULL;
319 AFFS_I(inode)->i_lc_size = 0;
320 AFFS_I(inode)->i_lc_shift = 0;
321 AFFS_I(inode)->i_lc_mask = 0;
322 AFFS_I(inode)->i_ac = NULL;
323 AFFS_I(inode)->i_ext_bh = NULL;
324 AFFS_I(inode)->mmu_private = 0;
325 AFFS_I(inode)->i_protect = 0;
326 AFFS_I(inode)->i_lastalloc = 0;
327 AFFS_I(inode)->i_pa_cnt = 0;
328 AFFS_I(inode)->i_extcnt = 1;
329 AFFS_I(inode)->i_ext_last = ~1;
330
331 insert_inode_hash(inode);
332
333 return inode;
334
335err_bh:
336 affs_free_block(sb, block);
337err_block:
338 iput(inode);
339err_inode:
340 return NULL;
341}
342
343/*
344 * Add an entry to a directory. Create the header block
345 * and insert it into the hash table.
346 */
347
348int
349affs_add_entry(struct inode *dir, struct inode *inode, struct dentry *dentry, s32 type)
350{
351 struct super_block *sb = dir->i_sb;
352 struct buffer_head *inode_bh = NULL;
Fabian Frederick78f444f2015-06-30 14:57:55 -0700353 struct buffer_head *bh;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700354 u32 block = 0;
355 int retval;
356
Geert Uytterhoeven08fe1002015-02-17 13:46:10 -0800357 pr_debug("%s(dir=%lu, inode=%lu, \"%pd\", type=%d)\n", __func__,
358 dir->i_ino, inode->i_ino, dentry, type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359
360 retval = -EIO;
361 bh = affs_bread(sb, inode->i_ino);
362 if (!bh)
363 goto done;
364
365 affs_lock_link(inode);
366 switch (type) {
367 case ST_LINKFILE:
368 case ST_LINKDIR:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700369 retval = -ENOSPC;
370 block = affs_alloc_block(dir, dir->i_ino);
371 if (!block)
372 goto err;
373 retval = -EIO;
Roman Zippeldca3c332008-04-29 17:02:20 +0200374 inode_bh = bh;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 bh = affs_getzeroblk(sb, block);
376 if (!bh)
377 goto err;
378 break;
379 default:
380 break;
381 }
382
383 AFFS_HEAD(bh)->ptype = cpu_to_be32(T_SHORT);
384 AFFS_HEAD(bh)->key = cpu_to_be32(bh->b_blocknr);
385 affs_copy_name(AFFS_TAIL(sb, bh)->name, dentry);
386 AFFS_TAIL(sb, bh)->stype = cpu_to_be32(type);
387 AFFS_TAIL(sb, bh)->parent = cpu_to_be32(dir->i_ino);
388
389 if (inode_bh) {
390 __be32 chain;
391 chain = AFFS_TAIL(sb, inode_bh)->link_chain;
392 AFFS_TAIL(sb, bh)->original = cpu_to_be32(inode->i_ino);
393 AFFS_TAIL(sb, bh)->link_chain = chain;
394 AFFS_TAIL(sb, inode_bh)->link_chain = cpu_to_be32(block);
395 affs_adjust_checksum(inode_bh, block - be32_to_cpu(chain));
396 mark_buffer_dirty_inode(inode_bh, inode);
Miklos Szeredibfe86842011-10-28 14:13:29 +0200397 set_nlink(inode, 2);
Al Viro7de9c6ee2010-10-23 11:11:40 -0400398 ihold(inode);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 }
400 affs_fix_checksum(sb, bh);
401 mark_buffer_dirty_inode(bh, inode);
402 dentry->d_fsdata = (void *)(long)bh->b_blocknr;
403
404 affs_lock_dir(dir);
405 retval = affs_insert_hash(dir, bh);
406 mark_buffer_dirty_inode(bh, inode);
407 affs_unlock_dir(dir);
408 affs_unlock_link(inode);
409
410 d_instantiate(dentry, inode);
411done:
412 affs_brelse(inode_bh);
413 affs_brelse(bh);
414 return retval;
415err:
416 if (block)
417 affs_free_block(sb, block);
418 affs_unlock_link(inode);
419 goto done;
420}