diff options
author | Boaz Harrosh <bharrosh@panasas.com> | 2010-10-16 04:14:01 -0400 |
---|---|---|
committer | Boaz Harrosh <bharrosh@panasas.com> | 2010-10-25 12:03:07 -0400 |
commit | fe2fd9ed5bf184f797412be8b86f4589d1b77bb8 (patch) | |
tree | 45677902196a26d12a9eb56a663e0a9787cc2cae /fs/exofs | |
parent | 571f7f46bf367b29f574ca51a9ca1db5035602bb (diff) |
exofs: Remove inode->i_count manipulation in exofs_new_inode
exofs_new_inode() was incrementing the inode->i_count and
decrementing it in create_done(), in a bad attempt to make sure
the inode will still be there when the asynchronous create_done()
finally arrives. This was very stupid because iput() was not called,
and if it was actually needed, it would leak the inode.
However all this is not needed, because at exofs_evict_inode()
we already wait for create_done() by waiting for the
object_created event. Therefore remove the superfluous ref counting
and just Thicken the comment at exofs_evict_inode() a bit.
While at it change places that open coded wait_obj_created()
to call the already available wrapper.
CC: Dave Chinner <dchinner@redhat.com>
CC: Christoph Hellwig <hch@lst.de>
CC: Nick Piggin <npiggin@kernel.dk>
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Diffstat (limited to 'fs/exofs')
-rw-r--r-- | fs/exofs/inode.c | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c index f5f8ce03c2f3..42685424817b 100644 --- a/fs/exofs/inode.c +++ b/fs/exofs/inode.c | |||
@@ -1067,8 +1067,10 @@ bad_inode: | |||
1067 | int __exofs_wait_obj_created(struct exofs_i_info *oi) | 1067 | int __exofs_wait_obj_created(struct exofs_i_info *oi) |
1068 | { | 1068 | { |
1069 | if (!obj_created(oi)) { | 1069 | if (!obj_created(oi)) { |
1070 | EXOFS_DBGMSG("!obj_created\n"); | ||
1070 | BUG_ON(!obj_2bcreated(oi)); | 1071 | BUG_ON(!obj_2bcreated(oi)); |
1071 | wait_event(oi->i_wq, obj_created(oi)); | 1072 | wait_event(oi->i_wq, obj_created(oi)); |
1073 | EXOFS_DBGMSG("wait_event done\n"); | ||
1072 | } | 1074 | } |
1073 | return unlikely(is_bad_inode(&oi->vfs_inode)) ? -EIO : 0; | 1075 | return unlikely(is_bad_inode(&oi->vfs_inode)) ? -EIO : 0; |
1074 | } | 1076 | } |
@@ -1102,7 +1104,6 @@ static void create_done(struct exofs_io_state *ios, void *p) | |||
1102 | 1104 | ||
1103 | set_obj_created(oi); | 1105 | set_obj_created(oi); |
1104 | 1106 | ||
1105 | atomic_dec(&inode->i_count); | ||
1106 | wake_up(&oi->i_wq); | 1107 | wake_up(&oi->i_wq); |
1107 | } | 1108 | } |
1108 | 1109 | ||
@@ -1153,17 +1154,11 @@ struct inode *exofs_new_inode(struct inode *dir, int mode) | |||
1153 | ios->obj.id = exofs_oi_objno(oi); | 1154 | ios->obj.id = exofs_oi_objno(oi); |
1154 | exofs_make_credential(oi->i_cred, &ios->obj); | 1155 | exofs_make_credential(oi->i_cred, &ios->obj); |
1155 | 1156 | ||
1156 | /* increment the refcount so that the inode will still be around when we | ||
1157 | * reach the callback | ||
1158 | */ | ||
1159 | atomic_inc(&inode->i_count); | ||
1160 | |||
1161 | ios->done = create_done; | 1157 | ios->done = create_done; |
1162 | ios->private = inode; | 1158 | ios->private = inode; |
1163 | ios->cred = oi->i_cred; | 1159 | ios->cred = oi->i_cred; |
1164 | ret = exofs_sbi_create(ios); | 1160 | ret = exofs_sbi_create(ios); |
1165 | if (ret) { | 1161 | if (ret) { |
1166 | atomic_dec(&inode->i_count); | ||
1167 | exofs_put_io_state(ios); | 1162 | exofs_put_io_state(ios); |
1168 | return ERR_PTR(ret); | 1163 | return ERR_PTR(ret); |
1169 | } | 1164 | } |
@@ -1253,12 +1248,7 @@ static int exofs_update_inode(struct inode *inode, int do_sync) | |||
1253 | ios->out_attr_len = 1; | 1248 | ios->out_attr_len = 1; |
1254 | ios->out_attr = &attr; | 1249 | ios->out_attr = &attr; |
1255 | 1250 | ||
1256 | if (!obj_created(oi)) { | 1251 | wait_obj_created(oi); |
1257 | EXOFS_DBGMSG("!obj_created\n"); | ||
1258 | BUG_ON(!obj_2bcreated(oi)); | ||
1259 | wait_event(oi->i_wq, obj_created(oi)); | ||
1260 | EXOFS_DBGMSG("wait_event done\n"); | ||
1261 | } | ||
1262 | 1252 | ||
1263 | if (!do_sync) { | 1253 | if (!do_sync) { |
1264 | args->sbi = sbi; | 1254 | args->sbi = sbi; |
@@ -1321,12 +1311,12 @@ void exofs_evict_inode(struct inode *inode) | |||
1321 | inode->i_size = 0; | 1311 | inode->i_size = 0; |
1322 | end_writeback(inode); | 1312 | end_writeback(inode); |
1323 | 1313 | ||
1324 | /* if we are deleting an obj that hasn't been created yet, wait */ | 1314 | /* if we are deleting an obj that hasn't been created yet, wait. |
1325 | if (!obj_created(oi)) { | 1315 | * This also makes sure that create_done cannot be called with an |
1326 | BUG_ON(!obj_2bcreated(oi)); | 1316 | * already evicted inode. |
1327 | wait_event(oi->i_wq, obj_created(oi)); | 1317 | */ |
1328 | /* ignore the error attempt a remove anyway */ | 1318 | wait_obj_created(oi); |
1329 | } | 1319 | /* ignore the error, attempt a remove anyway */ |
1330 | 1320 | ||
1331 | /* Now Remove the OSD objects */ | 1321 | /* Now Remove the OSD objects */ |
1332 | ret = exofs_get_io_state(&sbi->layout, &ios); | 1322 | ret = exofs_get_io_state(&sbi->layout, &ios); |