diff options
author | Jan Kara <jack@suse.cz> | 2011-04-27 18:20:44 +0200 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2011-04-29 23:20:17 +0200 |
commit | 05b2fb6840ae3631bbe5f7b5fc26c603381f62d9 (patch) | |
tree | f542a64fce435cdf29cd127a1222b817eb5610ac /fs | |
parent | ae54870a1dc978a88377ae8af0780648f2ccd4dc (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.
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext3/namei.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index f6ce3e79d315..9b9d89818ef1 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c @@ -1417,9 +1417,19 @@ static int make_indexed_dir(handle_t *handle, struct dentry *dentry, frame->bh = bh; bh = bh2; de = do_split(handle,dir, &bh, frame, &hinfo, &retval); - dx_release (frames); - if (!(de)) + if (!de) { + /* + * Even if the block split failed, we have to properly write + * out all the changes we did so far. Otherwise we can end up + * with corrupted filesystem. + */ + ext3_mark_inode_dirty(handle, dir); + ext3_journal_dirty_metadata(handle, frame->bh); + ext3_journal_dirty_metadata(handle, bh); + dx_release(frames); return retval; + } + dx_release(frames); return add_dirent_to_buf(handle, dentry, inode, de, bh); } @@ -2282,7 +2292,7 @@ out_stop: return err; err_drop_inode: unlock_new_inode(inode); - iput (inode); + iput(inode); return err; } |