Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1668532
| From | NeilBrown <neilb@suse.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH 06/13] rbd: use bio_clone_fast() instead of bio_clone() |
| Date | 2017-06-18 06:50 +0200 |
| Message-ID | <tTAjT-sG-1@gated-at.bofh.it> (permalink) |
| References | <tTAad-oX-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
bio_clone() makes a copy of the bi_io_vec, but rbd never changes that,
so there is no need for a copy.
bio_clone_fast() can be used instead, which avoids making the copy.
This requires that we provide a bio_set. bio_clone() uses fs_bio_set,
but it isn't, in general, safe to use the same bio_set at different
levels of the stack, as that can lead to deadlocks. As filesystems
use fs_bio_set, block devices shouldn't.
As rbd never stacks, it is safe to have a single global bio_set for
all rbd devices to use. So allocate that when the module is
initialised, and use it with bio_clone_fast().
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: NeilBrown <neilb@suse.com>
---
drivers/block/rbd.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 5420bc40c544..b008b6a98098 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -442,6 +442,8 @@ static DEFINE_SPINLOCK(rbd_client_list_lock);
static struct kmem_cache *rbd_img_request_cache;
static struct kmem_cache *rbd_obj_request_cache;
+static struct bio_set *rbd_bio_clone;
+
static int rbd_major;
static DEFINE_IDA(rbd_dev_id_ida);
@@ -1363,7 +1365,7 @@ static struct bio *bio_clone_range(struct bio *bio_src,
{
struct bio *bio;
- bio = bio_clone(bio_src, gfpmask);
+ bio = bio_clone_fast(bio_src, gfpmask, rbd_bio_clone);
if (!bio)
return NULL; /* ENOMEM */
@@ -6416,8 +6418,16 @@ static int rbd_slab_init(void)
if (!rbd_obj_request_cache)
goto out_err;
+ rbd_assert(!rbd_bio_clone);
+ rbd_bio_clone = bioset_create(BIO_POOL_SIZE, 0, 0);
+ if (!rbd_bio_clone)
+ goto out_err_clone;
+
return 0;
+out_err_clone:
+ kmem_cache_destroy(rbd_obj_request_cache);
+ rbd_obj_request_cache = NULL;
out_err:
kmem_cache_destroy(rbd_img_request_cache);
rbd_img_request_cache = NULL;
@@ -6433,6 +6443,10 @@ static void rbd_slab_exit(void)
rbd_assert(rbd_img_request_cache);
kmem_cache_destroy(rbd_img_request_cache);
rbd_img_request_cache = NULL;
+
+ rbd_assert(rbd_bio_clone);
+ bioset_free(rbd_bio_clone);
+ rbd_bio_clone = NULL;
}
static int __init rbd_init(void)
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH 00/13] block: assorted cleanup for bio splitting and cloning. NeilBrown <neilb@suse.com> - 2017-06-18 06:40 +0200
[PATCH 06/13] rbd: use bio_clone_fast() instead of bio_clone() NeilBrown <neilb@suse.com> - 2017-06-18 06:50 +0200
[PATCH 10/13] xen-blkfront: remove bio splitting. NeilBrown <neilb@suse.com> - 2017-06-18 06:50 +0200
[PATCH 12/13] block: remove bio_clone() and all references. NeilBrown <neilb@suse.com> - 2017-06-18 06:50 +0200
[PATCH 11/13] bcache: use kmalloc to allocate bio in bch_data_verify() NeilBrown <neilb@suse.com> - 2017-06-18 06:50 +0200
[PATCH 09/13] lightnvm/pblk-read: use bio_clone_fast() NeilBrown <neilb@suse.com> - 2017-06-18 06:50 +0200
[PATCH 13/13] block: don't check for BIO_MAX_PAGES in blk_bio_segment_split() NeilBrown <neilb@suse.com> - 2017-06-18 06:50 +0200
[PATCH 04/13] blk: use non-rescuing bioset for q->bio_split. NeilBrown <neilb@suse.com> - 2017-06-18 06:50 +0200
[PATCH 07/13] drbd: use bio_clone_fast() instead of bio_clone() NeilBrown <neilb@suse.com> - 2017-06-18 06:50 +0200
[PATCH 03/13] blk: make the bioset rescue_workqueue optional. NeilBrown <neilb@suse.com> - 2017-06-18 06:50 +0200
[PATCH 05/13] block: Improvements to bounce-buffer handling NeilBrown <neilb@suse.com> - 2017-06-18 06:50 +0200
[PATCH 08/13] pktcdvd: use bio_clone_fast() instead of bio_clone() NeilBrown <neilb@suse.com> - 2017-06-18 06:50 +0200
Re: [PATCH 00/13] block: assorted cleanup for bio splitting and cloning. Jens Axboe <axboe@kernel.dk> - 2017-06-18 20:50 +0200
Re: [PATCH 00/13] block: assorted cleanup for bio splitting and cloning. NeilBrown <neilb@suse.com> - 2017-06-18 23:40 +0200
csiph-web