Lines Matching +full:non +full:- +full:overlapping
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
37 new->agno = pag->pag_agno; in xfs_extent_busy_insert_list()
38 new->bno = bno; in xfs_extent_busy_insert_list()
39 new->length = len; in xfs_extent_busy_insert_list()
40 INIT_LIST_HEAD(&new->list); in xfs_extent_busy_insert_list()
41 new->flags = flags; in xfs_extent_busy_insert_list()
44 trace_xfs_extent_busy(pag->pag_mount, pag->pag_agno, bno, len); in xfs_extent_busy_insert_list()
46 spin_lock(&pag->pagb_lock); in xfs_extent_busy_insert_list()
47 rbp = &pag->pagb_tree.rb_node; in xfs_extent_busy_insert_list()
52 if (new->bno < busyp->bno) { in xfs_extent_busy_insert_list()
53 rbp = &(*rbp)->rb_left; in xfs_extent_busy_insert_list()
54 ASSERT(new->bno + new->length <= busyp->bno); in xfs_extent_busy_insert_list()
55 } else if (new->bno > busyp->bno) { in xfs_extent_busy_insert_list()
56 rbp = &(*rbp)->rb_right; in xfs_extent_busy_insert_list()
57 ASSERT(bno >= busyp->bno + busyp->length); in xfs_extent_busy_insert_list()
63 rb_link_node(&new->rb_node, parent, rbp); in xfs_extent_busy_insert_list()
64 rb_insert_color(&new->rb_node, &pag->pagb_tree); in xfs_extent_busy_insert_list()
67 list_add_tail(&new->list, busy_list); in xfs_extent_busy_insert_list()
68 spin_unlock(&pag->pagb_lock); in xfs_extent_busy_insert_list()
79 xfs_extent_busy_insert_list(pag, bno, len, flags, &tp->t_busy); in xfs_extent_busy_insert()
96 * xfs_extent_busy_search(). This function returns 0 for no overlapping busy
97 * extent, -1 for an overlapping but not exact busy extent, and 1 for an exact
98 * match. This is done so that a non-zero return indicates an overlap that
114 spin_lock(&pag->pagb_lock); in xfs_extent_busy_search()
115 rbp = pag->pagb_tree.rb_node; in xfs_extent_busy_search()
118 if (bno < busyp->bno) { in xfs_extent_busy_search()
120 if (bno + len > busyp->bno) in xfs_extent_busy_search()
121 match = -1; in xfs_extent_busy_search()
122 rbp = rbp->rb_left; in xfs_extent_busy_search()
123 } else if (bno > busyp->bno) { in xfs_extent_busy_search()
125 if (bno < busyp->bno + busyp->length) in xfs_extent_busy_search()
126 match = -1; in xfs_extent_busy_search()
127 rbp = rbp->rb_right; in xfs_extent_busy_search()
130 match = (busyp->length == len) ? 1 : -1; in xfs_extent_busy_search()
134 spin_unlock(&pag->pagb_lock); in xfs_extent_busy_search()
141 * extent, the overlapping portion can be made unbusy and used for the
156 bool userdata) __releases(&pag->pagb_lock) in xfs_extent_busy_update_extent()
157 __acquires(&pag->pagb_lock) in xfs_extent_busy_update_extent()
160 xfs_agblock_t bbno = busyp->bno; in xfs_extent_busy_update_extent()
161 xfs_agblock_t bend = bbno + busyp->length; in xfs_extent_busy_update_extent()
168 if (busyp->flags & XFS_EXTENT_BUSY_DISCARDED) { in xfs_extent_busy_update_extent()
169 spin_unlock(&pag->pagb_lock); in xfs_extent_busy_update_extent()
171 spin_lock(&pag->pagb_lock); in xfs_extent_busy_update_extent()
176 * If there is a busy extent overlapping a user allocation, we have in xfs_extent_busy_update_extent()
191 * +---------+ in xfs_extent_busy_update_extent()
210 * +-----------------+ in xfs_extent_busy_update_extent()
216 * +--------------------------+ in xfs_extent_busy_update_extent()
222 * +--------------------------+ in xfs_extent_busy_update_extent()
228 * +-----------------------------------+ in xfs_extent_busy_update_extent()
244 rb_erase(&busyp->rb_node, &pag->pagb_tree); in xfs_extent_busy_update_extent()
245 busyp->length = 0; in xfs_extent_busy_update_extent()
252 * +---------+ in xfs_extent_busy_update_extent()
258 * +------------------+ in xfs_extent_busy_update_extent()
262 busyp->bno = fend; in xfs_extent_busy_update_extent()
263 busyp->length = bend - fend; in xfs_extent_busy_update_extent()
269 * +-------------+ in xfs_extent_busy_update_extent()
275 * +----------------------+ in xfs_extent_busy_update_extent()
278 busyp->length = fbno - busyp->bno; in xfs_extent_busy_update_extent()
283 trace_xfs_extent_busy_reuse(mp, pag->pag_agno, fbno, flen); in xfs_extent_busy_update_extent()
287 spin_unlock(&pag->pagb_lock); in xfs_extent_busy_update_extent()
289 trace_xfs_extent_busy_force(mp, pag->pag_agno, fbno, flen); in xfs_extent_busy_update_extent()
290 spin_lock(&pag->pagb_lock); in xfs_extent_busy_update_extent()
309 spin_lock(&pag->pagb_lock); in xfs_extent_busy_reuse()
311 rbp = pag->pagb_tree.rb_node; in xfs_extent_busy_reuse()
315 xfs_agblock_t bbno = busyp->bno; in xfs_extent_busy_reuse()
316 xfs_agblock_t bend = bbno + busyp->length; in xfs_extent_busy_reuse()
319 rbp = rbp->rb_left; in xfs_extent_busy_reuse()
322 rbp = rbp->rb_right; in xfs_extent_busy_reuse()
330 spin_unlock(&pag->pagb_lock); in xfs_extent_busy_reuse()
336 * args->minlen no suitable extent could be found, and the higher level
359 spin_lock(&args->pag->pagb_lock); in xfs_extent_busy_trim()
362 rbp = args->pag->pagb_tree.rb_node; in xfs_extent_busy_trim()
363 while (rbp && flen >= args->minlen) { in xfs_extent_busy_trim()
367 xfs_agblock_t bbno = busyp->bno; in xfs_extent_busy_trim()
368 xfs_agblock_t bend = bbno + busyp->length; in xfs_extent_busy_trim()
371 rbp = rbp->rb_left; in xfs_extent_busy_trim()
374 rbp = rbp->rb_right; in xfs_extent_busy_trim()
385 * +---------+ in xfs_extent_busy_trim()
391 * +-------------+ in xfs_extent_busy_trim()
397 * +-------------+ in xfs_extent_busy_trim()
403 * +-----------------+ in xfs_extent_busy_trim()
415 * +----------------------+ in xfs_extent_busy_trim()
421 * +--------------------------+ in xfs_extent_busy_trim()
425 * +-------+ in xfs_extent_busy_trim()
436 * +------------------+ in xfs_extent_busy_trim()
442 * +--------------------------+ in xfs_extent_busy_trim()
446 * +-------+ in xfs_extent_busy_trim()
457 * +-----------------------------------+ in xfs_extent_busy_trim()
461 * +-------+ OR +-------+ in xfs_extent_busy_trim()
484 if (bbno - fbno >= args->maxlen) { in xfs_extent_busy_trim()
487 } else if (fend - bend >= args->maxlen * 4) { in xfs_extent_busy_trim()
490 } else if (bbno - fbno >= args->minlen) { in xfs_extent_busy_trim()
498 flen = fend - fbno; in xfs_extent_busy_trim()
503 trace_xfs_extent_busy_trim(args->mp, args->agno, *bno, *len, in xfs_extent_busy_trim()
507 *busy_gen = args->pag->pagb_gen; in xfs_extent_busy_trim()
510 spin_unlock(&args->pag->pagb_lock); in xfs_extent_busy_trim()
515 * re-check if the trimmed extent satisfies the minlen requirement. in xfs_extent_busy_trim()
527 if (busyp->length) { in xfs_extent_busy_clear_one()
529 !(busyp->flags & XFS_EXTENT_BUSY_SKIP_DISCARD)) { in xfs_extent_busy_clear_one()
530 busyp->flags = XFS_EXTENT_BUSY_DISCARDED; in xfs_extent_busy_clear_one()
533 trace_xfs_extent_busy_clear(pag->pag_mount, busyp->agno, in xfs_extent_busy_clear_one()
534 busyp->bno, busyp->length); in xfs_extent_busy_clear_one()
535 rb_erase(&busyp->rb_node, &pag->pagb_tree); in xfs_extent_busy_clear_one()
538 list_del_init(&busyp->list); in xfs_extent_busy_clear_one()
564 pag = xfs_perag_get(mp, busyp->agno); in xfs_extent_busy_clear()
565 spin_lock(&pag->pagb_lock); in xfs_extent_busy_clear()
572 busyp->agno == pag->pag_agno); in xfs_extent_busy_clear()
575 pag->pagb_gen++; in xfs_extent_busy_clear()
576 wake_up_all(&pag->pagb_wait); in xfs_extent_busy_clear()
578 spin_unlock(&pag->pagb_lock); in xfs_extent_busy_clear()
593 * In this case, we must return -EAGAIN to avoid a deadlock by informing the
607 error = xfs_log_force(tp->t_mountp, XFS_LOG_SYNC); in xfs_extent_busy_flush()
612 if (!list_empty(&tp->t_busy)) { in xfs_extent_busy_flush()
616 if (busy_gen != READ_ONCE(pag->pagb_gen)) in xfs_extent_busy_flush()
620 return -EAGAIN; in xfs_extent_busy_flush()
625 prepare_to_wait(&pag->pagb_wait, &wait, TASK_KILLABLE); in xfs_extent_busy_flush()
626 if (busy_gen != READ_ONCE(pag->pagb_gen)) in xfs_extent_busy_flush()
631 finish_wait(&pag->pagb_wait, &wait); in xfs_extent_busy_flush()
645 prepare_to_wait(&pag->pagb_wait, &wait, TASK_KILLABLE); in xfs_extent_busy_wait_all()
646 if (RB_EMPTY_ROOT(&pag->pagb_tree)) in xfs_extent_busy_wait_all()
650 finish_wait(&pag->pagb_wait, &wait); in xfs_extent_busy_wait_all()
669 diff = b1->agno - b2->agno; in xfs_extent_busy_ag_cmp()
671 diff = b1->bno - b2->bno; in xfs_extent_busy_ag_cmp()
682 spin_lock(&pag->pagb_lock); in xfs_extent_busy_list_empty()
683 res = RB_EMPTY_ROOT(&pag->pagb_tree); in xfs_extent_busy_list_empty()
684 spin_unlock(&pag->pagb_lock); in xfs_extent_busy_list_empty()