Lines Matching +full:non +full:- +full:overlapping
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
36 new->agno = pag->pag_agno; in xfs_extent_busy_insert_list()
37 new->bno = bno; in xfs_extent_busy_insert_list()
38 new->length = len; in xfs_extent_busy_insert_list()
39 INIT_LIST_HEAD(&new->list); in xfs_extent_busy_insert_list()
40 new->flags = flags; in xfs_extent_busy_insert_list()
43 trace_xfs_extent_busy(pag->pag_mount, pag->pag_agno, bno, len); in xfs_extent_busy_insert_list()
45 spin_lock(&pag->pagb_lock); in xfs_extent_busy_insert_list()
46 rbp = &pag->pagb_tree.rb_node; in xfs_extent_busy_insert_list()
51 if (new->bno < busyp->bno) { in xfs_extent_busy_insert_list()
52 rbp = &(*rbp)->rb_left; in xfs_extent_busy_insert_list()
53 ASSERT(new->bno + new->length <= busyp->bno); in xfs_extent_busy_insert_list()
54 } else if (new->bno > busyp->bno) { in xfs_extent_busy_insert_list()
55 rbp = &(*rbp)->rb_right; in xfs_extent_busy_insert_list()
56 ASSERT(bno >= busyp->bno + busyp->length); in xfs_extent_busy_insert_list()
62 rb_link_node(&new->rb_node, parent, rbp); in xfs_extent_busy_insert_list()
63 rb_insert_color(&new->rb_node, &pag->pagb_tree); in xfs_extent_busy_insert_list()
66 list_add_tail(&new->list, busy_list); in xfs_extent_busy_insert_list()
67 spin_unlock(&pag->pagb_lock); in xfs_extent_busy_insert_list()
78 xfs_extent_busy_insert_list(pag, bno, len, flags, &tp->t_busy); in xfs_extent_busy_insert()
95 * xfs_extent_busy_search(). This function returns 0 for no overlapping busy
96 * extent, -1 for an overlapping but not exact busy extent, and 1 for an exact
97 * match. This is done so that a non-zero return indicates an overlap that
113 spin_lock(&pag->pagb_lock); in xfs_extent_busy_search()
114 rbp = pag->pagb_tree.rb_node; in xfs_extent_busy_search()
117 if (bno < busyp->bno) { in xfs_extent_busy_search()
119 if (bno + len > busyp->bno) in xfs_extent_busy_search()
120 match = -1; in xfs_extent_busy_search()
121 rbp = rbp->rb_left; in xfs_extent_busy_search()
122 } else if (bno > busyp->bno) { in xfs_extent_busy_search()
124 if (bno < busyp->bno + busyp->length) in xfs_extent_busy_search()
125 match = -1; in xfs_extent_busy_search()
126 rbp = rbp->rb_right; in xfs_extent_busy_search()
129 match = (busyp->length == len) ? 1 : -1; in xfs_extent_busy_search()
133 spin_unlock(&pag->pagb_lock); in xfs_extent_busy_search()
140 * extent, the overlapping portion can be made unbusy and used for the
155 bool userdata) __releases(&pag->pagb_lock) in xfs_extent_busy_update_extent()
156 __acquires(&pag->pagb_lock) in xfs_extent_busy_update_extent()
159 xfs_agblock_t bbno = busyp->bno; in xfs_extent_busy_update_extent()
160 xfs_agblock_t bend = bbno + busyp->length; in xfs_extent_busy_update_extent()
167 if (busyp->flags & XFS_EXTENT_BUSY_DISCARDED) { in xfs_extent_busy_update_extent()
168 spin_unlock(&pag->pagb_lock); in xfs_extent_busy_update_extent()
170 spin_lock(&pag->pagb_lock); in xfs_extent_busy_update_extent()
175 * If there is a busy extent overlapping a user allocation, we have in xfs_extent_busy_update_extent()
190 * +---------+ in xfs_extent_busy_update_extent()
209 * +-----------------+ in xfs_extent_busy_update_extent()
215 * +--------------------------+ in xfs_extent_busy_update_extent()
221 * +--------------------------+ in xfs_extent_busy_update_extent()
227 * +-----------------------------------+ in xfs_extent_busy_update_extent()
243 rb_erase(&busyp->rb_node, &pag->pagb_tree); in xfs_extent_busy_update_extent()
244 busyp->length = 0; in xfs_extent_busy_update_extent()
251 * +---------+ in xfs_extent_busy_update_extent()
257 * +------------------+ in xfs_extent_busy_update_extent()
261 busyp->bno = fend; in xfs_extent_busy_update_extent()
262 busyp->length = bend - fend; in xfs_extent_busy_update_extent()
268 * +-------------+ in xfs_extent_busy_update_extent()
274 * +----------------------+ in xfs_extent_busy_update_extent()
277 busyp->length = fbno - busyp->bno; in xfs_extent_busy_update_extent()
282 trace_xfs_extent_busy_reuse(mp, pag->pag_agno, fbno, flen); in xfs_extent_busy_update_extent()
286 spin_unlock(&pag->pagb_lock); in xfs_extent_busy_update_extent()
288 trace_xfs_extent_busy_force(mp, pag->pag_agno, fbno, flen); in xfs_extent_busy_update_extent()
289 spin_lock(&pag->pagb_lock); in xfs_extent_busy_update_extent()
308 spin_lock(&pag->pagb_lock); in xfs_extent_busy_reuse()
310 rbp = pag->pagb_tree.rb_node; in xfs_extent_busy_reuse()
314 xfs_agblock_t bbno = busyp->bno; in xfs_extent_busy_reuse()
315 xfs_agblock_t bend = bbno + busyp->length; in xfs_extent_busy_reuse()
318 rbp = rbp->rb_left; in xfs_extent_busy_reuse()
321 rbp = rbp->rb_right; in xfs_extent_busy_reuse()
329 spin_unlock(&pag->pagb_lock); in xfs_extent_busy_reuse()
335 * args->minlen no suitable extent could be found, and the higher level
358 spin_lock(&args->pag->pagb_lock); in xfs_extent_busy_trim()
361 rbp = args->pag->pagb_tree.rb_node; in xfs_extent_busy_trim()
362 while (rbp && flen >= args->minlen) { in xfs_extent_busy_trim()
366 xfs_agblock_t bbno = busyp->bno; in xfs_extent_busy_trim()
367 xfs_agblock_t bend = bbno + busyp->length; in xfs_extent_busy_trim()
370 rbp = rbp->rb_left; in xfs_extent_busy_trim()
373 rbp = rbp->rb_right; in xfs_extent_busy_trim()
384 * +---------+ in xfs_extent_busy_trim()
390 * +-------------+ in xfs_extent_busy_trim()
396 * +-------------+ in xfs_extent_busy_trim()
402 * +-----------------+ in xfs_extent_busy_trim()
414 * +----------------------+ in xfs_extent_busy_trim()
420 * +--------------------------+ in xfs_extent_busy_trim()
424 * +-------+ in xfs_extent_busy_trim()
435 * +------------------+ in xfs_extent_busy_trim()
441 * +--------------------------+ in xfs_extent_busy_trim()
445 * +-------+ in xfs_extent_busy_trim()
456 * +-----------------------------------+ in xfs_extent_busy_trim()
460 * +-------+ OR +-------+ in xfs_extent_busy_trim()
483 if (bbno - fbno >= args->maxlen) { in xfs_extent_busy_trim()
486 } else if (fend - bend >= args->maxlen * 4) { in xfs_extent_busy_trim()
489 } else if (bbno - fbno >= args->minlen) { in xfs_extent_busy_trim()
497 flen = fend - fbno; in xfs_extent_busy_trim()
502 trace_xfs_extent_busy_trim(args->mp, args->agno, *bno, *len, in xfs_extent_busy_trim()
506 *busy_gen = args->pag->pagb_gen; in xfs_extent_busy_trim()
509 spin_unlock(&args->pag->pagb_lock); in xfs_extent_busy_trim()
514 * re-check if the trimmed extent satisfies the minlen requirement. in xfs_extent_busy_trim()
526 if (busyp->length) { in xfs_extent_busy_clear_one()
527 trace_xfs_extent_busy_clear(mp, busyp->agno, busyp->bno, in xfs_extent_busy_clear_one()
528 busyp->length); in xfs_extent_busy_clear_one()
529 rb_erase(&busyp->rb_node, &pag->pagb_tree); in xfs_extent_busy_clear_one()
532 list_del_init(&busyp->list); in xfs_extent_busy_clear_one()
540 __releases(pag->pagb_lock) in xfs_extent_busy_put_pag()
543 pag->pagb_gen++; in xfs_extent_busy_put_pag()
544 wake_up_all(&pag->pagb_wait); in xfs_extent_busy_put_pag()
547 spin_unlock(&pag->pagb_lock); in xfs_extent_busy_put_pag()
568 if (busyp->agno != agno) { in xfs_extent_busy_clear()
571 agno = busyp->agno; in xfs_extent_busy_clear()
573 spin_lock(&pag->pagb_lock); in xfs_extent_busy_clear()
577 if (do_discard && busyp->length && in xfs_extent_busy_clear()
578 !(busyp->flags & XFS_EXTENT_BUSY_SKIP_DISCARD)) { in xfs_extent_busy_clear()
579 busyp->flags = XFS_EXTENT_BUSY_DISCARDED; in xfs_extent_busy_clear()
600 * In this case, we must return -EAGAIN to avoid a deadlock by informing the
614 error = xfs_log_force(tp->t_mountp, XFS_LOG_SYNC); in xfs_extent_busy_flush()
619 if (!list_empty(&tp->t_busy)) { in xfs_extent_busy_flush()
623 if (busy_gen != READ_ONCE(pag->pagb_gen)) in xfs_extent_busy_flush()
627 return -EAGAIN; in xfs_extent_busy_flush()
632 prepare_to_wait(&pag->pagb_wait, &wait, TASK_KILLABLE); in xfs_extent_busy_flush()
633 if (busy_gen != READ_ONCE(pag->pagb_gen)) in xfs_extent_busy_flush()
638 finish_wait(&pag->pagb_wait, &wait); in xfs_extent_busy_flush()
652 prepare_to_wait(&pag->pagb_wait, &wait, TASK_KILLABLE); in xfs_extent_busy_wait_all()
653 if (RB_EMPTY_ROOT(&pag->pagb_tree)) in xfs_extent_busy_wait_all()
657 finish_wait(&pag->pagb_wait, &wait); in xfs_extent_busy_wait_all()
676 diff = b1->agno - b2->agno; in xfs_extent_busy_ag_cmp()
678 diff = b1->bno - b2->bno; in xfs_extent_busy_ag_cmp()