Commit 73a8fd93 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

xfs: consolidate the xfs_alloc_lookup_* helpers

Add a single xfs_alloc_lookup helper to sort out the argument passing and
setting of the active flag instead of duplicating the logic three times.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <djwong@kernel.org>
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
parent e9e66df8
...@@ -151,23 +151,35 @@ xfs_alloc_ag_max_usable( ...@@ -151,23 +151,35 @@ xfs_alloc_ag_max_usable(
return mp->m_sb.sb_agblocks - blocks; return mp->m_sb.sb_agblocks - blocks;
} }
static int
xfs_alloc_lookup(
struct xfs_btree_cur *cur,
xfs_lookup_t dir,
xfs_agblock_t bno,
xfs_extlen_t len,
int *stat)
{
int error;
cur->bc_rec.a.ar_startblock = bno;
cur->bc_rec.a.ar_blockcount = len;
error = xfs_btree_lookup(cur, dir, stat);
cur->bc_ag.abt.active = (*stat == 1);
return error;
}
/* /*
* Lookup the record equal to [bno, len] in the btree given by cur. * Lookup the record equal to [bno, len] in the btree given by cur.
*/ */
STATIC int /* error */ static inline int /* error */
xfs_alloc_lookup_eq( xfs_alloc_lookup_eq(
struct xfs_btree_cur *cur, /* btree cursor */ struct xfs_btree_cur *cur, /* btree cursor */
xfs_agblock_t bno, /* starting block of extent */ xfs_agblock_t bno, /* starting block of extent */
xfs_extlen_t len, /* length of extent */ xfs_extlen_t len, /* length of extent */
int *stat) /* success/failure */ int *stat) /* success/failure */
{ {
int error; return xfs_alloc_lookup(cur, XFS_LOOKUP_EQ, bno, len, stat);
cur->bc_rec.a.ar_startblock = bno;
cur->bc_rec.a.ar_blockcount = len;
error = xfs_btree_lookup(cur, XFS_LOOKUP_EQ, stat);
cur->bc_ag.abt.active = (*stat == 1);
return error;
} }
/* /*
...@@ -181,13 +193,7 @@ xfs_alloc_lookup_ge( ...@@ -181,13 +193,7 @@ xfs_alloc_lookup_ge(
xfs_extlen_t len, /* length of extent */ xfs_extlen_t len, /* length of extent */
int *stat) /* success/failure */ int *stat) /* success/failure */
{ {
int error; return xfs_alloc_lookup(cur, XFS_LOOKUP_GE, bno, len, stat);
cur->bc_rec.a.ar_startblock = bno;
cur->bc_rec.a.ar_blockcount = len;
error = xfs_btree_lookup(cur, XFS_LOOKUP_GE, stat);
cur->bc_ag.abt.active = (*stat == 1);
return error;
} }
/* /*
...@@ -201,12 +207,7 @@ xfs_alloc_lookup_le( ...@@ -201,12 +207,7 @@ xfs_alloc_lookup_le(
xfs_extlen_t len, /* length of extent */ xfs_extlen_t len, /* length of extent */
int *stat) /* success/failure */ int *stat) /* success/failure */
{ {
int error; return xfs_alloc_lookup(cur, XFS_LOOKUP_LE, bno, len, stat);
cur->bc_rec.a.ar_startblock = bno;
cur->bc_rec.a.ar_blockcount = len;
error = xfs_btree_lookup(cur, XFS_LOOKUP_LE, stat);
cur->bc_ag.abt.active = (*stat == 1);
return error;
} }
static inline bool static inline bool
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment