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.

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 97aa3ba44f0b3911866e5dfc31b0d7a9fb124855
Showing with 6 additions and 0 deletions.
  1. +6 −0 module/zfs/zfs_vnops.c
@@ -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;

0 comments on commit 97aa3ba

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