]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/alloc_background.c
Update bcachefs sources to 84505cfd37 bcachefs: Go RW before check_alloc_info()
[bcachefs-tools-debian] / libbcachefs / alloc_background.c
index 0939200e6d1a723edbeec55d0f6503cb78c00e84..ae6ae78a2618032949db2016d7bbbdb9e31af277 100644 (file)
@@ -800,6 +800,7 @@ static int bch2_bucket_do_index(struct btree_trans *trans,
                goto err;
 
        if (ca->mi.freespace_initialized &&
+           test_bit(BCH_FS_CHECK_ALLOC_DONE, &c->flags) &&
            bch2_trans_inconsistent_on(old.k->type != old_type, trans,
                        "incorrect key when %s %s btree (got %s should be %s)\n"
                        "  for %s",
@@ -1649,21 +1650,28 @@ static int bch2_discard_one_bucket(struct btree_trans *trans,
                goto write;
        }
 
-       if (bch2_trans_inconsistent_on(a->v.journal_seq > c->journal.flushed_seq_ondisk, trans,
-                       "clearing need_discard but journal_seq %llu > flushed_seq %llu\n"
-                       "%s",
-                       a->v.journal_seq,
-                       c->journal.flushed_seq_ondisk,
-                       (bch2_bkey_val_to_text(&buf, c, k), buf.buf))) {
-               ret = -EIO;
+       if (a->v.journal_seq > c->journal.flushed_seq_ondisk) {
+               if (test_bit(BCH_FS_CHECK_ALLOC_DONE, &c->flags)) {
+                       bch2_trans_inconsistent(trans,
+                               "clearing need_discard but journal_seq %llu > flushed_seq %llu\n"
+                               "%s",
+                               a->v.journal_seq,
+                               c->journal.flushed_seq_ondisk,
+                               (bch2_bkey_val_to_text(&buf, c, k), buf.buf));
+                       ret = -EIO;
+               }
                goto out;
        }
 
-       if (bch2_trans_inconsistent_on(a->v.data_type != BCH_DATA_need_discard, trans,
-                       "bucket incorrectly set in need_discard btree\n"
-                       "%s",
-                       (bch2_bkey_val_to_text(&buf, c, k), buf.buf))) {
-               ret = -EIO;
+       if (a->v.data_type != BCH_DATA_need_discard) {
+               if (test_bit(BCH_FS_CHECK_ALLOC_DONE, &c->flags)) {
+                       bch2_trans_inconsistent(trans,
+                               "bucket incorrectly set in need_discard btree\n"
+                               "%s",
+                               (bch2_bkey_val_to_text(&buf, c, k), buf.buf));
+                       ret = -EIO;
+               }
+
                goto out;
        }