From: Joseph Qi Date: Thu, 14 Jan 2016 23:17:44 +0000 (-0800) Subject: ocfs2: access orphan dinode before delete entry in ocfs2_orphan_del X-Git-Tag: v4.1.12-92~39^2~5 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=96199900d5c1093473e800c43006d5f504980f41;p=users%2Fjedix%2Flinux-maple.git ocfs2: access orphan dinode before delete entry in ocfs2_orphan_del In ocfs2_orphan_del, currently it finds and deletes entry first, and then access orphan dir dinode. This will have a problem once ocfs2_journal_access_di fails. In this case, entry will be removed from orphan dir, but in deed the inode hasn't been deleted successfully. In other words, the file is missing but not actually deleted. So we should access orphan dinode first like unlink and rename. Signed-off-by: Joseph Qi Reviewed-by: Jiufei Xue Cc: Mark Fasheh Cc: Joel Becker Reviewed-by: Junxiao Bi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds (cherry picked from commit 074a6c655f6da12cb1123c8a84bfd8d781138800) Orabug: 24939243 Signed-off-by: Junxiao Bi --- diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c index 0a3093baf369..d5bab3e0c973 100644 --- a/fs/ocfs2/namei.c +++ b/fs/ocfs2/namei.c @@ -2351,6 +2351,15 @@ int ocfs2_orphan_del(struct ocfs2_super *osb, (unsigned long long)OCFS2_I(orphan_dir_inode)->ip_blkno, name, strlen(name)); + status = ocfs2_journal_access_di(handle, + INODE_CACHE(orphan_dir_inode), + orphan_dir_bh, + OCFS2_JOURNAL_ACCESS_WRITE); + if (status < 0) { + mlog_errno(status); + goto leave; + } + /* find it's spot in the orphan directory */ status = ocfs2_find_entry(name, strlen(name), orphan_dir_inode, &lookup); @@ -2366,15 +2375,6 @@ int ocfs2_orphan_del(struct ocfs2_super *osb, goto leave; } - status = ocfs2_journal_access_di(handle, - INODE_CACHE(orphan_dir_inode), - orphan_dir_bh, - OCFS2_JOURNAL_ACCESS_WRITE); - if (status < 0) { - mlog_errno(status); - goto leave; - } - /* do the i_nlink dance! :) */ orphan_fe = (struct ocfs2_dinode *) orphan_dir_bh->b_data; if (S_ISDIR(inode->i_mode))