From: Darrick J. Wong Date: Wed, 31 May 2023 09:05:21 +0000 (+0200) Subject: xfs: refactor converting btree irec to btree key X-Git-Tag: v6.4.0~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=98226d914dcbd529837e1eb1ecc7b4f6bb4963e5;p=thirdparty%2Fxfsprogs-dev.git xfs: refactor converting btree irec to btree key Source kernel commit: ee5fe8ff6d19b35e7547af789cba877dbf04517b We keep doing these conversions to support btree queries, so refactor this into a helper. Signed-off-by: Darrick J. Wong Reviewed-by: Dave Chinner Reviewed-by: Dave Chinner Signed-off-by: Carlos Maiolino --- diff --git a/libxfs/xfs_btree.c b/libxfs/xfs_btree.c index 87ddff58d..9585b779a 100644 --- a/libxfs/xfs_btree.c +++ b/libxfs/xfs_btree.c @@ -4934,6 +4934,19 @@ out: return error; } +static inline void +xfs_btree_key_from_irec( + struct xfs_btree_cur *cur, + union xfs_btree_key *key, + const union xfs_btree_irec *irec) +{ + union xfs_btree_rec rec; + + cur->bc_rec = *irec; + cur->bc_ops->init_rec_from_cur(cur, &rec); + cur->bc_ops->init_key_from_rec(key, &rec); +} + /* * Query a btree for all records overlapping a given interval of keys. The * supplied function will be called with each record found; return one of the @@ -4948,18 +4961,12 @@ xfs_btree_query_range( xfs_btree_query_range_fn fn, void *priv) { - union xfs_btree_rec rec; union xfs_btree_key low_key; union xfs_btree_key high_key; /* Find the keys of both ends of the interval. */ - cur->bc_rec = *high_rec; - cur->bc_ops->init_rec_from_cur(cur, &rec); - cur->bc_ops->init_key_from_rec(&high_key, &rec); - - cur->bc_rec = *low_rec; - cur->bc_ops->init_rec_from_cur(cur, &rec); - cur->bc_ops->init_key_from_rec(&low_key, &rec); + xfs_btree_key_from_irec(cur, &high_key, high_rec); + xfs_btree_key_from_irec(cur, &low_key, low_rec); /* Enforce low key < high key. */ if (cur->bc_ops->diff_two_keys(cur, &low_key, &high_key) > 0)