raid5: avoid unnecessary bio data set
authorShaohua Li <shli@fb.com>
Tue, 23 Aug 2016 04:14:02 +0000 (21:14 -0700)
committerShaohua Li <shli@fb.com>
Wed, 24 Aug 2016 17:21:53 +0000 (10:21 -0700)
bio_reset doesn't change bi_io_vec and bi_max_vecs, so we don't need to
set them every time. bi_private will be set before the bio is
dispatched.

Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/raid5.c

index d1a279b1916b332833cfda986224979a63e16073..62febe8d491958b37a5a357021a72f363b84604e 100644 (file)
@@ -2005,7 +2005,12 @@ static struct stripe_head *alloc_stripe(struct kmem_cache *sc, gfp_t gfp,
                        struct r5dev *dev = &sh->dev[i];
 
                        bio_init(&dev->req);
+                       dev->req.bi_io_vec = &dev->vec;
+                       dev->req.bi_max_vecs = 1;
+
                        bio_init(&dev->rreq);
+                       dev->rreq.bi_io_vec = &dev->rvec;
+                       dev->rreq.bi_max_vecs = 1;
                }
        }
        return sh;
@@ -2507,14 +2512,6 @@ static void raid5_build_block(struct stripe_head *sh, int i, int previous)
 {
        struct r5dev *dev = &sh->dev[i];
 
-       dev->req.bi_io_vec = &dev->vec;
-       dev->req.bi_max_vecs = 1;
-       dev->req.bi_private = sh;
-
-       dev->rreq.bi_io_vec = &dev->rvec;
-       dev->rreq.bi_max_vecs = 1;
-       dev->rreq.bi_private = sh;
-
        dev->flags = 0;
        dev->sector = raid5_compute_blocknr(sh, i, previous);
 }