diff options
author | Chris Dunlop <[email protected]> | 2016-07-15 00:44:38 +1000 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2016-07-14 16:25:34 -0700 |
commit | dfbc86309fd8ebb70a55cafa876320dc1ea8e833 (patch) | |
tree | 32c1b694d9d6b6bd89db7b3041cd459bc4e44541 /module/zfs/zfs_vnops.c | |
parent | 02de3e3c5d54bd545b34cccfd35ace80edd1f864 (diff) |
Use native inode->i_nlink instead of znode->z_links
A mostly mechanical change, taking into account i_nlink is 32 bits vs ZFS's
64 bit on-disk link count.
We revert "xattr dir doesn't get purged during iput" (ddae16a) as this is a
more Linux-integrated fix for the same issue.
In addition, setting the initial link count on a new node has been changed
from setting one less than required in zfs_mknode() then incrementing to the
correct count in zfs_link_create() (which was somewhat bizarre in the first
place), to setting the correct count in zfs_mknode() and not incrementing it
in zfs_link_create(). This both means we no longer set the link count in
sa_bulk_update() twice (once for the initial incorrect count then again for
the correct count), as well as adhering to the Linux requirement of not
incrementing a zero link count without I_LINKABLE (see linux commit
f4e0c30c).
Signed-off-by: Chris Dunlop <[email protected]>
Signed-off-by: Brian Behlendorf <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Closes #4838
Issue #227
Diffstat (limited to 'module/zfs/zfs_vnops.c')
-rw-r--r-- | module/zfs/zfs_vnops.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c index 48a72e302..bc3dd2166 100644 --- a/module/zfs/zfs_vnops.c +++ b/module/zfs/zfs_vnops.c @@ -1524,6 +1524,7 @@ zfs_remove(struct inode *dip, char *name, cred_t *cr, int flags) uint64_t acl_obj, xattr_obj; uint64_t xattr_obj_unlinked = 0; uint64_t obj = 0; + uint64_t links; zfs_dirlock_t *dl; dmu_tx_t *tx; boolean_t may_delete_now, delete_now = FALSE; @@ -1672,12 +1673,13 @@ top: if (delete_now) { if (xattr_obj_unlinked) { - ASSERT3U(xzp->z_links, ==, 2); + ASSERT3U(ZTOI(xzp)->i_nlink, ==, 2); mutex_enter(&xzp->z_lock); xzp->z_unlinked = 1; - xzp->z_links = 0; + clear_nlink(ZTOI(xzp)); + links = 0; error = sa_update(xzp->z_sa_hdl, SA_ZPL_LINKS(zsb), - &xzp->z_links, sizeof (xzp->z_links), tx); + &links, sizeof (links), tx); ASSERT3U(error, ==, 0); mutex_exit(&xzp->z_lock); zfs_unlinked_add(xzp, tx); @@ -2297,9 +2299,9 @@ zfs_getattr(struct inode *ip, vattr_t *vap, int flags, cred_t *cr) vap->va_fsid = ZTOI(zp)->i_sb->s_dev; vap->va_nodeid = zp->z_id; if ((zp->z_id == zsb->z_root) && zfs_show_ctldir(zp)) - links = zp->z_links + 1; + links = ZTOI(zp)->i_nlink + 1; else - links = zp->z_links; + links = ZTOI(zp)->i_nlink; vap->va_nlink = MIN(links, ZFS_LINK_MAX); vap->va_size = i_size_read(ip); vap->va_rdev = ip->i_rdev; |