/*
- * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
+ * Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of version 2 of the GNU General Public License as
xfs_trans_mod_sb(args->tp,
args->wasdel ? XFS_TRANS_SB_RES_FDBLOCKS :
XFS_TRANS_SB_FDBLOCKS, -slen);
- XFS_STATS_INC(xfsstats.xs_allocx);
- XFS_STATS_ADD(xfsstats.xs_allocb, args->len);
+ XFS_STATS_INC(xs_allocx);
+ XFS_STATS_ADD(xs_allocb, args->len);
}
return 0;
}
* Allocate/initialize a cursor for the by-number freespace btree.
*/
bno_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp,
- args->agno, XFS_BTNUM_BNO, 0, 0);
+ args->agno, XFS_BTNUM_BNO, NULL, 0);
/*
* Lookup bno and minlen in the btree (minlen is irrelevant, really).
* Look for the closest free block <= bno, it must contain bno
* Allocate/initialize a cursor for the by-size btree.
*/
cnt_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp,
- args->agno, XFS_BTNUM_CNT, 0, 0);
+ args->agno, XFS_BTNUM_CNT, NULL, 0);
ASSERT(args->agbno + args->len <=
INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_length,
ARCH_CONVERT));
/*
* Randomly don't execute the first algorithm.
*/
- static int seed; /* randomizing seed value */
int dofirst; /* set to do first algorithm */
- timespec_t now; /* current time */
- if (!seed) {
- nanotime(&now);
- seed = (int)now.tv_sec ^ (int)now.tv_nsec;
- }
dofirst = random() & 1;
#endif
/*
* Get a cursor for the by-size btree.
*/
cnt_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp,
- args->agno, XFS_BTNUM_CNT, 0, 0);
+ args->agno, XFS_BTNUM_CNT, NULL, 0);
ltlen = 0;
bno_cur_lt = bno_cur_gt = NULL;
/*
* Set up a cursor for the by-bno tree.
*/
bno_cur_lt = xfs_btree_init_cursor(args->mp, args->tp,
- args->agbp, args->agno, XFS_BTNUM_BNO, 0, 0);
+ args->agbp, args->agno, XFS_BTNUM_BNO, NULL, 0);
/*
* Fix up the btree entries.
*/
* Allocate and initialize the cursor for the leftward search.
*/
bno_cur_lt = xfs_btree_init_cursor(args->mp, args->tp, args->agbp,
- args->agno, XFS_BTNUM_BNO, 0, 0);
+ args->agno, XFS_BTNUM_BNO, NULL, 0);
/*
* Lookup <= bno to find the leftward search's starting point.
*/
* search.
*/
bno_cur_gt = bno_cur_lt;
- bno_cur_lt = 0;
+ bno_cur_lt = NULL;
}
/*
* Found something. Duplicate the cursor for the rightward search.
* Allocate and initialize a cursor for the by-size btree.
*/
cnt_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp,
- args->agno, XFS_BTNUM_CNT, 0, 0);
+ args->agno, XFS_BTNUM_CNT, NULL, 0);
bno_cur = NULL;
/*
* Look for an entry >= maxlen+alignment-1 blocks.
* Allocate and initialize a cursor for the by-block tree.
*/
bno_cur = xfs_btree_init_cursor(args->mp, args->tp, args->agbp,
- args->agno, XFS_BTNUM_BNO, 0, 0);
+ args->agno, XFS_BTNUM_BNO, NULL, 0);
if ((error = xfs_alloc_fixup_trees(cnt_cur, bno_cur, fbno, flen,
rbno, rlen, XFSA_FIXUP_CNT_OK)))
goto error0;
else if (args->minlen == 1 && args->alignment == 1 && !args->isfl &&
(INT_GET(XFS_BUF_TO_AGF(args->agbp)->agf_flcount,
ARCH_CONVERT) > args->minleft)) {
- if ((error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno)))
+ error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno);
+ if (error)
goto error0;
if (fbno != NULLAGBLOCK) {
if (args->userdata) {
/*
* Allocate and initialize a cursor for the by-block btree.
*/
- bno_cur = xfs_btree_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_BNO, 0,
+ bno_cur = xfs_btree_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_BNO, NULL,
0);
cnt_cur = NULL;
/*
/*
* Now allocate and initialize a cursor for the by-size tree.
*/
- cnt_cur = xfs_btree_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_CNT, 0,
+ cnt_cur = xfs_btree_init_cursor(mp, tp, agbp, agno, XFS_BTNUM_CNT, NULL,
0);
/*
* Have both left and right contiguous neighbors.
xfs_alloc_log_agf(tp, agbp, XFS_AGF_FREEBLKS);
if (!isfl)
xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, (long)len);
- XFS_STATS_INC(xfsstats.xs_freex);
- XFS_STATS_ADD(xfsstats.xs_freeb, len);
+ XFS_STATS_INC(xs_freex);
+ XFS_STATS_ADD(xs_freeb, len);
}
TRACE_FREE(haveleft ?
(haveright ? "both" : "left") :
/*
* Freelist is empty, give up.
*/
- if (INT_ISZERO(agf->agf_flcount, ARCH_CONVERT)) {
+ if (!agf->agf_flcount) {
*bnop = NULLAGBLOCK;
return 0;
}
INT_MOD(agf->agf_flfirst, ARCH_CONVERT, 1);
xfs_trans_brelse(tp, agflbp);
if (INT_GET(agf->agf_flfirst, ARCH_CONVERT) == XFS_AGFL_SIZE(mp))
- INT_ZERO(agf->agf_flfirst, ARCH_CONVERT);
+ agf->agf_flfirst = 0;
pag = &mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)];
INT_MOD(agf->agf_flcount, ARCH_CONVERT, -1);
xfs_trans_agflist_delta(tp, -1);
agfl = XFS_BUF_TO_AGFL(agflbp);
INT_MOD(agf->agf_fllast, ARCH_CONVERT, 1);
if (INT_GET(agf->agf_fllast, ARCH_CONVERT) == XFS_AGFL_SIZE(mp))
- INT_ZERO(agf->agf_fllast, ARCH_CONVERT);
+ agf->agf_fllast = 0;
pag = &mp->m_perag[INT_GET(agf->agf_seqno, ARCH_CONVERT)];
INT_MOD(agf->agf_flcount, ARCH_CONVERT, 1);
xfs_trans_agflist_delta(tp, 1);
xfs_alloctype_t type; /* input allocation type */
int bump_rotor = 0;
int no_min = 0;
+ xfs_agnumber_t rotorstep = xfs_rotorstep; /* inode32 agf stepper */
mp = args->mp;
type = args->otype = args->type;
*/
if ((args->userdata == XFS_ALLOC_INITIAL_USER_DATA) &&
(mp->m_flags & XFS_MOUNT_32BITINODES)) {
- args->fsbno = XFS_AGB_TO_FSB(mp, mp->m_agfrotor, 0);
+ args->fsbno = XFS_AGB_TO_FSB(mp,
+ ((mp->m_agfrotor / rotorstep) %
+ mp->m_sb.sb_agcount), 0);
bump_rotor = 1;
}
args->agbno = XFS_FSB_TO_AGBNO(mp, args->fsbno);
/*
* Start with the last place we left off.
*/
- args->agno = sagno = mp->m_agfrotor;
+ args->agno = sagno = (mp->m_agfrotor / rotorstep) %
+ mp->m_sb.sb_agcount;
args->type = XFS_ALLOCTYPE_THIS_AG;
flags = XFS_ALLOC_FLAG_TRYLOCK;
} else if (type == XFS_ALLOCTYPE_FIRST_AG) {
}
}
up_read(&mp->m_peraglock);
- if (bump_rotor || (type == XFS_ALLOCTYPE_ANY_AG))
- mp->m_agfrotor = (args->agno + 1) % mp->m_sb.sb_agcount;
+ if (bump_rotor || (type == XFS_ALLOCTYPE_ANY_AG)) {
+ if (args->agno == sagno)
+ mp->m_agfrotor = (mp->m_agfrotor + 1) %
+ (mp->m_sb.sb_agcount * rotorstep);
+ else
+ mp->m_agfrotor = (args->agno * rotorstep + 1) %
+ (mp->m_sb.sb_agcount * rotorstep);
+ }
break;
default:
ASSERT(0);