Inodes are always allocated in chunks of 64 and thus the loop in xfs_inobt_insert() is unnecessary. Also replace the use of hardcoded constants (i.e., XFS_INODES_PER_CHUNK) with values provided by the caller. This prepares the codepath to support sparse inode chunks, which might have varying numbers of free inodes. Signed-off-by: Brian Foster <bfoster@xxxxxxxxxx> --- fs/xfs/libxfs/xfs_ialloc.c | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index b62771f..6e2ccb3 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c @@ -134,37 +134,32 @@ xfs_inobt_insert( struct xfs_mount *mp, struct xfs_trans *tp, struct xfs_buf *agbp, - xfs_agino_t newino, - xfs_agino_t newlen, + xfs_agino_t newino, /* start inode of record */ + xfs_agino_t count, /* inode count */ + xfs_inofree_t free, /* free mask */ xfs_btnum_t btnum) { struct xfs_btree_cur *cur; struct xfs_agi *agi = XFS_BUF_TO_AGI(agbp); xfs_agnumber_t agno = be32_to_cpu(agi->agi_seqno); - xfs_agino_t thisino; int i; int error; cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, btnum); - for (thisino = newino; - thisino < newino + newlen; - thisino += XFS_INODES_PER_CHUNK) { - error = xfs_inobt_lookup(cur, thisino, XFS_LOOKUP_EQ, &i); - if (error) { - xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); - return error; - } - ASSERT(i == 0); + error = xfs_inobt_lookup(cur, newino, XFS_LOOKUP_EQ, &i); + if (error) { + xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); + return error; + } + ASSERT(i == 0); - error = xfs_inobt_insert_rec(cur, XFS_INODES_PER_CHUNK, - XFS_INOBT_ALL_FREE, &i); - if (error) { - xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); - return error; - } - ASSERT(i == 1); + error = xfs_inobt_insert_rec(cur, count, free, &i); + if (error) { + xfs_btree_del_cursor(cur, XFS_BTREE_ERROR); + return error; } + ASSERT(i == 1); xfs_btree_del_cursor(cur, XFS_BTREE_NOERROR); @@ -517,13 +512,13 @@ xfs_ialloc_ag_alloc( * Insert records describing the new inode chunk into the btrees. */ error = xfs_inobt_insert(args.mp, tp, agbp, newino, newlen, - XFS_BTNUM_INO); + XFS_INOBT_ALL_FREE, XFS_BTNUM_INO); if (error) return error; if (xfs_sb_version_hasfinobt(&args.mp->m_sb)) { error = xfs_inobt_insert(args.mp, tp, agbp, newino, newlen, - XFS_BTNUM_FINO); + XFS_INOBT_ALL_FREE, XFS_BTNUM_FINO); if (error) return error; } -- 1.8.3.1 _______________________________________________ xfs mailing list xfs@xxxxxxxxxxx http://oss.sgi.com/mailman/listinfo/xfs