diff options
author | Tomohiro Kusumi <[email protected]> | 2019-05-09 08:40:51 +0900 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2019-05-08 16:40:51 -0700 |
commit | 97aa3ba44f0b3911866e5dfc31b0d7a9fb124855 (patch) | |
tree | 9cbdc28323eca6bb9835f261cafa79039c3fa6d2 /module/zfs/zfs_vnops.c | |
parent | e2dddb7e58f7046dc1bfdbc49db52f298fb7019f (diff) |
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 <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Tomohiro Kusumi <[email protected]>
Closes #8727
Diffstat (limited to 'module/zfs/zfs_vnops.c')
-rw-r--r-- | module/zfs/zfs_vnops.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 27f179d82..41c1bd255 100644 --- a/module/zfs/zfs_vnops.c +++ b/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; |