Linux ocfs2 filesystem development
 help / color / mirror / Atom feed
From: jiangyiwen <jiangyiwen@huawei.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH] ocfs2: set filesytem read-only when ocfs2_delete_entry failed.
Date: Wed, 15 Apr 2015 09:37:59 +0800	[thread overview]
Message-ID: <552DC0F7.2070303@huawei.com> (raw)

In ocfs2_rename, it will lead to an inode with two entried(old and new)
if ocfs2_delete_entry(old) failed. Thus, filesystem will be
inconsistent.
The case is described below:
ocfs2_rename
    -> ocfs2_start_trans
    -> ocfs2_add_entry(new)
    -> ocfs2_delete_entry(old)
        -> __ocfs2_journal_access *failed* because of -ENOMEM
    -> ocfs2_commit_trans
So filesystem should be set to read-only at the moment.

Signed-off-by: Yiwen Jiang <jiangyiwen@huawei.com>
---
 fs/ocfs2/namei.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index b5c3a5e..6f2f36d 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1551,12 +1551,21 @@ static int ocfs2_rename(struct inode *old_dir,
 	status = ocfs2_find_entry(old_dentry->d_name.name,
 				  old_dentry->d_name.len, old_dir,
 				  &old_entry_lookup);
-	if (status)
+	if (status) {
+		ocfs2_error(osb->sb, "new entry %.*s is added, but old entry %.*s "
+				"is not deleted.",
+				new_dentry->d_name.len, new_dentry->d_name.name,
+				old_dentry->d_name.len, old_dentry->d_name.name);
 		goto bail;
+	}

 	status = ocfs2_delete_entry(handle, old_dir, &old_entry_lookup);
 	if (status < 0) {
 		mlog_errno(status);
+		ocfs2_error(osb->sb, "new entry %.*s is added, but old entry %.*s "
+				"is not deleted.",
+				new_dentry->d_name.len, new_dentry->d_name.name,
+				old_dentry->d_name.len, old_dentry->d_name.name);
 		goto bail;
 	}

-- 1.8.3.4

                 reply	other threads:[~2015-04-15  1:37 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=552DC0F7.2070303@huawei.com \
    --to=jiangyiwen@huawei.com \
    --cc=ocfs2-devel@oss.oracle.com \
    /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