Skip to content
Permalink
Browse files

Fix link count of root inode when snapdir is visible

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.

Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@osnexus.com>
  • Loading branch information...
kusumi committed May 8, 2019
1 parent 1f02ecc commit 139541877c8c513842d549df84927c4618a07582
Showing with 6 additions and 0 deletions.
  1. +6 −0 module/zfs/zfs_vnops.c
@@ -2656,6 +2656,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;

0 comments on commit 1395418

Please sign in to comment.
You can’t perform that action at this time.