bcachefs: Delete dead code from bch2_discard_one_bucket()
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 27 Oct 2024 02:52:06 +0000 (22:52 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sat, 21 Dec 2024 06:36:17 +0000 (01:36 -0500)
alloc key validation ensures that if a bucket is in need_discard state
the sector counts are all zero - we don't have to check for that.

The NEED_INC_GEN check appears to be dead code, as well: we only see
buckets in the need_discard btree, and it's an error if they aren't in
the need_discard state.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/alloc_background.c

index a1bd75a44d7963866d2b219a992779388ba2fc69..38df36f8e70a80f2c7f5c1ab3628cc50713e2acf 100644 (file)
@@ -1756,22 +1756,7 @@ static int bch2_discard_one_bucket(struct btree_trans *trans,
        if (ret)
                goto out;
 
-       if (bch2_bucket_sectors_total(a->v)) {
-               if (bch2_trans_inconsistent_on(c->curr_recovery_pass > BCH_RECOVERY_PASS_check_alloc_info,
-                                              trans, "attempting to discard bucket with dirty data\n%s",
-                                              (bch2_bkey_val_to_text(&buf, c, k), buf.buf)))
-                       ret = -EIO;
-               goto out;
-       }
-
        if (a->v.data_type != BCH_DATA_need_discard) {
-               if (data_type_is_empty(a->v.data_type) &&
-                   BCH_ALLOC_V4_NEED_INC_GEN(&a->v)) {
-                       a->v.gen++;
-                       SET_BCH_ALLOC_V4_NEED_INC_GEN(&a->v, false);
-                       goto write;
-               }
-
                if (bch2_trans_inconsistent_on(c->curr_recovery_pass > BCH_RECOVERY_PASS_check_alloc_info,
                                               trans, "bucket incorrectly set in need_discard btree\n"
                                               "%s",
@@ -1814,7 +1799,6 @@ static int bch2_discard_one_bucket(struct btree_trans *trans,
        }
 
        SET_BCH_ALLOC_V4_NEED_DISCARD(&a->v, false);
-write:
        alloc_data_type_set(&a->v, a->v.data_type);
 
        ret =   bch2_trans_update(trans, &iter, &a->k_i, 0) ?: