]> 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>
Sat, 7 Nov 2026 23:03:58 +0000 (18:03 -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.

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
fs/btrfs/raid56.c
fs/btrfs/raid56.h

index ea85d8e41e01ab89bc63da5cf4ef70733161d15c..d472dd7288a206c364b694582f37643f01f9bd59 100644 (file)
@@ -1879,10 +1879,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(rbio->bioc->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;
 
@@ -1923,8 +1928,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 22687b6194f93adc3c680dbc59aa1b879ed2eacc..a64a403a63cbd086483b7fdfab6b2b2d9be4db41 100644 (file)
@@ -167,6 +167,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;