]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Fix link count of root inode when snapdir is visible
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Wed, 8 May 2019 23:40:51 +0000 (08:40 +0900)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 8 May 2019 23:40:51 +0000 (16:40 -0700)
Given how zfs_getattr() is implemented, zfs_getattr_fast() (used by
->getattr() of zpl inodes) also needs to consider an additional link
count if "snapdir" property is set to "visible".

Without this, # of directories in root inode of each dataset doesn't
match the link count when snapdir is visible.

Reviewed-by: Richard Yao <ryao@gentoo.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@osnexus.com>
Closes #8727

module/zfs/zfs_vnops.c

index 27f179d826b9ae772edb4641d3e2f02a76c7ca1e..41c1bd255753467a272f0677cbcfae2068a1143a 100644 (file)
@@ -2657,6 +2657,12 @@ zfs_getattr_fast(struct inode *ip, struct kstat *sp)
        mutex_enter(&zp->z_lock);
 
        generic_fillattr(ip, sp);
+       /*
+        * +1 link count for root inode with visible '.zfs' directory.
+        */
+       if ((zp->z_id == zfsvfs->z_root) && zfs_show_ctldir(zp))
+               if (sp->nlink < ZFS_LINK_MAX)
+                       sp->nlink++;
 
        sa_object_size(zp->z_sa_hdl, &blksize, &nblocks);
        sp->blksize = blksize;