* [PATCH 1/2] ext4: handle errors in ext4_rename
@ 2011-03-01 12:17 Amir Goldstein
2011-03-21 1:23 ` Ted Ts'o
0 siblings, 1 reply; 2+ messages in thread
From: Amir Goldstein @ 2011-03-01 12:17 UTC (permalink / raw)
To: Theodore Tso; +Cc: Ext4 Developers List
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.
Getting write_access to dir_bh sooner, so rename operation can be
aborted sooner.
Signed-off-by: Amir Goldstein <amir73il@users.sf.net>
---
fs/ext4/namei.c | 10 +++++++---
1 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 5485390..ad87584 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,
if (!new_inode && new_dir != old_dir &&
EXT4_DIR_LINK_MAX(new_dir))
goto end_rename;
+ BUFFER_TRACE(dir_bh, "get_write_access");
+ retval = ext4_journal_get_write_access(handle, dir_bh);
+ if (retval)
+ goto end_rename;
}
if (!new_bh) {
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,
goto end_rename;
} else {
BUFFER_TRACE(new_bh, "get write access");
- ext4_journal_get_write_access(handle, new_bh);
+ retval = ext4_journal_get_write_access(handle, new_bh);
+ if (retval)
+ goto end_rename;
new_de->inode = cpu_to_le32(old_inode->i_ino);
if (EXT4_HAS_INCOMPAT_FEATURE(new_dir->i_sb,
EXT4_FEATURE_INCOMPAT_FILETYPE))
@@ -2477,8 +2483,6 @@ static int ext4_rename(struct inode *old_dir,
struct dentry *old_dentry,
old_dir->i_ctime = old_dir->i_mtime = ext4_current_time(old_dir);
ext4_update_dx_flag(old_dir);
if (dir_bh) {
- BUFFER_TRACE(dir_bh, "get_write_access");
- ext4_journal_get_write_access(handle, dir_bh);
PARENT_INO(dir_bh->b_data, new_dir->i_sb->s_blocksize) =
cpu_to_le32(new_dir->i_ino);
BUFFER_TRACE(dir_bh, "call ext4_handle_dirty_metadata");
--
1.7.0.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 1/2] ext4: handle errors in ext4_rename
2011-03-01 12:17 [PATCH 1/2] ext4: handle errors in ext4_rename Amir Goldstein
@ 2011-03-21 1:23 ` Ted Ts'o
0 siblings, 0 replies; 2+ messages in thread
From: Ted Ts'o @ 2011-03-21 1:23 UTC (permalink / raw)
To: Amir Goldstein; +Cc: Ext4 Developers List
Added to the ext4 patch queue.
- Ted
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-03-21 1:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-01 12:17 [PATCH 1/2] ext4: handle errors in ext4_rename Amir Goldstein
2011-03-21 1:23 ` Ted Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).