Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1573821

[PATCH 3/4] md/raid1: use bio_clone_slow_mddev_partial in case of write behind

From Ming Lei <tom.leiming@gmail.com>
Newsgroups linux.kernel
Subject [PATCH 3/4] md/raid1: use bio_clone_slow_mddev_partial in case of write behind
Date 2017-02-05 07:30 +0100
Message-ID <t7ouJ-3zf-13@gated-at.bofh.it> (permalink)
References <t7ouJ-3zf-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Write behind need to replace pages in bio's bvecs, and we have
to clone a fresh bio with new bvec table, so use the introduced
bio_clone_slow_mddev_partial() for it.

For other bio_clone_mddev() cases, we will use fast clone since
they don't need to touch bvec table.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
 drivers/md/raid1.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 830ff2b20346..e1c5639febdb 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -1341,13 +1341,12 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
 
 	first_clone = 1;
 	for (i = 0; i < disks; i++) {
-		struct bio *mbio;
+		struct bio *mbio = NULL;
+		int offset;
 		if (!r1_bio->bios[i])
 			continue;
 
-		mbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
-		bio_trim(mbio, r1_bio->sector - bio->bi_iter.bi_sector,
-			 max_sectors);
+		offset = r1_bio->sector - bio->bi_iter.bi_sector;
 
 		if (first_clone) {
 			/* do behind I/O ?
@@ -1357,8 +1356,14 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
 			if (bitmap &&
 			    (atomic_read(&bitmap->behind_writes)
 			     < mddev->bitmap_info.max_write_behind) &&
-			    !waitqueue_active(&bitmap->behind_wait))
+			    !waitqueue_active(&bitmap->behind_wait)) {
+				mbio = bio_clone_slow_mddev_partial(bio,
+								    GFP_NOIO,
+								    mddev,
+								    offset,
+								    max_sectors);
 				alloc_behind_pages(mbio, r1_bio);
+			}
 
 			bitmap_startwrite(bitmap, r1_bio->sector,
 					  r1_bio->sectors,
@@ -1366,6 +1371,12 @@ static void raid1_write_request(struct mddev *mddev, struct bio *bio,
 						   &r1_bio->state));
 			first_clone = 0;
 		}
+
+		if (!mbio) {
+			mbio = bio_clone_mddev(bio, GFP_NOIO, mddev);
+			bio_trim(mbio, offset, max_sectors);
+		}
+
 		if (r1_bio->behind_bvecs) {
 			struct bio_vec *bvec;
 			int j;
-- 
2.7.4

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] md: use bio_clone_fast() Ming Lei <tom.leiming@gmail.com> - 2017-02-05 07:30 +0100
  [PATCH 4/4] md: fast clone bio in bio_clone_mddev() Ming Lei <tom.leiming@gmail.com> - 2017-02-05 07:30 +0100
    Re: [PATCH 4/4] md: fast clone bio in bio_clone_mddev() Christoph Hellwig <hch@infradead.org> - 2017-02-06 10:20 +0100
      Re: [PATCH 4/4] md: fast clone bio in bio_clone_mddev() Ming Lei <tom.leiming@gmail.com> - 2017-02-06 11:50 +0100
        Re: [PATCH 4/4] md: fast clone bio in bio_clone_mddev() Christoph Hellwig <hch@infradead.org> - 2017-02-06 15:30 +0100
  [PATCH 2/4] md: introduce bio_clone_slow_mddev_partial() Ming Lei <tom.leiming@gmail.com> - 2017-02-05 07:30 +0100
    Re: [PATCH 2/4] md: introduce bio_clone_slow_mddev_partial() Christoph Hellwig <hch@infradead.org> - 2017-02-06 10:00 +0100
  [PATCH 1/4] block: introduce bio_clone_bioset_partial() Ming Lei <tom.leiming@gmail.com> - 2017-02-05 07:30 +0100
  [PATCH 3/4] md/raid1: use bio_clone_slow_mddev_partial in case of write behind Ming Lei <tom.leiming@gmail.com> - 2017-02-05 07:30 +0100

csiph-web