NFSv4: link must update the inode nlink.
authorTrond Myklebust <trond.myklebust@hammerspace.com>
Thu, 1 Apr 2021 18:57:56 +0000 (14:57 -0400)
committerTrond Myklebust <trond.myklebust@hammerspace.com>
Wed, 14 Apr 2021 13:36:29 +0000 (09:36 -0400)
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
fs/nfs/dir.c
fs/nfs/nfs4proc.c

index d2835d2..5c25c8c 100644 (file)
@@ -1711,7 +1711,7 @@ static void nfs_drop_nlink(struct inode *inode)
        NFS_I(inode)->attr_gencount = nfs_inc_attr_generation_counter();
        nfs_set_cache_invalid(
                inode, NFS_INO_INVALID_CHANGE | NFS_INO_INVALID_CTIME |
-                              NFS_INO_INVALID_NLINK | NFS_INO_REVAL_FORCED);
+                              NFS_INO_INVALID_NLINK);
        spin_unlock(&inode->i_lock);
 }
 
index d05f4ca..2215f20 100644 (file)
@@ -1175,6 +1175,14 @@ nfs4_inc_nlink_locked(struct inode *inode)
        inc_nlink(inode);
 }
 
+static void
+nfs4_inc_nlink(struct inode *inode)
+{
+       spin_lock(&inode->i_lock);
+       nfs4_inc_nlink_locked(inode);
+       spin_unlock(&inode->i_lock);
+}
+
 static void
 nfs4_dec_nlink_locked(struct inode *inode)
 {
@@ -4791,6 +4799,7 @@ static int _nfs4_proc_link(struct inode *inode, struct inode *dir, const struct
        if (!status) {
                nfs4_update_changeattr(dir, &res.cinfo, res.fattr->time_start,
                                       NFS_INO_INVALID_DATA);
+               nfs4_inc_nlink(inode);
                status = nfs_post_op_update_inode(inode, res.fattr);
                if (!status)
                        nfs_setsecurity(inode, res.fattr, res.label);