diff --git a/kmod/src/forest.c b/kmod/src/forest.c index f08724d9..0e5c31d3 100644 --- a/kmod/src/forest.c +++ b/kmod/src/forest.c @@ -238,19 +238,16 @@ static int forest_read_items(struct super_block *sb, struct scoutfs_key *key, u6 * We return -ESTALE if we hit stale blocks to give the caller a chance * to reset their state and retry with a newer version of the btrees. */ -int scoutfs_forest_read_items(struct super_block *sb, - struct scoutfs_key *key, - struct scoutfs_key *bloom_key, - struct scoutfs_key *start, - struct scoutfs_key *end, - scoutfs_forest_item_cb cb, void *arg) +int scoutfs_forest_read_items_roots(struct super_block *sb, struct scoutfs_net_roots *roots, + struct scoutfs_key *key, struct scoutfs_key *bloom_key, + struct scoutfs_key *start, struct scoutfs_key *end, + scoutfs_forest_item_cb cb, void *arg) { struct forest_read_items_data rid = { .cb = cb, .cb_arg = arg, }; struct scoutfs_log_trees lt; - struct scoutfs_net_roots roots; struct scoutfs_bloom_block *bb; struct forest_bloom_nrs bloom; SCOUTFS_BTREE_ITEM_REF(iref); @@ -264,18 +261,14 @@ int scoutfs_forest_read_items(struct super_block *sb, scoutfs_inc_counter(sb, forest_read_items); calc_bloom_nrs(&bloom, bloom_key); - ret = scoutfs_client_get_roots(sb, &roots); - if (ret) - goto out; - - trace_scoutfs_forest_using_roots(sb, &roots.fs_root, &roots.logs_root); + trace_scoutfs_forest_using_roots(sb, &roots->fs_root, &roots->logs_root); *start = orig_start; *end = orig_end; /* start with fs root items */ rid.fic |= FIC_FS_ROOT; - ret = scoutfs_btree_read_items(sb, &roots.fs_root, key, start, end, + ret = scoutfs_btree_read_items(sb, &roots->fs_root, key, start, end, forest_read_items, &rid); if (ret < 0) goto out; @@ -283,7 +276,7 @@ int scoutfs_forest_read_items(struct super_block *sb, scoutfs_key_init_log_trees(<k, 0, 0); for (;; scoutfs_key_inc(<k)) { - ret = scoutfs_btree_next(sb, &roots.logs_root, <k, &iref); + ret = scoutfs_btree_next(sb, &roots->logs_root, <k, &iref); if (ret == 0) { if (iref.val_len == sizeof(lt)) { ltk = *iref.key; @@ -340,6 +333,23 @@ out: return ret; } +int scoutfs_forest_read_items(struct super_block *sb, + struct scoutfs_key *key, + struct scoutfs_key *bloom_key, + struct scoutfs_key *start, + struct scoutfs_key *end, + scoutfs_forest_item_cb cb, void *arg) +{ + struct scoutfs_net_roots roots; + int ret; + + ret = scoutfs_client_get_roots(sb, &roots); + if (ret == 0) + ret = scoutfs_forest_read_items_roots(sb, &roots, key, bloom_key, start, end, + cb, arg); + return ret; +} + /* * If the items are deltas then combine the src with the destination * value and store the result in the destination. diff --git a/kmod/src/forest.h b/kmod/src/forest.h index 24753e89..151affb8 100644 --- a/kmod/src/forest.h +++ b/kmod/src/forest.h @@ -24,6 +24,10 @@ int scoutfs_forest_read_items(struct super_block *sb, struct scoutfs_key *start, struct scoutfs_key *end, scoutfs_forest_item_cb cb, void *arg); +int scoutfs_forest_read_items_roots(struct super_block *sb, struct scoutfs_net_roots *roots, + struct scoutfs_key *key, struct scoutfs_key *bloom_key, + struct scoutfs_key *start, struct scoutfs_key *end, + scoutfs_forest_item_cb cb, void *arg); int scoutfs_forest_set_bloom_bits(struct super_block *sb, struct scoutfs_lock *lock); void scoutfs_forest_set_max_seq(struct super_block *sb, u64 max_seq);