]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
bcachefs: Don't allocate stripes at POS_MIN
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 19 Jan 2021 01:20:24 +0000 (20:20 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:51 +0000 (17:08 -0400)
In the future, stripe index 0 will be a sentinal value. This patch
doesn't disallow stripes at POS_MIN yet, leaving that for when we do the
on disk format changes.

Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/bkey.h
fs/bcachefs/ec.c

index 5ce883ba22dc62dcbd8de2bfb5c9d779f3d72c72..f984064f4b5db7840ed9669e69cb5c4667252e8f 100644 (file)
@@ -178,6 +178,11 @@ static inline struct bpos bpos_min(struct bpos l, struct bpos r)
        return bkey_cmp(l, r) < 0 ? l : r;
 }
 
+static inline struct bpos bpos_max(struct bpos l, struct bpos r)
+{
+       return bkey_cmp(l, r) > 0 ? l : r;
+}
+
 void bch2_bpos_swab(struct bpos *);
 void bch2_bkey_swab_key(const struct bkey_format *, struct bkey_packed *);
 
index 43296763148cc8ef2c3343010ac0cfb875389713..f280ca20d4574627b8acadd68516a125f449d353 100644 (file)
@@ -690,7 +690,8 @@ static int ec_stripe_bkey_insert(struct bch_fs *c,
        struct btree_trans trans;
        struct btree_iter *iter;
        struct bkey_s_c k;
-       struct bpos start_pos = POS(0, c->ec_stripe_hint);
+       struct bpos min_pos = POS(0, 1);
+       struct bpos start_pos = bpos_max(min_pos, POS(0, c->ec_stripe_hint));
        int ret;
 
        bch2_trans_init(&trans, c, 0, 0);
@@ -701,7 +702,7 @@ retry:
                           BTREE_ITER_SLOTS|BTREE_ITER_INTENT, k, ret) {
                if (bkey_cmp(k.k->p, POS(0, U32_MAX)) > 0) {
                        if (start_pos.offset) {
-                               start_pos = POS_MIN;
+                               start_pos = min_pos;
                                bch2_btree_iter_set_pos(iter, start_pos);
                                continue;
                        }