From: Namhyung Kim <namhyung@gmail.com>
To: Jan Kara <jack@suse.cz>,
Andrew Morton <akpm@linux-foundation.org>,
Andreas Dilger <adilger.kernel@dilger.ca>
Cc: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] ext3: Add journal error check into ext3_rename()
Date: Fri, 19 Nov 2010 16:28:36 +0900 [thread overview]
Message-ID: <1290151716-4041-2-git-send-email-namhyung@gmail.com> (raw)
In-Reply-To: <1290151716-4041-1-git-send-email-namhyung@gmail.com>
Check return value of ext3_journal_get_write_access() and
ext3_journal_dirty_metadata(). 'new_bh' should be kept in
order to get revoked in case of journal error in dir_bh.
Signed-off-by: Namhyung Kim <namhyung@gmail.com>
---
fs/ext3/namei.c | 27 +++++++++++++++++++++------
1 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c
index 672cea1..8061281 100644
--- a/fs/ext3/namei.c
+++ b/fs/ext3/namei.c
@@ -2371,7 +2371,9 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
goto end_rename;
} else {
BUFFER_TRACE(new_bh, "get write access");
- ext3_journal_get_write_access(handle, new_bh);
+ retval = ext3_journal_get_write_access(handle, new_bh);
+ if (retval)
+ goto journal_error1;
new_de->inode = cpu_to_le32(old_inode->i_ino);
if (EXT3_HAS_INCOMPAT_FEATURE(new_dir->i_sb,
EXT3_FEATURE_INCOMPAT_FILETYPE))
@@ -2380,9 +2382,12 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
new_dir->i_ctime = new_dir->i_mtime = CURRENT_TIME_SEC;
ext3_mark_inode_dirty(handle, new_dir);
BUFFER_TRACE(new_bh, "call ext3_journal_dirty_metadata");
- ext3_journal_dirty_metadata(handle, new_bh);
- brelse(new_bh);
- new_bh = NULL;
+ retval = ext3_journal_dirty_metadata(handle, new_bh);
+ if (retval) {
+journal_error1:
+ ext3_std_error(new_dir->i_sb, retval);
+ goto end_rename;
+ }
}
/*
@@ -2429,10 +2434,20 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
ext3_update_dx_flag(old_dir);
if (dir_bh) {
BUFFER_TRACE(dir_bh, "get_write_access");
- ext3_journal_get_write_access(handle, dir_bh);
+ retval = ext3_journal_get_write_access(handle, dir_bh);
+ if (retval)
+ goto journal_error2;
PARENT_INO(dir_bh->b_data) = cpu_to_le32(new_dir->i_ino);
BUFFER_TRACE(dir_bh, "call ext3_journal_dirty_metadata");
- ext3_journal_dirty_metadata(handle, dir_bh);
+ retval = ext3_journal_dirty_metadata(handle, dir_bh);
+ if (retval) {
+journal_error2:
+ if (new_bh)
+ ext3_journal_revoke(handle, new_bh->b_blocknr,
+ new_bh);
+ ext3_std_error(new_dir->i_sb, retval);
+ goto end_rename;
+ }
drop_nlink(old_dir);
if (new_inode) {
drop_nlink(new_inode);
--
1.7.0.4
next prev parent reply other threads:[~2010-11-19 7:28 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-19 7:28 [PATCH 1/2] ext3: Add journal error check into ext3_delete_entry() Namhyung Kim
2010-11-19 7:28 ` Namhyung Kim [this message]
2010-11-22 18:05 ` [PATCH 2/2] ext3: Add journal error check into ext3_rename() Jan Kara
2010-11-23 3:37 ` Namhyung Kim
2010-11-22 17:55 ` [PATCH 1/2] ext3: Add journal error check into ext3_delete_entry() Jan Kara
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1290151716-4041-2-git-send-email-namhyung@gmail.com \
--to=namhyung@gmail.com \
--cc=adilger.kernel@dilger.ca \
--cc=akpm@linux-foundation.org \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).