summaryrefslogtreecommitdiff
path: root/fs/bcachefs/ec.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/bcachefs/ec.c')
-rw-r--r--fs/bcachefs/ec.c47
1 files changed, 16 insertions, 31 deletions
diff --git a/fs/bcachefs/ec.c b/fs/bcachefs/ec.c
index 909a4a5036ab..074b811e9043 100644
--- a/fs/bcachefs/ec.c
+++ b/fs/bcachefs/ec.c
@@ -1273,38 +1273,28 @@ int bch2_stripes_write(struct bch_fs *c, unsigned flags, bool *wrote)
return ret;
}
-int bch2_stripes_read(struct bch_fs *c, struct journal_keys *journal_keys)
+static int bch2_stripes_read_fn(struct bch_fs *c, enum btree_id id,
+ unsigned level, struct bkey_s_c k)
{
- struct btree_trans trans;
- struct btree_and_journal_iter iter;
- struct bkey_s_c k;
- int ret;
-
- ret = bch2_fs_ec_start(c);
- if (ret)
- return ret;
-
- bch2_trans_init(&trans, c, 0, 0);
-
- bch2_btree_and_journal_iter_init(&iter, &trans, journal_keys,
- BTREE_ID_EC, POS_MIN);
-
+ int ret = 0;
- while ((k = bch2_btree_and_journal_iter_peek(&iter)).k) {
- bch2_mark_key(c, k, 0, 0, NULL, 0,
- BTREE_TRIGGER_ALLOC_READ|
- BTREE_TRIGGER_NOATOMIC);
+ if (k.k->type == KEY_TYPE_stripe)
+ ret = __ec_stripe_mem_alloc(c, k.k->p.offset, GFP_KERNEL) ?:
+ bch2_mark_key(c, k, 0, 0, NULL, 0,
+ BTREE_TRIGGER_ALLOC_READ|
+ BTREE_TRIGGER_NOATOMIC);
- bch2_btree_and_journal_iter_advance(&iter);
- }
+ return ret;
+}
- ret = bch2_trans_exit(&trans) ?: ret;
- if (ret) {
+int bch2_stripes_read(struct bch_fs *c, struct journal_keys *journal_keys)
+{
+ int ret = bch2_btree_and_journal_walk(c, journal_keys, BTREE_ID_EC,
+ NULL, bch2_stripes_read_fn);
+ if (ret)
bch_err(c, "error reading stripes: %i", ret);
- return ret;
- }
- return 0;
+ return ret;
}
int bch2_ec_mem_alloc(struct bch_fs *c, bool gc)
@@ -1343,11 +1333,6 @@ int bch2_ec_mem_alloc(struct bch_fs *c, bool gc)
return 0;
}
-int bch2_fs_ec_start(struct bch_fs *c)
-{
- return bch2_ec_mem_alloc(c, false);
-}
-
void bch2_fs_ec_exit(struct bch_fs *c)
{
struct ec_stripe_head *h;