Commit 6dfeb0c2 authored by Darrick J. Wong's avatar Darrick J. Wong

xfs: move btree bulkload record initialization to ->get_record implementations

When we're performing a bulk load of a btree, move the code that
actually stores the btree record in the new btree block out of the
generic code and into the individual ->get_record implementations.
This is preparation for being able to store multiple records with a
single indirect call.
Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent a20ffa7d
...@@ -440,22 +440,19 @@ STATIC int ...@@ -440,22 +440,19 @@ STATIC int
xfs_btree_bload_leaf( xfs_btree_bload_leaf(
struct xfs_btree_cur *cur, struct xfs_btree_cur *cur,
unsigned int recs_this_block, unsigned int recs_this_block,
xfs_btree_bload_get_record_fn get_record, xfs_btree_bload_get_records_fn get_records,
struct xfs_btree_block *block, struct xfs_btree_block *block,
void *priv) void *priv)
{ {
unsigned int j; unsigned int j = 1;
int ret; int ret;
/* Fill the leaf block with records. */ /* Fill the leaf block with records. */
for (j = 1; j <= recs_this_block; j++) { while (j <= recs_this_block) {
union xfs_btree_rec *block_rec; ret = get_records(cur, j, block, recs_this_block - j + 1, priv);
if (ret < 0)
ret = get_record(cur, priv);
if (ret)
return ret; return ret;
block_rec = xfs_btree_rec_addr(cur, j, block); j += ret;
cur->bc_ops->init_rec_from_cur(cur, block_rec);
} }
return 0; return 0;
...@@ -798,7 +795,7 @@ xfs_btree_bload( ...@@ -798,7 +795,7 @@ xfs_btree_bload(
trace_xfs_btree_bload_block(cur, level, i, blocks, &ptr, trace_xfs_btree_bload_block(cur, level, i, blocks, &ptr,
nr_this_block); nr_this_block);
ret = xfs_btree_bload_leaf(cur, nr_this_block, bbl->get_record, ret = xfs_btree_bload_leaf(cur, nr_this_block, bbl->get_records,
block, priv); block, priv);
if (ret) if (ret)
goto out; goto out;
......
...@@ -47,7 +47,9 @@ void xfs_btree_commit_ifakeroot(struct xfs_btree_cur *cur, struct xfs_trans *tp, ...@@ -47,7 +47,9 @@ void xfs_btree_commit_ifakeroot(struct xfs_btree_cur *cur, struct xfs_trans *tp,
int whichfork, const struct xfs_btree_ops *ops); int whichfork, const struct xfs_btree_ops *ops);
/* Bulk loading of staged btrees. */ /* Bulk loading of staged btrees. */
typedef int (*xfs_btree_bload_get_record_fn)(struct xfs_btree_cur *cur, void *priv); typedef int (*xfs_btree_bload_get_records_fn)(struct xfs_btree_cur *cur,
unsigned int idx, struct xfs_btree_block *block,
unsigned int nr_wanted, void *priv);
typedef int (*xfs_btree_bload_claim_block_fn)(struct xfs_btree_cur *cur, typedef int (*xfs_btree_bload_claim_block_fn)(struct xfs_btree_cur *cur,
union xfs_btree_ptr *ptr, void *priv); union xfs_btree_ptr *ptr, void *priv);
typedef size_t (*xfs_btree_bload_iroot_size_fn)(struct xfs_btree_cur *cur, typedef size_t (*xfs_btree_bload_iroot_size_fn)(struct xfs_btree_cur *cur,
...@@ -55,11 +57,14 @@ typedef size_t (*xfs_btree_bload_iroot_size_fn)(struct xfs_btree_cur *cur, ...@@ -55,11 +57,14 @@ typedef size_t (*xfs_btree_bload_iroot_size_fn)(struct xfs_btree_cur *cur,
struct xfs_btree_bload { struct xfs_btree_bload {
/* /*
* This function will be called nr_records times to load records into * This function will be called to load @nr_wanted records into the
* the btree. The function does this by setting the cursor's bc_rec * btree. The implementation does this by setting the cursor's bc_rec
* field in in-core format. Records must be returned in sort order. * field in in-core format and using init_rec_from_cur to set the
* records in the btree block. Records must be returned in sort order.
* The function must return the number of records loaded or the usual
* negative errno.
*/ */
xfs_btree_bload_get_record_fn get_record; xfs_btree_bload_get_records_fn get_records;
/* /*
* This function will be called nr_blocks times to obtain a pointer * This function will be called nr_blocks times to obtain a pointer
......
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