Skip to contentSkip to conversation

bcache: super: use bio_set_vec_table()

PATCH In review Ming Lei 3 participants 20 messages Apr 5, 2016

Subsystems (7)
lore
Share & tools
lore

Ming Lei

author
#0 lore raw

PATCH 15/27 bcache: super: use bio_set_vec_table()

---
 drivers/md/bcache/super.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/md/bcache/super.c +4 -6
index a296425..3f649c9 100644
@@ -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);
 
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH 16/27 bcache: super: use bio_get_base_vec

---
 drivers/md/bcache/super.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)
drivers/md/bcache/super.c +14 -4
index 3f649c9..56ad797 100644
@@ -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)))
Signature · 1 line
1.9.1
author
#2 lore raw

PATCH 17/27 dm: crypt: use bio_add_page()

In reply to Ming Lei
---
 drivers/md/dm-crypt.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/md/dm-crypt.c +1 -7
index 4f3cb35..a2805c1 100644
@@ -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;
 	}
Signature · 1 line
1.9.1
author
#4 lore raw

PATCH 18/27 dm: dm-io.c: use bio_get_base_vec()

In reply to Ming Lei
---
 drivers/md/dm-io.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/md/dm-io.c +6 -1
index 06d426e..6b0e466 100644
@@ -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;
 }
 
Signature · 1 line
1.9.1
author
#5 lore raw

PATCH 19/27 dm: dm.c: replace 'bio->bi_vcnt == 1' with !bio_multiple_segments

In reply to Ming Lei
---
 drivers/md/dm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/md/dm.c +2 -1
index be49057..4c34f88 100644
@@ -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);
Signature · 1 line
1.9.1
author
#6 lore raw

PATCH 20/27 dm: dm-bufio.c: use bio_set_vec_table()

In reply to Ming Lei
---
 drivers/md/dm-bufio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/dm-bufio.c +1 -2
index cd77216..0e48ad7 100644
@@ -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;
Signature · 1 line
1.9.1
#7 lore raw

Re: [PATCH 20/27] dm: dm-bufio.c: use bio_set_vec_table()

Quoted 10 lines · Ming Lei
---
 drivers/md/dm-bufio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/dm-bufio.c +0 -0
index cd77216..0e48ad7 100644

drivers/md/dm-bufio.c static void use_inline_bio(struct dm_buffer *b, int rw, sector_t block, · line 630

Quoted 9 lines
drivers/md/dm-bufio.c +1 -2
@@ -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.

#8 lore raw

Re: [PATCH 20/27] dm: dm-bufio.c: use bio_set_vec_table()

Quoted 13 lines · Christoph Hellwig
Quoted 12 lines · Ming Lei
---
 drivers/md/dm-bufio.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/md/dm-bufio.c +0 -0
index cd77216..0e48ad7 100644
@@ -624,8 +624,7 @@ static void use_inline_bio(struct dm_buffer *b, int rw, sector_t block,
 	int len;
 
Quoted 9 lines

drivers/md/dm-bufio.c static void use_inline_bio(struct dm_buffer *b, int rw, sector_t block, · line 630

Quoted 7 lines
drivers/md/dm-bufio.c +1 -2
 	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?

author
#9 lore raw

PATCH 21/27 fs: logfs: use bio_set_vec_table()

In reply to Ming Lei
---
 fs/logfs/dev_bdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
fs/logfs/dev_bdev.c +1 -2
index a709d80..bc422bc9 100644
@@ -20,8 +20,7 @@ static int sync_request(struct page *page, struct block_device *bdev, int rw)
 	struct bio_vec bio_vec;
 
 	bio_init(&bio);
-	bio.bi_max_vecs = 1;
-	bio.bi_io_vec = &bio_vec;
+	bio_set_vec_table(&bio, &bio_vec, 1);
 	bio_vec.bv_page = page;
 	bio_vec.bv_len = PAGE_SIZE;
 	bio_vec.bv_offset = 0;
Signature · 1 line
1.9.1
author
#11 lore raw

PATCH 22/27 fs: logfs: convert to bio_add_page() in sync_request()

In reply to Ming Lei
---
 fs/logfs/dev_bdev.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
fs/logfs/dev_bdev.c +2 -5
index bc422bc9..957c237 100644
@@ -21,13 +21,10 @@ static int sync_request(struct page *page, struct block_device *bdev, int rw)
 
 	bio_init(&bio);
 	bio_set_vec_table(&bio, &bio_vec, 1);
-	bio_vec.bv_page = page;
-	bio_vec.bv_len = PAGE_SIZE;
-	bio_vec.bv_offset = 0;
-	bio.bi_vcnt = 1;
 	bio.bi_bdev = bdev;
 	bio.bi_iter.bi_sector = page->index * (PAGE_SIZE >> 9);
-	bio.bi_iter.bi_size = PAGE_SIZE;
+
+	bio_add_page(&bio, page, PAGE_SIZE, 0);
 
 	return submit_bio_wait(rw, &bio);
 }
Signature · 1 line
1.9.1
author
#13 lore raw

PATCH 23/27 fs: logfs: use bio_add_page() in __bdev_writeseg()

In reply to Ming Lei

Also this patch simplify the code a bit.

---
 fs/logfs/dev_bdev.c | 51 +++++++++++++++++++++------------------------------
 1 file changed, 21 insertions(+), 30 deletions(-)
fs/logfs/dev_bdev.c +21 -30
index 957c237..1df84e0 100644
@@ -72,54 +72,45 @@ static int __bdev_writeseg(struct super_block *sb, u64 ofs, pgoff_t index,
 {
 	struct logfs_super *super = logfs_super(sb);
 	struct address_space *mapping = super->s_mapping_inode->i_mapping;
-	struct bio *bio;
+	struct bio *bio = NULL;
 	struct page *page;
 	unsigned int max_pages;
-	int i;
+	int i, ret;
 
 	max_pages = min_t(size_t, nr_pages, BIO_MAX_PAGES);
 
-	bio = bio_alloc(GFP_NOFS, max_pages);
-	BUG_ON(!bio);
-
 	for (i = 0; i < nr_pages; i++) {
-		if (i >= max_pages) {
-			/* Block layer cannot split bios :( */
-			bio->bi_vcnt = i;
-			bio->bi_iter.bi_size = i * PAGE_SIZE;
+		if (!bio) {
+			bio = bio_alloc(GFP_NOFS, max_pages);
+			BUG_ON(!bio);
 			bio->bi_bdev = super->s_bdev;
 			bio->bi_iter.bi_sector = ofs >> 9;
 			bio->bi_private = sb;
 			bio->bi_end_io = writeseg_end_io;
-			atomic_inc(&super->s_pending_writes);
-			submit_bio(WRITE, bio);
-
-			ofs += i * PAGE_SIZE;
-			index += i;
-			nr_pages -= i;
-			i = 0;
-
-			bio = bio_alloc(GFP_NOFS, max_pages);
-			BUG_ON(!bio);
 		}
+
 		page = find_lock_page(mapping, index + i);
 		BUG_ON(!page);
-		bio->bi_io_vec[i].bv_page = page;
-		bio->bi_io_vec[i].bv_len = PAGE_SIZE;
-		bio->bi_io_vec[i].bv_offset = 0;
+
+		ret = bio_add_page(bio, page, PAGE_SIZE, 0);
 
 		BUG_ON(PageWriteback(page));
 		set_page_writeback(page);
 		unlock_page(page);
+		if (!ret) {
+			/* Block layer cannot split bios :( */
+			ofs += bio->bi_iter.bi_size;
+			atomic_inc(&super->s_pending_writes);
+			submit_bio(WRITE, bio);
+
+			bio = NULL;
+		}
+	}
+
+	if (bio) {
+		atomic_inc(&super->s_pending_writes);
+		submit_bio(WRITE, bio);
 	}
-	bio->bi_vcnt = nr_pages;
-	bio->bi_iter.bi_size = nr_pages * PAGE_SIZE;
-	bio->bi_bdev = super->s_bdev;
-	bio->bi_iter.bi_sector = ofs >> 9;
-	bio->bi_private = sb;
-	bio->bi_end_io = writeseg_end_io;
-	atomic_inc(&super->s_pending_writes);
-	submit_bio(WRITE, bio);
 	return 0;
 }
 
Signature · 1 line
1.9.1
author
#14 lore raw

PATCH 24/27 fs: logfs: use bio_add_page() in do_erase()

In reply to Ming Lei

Also code gets simplified a bit.

---
 fs/logfs/dev_bdev.c | 45 ++++++++++++++++++---------------------------
 1 file changed, 18 insertions(+), 27 deletions(-)
fs/logfs/dev_bdev.c +18 -27
index 1df84e0..db04231 100644
@@ -154,47 +154,38 @@ static int do_erase(struct super_block *sb, u64 ofs, pgoff_t index,
 		size_t nr_pages)
 {
 	struct logfs_super *super = logfs_super(sb);
-	struct bio *bio;
+	struct bio *bio = NULL;
 	unsigned int max_pages;
-	int i;
+	int i, ret;
 
 	max_pages = min_t(size_t, nr_pages, BIO_MAX_PAGES);
 
-	bio = bio_alloc(GFP_NOFS, max_pages);
-	BUG_ON(!bio);
-
 	for (i = 0; i < nr_pages; i++) {
-		if (i >= max_pages) {
-			/* Block layer cannot split bios :( */
-			bio->bi_vcnt = i;
-			bio->bi_iter.bi_size = i * PAGE_SIZE;
+		if (!bio) {
+			bio = bio_alloc(GFP_NOFS, max_pages);
+			BUG_ON(!bio);
+
 			bio->bi_bdev = super->s_bdev;
 			bio->bi_iter.bi_sector = ofs >> 9;
 			bio->bi_private = sb;
 			bio->bi_end_io = erase_end_io;
+		}
+
+		ret = bio_add_page(bio, super->s_erase_page, PAGE_SIZE, 0);
+		if (!ret) {
+			/* Block layer cannot split bios :( */
+			ofs += bio->bi_iter.bi_size;
 			atomic_inc(&super->s_pending_writes);
 			submit_bio(WRITE, bio);
 
-			ofs += i * PAGE_SIZE;
-			index += i;
-			nr_pages -= i;
-			i = 0;
-
-			bio = bio_alloc(GFP_NOFS, max_pages);
-			BUG_ON(!bio);
+			bio = NULL;
 		}
-		bio->bi_io_vec[i].bv_page = super->s_erase_page;
-		bio->bi_io_vec[i].bv_len = PAGE_SIZE;
-		bio->bi_io_vec[i].bv_offset = 0;
 	}
-	bio->bi_vcnt = nr_pages;
-	bio->bi_iter.bi_size = nr_pages * PAGE_SIZE;
-	bio->bi_bdev = super->s_bdev;
-	bio->bi_iter.bi_sector = ofs >> 9;
-	bio->bi_private = sb;
-	bio->bi_end_io = erase_end_io;
-	atomic_inc(&super->s_pending_writes);
-	submit_bio(WRITE, bio);
+
+	if (bio) {
+		atomic_inc(&super->s_pending_writes);
+		submit_bio(WRITE, bio);
+	}
 	return 0;
 }
 
Signature · 1 line
1.9.1
author
#15 lore raw

PATCH 25/27 fs: logfs: remove unnecesary check

In reply to Ming Lei

The check on bio->bi_vcnt doesn't make sense in erase_end_io().

---
 fs/logfs/dev_bdev.c | 1 -
 1 file changed, 1 deletion(-)
fs/logfs/dev_bdev.c +0 -1
index db04231..3d9cde7 100644
@@ -144,7 +144,6 @@ static void erase_end_io(struct bio *bio)
 	struct logfs_super *super = logfs_super(sb); 
 
 	BUG_ON(bio->bi_error); /* FIXME: Retry io or write elsewhere */ 
-	BUG_ON(bio->bi_vcnt == 0); 
 	bio_put(bio); 
 	if (atomic_dec_and_test(&super->s_pending_writes))
 		wake_up(&wq); 
Signature · 1 line
1.9.1
author
#16 lore raw

PATCH 26/27 kernel/power/swap.c: use bio_get_base_vec()

In reply to Ming Lei
---
 kernel/power/swap.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)
kernel/power/swap.c +9 -1
index 12cd989..cedf752 100644
@@ -230,7 +230,15 @@ static void hib_init_batch(struct hib_bio_batch *hb)
 static void hib_end_io(struct bio *bio)
 {
 	struct hib_bio_batch *hb = bio->bi_private;
-	struct page *page = bio->bi_io_vec[0].bv_page;
+
+	/*
+	 * Single bvec bio.
+	 *
+	 * 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 page *page = bvec->bv_page;
 
 	if (bio->bi_error) {
 		printk(KERN_ALERT "Read-error on swap-device (%u:%u:%Lu)\n",
Signature · 1 line
1.9.1
#17 lore raw

Re: [PATCH 26/27] kernel/power/swap.c: use bio_get_base_vec()

I really don't like all these bio_get_base_vec uses. The end_io handlers generall want to iterate over all pages in the bio, with a special case where all of them is the fixed number one.

So What I think we'll need is a bio_for_each_page, and if there is any good justification for it as special version of the single page case.

author
#18 lore raw

Re: [PATCH 26/27] kernel/power/swap.c: use bio_get_base_vec()

Quoted 7 lines · Christoph Hellwig

I really don't like all these bio_get_base_vec uses. The end_io handlers generall want to iterate over all pages in the bio, with a special case where all of them is the fixed number one.

So What I think we'll need is a bio_for_each_page, and if there is any good justification for it as special version of the single page case.

I thought about that too, and bio_get_base_vec() can be thought as the special version too, IMO. Actually it is just about the name of the helper, do you have a better name or other idea for such issue?

There are about ten such usages, as found in this patchset.

Thanks,
Ming Lei

author
#19 lore raw

PATCH 27/27 mm: page_io.c: use bio_get_base_vec()

In reply to Ming Lei
---
 mm/page_io.c | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
mm/page_io.c +16 -2
index 18aac78..b5a6baf 100644
@@ -43,7 +43,14 @@ static struct bio *get_swap_bio(gfp_t gfp_flags,
 
 void end_swap_bio_write(struct bio *bio)
 {
-	struct page *page = bio->bi_io_vec[0].bv_page;
+	/*
+	 * Single bvec bio.
+	 *
+	 * 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 page *page = bvec->bv_page;
 
 	if (bio->bi_error) {
 		SetPageError(page);
@@ -116,7 +123,14 @@ static void swap_slot_free_notify(struct page *page)
 
 static void end_swap_bio_read(struct bio *bio)
 {
-	struct page *page = bio->bi_io_vec[0].bv_page;
+	/*
+	 * Single bvec bio.
+	 *
+	 * 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 page *page = bvec->bv_page;
 
 	if (bio->bi_error) {
 		SetPageError(page);
Signature · 7 lines
1.9.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>