md: fast clone bio in bio_clone_mddev()
authorMing Lei <tom.leiming@gmail.com>
Tue, 14 Feb 2017 15:29:03 +0000 (23:29 +0800)
committerShaohua Li <shli@fb.com>
Wed, 15 Feb 2017 19:24:54 +0000 (11:24 -0800)
Firstly bio_clone_mddev() is used in raid normal I/O and isn't
in resync I/O path.

Secondly all the direct access to bvec table in raid happens on
resync I/O except for write behind of raid1, in which we still
use bio_clone() for allocating new bvec table.

So this patch replaces bio_clone() with bio_clone_fast()
in bio_clone_mddev().

Also kill bio_clone_mddev() and call bio_clone_fast() directly, as
suggested by Christoph Hellwig.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Shaohua Li <shli@fb.com>
drivers/md/faulty.c
drivers/md/md.c
drivers/md/md.h
drivers/md/raid1.c
drivers/md/raid10.c
drivers/md/raid5.c

index 685aa2d77e2526935f8f2f416ad8d8681b6c7b14..b0536cfd8e174b83a53d49391552b0c7ec64aef8 100644 (file)
@@ -214,7 +214,7 @@ static void faulty_make_request(struct mddev *mddev, struct bio *bio)
                }
        }
        if (failit) {
-               struct bio *b = bio_clone_mddev(bio, GFP_NOIO, mddev);
+               struct bio *b = bio_clone_fast(bio, GFP_NOIO, mddev->bio_set);
 
                b->bi_bdev = conf->rdev->bdev;
                b->bi_private = bio;
index 0e408bc6790439720c6c2f1f03152139e85eb635..55e7e7a8714eff69617518ba124dd5a806868e07 100644 (file)
@@ -190,13 +190,6 @@ struct bio *bio_alloc_mddev(gfp_t gfp_mask, int nr_iovecs,
 }
 EXPORT_SYMBOL_GPL(bio_alloc_mddev);
 
-struct bio *bio_clone_mddev(struct bio *bio, gfp_t gfp_mask,
-                           struct mddev *mddev)
-{
-       return bio_clone_bioset(bio, gfp_mask, mddev->bio_set);
-}
-EXPORT_SYMBOL_GPL(bio_clone_mddev);
-
 /*
  * We have a system wide 'event count' that is incremented
  * on any 'interesting' event, and readers of /proc/mdstat
index 42f8398181a81a6b8a5d2f2bcfc4f9c918410e1d..b8859cbf84b618b39ed3d92a2887e8764c403919 100644 (file)
@@ -673,8 +673,6 @@ extern void md_rdev_clear(struct md_rdev *rdev);
 
 extern void mddev_suspend(struct mddev *mddev);
 extern void mddev_resume(struct mddev *mddev);
-extern struct bio *bio_clone_mddev(struct bio *bio, gfp_t gfp_mask,
-                                  struct mddev *mddev);
 extern struct bio *bio_alloc_mddev(gfp_t gfp_mask, int nr_iovecs,
                                   struct mddev *mddev);
 
index 691d6d9bf740add6d889af3242a3d2b7c7b9c0f7..ad5c9483bd50ecfb5b7be282c86ba1e07befbbb2 100644 (file)
@@ -1108,7 +1108,7 @@ read_again:
        r1_bio->read_disk = rdisk;
        r1_bio->start_next_window = 0;
 
-       read_bio = bio_clone_mddev(bio, GFP_NOIO, mddev);
+       read_bio = bio_clone_fast(bio, GFP_NOIO, mddev->bio_set);
        bio_trim(read_bio, r1_bio->sector - bio->bi_iter.bi_sector,
                 max_sectors);
 
@@ -1376,7 +1376,7 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
                }
 
                if (!mbio) {
-                       mbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
+                       mbio = bio_clone_fast(bio, GFP_NOIO, mddev->bio_set);
                        bio_trim(mbio, offset, max_sectors);
                }
 
@@ -2286,7 +2286,8 @@ static int narrow_write_error(struct r1bio *r1_bio, int i)
 
                        wbio->bi_vcnt = vcnt;
                } else {
-                       wbio = bio_clone_mddev(r1_bio->master_bio, GFP_NOIO, mddev);
+                       wbio = bio_clone_fast(r1_bio->master_bio, GFP_NOIO,
+                                             mddev->bio_set);
                }
 
                bio_set_op_attrs(wbio, REQ_OP_WRITE, 0);
@@ -2424,7 +2425,8 @@ read_more:
                const unsigned long do_sync
                        = r1_bio->master_bio->bi_opf & REQ_SYNC;
                r1_bio->read_disk = disk;
-               bio = bio_clone_mddev(r1_bio->master_bio, GFP_NOIO, mddev);
+               bio = bio_clone_fast(r1_bio->master_bio, GFP_NOIO,
+                                    mddev->bio_set);
                bio_trim(bio, r1_bio->sector - bio->bi_iter.bi_sector,
                         max_sectors);
                r1_bio->bios[r1_bio->read_disk] = bio;
index 1920756828dfb3fd512e2cb5705f329f10324698..ade7d69234d54b3243792d182713cfec02f681aa 100644 (file)
@@ -1132,7 +1132,7 @@ read_again:
        }
        slot = r10_bio->read_slot;
 
-       read_bio = bio_clone_mddev(bio, GFP_NOIO, mddev);
+       read_bio = bio_clone_fast(bio, GFP_NOIO, mddev->bio_set);
        bio_trim(read_bio, r10_bio->sector - bio->bi_iter.bi_sector,
                 max_sectors);
 
@@ -1406,7 +1406,7 @@ retry_write:
                int d = r10_bio->devs[i].devnum;
                if (r10_bio->devs[i].bio) {
                        struct md_rdev *rdev = conf->mirrors[d].rdev;
-                       mbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
+                       mbio = bio_clone_fast(bio, GFP_NOIO, mddev->bio_set);
                        bio_trim(mbio, r10_bio->sector - bio->bi_iter.bi_sector,
                                 max_sectors);
                        r10_bio->devs[i].bio = mbio;
@@ -1457,7 +1457,7 @@ retry_write:
                                smp_mb();
                                rdev = conf->mirrors[d].rdev;
                        }
-                       mbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
+                       mbio = bio_clone_fast(bio, GFP_NOIO, mddev->bio_set);
                        bio_trim(mbio, r10_bio->sector - bio->bi_iter.bi_sector,
                                 max_sectors);
                        r10_bio->devs[i].repl_bio = mbio;
@@ -2565,7 +2565,7 @@ static int narrow_write_error(struct r10bio *r10_bio, int i)
                if (sectors > sect_to_write)
                        sectors = sect_to_write;
                /* Write at 'sector' for 'sectors' */
-               wbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
+               wbio = bio_clone_fast(bio, GFP_NOIO, mddev->bio_set);
                bio_trim(wbio, sector - bio->bi_iter.bi_sector, sectors);
                wsector = r10_bio->devs[i].addr + (sector - r10_bio->sector);
                wbio->bi_iter.bi_sector = wsector +
@@ -2641,8 +2641,7 @@ read_more:
                           mdname(mddev),
                           bdevname(rdev->bdev, b),
                           (unsigned long long)r10_bio->sector);
-       bio = bio_clone_mddev(r10_bio->master_bio,
-                             GFP_NOIO, mddev);
+       bio = bio_clone_fast(r10_bio->master_bio, GFP_NOIO, mddev->bio_set);
        bio_trim(bio, r10_bio->sector - bio->bi_iter.bi_sector, max_sectors);
        r10_bio->devs[slot].bio = bio;
        r10_bio->devs[slot].rdev = rdev;
index e2fa88fc6a1bbe5c6904f4249aa22b34111ab234..b193316804d47203af1746f3b7c09736821e0dba 100644 (file)
@@ -5056,9 +5056,9 @@ static int raid5_read_one_chunk(struct mddev *mddev, struct bio *raid_bio)
                return 0;
        }
        /*
-        * use bio_clone_mddev to make a copy of the bio
+        * use bio_clone_fast to make a copy of the bio
         */
-       align_bi = bio_clone_mddev(raid_bio, GFP_NOIO, mddev);
+       align_bi = bio_clone_fast(raid_bio, GFP_NOIO, mddev->bio_set);
        if (!align_bi)
                return 0;
        /*