]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
md/raid5: always convert llbitmap bits for discard
authorYu Kuai <yukuai@fygo.io>
Fri, 5 Jun 2026 07:26:39 +0000 (15:26 +0800)
committerYu Kuai <yukuai@fygo.io>
Sat, 20 Jun 2026 19:16:24 +0000 (03:16 +0800)
llbitmap discard is useful even when no underlying member device supports
it. The discard still converts the llbitmap range to unwritten, so later
reads and recovery do not rely on stale parity for that range.

Let llbitmap discard bypass the raid5 lower discard support check. If lower
discard is not safe or not supported, complete the accounted clone after
md_account_bio() so the llbitmap conversion callbacks run without member
discard bios.

Link: https://patch.msgid.link/20260605072639.2434847-4-yukuai@kernel.org
Signed-off-by: Yu Kuai <yukuai@fygo.io>
drivers/md/raid5.c

index 76e736ee48d386b92f45a7eeb9bb302302fd49f4..180ff0660b6ad64289f99e8d5ac384a270e42b20 100644 (file)
@@ -1138,6 +1138,9 @@ static bool raid5_discard_limits(struct mddev *mddev, struct bio *bi)
 {
        struct r5conf *conf = mddev->private;
 
+       if (mddev->bitmap_id == ID_LLBITMAP)
+               return true;
+
        if (!conf->raid5_discard_unsupported)
                return true;
 
@@ -5740,6 +5743,12 @@ static void make_discard_request(struct mddev *mddev, struct bio *bi)
        bi->bi_iter = bi_iter;
        bi->bi_next = NULL;
 
+       if (mddev->bitmap_id == ID_LLBITMAP &&
+           conf->raid5_discard_unsupported) {
+               bio_endio(bi);
+               return;
+       }
+
        logical_sector = first_stripe * conf->chunk_sectors;
        last_sector = last_stripe * conf->chunk_sectors;