Subject: + ocfs2-fix-readonly-issue-in-ocfs2_unlink.patch added to -mm tree To: younger.liu@xxxxxxxxxx,jeff.liu@xxxxxxxxxx,jlbec@xxxxxxxxxxxx,mfasheh@xxxxxxxx,shencanquan@xxxxxxxxxx,sunil.mushran@xxxxxxxxx From: akpm@xxxxxxxxxxxxxxxxxxxx Date: Thu, 27 Jun 2013 14:59:02 -0700 The patch titled Subject: ocfs2: fix readonly issue in ocfs2_unlink() has been added to the -mm tree. Its filename is ocfs2-fix-readonly-issue-in-ocfs2_unlink.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Younger Liu <younger.liu@xxxxxxxxxx> Subject: ocfs2: fix readonly issue in ocfs2_unlink() While deleting a file with ocfs2_unlink(), there is a bug in this function. This bug will result in filesystem read-only. After calling ocfs2_orphan_add(), the file which will be deleted is added into orphan dir. If ocfs2_delete_entry() fails, the file still exists in the parent dir. And this scenario introduces a conflict of metadata. If a file is added into orphan dir, when we put inode of the file with iput(), the inode i_flags is setted (~OCFS2_VALID_FL) in ocfs2_remove_inode(), and then write back to disk. But as previously mentioned, the file still exists in the parent dir. On other nodes, the file can be still accessed. When first read the file with ocfs2_read_blocks() from disk, It will check and avalidate inode using ocfs2_validate_inode_block(). So File system will be readonly because the inode is invalid. In other words, the inode i_flags has been set (~OCFS2_VALID_FL). Signed-off-by: Younger Liu <younger.liu@xxxxxxxxxx> Signed-off-by: Jensen <shencanquan@xxxxxxxxxx> Cc: Jie Liu <jeff.liu@xxxxxxxxxx> Cc: Joel Becker <jlbec@xxxxxxxxxxxx> Cc: Mark Fasheh <mfasheh@xxxxxxxx> Cc: Sunil Mushran <sunil.mushran@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- fs/ocfs2/namei.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff -puN fs/ocfs2/namei.c~ocfs2-fix-readonly-issue-in-ocfs2_unlink fs/ocfs2/namei.c --- a/fs/ocfs2/namei.c~ocfs2-fix-readonly-issue-in-ocfs2_unlink +++ a/fs/ocfs2/namei.c @@ -790,7 +790,7 @@ static int ocfs2_unlink(struct inode *di struct dentry *dentry) { int status; - int child_locked = 0; + int child_locked = 0, is_unlinkable = 0; struct inode *inode = dentry->d_inode; struct inode *orphan_dir = NULL; struct ocfs2_super *osb = OCFS2_SB(dir->i_sb); @@ -873,6 +873,7 @@ static int ocfs2_unlink(struct inode *di mlog_errno(status); goto leave; } + is_unlinkable = 1; } handle = ocfs2_start_trans(osb, ocfs2_unlink_credits(osb->sb)); @@ -892,15 +893,6 @@ static int ocfs2_unlink(struct inode *di fe = (struct ocfs2_dinode *) fe_bh->b_data; - if (inode_is_unlinkable(inode)) { - status = ocfs2_orphan_add(osb, handle, inode, fe_bh, orphan_name, - &orphan_insert, orphan_dir); - if (status < 0) { - mlog_errno(status); - goto leave; - } - } - /* delete the name from the parent dir */ status = ocfs2_delete_entry(handle, dir, &lookup); if (status < 0) { @@ -923,6 +915,14 @@ static int ocfs2_unlink(struct inode *di mlog_errno(status); if (S_ISDIR(inode->i_mode)) inc_nlink(dir); + goto leave; + } + + if (is_unlinkable) { + status = ocfs2_orphan_add(osb, handle, inode, fe_bh, orphan_name, + &orphan_insert, orphan_dir); + if (status < 0) + mlog_errno(status); } leave: _ Patches currently in -mm which might be from younger.liu@xxxxxxxxxx are linux-next.patch fs-ocfs2-cluster-tcpc-free-sc-sc_page-in-sc_kref_release.patch ocfs2-should-call-ocfs2_journal_access_di-before-ocfs2_delete_entry-in-ocfs2_orphan_del.patch ocfs2-need-rollback-when-journal_access-failed-in-ocfs2_orphan_add.patch ocfs2-rework-transaction-rollback-in-ocfs2_relink_block_group.patch ocfs2-rework-transaction-rollback-in-ocfs2_relink_block_group-fix.patch ocfs2-fix-readonly-issue-in-ocfs2_unlink.patch ocfs2-fix-readonly-issue-in-ocfs2_unlink-fix.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html