]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/blobdiff - fs/btrfs/raid56.c
btrfs: raid56: simplify tracking of Q stripe presence
[mirror_ubuntu-focal-kernel.git] / fs / btrfs / raid56.c
index 57a2ac721985062661329ffffc27e623eac5bcc4..9fa7c660c32200b3b95b5308493f2f72f38f4ff0 100644 (file)
@@ -190,7 +190,7 @@ static void scrub_parity_work(struct btrfs_work *work);
 
 static void start_async_work(struct btrfs_raid_bio *rbio, btrfs_func_t work_func)
 {
-       btrfs_init_work(&rbio->work, btrfs_rmw_helper, work_func, NULL, NULL);
+       btrfs_init_work(&rbio->work, work_func, NULL, NULL);
        btrfs_queue_work(rbio->fs_info->rmw_workers, &rbio->work);
 }
 
@@ -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
@@ -1743,8 +1740,7 @@ static void btrfs_raid_unplug(struct blk_plug_cb *cb, bool from_schedule)
        plug = container_of(cb, struct btrfs_plug_cb, cb);
 
        if (from_schedule) {
-               btrfs_init_work(&plug->work, btrfs_rmw_helper,
-                               unplug_work, NULL, NULL);
+               btrfs_init_work(&plug->work, unplug_work, NULL, NULL);
                btrfs_queue_work(plug->info->rmw_workers,
                                 &plug->work);
                return;
@@ -2356,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;
@@ -2367,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;
@@ -2396,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);
@@ -2419,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