]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Fix spurious inconsistency in recovery
authorKent Overstreet <kent.overstreet@gmail.com>
Tue, 14 May 2019 18:37:11 +0000 (14:37 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:22 +0000 (17:08 -0400)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/alloc_background.c
fs/bcachefs/buckets.c
fs/bcachefs/buckets.h

index 25c18b8cd3a694a71d5d736864279af9ebcf3ffa..61991d898d9908ee9180ac0ba12bdd3bcd2e063a 100644 (file)
@@ -232,7 +232,9 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys)
        bch2_trans_init(&trans, c);
 
        for_each_btree_key(&trans, iter, BTREE_ID_ALLOC, POS_MIN, 0, k, ret)
-               bch2_mark_key(c, k, true, 0, NULL, 0, 0);
+               bch2_mark_key(c, k, true, 0, NULL, 0,
+                             BCH_BUCKET_MARK_NOATOMIC|
+                             BCH_BUCKET_MARK_ALLOC_READ);
 
        ret = bch2_trans_exit(&trans) ?: ret;
        if (ret) {
@@ -243,7 +245,9 @@ int bch2_alloc_read(struct bch_fs *c, struct journal_keys *journal_keys)
        for_each_journal_key(*journal_keys, j)
                if (j->btree_id == BTREE_ID_ALLOC)
                        bch2_mark_key(c, bkey_i_to_s_c(j->k),
-                                     true, 0, NULL, 0, 0);
+                                     true, 0, NULL, 0,
+                                     BCH_BUCKET_MARK_NOATOMIC|
+                                     BCH_BUCKET_MARK_ALLOC_READ);
 
        percpu_down_write(&c->mark_lock);
        bch2_dev_usage_from_buckets(c);
index d0a288dddb45e710d42e867d97264fc7a27e9f7a..78b4c93a7170e5e1f642011e13d52c9cb4a1e254 100644 (file)
@@ -657,7 +657,7 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k,
        g = __bucket(ca, k.k->p.offset, gc);
        u = bch2_alloc_unpack(k);
 
-       old = bucket_data_cmpxchg(c, ca, fs_usage, g, m, ({
+       old = bucket_cmpxchg(g, m, ({
                m.gen                   = u.gen;
                m.data_type             = u.data_type;
                m.dirty_sectors         = u.dirty_sectors;
@@ -669,6 +669,9 @@ static int bch2_mark_alloc(struct bch_fs *c, struct bkey_s_c k,
                }
        }));
 
+       if (!(flags & BCH_BUCKET_MARK_ALLOC_READ))
+               bch2_dev_usage_update(c, ca, fs_usage, old, m, gc);
+
        g->io_time[READ]        = u.read_time;
        g->io_time[WRITE]       = u.write_time;
        g->oldest_gen           = u.oldest_gen;
index 578019089a91ff9a0f34bb357bb354abc7267481..9f53fe6280f38deca44d13a3e95220027b6d35b0 100644 (file)
@@ -251,6 +251,7 @@ void bch2_mark_metadata_bucket(struct bch_fs *, struct bch_dev *,
 
 #define BCH_BUCKET_MARK_GC                     (1 << 0)
 #define BCH_BUCKET_MARK_NOATOMIC               (1 << 1)
+#define BCH_BUCKET_MARK_ALLOC_READ             (1 << 2)
 
 int bch2_mark_key_locked(struct bch_fs *, struct bkey_s_c,
                  bool, s64, struct bch_fs_usage *,