* [PATCH v1 10/27] bcache: debug: avoid to access .bi_io_vec directly
2016-04-14 12:02 [PATCH v1 00/27] block: cleanup direct access to .bi_vcnt & .bi_io_vec Ming Lei
@ 2016-04-14 12:02 ` Ming Lei
2016-04-14 12:02 ` [PATCH v1 11/27] bcache: io.c: use bio_set_vec_table Ming Lei
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ming Lei @ 2016-04-14 12:02 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, Ming Lei, Kent Overstreet,
Shaohua Li, open list:BCACHE BLOCK LAYER CACHE,
open list:SOFTWARE RAID Multiple Disks SUPPORT
Instead we use standard iterator way to do that.
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
---
drivers/md/bcache/debug.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/md/bcache/debug.c b/drivers/md/bcache/debug.c
index 8b1f1d5..d1ad49d 100644
--- a/drivers/md/bcache/debug.c
+++ b/drivers/md/bcache/debug.c
@@ -106,8 +106,8 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
{
char name[BDEVNAME_SIZE];
struct bio *check;
- struct bio_vec bv, *bv2;
- struct bvec_iter iter;
+ struct bio_vec bv, cbv, *bv2;
+ struct bvec_iter iter, citer = { 0 };
int i;
check = bio_clone(bio, GFP_NOIO);
@@ -119,9 +119,13 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
submit_bio_wait(READ_SYNC, check);
+ citer.bi_size = UINT_MAX;
bio_for_each_segment(bv, bio, iter) {
void *p1 = kmap_atomic(bv.bv_page);
- void *p2 = page_address(check->bi_io_vec[iter.bi_idx].bv_page);
+ void *p2;
+
+ cbv = bio_iter_iovec(check, citer);
+ p2 = page_address(cbv.bv_page);
cache_set_err_on(memcmp(p1 + bv.bv_offset,
p2 + bv.bv_offset,
@@ -132,6 +136,7 @@ void bch_data_verify(struct cached_dev *dc, struct bio *bio)
(uint64_t) bio->bi_iter.bi_sector);
kunmap_atomic(p1);
+ bio_advance_iter(check, &citer, bv.bv_len);
}
bio_for_each_segment_all(bv2, check, i)
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v1 11/27] bcache: io.c: use bio_set_vec_table
2016-04-14 12:02 [PATCH v1 00/27] block: cleanup direct access to .bi_vcnt & .bi_io_vec Ming Lei
2016-04-14 12:02 ` [PATCH v1 10/27] bcache: debug: avoid to access .bi_io_vec directly Ming Lei
@ 2016-04-14 12:02 ` Ming Lei
2016-04-14 12:02 ` [PATCH v1 12/27] bcache: journal.c: use bio_set_vec_table() Ming Lei
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ming Lei @ 2016-04-14 12:02 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, 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/io.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c
index 86a0bb8..1c48462 100644
--- a/drivers/md/bcache/io.c
+++ b/drivers/md/bcache/io.c
@@ -26,8 +26,7 @@ struct bio *bch_bbio_alloc(struct cache_set *c)
bio_init(bio);
bio->bi_flags |= BIO_POOL_NONE << BIO_POOL_OFFSET;
- bio->bi_max_vecs = bucket_pages(c);
- bio->bi_io_vec = bio->bi_inline_vecs;
+ bio_set_vec_table(bio, bio->bi_inline_vecs, bucket_pages(c));
return bio;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v1 12/27] bcache: journal.c: use bio_set_vec_table()
2016-04-14 12:02 [PATCH v1 00/27] block: cleanup direct access to .bi_vcnt & .bi_io_vec Ming Lei
2016-04-14 12:02 ` [PATCH v1 10/27] bcache: debug: avoid to access .bi_io_vec directly Ming Lei
2016-04-14 12:02 ` [PATCH v1 11/27] bcache: io.c: use bio_set_vec_table Ming Lei
@ 2016-04-14 12:02 ` Ming Lei
2016-04-14 12:02 ` [PATCH v1 13/27] bcache: movinggc: " Ming Lei
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ming Lei @ 2016-04-14 12:02 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, 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/journal.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c
index 29eba72..bf8924f 100644
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -453,8 +453,7 @@ static void do_journal_discard(struct cache *ca)
ca->sb.d[ja->discard_idx]);
bio->bi_bdev = ca->bdev;
bio->bi_rw = REQ_WRITE|REQ_DISCARD;
- bio->bi_max_vecs = 1;
- bio->bi_io_vec = bio->bi_inline_vecs;
+ bio_set_vec_table(bio, bio->bi_inline_vecs, 1);
bio->bi_iter.bi_size = bucket_bytes(ca);
bio->bi_end_io = journal_discard_endio;
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v1 13/27] bcache: movinggc: use bio_set_vec_table()
2016-04-14 12:02 [PATCH v1 00/27] block: cleanup direct access to .bi_vcnt & .bi_io_vec Ming Lei
` (2 preceding siblings ...)
2016-04-14 12:02 ` [PATCH v1 12/27] bcache: journal.c: use bio_set_vec_table() Ming Lei
@ 2016-04-14 12:02 ` Ming Lei
2016-04-14 12:02 ` [PATCH v1 14/27] bcache: writeback: " Ming Lei
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Ming Lei @ 2016-04-14 12:02 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, 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/movinggc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/md/bcache/movinggc.c b/drivers/md/bcache/movinggc.c
index b929fc9..dbe5af2 100644
--- a/drivers/md/bcache/movinggc.c
+++ b/drivers/md/bcache/movinggc.c
@@ -85,10 +85,10 @@ static void moving_init(struct moving_io *io)
bio_set_prio(bio, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0));
bio->bi_iter.bi_size = KEY_SIZE(&io->w->key) << 9;
- bio->bi_max_vecs = DIV_ROUND_UP(KEY_SIZE(&io->w->key),
- PAGE_SECTORS);
bio->bi_private = &io->cl;
- bio->bi_io_vec = bio->bi_inline_vecs;
+ bio_set_vec_table(bio, bio->bi_inline_vecs,
+ DIV_ROUND_UP(KEY_SIZE(&io->w->key),
+ PAGE_SECTORS));
bch_bio_map(bio, NULL);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v1 14/27] bcache: writeback: use bio_set_vec_table()
2016-04-14 12:02 [PATCH v1 00/27] block: cleanup direct access to .bi_vcnt & .bi_io_vec Ming Lei
` (3 preceding siblings ...)
2016-04-14 12:02 ` [PATCH v1 13/27] bcache: movinggc: " Ming Lei
@ 2016-04-14 12:02 ` Ming Lei
2016-04-14 12:02 ` [PATCH v1 15/27] bcache: super: " Ming Lei
2016-04-14 12:02 ` [PATCH v1 16/27] bcache: super: use bio_get_base_vec Ming Lei
6 siblings, 0 replies; 8+ messages in thread
From: Ming Lei @ 2016-04-14 12:02 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, 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/writeback.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/md/bcache/writeback.c b/drivers/md/bcache/writeback.c
index b9346cd..49a8f8a 100644
--- a/drivers/md/bcache/writeback.c
+++ b/drivers/md/bcache/writeback.c
@@ -112,9 +112,9 @@ static void dirty_init(struct keybuf_key *w)
bio_set_prio(bio, IOPRIO_PRIO_VALUE(IOPRIO_CLASS_IDLE, 0));
bio->bi_iter.bi_size = KEY_SIZE(&w->key) << 9;
- bio->bi_max_vecs = DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS);
bio->bi_private = w;
- bio->bi_io_vec = bio->bi_inline_vecs;
+ bio_set_vec_table(bio, bio->bi_inline_vecs,
+ DIV_ROUND_UP(KEY_SIZE(&w->key), PAGE_SECTORS));
bch_bio_map(bio, NULL);
}
--
1.9.1
^ permalink raw reply related [flat|nested] 8+ messages in thread* [PATCH v1 15/27] bcache: super: use bio_set_vec_table()
2016-04-14 12:02 [PATCH v1 00/27] block: cleanup direct access to .bi_vcnt & .bi_io_vec Ming Lei
` (4 preceding siblings ...)
2016-04-14 12:02 ` [PATCH v1 14/27] bcache: writeback: " Ming Lei
@ 2016-04-14 12:02 ` Ming Lei
2016-04-14 12:02 ` [PATCH v1 16/27] bcache: super: use bio_get_base_vec Ming Lei
6 siblings, 0 replies; 8+ messages in thread
From: Ming Lei @ 2016-04-14 12:02 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, 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 f5dbb4e..3fa1ecf 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] 8+ messages in thread* [PATCH v1 16/27] bcache: super: use bio_get_base_vec
2016-04-14 12:02 [PATCH v1 00/27] block: cleanup direct access to .bi_vcnt & .bi_io_vec Ming Lei
` (5 preceding siblings ...)
2016-04-14 12:02 ` [PATCH v1 15/27] bcache: super: " Ming Lei
@ 2016-04-14 12:02 ` Ming Lei
6 siblings, 0 replies; 8+ messages in thread
From: Ming Lei @ 2016-04-14 12:02 UTC (permalink / raw)
To: Jens Axboe, linux-kernel
Cc: linux-block, Christoph Hellwig, 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 | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 3fa1ecf..d7fda32 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,9 @@ 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;
+ /* single bvec, still works after multipage bvecs */
+ 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 +1784,11 @@ void bch_cache_release(struct kobject *kobj)
{
struct cache *ca = container_of(kobj, struct cache, kobj);
unsigned i;
+ /*
+ * For accessing page pointed to by the 1st bvec, it
+ * works too after multipage bvecs.
+ */
+ 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 +1806,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 +1856,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 +1864,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] 8+ messages in thread