From 37a734c1bc6493e534de66378a27ffd15f23c6f9 Mon Sep 17 00:00:00 2001 From: Dave Kleikamp Date: Wed, 29 Oct 2003 21:31:36 -0600 Subject: [PATCH] JFS: Fix race between link() and unlink() JFS isn't happy it thinks a file has been removed, and link() increases its nlink count back from zero. In 2.4, i_zombie prevented this race condition. http://bugzilla.kernel.org/show_bug.cgi?id=866 --- fs/jfs/namei.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c index c41d213e418b5..f71cd7088d631 100644 --- a/fs/jfs/namei.c +++ b/fs/jfs/namei.c @@ -772,16 +772,17 @@ int jfs_link(struct dentry *old_dentry, jfs_info("jfs_link: %s %s", old_dentry->d_name.name, dentry->d_name.name); + if (ip->i_nlink == JFS_LINK_MAX) + return -EMLINK; + + if (ip->i_nlink == 0) + return -ENOENT; + tid = txBegin(ip->i_sb, 0); down(&JFS_IP(dir)->commit_sem); down(&JFS_IP(ip)->commit_sem); - if (ip->i_nlink == JFS_LINK_MAX) { - rc = -EMLINK; - goto out; - } - /* * scan parent directory for entry/freespace */ -- 2.53.0