Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 229031
b: refs/heads/master
c: 9f9baab
h: refs/heads/master
i:
  229029: e82bffa
  229027: f441b95
  229023: 35c2425
v: v3
  • Loading branch information
Christoph Hellwig authored and Alex Elder committed Dec 16, 2010
1 parent 4d78f7f commit 8fc161b
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 27 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ecff71e677c6d469f525dcf31ada709d5858307c
refs/heads/master: 9f9baab38dacd11fe6095a1e59f3783a305f7020
1 change: 1 addition & 0 deletions trunk/fs/xfs/linux-2.6/xfs_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,7 @@ DEFINE_EVENT(xfs_alloc_class, name, \
TP_PROTO(struct xfs_alloc_arg *args), \
TP_ARGS(args))
DEFINE_ALLOC_EVENT(xfs_alloc_exact_done);
DEFINE_ALLOC_EVENT(xfs_alloc_exact_notfound);
DEFINE_ALLOC_EVENT(xfs_alloc_exact_error);
DEFINE_ALLOC_EVENT(xfs_alloc_near_nominleft);
DEFINE_ALLOC_EVENT(xfs_alloc_near_first);
Expand Down
58 changes: 32 additions & 26 deletions trunk/fs/xfs/xfs_alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -577,61 +577,58 @@ xfs_alloc_ag_vextent_exact(
xfs_extlen_t rlen; /* length of returned extent */

ASSERT(args->alignment == 1);

/*
* Allocate/initialize a cursor for the by-number freespace btree.
*/
bno_cur = xfs_allocbt_init_cursor(args->mp, args->tp, args->agbp,
args->agno, XFS_BTNUM_BNO);
args->agno, XFS_BTNUM_BNO);

/*
* Lookup bno and minlen in the btree (minlen is irrelevant, really).
* Look for the closest free block <= bno, it must contain bno
* if any free block does.
*/
if ((error = xfs_alloc_lookup_le(bno_cur, args->agbno, args->minlen, &i)))
error = xfs_alloc_lookup_le(bno_cur, args->agbno, args->minlen, &i);
if (error)
goto error0;
if (!i) {
/*
* Didn't find it, return null.
*/
xfs_btree_del_cursor(bno_cur, XFS_BTREE_NOERROR);
args->agbno = NULLAGBLOCK;
return 0;
}
if (!i)
goto not_found;

/*
* Grab the freespace record.
*/
if ((error = xfs_alloc_get_rec(bno_cur, &fbno, &flen, &i)))
error = xfs_alloc_get_rec(bno_cur, &fbno, &flen, &i);
if (error)
goto error0;
XFS_WANT_CORRUPTED_GOTO(i == 1, error0);
ASSERT(fbno <= args->agbno);
minend = args->agbno + args->minlen;
maxend = args->agbno + args->maxlen;
fend = fbno + flen;

/*
* Give up if the freespace isn't long enough for the minimum request.
*/
if (fend < minend) {
xfs_btree_del_cursor(bno_cur, XFS_BTREE_NOERROR);
args->agbno = NULLAGBLOCK;
return 0;
}
if (fend < minend)
goto not_found;

/*
* End of extent will be smaller of the freespace end and the
* maximal requested end.
*/
end = XFS_AGBLOCK_MIN(fend, maxend);
/*
*
* Fix the length according to mod and prod if given.
*/
end = XFS_AGBLOCK_MIN(fend, maxend);
args->len = end - args->agbno;
xfs_alloc_fix_len(args);
if (!xfs_alloc_fix_minleft(args)) {
xfs_btree_del_cursor(bno_cur, XFS_BTREE_NOERROR);
return 0;
}
if (!xfs_alloc_fix_minleft(args))
goto not_found;

rlen = args->len;
ASSERT(args->agbno + rlen <= fend);
end = args->agbno + rlen;

/*
* We are allocating agbno for rlen [agbno .. end]
* Allocate/initialize a cursor for the by-size btree.
Expand All @@ -640,16 +637,25 @@ xfs_alloc_ag_vextent_exact(
args->agno, XFS_BTNUM_CNT);
ASSERT(args->agbno + args->len <=
be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_length));
if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen,
args->agbno, args->len, XFSA_FIXUP_BNO_OK))) {
error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen, args->agbno,
args->len, XFSA_FIXUP_BNO_OK);
if (error) {
xfs_btree_del_cursor(cnt_cur, XFS_BTREE_ERROR);
goto error0;
}

xfs_btree_del_cursor(bno_cur, XFS_BTREE_NOERROR);
xfs_btree_del_cursor(cnt_cur, XFS_BTREE_NOERROR);

trace_xfs_alloc_exact_done(args);
args->wasfromfl = 0;
trace_xfs_alloc_exact_done(args);
return 0;

not_found:
/* Didn't find it, return null. */
xfs_btree_del_cursor(bno_cur, XFS_BTREE_NOERROR);
args->agbno = NULLAGBLOCK;
trace_xfs_alloc_exact_notfound(args);
return 0;

error0:
Expand Down

0 comments on commit 8fc161b

Please sign in to comment.