]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
Btrfs: search parity device wisely
authorLiu Bo <bo.li.liu@oracle.com>
Thu, 3 Aug 2017 19:53:31 +0000 (13:53 -0600)
committerDavid Sterba <dsterba@suse.com>
Mon, 30 Oct 2017 11:27:55 +0000 (12:27 +0100)
After mapping block with BTRFS_MAP_WRITE, parities have been sorted to
the end position, so this search can start from the first parity
stripe.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Reviewed-by: David Sterba <dsterba@suse.com>
[ copied changelog as a comment ]
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/raid56.c

index 24a62224b24b1b5b307c84f38b07af31552729d7..cba5e7339462bc918d67a4e166ff4c6a87e53397 100644 (file)
@@ -2231,12 +2231,18 @@ raid56_parity_alloc_scrub_rbio(struct btrfs_fs_info *fs_info, struct bio *bio,
        ASSERT(!bio->bi_iter.bi_size);
        rbio->operation = BTRFS_RBIO_PARITY_SCRUB;
 
-       for (i = 0; i < rbio->real_stripes; i++) {
+       /*
+        * After mapping bbio with BTRFS_MAP_WRITE, parities have been sorted
+        * to the end position, so this search can start from the first parity
+        * stripe.
+        */
+       for (i = rbio->nr_data; i < rbio->real_stripes; i++) {
                if (bbio->stripes[i].dev == scrub_dev) {
                        rbio->scrubp = i;
                        break;
                }
        }
+       ASSERT(i < rbio->real_stripes);
 
        /* Now we just support the sectorsize equals to page size */
        ASSERT(fs_info->sectorsize == PAGE_SIZE);