aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2011-04-27 12:20:44 -0400
committerJan Kara <jack@suse.cz>2011-05-17 07:47:15 -0400
commit86c4f6d85595cd7da635dc6985d27bfa43b1ae10 (patch)
treeef129a2eebdf5cfbecc0ddfbef96b26590242c3d
parentae54870a1dc978a88377ae8af0780648f2ccd4dc (diff)
ext3: Fix fs corruption when make_indexed_dir() fails
When make_indexed_dir() fails (e.g. because of ENOSPC) after it has allocated block for index tree root, we did not properly mark all changed buffers dirty. This lead to only some of these buffers being written out and thus effectively corrupting the directory. Fix the issue by marking all changed data dirty even in the error failure case. CC: stable@kernel.org Signed-off-by: Jan Kara <jack@suse.cz>
-rw-r--r--fs/ext3/namei.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index f6ce3e79d315..34b6d9bfc48a 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -1416,10 +1416,19 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry,
1416 frame->at = entries; 1416 frame->at = entries;
1417 frame->bh = bh; 1417 frame->bh = bh;
1418 bh = bh2; 1418 bh = bh2;
1419 /*
1420 * Mark buffers dirty here so that if do_split() fails we write a
1421 * consistent set of buffers to disk.
1422 */
1423 ext3_journal_dirty_metadata(handle, frame->bh);
1424 ext3_journal_dirty_metadata(handle, bh);
1419 de = do_split(handle,dir, &bh, frame, &hinfo, &retval); 1425 de = do_split(handle,dir, &bh, frame, &hinfo, &retval);
1420 dx_release (frames); 1426 if (!de) {
1421 if (!(de)) 1427 ext3_mark_inode_dirty(handle, dir);
1428 dx_release(frames);
1422 return retval; 1429 return retval;
1430 }
1431 dx_release(frames);
1423 1432
1424 return add_dirent_to_buf(handle, dentry, inode, de, bh); 1433 return add_dirent_to_buf(handle, dentry, inode, de, bh);
1425} 1434}
@@ -2282,7 +2291,7 @@ out_stop:
2282 return err; 2291 return err;
2283err_drop_inode: 2292err_drop_inode:
2284 unlock_new_inode(inode); 2293 unlock_new_inode(inode);
2285 iput (inode); 2294 iput(inode);
2286 return err; 2295 return err;
2287} 2296}
2288 2297