md: use bio_clone_fast()
Subsystems (2)
v2 cover md: use bio_clone_fast()
Hi,
This patches replaces bio_clone() with bio_fast_clone() in bio_clone_mddev() because:
1) bio_clone_mddev() is used in raid normal I/O and isn't in resync I/O path, and all the direct access to bvec table in raid happens on resync I/O only except for write behind of raid1. Write behind is treated specially, so the replacement is safe.
2) for write behind, bio_clone() is kept, but this patchset introduces bio_clone_bioset_partial() to just clone one specific bvecs range instead of whole table. Then write behind is improved too.
V2:
1) move 3rd patch into 2nd one
2) kill bio_clone_mddev() and use bio_clone_fast() directly
3) define local variable 'offset' as sector_t in raid1_write_request()
V1:
1) don't introduce bio_clone_slow_mddev_partial()
2) return failure if mddev->bio_set can't be created
3) remove check in bio_clone_mddev() as suggested by Christoph Hellwig.
4) rename bio_clone_mddev() as bio_clone_fast_mddev()
Ming Lei (5):
block: introduce bio_clone_bioset_partial()
md: fail if mddev->bio_set can't be created
md/raid1: use bio_clone_bioset_partial() in case of write behind
md: remove unnecessary check on mddev
md: fast clone bio in bio_clone_mddev()
block/bio.c | 61 +++++++++++++++++++++++++++++++++++++++++------------ drivers/md/faulty.c | 2 +- drivers/md/md.c | 15 ++++--------- drivers/md/md.h | 2 -- drivers/md/raid1.c | 28 +++++++++++++++++------- drivers/md/raid10.c | 11 +++++----- drivers/md/raid5.c | 4 ++-- include/linux/bio.h | 11 ++++++++-- 8 files changed, 89 insertions(+), 45 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/5 block: introduce bio_clone_bioset_partial()
md still need bio clone(not the fast version) for behind write, and it is more efficient to use bio_clone_bioset_partial().
The idea is simple and just copy the bvecs range specified from parameters.
--- block/bio.c | 61 +++++++++++++++++++++++++++++++++++++++++------------ include/linux/bio.h | 11 ++++++++-- 2 files changed, 57 insertions(+), 15 deletions(-)
block/bio.c +48 -13
@@ -625,21 +625,20 @@ struct bio *bio_clone_fast(struct bio *bio, gfp_t gfp_mask, struct bio_set *bs) }EXPORT_SYMBOL (bio_clone_fast); -/** -* bio_clone_bioset - clone a bio -* @bio_src: bio to clone -* @gfp_mask: allocation priority -* @bs: bio_set to allocate from -* -* Clone bio. Caller will own the returned bio, but not the actual data it -* points to. Reference count of returned bio will be one. -*/ -struct bio *bio_clone_bioset (struct bio *bio_src,gfp_t gfp_mask, -struct bio_set *bs) +static struct bio *__bio_clone_bioset (struct bio *bio_src,gfp_t gfp_mask, +struct bio_set *bs,int offset, +int size) {struct bvec_iter iter;struct bio_vec bv;struct bio *bio; +struct bvec_iter iter_src = bio_src->bi_iter; + +/* for supporting partial clone */ +if (offset || size != bio_src->bi_iter.bi_size) { +bio_advance_iter (bio_src, &iter_src, offset); + iter_src.bi_size = size; + }/* * Pre immutable biovecs, __bio_clone() used to just do a memcpy from
@@ -663,7 +662,8 @@ struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask,* __bio_clone_fast() anyways. */ - bio =bio_alloc_bioset (gfp_mask,bio_segments (bio_src), bs); + bio =bio_alloc_bioset (gfp_mask,__bio_segments (bio_src, + &iter_src), bs);if (!bio)return NULL ; bio->bi_bdev = bio_src->bi_bdev;
@@ -680,7 +680,7 @@ struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask, bio->bi_io_vec[bio->bi_vcnt++] = bio_src->bi_io_vec[0 ];break ;default : -bio_for_each_segment (bv, bio_src, iter) +__bio_for_each_segment (bv, bio_src, iter, iter_src) bio->bi_io_vec[bio->bi_vcnt++] = bv;break ; }
@@ -699,9 +699,44 @@ struct bio *bio_clone_bioset(struct bio *bio_src, gfp_t gfp_mask,return bio; } + +/** +* bio_clone_bioset - clone a bio +* @bio_src: bio to clone +* @gfp_mask: allocation priority +* @bs: bio_set to allocate from +* +* Clone bio. Caller will own the returned bio, but not the actual data it +* points to. Reference count of returned bio will be one. +*/ +struct bio *bio_clone_bioset (struct bio *bio_src,gfp_t gfp_mask, +struct bio_set *bs) +{ +return __bio_clone_bioset (bio_src, gfp_mask, bs,0 , + bio_src->bi_iter.bi_size); +}EXPORT_SYMBOL (bio_clone_bioset);/** +* bio_clone_bioset_partial - clone a partial bio +* @bio_src: bio to clone +* @gfp_mask: allocation priority +* @bs: bio_set to allocate from +* @offset: cloned starting from the offset +* @size: size for the cloned bio +* +* Clone bio. Caller will own the returned bio, but not the actual data it +* points to. Reference count of returned bio will be one. +*/ +struct bio *bio_clone_bioset_partial (struct bio *bio_src,gfp_t gfp_mask, +struct bio_set *bs,int offset, +int size) +{ +return __bio_clone_bioset (bio_src, gfp_mask, bs, offset, size); +} +EXPORT_SYMBOL (bio_clone_bioset_partial); + +/** * bio_add_pc_page - attempt to add page to bio * @q: the target queue * @bio: destination bio
include/linux/bio.h +9 -2
@@ -183,7 +183,7 @@ static inline void bio_advance_iter(struct bio *bio, struct bvec_iter *iter,#define bio_iter_last (bvec, iter) ((iter).bi_size == (bvec).bv_len) -static inline unsigned bio_segments (struct bio *bio) +static inline unsigned __bio_segments (struct bio *bio,struct bvec_iter *bvec) {unsigned segs =0 ;struct bio_vec bv;
@@ -205,12 +205,17 @@ static inline unsigned bio_segments(struct bio *bio)break ; } -bio_for_each_segment (bv, bio, iter) +__bio_for_each_segment (bv, bio, iter, *bvec) segs++;return segs; } +static inline unsigned bio_segments (struct bio *bio) +{ +return __bio_segments (bio, &bio->bi_iter); +} +/* * get a reference to a bio, so it won't disappear. the intended use is * something like:
@@ -384,6 +389,8 @@ extern void bio_put(struct bio *);extern void __bio_clone_fast (struct bio *,struct bio *);extern struct bio *bio_clone_fast (struct bio *,gfp_t ,struct bio_set *);extern struct bio *bio_clone_bioset (struct bio *,gfp_t ,struct bio_set *bs); +extern struct bio *bio_clone_bioset_partial (struct bio *,gfp_t , +struct bio_set *,int ,int );extern struct bio_set *fs_bio_set;
Signature · 1 line
2.7.4
PATCH v2 2/5 md: fail if mddev->bio_set can't be created
In reply to Ming LeiThe current behaviour is to fall back to allocate bio from 'fs_bio_set', that isn't a correct way because it might cause deadlock.
So this patch simply return failure if mddev->bio_set can't be created.
--- drivers/md/md.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/md/md.c +4 -1
@@ -5228,8 +5228,11 @@ int md_run(struct mddev *mddev)sysfs_notify_dirent_safe (rdev->sysfs_state); } -if (mddev->bio_set ==NULL ) +if (mddev->bio_set ==NULL ) { mddev->bio_set =bioset_create (BIO_POOL_SIZE ,0 ); +if (!mddev->bio_set) +return -ENOMEM ; + }spin_lock (&pers_lock); pers =find_pers (mddev->level, mddev->clevel);
Signature · 1 line
2.7.4
PATCH v2 3/5 md/raid1: use bio_clone_bioset_partial() in case of write behind
In reply to Ming LeiWrite 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_bioset_partial() for it.
For other bio_clone_mddev() cases, we will use fast clone since they don't need to touch bvec table.
--- drivers/md/raid1.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)
drivers/md/raid1.c +15 -5
@@ -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 ; +sector_t 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,13 @@ 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_bioset_partial (bio,GFP_NOIO , + mddev->bio_set, + offset, + max_sectors);alloc_behind_pages (mbio, r1_bio); + } bitmap_startwrite(bitmap, r1_bio->sector, r1_bio->sectors,
@@ -1366,6 +1370,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;
Signature · 1 line
2.7.4
PATCH v2 4/5 md: remove unnecessary check on mddev
In reply to Ming Leimddev is never NULL and neither is ->bio_set, so
remove the check.
--- drivers/md/md.c | 3 --- 1 file changed, 3 deletions(-)
drivers/md/md.c +0 -3
@@ -193,9 +193,6 @@ EXPORT_SYMBOL_GPL(bio_alloc_mddev);struct bio *bio_clone_mddev (struct bio *bio,gfp_t gfp_mask,struct mddev *mddev) { -if (!mddev || !mddev->bio_set) -return bio_clone (bio, gfp_mask); -return bio_clone_bioset (bio, gfp_mask, mddev->bio_set); }EXPORT_SYMBOL_GPL (bio_clone_mddev);
Signature · 1 line
2.7.4
PATCH v2 5/5 md: fast clone bio in bio_clone_mddev()
In reply to Ming LeiFirstly 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.
--- drivers/md/faulty.c | 2 +- drivers/md/md.c | 7 ------- drivers/md/md.h | 2 -- drivers/md/raid1.c | 10 ++++++---- drivers/md/raid10.c | 11 +++++------ drivers/md/raid5.c | 4 ++-- 6 files changed, 14 insertions(+), 22 deletions(-)
drivers/md/faulty.c +1 -1
@@ -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;
drivers/md/md.c +0 -7
@@ -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
drivers/md/md.h +0 -2
@@ -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);
drivers/md/raid1.c +6 -4
@@ -1108,7 +1108,7 @@ static void raid1_read_request(struct mddev *mddev, struct bio *bio, 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);
@@ -1372,7 +1372,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); }
@@ -2283,7 +2283,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 );
@@ -2421,7 +2422,8 @@ static void handle_read_error(struct r1conf *conf, struct r1bio *r1_bio)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;
drivers/md/raid10.c +5 -6
@@ -1132,7 +1132,7 @@ static void raid10_read_request(struct mddev *mddev, struct bio *bio, } 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 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,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 @@ static void raid10_write_request(struct mddev *mddev, struct bio *bio,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 @@ static void handle_read_error(struct mddev *mddev, struct r10bio *r10_bio)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;
drivers/md/raid5.c +2 -2
@@ -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 ;/*
Signature · 1 line
2.7.4
Re: [PATCH v2 5/5] md: fast clone bio in bio_clone_mddev()
Quoted 7 lines · Ming Lei
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.
Quoted 7 lines
So this patch replaces
bio_clone()withbio_clone_fast()inbio_clone_mddev().Also kill
bio_clone_mddev()and callbio_clone_fast()directly, as suggested by Christoph Hellwig.Signed-off-by Ming Lei <[email protected]>
Looks fine,
Btw, can you also tack on another patch to kill bio_alloc_mddev to be consistent?
Re: [PATCH v2 5/5] md: fast clone bio in bio_clone_mddev()
Quoted 14 lines · Christoph Hellwig
Quoted 13 lines · Ming Lei
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()withbio_clone_fast()inbio_clone_mddev().Also kill
bio_clone_mddev()and callbio_clone_fast()directly, as suggested by Christoph Hellwig.
Quoted 8 lines
Quoted 1 line
Signed-off-by Ming Lei <[email protected]>Looks fine,
Reviewed-by Christoph Hellwig <[email protected]>Btw, can you also tack on another patch to kill
bio_alloc_mddevto be consistent?
I'll take care of this
Re: [PATCH v2 5/5] md: fast clone bio in bio_clone_mddev()
Quoted 17 lines · Shaohua Li
Quoted 16 lines · Christoph Hellwig
Quoted 14 lines · Ming Lei
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()withbio_clone_fast()inbio_clone_mddev().Also kill
bio_clone_mddev()and callbio_clone_fast()directly, as suggested by Christoph Hellwig.Signed-off-by Ming Lei <[email protected]>
Quoted 8 lines
Quoted 6 lines
Looks fine,
Reviewed-by Christoph Hellwig <[email protected]>Btw, can you also tack on another patch to kill
bio_alloc_mddevto be consistent?I'll take care of this
Hmm, bio_alloc_mddev is a little different, it could be called without the bio_set. We can only guarantee the bio_set is valid for bio for md personality not for metadata. Fully fixing the bio_set issue will need rework mddev struct allocation, don't think it's worthy doing. So below is one removing the export of the wrap.
From eaf70c32e5cca68110a0cf7a0311ef0ac97f4d42 Mon Sep 17 00:00:00 2001
Message-Id: <eaf70c32e5cca68110a0cf7a0311ef0ac97f4d42.1487200103.git.shli@fb.com>
From: Shaohua Li <[email protected]>
Date: Wed, 15 Feb 2017 11:41:21 -0800
Subject: [PATCH] md: don't export bio_alloc_mddev
When mddev is running, it has a valid bio_set, so the bio_alloc_mddev wrap is unncessary. The problem is we run some IO (eg, load superblock) before mddev is fully initialized. At that time bio_set isn't initialized. Moving bio_set creation to md_alloc doesn't help either, because dm-raid doesn't use it.
--- drivers/md/md.c | 12 ++++++------ drivers/md/md.h | 2 -- drivers/md/raid1.c | 2 +- drivers/md/raid10.c | 2 +- 4 files changed, 8 insertions(+), 10 deletions(-)
drivers/md/md.c +6 -6
@@ -171,11 +171,12 @@ static const struct block_device_operations md_fops;static int start_readonly; -/* bio_clone_mddev -* like bio_clone, but with a local bio set +/* +* This is only required for meta data related bio, where bio_set might not be +* initialized yet. dm-raid doesn't use md_alloc, so we can't alloc bio_set +* there. */ - -struct bio *bio_alloc_mddev (gfp_t gfp_mask,int nr_iovecs, +static struct bio *bio_alloc_mddev (gfp_t gfp_mask,int nr_iovecs,struct mddev *mddev) {struct bio *b;
@@ -188,7 +189,6 @@ struct bio *bio_alloc_mddev(gfp_t gfp_mask, int nr_iovecs,return NULL ;return b; } -EXPORT_SYMBOL_GPL (bio_alloc_mddev);/* * We have a system wide 'event count' that is incremented
@@ -393,7 +393,7 @@ static void submit_flushes(struct work_struct *ws)atomic_inc (&rdev->nr_pending);atomic_inc (&rdev->nr_pending);rcu_read_unlock (); - bi =bio_alloc_mddev (GFP_NOIO ,0 , mddev); + bi =bio_alloc_bioset (GFP_NOIO ,0 , mddev->bio_set); bi->bi_end_io = md_end_flush; bi->bi_private = rdev; bi->bi_bdev = rdev->bdev;
drivers/md/md.h +0 -2
@@ -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_alloc_mddev (gfp_t gfp_mask,int nr_iovecs, -struct mddev *mddev);extern void md_unplug (struct blk_plug_cb *cb,bool from_schedule);extern void md_reload_sb (struct mddev *mddev,int raid_disk);
drivers/md/raid1.c +1 -1
@@ -2281,7 +2281,7 @@ static int narrow_write_error(struct r1bio *r1_bio, int i) vcnt--; } - wbio =bio_alloc_mddev (GFP_NOIO , vcnt, mddev); + wbio =bio_alloc_bioset (GFP_NOIO , vcnt, mddev->bio_set);memcpy (wbio->bi_io_vec, vec, vcnt *sizeof (struct bio_vec )); wbio->bi_vcnt = vcnt;
drivers/md/raid10.c +1 -1
@@ -4473,7 +4473,7 @@ static sector_t reshape_request(struct mddev *mddev, sector_t sector_nr,return sectors_done; } - read_bio =bio_alloc_mddev (GFP_KERNEL ,RESYNC_PAGES , mddev); + read_bio =bio_alloc_bioset (GFP_KERNEL ,RESYNC_PAGES , mddev->bio_set); read_bio->bi_bdev = rdev->bdev; read_bio->bi_iter.bi_sector = (r10_bio->devs[r10_bio->read_slot].addr
Signature · 1 line
2.9.3
Quoted 10 lines · Ming Lei
Hi,
This patches replaces
bio_clone()withbio_fast_clone()inbio_clone_mddev()because:1)
bio_clone_mddev()is used in raid normal I/O and isn't in resync I/O path, and all the direct access to bvec table in raid happens on resync I/O only except for write behind of raid1. Write behind is treated specially, so the replacement is safe.
Quoted 4 lines
2) for write behind,
bio_clone()is kept, but this patchset introducesbio_clone_bioset_partial()to just clone one specific bvecs range instead of whole table. Then write behind is improved too.
You can add my reviewed-by to the first patch. Shaohua, I'm fine with you carrying this in the md tree, that would be the easiest way forward.
Signature · 1 line
Jens Axboe
Shaohua Li
AppliedQuoted 20 lines · Ming Lei
Hi,
This patches replaces
bio_clone()withbio_fast_clone()inbio_clone_mddev()because:1)
bio_clone_mddev()is used in raid normal I/O and isn't in resync I/O path, and all the direct access to bvec table in raid happens on resync I/O only except for write behind of raid1. Write behind is treated specially, so the replacement is safe.2) for write behind,
bio_clone()is kept, but this patchset introducesbio_clone_bioset_partial()to just clone one specific bvecs range instead of whole table. Then write behind is improved too.V2:
1) move 3rd patch into 2nd one
2) killbio_clone_mddev()and usebio_clone_fast()directly
3) define local variable 'offset' assector_tinraid1_write_request()
Quoted 6 lines
V1:
1) don't introducebio_clone_slow_mddev_partial()
2) return failure ifmddev->bio_setcan't be created
3) remove check inbio_clone_mddev()as suggested by Christoph Hellwig.
4) renamebio_clone_mddev()asbio_clone_fast_mddev()
Applied, thanks!
Quoted 20 lines
Ming Lei (5):
block: introducebio_clone_bioset_partial()
md: fail ifmddev->bio_setcan't be created
md/raid1: usebio_clone_bioset_partial()in case of write behind
md: remove unnecessary check on mddev
md: fast clone bio inbio_clone_mddev()block/bio.c | 61 +++++++++++++++++++++++++++++++++++++++++------------ drivers/md/faulty.c | 2 +- drivers/md/md.c | 15 ++++--------- drivers/md/md.h | 2 -- drivers/md/raid1.c | 28 +++++++++++++++++------- drivers/md/raid10.c | 11 +++++----- drivers/md/raid5.c | 4 ++-- include/linux/bio.h | 11 ++++++++-- 8 files changed, 89 insertions(+), 45 deletions(-)Signature · 1 line
2.7.4