diff --git a/include/sys/zfs_znode.h b/include/sys/zfs_znode.h index 88d6423506..3a4a0c3cb5 100644 --- a/include/sys/zfs_znode.h +++ b/include/sys/zfs_znode.h @@ -242,9 +242,9 @@ zfs_enter_verify_zp(zfsvfs_t *zfsvfs, znode_t *zp, const char *tag) typedef struct znode_hold { uint64_t zh_obj; /* object id */ - kmutex_t zh_lock; /* lock serializing object access */ avl_node_t zh_node; /* avl tree linkage */ - zfs_refcount_t zh_refcount; /* active consumer reference count */ + kmutex_t zh_lock; /* lock serializing object access */ + int zh_refcount; /* active consumer reference count */ } znode_hold_t; static inline uint64_t diff --git a/module/os/linux/zfs/zfs_znode.c b/module/os/linux/zfs/zfs_znode.c index 662147ab47..d673da3846 100644 --- a/module/os/linux/zfs/zfs_znode.c +++ b/module/os/linux/zfs/zfs_znode.c @@ -169,8 +169,7 @@ zfs_znode_hold_cache_constructor(void *buf, void *arg, int kmflags) znode_hold_t *zh = buf; mutex_init(&zh->zh_lock, NULL, MUTEX_DEFAULT, NULL); - zfs_refcount_create(&zh->zh_refcount); - zh->zh_obj = ZFS_NO_OBJECT; + zh->zh_refcount = 0; return (0); } @@ -182,7 +181,6 @@ zfs_znode_hold_cache_destructor(void *buf, void *arg) znode_hold_t *zh = buf; mutex_destroy(&zh->zh_lock); - zfs_refcount_destroy(&zh->zh_refcount); } void @@ -281,26 +279,26 @@ zfs_znode_hold_enter(zfsvfs_t *zfsvfs, uint64_t obj) boolean_t found = B_FALSE; zh_new = kmem_cache_alloc(znode_hold_cache, KM_SLEEP); - zh_new->zh_obj = obj; search.zh_obj = obj; mutex_enter(&zfsvfs->z_hold_locks[i]); zh = avl_find(&zfsvfs->z_hold_trees[i], &search, NULL); if (likely(zh == NULL)) { zh = zh_new; + zh->zh_obj = obj; avl_add(&zfsvfs->z_hold_trees[i], zh); } else { ASSERT3U(zh->zh_obj, ==, obj); found = B_TRUE; } - zfs_refcount_add(&zh->zh_refcount, NULL); + zh->zh_refcount++; + ASSERT3S(zh->zh_refcount, >, 0); mutex_exit(&zfsvfs->z_hold_locks[i]); if (found == B_TRUE) kmem_cache_free(znode_hold_cache, zh_new); ASSERT(MUTEX_NOT_HELD(&zh->zh_lock)); - ASSERT3S(zfs_refcount_count(&zh->zh_refcount), >, 0); mutex_enter(&zh->zh_lock); return (zh); @@ -313,11 +311,11 @@ zfs_znode_hold_exit(zfsvfs_t *zfsvfs, znode_hold_t *zh) boolean_t remove = B_FALSE; ASSERT(zfs_znode_held(zfsvfs, zh->zh_obj)); - ASSERT3S(zfs_refcount_count(&zh->zh_refcount), >, 0); mutex_exit(&zh->zh_lock); mutex_enter(&zfsvfs->z_hold_locks[i]); - if (zfs_refcount_remove(&zh->zh_refcount, NULL) == 0) { + ASSERT3S(zh->zh_refcount, >, 0); + if (--zh->zh_refcount == 0) { avl_remove(&zfsvfs->z_hold_trees[i], zh); remove = B_TRUE; }