* [PATCH 15/27] bcache: super: use bio_set_vec_table()
@ 2016-04-05 12:07 Ming Lei
2016-04-05 12:07 ` [PATCH 16/27] bcache: super: use bio_get_base_vec Ming Lei
` (4 more replies)
0 siblings, 5 replies; 9+ messages in thread
From: Ming Lei @ 2016-04-05 12:07 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, Boaz Harrosh, Ming Lei,
Kent Overstreet, Shaohua Li, open list:BCACHE BLOCK LAYER CACHE,
open list:SOFTWARE RAID Multiple Disks SUPPORT
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
drivers/md/bcache/super.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index a296425..3f649c9 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1151,8 +1151,7 @@ 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_max_vecs = 1;
- dc->sb_bio.bi_io_vec = dc->sb_bio.bi_inline_vecs;
+ bio_set_vec_table(&dc->sb_bio, dc->sb_bio.bi_inline_vecs, 1);
dc->sb_bio.bi_io_vec[0].bv_page = sb_page;
get_page(sb_page);
@@ -1812,8 +1811,8 @@ static int cache_alloc(struct cache_sb *sb, struct cache *ca)
kobject_init(&ca->kobj, &bch_cache_ktype);
bio_init(&ca->journal.bio);
- ca->journal.bio.bi_max_vecs = 8;
- ca->journal.bio.bi_io_vec = ca->journal.bio.bi_inline_vecs;
+ bio_set_vec_table(&ca->journal.bio,
+ ca->journal.bio.bi_inline_vecs, 8);
free = roundup_pow_of_two(ca->sb.nbuckets) >> 10;
@@ -1850,8 +1849,7 @@ 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_max_vecs = 1;
- ca->sb_bio.bi_io_vec = ca->sb_bio.bi_inline_vecs;
+ bio_set_vec_table(&ca->sb_bio, ca->sb_bio.bi_inline_vecs, 1);
ca->sb_bio.bi_io_vec[0].bv_page = sb_page;
get_page(sb_page);
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 16/27] bcache: super: use bio_get_base_vec
2016-04-05 12:07 [PATCH 15/27] bcache: super: use bio_set_vec_table() Ming Lei
@ 2016-04-05 12:07 ` Ming Lei
2016-04-05 12:07 ` [PATCH 17/27] dm: crypt: use bio_add_page() Ming Lei
` (3 subsequent siblings)
4 siblings, 0 replies; 9+ messages in thread
From: Ming Lei @ 2016-04-05 12:07 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, Boaz Harrosh, Ming Lei,
Kent Overstreet, Shaohua Li, open list:BCACHE BLOCK LAYER CACHE,
open list:SOFTWARE RAID Multiple Disks SUPPORT
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
drivers/md/bcache/super.c | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 3f649c9..56ad797 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -208,7 +208,12 @@ static void write_bdev_super_endio(struct bio *bio)
static void __write_super(struct cache_sb *sb, struct bio *bio)
{
- struct cache_sb *out = page_address(bio->bi_io_vec[0].bv_page);
+ /*
+ * For accessing page pointed to by the 1st bvec, it
+ * works too after multipage bvecs.
+ */
+ struct bio_vec *bvec = bio_get_base_vec(bio);
+ struct cache_sb *out = page_address(bvec->bv_page);
unsigned i;
bio->bi_iter.bi_sector = SB_SECTOR;
@@ -1145,6 +1150,7 @@ static void register_bdev(struct cache_sb *sb, struct page *sb_page,
char name[BDEVNAME_SIZE];
const char *err = "cannot allocate memory";
struct cache_set *c;
+ struct bio_vec *bvec;
memcpy(&dc->sb, sb, sizeof(struct cache_sb));
dc->bdev = bdev;
@@ -1152,7 +1158,8 @@ static void register_bdev(struct cache_sb *sb, struct page *sb_page,
bio_init(&dc->sb_bio);
bio_set_vec_table(&dc->sb_bio, dc->sb_bio.bi_inline_vecs, 1);
- dc->sb_bio.bi_io_vec[0].bv_page = sb_page;
+ bvec = bio_get_base_vec(&dc->sb_bio);
+ bvec->bv_page = sb_page;
get_page(sb_page);
if (cached_dev_init(dc, sb->block_size << 9))
@@ -1776,6 +1783,7 @@ void bch_cache_release(struct kobject *kobj)
{
struct cache *ca = container_of(kobj, struct cache, kobj);
unsigned i;
+ struct bio_vec *bvec = bio_get_base_vec(&ca->sb_bio);
if (ca->set) {
BUG_ON(ca->set->cache[ca->sb.nr_this_dev] != ca);
@@ -1793,7 +1801,7 @@ void bch_cache_release(struct kobject *kobj)
free_fifo(&ca->free[i]);
if (ca->sb_bio.bi_inline_vecs[0].bv_page)
- put_page(ca->sb_bio.bi_io_vec[0].bv_page);
+ put_page(bvec->bv_page);
if (!IS_ERR_OR_NULL(ca->bdev))
blkdev_put(ca->bdev, FMODE_READ|FMODE_WRITE|FMODE_EXCL);
@@ -1843,6 +1851,7 @@ static int register_cache(struct cache_sb *sb, struct page *sb_page,
char name[BDEVNAME_SIZE];
const char *err = NULL;
int ret = 0;
+ struct bio_vec *bvec;
memcpy(&ca->sb, sb, sizeof(struct cache_sb));
ca->bdev = bdev;
@@ -1850,7 +1859,8 @@ static int register_cache(struct cache_sb *sb, struct page *sb_page,
bio_init(&ca->sb_bio);
bio_set_vec_table(&ca->sb_bio, ca->sb_bio.bi_inline_vecs, 1);
- ca->sb_bio.bi_io_vec[0].bv_page = sb_page;
+ bvec = bio_get_base_vec(&ca->sb_bio);
+ bvec->bv_page = sb_page;
get_page(sb_page);
if (blk_queue_discard(bdev_get_queue(ca->bdev)))
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 17/27] dm: crypt: use bio_add_page()
2016-04-05 12:07 [PATCH 15/27] bcache: super: use bio_set_vec_table() Ming Lei
2016-04-05 12:07 ` [PATCH 16/27] bcache: super: use bio_get_base_vec Ming Lei
@ 2016-04-05 12:07 ` Ming Lei
2016-04-05 12:49 ` Christoph Hellwig
2016-04-05 12:07 ` [PATCH 18/27] dm: dm-io.c: use bio_get_base_vec() Ming Lei
` (2 subsequent siblings)
4 siblings, 1 reply; 9+ messages in thread
From: Ming Lei @ 2016-04-05 12:07 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, Boaz Harrosh, Ming Lei,
Alasdair Kergon, Mike Snitzer, maintainer:DEVICE-MAPPER LVM,
Shaohua Li, open list:SOFTWARE RAID Multiple Disks SUPPORT
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
drivers/md/dm-crypt.c | 8 +-------
1 file changed, 1 insertion(+), 7 deletions(-)
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c
index 4f3cb35..a2805c1 100644
--- a/drivers/md/dm-crypt.c
+++ b/drivers/md/dm-crypt.c
@@ -995,7 +995,6 @@ static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size)
gfp_t gfp_mask = GFP_NOWAIT | __GFP_HIGHMEM;
unsigned i, len, remaining_size;
struct page *page;
- struct bio_vec *bvec;
retry:
if (unlikely(gfp_mask & __GFP_DIRECT_RECLAIM))
@@ -1020,12 +1019,7 @@ retry:
len = (remaining_size > PAGE_SIZE) ? PAGE_SIZE : remaining_size;
- bvec = &clone->bi_io_vec[clone->bi_vcnt++];
- bvec->bv_page = page;
- bvec->bv_len = len;
- bvec->bv_offset = 0;
-
- clone->bi_iter.bi_size += len;
+ bio_add_page(clone, page, len, 0);
remaining_size -= len;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 18/27] dm: dm-io.c: use bio_get_base_vec()
2016-04-05 12:07 [PATCH 15/27] bcache: super: use bio_set_vec_table() Ming Lei
2016-04-05 12:07 ` [PATCH 16/27] bcache: super: use bio_get_base_vec Ming Lei
2016-04-05 12:07 ` [PATCH 17/27] dm: crypt: use bio_add_page() Ming Lei
@ 2016-04-05 12:07 ` Ming Lei
2016-04-05 12:07 ` [PATCH 19/27] dm: dm.c: replace 'bio->bi_vcnt == 1' with !bio_multiple_segments Ming Lei
2016-04-05 12:07 ` [PATCH 20/27] dm: dm-bufio.c: use bio_set_vec_table() Ming Lei
4 siblings, 0 replies; 9+ messages in thread
From: Ming Lei @ 2016-04-05 12:07 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, Boaz Harrosh, Ming Lei,
Alasdair Kergon, Mike Snitzer, maintainer:DEVICE-MAPPER LVM,
Shaohua Li, open list:SOFTWARE RAID Multiple Disks SUPPORT
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
drivers/md/dm-io.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index 06d426e..6b0e466 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -221,7 +221,12 @@ static void bio_dp_init(struct dpages *dp, struct bio *bio)
{
dp->get_page = bio_get_page;
dp->next_page = bio_next_page;
- dp->context_ptr = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter);
+
+ /*
+ * need to fix both bio_get_page() and bio_next_page()
+ * before multipage bvecs
+ */
+ dp->context_ptr = bio_get_base_vec(bio);
dp->context_u = bio->bi_iter.bi_bvec_done;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 19/27] dm: dm.c: replace 'bio->bi_vcnt == 1' with !bio_multiple_segments
2016-04-05 12:07 [PATCH 15/27] bcache: super: use bio_set_vec_table() Ming Lei
` (2 preceding siblings ...)
2016-04-05 12:07 ` [PATCH 18/27] dm: dm-io.c: use bio_get_base_vec() Ming Lei
@ 2016-04-05 12:07 ` Ming Lei
2016-04-05 12:07 ` [PATCH 20/27] dm: dm-bufio.c: use bio_set_vec_table() Ming Lei
4 siblings, 0 replies; 9+ messages in thread
From: Ming Lei @ 2016-04-05 12:07 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, Boaz Harrosh, Ming Lei,
Alasdair Kergon, Mike Snitzer, maintainer:DEVICE-MAPPER LVM,
Shaohua Li, open list:SOFTWARE RAID Multiple Disks SUPPORT
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
drivers/md/dm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/md/dm.c b/drivers/md/dm.c
index be49057..4c34f88 100644
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@ -2172,7 +2172,8 @@ static void dm_request_fn(struct request_queue *q)
pos = blk_rq_pos(rq);
if ((dm_request_peeked_before_merge_deadline(md) &&
- md_in_flight(md) && rq->bio && rq->bio->bi_vcnt == 1 &&
+ md_in_flight(md) && rq->bio &&
+ !bio_multiple_segments(rq->bio) &&
md->last_rq_pos == pos && md->last_rq_rw == rq_data_dir(rq)) ||
(ti->type->busy && ti->type->busy(ti))) {
blk_delay_queue(q, HZ / 100);
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 20/27] dm: dm-bufio.c: use bio_set_vec_table()
2016-04-05 12:07 [PATCH 15/27] bcache: super: use bio_set_vec_table() Ming Lei
` (3 preceding siblings ...)
2016-04-05 12:07 ` [PATCH 19/27] dm: dm.c: replace 'bio->bi_vcnt == 1' with !bio_multiple_segments Ming Lei
@ 2016-04-05 12:07 ` Ming Lei
2016-04-05 13:04 ` Christoph Hellwig
4 siblings, 1 reply; 9+ messages in thread
From: Ming Lei @ 2016-04-05 12:07 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, Boaz Harrosh, Ming Lei,
Alasdair Kergon, Mike Snitzer, maintainer:DEVICE-MAPPER LVM,
Shaohua Li, open list:SOFTWARE RAID Multiple Disks SUPPORT
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
drivers/md/dm-bufio.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
index cd77216..0e48ad7 100644
--- a/drivers/md/dm-bufio.c
+++ b/drivers/md/dm-bufio.c
@@ -624,8 +624,7 @@ static void use_inline_bio(struct dm_buffer *b, int rw, sector_t block,
int len;
bio_init(&b->bio);
- b->bio.bi_io_vec = b->bio_vec;
- b->bio.bi_max_vecs = DM_BUFIO_INLINE_VECS;
+ bio_set_vec_table(&b->bio, b->bio_vec, DM_BUFIO_INLINE_VECS);
b->bio.bi_iter.bi_sector = block << b->c->sectors_per_block_bits;
b->bio.bi_bdev = b->c->bdev;
b->bio.bi_end_io = inline_endio;
--
1.9.1
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 17/27] dm: crypt: use bio_add_page()
2016-04-05 12:07 ` [PATCH 17/27] dm: crypt: use bio_add_page() Ming Lei
@ 2016-04-05 12:49 ` Christoph Hellwig
0 siblings, 0 replies; 9+ messages in thread
From: Christoph Hellwig @ 2016-04-05 12:49 UTC (permalink / raw)
To: Ming Lei
Cc: Jens Axboe, linux-kernel, linux-block, Christoph Hellwig,
Boaz Harrosh, Alasdair Kergon, Mike Snitzer,
maintainer:DEVICE-MAPPER (LVM), Shaohua Li,
open list:SOFTWARE RAID (Multiple Disks) SUPPORT
Looks fine,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 20/27] dm: dm-bufio.c: use bio_set_vec_table()
2016-04-05 12:07 ` [PATCH 20/27] dm: dm-bufio.c: use bio_set_vec_table() Ming Lei
@ 2016-04-05 13:04 ` Christoph Hellwig
2016-04-05 18:11 ` Mike Snitzer
0 siblings, 1 reply; 9+ messages in thread
From: Christoph Hellwig @ 2016-04-05 13:04 UTC (permalink / raw)
To: Ming Lei
Cc: Jens Axboe, linux-kernel, linux-block, Christoph Hellwig,
Boaz Harrosh, Alasdair Kergon, Mike Snitzer,
maintainer:DEVICE-MAPPER (LVM), Shaohua Li,
open list:SOFTWARE RAID (Multiple Disks) SUPPORT
On Tue, Apr 05, 2016 at 08:07:35PM +0800, Ming Lei wrote:
> Signed-off-by: Ming Lei <tom.leiming@gmail.com>
> ---
> drivers/md/dm-bufio.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
> index cd77216..0e48ad7 100644
> --- a/drivers/md/dm-bufio.c
> +++ b/drivers/md/dm-bufio.c
> @@ -624,8 +624,7 @@ static void use_inline_bio(struct dm_buffer *b, int rw, sector_t block,
> int len;
>
> bio_init(&b->bio);
> - b->bio.bi_io_vec = b->bio_vec;
> - b->bio.bi_max_vecs = DM_BUFIO_INLINE_VECS;
> + bio_set_vec_table(&b->bio, b->bio_vec, DM_BUFIO_INLINE_VECS);
> b->bio.bi_iter.bi_sector = block << b->c->sectors_per_block_bits;
> b->bio.bi_bdev = b->c->bdev;
> b->bio.bi_end_io = inline_endio;
Should be switched to use bio_alloc instead.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 20/27] dm: dm-bufio.c: use bio_set_vec_table()
2016-04-05 13:04 ` Christoph Hellwig
@ 2016-04-05 18:11 ` Mike Snitzer
0 siblings, 0 replies; 9+ messages in thread
From: Mike Snitzer @ 2016-04-05 18:11 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Ming Lei, Jens Axboe, linux-kernel, linux-block, Boaz Harrosh,
Alasdair Kergon, maintainer:DEVICE-MAPPER (LVM), Shaohua Li,
open list:SOFTWARE RAID (Multiple Disks) SUPPORT
On Tue, Apr 05 2016 at 9:04am -0400,
Christoph Hellwig <hch@infradead.org> wrote:
> On Tue, Apr 05, 2016 at 08:07:35PM +0800, Ming Lei wrote:
> > Signed-off-by: Ming Lei <tom.leiming@gmail.com>
> > ---
> > drivers/md/dm-bufio.c | 3 +--
> > 1 file changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c
> > index cd77216..0e48ad7 100644
> > --- a/drivers/md/dm-bufio.c
> > +++ b/drivers/md/dm-bufio.c
> > @@ -624,8 +624,7 @@ static void use_inline_bio(struct dm_buffer *b, int rw, sector_t block,
> > int len;
> >
> > bio_init(&b->bio);
> > - b->bio.bi_io_vec = b->bio_vec;
> > - b->bio.bi_max_vecs = DM_BUFIO_INLINE_VECS;
> > + bio_set_vec_table(&b->bio, b->bio_vec, DM_BUFIO_INLINE_VECS);
> > b->bio.bi_iter.bi_sector = block << b->c->sectors_per_block_bits;
> > b->bio.bi_bdev = b->c->bdev;
> > b->bio.bi_end_io = inline_endio;
>
> Should be switched to use bio_alloc instead.
Why does the use of bio_init() vs bio_alloc() bother you?
'struct dm_buffer' has a 'struct bio'. That bio is allocated as part of
the dm_buffer in drivers/md/dmbufio.c:alloc_buffer() -- which is called
by various other bufio interfaces (e.g. __alloc_buffer_wait). Bufio is
in control of ensuring forward progress by carefully managing the memory
associated with these buffers. I don't see the benefit of bio_alloc()
here. What am I missing?
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2016-04-05 18:11 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-05 12:07 [PATCH 15/27] bcache: super: use bio_set_vec_table() Ming Lei
2016-04-05 12:07 ` [PATCH 16/27] bcache: super: use bio_get_base_vec Ming Lei
2016-04-05 12:07 ` [PATCH 17/27] dm: crypt: use bio_add_page() Ming Lei
2016-04-05 12:49 ` Christoph Hellwig
2016-04-05 12:07 ` [PATCH 18/27] dm: dm-io.c: use bio_get_base_vec() Ming Lei
2016-04-05 12:07 ` [PATCH 19/27] dm: dm.c: replace 'bio->bi_vcnt == 1' with !bio_multiple_segments Ming Lei
2016-04-05 12:07 ` [PATCH 20/27] dm: dm-bufio.c: use bio_set_vec_table() Ming Lei
2016-04-05 13:04 ` Christoph Hellwig
2016-04-05 18:11 ` Mike Snitzer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).