]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
btrfs: raid56: simplify tracking of Q stripe presence
authorDavid Sterba <dsterba@suse.com>
Wed, 19 Feb 2020 14:17:20 +0000 (15:17 +0100)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Apr 2021 16:31:48 +0000 (18:31 +0200)
BugLink: https://bugs.launchpad.net/bugs/1920238
commit c17af96554a8a8777cbb0fd53b8497250e548b43 upstream.

There are temporary variables tracking the index of P and Q stripes, but
none of them is really used as such, merely for determining if the Q
stripe is present. This leads to compiler warnings with
-Wunused-but-set-variable and has been reported several times.

fs/btrfs/raid56.c: In function ‘finish_rmw’:
fs/btrfs/raid56.c:1199:6: warning: variable ‘p_stripe’ set but not used [-Wunused-but-set-variable]
 1199 |  int p_stripe = -1;
      |      ^~~~~~~~
fs/btrfs/raid56.c: In function ‘finish_parity_scrub’:
fs/btrfs/raid56.c:2356:6: warning: variable ‘p_stripe’ set but not used [-Wunused-but-set-variable]
 2356 |  int p_stripe = -1;
      |      ^~~~~~~~

Replace the two variables with one that has a clear meaning and also get
rid of the warnings. The logic that verifies that there are only 2
valid cases is unchanged.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
fs/btrfs/raid56.c

index 8f47a85944eb7883d6c165988ccb1e668b1de173..9fa7c660c32200b3b95b5308493f2f72f38f4ff0 100644 (file)
@@ -1198,22 +1198,19 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
        int nr_data = rbio->nr_data;
        int stripe;
        int pagenr;
-       int p_stripe = -1;
-       int q_stripe = -1;
+       bool has_qstripe;
        struct bio_list bio_list;
        struct bio *bio;
        int ret;
 
        bio_list_init(&bio_list);
 
-       if (rbio->real_stripes - rbio->nr_data == 1) {
-               p_stripe = rbio->real_stripes - 1;
-       } else if (rbio->real_stripes - rbio->nr_data == 2) {
-               p_stripe = rbio->real_stripes - 2;
-               q_stripe = rbio->real_stripes - 1;
-       } else {
+       if (rbio->real_stripes - rbio->nr_data == 1)
+               has_qstripe = false;
+       else if (rbio->real_stripes - rbio->nr_data == 2)
+               has_qstripe = true;
+       else
                BUG();
-       }
 
        /* at this point we either have a full stripe,
         * or we've read the full stripe from the drive.
@@ -1257,7 +1254,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio)
                SetPageUptodate(p);
                pointers[stripe++] = kmap(p);
 
-               if (q_stripe != -1) {
+               if (has_qstripe) {
 
                        /*
                         * raid6, add the qstripe and call the
@@ -2355,8 +2352,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
        int nr_data = rbio->nr_data;
        int stripe;
        int pagenr;
-       int p_stripe = -1;
-       int q_stripe = -1;
+       bool has_qstripe;
        struct page *p_page = NULL;
        struct page *q_page = NULL;
        struct bio_list bio_list;
@@ -2366,14 +2362,12 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
 
        bio_list_init(&bio_list);
 
-       if (rbio->real_stripes - rbio->nr_data == 1) {
-               p_stripe = rbio->real_stripes - 1;
-       } else if (rbio->real_stripes - rbio->nr_data == 2) {
-               p_stripe = rbio->real_stripes - 2;
-               q_stripe = rbio->real_stripes - 1;
-       } else {
+       if (rbio->real_stripes - rbio->nr_data == 1)
+               has_qstripe = false;
+       else if (rbio->real_stripes - rbio->nr_data == 2)
+               has_qstripe = true;
+       else
                BUG();
-       }
 
        if (bbio->num_tgtdevs && bbio->tgtdev_map[rbio->scrubp]) {
                is_replace = 1;
@@ -2395,7 +2389,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
                goto cleanup;
        SetPageUptodate(p_page);
 
-       if (q_stripe != -1) {
+       if (has_qstripe) {
                q_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM);
                if (!q_page) {
                        __free_page(p_page);
@@ -2418,8 +2412,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio,
                /* then add the parity stripe */
                pointers[stripe++] = kmap(p_page);
 
-               if (q_stripe != -1) {
-
+               if (has_qstripe) {
                        /*
                         * raid6, add the qstripe and call the
                         * library function to fill in our p/q