Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1706169 > unrolled thread
| Started by | Ming Lei <ming.lei@redhat.com> |
|---|---|
| First post | 2017-08-08 10:50 +0200 |
| Last post | 2017-08-10 13:20 +0200 |
| Articles | 20 on this page of 61 — 5 participants |
Back to article view | Back to linux.kernel
[PATCH v3 00/49] block: support multipage bvec Ming Lei <ming.lei@redhat.com> - 2017-08-08 10:50 +0200
[PATCH v3 10/49] dm: limit the max bio size as BIO_MAX_PAGES * PAGE_SIZE Ming Lei <ming.lei@redhat.com> - 2017-08-08 10:50 +0200
Re: [PATCH v3 10/49] dm: limit the max bio size as BIO_MAX_PAGES * PAGE_SIZE Christoph Hellwig <hch@infradead.org> - 2017-08-10 13:30 +0200
[PATCH v3 13/49] btrfs: comment on direct access bvec table Ming Lei <ming.lei@redhat.com> - 2017-08-08 10:50 +0200
[PATCH v3 08/49] block: comment on bio_alloc_pages() Ming Lei <ming.lei@redhat.com> - 2017-08-08 10:50 +0200
[PATCH v3 09/49] block: comment on bio_iov_iter_get_pages() Ming Lei <ming.lei@redhat.com> - 2017-08-08 10:50 +0200
Re: [PATCH v3 09/49] block: comment on bio_iov_iter_get_pages() Christoph Hellwig <hch@infradead.org> - 2017-08-10 13:30 +0200
[PATCH v3 07/49] bcache: comment on direct access to bvec table Ming Lei <ming.lei@redhat.com> - 2017-08-08 10:50 +0200
Re: [PATCH v3 07/49] bcache: comment on direct access to bvec table Coly Li <i@coly.li> - 2017-08-08 14:40 +0200
Re: [PATCH v3 07/49] bcache: comment on direct access to bvec table Christoph Hellwig <hch@infradead.org> - 2017-08-10 13:30 +0200
[PATCH v3 05/49] fs/buffer: comment on direct access to bvec table Ming Lei <ming.lei@redhat.com> - 2017-08-08 10:50 +0200
Re: [PATCH v3 05/49] fs/buffer: comment on direct access to bvec table Christoph Hellwig <hch@infradead.org> - 2017-08-10 13:20 +0200
[PATCH v3 12/49] btrfs: avoid to access bvec table directly for a cloned bio Ming Lei <ming.lei@redhat.com> - 2017-08-08 10:50 +0200
[PATCH v3 03/49] kernel/power/swap.c: comment on direct access to bvec table Ming Lei <ming.lei@redhat.com> - 2017-08-08 10:50 +0200
[PATCH v3 02/49] block: loop: comment on direct access to bvec table Ming Lei <ming.lei@redhat.com> - 2017-08-08 10:50 +0200
[PATCH v3 16/49] block: bounce: don't access bio->bi_io_vec in copy_to_high_bio_irq Ming Lei <ming.lei@redhat.com> - 2017-08-08 10:50 +0200
[PATCH v3 15/49] bvec_iter: introduce BVEC_ITER_ALL_INIT Ming Lei <ming.lei@redhat.com> - 2017-08-08 10:50 +0200
[PATCH v3 41/49] xfs: convert to bio_for_each_segment_all_sp() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
Re: [PATCH v3 41/49] xfs: convert to bio_for_each_segment_all_sp() "Darrick J. Wong" <darrick.wong@oracle.com> - 2017-08-08 18:40 +0200
[PATCH v3 48/49] block: enable multipage bvecs Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 33/49] bcache: convert to bio_for_each_segment_all_sp() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
Re: [PATCH v3 33/49] bcache: convert to bio_for_each_segment_all_sp() Coly Li <i@coly.li> - 2017-08-08 14:40 +0200
[PATCH v3 49/49] block: bio: pass segments to bio if bio_add_page() is bypassed Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 25/49] block: use bio_for_each_segment_mp() to map sg Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 37/49] fs/mpage: convert to bio_for_each_segment_all_sp() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
Re: [PATCH v3 37/49] fs/mpage: convert to bio_for_each_segment_all_sp() Christoph Hellwig <hch@infradead.org> - 2017-08-10 14:20 +0200
[PATCH v3 28/49] block: introduce bvec_get_last_page() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 34/49] md: raid1: convert to bio_for_each_segment_all_sp() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 26/49] block: introduce bvec_for_each_sp_bvec() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 44/49] exofs: convert to bio_for_each_segment_all_sp() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 35/49] dm-crypt: don't clear bvec->bv_page in crypt_free_buffer_pages() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 42/49] gfs2: convert to bio_for_each_segment_all_sp() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 32/49] block: convert to singe/multi page version of bio_for_each_segment_all() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 39/49] fs/iomap: convert to bio_for_each_segment_all_sp() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 29/49] fs/buffer.c: use bvec iterator to truncate the bio Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 21/49] blk-merge: compute bio->bi_seg_front_size efficiently Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
Re: [PATCH v3 21/49] blk-merge: compute bio->bi_seg_front_size efficiently Christoph Hellwig <hch@infradead.org> - 2017-08-10 14:30 +0200
[PATCH v3 24/49] block: use bio_for_each_segment_mp() to compute segments count Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 43/49] f2fs: convert to bio_for_each_segment_all_sp() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 23/49] block: blk-merge: remove unnecessary check Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
Re: [PATCH v3 23/49] block: blk-merge: remove unnecessary check Christoph Hellwig <hch@infradead.org> - 2017-08-10 14:20 +0200
[PATCH v3 27/49] block: bio: introduce single/multi page version of bio_for_each_segment_all() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 46/49] fs/btrfs: convert to bio_for_each_segment_all_sp() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
Re: [PATCH v3 46/49] fs/btrfs: convert to bio_for_each_segment_all_sp() Filipe Manana <fdmanana@gmail.com> - 2017-08-08 11:10 +0200
[PATCH v3 38/49] fs/block: convert to bio_for_each_segment_all_sp() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 18/49] block: introduce multipage/single page bvec helpers Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
Re: [PATCH v3 18/49] block: introduce multipage/single page bvec helpers Christoph Hellwig <hch@infradead.org> - 2017-08-10 14:10 +0200
[PATCH v3 47/49] fs/direct-io: convert to bio_for_each_segment_all_sp() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 31/49] block: deal with dirtying pages for multipage bvec Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 20/49] block: introduce bio_for_each_segment_mp() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
Re: [PATCH v3 20/49] block: introduce bio_for_each_segment_mp() Christoph Hellwig <hch@infradead.org> - 2017-08-10 14:30 +0200
[PATCH v3 45/49] fs: crypto: convert to bio_for_each_segment_all_sp() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 40/49] ext4: convert to bio_for_each_segment_all_sp() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 22/49] block: blk-merge: try to make front segments in full size Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
Re: [PATCH v3 22/49] block: blk-merge: try to make front segments in full size Christoph Hellwig <hch@infradead.org> - 2017-08-10 14:30 +0200
[PATCH v3 30/49] btrfs: use bvec_get_last_page to get bio's last page Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 36/49] dm-crypt: convert to bio_for_each_segment_all_sp() Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
[PATCH v3 19/49] block: implement sp version of bvec iterator helpers Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:00 +0200
Re: [PATCH v3 19/49] block: implement sp version of bvec iterator helpers Christoph Hellwig <hch@infradead.org> - 2017-08-10 14:10 +0200
[PATCH v3 04/49] mm: page_io.c: comment on direct access to bvec table Ming Lei <ming.lei@redhat.com> - 2017-08-08 11:10 +0200
Re: [PATCH v3 04/49] mm: page_io.c: comment on direct access to bvec table Christoph Hellwig <hch@infradead.org> - 2017-08-10 13:20 +0200
Page 1 of 4 [1] 2 3 4 Next page →
| From | Ming Lei <ming.lei@redhat.com> |
|---|---|
| Date | 2017-08-08 10:50 +0200 |
| Subject | [PATCH v3 00/49] block: support multipage bvec |
| Message-ID | <uc8n7-5sU-3@gated-at.bofh.it> |
Hi,
This patchset brings multipage bvec into block layer:
1) what is multipage bvec?
Multipage bvecs means that one 'struct bio_bvec' can hold
multiple pages which are physically contiguous instead
of one single page used in linux kernel for long time.
2) why is multipage bvec introduced?
Kent proposed the idea[1] first.
As system's RAM becomes much bigger than before, and
at the same time huge page, transparent huge page and
memory compaction are widely used, it is a bit easy now
to see physically contiguous pages from fs in I/O.
On the other hand, from block layer's view, it isn't
necessary to store intermediate pages into bvec, and
it is enough to just store the physicallly contiguous
'segment' in each io vector.
Also huge pages are being brought to filesystem and swap
[2][6], we can do IO on a hugepage each time[3], which
requires that one bio can transfer at least one huge page
one time. Turns out it isn't flexiable to change BIO_MAX_PAGES
simply[3][5]. Multipage bvec can fit in this case very well.
With multipage bvec:
- segment handling in block layer can be improved much
in future since it should be quite easy to convert
multipage bvec into segment easily. For example, we might
just store segment in each bvec directly in future.
- bio size can be increased and it should improve some
high-bandwidth IO case in theory[4].
- Inside block layer, both bio splitting and sg map can
become more efficient than before by just traversing the
physically contiguous 'segment' instead of each page.
- there is opportunity in future to improve memory footprint
of bvecs.
3) how is multipage bvec implemented in this patchset?
The 1st 17 patches comment on some special cases and deal with
some special cases of direct access to bvec table.
The 2nd part(18~29) implements multipage bvec in block layer:
- put all tricks into bvec/bio/rq iterators, and as far as
drivers and fs use these standard iterators, they are happy
with multipage bvec
- use multipage bvec to split bio and map sg
- bio_for_each_segment_all() changes
this helper pass pointer of each bvec directly to user, and
it has to be changed. Two new helpers(bio_for_each_segment_all_sp()
and bio_for_each_segment_all_mp()) are introduced.
The 3rd part(32~47) convert current users of bio_for_each_segment_all()
to bio_for_each_segment_all_sp()/bio_for_each_segment_all_mp().
The last part(48~49) enables multipage bvec.
These patches can be found in the following git tree:
https://github.com/ming1/linux/commits/v4.13-rc3-block-next-mp-bvec-V3
Thanks Christoph for looking at the early version and providing
very good suggestions, such as: introduce bio_init_with_vec_table(),
remove another unnecessary helpers for cleanup and so on.
Any comments are welcome!
BTW, I will be on a trip in the following week, so may not reply
in time.
V3:
- rebase on v4.13-rc3 with for-next of block tree
- run more xfstests: xfs/ext4 over NVMe, Sata, DM(linear),
MD(raid1), and not see regressions triggered
- add Reviewed-by on some btrfs patches
- remove two MD patches because both are merged to linus tree
already
V2:
- bvec table direct access in raid has been cleaned, so NO_MP
flag is dropped
- rebase on recent Neil Brown's change on bio and bounce code
- reorganize the patchset
V1:
- against v4.10-rc1 and some cleanup in V0 are in -linus already
- handle queue_virt_boundary() in mp bvec change and make NVMe happy
- further BTRFS cleanup
- remove QUEUE_FLAG_SPLIT_MP
- rename for two new helpers of bio_for_each_segment_all()
- fix bounce convertion
- address comments in V0
[1], http://marc.info/?l=linux-kernel&m=141680246629547&w=2
[2], https://patchwork.kernel.org/patch/9451523/
[3], http://marc.info/?t=147735447100001&r=1&w=2
[4], http://marc.info/?l=linux-mm&m=147745525801433&w=2
[5], http://marc.info/?t=149569484500007&r=1&w=2
[6], http://marc.info/?t=149820215300004&r=1&w=2
Ming Lei (49):
block: drbd: comment on direct access bvec table
block: loop: comment on direct access to bvec table
kernel/power/swap.c: comment on direct access to bvec table
mm: page_io.c: comment on direct access to bvec table
fs/buffer: comment on direct access to bvec table
f2fs: f2fs_read_end_io: comment on direct access to bvec table
bcache: comment on direct access to bvec table
block: comment on bio_alloc_pages()
block: comment on bio_iov_iter_get_pages()
dm: limit the max bio size as BIO_MAX_PAGES * PAGE_SIZE
btrfs: avoid access to .bi_vcnt directly
btrfs: avoid to access bvec table directly for a cloned bio
btrfs: comment on direct access bvec table
block: bounce: avoid direct access to bvec table
bvec_iter: introduce BVEC_ITER_ALL_INIT
block: bounce: don't access bio->bi_io_vec in copy_to_high_bio_irq
block: comments on bio_for_each_segment[_all]
block: introduce multipage/single page bvec helpers
block: implement sp version of bvec iterator helpers
block: introduce bio_for_each_segment_mp()
blk-merge: compute bio->bi_seg_front_size efficiently
block: blk-merge: try to make front segments in full size
block: blk-merge: remove unnecessary check
block: use bio_for_each_segment_mp() to compute segments count
block: use bio_for_each_segment_mp() to map sg
block: introduce bvec_for_each_sp_bvec()
block: bio: introduce single/multi page version of
bio_for_each_segment_all()
block: introduce bvec_get_last_page()
fs/buffer.c: use bvec iterator to truncate the bio
btrfs: use bvec_get_last_page to get bio's last page
block: deal with dirtying pages for multipage bvec
block: convert to singe/multi page version of
bio_for_each_segment_all()
bcache: convert to bio_for_each_segment_all_sp()
md: raid1: convert to bio_for_each_segment_all_sp()
dm-crypt: don't clear bvec->bv_page in crypt_free_buffer_pages()
dm-crypt: convert to bio_for_each_segment_all_sp()
fs/mpage: convert to bio_for_each_segment_all_sp()
fs/block: convert to bio_for_each_segment_all_sp()
fs/iomap: convert to bio_for_each_segment_all_sp()
ext4: convert to bio_for_each_segment_all_sp()
xfs: convert to bio_for_each_segment_all_sp()
gfs2: convert to bio_for_each_segment_all_sp()
f2fs: convert to bio_for_each_segment_all_sp()
exofs: convert to bio_for_each_segment_all_sp()
fs: crypto: convert to bio_for_each_segment_all_sp()
fs/btrfs: convert to bio_for_each_segment_all_sp()
fs/direct-io: convert to bio_for_each_segment_all_sp()
block: enable multipage bvecs
block: bio: pass segments to bio if bio_add_page() is bypassed
block/bio.c | 137 ++++++++++++++++++++----
block/blk-merge.c | 226 +++++++++++++++++++++++++++++++--------
block/blk-zoned.c | 5 +-
block/bounce.c | 39 ++++---
drivers/block/drbd/drbd_bitmap.c | 1 +
drivers/block/loop.c | 5 +
drivers/md/bcache/btree.c | 4 +-
drivers/md/bcache/super.c | 6 ++
drivers/md/bcache/util.c | 7 ++
drivers/md/dm-crypt.c | 4 +-
drivers/md/dm.c | 11 +-
drivers/md/raid1.c | 3 +-
fs/block_dev.c | 6 +-
fs/btrfs/compression.c | 12 ++-
fs/btrfs/disk-io.c | 3 +-
fs/btrfs/extent_io.c | 38 +++++--
fs/btrfs/extent_io.h | 2 +-
fs/btrfs/inode.c | 22 +++-
fs/btrfs/raid56.c | 1 +
fs/buffer.c | 11 +-
fs/crypto/bio.c | 3 +-
fs/direct-io.c | 4 +-
fs/exofs/ore.c | 3 +-
fs/exofs/ore_raid.c | 3 +-
fs/ext4/page-io.c | 3 +-
fs/ext4/readpage.c | 3 +-
fs/f2fs/data.c | 13 ++-
fs/gfs2/lops.c | 3 +-
fs/gfs2/meta_io.c | 3 +-
fs/iomap.c | 3 +-
fs/mpage.c | 3 +-
fs/xfs/xfs_aops.c | 3 +-
include/linux/bio.h | 67 +++++++++++-
include/linux/blk_types.h | 6 ++
include/linux/bvec.h | 141 ++++++++++++++++++++++--
kernel/power/swap.c | 2 +
mm/page_io.c | 2 +
37 files changed, 674 insertions(+), 134 deletions(-)
--
2.9.4
[toc] | [next] | [standalone]
| From | Ming Lei <ming.lei@redhat.com> |
|---|---|
| Date | 2017-08-08 10:50 +0200 |
| Subject | [PATCH v3 10/49] dm: limit the max bio size as BIO_MAX_PAGES * PAGE_SIZE |
| Message-ID | <uc8n8-5sU-19@gated-at.bofh.it> |
| In reply to | #1706169 |
For BIO based DM, some targets aren't ready for dealing with bigger incoming bio than 1Mbyte, such as crypt target. Cc: Mike Snitzer <snitzer@redhat.com> Cc:dm-devel@redhat.com Signed-off-by: Ming Lei <ming.lei@redhat.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 2edbcc2d7d3f..631348699fb8 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -922,7 +922,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.9.4
[toc] | [prev] | [next] | [standalone]
| From | Christoph Hellwig <hch@infradead.org> |
|---|---|
| Date | 2017-08-10 13:30 +0200 |
| Subject | Re: [PATCH v3 10/49] dm: limit the max bio size as BIO_MAX_PAGES * PAGE_SIZE |
| Message-ID | <ucTP3-4V8-5@gated-at.bofh.it> |
| In reply to | #1706170 |
> + ti->max_io_len = min_t(uint32_t, len, > + (BIO_MAX_PAGES * PAGE_SIZE)); No need for the inner braces. Also all of the above fits nicely onto a single < 80 char line. Otherwise this looks fine: Reviewed-by: Christoph Hellwig <hch@lst.de>
[toc] | [prev] | [next] | [standalone]
| From | Ming Lei <ming.lei@redhat.com> |
|---|---|
| Date | 2017-08-08 10:50 +0200 |
| Subject | [PATCH v3 13/49] btrfs: comment on direct access bvec table |
| Message-ID | <uc8n9-5sU-27@gated-at.bofh.it> |
| In reply to | #1706169 |
Cc: Chris Mason <clm@fb.com> Cc: Josef Bacik <jbacik@fb.com> Cc: David Sterba <dsterba@suse.com> Cc: linux-btrfs@vger.kernel.org Acked: David Sterba <dsterba@suse.com> Signed-off-by: Ming Lei <ming.lei@redhat.com> --- fs/btrfs/compression.c | 4 ++++ fs/btrfs/inode.c | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index d2ef9ac2a630..f795d0a6d176 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -542,6 +542,10 @@ blk_status_t btrfs_submit_compressed_read(struct inode *inode, struct bio *bio, /* we need the actual starting offset of this extent in the file */ read_lock(&em_tree->lock); + /* + * It is still safe to retrieve the 1st page of the bio + * in this way after supporting multipage bvec. + */ em = lookup_extent_mapping(em_tree, page_offset(bio->bi_io_vec->bv_page), PAGE_SIZE); diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 5cf320ee7ea0..084ed99dd308 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -8051,6 +8051,12 @@ static void btrfs_retry_endio_nocsum(struct bio *bio) if (bio->bi_status) goto end; + /* + * WARNING: + * + * With multipage bvec, the following way of direct access to + * bvec table is only safe if the bio includes single page. + */ ASSERT(bio->bi_vcnt == 1); io_tree = &BTRFS_I(inode)->io_tree; failure_tree = &BTRFS_I(inode)->io_failure_tree; @@ -8143,6 +8149,12 @@ static void btrfs_retry_endio(struct bio *bio) uptodate = 1; + /* + * WARNING: + * + * With multipage bvec, the following way of direct access to + * bvec table is only safe if the bio includes single page. + */ ASSERT(bio->bi_vcnt == 1); ASSERT(bio->bi_io_vec->bv_len == btrfs_inode_sectorsize(done->inode)); -- 2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Ming Lei <ming.lei@redhat.com> |
|---|---|
| Date | 2017-08-08 10:50 +0200 |
| Subject | [PATCH v3 08/49] block: comment on bio_alloc_pages() |
| Message-ID | <uc8n9-5sU-29@gated-at.bofh.it> |
| In reply to | #1706169 |
This patch adds comment on usage of bio_alloc_pages(). Signed-off-by: Ming Lei <ming.lei@redhat.com> --- block/bio.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/bio.c b/block/bio.c index e241bbc49f14..826b5d173416 100644 --- a/block/bio.c +++ b/block/bio.c @@ -981,7 +981,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. -- 2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Ming Lei <ming.lei@redhat.com> |
|---|---|
| Date | 2017-08-08 10:50 +0200 |
| Subject | [PATCH v3 09/49] block: comment on bio_iov_iter_get_pages() |
| Message-ID | <uc8n9-5sU-31@gated-at.bofh.it> |
| In reply to | #1706169 |
bio_iov_iter_get_pages() used unused bvec spaces for
storing page pointer array temporarily, and this patch
comments on this usage wrt. multipage bvec support.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/bio.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/block/bio.c b/block/bio.c
index 826b5d173416..28697e3c8ce3 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -875,6 +875,10 @@ EXPORT_SYMBOL(bio_add_page);
*
* Pins as many pages from *iter and appends them to @bio's bvec array. The
* pages will have to be released using put_page() when done.
+ *
+ * The hacking way of using bvec table as page pointer array is safe
+ * even after multipage bvec is introduced because that space can be
+ * thought as unused by bio_add_page().
*/
int bio_iov_iter_get_pages(struct bio *bio, struct iov_iter *iter)
{
--
2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Christoph Hellwig <hch@infradead.org> |
|---|---|
| Date | 2017-08-10 13:30 +0200 |
| Subject | Re: [PATCH v3 09/49] block: comment on bio_iov_iter_get_pages() |
| Message-ID | <ucTP4-4V8-11@gated-at.bofh.it> |
| In reply to | #1706174 |
> + * The hacking way of using bvec table as page pointer array is safe > + * even after multipage bvec is introduced because that space can be > + * thought as unused by bio_add_page(). I'm not sure what value this comment adds. Note that once we have multi-page biovecs this could should change to take advantage of multipage biovecs, so adding a comment before that doesn't seem too helpful.
[toc] | [prev] | [next] | [standalone]
| From | Ming Lei <ming.lei@redhat.com> |
|---|---|
| Date | 2017-08-08 10:50 +0200 |
| Subject | [PATCH v3 07/49] bcache: comment on direct access to bvec table |
| Message-ID | <uc8n9-5sU-33@gated-at.bofh.it> |
| In reply to | #1706169 |
Looks all are safe after multipage bvec is supported.
Cc: linux-bcache@vger.kernel.org
Signed-off-by: Ming Lei <ming.lei@redhat.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 866dcf78ff8e..3da595ae565b 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -431,6 +431,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 8352fad765f6..6808f548cd13 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;
@@ -1154,6 +1155,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 8c3a938f4bf0..11b4230ea6ad 100644
--- a/drivers/md/bcache/util.c
+++ b/drivers/md/bcache/util.c
@@ -223,6 +223,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.9.4
[toc] | [prev] | [next] | [standalone]
| From | Coly Li <i@coly.li> |
|---|---|
| Date | 2017-08-08 14:40 +0200 |
| Subject | Re: [PATCH v3 07/49] bcache: comment on direct access to bvec table |
| Message-ID | <ucbXH-8or-1@gated-at.bofh.it> |
| In reply to | #1706175 |
On 2017/8/8 下午4:45, Ming Lei wrote:
> Looks all are safe after multipage bvec is supported.
>
> Cc: linux-bcache@vger.kernel.org
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
Acked-by: Coly Li <colyli@suse.de>
Coly Li
> ---
> 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 866dcf78ff8e..3da595ae565b 100644
> --- a/drivers/md/bcache/btree.c
> +++ b/drivers/md/bcache/btree.c
> @@ -431,6 +431,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 8352fad765f6..6808f548cd13 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;
>
> @@ -1154,6 +1155,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 8c3a938f4bf0..11b4230ea6ad 100644
> --- a/drivers/md/bcache/util.c
> +++ b/drivers/md/bcache/util.c
> @@ -223,6 +223,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;
>
[toc] | [prev] | [next] | [standalone]
| From | Christoph Hellwig <hch@infradead.org> |
|---|---|
| Date | 2017-08-10 13:30 +0200 |
| Subject | Re: [PATCH v3 07/49] bcache: comment on direct access to bvec table |
| Message-ID | <ucTP4-4V8-23@gated-at.bofh.it> |
| In reply to | #1706175 |
I think all this bcache code needs bigger attention. For one
bio_alloc_pages is only used in bcache, so we should move it in there.
Second the way bio_alloc_pages is currently written looks potentially
dangerous for multi-page biovecs, so we should think about a better
calling convention. The way bcache seems to generally use it is by
allocating a bio, then calling bch_bio_map on it and then calling
bio_alloc_pages. I think it just needs a new bio_alloc_pages calling
convention that passes the size to be allocated and stop looking into
the segment count.
Second bch_bio_map isn't something we should be doing in a driver,
it should be rewritten using bio_add_page.
> diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
> index 866dcf78ff8e..3da595ae565b 100644
> --- a/drivers/md/bcache/btree.c
> +++ b/drivers/md/bcache/btree.c
> @@ -431,6 +431,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;
This should go away - bio_alloc_pages or it's replacement should not
modify bi_vcnt on failure.
> + /* single page bio, safe for multipage bvec */
> dc->sb_bio.bi_io_vec[0].bv_page = sb_page;
needs to use bio_add_page.
> + /* single page bio, safe for multipage bvec */
> ca->sb_bio.bi_io_vec[0].bv_page = sb_page;
needs to use bio_add_page.
[toc] | [prev] | [next] | [standalone]
| From | Ming Lei <ming.lei@redhat.com> |
|---|---|
| Date | 2017-08-08 10:50 +0200 |
| Subject | [PATCH v3 05/49] fs/buffer: comment on direct access to bvec table |
| Message-ID | <uc8n9-5sU-39@gated-at.bofh.it> |
| In reply to | #1706169 |
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
fs/buffer.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/fs/buffer.c b/fs/buffer.c
index 5715dac7821f..c821ed6a6f0e 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -3054,8 +3054,13 @@ static void end_bio_bh_io_sync(struct bio *bio)
void guard_bio_eod(int op, struct bio *bio)
{
sector_t maxsector;
- struct bio_vec *bvec = &bio->bi_io_vec[bio->bi_vcnt - 1];
unsigned truncated_bytes;
+ /*
+ * It is safe to truncate the last bvec in the following way
+ * even though multipage bvec is supported, but we need to
+ * fix the parameters passed to zero_user().
+ */
+ struct bio_vec *bvec = &bio->bi_io_vec[bio->bi_vcnt - 1];
maxsector = i_size_read(bio->bi_bdev->bd_inode) >> 9;
if (!maxsector)
--
2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Christoph Hellwig <hch@infradead.org> |
|---|---|
| Date | 2017-08-10 13:20 +0200 |
| Subject | Re: [PATCH v3 05/49] fs/buffer: comment on direct access to bvec table |
| Message-ID | <ucTFn-4RQ-3@gated-at.bofh.it> |
| In reply to | #1706177 |
> + /* > + * It is safe to truncate the last bvec in the following way > + * even though multipage bvec is supported, but we need to > + * fix the parameters passed to zero_user(). > + */ > + struct bio_vec *bvec = &bio->bi_io_vec[bio->bi_vcnt - 1]; A 'we need to fix XXX' comment isn't very useful. Just fix it in the series (which I suspect you're going to do anyway). Also a bio_last_vec helper might be nice for something like this and documents properly converted places much better than these comments.
[toc] | [prev] | [next] | [standalone]
| From | Ming Lei <ming.lei@redhat.com> |
|---|---|
| Date | 2017-08-08 10:50 +0200 |
| Subject | [PATCH v3 12/49] btrfs: avoid to access bvec table directly for a cloned bio |
| Message-ID | <uc8n9-5sU-41@gated-at.bofh.it> |
| In reply to | #1706169 |
Commit 17347cec15f919901c90(Btrfs: change how we iterate bios in endio) mentioned that for dio the submitted bio may be fast cloned, we can't access the bvec table directly for a cloned bio, so use bio_get_first_bvec() to retrieve the 1st bvec. Cc: Chris Mason <clm@fb.com> Cc: Josef Bacik <jbacik@fb.com> Cc: David Sterba <dsterba@suse.com> Cc: linux-btrfs@vger.kernel.org Cc: Liu Bo <bo.li.liu@oracle.com> Reviewed-by: Liu Bo <bo.li.liu@oracle.com> Acked: David Sterba <dsterba@suse.com> Signed-off-by: Ming Lei <ming.lei@redhat.com> --- fs/btrfs/inode.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 95c212037095..5cf320ee7ea0 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -7993,6 +7993,7 @@ static int dio_read_error(struct inode *inode, struct bio *failed_bio, int read_mode = 0; int segs; int ret; + struct bio_vec bvec; BUG_ON(bio_op(failed_bio) == REQ_OP_WRITE); @@ -8008,8 +8009,9 @@ static int dio_read_error(struct inode *inode, struct bio *failed_bio, } segs = bio_segments(failed_bio); + bio_get_first_bvec(failed_bio, &bvec); if (segs > 1 || - (failed_bio->bi_io_vec->bv_len > btrfs_inode_sectorsize(inode))) + (bvec.bv_len > btrfs_inode_sectorsize(inode))) read_mode |= REQ_FAILFAST_DEV; isector = start - btrfs_io_bio(failed_bio)->logical; -- 2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Ming Lei <ming.lei@redhat.com> |
|---|---|
| Date | 2017-08-08 10:50 +0200 |
| Subject | [PATCH v3 03/49] kernel/power/swap.c: comment on direct access to bvec table |
| Message-ID | <uc8n9-5sU-43@gated-at.bofh.it> |
| In reply to | #1706169 |
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: linux-pm@vger.kernel.org
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
kernel/power/swap.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 57d22571f306..aa52ccc03fcc 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -238,6 +238,8 @@ 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;
+
+ /* single page bio, safe for multipage bvec */
struct page *page = bio->bi_io_vec[0].bv_page;
if (bio->bi_status) {
--
2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Ming Lei <ming.lei@redhat.com> |
|---|---|
| Date | 2017-08-08 10:50 +0200 |
| Subject | [PATCH v3 02/49] block: loop: comment on direct access to bvec table |
| Message-ID | <uc8na-5sU-51@gated-at.bofh.it> |
| In reply to | #1706169 |
Signed-off-by: Ming Lei <ming.lei@redhat.com> --- drivers/block/loop.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/block/loop.c b/drivers/block/loop.c index ef8334949b42..58df9ed70328 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c @@ -487,6 +487,11 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, /* nomerge for loop request queue */ WARN_ON(cmd->rq->bio != cmd->rq->biotail); + /* + * For multipage bvec support, it is safe to pass the bvec + * table to iov iterator, because iov iter still uses bvec + * iter helpers to travese bvec. + */ bvec = __bvec_iter_bvec(bio->bi_io_vec, bio->bi_iter); iov_iter_bvec(&iter, ITER_BVEC | rw, bvec, bio_segments(bio), blk_rq_bytes(cmd->rq)); -- 2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Ming Lei <ming.lei@redhat.com> |
|---|---|
| Date | 2017-08-08 10:50 +0200 |
| Subject | [PATCH v3 16/49] block: bounce: don't access bio->bi_io_vec in copy_to_high_bio_irq |
| Message-ID | <uc8n9-5sU-49@gated-at.bofh.it> |
| In reply to | #1706169 |
As we need to support multipage bvecs, so don't access bio->bi_io_vec
in copy_to_high_bio_irq(), and just use the standard iterator
to do that.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/bounce.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/block/bounce.c b/block/bounce.c
index e57cf2bdcd27..50e965a15295 100644
--- a/block/bounce.c
+++ b/block/bounce.c
@@ -112,24 +112,30 @@ int init_emergency_isa_pool(void)
static void copy_to_high_bio_irq(struct bio *to, struct bio *from)
{
unsigned char *vfrom;
- struct bio_vec tovec, *fromvec = from->bi_io_vec;
+ struct bio_vec tovec, fromvec;
struct bvec_iter iter;
+ /*
+ * The bio of @from is created by bounce, so we can iterate
+ * its bvec from start to end, but the @from->bi_iter can't be
+ * trusted because it might be changed by splitting.
+ */
+ struct bvec_iter from_iter = BVEC_ITER_ALL_INIT;
bio_for_each_segment(tovec, to, iter) {
- if (tovec.bv_page != fromvec->bv_page) {
+ fromvec = bio_iter_iovec(from, from_iter);
+ if (tovec.bv_page != fromvec.bv_page) {
/*
* fromvec->bv_offset and fromvec->bv_len might have
* been modified by the block layer, so use the original
* copy, bounce_copy_vec already uses tovec->bv_len
*/
- vfrom = page_address(fromvec->bv_page) +
+ vfrom = page_address(fromvec.bv_page) +
tovec.bv_offset;
bounce_copy_vec(&tovec, vfrom);
flush_dcache_page(tovec.bv_page);
}
-
- fromvec++;
+ bio_advance_iter(from, &from_iter, tovec.bv_len);
}
}
--
2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Ming Lei <ming.lei@redhat.com> |
|---|---|
| Date | 2017-08-08 10:50 +0200 |
| Subject | [PATCH v3 15/49] bvec_iter: introduce BVEC_ITER_ALL_INIT |
| Message-ID | <uc8n9-5sU-47@gated-at.bofh.it> |
| In reply to | #1706169 |
Introduce BVEC_ITER_ALL_INIT for iterating one bio
from start to end.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
include/linux/bvec.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/include/linux/bvec.h b/include/linux/bvec.h
index ec8a4d7af6bd..fe7a22dd133b 100644
--- a/include/linux/bvec.h
+++ b/include/linux/bvec.h
@@ -125,4 +125,13 @@ static inline bool bvec_iter_rewind(const struct bio_vec *bv,
((bvl = bvec_iter_bvec((bio_vec), (iter))), 1); \
bvec_iter_advance((bio_vec), &(iter), (bvl).bv_len))
+/* for iterating one bio from start to end */
+#define BVEC_ITER_ALL_INIT (struct bvec_iter) \
+{ \
+ .bi_sector = 0, \
+ .bi_size = UINT_MAX, \
+ .bi_idx = 0, \
+ .bi_bvec_done = 0, \
+}
+
#endif /* __LINUX_BVEC_ITER_H */
--
2.9.4
[toc] | [prev] | [next] | [standalone]
| From | Ming Lei <ming.lei@redhat.com> |
|---|---|
| Date | 2017-08-08 11:00 +0200 |
| Subject | [PATCH v3 41/49] xfs: convert to bio_for_each_segment_all_sp() |
| Message-ID | <uc8wN-5yr-1@gated-at.bofh.it> |
| In reply to | #1706169 |
Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
fs/xfs/xfs_aops.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
index 6bf120bb1a17..94df43dcae0b 100644
--- a/fs/xfs/xfs_aops.c
+++ b/fs/xfs/xfs_aops.c
@@ -139,6 +139,7 @@ xfs_destroy_ioend(
for (bio = &ioend->io_inline_bio; bio; bio = next) {
struct bio_vec *bvec;
int i;
+ struct bvec_iter_all bia;
/*
* For the last bio, bi_private points to the ioend, so we
@@ -150,7 +151,7 @@ xfs_destroy_ioend(
next = bio->bi_private;
/* walk each page on bio, ending page IO on them */
- bio_for_each_segment_all(bvec, bio, i)
+ bio_for_each_segment_all_sp(bvec, bio, i, bia)
xfs_finish_page_writeback(inode, bvec, error);
bio_put(bio);
--
2.9.4
[toc] | [prev] | [next] | [standalone]
| From | "Darrick J. Wong" <darrick.wong@oracle.com> |
|---|---|
| Date | 2017-08-08 18:40 +0200 |
| Subject | Re: [PATCH v3 41/49] xfs: convert to bio_for_each_segment_all_sp() |
| Message-ID | <ucfHY-2yd-41@gated-at.bofh.it> |
| In reply to | #1706186 |
On Tue, Aug 08, 2017 at 04:45:40PM +0800, Ming Lei wrote:
Sure would be nice to have a changelog explaining why we're doing this.
> Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
> Cc: linux-xfs@vger.kernel.org
> Signed-off-by: Ming Lei <ming.lei@redhat.com>
> ---
> fs/xfs/xfs_aops.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/fs/xfs/xfs_aops.c b/fs/xfs/xfs_aops.c
> index 6bf120bb1a17..94df43dcae0b 100644
> --- a/fs/xfs/xfs_aops.c
> +++ b/fs/xfs/xfs_aops.c
> @@ -139,6 +139,7 @@ xfs_destroy_ioend(
> for (bio = &ioend->io_inline_bio; bio; bio = next) {
> struct bio_vec *bvec;
> int i;
> + struct bvec_iter_all bia;
>
> /*
> * For the last bio, bi_private points to the ioend, so we
> @@ -150,7 +151,7 @@ xfs_destroy_ioend(
> next = bio->bi_private;
>
> /* walk each page on bio, ending page IO on them */
> - bio_for_each_segment_all(bvec, bio, i)
> + bio_for_each_segment_all_sp(bvec, bio, i, bia)
It's confusing that you're splitting the old bio_for_each_segment_all
into multipage and singlepage variants, but bio_for_each_segment_all
continues to exist?
Hmm, the new multipage variant aliases the name bio_for_each_segment_all,
so clearly the _all function's sematics have changed a bit, but its name
and signature haven't, which seems likely to trip up someone who didn't
notice the behavioral change.
Is it still valid to call bio_for_each_segment_all? I get the feeling
from this patchset that you're really supposed to decide whether you
want one page at a time or more than one page at a time and choose _sp
or _mp?
(And, seeing how this was the only patch sent to this list, the chances
are higher of someone missing out on these subtle changes...)
--D
> xfs_finish_page_writeback(inode, bvec, error);
>
> bio_put(bio);
> --
> 2.9.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
[toc] | [prev] | [next] | [standalone]
| From | Ming Lei <ming.lei@redhat.com> |
|---|---|
| Date | 2017-08-08 11:00 +0200 |
| Subject | [PATCH v3 48/49] block: enable multipage bvecs |
| Message-ID | <uc8wN-5yr-3@gated-at.bofh.it> |
| In reply to | #1706169 |
This patch pulls the trigger for multipage bvecs.
Now any request queue which supports queue cluster
will see multipage bvecs.
Signed-off-by: Ming Lei <ming.lei@redhat.com>
---
block/bio.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/block/bio.c b/block/bio.c
index fd6a055f491c..a5f7fd4ef818 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -844,6 +844,11 @@ int bio_add_page(struct bio *bio, struct page *page,
* a consecutive offset. Optimize this special case.
*/
if (bio->bi_vcnt > 0) {
+ struct request_queue *q = NULL;
+
+ if (bio->bi_bdev)
+ q = bdev_get_queue(bio->bi_bdev);
+
bv = &bio->bi_io_vec[bio->bi_vcnt - 1];
if (page == bv->bv_page &&
@@ -851,6 +856,14 @@ int bio_add_page(struct bio *bio, struct page *page,
bv->bv_len += len;
goto done;
}
+
+ /* disable multipage bvec too if cluster isn't enabled */
+ if (q && blk_queue_cluster(q) &&
+ (bvec_to_phys(bv) + bv->bv_len ==
+ page_to_phys(page) + offset)) {
+ bv->bv_len += len;
+ goto done;
+ }
}
if (bio->bi_vcnt >= bio->bi_max_vecs)
--
2.9.4
[toc] | [prev] | [next] | [standalone]
Page 1 of 4 [1] 2 3 4 Next page →
Back to top | Article view | linux.kernel
csiph-web