]> git.hungrycats.org Git - linux/commitdiff
btrfs: raid56: pass REQ_META to per-device bios
authorMark Korenberg <socketpair@gmail.com>
Fri, 6 Nov 2026 17:33:10 +0000 (22:33 +0500)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Sun, 8 Nov 2026 23:38:09 +0000 (18:38 -0500)
RAID5/6 writes, and reads that need a rebuild, go through an rbio,
which builds new per-device bios from a bare REQ_OP_READ or
REQ_OP_WRITE.  So all tree block writes on RAID5/6 lose REQ_META, while
on the other profiles the per-device bios are clones and keep it.  The
same goes for a tree block read rebuilt from the other stripes, for
example with a missing device.

Pass REQ_META on to all per-device bios of an rbio, data and P/Q alike,
if any bio it serves has it.  Scrub and relocation do not set REQ_META,
so their rbios stay untagged, as do rbios that only serve file data.

[zygo: 7.3 port: 7.3 has no per-chunk stripe length (map->stripe_len,
map->stripe_shift, two-argument btrfs_stripe_nr_to_offset()), context
adjusted to BTRFS_STRIPE_LEN; the change itself is unchanged]

Signed-off-by: Mark Korenberg <socketpair@gmail.com>
Link: https://lore.kernel.org/r/20261106-btrfs-sb-read-req-meta-v2-2-71c1afaf5c67@gmail.com
Assisted-by: Claude:claude-opus-5-5
fs/btrfs/raid56.c
fs/btrfs/raid56.h

index 707c772201cbf2c2b2ee7bfde7dd6d96ce84056e..eb27fc567926d3b2e4ddbd00907e1115e9d9ee87 100644 (file)
@@ -1949,10 +1949,15 @@ static int rbio_add_io_paddrs(struct btrfs_raid_bio *rbio, struct bio_list *bio_
                }
        }
 
-       /* put a new bio on the list */
+       /*
+        * Put a new bio on the list.  Every per-device bio, data and P/Q
+        * alike, serves the bios in rbio->bio_list, so it is metadata I/O if
+        * any of them is: a tree block write, or a tree block read rebuilt
+        * from the other stripes.
+        */
        bio = bio_alloc(stripe->dev->bdev,
                        max(BTRFS_STRIPE_LEN >> PAGE_SHIFT, 1),
-                       op, GFP_NOFS);
+                       op | rbio->req_meta, GFP_NOFS);
        bio->bi_iter.bi_sector = disk_start >> SECTOR_SHIFT;
        bio->bi_private = rbio;
 
@@ -1993,8 +1998,11 @@ static void index_rbio_pages(struct btrfs_raid_bio *rbio)
        struct bio *bio;
 
        spin_lock(&rbio->bio_list_lock);
-       bio_list_for_each(bio, &rbio->bio_list)
+       rbio->req_meta = 0;
+       bio_list_for_each(bio, &rbio->bio_list) {
                index_one_bio(rbio, bio);
+               rbio->req_meta |= bio->bi_opf & REQ_META;
+       }
 
        spin_unlock(&rbio->bio_list_lock);
 }
index 313c19591bf6233e3fad77c51132e045f57260b2..78be1ac524b07d315eabef49ecb1678c252c22fe 100644 (file)
@@ -169,6 +169,13 @@ struct btrfs_raid_bio {
         */
        enum btrfs_rbio_ops operation;
 
+       /*
+        * REQ_META if any bio in bio_list has it.  Set under bio_list_lock by
+        * index_rbio_pages(), which runs before every assembly of per-device
+        * bios.
+        */
+       blk_opf_t req_meta;
+
        /* How many pages there are for the full stripe including P/Q */
        u16 nr_pages;