From: Andrew Price Date: Tue, 14 Mar 2023 13:18:27 +0000 (+0000) Subject: gfs2: Remove duplicate i_nlink check from gfs2_link() X-Git-Tag: v6.4-rc1~140^2~10 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8dc14966ca3eb5bf4e200c50cc73199ee6de2bd7;p=thirdparty%2Fkernel%2Flinux.git gfs2: Remove duplicate i_nlink check from gfs2_link() The duplication is: struct gfs2_inode *ip = GFS2_I(inode); [...] error = -ENOENT; if (inode->i_nlink == 0) goto out_gunlock; [...] error = -EINVAL; if (!ip->i_inode.i_nlink) goto out_gunlock; The second check is removed. ENOENT is the correct error code for attempts to link a deleted inode (ref: link(2)). If we support O_TMPFILE in future the check will need to be updated with an exception for inodes flagged I_LINKABLE so sorting out this duplication now will make it a slightly cleaner change. Signed-off-by: Andrew Price Signed-off-by: Andreas Gruenbacher --- diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 1291b5ee35842..79eef9a0ebfc5 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c @@ -992,9 +992,6 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, error = -EPERM; if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) goto out_gunlock; - error = -EINVAL; - if (!ip->i_inode.i_nlink) - goto out_gunlock; error = -EMLINK; if (ip->i_inode.i_nlink == (u32)-1) goto out_gunlock;