Skip to content

block: support multipage bvec

Ming Lei cluster-devel dm-devel drbd-dev linux-bcache linux-block linux-btrfs linux-ext4 linux-f2fs-devel linux-fsdevel linux-mm linux-pm linux-raid linux-scsi linux-xfs lkml sparclinux 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest60 patches 47 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/60block: bio: introduce bio_init_with_vec_table()include/linux/bio.h+10 -01 reply
2/60block drivers: convert to bio_init_with_vec_table()drivers/block/floppy.c drivers/md/bcache/io.c drivers/md/bcache/journal.c +7 more+18 -400 replies
3/60block: drbd: remove impossible failure handlingdrivers/block/drbd/drbd_receiver.c+1 -131 reply
4/60block: floppy: use bio_add_page()drivers/block/floppy.c+2 -54 replies
5/60target: avoid to access .bi_vcnt directlydrivers/target/target_core_pscsi.c+2 -61 reply
6/60bcache: debug: avoid to access .bi_io_vec directlydrivers/md/bcache/debug.c+8 -30 replies
7/60dm: crypt: use bio_add_page()drivers/md/dm-crypt.c+1 -70 replies
8/60dm: use bvec iterator helpers to implement .get_page and .next_pagedrivers/md/dm-io.c+24 -100 replies
9/60dm: dm.c: replace 'bio->bi_vcnt == 1' with !bio_multiple_segmentsdrivers/md/dm-rq.c+2 -16 replies
10/60fs: logfs: convert to bio_add_page() in sync_request()fs/logfs/dev_bdev.c+2 -50 replies
11/60fs: logfs: use bio_add_page() in __bdev_writeseg()fs/logfs/dev_bdev.c+20 -311 reply
12/60fs: logfs: use bio_add_page() in do_erase()fs/logfs/dev_bdev.c+15 -291 reply
13/60fs: logfs: remove unnecesary checkfs/logfs/dev_bdev.c+0 -11 reply
14/60block: drbd: comment on direct access bvec tabledrivers/block/drbd/drbd_bitmap.c+1 -00 replies
15/60block: loop: comment on direct access to bvec tabledrivers/block/loop.c+5 -02 replies
16/60block: pktcdvd: comment on direct access to bvec tabledrivers/block/pktcdvd.c+5 -02 replies
17/60kernel/power/swap.c: comment on direct access to bvec tablekernel/power/swap.c+2 -00 replies
18/60mm: page_io.c: comment on direct access to bvec tablemm/page_io.c+1 -00 replies
19/60fs/buffer: comment on direct access to bvec tablefs/buffer.c+6 -12 replies
20/60f2fs: f2fs_read_end_io: comment on direct access to bvec tablefs/f2fs/data.c+4 -00 replies
21/60bcache: comment on direct access to bvec tabledrivers/md/bcache/btree.c drivers/md/bcache/super.c drivers/md/bcache/util.c+14 -00 replies
22/60block: comment on bio_alloc_pages()block/bio.c drivers/md/bcache/debug.c+9 -10 replies
23/60block: introduce flag QUEUE_FLAG_NO_MPinclude/linux/blkdev.h+2 -02 replies
24/60md: set NO_MP for request queue of mddrivers/md/md.c+12 -00 replies
25/60block: pktcdvd: set NO_MP for pktcdvd request queuedrivers/block/pktcdvd.c+3 -00 replies
26/60btrfs: set NO_MP for request queues behind BTRFSfs/btrfs/volumes.c+3 -03 replies
27/60block: introduce BIO_SP_MAX_SECTORSinclude/linux/bio.h+3 -00 replies
28/60block: introduce QUEUE_FLAG_SPLIT_MPblock/blk-merge.c include/linux/blkdev.h+6 -07 replies
29/60dm: limit the max bio size as BIO_SP_MAX_SECTORS << SECTOR_SHIFTdrivers/md/dm.c+10 -10 replies
30/60bcache: set flag of QUEUE_FLAG_SPLIT_MPdrivers/md/bcache/super.c+6 -00 replies
31/60block: introduce multipage/single page bvec helpersinclude/linux/bvec.h+54 -30 replies
32/60block: implement sp version of bvec iterator helpersinclude/linux/bvec.h+14 -31 reply
33/60block: introduce bio_for_each_segment_mp()include/linux/bio.h include/linux/bvec.h+65 -100 replies
34/60block: introduce bio_clone_sp()block/bio.c include/linux/bio.h+59 -100 replies
35/60bvec_iter: introduce BVEC_ITER_ALL_INITinclude/linux/bvec.h+8 -00 replies
36/60block: bounce: avoid direct access to bvec from bio->bi_io_vecblock/bounce.c+7 -50 replies
37/60block: bounce: don't access bio->bi_io_vec in copy_to_high_bio_irqblock/bounce.c+11 -50 replies
38/60block: bounce: convert multipage bvecs into singlepageblock/bounce.c+38 -80 replies
39/60bcache: debug: switch to bio_clone_sp()drivers/md/bcache/debug.c+3 -50 replies
40/60blk-merge: compute bio->bi_seg_front_size efficientlyblock/blk-merge.c+5 -40 replies
41/60block: blk-merge: try to make front segments in full sizeblock/blk-merge.c+39 -50 replies
42/60block: use bio_for_each_segment_mp() to compute segments countblock/blk-merge.c+75 -140 replies
43/60block: use bio_for_each_segment_mp() to map sgblock/blk-merge.c+52 -200 replies
44/60block: introduce bvec_for_each_sp_bvec()include/linux/bvec.h+10 -00 replies
45/60block: bio: introduce bio_for_each_segment_all_rd() and its write pairinclude/linux/bio.h include/linux/blk_types.h+21 -08 replies
46/60block: deal with dirtying pages for multipage bvecblock/bio.c+36 -72 replies
47/60block: convert to bio_for_each_segment_all_rd()block/bio.c block/bounce.c+15 -80 replies
48/60fs/mpage: convert to bio_for_each_segment_all_rd()fs/mpage.c+2 -10 replies
49/60fs/direct-io: convert to bio_for_each_segment_all_rd()fs/direct-io.c+3 -10 replies
50/60ext4: convert to bio_for_each_segment_all_rd()fs/ext4/page-io.c fs/ext4/readpage.c+4 -20 replies
51/60xfs: convert to bio_for_each_segment_all_rd()fs/xfs/xfs_aops.c+2 -10 replies
52/60logfs: convert to bio_for_each_segment_all_rd()fs/logfs/dev_bdev.c+2 -10 replies
53/60gfs2: convert to bio_for_each_segment_all_rd()fs/gfs2/lops.c fs/gfs2/meta_io.c+4 -20 replies
54/60f2fs: convert to bio_for_each_segment_all_rd()fs/f2fs/data.c+6 -30 replies
55/60exofs: convert to bio_for_each_segment_all_rd()fs/exofs/ore.c fs/exofs/ore_raid.c+4 -20 replies
56/60fs: crypto: convert to bio_for_each_segment_all_rd()fs/crypto/crypto.c+2 -10 replies
57/60bcache: convert to bio_for_each_segment_all_rd()drivers/md/bcache/btree.c+2 -10 replies
58/60dm-crypt: convert to bio_for_each_segment_all_rd()drivers/md/dm-crypt.c+2 -10 replies
59/60fs/buffer.c: use bvec iterator to truncate the biofs/buffer.c+13 -80 replies
60/60block: enable multipage bvecsblock/bio.c+13 -00 replies

Reviews trailers per patch

7 of 60 patches have a Reviewed-by or Acked-by.

PatchLars EllenbergChristoph Hellwig
1/60
2/60
3/60A-b R-b
4/60
5/60R-b
6/60
7/60R-b
8/60
9/60
10/60R-b
11/60R-b
12/60R-b
13/60R-b
14/60
15/60
16/60
17/60
18/60
19/60
20/60
21/60
22/60
23/60
24/60
25/60
26/60
27/60
28/60
29/60
30/60
31/60
32/60
33/60
34/60
35/60
36/60
37/60
38/60
39/60
40/60
41/60
42/60
43/60
44/60
45/60
46/60
47/60
48/60
49/60
50/60
51/60
52/60
53/60
54/60
55/60
56/60
57/60
58/60
59/60
60/60

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/60] block: support multipage bvec

Hi,

This patchset brings multipage bvec into block layer. Basic xfstests(-a auto) over virtio-blk/virtio-scsi have been run and no regression is found, so it should be good enough to show the approach now, and any comments are welcome!

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 inside fs/block stack. 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'.

Also huge pages are being brought to filesystem[2], we can do IO a hugepage a time[3], 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]. Multipage bvec can fit in this case very well.

With multipage bvec:

- 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 possibility in future to improve memory footprint of bvecs usage.

3) how is multipage bvec implemented in this patchset?

The 1st 22 patches cleanup on direct access to bvec table, and comments on some special cases. With this approach, most of cases are found as safe for multipage bvec, only fs/buffer, pktcdvd, dm-io, MD and btrfs need to deal with.

Given a little more work is involved to cleanup pktcdvd, MD and btrfs, this patchset introduces QUEUE_FLAG_NO_MP for them, and these components can still see/use singlepage bvec. In the future, once the cleanup is done, the flag can be killed.

The 2nd part(23 ~ 60) implements multipage bvec in block:

- 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

- 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_rd() and bio_for_each_segment_all_wt()) are introduced.

- bio_clone() changes
At default bio_clone still clones one new bio in multipage bvec way. Also single page version of bio_clone() is introduced for some special cases, such as only single page bvec is used for the new cloned bio(bio bounce, ...)

These patches can be found in the following git tree:

	https://github.com/ming1/linux/tree/mp-bvec-0.3-v4.9

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.

TODO:
- cleanup direct access to bvec table for MD & btrfs

[1], http://marc.info/?l=linux-kernel&m=141680246629547&w=2
[2], http://lwn.net/Articles/700781/
[3], http://marc.info/?t=147735447100001&r=1&w=2
[4], http://marc.info/?l=linux-mm&m=147745525801433&w=2

Ming Lei (60):
block: bio: introduce bio_init_with_vec_table()
block drivers: convert to bio_init_with_vec_table()
block: drbd: remove impossible failure handling
block: floppy: use bio_add_page()
target: avoid to access .bi_vcnt directly
bcache: debug: avoid to access .bi_io_vec directly
dm: crypt: use bio_add_page()
dm: use bvec iterator helpers to implement .get_page and .next_page
dm: dm.c: replace 'bio->bi_vcnt == 1' with !bio_multiple_segments
fs: logfs: convert to bio_add_page() in sync_request()
fs: logfs: use bio_add_page() in __bdev_writeseg()
fs: logfs: use bio_add_page() in do_erase()
fs: logfs: remove unnecesary check
block: drbd: comment on direct access bvec table
block: loop: comment on direct access to bvec table
block: pktcdvd: 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: introduce flag QUEUE_FLAG_NO_MP
md: set NO_MP for request queue of md
block: pktcdvd: set NO_MP for pktcdvd request queue
btrfs: set NO_MP for request queues behind BTRFS
block: introduce BIO_SP_MAX_SECTORS
block: introduce QUEUE_FLAG_SPLIT_MP
dm: limit the max bio size as BIO_SP_MAX_SECTORS << SECTOR_SHIFT
bcache: set flag of QUEUE_FLAG_SPLIT_MP
block: introduce multipage/single page bvec helpers
block: implement sp version of bvec iterator helpers
block: introduce bio_for_each_segment_mp()
block: introduce bio_clone_sp()
bvec_iter: introduce BVEC_ITER_ALL_INIT
block: bounce: avoid direct access to bvec from bio->bi_io_vec
block: bounce: don't access bio->bi_io_vec in copy_to_high_bio_irq
block: bounce: convert multipage bvecs into singlepage
bcache: debug: switch to bio_clone_sp()
blk-merge: compute bio->bi_seg_front_size efficiently
block: blk-merge: try to make front segments in full size
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 bio_for_each_segment_all_rd() and its write pair
block: deal with dirtying pages for multipage bvec
block: convert to bio_for_each_segment_all_rd()
fs/mpage: convert to bio_for_each_segment_all_rd() fs/direct-io: convert to bio_for_each_segment_all_rd()
ext4: convert to bio_for_each_segment_all_rd()
xfs: convert to bio_for_each_segment_all_rd()
logfs: convert to bio_for_each_segment_all_rd()
gfs2: convert to bio_for_each_segment_all_rd()
f2fs: convert to bio_for_each_segment_all_rd()
exofs: convert to bio_for_each_segment_all_rd()
fs: crypto: convert to bio_for_each_segment_all_rd()
bcache: convert to bio_for_each_segment_all_rd()
dm-crypt: convert to bio_for_each_segment_all_rd() fs/buffer.c: use bvec iterator to truncate the bio
block: enable multipage bvecs

 block/bio.c                        | 104 ++++++++++++++----
 block/blk-merge.c                  | 216 +++++++++++++++++++++++++++++--------
 block/bounce.c                     |  80 ++++++++++----
 drivers/block/drbd/drbd_bitmap.c   |   1 +
 drivers/block/drbd/drbd_receiver.c |  14 +--
 drivers/block/floppy.c             |  10 +-
 drivers/block/loop.c               |   5 +
 drivers/block/pktcdvd.c            |   8 ++
 drivers/md/bcache/btree.c          |   4 +-
 drivers/md/bcache/debug.c          |  19 +++-
 drivers/md/bcache/io.c             |   4 +-
 drivers/md/bcache/journal.c        |   4 +-
 drivers/md/bcache/movinggc.c       |   7 +-
 drivers/md/bcache/super.c          |  25 +++--
 drivers/md/bcache/util.c           |   7 ++
 drivers/md/bcache/writeback.c      |   6 +-
 drivers/md/dm-bufio.c              |   4 +-
 drivers/md/dm-crypt.c              |  11 +-
 drivers/md/dm-io.c                 |  34 ++++--
 drivers/md/dm-rq.c                 |   3 +-
 drivers/md/dm.c                    |  11 +-
 drivers/md/md.c                    |  12 +++
 drivers/md/raid5.c                 |   9 +-
 drivers/nvme/target/io-cmd.c       |   4 +-
 drivers/target/target_core_pscsi.c |   8 +-
 fs/btrfs/volumes.c                 |   3 +
 fs/buffer.c                        |  24 +++--
 fs/crypto/crypto.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/logfs/dev_bdev.c                | 110 +++++++------------
 fs/mpage.c                         |   3 +-
 fs/xfs/xfs_aops.c                  |   3 +-
 include/linux/bio.h                | 108 +++++++++++++++++--
 include/linux/blk_types.h          |   6 ++
 include/linux/blkdev.h             |   4 +
 include/linux/bvec.h               | 123 +++++++++++++++++++--
 kernel/power/swap.c                |   2 +
 mm/page_io.c                       |   1 +
 45 files changed, 759 insertions(+), 276 deletions(-)
Signature · 1 line
2.7.4