All of lore.kernel.org
 help / color / mirror / Atom feed
* [Ocfs2-devel] [PATCH V2] ocfs2: fix a tiny case that inode can not removed.
@ 2015-08-31  7:36 jiangyiwen
  2015-09-01 17:55 ` Mark Fasheh
  0 siblings, 1 reply; 2+ messages in thread
From: jiangyiwen @ 2015-08-31  7:36 UTC (permalink / raw)
  To: ocfs2-devel

When running dirop_fileop_racer we found a case that inode
can not removed.

2 nodes, say Node A and Node B, mount the same ocfs2 volume. Create
two dirs /race/1/ and /race/2/ in the filesystem.

Node A                            Node B
rm -r /race/2/
                                  mv /race/1/ /race/2/
call ocfs2_unlink(), get
the EX mode of /race/2/
                                  wait for B unlock /race/2/
decrease i_nlink of /race/2/ to 0,
and add inode of /race/2/ into
orphan dir, unlock /race/2/
                                  got EX mode of /race/2/. because
                                  /race/1/ is dir, so inc i_nlink
                                  of /race/2/ and update into disk,
                                  unlock /race/2/
because i_nlink of /race/2/
is not zero, this inode will
always remain in orphan dir

This patch fixes this case by test whether i_nlink of new dir is zero.

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

diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 6e6abb9..2092c88 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1284,6 +1284,11 @@ static int ocfs2_rename(struct inode *old_dir,
 	}
 	parents_locked = 1;

+	if (!new_dir->i_nlink) {
+		status = -EACCES;
+		goto bail;
+	}
+
 	/* make sure both dirs have bhs
 	 * get an extra ref on old_dir_bh if old==new */
 	if (!new_dir_bh) {
-- 
1.8.3.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [Ocfs2-devel] [PATCH V2] ocfs2: fix a tiny case that inode can not removed.
  2015-08-31  7:36 [Ocfs2-devel] [PATCH V2] ocfs2: fix a tiny case that inode can not removed jiangyiwen
@ 2015-09-01 17:55 ` Mark Fasheh
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Fasheh @ 2015-09-01 17:55 UTC (permalink / raw)
  To: ocfs2-devel

On Mon, Aug 31, 2015 at 03:36:15PM +0800, jiangyiwen wrote:
> When running dirop_fileop_racer we found a case that inode
> can not removed.
> 
> 2 nodes, say Node A and Node B, mount the same ocfs2 volume. Create
> two dirs /race/1/ and /race/2/ in the filesystem.
> 
> Node A                            Node B
> rm -r /race/2/
>                                   mv /race/1/ /race/2/
> call ocfs2_unlink(), get
> the EX mode of /race/2/
>                                   wait for B unlock /race/2/
> decrease i_nlink of /race/2/ to 0,
> and add inode of /race/2/ into
> orphan dir, unlock /race/2/
>                                   got EX mode of /race/2/. because
>                                   /race/1/ is dir, so inc i_nlink
>                                   of /race/2/ and update into disk,
>                                   unlock /race/2/
> because i_nlink of /race/2/
> is not zero, this inode will
> always remain in orphan dir
> 
> This patch fixes this case by test whether i_nlink of new dir is zero.
> 
> Signed-off-by: Yiwen Jiang <jiangyiwen@huawei.com>

Looks great, thanks

Reviewed-by: Mark Fasheh <mfasheh@suse.de>
	--Mark

--
Mark Fasheh

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-09-01 17:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-31  7:36 [Ocfs2-devel] [PATCH V2] ocfs2: fix a tiny case that inode can not removed jiangyiwen
2015-09-01 17:55 ` Mark Fasheh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.