Skip to content

Commit ee5fe8f

Browse files
author
Darrick J. Wong
committed
xfs: refactor converting btree irec to btree key
We keep doing these conversions to support btree queries, so refactor this into a helper. Signed-off-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
1 parent 2bea8df commit ee5fe8f

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

fs/xfs/libxfs/xfs_btree.c

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4937,6 +4937,19 @@ xfs_btree_overlapped_query_range(
49374937
return error;
49384938
}
49394939

4940+
static inline void
4941+
xfs_btree_key_from_irec(
4942+
struct xfs_btree_cur *cur,
4943+
union xfs_btree_key *key,
4944+
const union xfs_btree_irec *irec)
4945+
{
4946+
union xfs_btree_rec rec;
4947+
4948+
cur->bc_rec = *irec;
4949+
cur->bc_ops->init_rec_from_cur(cur, &rec);
4950+
cur->bc_ops->init_key_from_rec(key, &rec);
4951+
}
4952+
49404953
/*
49414954
* Query a btree for all records overlapping a given interval of keys. The
49424955
* supplied function will be called with each record found; return one of the
@@ -4951,18 +4964,12 @@ xfs_btree_query_range(
49514964
xfs_btree_query_range_fn fn,
49524965
void *priv)
49534966
{
4954-
union xfs_btree_rec rec;
49554967
union xfs_btree_key low_key;
49564968
union xfs_btree_key high_key;
49574969

49584970
/* Find the keys of both ends of the interval. */
4959-
cur->bc_rec = *high_rec;
4960-
cur->bc_ops->init_rec_from_cur(cur, &rec);
4961-
cur->bc_ops->init_key_from_rec(&high_key, &rec);
4962-
4963-
cur->bc_rec = *low_rec;
4964-
cur->bc_ops->init_rec_from_cur(cur, &rec);
4965-
cur->bc_ops->init_key_from_rec(&low_key, &rec);
4971+
xfs_btree_key_from_irec(cur, &high_key, high_rec);
4972+
xfs_btree_key_from_irec(cur, &low_key, low_rec);
49664973

49674974
/* Enforce low key < high key. */
49684975
if (cur->bc_ops->diff_two_keys(cur, &low_key, &high_key) > 0)

0 commit comments

Comments
 (0)