Print this page
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/fs/zfs/zfs_rlock.c
+++ new/usr/src/uts/common/fs/zfs/zfs_rlock.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 /*
27 + * Copyright (c) 2012 by Delphix. All rights reserved.
28 + */
29 +
30 +
31 +
32 +/*
27 33 * This file contains the code to implement file range locking in
28 34 * ZFS, although there isn't much specific to ZFS (all that comes to mind
29 35 * support for growing the blocksize).
30 36 *
31 37 * Interface
32 38 * ---------
33 39 * Defined in zfs_rlock.h but essentially:
34 40 * rl = zfs_range_lock(zp, off, len, lock_type);
35 41 * zfs_range_unlock(rl);
36 42 * zfs_range_reduce(rl, off, len);
37 43 *
38 44 * AVL tree
39 45 * --------
40 46 * An AVL tree is used to maintain the state of the existing ranges
41 47 * that are locked for exclusive (writer) or shared (reader) use.
42 48 * The starting range offset is used for searching and sorting the tree.
43 49 *
44 50 * Common case
45 51 * -----------
46 52 * The (hopefully) usual case is of no overlaps or contention for
47 53 * locks. On entry to zfs_lock_range() a rl_t is allocated; the tree
48 54 * searched that finds no overlap, and *this* rl_t is placed in the tree.
49 55 *
50 56 * Overlaps/Reference counting/Proxy locks
51 57 * ---------------------------------------
52 58 * The avl code only allows one node at a particular offset. Also it's very
53 59 * inefficient to search through all previous entries looking for overlaps
54 60 * (because the very 1st in the ordered list might be at offset 0 but
55 61 * cover the whole file).
56 62 * So this implementation uses reference counts and proxy range locks.
57 63 * Firstly, only reader locks use reference counts and proxy locks,
58 64 * because writer locks are exclusive.
59 65 * When a reader lock overlaps with another then a proxy lock is created
60 66 * for that range and replaces the original lock. If the overlap
61 67 * is exact then the reference count of the proxy is simply incremented.
62 68 * Otherwise, the proxy lock is split into smaller lock ranges and
63 69 * new proxy locks created for non overlapping ranges.
64 70 * The reference counts are adjusted accordingly.
65 71 * Meanwhile, the orginal lock is kept around (this is the callers handle)
66 72 * and its offset and length are used when releasing the lock.
67 73 *
68 74 * Thread coordination
69 75 * -------------------
70 76 * In order to make wakeups efficient and to ensure multiple continuous
71 77 * readers on a range don't starve a writer for the same range lock,
72 78 * two condition variables are allocated in each rl_t.
73 79 * If a writer (or reader) can't get a range it initialises the writer
74 80 * (or reader) cv; sets a flag saying there's a writer (or reader) waiting;
75 81 * and waits on that cv. When a thread unlocks that range it wakes up all
76 82 * writers then all readers before destroying the lock.
77 83 *
78 84 * Append mode writes
79 85 * ------------------
80 86 * Append mode writes need to lock a range at the end of a file.
81 87 * The offset of the end of the file is determined under the
82 88 * range locking mutex, and the lock type converted from RL_APPEND to
83 89 * RL_WRITER and the range locked.
84 90 *
85 91 * Grow block handling
86 92 * -------------------
87 93 * ZFS supports multiple block sizes currently upto 128K. The smallest
88 94 * block size is used for the file which is grown as needed. During this
89 95 * growth all other writers and readers must be excluded.
90 96 * So if the block size needs to be grown then the whole file is
91 97 * exclusively locked, then later the caller will reduce the lock
92 98 * range to just the range to be written using zfs_reduce_range.
93 99 */
94 100
95 101 #include <sys/zfs_rlock.h>
96 102
97 103 /*
98 104 * Check if a write lock can be grabbed, or wait and recheck until available.
99 105 */
100 106 static void
101 107 zfs_range_lock_writer(znode_t *zp, rl_t *new)
102 108 {
103 109 avl_tree_t *tree = &zp->z_range_avl;
104 110 rl_t *rl;
105 111 avl_index_t where;
106 112 uint64_t end_size;
107 113 uint64_t off = new->r_off;
108 114 uint64_t len = new->r_len;
109 115
110 116 for (;;) {
111 117 /*
112 118 * Range locking is also used by zvol and uses a
113 119 * dummied up znode. However, for zvol, we don't need to
114 120 * append or grow blocksize, and besides we don't have
115 121 * a "sa" data or z_zfsvfs - so skip that processing.
116 122 *
117 123 * Yes, this is ugly, and would be solved by not handling
118 124 * grow or append in range lock code. If that was done then
119 125 * we could make the range locking code generically available
120 126 * to other non-zfs consumers.
121 127 */
122 128 if (zp->z_vnode) { /* caller is ZPL */
123 129 /*
124 130 * If in append mode pick up the current end of file.
125 131 * This is done under z_range_lock to avoid races.
126 132 */
127 133 if (new->r_type == RL_APPEND)
128 134 new->r_off = zp->z_size;
129 135
130 136 /*
131 137 * If we need to grow the block size then grab the whole
132 138 * file range. This is also done under z_range_lock to
133 139 * avoid races.
134 140 */
135 141 end_size = MAX(zp->z_size, new->r_off + len);
136 142 if (end_size > zp->z_blksz && (!ISP2(zp->z_blksz) ||
137 143 zp->z_blksz < zp->z_zfsvfs->z_max_blksz)) {
138 144 new->r_off = 0;
139 145 new->r_len = UINT64_MAX;
140 146 }
141 147 }
142 148
143 149 /*
144 150 * First check for the usual case of no locks
145 151 */
146 152 if (avl_numnodes(tree) == 0) {
147 153 new->r_type = RL_WRITER; /* convert to writer */
148 154 avl_add(tree, new);
149 155 return;
150 156 }
151 157
152 158 /*
153 159 * Look for any locks in the range.
154 160 */
155 161 rl = avl_find(tree, new, &where);
156 162 if (rl)
157 163 goto wait; /* already locked at same offset */
158 164
159 165 rl = (rl_t *)avl_nearest(tree, where, AVL_AFTER);
160 166 if (rl && (rl->r_off < new->r_off + new->r_len))
161 167 goto wait;
162 168
163 169 rl = (rl_t *)avl_nearest(tree, where, AVL_BEFORE);
164 170 if (rl && rl->r_off + rl->r_len > new->r_off)
165 171 goto wait;
166 172
167 173 new->r_type = RL_WRITER; /* convert possible RL_APPEND */
168 174 avl_insert(tree, new, where);
169 175 return;
170 176 wait:
171 177 if (!rl->r_write_wanted) {
172 178 cv_init(&rl->r_wr_cv, NULL, CV_DEFAULT, NULL);
173 179 rl->r_write_wanted = B_TRUE;
174 180 }
175 181 cv_wait(&rl->r_wr_cv, &zp->z_range_lock);
176 182
177 183 /* reset to original */
178 184 new->r_off = off;
179 185 new->r_len = len;
180 186 }
181 187 }
182 188
183 189 /*
184 190 * If this is an original (non-proxy) lock then replace it by
185 191 * a proxy and return the proxy.
186 192 */
187 193 static rl_t *
188 194 zfs_range_proxify(avl_tree_t *tree, rl_t *rl)
189 195 {
190 196 rl_t *proxy;
191 197
192 198 if (rl->r_proxy)
193 199 return (rl); /* already a proxy */
194 200
195 201 ASSERT3U(rl->r_cnt, ==, 1);
196 202 ASSERT(rl->r_write_wanted == B_FALSE);
197 203 ASSERT(rl->r_read_wanted == B_FALSE);
198 204 avl_remove(tree, rl);
199 205 rl->r_cnt = 0;
200 206
201 207 /* create a proxy range lock */
202 208 proxy = kmem_alloc(sizeof (rl_t), KM_SLEEP);
203 209 proxy->r_off = rl->r_off;
204 210 proxy->r_len = rl->r_len;
205 211 proxy->r_cnt = 1;
206 212 proxy->r_type = RL_READER;
207 213 proxy->r_proxy = B_TRUE;
208 214 proxy->r_write_wanted = B_FALSE;
209 215 proxy->r_read_wanted = B_FALSE;
210 216 avl_add(tree, proxy);
211 217
212 218 return (proxy);
213 219 }
214 220
215 221 /*
216 222 * Split the range lock at the supplied offset
217 223 * returning the *front* proxy.
218 224 */
219 225 static rl_t *
220 226 zfs_range_split(avl_tree_t *tree, rl_t *rl, uint64_t off)
221 227 {
222 228 rl_t *front, *rear;
223 229
224 230 ASSERT3U(rl->r_len, >, 1);
225 231 ASSERT3U(off, >, rl->r_off);
226 232 ASSERT3U(off, <, rl->r_off + rl->r_len);
227 233 ASSERT(rl->r_write_wanted == B_FALSE);
228 234 ASSERT(rl->r_read_wanted == B_FALSE);
229 235
230 236 /* create the rear proxy range lock */
231 237 rear = kmem_alloc(sizeof (rl_t), KM_SLEEP);
232 238 rear->r_off = off;
233 239 rear->r_len = rl->r_off + rl->r_len - off;
234 240 rear->r_cnt = rl->r_cnt;
235 241 rear->r_type = RL_READER;
236 242 rear->r_proxy = B_TRUE;
237 243 rear->r_write_wanted = B_FALSE;
238 244 rear->r_read_wanted = B_FALSE;
239 245
240 246 front = zfs_range_proxify(tree, rl);
241 247 front->r_len = off - rl->r_off;
242 248
243 249 avl_insert_here(tree, rear, front, AVL_AFTER);
244 250 return (front);
245 251 }
246 252
247 253 /*
248 254 * Create and add a new proxy range lock for the supplied range.
249 255 */
250 256 static void
251 257 zfs_range_new_proxy(avl_tree_t *tree, uint64_t off, uint64_t len)
252 258 {
253 259 rl_t *rl;
254 260
255 261 ASSERT(len);
256 262 rl = kmem_alloc(sizeof (rl_t), KM_SLEEP);
257 263 rl->r_off = off;
258 264 rl->r_len = len;
259 265 rl->r_cnt = 1;
260 266 rl->r_type = RL_READER;
261 267 rl->r_proxy = B_TRUE;
262 268 rl->r_write_wanted = B_FALSE;
263 269 rl->r_read_wanted = B_FALSE;
264 270 avl_add(tree, rl);
265 271 }
266 272
267 273 static void
268 274 zfs_range_add_reader(avl_tree_t *tree, rl_t *new, rl_t *prev, avl_index_t where)
269 275 {
270 276 rl_t *next;
271 277 uint64_t off = new->r_off;
272 278 uint64_t len = new->r_len;
273 279
274 280 /*
275 281 * prev arrives either:
276 282 * - pointing to an entry at the same offset
277 283 * - pointing to the entry with the closest previous offset whose
278 284 * range may overlap with the new range
279 285 * - null, if there were no ranges starting before the new one
280 286 */
281 287 if (prev) {
282 288 if (prev->r_off + prev->r_len <= off) {
283 289 prev = NULL;
284 290 } else if (prev->r_off != off) {
285 291 /*
286 292 * convert to proxy if needed then
287 293 * split this entry and bump ref count
288 294 */
289 295 prev = zfs_range_split(tree, prev, off);
290 296 prev = AVL_NEXT(tree, prev); /* move to rear range */
291 297 }
292 298 }
293 299 ASSERT((prev == NULL) || (prev->r_off == off));
294 300
295 301 if (prev)
296 302 next = prev;
297 303 else
298 304 next = (rl_t *)avl_nearest(tree, where, AVL_AFTER);
299 305
300 306 if (next == NULL || off + len <= next->r_off) {
301 307 /* no overlaps, use the original new rl_t in the tree */
302 308 avl_insert(tree, new, where);
303 309 return;
304 310 }
305 311
306 312 if (off < next->r_off) {
307 313 /* Add a proxy for initial range before the overlap */
308 314 zfs_range_new_proxy(tree, off, next->r_off - off);
309 315 }
310 316
311 317 new->r_cnt = 0; /* will use proxies in tree */
312 318 /*
313 319 * We now search forward through the ranges, until we go past the end
314 320 * of the new range. For each entry we make it a proxy if it
315 321 * isn't already, then bump its reference count. If there's any
316 322 * gaps between the ranges then we create a new proxy range.
317 323 */
318 324 for (prev = NULL; next; prev = next, next = AVL_NEXT(tree, next)) {
319 325 if (off + len <= next->r_off)
320 326 break;
321 327 if (prev && prev->r_off + prev->r_len < next->r_off) {
322 328 /* there's a gap */
323 329 ASSERT3U(next->r_off, >, prev->r_off + prev->r_len);
324 330 zfs_range_new_proxy(tree, prev->r_off + prev->r_len,
325 331 next->r_off - (prev->r_off + prev->r_len));
326 332 }
327 333 if (off + len == next->r_off + next->r_len) {
328 334 /* exact overlap with end */
329 335 next = zfs_range_proxify(tree, next);
330 336 next->r_cnt++;
331 337 return;
332 338 }
333 339 if (off + len < next->r_off + next->r_len) {
334 340 /* new range ends in the middle of this block */
335 341 next = zfs_range_split(tree, next, off + len);
336 342 next->r_cnt++;
337 343 return;
338 344 }
339 345 ASSERT3U(off + len, >, next->r_off + next->r_len);
340 346 next = zfs_range_proxify(tree, next);
341 347 next->r_cnt++;
342 348 }
343 349
344 350 /* Add the remaining end range. */
345 351 zfs_range_new_proxy(tree, prev->r_off + prev->r_len,
346 352 (off + len) - (prev->r_off + prev->r_len));
347 353 }
348 354
349 355 /*
350 356 * Check if a reader lock can be grabbed, or wait and recheck until available.
351 357 */
352 358 static void
353 359 zfs_range_lock_reader(znode_t *zp, rl_t *new)
354 360 {
355 361 avl_tree_t *tree = &zp->z_range_avl;
356 362 rl_t *prev, *next;
357 363 avl_index_t where;
358 364 uint64_t off = new->r_off;
359 365 uint64_t len = new->r_len;
360 366
361 367 /*
362 368 * Look for any writer locks in the range.
363 369 */
364 370 retry:
365 371 prev = avl_find(tree, new, &where);
366 372 if (prev == NULL)
367 373 prev = (rl_t *)avl_nearest(tree, where, AVL_BEFORE);
368 374
369 375 /*
370 376 * Check the previous range for a writer lock overlap.
371 377 */
372 378 if (prev && (off < prev->r_off + prev->r_len)) {
373 379 if ((prev->r_type == RL_WRITER) || (prev->r_write_wanted)) {
374 380 if (!prev->r_read_wanted) {
375 381 cv_init(&prev->r_rd_cv, NULL, CV_DEFAULT, NULL);
376 382 prev->r_read_wanted = B_TRUE;
377 383 }
378 384 cv_wait(&prev->r_rd_cv, &zp->z_range_lock);
379 385 goto retry;
380 386 }
381 387 if (off + len < prev->r_off + prev->r_len)
382 388 goto got_lock;
383 389 }
384 390
385 391 /*
386 392 * Search through the following ranges to see if there's
387 393 * write lock any overlap.
388 394 */
389 395 if (prev)
390 396 next = AVL_NEXT(tree, prev);
391 397 else
392 398 next = (rl_t *)avl_nearest(tree, where, AVL_AFTER);
393 399 for (; next; next = AVL_NEXT(tree, next)) {
394 400 if (off + len <= next->r_off)
395 401 goto got_lock;
396 402 if ((next->r_type == RL_WRITER) || (next->r_write_wanted)) {
397 403 if (!next->r_read_wanted) {
398 404 cv_init(&next->r_rd_cv, NULL, CV_DEFAULT, NULL);
399 405 next->r_read_wanted = B_TRUE;
400 406 }
401 407 cv_wait(&next->r_rd_cv, &zp->z_range_lock);
402 408 goto retry;
403 409 }
404 410 if (off + len <= next->r_off + next->r_len)
405 411 goto got_lock;
406 412 }
407 413
408 414 got_lock:
409 415 /*
410 416 * Add the read lock, which may involve splitting existing
411 417 * locks and bumping ref counts (r_cnt).
412 418 */
413 419 zfs_range_add_reader(tree, new, prev, where);
414 420 }
415 421
416 422 /*
417 423 * Lock a range (offset, length) as either shared (RL_READER)
418 424 * or exclusive (RL_WRITER). Returns the range lock structure
419 425 * for later unlocking or reduce range (if entire file
420 426 * previously locked as RL_WRITER).
421 427 */
422 428 rl_t *
423 429 zfs_range_lock(znode_t *zp, uint64_t off, uint64_t len, rl_type_t type)
424 430 {
425 431 rl_t *new;
426 432
427 433 ASSERT(type == RL_READER || type == RL_WRITER || type == RL_APPEND);
428 434
429 435 new = kmem_alloc(sizeof (rl_t), KM_SLEEP);
430 436 new->r_zp = zp;
431 437 new->r_off = off;
432 438 if (len + off < off) /* overflow */
433 439 len = UINT64_MAX - off;
434 440 new->r_len = len;
435 441 new->r_cnt = 1; /* assume it's going to be in the tree */
436 442 new->r_type = type;
437 443 new->r_proxy = B_FALSE;
438 444 new->r_write_wanted = B_FALSE;
439 445 new->r_read_wanted = B_FALSE;
440 446
441 447 mutex_enter(&zp->z_range_lock);
442 448 if (type == RL_READER) {
443 449 /*
444 450 * First check for the usual case of no locks
445 451 */
446 452 if (avl_numnodes(&zp->z_range_avl) == 0)
447 453 avl_add(&zp->z_range_avl, new);
448 454 else
449 455 zfs_range_lock_reader(zp, new);
450 456 } else
451 457 zfs_range_lock_writer(zp, new); /* RL_WRITER or RL_APPEND */
452 458 mutex_exit(&zp->z_range_lock);
453 459 return (new);
454 460 }
455 461
456 462 /*
457 463 * Unlock a reader lock
458 464 */
459 465 static void
460 466 zfs_range_unlock_reader(znode_t *zp, rl_t *remove)
461 467 {
462 468 avl_tree_t *tree = &zp->z_range_avl;
463 469 rl_t *rl, *next;
464 470 uint64_t len;
465 471
466 472 /*
467 473 * The common case is when the remove entry is in the tree
468 474 * (cnt == 1) meaning there's been no other reader locks overlapping
469 475 * with this one. Otherwise the remove entry will have been
470 476 * removed from the tree and replaced by proxies (one or
471 477 * more ranges mapping to the entire range).
472 478 */
473 479 if (remove->r_cnt == 1) {
↓ open down ↓ |
437 lines elided |
↑ open up ↑ |
474 480 avl_remove(tree, remove);
475 481 if (remove->r_write_wanted) {
476 482 cv_broadcast(&remove->r_wr_cv);
477 483 cv_destroy(&remove->r_wr_cv);
478 484 }
479 485 if (remove->r_read_wanted) {
480 486 cv_broadcast(&remove->r_rd_cv);
481 487 cv_destroy(&remove->r_rd_cv);
482 488 }
483 489 } else {
484 - ASSERT3U(remove->r_cnt, ==, 0);
485 - ASSERT3U(remove->r_write_wanted, ==, 0);
486 - ASSERT3U(remove->r_read_wanted, ==, 0);
490 + ASSERT0(remove->r_cnt);
491 + ASSERT0(remove->r_write_wanted);
492 + ASSERT0(remove->r_read_wanted);
487 493 /*
488 494 * Find start proxy representing this reader lock,
489 495 * then decrement ref count on all proxies
490 496 * that make up this range, freeing them as needed.
491 497 */
492 498 rl = avl_find(tree, remove, NULL);
493 499 ASSERT(rl);
494 500 ASSERT(rl->r_cnt);
495 501 ASSERT(rl->r_type == RL_READER);
496 502 for (len = remove->r_len; len != 0; rl = next) {
497 503 len -= rl->r_len;
498 504 if (len) {
499 505 next = AVL_NEXT(tree, rl);
500 506 ASSERT(next);
501 507 ASSERT(rl->r_off + rl->r_len == next->r_off);
502 508 ASSERT(next->r_cnt);
503 509 ASSERT(next->r_type == RL_READER);
504 510 }
505 511 rl->r_cnt--;
506 512 if (rl->r_cnt == 0) {
507 513 avl_remove(tree, rl);
508 514 if (rl->r_write_wanted) {
509 515 cv_broadcast(&rl->r_wr_cv);
510 516 cv_destroy(&rl->r_wr_cv);
511 517 }
512 518 if (rl->r_read_wanted) {
513 519 cv_broadcast(&rl->r_rd_cv);
514 520 cv_destroy(&rl->r_rd_cv);
515 521 }
516 522 kmem_free(rl, sizeof (rl_t));
517 523 }
518 524 }
519 525 }
520 526 kmem_free(remove, sizeof (rl_t));
521 527 }
522 528
523 529 /*
524 530 * Unlock range and destroy range lock structure.
525 531 */
526 532 void
527 533 zfs_range_unlock(rl_t *rl)
528 534 {
529 535 znode_t *zp = rl->r_zp;
530 536
531 537 ASSERT(rl->r_type == RL_WRITER || rl->r_type == RL_READER);
532 538 ASSERT(rl->r_cnt == 1 || rl->r_cnt == 0);
533 539 ASSERT(!rl->r_proxy);
534 540
535 541 mutex_enter(&zp->z_range_lock);
536 542 if (rl->r_type == RL_WRITER) {
537 543 /* writer locks can't be shared or split */
538 544 avl_remove(&zp->z_range_avl, rl);
539 545 mutex_exit(&zp->z_range_lock);
540 546 if (rl->r_write_wanted) {
541 547 cv_broadcast(&rl->r_wr_cv);
542 548 cv_destroy(&rl->r_wr_cv);
543 549 }
544 550 if (rl->r_read_wanted) {
545 551 cv_broadcast(&rl->r_rd_cv);
546 552 cv_destroy(&rl->r_rd_cv);
547 553 }
548 554 kmem_free(rl, sizeof (rl_t));
549 555 } else {
550 556 /*
551 557 * lock may be shared, let zfs_range_unlock_reader()
552 558 * release the lock and free the rl_t
553 559 */
554 560 zfs_range_unlock_reader(zp, rl);
555 561 mutex_exit(&zp->z_range_lock);
556 562 }
557 563 }
558 564
559 565 /*
560 566 * Reduce range locked as RL_WRITER from whole file to specified range.
561 567 * Asserts the whole file is exclusivly locked and so there's only one
562 568 * entry in the tree.
563 569 */
564 570 void
565 571 zfs_range_reduce(rl_t *rl, uint64_t off, uint64_t len)
566 572 {
567 573 znode_t *zp = rl->r_zp;
568 574
569 575 /* Ensure there are no other locks */
570 576 ASSERT(avl_numnodes(&zp->z_range_avl) == 1);
571 577 ASSERT(rl->r_off == 0);
572 578 ASSERT(rl->r_type == RL_WRITER);
573 579 ASSERT(!rl->r_proxy);
574 580 ASSERT3U(rl->r_len, ==, UINT64_MAX);
575 581 ASSERT3U(rl->r_cnt, ==, 1);
576 582
577 583 mutex_enter(&zp->z_range_lock);
578 584 rl->r_off = off;
579 585 rl->r_len = len;
580 586 mutex_exit(&zp->z_range_lock);
581 587 if (rl->r_write_wanted)
582 588 cv_broadcast(&rl->r_wr_cv);
583 589 if (rl->r_read_wanted)
584 590 cv_broadcast(&rl->r_rd_cv);
585 591 }
586 592
587 593 /*
588 594 * AVL comparison function used to order range locks
589 595 * Locks are ordered on the start offset of the range.
590 596 */
591 597 int
592 598 zfs_range_compare(const void *arg1, const void *arg2)
593 599 {
594 600 const rl_t *rl1 = arg1;
595 601 const rl_t *rl2 = arg2;
596 602
597 603 if (rl1->r_off > rl2->r_off)
598 604 return (1);
599 605 if (rl1->r_off < rl2->r_off)
600 606 return (-1);
601 607 return (0);
602 608 }
↓ open down ↓ |
106 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX