summaryrefslogtreecommitdiff
path: root/libbcachefs/ec.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-06-03 16:21:35 -0400
committerKent Overstreet <kent.overstreet@gmail.com>2020-06-03 19:56:33 -0400
commit1952c0790c74e4e81d7066a19aabc5c55a13f10f (patch)
tree501fa5db6a5f1fd3b2412a2660e995c74ebf0bba /libbcachefs/ec.c
parent90d54b388666b258c97be6a4e632824d136356c4 (diff)
Update bcachefs sources to c9b4a210f9 fixup! bcachefs: Fixes for going RO
Diffstat (limited to 'libbcachefs/ec.c')
-rw-r--r--libbcachefs/ec.c47
1 files changed, 16 insertions, 31 deletions
diff --git a/libbcachefs/ec.c b/libbcachefs/ec.c
index 933945b..9442d6e 100644
--- a/libbcachefs/ec.c
+++ b/libbcachefs/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;