Deleted Added
full compact
refcount.c (307265) refcount.c (307277)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 6 unchanged lines hidden (view full) ---

15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE

--- 6 unchanged lines hidden (view full) ---

15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21/*
22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 * Copyright (c) 2012 by Delphix. All rights reserved.
23 * Copyright (c) 2012, 2015 by Delphix. All rights reserved.
24 */
25
26#include <sys/zfs_context.h>
27#include <sys/refcount.h>
28
29#ifdef ZFS_DEBUG
30
31#ifdef _KERNEL

--- 36 unchanged lines hidden (view full) ---

68 list_create(&rc->rc_removed, sizeof (reference_t),
69 offsetof(reference_t, ref_link));
70 rc->rc_count = 0;
71 rc->rc_removed_count = 0;
72 rc->rc_tracked = reference_tracking_enable;
73}
74
75void
24 */
25
26#include <sys/zfs_context.h>
27#include <sys/refcount.h>
28
29#ifdef ZFS_DEBUG
30
31#ifdef _KERNEL

--- 36 unchanged lines hidden (view full) ---

68 list_create(&rc->rc_removed, sizeof (reference_t),
69 offsetof(reference_t, ref_link));
70 rc->rc_count = 0;
71 rc->rc_removed_count = 0;
72 rc->rc_tracked = reference_tracking_enable;
73}
74
75void
76refcount_create_tracked(refcount_t *rc)
77{
78 refcount_create(rc);
79 rc->rc_tracked = B_TRUE;
80}
81
82void
76refcount_create_untracked(refcount_t *rc)
77{
78 refcount_create(rc);
79 rc->rc_tracked = B_FALSE;
80}
81
82void
83refcount_destroy_many(refcount_t *rc, uint64_t number)

--- 166 unchanged lines hidden (view full) ---

250 ref->ref_holder = new_holder;
251 found = B_TRUE;
252 break;
253 }
254 }
255 ASSERT(found);
256 mutex_exit(&rc->rc_mtx);
257}
83refcount_create_untracked(refcount_t *rc)
84{
85 refcount_create(rc);
86 rc->rc_tracked = B_FALSE;
87}
88
89void
90refcount_destroy_many(refcount_t *rc, uint64_t number)

--- 166 unchanged lines hidden (view full) ---

257 ref->ref_holder = new_holder;
258 found = B_TRUE;
259 break;
260 }
261 }
262 ASSERT(found);
263 mutex_exit(&rc->rc_mtx);
264}
265
266/*
267 * If tracking is enabled, return true if a reference exists that matches
268 * the "holder" tag. If tracking is disabled, then return true if a reference
269 * might be held.
270 */
271boolean_t
272refcount_held(refcount_t *rc, void *holder)
273{
274 reference_t *ref;
275
276 mutex_enter(&rc->rc_mtx);
277
278 if (!rc->rc_tracked) {
279 mutex_exit(&rc->rc_mtx);
280 return (rc->rc_count > 0);
281 }
282
283 for (ref = list_head(&rc->rc_list); ref;
284 ref = list_next(&rc->rc_list, ref)) {
285 if (ref->ref_holder == holder) {
286 mutex_exit(&rc->rc_mtx);
287 return (B_TRUE);
288 }
289 }
290 mutex_exit(&rc->rc_mtx);
291 return (B_FALSE);
292}
293
294/*
295 * If tracking is enabled, return true if a reference does not exist that
296 * matches the "holder" tag. If tracking is disabled, always return true
297 * since the reference might not be held.
298 */
299boolean_t
300refcount_not_held(refcount_t *rc, void *holder)
301{
302 reference_t *ref;
303
304 mutex_enter(&rc->rc_mtx);
305
306 if (!rc->rc_tracked) {
307 mutex_exit(&rc->rc_mtx);
308 return (B_TRUE);
309 }
310
311 for (ref = list_head(&rc->rc_list); ref;
312 ref = list_next(&rc->rc_list, ref)) {
313 if (ref->ref_holder == holder) {
314 mutex_exit(&rc->rc_mtx);
315 return (B_FALSE);
316 }
317 }
318 mutex_exit(&rc->rc_mtx);
319 return (B_TRUE);
320}
258#endif /* ZFS_DEBUG */
321#endif /* ZFS_DEBUG */