Skip to contentSkip to conversation

ocfs2: set filesytem read-only when ocfs2_delete_entry failed.

PATCH Superseded jiangyiwen 1 participant 1 message Apr 15, 2015 OCFS2

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

jiangyiwen

author
#0 lore raw

PATCH 1/1 ocfs2: set filesytem read-only when ocfs2_delete_entry failed.

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.

---
 fs/ocfs2/namei.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
fs/ocfs2/namei.c +10 -1
index b5c3a5e..6f2f36d 100644
@@ -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