]> git.proxmox.com Git - zfsonlinux.git/blob - zfs-patches/0013-Linux-4.19-rc3-compat-Remove-refcount_t-compat.patch
update/rebase to zfs-0.7.12 with patches from ZOL
[zfsonlinux.git] / zfs-patches / 0013-Linux-4.19-rc3-compat-Remove-refcount_t-compat.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Tim Schumacher <timschumi@gmx.de>
3 Date: Wed, 26 Sep 2018 19:29:26 +0200
4 Subject: [PATCH] Linux 4.19-rc3+ compat: Remove refcount_t compat
5
6 torvalds/linux@59b57717f ("blkcg: delay blkg destruction until
7 after writeback has finished") added a refcount_t to the blkcg
8 structure. Due to the refcount_t compatibility code, zfs_refcount_t
9 was used by mistake.
10
11 Resolve this by removing the compatibility code and replacing the
12 occurrences of refcount_t with zfs_refcount_t.
13
14 Reviewed-by: Franz Pletz <fpletz@fnordicwalking.de>
15 Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
16 Signed-off-by: Tim Schumacher <timschumi@gmx.de>
17 Closes #7885
18 Closes #7932
19 ---
20 cmd/ztest/ztest.c | 6 +++---
21 include/linux/vfs_compat.h | 5 -----
22 include/sys/abd.h | 2 +-
23 include/sys/arc.h | 2 +-
24 include/sys/arc_impl.h | 8 +++----
25 include/sys/dbuf.h | 2 +-
26 include/sys/dmu_tx.h | 4 ++--
27 include/sys/dnode.h | 4 ++--
28 include/sys/dsl_dataset.h | 2 +-
29 include/sys/metaslab_impl.h | 5 ++---
30 include/sys/refcount.h | 52 ++++++++++++++++++++-------------------------
31 include/sys/rrwlock.h | 4 ++--
32 include/sys/sa_impl.h | 2 +-
33 include/sys/spa_impl.h | 6 +++---
34 include/sys/zap.h | 2 +-
35 include/sys/zfs_znode.h | 2 +-
36 module/zfs/arc.c | 12 +++++------
37 module/zfs/dbuf.c | 10 ++++-----
38 module/zfs/dmu.c | 2 +-
39 module/zfs/dmu_tx.c | 6 +++---
40 module/zfs/dnode.c | 6 +++---
41 module/zfs/dsl_dataset.c | 2 +-
42 module/zfs/metaslab.c | 4 ++--
43 module/zfs/refcount.c | 30 +++++++++++++-------------
44 module/zfs/rrwlock.c | 4 ++--
45 module/zfs/sa.c | 2 +-
46 module/zfs/spa_misc.c | 8 +++----
47 module/zfs/zfs_ctldir.c | 10 ++++-----
48 module/zfs/zfs_znode.c | 2 +-
49 29 files changed, 97 insertions(+), 109 deletions(-)
50
51 diff --git a/cmd/ztest/ztest.c b/cmd/ztest/ztest.c
52 index a410eeef..24967a76 100644
53 --- a/cmd/ztest/ztest.c
54 +++ b/cmd/ztest/ztest.c
55 @@ -1189,7 +1189,7 @@ ztest_spa_prop_set_uint64(zpool_prop_t prop, uint64_t value)
56 */
57 typedef struct {
58 list_node_t z_lnode;
59 - refcount_t z_refcnt;
60 + zfs_refcount_t z_refcnt;
61 uint64_t z_object;
62 zfs_rlock_t z_range_lock;
63 } ztest_znode_t;
64 @@ -1248,13 +1248,13 @@ ztest_znode_get(ztest_ds_t *zd, uint64_t object)
65 for (zp = list_head(&zll->z_list); (zp);
66 zp = list_next(&zll->z_list, zp)) {
67 if (zp->z_object == object) {
68 - refcount_add(&zp->z_refcnt, RL_TAG);
69 + zfs_refcount_add(&zp->z_refcnt, RL_TAG);
70 break;
71 }
72 }
73 if (zp == NULL) {
74 zp = ztest_znode_init(object);
75 - refcount_add(&zp->z_refcnt, RL_TAG);
76 + zfs_refcount_add(&zp->z_refcnt, RL_TAG);
77 list_insert_head(&zll->z_list, zp);
78 }
79 mutex_exit(&zll->z_lock);
80 diff --git a/include/linux/vfs_compat.h b/include/linux/vfs_compat.h
81 index 90b3cca7..c01f5850 100644
82 --- a/include/linux/vfs_compat.h
83 +++ b/include/linux/vfs_compat.h
84 @@ -297,9 +297,6 @@ lseek_execute(
85 * This is several orders of magnitude larger than expected grace period.
86 * At 60 seconds the kernel will also begin issuing RCU stall warnings.
87 */
88 -#ifdef refcount_t
89 -#undef refcount_t
90 -#endif
91
92 #include <linux/posix_acl.h>
93
94 @@ -430,8 +427,6 @@ typedef mode_t zpl_equivmode_t;
95 #define zpl_posix_acl_valid(ip, acl) posix_acl_valid(acl)
96 #endif
97
98 -#define refcount_t zfs_refcount_t
99 -
100 #endif /* CONFIG_FS_POSIX_ACL */
101
102 /*
103 diff --git a/include/sys/abd.h b/include/sys/abd.h
104 index cd710501..4898606a 100644
105 --- a/include/sys/abd.h
106 +++ b/include/sys/abd.h
107 @@ -52,7 +52,7 @@ typedef struct abd {
108 abd_flags_t abd_flags;
109 uint_t abd_size; /* excludes scattered abd_offset */
110 struct abd *abd_parent;
111 - refcount_t abd_children;
112 + zfs_refcount_t abd_children;
113 union {
114 struct abd_scatter {
115 uint_t abd_offset;
116 diff --git a/include/sys/arc.h b/include/sys/arc.h
117 index 1ea4937b..943ebfb5 100644
118 --- a/include/sys/arc.h
119 +++ b/include/sys/arc.h
120 @@ -76,7 +76,7 @@ struct arc_prune {
121 void *p_private;
122 uint64_t p_adjust;
123 list_node_t p_node;
124 - refcount_t p_refcnt;
125 + zfs_refcount_t p_refcnt;
126 };
127
128 typedef enum arc_strategy {
129 diff --git a/include/sys/arc_impl.h b/include/sys/arc_impl.h
130 index c6363f2a..ed2b0abe 100644
131 --- a/include/sys/arc_impl.h
132 +++ b/include/sys/arc_impl.h
133 @@ -74,12 +74,12 @@ typedef struct arc_state {
134 /*
135 * total amount of evictable data in this state
136 */
137 - refcount_t arcs_esize[ARC_BUFC_NUMTYPES];
138 + zfs_refcount_t arcs_esize[ARC_BUFC_NUMTYPES];
139 /*
140 * total amount of data in this state; this includes: evictable,
141 * non-evictable, ARC_BUFC_DATA, and ARC_BUFC_METADATA.
142 */
143 - refcount_t arcs_size;
144 + zfs_refcount_t arcs_size;
145 /*
146 * supports the "dbufs" kstat
147 */
148 @@ -163,7 +163,7 @@ typedef struct l1arc_buf_hdr {
149 uint32_t b_l2_hits;
150
151 /* self protecting */
152 - refcount_t b_refcnt;
153 + zfs_refcount_t b_refcnt;
154
155 arc_callback_t *b_acb;
156 abd_t *b_pabd;
157 @@ -180,7 +180,7 @@ typedef struct l2arc_dev {
158 kmutex_t l2ad_mtx; /* lock for buffer list */
159 list_t l2ad_buflist; /* buffer list */
160 list_node_t l2ad_node; /* device list node */
161 - refcount_t l2ad_alloc; /* allocated bytes */
162 + zfs_refcount_t l2ad_alloc; /* allocated bytes */
163 } l2arc_dev_t;
164
165 typedef struct l2arc_buf_hdr {
166 diff --git a/include/sys/dbuf.h b/include/sys/dbuf.h
167 index f3f2007d..127acad3 100644
168 --- a/include/sys/dbuf.h
169 +++ b/include/sys/dbuf.h
170 @@ -212,7 +212,7 @@ typedef struct dmu_buf_impl {
171 * If nonzero, the buffer can't be destroyed.
172 * Protected by db_mtx.
173 */
174 - refcount_t db_holds;
175 + zfs_refcount_t db_holds;
176
177 /* buffer holding our data */
178 arc_buf_t *db_buf;
179 diff --git a/include/sys/dmu_tx.h b/include/sys/dmu_tx.h
180 index 74b7e111..96bbcb05 100644
181 --- a/include/sys/dmu_tx.h
182 +++ b/include/sys/dmu_tx.h
183 @@ -97,8 +97,8 @@ typedef struct dmu_tx_hold {
184 dmu_tx_t *txh_tx;
185 list_node_t txh_node;
186 struct dnode *txh_dnode;
187 - refcount_t txh_space_towrite;
188 - refcount_t txh_memory_tohold;
189 + zfs_refcount_t txh_space_towrite;
190 + zfs_refcount_t txh_memory_tohold;
191 enum dmu_tx_hold_type txh_type;
192 uint64_t txh_arg1;
193 uint64_t txh_arg2;
194 diff --git a/include/sys/dnode.h b/include/sys/dnode.h
195 index 2dd087b3..1e77e0a3 100644
196 --- a/include/sys/dnode.h
197 +++ b/include/sys/dnode.h
198 @@ -266,8 +266,8 @@ struct dnode {
199 uint8_t *dn_dirtyctx_firstset; /* dbg: contents meaningless */
200
201 /* protected by own devices */
202 - refcount_t dn_tx_holds;
203 - refcount_t dn_holds;
204 + zfs_refcount_t dn_tx_holds;
205 + zfs_refcount_t dn_holds;
206
207 kmutex_t dn_dbufs_mtx;
208 /*
209 diff --git a/include/sys/dsl_dataset.h b/include/sys/dsl_dataset.h
210 index 1281674b..d96f526d 100644
211 --- a/include/sys/dsl_dataset.h
212 +++ b/include/sys/dsl_dataset.h
213 @@ -186,7 +186,7 @@ typedef struct dsl_dataset {
214 * Owning counts as a long hold. See the comments above
215 * dsl_pool_hold() for details.
216 */
217 - refcount_t ds_longholds;
218 + zfs_refcount_t ds_longholds;
219
220 /* no locking; only for making guesses */
221 uint64_t ds_trysnap_txg;
222 diff --git a/include/sys/metaslab_impl.h b/include/sys/metaslab_impl.h
223 index f8a713a4..60151937 100644
224 --- a/include/sys/metaslab_impl.h
225 +++ b/include/sys/metaslab_impl.h
226 @@ -179,8 +179,7 @@ struct metaslab_class {
227 * number of allocations allowed.
228 */
229 uint64_t mc_alloc_max_slots;
230 - refcount_t mc_alloc_slots;
231 -
232 + zfs_refcount_t mc_alloc_slots;
233 uint64_t mc_alloc_groups; /* # of allocatable groups */
234
235 uint64_t mc_alloc; /* total allocated space */
236 @@ -230,7 +229,7 @@ struct metaslab_group {
237 * are unable to handle their share of allocations.
238 */
239 uint64_t mg_max_alloc_queue_depth;
240 - refcount_t mg_alloc_queue_depth;
241 + zfs_refcount_t mg_alloc_queue_depth;
242
243 /*
244 * A metalab group that can no longer allocate the minimum block
245 diff --git a/include/sys/refcount.h b/include/sys/refcount.h
246 index a96220b2..5c5198d8 100644
247 --- a/include/sys/refcount.h
248 +++ b/include/sys/refcount.h
249 @@ -41,17 +41,6 @@ extern "C" {
250 */
251 #define FTAG ((char *)__func__)
252
253 -/*
254 - * Starting with 4.11, torvalds/linux@f405df5, the linux kernel defines a
255 - * refcount_t type of its own. The macro below effectively changes references
256 - * in the ZFS code from refcount_t to zfs_refcount_t at compile time, so that
257 - * existing code need not be altered, reducing conflicts when landing openZFS
258 - * patches.
259 - */
260 -
261 -#define refcount_t zfs_refcount_t
262 -#define refcount_add zfs_refcount_add
263 -
264 #ifdef ZFS_DEBUG
265 typedef struct reference {
266 list_node_t ref_link;
267 @@ -69,23 +58,28 @@ typedef struct refcount {
268 uint64_t rc_removed_count;
269 } zfs_refcount_t;
270
271 -/* Note: refcount_t must be initialized with refcount_create[_untracked]() */
272 -
273 -void refcount_create(refcount_t *rc);
274 -void refcount_create_untracked(refcount_t *rc);
275 -void refcount_create_tracked(refcount_t *rc);
276 -void refcount_destroy(refcount_t *rc);
277 -void refcount_destroy_many(refcount_t *rc, uint64_t number);
278 -int refcount_is_zero(refcount_t *rc);
279 -int64_t refcount_count(refcount_t *rc);
280 -int64_t zfs_refcount_add(refcount_t *rc, void *holder_tag);
281 -int64_t refcount_remove(refcount_t *rc, void *holder_tag);
282 -int64_t refcount_add_many(refcount_t *rc, uint64_t number, void *holder_tag);
283 -int64_t refcount_remove_many(refcount_t *rc, uint64_t number, void *holder_tag);
284 -void refcount_transfer(refcount_t *dst, refcount_t *src);
285 -void refcount_transfer_ownership(refcount_t *, void *, void *);
286 -boolean_t refcount_held(refcount_t *, void *);
287 -boolean_t refcount_not_held(refcount_t *, void *);
288 +/*
289 + * Note: zfs_refcount_t must be initialized with
290 + * refcount_create[_untracked]()
291 + */
292 +
293 +void refcount_create(zfs_refcount_t *rc);
294 +void refcount_create_untracked(zfs_refcount_t *rc);
295 +void refcount_create_tracked(zfs_refcount_t *rc);
296 +void refcount_destroy(zfs_refcount_t *rc);
297 +void refcount_destroy_many(zfs_refcount_t *rc, uint64_t number);
298 +int refcount_is_zero(zfs_refcount_t *rc);
299 +int64_t refcount_count(zfs_refcount_t *rc);
300 +int64_t zfs_refcount_add(zfs_refcount_t *rc, void *holder_tag);
301 +int64_t refcount_remove(zfs_refcount_t *rc, void *holder_tag);
302 +int64_t refcount_add_many(zfs_refcount_t *rc, uint64_t number,
303 + void *holder_tag);
304 +int64_t refcount_remove_many(zfs_refcount_t *rc, uint64_t number,
305 + void *holder_tag);
306 +void refcount_transfer(zfs_refcount_t *dst, zfs_refcount_t *src);
307 +void refcount_transfer_ownership(zfs_refcount_t *, void *, void *);
308 +boolean_t refcount_held(zfs_refcount_t *, void *);
309 +boolean_t refcount_not_held(zfs_refcount_t *, void *);
310
311 void refcount_init(void);
312 void refcount_fini(void);
313 @@ -94,7 +88,7 @@ void refcount_fini(void);
314
315 typedef struct refcount {
316 uint64_t rc_count;
317 -} refcount_t;
318 +} zfs_refcount_t;
319
320 #define refcount_create(rc) ((rc)->rc_count = 0)
321 #define refcount_create_untracked(rc) ((rc)->rc_count = 0)
322 diff --git a/include/sys/rrwlock.h b/include/sys/rrwlock.h
323 index 7a328fd6..e1c1756c 100644
324 --- a/include/sys/rrwlock.h
325 +++ b/include/sys/rrwlock.h
326 @@ -57,8 +57,8 @@ typedef struct rrwlock {
327 kmutex_t rr_lock;
328 kcondvar_t rr_cv;
329 kthread_t *rr_writer;
330 - refcount_t rr_anon_rcount;
331 - refcount_t rr_linked_rcount;
332 + zfs_refcount_t rr_anon_rcount;
333 + zfs_refcount_t rr_linked_rcount;
334 boolean_t rr_writer_wanted;
335 boolean_t rr_track_all;
336 } rrwlock_t;
337 diff --git a/include/sys/sa_impl.h b/include/sys/sa_impl.h
338 index b68b7610..7eddd875 100644
339 --- a/include/sys/sa_impl.h
340 +++ b/include/sys/sa_impl.h
341 @@ -110,7 +110,7 @@ typedef struct sa_idx_tab {
342 list_node_t sa_next;
343 sa_lot_t *sa_layout;
344 uint16_t *sa_variable_lengths;
345 - refcount_t sa_refcount;
346 + zfs_refcount_t sa_refcount;
347 uint32_t *sa_idx_tab; /* array of offsets */
348 } sa_idx_tab_t;
349
350 diff --git a/include/sys/spa_impl.h b/include/sys/spa_impl.h
351 index fa7490ac..62ac8f67 100644
352 --- a/include/sys/spa_impl.h
353 +++ b/include/sys/spa_impl.h
354 @@ -78,7 +78,7 @@ typedef struct spa_config_lock {
355 kthread_t *scl_writer;
356 int scl_write_wanted;
357 kcondvar_t scl_cv;
358 - refcount_t scl_count;
359 + zfs_refcount_t scl_count;
360 } spa_config_lock_t;
361
362 typedef struct spa_config_dirent {
363 @@ -281,12 +281,12 @@ struct spa {
364
365 /*
366 * spa_refcount & spa_config_lock must be the last elements
367 - * because refcount_t changes size based on compilation options.
368 + * because zfs_refcount_t changes size based on compilation options.
369 * In order for the MDB module to function correctly, the other
370 * fields must remain in the same location.
371 */
372 spa_config_lock_t spa_config_lock[SCL_LOCKS]; /* config changes */
373 - refcount_t spa_refcount; /* number of opens */
374 + zfs_refcount_t spa_refcount; /* number of opens */
375
376 taskq_t *spa_upgrade_taskq; /* taskq for upgrade jobs */
377 };
378 diff --git a/include/sys/zap.h b/include/sys/zap.h
379 index 43b7fbd2..7acc3bec 100644
380 --- a/include/sys/zap.h
381 +++ b/include/sys/zap.h
382 @@ -226,7 +226,7 @@ int zap_lookup_norm_by_dnode(dnode_t *dn, const char *name,
383 boolean_t *ncp);
384
385 int zap_count_write_by_dnode(dnode_t *dn, const char *name,
386 - int add, refcount_t *towrite, refcount_t *tooverwrite);
387 + int add, zfs_refcount_t *towrite, zfs_refcount_t *tooverwrite);
388
389 /*
390 * Create an attribute with the given name and value.
391 diff --git a/include/sys/zfs_znode.h b/include/sys/zfs_znode.h
392 index 26d1eb37..33bc20d1 100644
393 --- a/include/sys/zfs_znode.h
394 +++ b/include/sys/zfs_znode.h
395 @@ -209,7 +209,7 @@ typedef struct znode_hold {
396 uint64_t zh_obj; /* object id */
397 kmutex_t zh_lock; /* lock serializing object access */
398 avl_node_t zh_node; /* avl tree linkage */
399 - refcount_t zh_refcount; /* active consumer reference count */
400 + zfs_refcount_t zh_refcount; /* active consumer reference count */
401 } znode_hold_t;
402
403 /*
404 diff --git a/module/zfs/arc.c b/module/zfs/arc.c
405 index bcf74dd6..7518d5c8 100644
406 --- a/module/zfs/arc.c
407 +++ b/module/zfs/arc.c
408 @@ -1966,7 +1966,7 @@ add_reference(arc_buf_hdr_t *hdr, void *tag)
409
410 state = hdr->b_l1hdr.b_state;
411
412 - if ((refcount_add(&hdr->b_l1hdr.b_refcnt, tag) == 1) &&
413 + if ((zfs_refcount_add(&hdr->b_l1hdr.b_refcnt, tag) == 1) &&
414 (state != arc_anon)) {
415 /* We don't use the L2-only state list. */
416 if (state != arc_l2c_only) {
417 @@ -2505,7 +2505,7 @@ arc_return_buf(arc_buf_t *buf, void *tag)
418
419 ASSERT3P(buf->b_data, !=, NULL);
420 ASSERT(HDR_HAS_L1HDR(hdr));
421 - (void) refcount_add(&hdr->b_l1hdr.b_refcnt, tag);
422 + (void) zfs_refcount_add(&hdr->b_l1hdr.b_refcnt, tag);
423 (void) refcount_remove(&hdr->b_l1hdr.b_refcnt, arc_onloan_tag);
424
425 arc_loaned_bytes_update(-arc_buf_size(buf));
426 @@ -2519,7 +2519,7 @@ arc_loan_inuse_buf(arc_buf_t *buf, void *tag)
427
428 ASSERT3P(buf->b_data, !=, NULL);
429 ASSERT(HDR_HAS_L1HDR(hdr));
430 - (void) refcount_add(&hdr->b_l1hdr.b_refcnt, arc_onloan_tag);
431 + (void) zfs_refcount_add(&hdr->b_l1hdr.b_refcnt, arc_onloan_tag);
432 (void) refcount_remove(&hdr->b_l1hdr.b_refcnt, tag);
433
434 arc_loaned_bytes_update(arc_buf_size(buf));
435 @@ -3533,7 +3533,7 @@ arc_prune_async(int64_t adjust)
436 if (refcount_count(&ap->p_refcnt) >= 2)
437 continue;
438
439 - refcount_add(&ap->p_refcnt, ap->p_pfunc);
440 + zfs_refcount_add(&ap->p_refcnt, ap->p_pfunc);
441 ap->p_adjust = adjust;
442 if (taskq_dispatch(arc_prune_taskq, arc_prune_task,
443 ap, TQ_SLEEP) == TASKQID_INVALID) {
444 @@ -5549,7 +5549,7 @@ arc_add_prune_callback(arc_prune_func_t *func, void *private)
445 refcount_create(&p->p_refcnt);
446
447 mutex_enter(&arc_prune_mtx);
448 - refcount_add(&p->p_refcnt, &arc_prune_list);
449 + zfs_refcount_add(&p->p_refcnt, &arc_prune_list);
450 list_insert_head(&arc_prune_list, p);
451 mutex_exit(&arc_prune_mtx);
452
453 @@ -5815,7 +5815,7 @@ arc_release(arc_buf_t *buf, void *tag)
454 nhdr->b_l1hdr.b_mfu_hits = 0;
455 nhdr->b_l1hdr.b_mfu_ghost_hits = 0;
456 nhdr->b_l1hdr.b_l2_hits = 0;
457 - (void) refcount_add(&nhdr->b_l1hdr.b_refcnt, tag);
458 + (void) zfs_refcount_add(&nhdr->b_l1hdr.b_refcnt, tag);
459 buf->b_hdr = nhdr;
460
461 mutex_exit(&buf->b_evict_lock);
462 diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c
463 index 6edb39d6..5101c848 100644
464 --- a/module/zfs/dbuf.c
465 +++ b/module/zfs/dbuf.c
466 @@ -104,7 +104,7 @@ static boolean_t dbuf_evict_thread_exit;
467 * become eligible for arc eviction.
468 */
469 static multilist_t *dbuf_cache;
470 -static refcount_t dbuf_cache_size;
471 +static zfs_refcount_t dbuf_cache_size;
472 unsigned long dbuf_cache_max_bytes = 100 * 1024 * 1024;
473
474 /* Cap the size of the dbuf cache to log2 fraction of arc size. */
475 @@ -2384,7 +2384,7 @@ dbuf_create(dnode_t *dn, uint8_t level, uint64_t blkid,
476
477 ASSERT(dn->dn_object == DMU_META_DNODE_OBJECT ||
478 refcount_count(&dn->dn_holds) > 0);
479 - (void) refcount_add(&dn->dn_holds, db);
480 + (void) zfs_refcount_add(&dn->dn_holds, db);
481 atomic_inc_32(&dn->dn_dbufs_count);
482
483 dprintf_dbuf(db, "db=%p\n", db);
484 @@ -2749,7 +2749,7 @@ __dbuf_hold_impl(struct dbuf_hold_impl_data *dh)
485 (void) refcount_remove_many(&dbuf_cache_size,
486 dh->dh_db->db.db_size, dh->dh_db);
487 }
488 - (void) refcount_add(&dh->dh_db->db_holds, dh->dh_tag);
489 + (void) zfs_refcount_add(&dh->dh_db->db_holds, dh->dh_tag);
490 DBUF_VERIFY(dh->dh_db);
491 mutex_exit(&dh->dh_db->db_mtx);
492
493 @@ -2873,7 +2873,7 @@ dbuf_rm_spill(dnode_t *dn, dmu_tx_t *tx)
494 void
495 dbuf_add_ref(dmu_buf_impl_t *db, void *tag)
496 {
497 - int64_t holds = refcount_add(&db->db_holds, tag);
498 + int64_t holds = zfs_refcount_add(&db->db_holds, tag);
499 VERIFY3S(holds, >, 1);
500 }
501
502 @@ -2893,7 +2893,7 @@ dbuf_try_add_ref(dmu_buf_t *db_fake, objset_t *os, uint64_t obj, uint64_t blkid,
503
504 if (found_db != NULL) {
505 if (db == found_db && dbuf_refcount(db) > db->db_dirtycnt) {
506 - (void) refcount_add(&db->db_holds, tag);
507 + (void) zfs_refcount_add(&db->db_holds, tag);
508 result = B_TRUE;
509 }
510 mutex_exit(&found_db->db_mtx);
511 diff --git a/module/zfs/dmu.c b/module/zfs/dmu.c
512 index a09ac4f9..a76cdd9f 100644
513 --- a/module/zfs/dmu.c
514 +++ b/module/zfs/dmu.c
515 @@ -342,7 +342,7 @@ dmu_bonus_hold(objset_t *os, uint64_t object, void *tag, dmu_buf_t **dbp)
516 db = dn->dn_bonus;
517
518 /* as long as the bonus buf is held, the dnode will be held */
519 - if (refcount_add(&db->db_holds, tag) == 1) {
520 + if (zfs_refcount_add(&db->db_holds, tag) == 1) {
521 VERIFY(dnode_add_ref(dn, db));
522 atomic_inc_32(&dn->dn_dbufs_count);
523 }
524 diff --git a/module/zfs/dmu_tx.c b/module/zfs/dmu_tx.c
525 index 6ebff267..b1508ffa 100644
526 --- a/module/zfs/dmu_tx.c
527 +++ b/module/zfs/dmu_tx.c
528 @@ -114,7 +114,7 @@ dmu_tx_hold_dnode_impl(dmu_tx_t *tx, dnode_t *dn, enum dmu_tx_hold_type type,
529 dmu_tx_hold_t *txh;
530
531 if (dn != NULL) {
532 - (void) refcount_add(&dn->dn_holds, tx);
533 + (void) zfs_refcount_add(&dn->dn_holds, tx);
534 if (tx->tx_txg != 0) {
535 mutex_enter(&dn->dn_mtx);
536 /*
537 @@ -124,7 +124,7 @@ dmu_tx_hold_dnode_impl(dmu_tx_t *tx, dnode_t *dn, enum dmu_tx_hold_type type,
538 */
539 ASSERT(dn->dn_assigned_txg == 0);
540 dn->dn_assigned_txg = tx->tx_txg;
541 - (void) refcount_add(&dn->dn_tx_holds, tx);
542 + (void) zfs_refcount_add(&dn->dn_tx_holds, tx);
543 mutex_exit(&dn->dn_mtx);
544 }
545 }
546 @@ -916,7 +916,7 @@ dmu_tx_try_assign(dmu_tx_t *tx, uint64_t txg_how)
547 if (dn->dn_assigned_txg == 0)
548 dn->dn_assigned_txg = tx->tx_txg;
549 ASSERT3U(dn->dn_assigned_txg, ==, tx->tx_txg);
550 - (void) refcount_add(&dn->dn_tx_holds, tx);
551 + (void) zfs_refcount_add(&dn->dn_tx_holds, tx);
552 mutex_exit(&dn->dn_mtx);
553 }
554 towrite += refcount_count(&txh->txh_space_towrite);
555 diff --git a/module/zfs/dnode.c b/module/zfs/dnode.c
556 index 4a169c49..77d38c36 100644
557 --- a/module/zfs/dnode.c
558 +++ b/module/zfs/dnode.c
559 @@ -1267,7 +1267,7 @@ dnode_hold_impl(objset_t *os, uint64_t object, int flag, int slots,
560 if ((flag & DNODE_MUST_BE_FREE) && type != DMU_OT_NONE)
561 return (SET_ERROR(EEXIST));
562 DNODE_VERIFY(dn);
563 - (void) refcount_add(&dn->dn_holds, tag);
564 + (void) zfs_refcount_add(&dn->dn_holds, tag);
565 *dnp = dn;
566 return (0);
567 }
568 @@ -1484,7 +1484,7 @@ dnode_hold_impl(objset_t *os, uint64_t object, int flag, int slots,
569 return (type == DMU_OT_NONE ? ENOENT : EEXIST);
570 }
571
572 - if (refcount_add(&dn->dn_holds, tag) == 1)
573 + if (zfs_refcount_add(&dn->dn_holds, tag) == 1)
574 dbuf_add_ref(db, dnh);
575
576 mutex_exit(&dn->dn_mtx);
577 @@ -1524,7 +1524,7 @@ dnode_add_ref(dnode_t *dn, void *tag)
578 mutex_exit(&dn->dn_mtx);
579 return (FALSE);
580 }
581 - VERIFY(1 < refcount_add(&dn->dn_holds, tag));
582 + VERIFY(1 < zfs_refcount_add(&dn->dn_holds, tag));
583 mutex_exit(&dn->dn_mtx);
584 return (TRUE);
585 }
586 diff --git a/module/zfs/dsl_dataset.c b/module/zfs/dsl_dataset.c
587 index bd03b486..b7562bcd 100644
588 --- a/module/zfs/dsl_dataset.c
589 +++ b/module/zfs/dsl_dataset.c
590 @@ -645,7 +645,7 @@ void
591 dsl_dataset_long_hold(dsl_dataset_t *ds, void *tag)
592 {
593 ASSERT(dsl_pool_config_held(ds->ds_dir->dd_pool));
594 - (void) refcount_add(&ds->ds_longholds, tag);
595 + (void) zfs_refcount_add(&ds->ds_longholds, tag);
596 }
597
598 void
599 diff --git a/module/zfs/metaslab.c b/module/zfs/metaslab.c
600 index ee24850d..40658d51 100644
601 --- a/module/zfs/metaslab.c
602 +++ b/module/zfs/metaslab.c
603 @@ -2663,7 +2663,7 @@ metaslab_group_alloc_increment(spa_t *spa, uint64_t vdev, void *tag, int flags)
604 if (!mg->mg_class->mc_alloc_throttle_enabled)
605 return;
606
607 - (void) refcount_add(&mg->mg_alloc_queue_depth, tag);
608 + (void) zfs_refcount_add(&mg->mg_alloc_queue_depth, tag);
609 }
610
611 void
612 @@ -3360,7 +3360,7 @@ metaslab_class_throttle_reserve(metaslab_class_t *mc, int slots, zio_t *zio,
613 * them individually when an I/O completes.
614 */
615 for (d = 0; d < slots; d++) {
616 - reserved_slots = refcount_add(&mc->mc_alloc_slots, zio);
617 + reserved_slots = zfs_refcount_add(&mc->mc_alloc_slots, zio);
618 }
619 zio->io_flags |= ZIO_FLAG_IO_ALLOCATING;
620 slot_reserved = B_TRUE;
621 diff --git a/module/zfs/refcount.c b/module/zfs/refcount.c
622 index a151acea..13f9bb6b 100644
623 --- a/module/zfs/refcount.c
624 +++ b/module/zfs/refcount.c
625 @@ -55,7 +55,7 @@ refcount_fini(void)
626 }
627
628 void
629 -refcount_create(refcount_t *rc)
630 +refcount_create(zfs_refcount_t *rc)
631 {
632 mutex_init(&rc->rc_mtx, NULL, MUTEX_DEFAULT, NULL);
633 list_create(&rc->rc_list, sizeof (reference_t),
634 @@ -68,21 +68,21 @@ refcount_create(refcount_t *rc)
635 }
636
637 void
638 -refcount_create_tracked(refcount_t *rc)
639 +refcount_create_tracked(zfs_refcount_t *rc)
640 {
641 refcount_create(rc);
642 rc->rc_tracked = B_TRUE;
643 }
644
645 void
646 -refcount_create_untracked(refcount_t *rc)
647 +refcount_create_untracked(zfs_refcount_t *rc)
648 {
649 refcount_create(rc);
650 rc->rc_tracked = B_FALSE;
651 }
652
653 void
654 -refcount_destroy_many(refcount_t *rc, uint64_t number)
655 +refcount_destroy_many(zfs_refcount_t *rc, uint64_t number)
656 {
657 reference_t *ref;
658
659 @@ -103,25 +103,25 @@ refcount_destroy_many(refcount_t *rc, uint64_t number)
660 }
661
662 void
663 -refcount_destroy(refcount_t *rc)
664 +refcount_destroy(zfs_refcount_t *rc)
665 {
666 refcount_destroy_many(rc, 0);
667 }
668
669 int
670 -refcount_is_zero(refcount_t *rc)
671 +refcount_is_zero(zfs_refcount_t *rc)
672 {
673 return (rc->rc_count == 0);
674 }
675
676 int64_t
677 -refcount_count(refcount_t *rc)
678 +refcount_count(zfs_refcount_t *rc)
679 {
680 return (rc->rc_count);
681 }
682
683 int64_t
684 -refcount_add_many(refcount_t *rc, uint64_t number, void *holder)
685 +refcount_add_many(zfs_refcount_t *rc, uint64_t number, void *holder)
686 {
687 reference_t *ref = NULL;
688 int64_t count;
689 @@ -143,13 +143,13 @@ refcount_add_many(refcount_t *rc, uint64_t number, void *holder)
690 }
691
692 int64_t
693 -zfs_refcount_add(refcount_t *rc, void *holder)
694 +zfs_refcount_add(zfs_refcount_t *rc, void *holder)
695 {
696 return (refcount_add_many(rc, 1, holder));
697 }
698
699 int64_t
700 -refcount_remove_many(refcount_t *rc, uint64_t number, void *holder)
701 +refcount_remove_many(zfs_refcount_t *rc, uint64_t number, void *holder)
702 {
703 reference_t *ref;
704 int64_t count;
705 @@ -197,13 +197,13 @@ refcount_remove_many(refcount_t *rc, uint64_t number, void *holder)
706 }
707
708 int64_t
709 -refcount_remove(refcount_t *rc, void *holder)
710 +refcount_remove(zfs_refcount_t *rc, void *holder)
711 {
712 return (refcount_remove_many(rc, 1, holder));
713 }
714
715 void
716 -refcount_transfer(refcount_t *dst, refcount_t *src)
717 +refcount_transfer(zfs_refcount_t *dst, zfs_refcount_t *src)
718 {
719 int64_t count, removed_count;
720 list_t list, removed;
721 @@ -234,7 +234,7 @@ refcount_transfer(refcount_t *dst, refcount_t *src)
722 }
723
724 void
725 -refcount_transfer_ownership(refcount_t *rc, void *current_holder,
726 +refcount_transfer_ownership(zfs_refcount_t *rc, void *current_holder,
727 void *new_holder)
728 {
729 reference_t *ref;
730 @@ -264,7 +264,7 @@ refcount_transfer_ownership(refcount_t *rc, void *current_holder,
731 * might be held.
732 */
733 boolean_t
734 -refcount_held(refcount_t *rc, void *holder)
735 +refcount_held(zfs_refcount_t *rc, void *holder)
736 {
737 reference_t *ref;
738
739 @@ -292,7 +292,7 @@ refcount_held(refcount_t *rc, void *holder)
740 * since the reference might not be held.
741 */
742 boolean_t
743 -refcount_not_held(refcount_t *rc, void *holder)
744 +refcount_not_held(zfs_refcount_t *rc, void *holder)
745 {
746 reference_t *ref;
747
748 diff --git a/module/zfs/rrwlock.c b/module/zfs/rrwlock.c
749 index 704f7606..effff330 100644
750 --- a/module/zfs/rrwlock.c
751 +++ b/module/zfs/rrwlock.c
752 @@ -183,9 +183,9 @@ rrw_enter_read_impl(rrwlock_t *rrl, boolean_t prio, void *tag)
753 if (rrl->rr_writer_wanted || rrl->rr_track_all) {
754 /* may or may not be a re-entrant enter */
755 rrn_add(rrl, tag);
756 - (void) refcount_add(&rrl->rr_linked_rcount, tag);
757 + (void) zfs_refcount_add(&rrl->rr_linked_rcount, tag);
758 } else {
759 - (void) refcount_add(&rrl->rr_anon_rcount, tag);
760 + (void) zfs_refcount_add(&rrl->rr_anon_rcount, tag);
761 }
762 ASSERT(rrl->rr_writer == NULL);
763 mutex_exit(&rrl->rr_lock);
764 diff --git a/module/zfs/sa.c b/module/zfs/sa.c
765 index 1fb1a8b5..df4f6fd8 100644
766 --- a/module/zfs/sa.c
767 +++ b/module/zfs/sa.c
768 @@ -1337,7 +1337,7 @@ sa_idx_tab_hold(objset_t *os, sa_idx_tab_t *idx_tab)
769 ASSERTV(sa_os_t *sa = os->os_sa);
770
771 ASSERT(MUTEX_HELD(&sa->sa_lock));
772 - (void) refcount_add(&idx_tab->sa_refcount, NULL);
773 + (void) zfs_refcount_add(&idx_tab->sa_refcount, NULL);
774 }
775
776 void
777 diff --git a/module/zfs/spa_misc.c b/module/zfs/spa_misc.c
778 index cc1c641d..f6c9b40b 100644
779 --- a/module/zfs/spa_misc.c
780 +++ b/module/zfs/spa_misc.c
781 @@ -80,7 +80,7 @@
782 * definition they must have an existing reference, and will never need
783 * to lookup a spa_t by name.
784 *
785 - * spa_refcount (per-spa refcount_t protected by mutex)
786 + * spa_refcount (per-spa zfs_refcount_t protected by mutex)
787 *
788 * This reference count keep track of any active users of the spa_t. The
789 * spa_t cannot be destroyed or freed while this is non-zero. Internally,
790 @@ -414,7 +414,7 @@ spa_config_tryenter(spa_t *spa, int locks, void *tag, krw_t rw)
791 }
792 scl->scl_writer = curthread;
793 }
794 - (void) refcount_add(&scl->scl_count, tag);
795 + (void) zfs_refcount_add(&scl->scl_count, tag);
796 mutex_exit(&scl->scl_lock);
797 }
798 return (1);
799 @@ -448,7 +448,7 @@ spa_config_enter(spa_t *spa, int locks, void *tag, krw_t rw)
800 }
801 scl->scl_writer = curthread;
802 }
803 - (void) refcount_add(&scl->scl_count, tag);
804 + (void) zfs_refcount_add(&scl->scl_count, tag);
805 mutex_exit(&scl->scl_lock);
806 }
807 ASSERT(wlocks_held <= locks);
808 @@ -768,7 +768,7 @@ spa_open_ref(spa_t *spa, void *tag)
809 {
810 ASSERT(refcount_count(&spa->spa_refcount) >= spa->spa_minref ||
811 MUTEX_HELD(&spa_namespace_lock));
812 - (void) refcount_add(&spa->spa_refcount, tag);
813 + (void) zfs_refcount_add(&spa->spa_refcount, tag);
814 }
815
816 /*
817 diff --git a/module/zfs/zfs_ctldir.c b/module/zfs/zfs_ctldir.c
818 index 0ab5b4f0..de3c5a41 100644
819 --- a/module/zfs/zfs_ctldir.c
820 +++ b/module/zfs/zfs_ctldir.c
821 @@ -120,7 +120,7 @@ typedef struct {
822 taskqid_t se_taskqid; /* scheduled unmount taskqid */
823 avl_node_t se_node_name; /* zfs_snapshots_by_name link */
824 avl_node_t se_node_objsetid; /* zfs_snapshots_by_objsetid link */
825 - refcount_t se_refcount; /* reference count */
826 + zfs_refcount_t se_refcount; /* reference count */
827 } zfs_snapentry_t;
828
829 static void zfsctl_snapshot_unmount_delay_impl(zfs_snapentry_t *se, int delay);
830 @@ -169,7 +169,7 @@ zfsctl_snapshot_free(zfs_snapentry_t *se)
831 static void
832 zfsctl_snapshot_hold(zfs_snapentry_t *se)
833 {
834 - refcount_add(&se->se_refcount, NULL);
835 + zfs_refcount_add(&se->se_refcount, NULL);
836 }
837
838 /*
839 @@ -192,7 +192,7 @@ static void
840 zfsctl_snapshot_add(zfs_snapentry_t *se)
841 {
842 ASSERT(RW_WRITE_HELD(&zfs_snapshot_lock));
843 - refcount_add(&se->se_refcount, NULL);
844 + zfs_refcount_add(&se->se_refcount, NULL);
845 avl_add(&zfs_snapshots_by_name, se);
846 avl_add(&zfs_snapshots_by_objsetid, se);
847 }
848 @@ -269,7 +269,7 @@ zfsctl_snapshot_find_by_name(char *snapname)
849 search.se_name = snapname;
850 se = avl_find(&zfs_snapshots_by_name, &search, NULL);
851 if (se)
852 - refcount_add(&se->se_refcount, NULL);
853 + zfs_refcount_add(&se->se_refcount, NULL);
854
855 return (se);
856 }
857 @@ -290,7 +290,7 @@ zfsctl_snapshot_find_by_objsetid(spa_t *spa, uint64_t objsetid)
858 search.se_objsetid = objsetid;
859 se = avl_find(&zfs_snapshots_by_objsetid, &search, NULL);
860 if (se)
861 - refcount_add(&se->se_refcount, NULL);
862 + zfs_refcount_add(&se->se_refcount, NULL);
863
864 return (se);
865 }
866 diff --git a/module/zfs/zfs_znode.c b/module/zfs/zfs_znode.c
867 index e222c791..0ca10f82 100644
868 --- a/module/zfs/zfs_znode.c
869 +++ b/module/zfs/zfs_znode.c
870 @@ -272,7 +272,7 @@ zfs_znode_hold_enter(zfsvfs_t *zfsvfs, uint64_t obj)
871 ASSERT3U(zh->zh_obj, ==, obj);
872 found = B_TRUE;
873 }
874 - refcount_add(&zh->zh_refcount, NULL);
875 + zfs_refcount_add(&zh->zh_refcount, NULL);
876 mutex_exit(&zfsvfs->z_hold_locks[i]);
877
878 if (found == B_TRUE)