* [PATCH v1 07/54] bcache: comment on direct access to bvec table
2016-12-27 15:55 [PATCH v1 00/54] block: support multipage bvec Ming Lei
@ 2016-12-27 15:55 ` Ming Lei
2016-12-30 16:56 ` Coly Li
2016-12-27 15:55 ` [PATCH v1 08/54] block: comment on bio_alloc_pages() Ming Lei
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Ming Lei @ 2016-12-27 15:55 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, Ming Lei, Kent Overstreet,
Shaohua Li, Guoqing Jiang, Zheng Liu, Mike Christie, Jiri Kosina,
Eric Wheeler, Yijing Wang, Al Viro,
open list:BCACHE BLOCK LAYER CACHE,
open list:SOFTWARE RAID Multiple Disks SUPPORT
Looks all are safe after multipage bvec is supported.
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
drivers/md/bcache/btree.c | 1 +
drivers/md/bcache/super.c | 6 ++++++
drivers/md/bcache/util.c | 7 +++++++
3 files changed, 14 insertions(+)
diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index a43eedd5804d..fc35cfb4d0f1 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -428,6 +428,7 @@ static void do_btree_node_write(struct btree *b)
continue_at(cl, btree_node_write_done, NULL);
} else {
+ /* No harm for multipage bvec since the new is just allocated */
b->bio->bi_vcnt = 0;
bch_bio_map(b->bio, i);
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 3a19cbc8b230..607b022259dc 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -208,6 +208,7 @@ static void write_bdev_super_endio(struct bio *bio)
static void __write_super(struct cache_sb *sb, struct bio *bio)
{
+ /* single page bio, safe for multipage bvec */
struct cache_sb *out = page_address(bio->bi_io_vec[0].bv_page);
unsigned i;
@@ -1156,6 +1157,8 @@ static void register_bdev(struct cache_sb *sb, struct page *sb_page,
dc->bdev->bd_holder = dc;
bio_init(&dc->sb_bio, dc->sb_bio.bi_inline_vecs, 1);
+
+ /* single page bio, safe for multipage bvec */
dc->sb_bio.bi_io_vec[0].bv_page = sb_page;
get_page(sb_page);
@@ -1799,6 +1802,7 @@ void bch_cache_release(struct kobject *kobj)
for (i = 0; i < RESERVE_NR; i++)
free_fifo(&ca->free[i]);
+ /* single page bio, safe for multipage bvec */
if (ca->sb_bio.bi_inline_vecs[0].bv_page)
put_page(ca->sb_bio.bi_io_vec[0].bv_page);
@@ -1854,6 +1858,8 @@ static int register_cache(struct cache_sb *sb, struct page *sb_page,
ca->bdev->bd_holder = ca;
bio_init(&ca->sb_bio, ca->sb_bio.bi_inline_vecs, 1);
+
+ /* single page bio, safe for multipage bvec */
ca->sb_bio.bi_io_vec[0].bv_page = sb_page;
get_page(sb_page);
diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c
index dde6172f3f10..5cc0b49a65fb 100644
--- a/drivers/md/bcache/util.c
+++ b/drivers/md/bcache/util.c
@@ -222,6 +222,13 @@ uint64_t bch_next_delay(struct bch_ratelimit *d, uint64_t done)
: 0;
}
+/*
+ * Generally it isn't good to access .bi_io_vec and .bi_vcnt
+ * directly, the preferred way is bio_add_page, but in
+ * this case, bch_bio_map() supposes that the bvec table
+ * is empty, so it is safe to access .bi_vcnt & .bi_io_vec
+ * in this way even after multipage bvec is supported.
+ */
void bch_bio_map(struct bio *bio, void *base)
{
size_t size = bio->bi_iter.bi_size;
--
2.7.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v1 07/54] bcache: comment on direct access to bvec table
2016-12-27 15:55 ` [PATCH v1 07/54] bcache: comment on direct access to bvec table Ming Lei
@ 2016-12-30 16:56 ` Coly Li
0 siblings, 0 replies; 11+ messages in thread
From: Coly Li @ 2016-12-30 16:56 UTC (permalink / raw)
To: Ming Lei
Cc: Jens Axboe, linux-kernel, linux-block, Christoph Hellwig,
Kent Overstreet, Shaohua Li, Guoqing Jiang, Zheng Liu,
Mike Christie, Jiri Kosina, Eric Wheeler, Yijing Wang, Al Viro,
open list:BCACHE (BLOCK LAYER CACHE),
open list:SOFTWARE RAID (Multiple Disks) SUPPORT
On 2016/12/27 下午11:55, Ming Lei wrote:
> Looks all are safe after multipage bvec is supported.
>
> Signed-off-by: Ming Lei <tom.leiming@gmail.com>
> ---
> drivers/md/bcache/btree.c | 1 +
> drivers/md/bcache/super.c | 6 ++++++
> drivers/md/bcache/util.c | 7 +++++++
> 3 files changed, 14 insertions(+)
>
> diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
> index a43eedd5804d..fc35cfb4d0f1 100644
> --- a/drivers/md/bcache/btree.c
> +++ b/drivers/md/bcache/btree.c
> @@ -428,6 +428,7 @@ static void do_btree_node_write(struct btree *b)
>
> continue_at(cl, btree_node_write_done, NULL);
> } else {
> + /* No harm for multipage bvec since the new is just allocated */
> b->bio->bi_vcnt = 0;
> bch_bio_map(b->bio, i);
>
> diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
> index 3a19cbc8b230..607b022259dc 100644
> --- a/drivers/md/bcache/super.c
> +++ b/drivers/md/bcache/super.c
> @@ -208,6 +208,7 @@ static void write_bdev_super_endio(struct bio *bio)
>
> static void __write_super(struct cache_sb *sb, struct bio *bio)
> {
> + /* single page bio, safe for multipage bvec */
> struct cache_sb *out = page_address(bio->bi_io_vec[0].bv_page);
> unsigned i;
>
> @@ -1156,6 +1157,8 @@ static void register_bdev(struct cache_sb *sb, struct page *sb_page,
> dc->bdev->bd_holder = dc;
>
> bio_init(&dc->sb_bio, dc->sb_bio.bi_inline_vecs, 1);
> +
> + /* single page bio, safe for multipage bvec */
> dc->sb_bio.bi_io_vec[0].bv_page = sb_page;
> get_page(sb_page);
>
> @@ -1799,6 +1802,7 @@ void bch_cache_release(struct kobject *kobj)
> for (i = 0; i < RESERVE_NR; i++)
> free_fifo(&ca->free[i]);
>
> + /* single page bio, safe for multipage bvec */
> if (ca->sb_bio.bi_inline_vecs[0].bv_page)
> put_page(ca->sb_bio.bi_io_vec[0].bv_page);
>
> @@ -1854,6 +1858,8 @@ static int register_cache(struct cache_sb *sb, struct page *sb_page,
> ca->bdev->bd_holder = ca;
>
> bio_init(&ca->sb_bio, ca->sb_bio.bi_inline_vecs, 1);
> +
> + /* single page bio, safe for multipage bvec */
> ca->sb_bio.bi_io_vec[0].bv_page = sb_page;
> get_page(sb_page);
>
> diff --git a/drivers/md/bcache/util.c b/drivers/md/bcache/util.c
> index dde6172f3f10..5cc0b49a65fb 100644
> --- a/drivers/md/bcache/util.c
> +++ b/drivers/md/bcache/util.c
> @@ -222,6 +222,13 @@ uint64_t bch_next_delay(struct bch_ratelimit *d, uint64_t done)
> : 0;
> }
>
> +/*
> + * Generally it isn't good to access .bi_io_vec and .bi_vcnt
> + * directly, the preferred way is bio_add_page, but in
> + * this case, bch_bio_map() supposes that the bvec table
> + * is empty, so it is safe to access .bi_vcnt & .bi_io_vec
> + * in this way even after multipage bvec is supported.
> + */
> void bch_bio_map(struct bio *bio, void *base)
> {
> size_t size = bio->bi_iter.bi_size;
>
Acked-by: Coly Li <colyli@suse.de>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v1 08/54] block: comment on bio_alloc_pages()
2016-12-27 15:55 [PATCH v1 00/54] block: support multipage bvec Ming Lei
2016-12-27 15:55 ` [PATCH v1 07/54] bcache: comment on direct access to bvec table Ming Lei
@ 2016-12-27 15:55 ` Ming Lei
2016-12-30 10:40 ` Coly Li
2016-12-30 11:06 ` Coly Li
2016-12-27 15:56 ` [PATCH v1 11/54] md: set NO_MP for request queue of md Ming Lei
` (2 subsequent siblings)
4 siblings, 2 replies; 11+ messages in thread
From: Ming Lei @ 2016-12-27 15:55 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, Ming Lei, Jens Axboe,
Kent Overstreet, Shaohua Li, Mike Christie, Guoqing Jiang,
Hannes Reinecke, open list:BCACHE BLOCK LAYER CACHE,
open list:SOFTWARE RAID Multiple Disks SUPPORT
This patch adds comment on usage of bio_alloc_pages(),
also comments on one special case of bch_data_verify().
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
block/bio.c | 4 +++-
drivers/md/bcache/debug.c | 6 ++++++
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/block/bio.c b/block/bio.c
index 2b375020fc49..d4a1e0b63ea0 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -961,7 +961,9 @@ EXPORT_SYMBOL(bio_advance);
* @bio: bio to allocate pages for
* @gfp_mask: flags for allocation
*
- * Allocates pages up to @bio->bi_vcnt.
+ * Allocates pages up to @bio->bi_vcnt, and this function should only
+ * be called on a new initialized bio, which means all pages aren't added
+ * to the bio via bio_add_page() yet.
*
* Returns 0 on success, -ENOMEM on failure. On failure, any allocated pages are
* freed.
diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
index 06f55056aaae..48d03e8b3385 100644
--- a/drivers/md/bcache/debug.c
+++ b/drivers/md/bcache/debug.c
@@ -110,6 +110,12 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
struct bio_vec bv, cbv;
struct bvec_iter iter, citer = { 0 };
+ /*
+ * Once multipage bvec is supported, the bio_clone()
+ * has to make sure page count in this bio can be held
+ * in the new cloned bio because each single page need
+ * to assign to each bvec of the new bio.
+ */
check = bio_clone(bio, GFP_NOIO);
if (!check)
return;
--
2.7.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v1 08/54] block: comment on bio_alloc_pages()
2016-12-27 15:55 ` [PATCH v1 08/54] block: comment on bio_alloc_pages() Ming Lei
@ 2016-12-30 10:40 ` Coly Li
2016-12-30 11:06 ` Coly Li
1 sibling, 0 replies; 11+ messages in thread
From: Coly Li @ 2016-12-30 10:40 UTC (permalink / raw)
To: Ming Lei, Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, Jens Axboe, Kent Overstreet,
Shaohua Li, Mike Christie, Guoqing Jiang, Hannes Reinecke,
open list:BCACHE (BLOCK LAYER CACHE),
open list:SOFTWARE RAID (Multiple Disks) SUPPORT
On 2016/12/27 下午11:55, Ming Lei wrote:
> This patch adds comment on usage of bio_alloc_pages(),
> also comments on one special case of bch_data_verify().
>
> Signed-off-by: Ming Lei <tom.leiming@gmail.com>
> ---
> block/bio.c | 4 +++-
> drivers/md/bcache/debug.c | 6 ++++++
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/block/bio.c b/block/bio.c
> index 2b375020fc49..d4a1e0b63ea0 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -961,7 +961,9 @@ EXPORT_SYMBOL(bio_advance);
> * @bio: bio to allocate pages for
> * @gfp_mask: flags for allocation
> *
> - * Allocates pages up to @bio->bi_vcnt.
> + * Allocates pages up to @bio->bi_vcnt, and this function should only
> + * be called on a new initialized bio, which means all pages aren't added
> + * to the bio via bio_add_page() yet.
> *
> * Returns 0 on success, -ENOMEM on failure. On failure, any allocated pages are
> * freed.
> diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
> index 06f55056aaae..48d03e8b3385 100644
> --- a/drivers/md/bcache/debug.c
> +++ b/drivers/md/bcache/debug.c
> @@ -110,6 +110,12 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
> struct bio_vec bv, cbv;
> struct bvec_iter iter, citer = { 0 };
>
> + /*
> + * Once multipage bvec is supported, the bio_clone()
> + * has to make sure page count in this bio can be held
> + * in the new cloned bio because each single page need
> + * to assign to each bvec of the new bio.
> + */
> check = bio_clone(bio, GFP_NOIO);
> if (!check)
> return;
>
Acked-by: Coly Li <colyli@suse.de>
--
Coly Li
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v1 08/54] block: comment on bio_alloc_pages()
2016-12-27 15:55 ` [PATCH v1 08/54] block: comment on bio_alloc_pages() Ming Lei
2016-12-30 10:40 ` Coly Li
@ 2016-12-30 11:06 ` Coly Li
1 sibling, 0 replies; 11+ messages in thread
From: Coly Li @ 2016-12-30 11:06 UTC (permalink / raw)
To: Ming Lei, Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, Jens Axboe, Kent Overstreet,
Shaohua Li, Mike Christie, Guoqing Jiang, Hannes Reinecke,
open list:BCACHE (BLOCK LAYER CACHE),
open list:SOFTWARE RAID (Multiple Disks) SUPPORT
On 2016/12/27 下午11:55, Ming Lei wrote:
> This patch adds comment on usage of bio_alloc_pages(),
> also comments on one special case of bch_data_verify().
>
> Signed-off-by: Ming Lei <tom.leiming@gmail.com>
> ---
> block/bio.c | 4 +++-
> drivers/md/bcache/debug.c | 6 ++++++
> 2 files changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/block/bio.c b/block/bio.c
> index 2b375020fc49..d4a1e0b63ea0 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -961,7 +961,9 @@ EXPORT_SYMBOL(bio_advance);
> * @bio: bio to allocate pages for
> * @gfp_mask: flags for allocation
> *
> - * Allocates pages up to @bio->bi_vcnt.
> + * Allocates pages up to @bio->bi_vcnt, and this function should only
> + * be called on a new initialized bio, which means all pages aren't added
> + * to the bio via bio_add_page() yet.
> *
> * Returns 0 on success, -ENOMEM on failure. On failure, any allocated pages are
> * freed.
> diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
> index 06f55056aaae..48d03e8b3385 100644
> --- a/drivers/md/bcache/debug.c
> +++ b/drivers/md/bcache/debug.c
> @@ -110,6 +110,12 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
> struct bio_vec bv, cbv;
> struct bvec_iter iter, citer = { 0 };
>
> + /*
> + * Once multipage bvec is supported, the bio_clone()
> + * has to make sure page count in this bio can be held
> + * in the new cloned bio because each single page need
> + * to assign to each bvec of the new bio.
> + */
> check = bio_clone(bio, GFP_NOIO);
> if (!check)
> return;
>
Acked-by: Coly Li <colyli@suse.de>
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v1 11/54] md: set NO_MP for request queue of md
2016-12-27 15:55 [PATCH v1 00/54] block: support multipage bvec Ming Lei
2016-12-27 15:55 ` [PATCH v1 07/54] bcache: comment on direct access to bvec table Ming Lei
2016-12-27 15:55 ` [PATCH v1 08/54] block: comment on bio_alloc_pages() Ming Lei
@ 2016-12-27 15:56 ` Ming Lei
2016-12-27 15:56 ` [PATCH v1 12/54] dm: limit the max bio size as BIO_MAX_PAGES * PAGE_SIZE Ming Lei
2016-12-27 15:56 ` [PATCH v1 23/54] bcache: handle bio_clone() & bvec updating for multipage bvecs Ming Lei
4 siblings, 0 replies; 11+ messages in thread
From: Ming Lei @ 2016-12-27 15:56 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, Ming Lei, Shaohua Li,
open list:SOFTWARE RAID Multiple Disks SUPPORT
MD isn't ready for multipage bvecs, so mark it as
NO_MP.
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
drivers/md/md.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/drivers/md/md.c b/drivers/md/md.c
index 82821ee0d57f..63c6326bafde 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5162,6 +5162,16 @@ static void md_safemode_timeout(unsigned long data)
static int start_dirty_degraded;
+/*
+ * MD isn't ready for multipage bvecs yet, and set the flag
+ * so that MD still can see singlepage bvecs bio
+ */
+static inline void md_set_no_mp(struct mddev *mddev)
+{
+ if (mddev->queue)
+ set_bit(QUEUE_FLAG_NO_MP, &mddev->queue->queue_flags);
+}
+
int md_run(struct mddev *mddev)
{
int err;
@@ -5381,6 +5391,8 @@ int md_run(struct mddev *mddev)
if (mddev->sb_flags)
md_update_sb(mddev, 0);
+ md_set_no_mp(mddev);
+
md_new_event(mddev);
sysfs_notify_dirent_safe(mddev->sysfs_state);
sysfs_notify_dirent_safe(mddev->sysfs_action);
--
2.7.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v1 12/54] dm: limit the max bio size as BIO_MAX_PAGES * PAGE_SIZE
2016-12-27 15:55 [PATCH v1 00/54] block: support multipage bvec Ming Lei
` (2 preceding siblings ...)
2016-12-27 15:56 ` [PATCH v1 11/54] md: set NO_MP for request queue of md Ming Lei
@ 2016-12-27 15:56 ` Ming Lei
2016-12-27 15:56 ` [PATCH v1 23/54] bcache: handle bio_clone() & bvec updating for multipage bvecs Ming Lei
4 siblings, 0 replies; 11+ messages in thread
From: Ming Lei @ 2016-12-27 15:56 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, Ming Lei, Alasdair Kergon,
Mike Snitzer, maintainer:DEVICE-MAPPER LVM, Shaohua Li,
open list:SOFTWARE RAID Multiple Disks SUPPORT
For BIO based DM, some targets aren't ready for dealing with
bigger incoming bio than 1Mbyte, such as crypt target.
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
drivers/md/dm.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index 3086da5664f3..6139bf7623f7 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -899,7 +899,16 @@ int dm_set_target_max_io_len(struct dm_target *ti, sector_t len)
return -EINVAL;
}
- ti->max_io_len = (uint32_t) len;
+ /*
+ * BIO based queue uses its own splitting. When multipage bvecs
+ * is switched on, size of the incoming bio may be too big to
+ * be handled in some targets, such as crypt.
+ *
+ * When these targets are ready for the big bio, we can remove
+ * the limit.
+ */
+ ti->max_io_len = min_t(uint32_t, len,
+ (BIO_MAX_PAGES * PAGE_SIZE));
return 0;
}
--
2.7.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH v1 23/54] bcache: handle bio_clone() & bvec updating for multipage bvecs
2016-12-27 15:55 [PATCH v1 00/54] block: support multipage bvec Ming Lei
` (3 preceding siblings ...)
2016-12-27 15:56 ` [PATCH v1 12/54] dm: limit the max bio size as BIO_MAX_PAGES * PAGE_SIZE Ming Lei
@ 2016-12-27 15:56 ` Ming Lei
2016-12-30 11:01 ` Coly Li
4 siblings, 1 reply; 11+ messages in thread
From: Ming Lei @ 2016-12-27 15:56 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, Ming Lei, Kent Overstreet,
Shaohua Li, Mike Christie, Guoqing Jiang,
open list:BCACHE BLOCK LAYER CACHE,
open list:SOFTWARE RAID Multiple Disks SUPPORT
The incoming bio may be too big to be cloned into
one singlepage bvecs bio, so split the bio and
check the splitted bio one by one.
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
drivers/md/bcache/debug.c | 24 ++++++++++++++++++++++--
1 file changed, 22 insertions(+), 2 deletions(-)
diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
index 48d03e8b3385..18b2d2d138e3 100644
--- a/drivers/md/bcache/debug.c
+++ b/drivers/md/bcache/debug.c
@@ -103,7 +103,7 @@ void bch_btree_verify(struct btree *b)
up(&b->io_mutex);
}
-void bch_data_verify(struct cached_dev *dc, struct bio *bio)
+static void __bch_data_verify(struct cached_dev *dc, struct bio *bio)
{
char name[BDEVNAME_SIZE];
struct bio *check;
@@ -116,7 +116,7 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
* in the new cloned bio because each single page need
* to assign to each bvec of the new bio.
*/
- check = bio_clone(bio, GFP_NOIO);
+ check = bio_clone_sp(bio, GFP_NOIO);
if (!check)
return;
check->bi_opf = REQ_OP_READ;
@@ -151,6 +151,26 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
bio_put(check);
}
+void bch_data_verify(struct cached_dev *dc, struct bio *bio)
+{
+ struct request_queue *q = bdev_get_queue(bio->bi_bdev);
+ struct bio *clone = bio_clone_fast(bio, GFP_NOIO, q->bio_split);
+ unsigned sectors;
+
+ while (!bio_can_convert_to_sp(clone, §ors)) {
+ struct bio *split = bio_split(clone, sectors,
+ GFP_NOIO, q->bio_split);
+
+ __bch_data_verify(dc, split);
+ bio_put(split);
+ }
+
+ if (bio_sectors(clone))
+ __bch_data_verify(dc, clone);
+
+ bio_put(clone);
+}
+
#endif
#ifdef CONFIG_DEBUG_FS
--
2.7.4
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v1 23/54] bcache: handle bio_clone() & bvec updating for multipage bvecs
2016-12-27 15:56 ` [PATCH v1 23/54] bcache: handle bio_clone() & bvec updating for multipage bvecs Ming Lei
@ 2016-12-30 11:01 ` Coly Li
2016-12-31 10:29 ` Ming Lei
0 siblings, 1 reply; 11+ messages in thread
From: Coly Li @ 2016-12-30 11:01 UTC (permalink / raw)
To: Ming Lei
Cc: Jens Axboe, linux-kernel, linux-block, Christoph Hellwig,
Kent Overstreet, Shaohua Li, Mike Christie, Guoqing Jiang,
open list:BCACHE (BLOCK LAYER CACHE),
open list:SOFTWARE RAID (Multiple Disks) SUPPORT
On 2016/12/27 下午11:56, Ming Lei wrote:
> The incoming bio may be too big to be cloned into
> one singlepage bvecs bio, so split the bio and
> check the splitted bio one by one.
>
> Signed-off-by: Ming Lei <tom.leiming@gmail.com>
> ---
> drivers/md/bcache/debug.c | 24 ++++++++++++++++++++++--
> 1 file changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
> index 48d03e8b3385..18b2d2d138e3 100644
> --- a/drivers/md/bcache/debug.c
> +++ b/drivers/md/bcache/debug.c
> @@ -103,7 +103,7 @@ void bch_btree_verify(struct btree *b)
> up(&b->io_mutex);
> }
>
> -void bch_data_verify(struct cached_dev *dc, struct bio *bio)
> +static void __bch_data_verify(struct cached_dev *dc, struct bio *bio)
> {
> char name[BDEVNAME_SIZE];
> struct bio *check;
> @@ -116,7 +116,7 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
> * in the new cloned bio because each single page need
> * to assign to each bvec of the new bio.
> */
> - check = bio_clone(bio, GFP_NOIO);
> + check = bio_clone_sp(bio, GFP_NOIO);
> if (!check)
> return;
> check->bi_opf = REQ_OP_READ;
> @@ -151,6 +151,26 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
> bio_put(check);
> }
>
> +void bch_data_verify(struct cached_dev *dc, struct bio *bio)
> +{
> + struct request_queue *q = bdev_get_queue(bio->bi_bdev);
> + struct bio *clone = bio_clone_fast(bio, GFP_NOIO, q->bio_split);
> + unsigned sectors;
> +
> + while (!bio_can_convert_to_sp(clone, §ors)) {
> + struct bio *split = bio_split(clone, sectors,
> + GFP_NOIO, q->bio_split);
> +
> + __bch_data_verify(dc, split);
> + bio_put(split);
> + }
> +
> + if (bio_sectors(clone))
> + __bch_data_verify(dc, clone);
> +
> + bio_put(clone);
> +}
> +
Hi Lei,
The above patch is good IMHO. Just wondering why not use the classical
style ? something like,
do {
if (!bio_can_convert_to_sp(clone, §ors))
split = bio_split(clone, sectors,
GFP_NOIO, q->bio_split);
else
split = clone;
__bch_data_verity(gc, split);
bio_put(split);
} while (split != clone);
I guess maybe the above style generates less binary code.
--
Coly Li
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v1 23/54] bcache: handle bio_clone() & bvec updating for multipage bvecs
2016-12-30 11:01 ` Coly Li
@ 2016-12-31 10:29 ` Ming Lei
0 siblings, 0 replies; 11+ messages in thread
From: Ming Lei @ 2016-12-31 10:29 UTC (permalink / raw)
To: Coly Li
Cc: Jens Axboe, Linux Kernel Mailing List, linux-block,
Christoph Hellwig, Kent Overstreet, Shaohua Li, Mike Christie,
Guoqing Jiang, open list:BCACHE (BLOCK LAYER CACHE),
open list:SOFTWARE RAID (Multiple Disks) SUPPORT
Hi Coly,
On Fri, Dec 30, 2016 at 7:01 PM, Coly Li <i@coly.li> wrote:
> On 2016/12/27 下午11:56, Ming Lei wrote:
>> The incoming bio may be too big to be cloned into
>> one singlepage bvecs bio, so split the bio and
>> check the splitted bio one by one.
>>
>> Signed-off-by: Ming Lei <tom.leiming@gmail.com>
>> ---
>> drivers/md/bcache/debug.c | 24 ++++++++++++++++++++++--
>> 1 file changed, 22 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
>> index 48d03e8b3385..18b2d2d138e3 100644
>> --- a/drivers/md/bcache/debug.c
>> +++ b/drivers/md/bcache/debug.c
>> @@ -103,7 +103,7 @@ void bch_btree_verify(struct btree *b)
>> up(&b->io_mutex);
>> }
>>
>> -void bch_data_verify(struct cached_dev *dc, struct bio *bio)
>> +static void __bch_data_verify(struct cached_dev *dc, struct bio *bio)
>> {
>> char name[BDEVNAME_SIZE];
>> struct bio *check;
>> @@ -116,7 +116,7 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
>> * in the new cloned bio because each single page need
>> * to assign to each bvec of the new bio.
>> */
>> - check = bio_clone(bio, GFP_NOIO);
>> + check = bio_clone_sp(bio, GFP_NOIO);
>> if (!check)
>> return;
>> check->bi_opf = REQ_OP_READ;
>> @@ -151,6 +151,26 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
>> bio_put(check);
>> }
>>
>> +void bch_data_verify(struct cached_dev *dc, struct bio *bio)
>> +{
>> + struct request_queue *q = bdev_get_queue(bio->bi_bdev);
>> + struct bio *clone = bio_clone_fast(bio, GFP_NOIO, q->bio_split);
>> + unsigned sectors;
>> +
>> + while (!bio_can_convert_to_sp(clone, §ors)) {
>> + struct bio *split = bio_split(clone, sectors,
>> + GFP_NOIO, q->bio_split);
>> +
>> + __bch_data_verify(dc, split);
>> + bio_put(split);
>> + }
>> +
>> + if (bio_sectors(clone))
>> + __bch_data_verify(dc, clone);
>> +
>> + bio_put(clone);
>> +}
>> +
>
> Hi Lei,
>
> The above patch is good IMHO. Just wondering why not use the classical
> style ? something like,
I don't know there is the classical style, :-)
>
>
> do {
> if (!bio_can_convert_to_sp(clone, §ors))
> split = bio_split(clone, sectors,
> GFP_NOIO, q->bio_split);
> else
> split = clone;
>
> __bch_data_verity(gc, split);
> bio_put(split);
> } while (split != clone);
>
>
> I guess maybe the above style generates less binary code.
Maybe, will take this style in V2.
Thanks for the review!
--
Ming Lei
^ permalink raw reply [flat|nested] 11+ messages in thread