md/raid5: Move stripe_add_to_batch_list() call out of add_stripe_bio()
authorLogan Gunthorpe <logang@deltatee.com>
Thu, 16 Jun 2022 19:19:34 +0000 (13:19 -0600)
committerSong Liu <song@kernel.org>
Sun, 3 Jul 2022 14:55:40 +0000 (07:55 -0700)
stripe_add_to_batch_list() is better done in the loop in make_request
instead of inside add_stripe_bio(). This is clearer and allows for
storing the batch_head state outside the loop in a subsequent patch.

The call to add_stripe_bio() in retry_aligned_read() is for read
and batching only applies to write. So it's impossible for batching
to happen at that call site.

No functional changes intended.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Signed-off-by: Song Liu <song@kernel.org>
drivers/md/raid5.c

index 25db747c5856f8c50971028e60f6a01c5c51fe0d..969609b7114b29d4c3dc0ecbfbdb13bb93421278 100644 (file)
@@ -3531,8 +3531,6 @@ static int add_stripe_bio(struct stripe_head *sh, struct bio *bi, int dd_idx,
        }
        spin_unlock_irq(&sh->stripe_lock);
 
-       if (stripe_can_batch(sh))
-               stripe_add_to_batch_list(conf, sh);
        return 1;
 
  overlap:
@@ -5950,6 +5948,9 @@ static bool raid5_make_request(struct mddev *mddev, struct bio * bi)
                        goto retry;
                }
 
+               if (stripe_can_batch(sh))
+                       stripe_add_to_batch_list(conf, sh);
+
                if (do_flush) {
                        set_bit(STRIPE_R5C_PREFLUSH, &sh->state);
                        /* we only need flush for one stripe */