aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext4
diff options
context:
space:
mode:
authorAmir Goldstein <amir73il@gmail.com>2011-03-20 21:18:44 -0400
committerTheodore Ts'o <tytso@mit.edu>2011-03-20 21:18:44 -0400
commitef6078930263bfcdcfe4dddb2cd85254b4cf4f5c (patch)
tree78ad55a45c5df9be3be1453c2fc36e98d3c2196b /fs/ext4
parent93737456d68ddcb86232f669b83da673dd12e351 (diff)
ext4: handle errors in ext4_rename
Checking return code from ext4_journal_get_write_access() is important with snapshots, because this function invokes COW, so may return new errors, such as ENOSPC. We move the call to ext4_journal_get_write_access earlier in the function, to simplify error handling in the case that this function returns returns an error. Signed-off-by: Amir Goldstein <amir73il@users.sf.net> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'fs/ext4')
-rw-r--r--fs/ext4/namei.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 5485390d32c5..ad87584aa8d2 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2409,6 +2409,10 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
2409 if (!new_inode && new_dir != old_dir && 2409 if (!new_inode && new_dir != old_dir &&
2410 EXT4_DIR_LINK_MAX(new_dir)) 2410 EXT4_DIR_LINK_MAX(new_dir))
2411 goto end_rename; 2411 goto end_rename;
2412 BUFFER_TRACE(dir_bh, "get_write_access");
2413 retval = ext4_journal_get_write_access(handle, dir_bh);
2414 if (retval)
2415 goto end_rename;
2412 } 2416 }
2413 if (!new_bh) { 2417 if (!new_bh) {
2414 retval = ext4_add_entry(handle, new_dentry, old_inode); 2418 retval = ext4_add_entry(handle, new_dentry, old_inode);
@@ -2416,7 +2420,9 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
2416 goto end_rename; 2420 goto end_rename;
2417 } else { 2421 } else {
2418 BUFFER_TRACE(new_bh, "get write access"); 2422 BUFFER_TRACE(new_bh, "get write access");
2419 ext4_journal_get_write_access(handle, new_bh); 2423 retval = ext4_journal_get_write_access(handle, new_bh);
2424 if (retval)
2425 goto end_rename;
2420 new_de->inode = cpu_to_le32(old_inode->i_ino); 2426 new_de->inode = cpu_to_le32(old_inode->i_ino);
2421 if (EXT4_HAS_INCOMPAT_FEATURE(new_dir->i_sb, 2427 if (EXT4_HAS_INCOMPAT_FEATURE(new_dir->i_sb,
2422 EXT4_FEATURE_INCOMPAT_FILETYPE)) 2428 EXT4_FEATURE_INCOMPAT_FILETYPE))
@@ -2477,8 +2483,6 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry,
2477 old_dir->i_ctime = old_dir->i_mtime = ext4_current_time(old_dir); 2483 old_dir->i_ctime = old_dir->i_mtime = ext4_current_time(old_dir);
2478 ext4_update_dx_flag(old_dir); 2484 ext4_update_dx_flag(old_dir);
2479 if (dir_bh) { 2485 if (dir_bh) {
2480 BUFFER_TRACE(dir_bh, "get_write_access");
2481 ext4_journal_get_write_access(handle, dir_bh);
2482 PARENT_INO(dir_bh->b_data, new_dir->i_sb->s_blocksize) = 2486 PARENT_INO(dir_bh->b_data, new_dir->i_sb->s_blocksize) =
2483 cpu_to_le32(new_dir->i_ino); 2487 cpu_to_le32(new_dir->i_ino);
2484 BUFFER_TRACE(dir_bh, "call ext4_handle_dirty_metadata"); 2488 BUFFER_TRACE(dir_bh, "call ext4_handle_dirty_metadata");