Skip to content

Commit

Permalink
Fix link count of root inode when snapdir is visible
Browse files Browse the repository at this point in the history
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
  • Loading branch information
kusumi authored and behlendorf committed May 8, 2019
1 parent e2dddb7 commit 97aa3ba
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions module/zfs/zfs_vnops.c
Expand Up @@ -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;
Expand Down

0 comments on commit 97aa3ba

Please sign in to comment.