Skip to content

block: cleanup direct access to .bi_vcnt & .bi_io_vec

Ming Lei dm-devel drbd-dev linux-bcache linux-mm linux-pm linux-raid linux-scsi lkml lustre-devel 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest27 patches 0 repliesNew

Changes in v1 from the cover letter

- add Reviewed-by
- remove bio_is_full() helper because target can find it via the return value of bio_add_pc_page() (9/27)
- add comment on another two uses of bio_get_base_vec() (16/27)
- rebased on latest for-next branch of block tree

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/27block: bio: introduce 3 helpers for cleanupinclude/linux/bio.h+21 -00 replies
2/27block: drbd: use bio_get_base_vec() to retrieve the 1st bvecdrivers/block/drbd/drbd_bitmap.c+3 -10 replies
3/27block: drbd: remove impossible failure handlingdrivers/block/drbd/drbd_receiver.c+1 -130 replies
4/27block: loop: use bio_get_base_vec() to retrive bvec tabledrivers/block/loop.c+3 -20 replies
5/27block: pktcdvd: use bio_get_base_vec() to retrive bvec tabledrivers/block/pktcdvd.c+2 -10 replies
6/27block: floppy: use bio_set_vec_table()drivers/block/floppy.c+1 -10 replies
7/27block: floppy: use bio_add_page()drivers/block/floppy.c+2 -50 replies
8/27staging: lustre: avoid to use bio->bi_vcnt directlydrivers/staging/lustre/lustre/llite/lloop.c+5 -40 replies
9/27target: avoid to access .bi_vcnt directlydrivers/target/target_core_pscsi.c+2 -60 replies
10/27bcache: debug: avoid to access .bi_io_vec directlydrivers/md/bcache/debug.c+8 -30 replies
11/27bcache: io.c: use bio_set_vec_tabledrivers/md/bcache/io.c+1 -20 replies
12/27bcache: journal.c: use bio_set_vec_table()drivers/md/bcache/journal.c+1 -20 replies
13/27bcache: movinggc: use bio_set_vec_table()drivers/md/bcache/movinggc.c+3 -30 replies
14/27bcache: writeback: use bio_set_vec_table()drivers/md/bcache/writeback.c+2 -20 replies
15/27bcache: super: use bio_set_vec_table()drivers/md/bcache/super.c+4 -60 replies
16/27bcache: super: use bio_get_base_vecdrivers/md/bcache/super.c+19 -40 replies
17/27dm: crypt: use bio_add_page()drivers/md/dm-crypt.c+1 -70 replies
18/27dm: dm-io.c: use bio_get_base_vec()drivers/md/dm-io.c+6 -10 replies
19/27dm: dm.c: replace 'bio->bi_vcnt == 1' with !bio_multiple_segmentsdrivers/md/dm.c+2 -10 replies
20/27dm: dm-bufio.c: use bio_set_vec_table()drivers/md/dm-bufio.c+1 -20 replies
21/27fs: logfs: use bio_set_vec_table()fs/logfs/dev_bdev.c+1 -20 replies
22/27fs: logfs: convert to bio_add_page() in sync_request()fs/logfs/dev_bdev.c+2 -50 replies
23/27fs: logfs: use bio_add_page() in __bdev_writeseg()fs/logfs/dev_bdev.c+21 -300 replies
24/27fs: logfs: use bio_add_page() in do_erase()fs/logfs/dev_bdev.c+18 -270 replies
25/27fs: logfs: remove unnecesary checkfs/logfs/dev_bdev.c+0 -10 replies
26/27kernel/power/swap.c: use bio_get_base_vec()kernel/power/swap.c+9 -10 replies
27/27mm: page_io.c: use bio_get_base_vec()mm/page_io.c+16 -20 replies

Reviews trailers per patch

4 of 27 patches have a Reviewed-by or Acked-by.

PatchGreg Kroah-HartmanChristoph HellwigLars Ellenberg
1/27
2/27
3/27A-b
4/27
5/27
6/27
7/27
8/27A-b
9/27
10/27
11/27
12/27
13/27
14/27
15/27
16/27
17/27R-b
18/27
19/27
20/27
21/27
22/27R-b
23/27
24/27
25/27
26/27
27/27

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH v1 00/27] block: cleanup direct access to .bi_vcnt & .bi_io_vec

Hi Guys,

It is always not a good practice to access bio->bi_vcnt and bio->bi_io_vec from drivers directly. Also this kind of direct access will cause trouble when converting to multipage bvecs because currently drivers may suppose one bvec always include one page, and use the two fields to figure out how to handle pages.

Even the actual meaning of the two fields arn't change from block subsystem's view, but it may change from driver or fs's view, so this patchset takes a conservative approach to cleanup direct access to the two fields for avoiding regressions.

The 1st patch introduces the following 3 bio helpers which can be used inside drivers for avoiding direct access to .bi_vcnt and .bi_io_vec.

        bio_pages()
        bio_get_base_vec()
        bio_set_vec_table()

bio_pages() can be easy to convert to multipage bvecs.

For bio_get_base_vec() and bio_set_vec_table(), they are often used during initializing a new bio or in case of single bvec bio. With the two new helpers, it becomes quite easy to audit access to .bi_io_vec and .bi_vcnt.

Most of the other patches use the 3 helpers to clean up most of direct access to .bi_vcnt and .bi_io_vec from drivers, except for MD and btrfs, which two subsystems will be handled with different way in future.

For btrfs, its direct access to .bi_vcnt & .bi_io_vec need to be cleanuped and audited that there isn't issue once converting to multipage bvecs.

For raid(md), given its usage is quite complicated, we can just not enable multipage bvecs for raid queue until all its usage are cleaned up and audited. So it won't be a blocker for multipage bvecs.

Also bio_add_page() is used in floppy, dm-crypt and fs/logfs to avoiding direct access to .bi_vcnt & .bi_io_vec.

The patchset can be found in the following tree:

https://github.com/ming1/linux/tree/v4.6-rc-block-next-mpbvecs-cleanup.v1

V1:
- add Reviewed-by
- remove bio_is_full() helper because target can find it via the return value of bio_add_pc_page() (9/27)
- add comment on another two uses of bio_get_base_vec() (16/27)
- rebased on latest for-next branch of block tree

Ming Lei (27):
block: bio: introduce 3 helpers for cleanup
block: drbd: use bio_get_base_vec() to retrieve the 1st bvec
block: drbd: remove impossible failure handling
block: loop: use bio_get_base_vec() to retrive bvec table
block: pktcdvd: use bio_get_base_vec() to retrive bvec table
block: floppy: use bio_set_vec_table()
block: floppy: use bio_add_page()
staging: lustre: avoid to use bio->bi_vcnt directly
target: avoid to access .bi_vcnt directly
bcache: debug: avoid to access .bi_io_vec directly
bcache: io.c: use bio_set_vec_table
bcache: journal.c: use bio_set_vec_table()
bcache: movinggc: use bio_set_vec_table()
bcache: writeback: use bio_set_vec_table()
bcache: super: use bio_set_vec_table()
bcache: super: use bio_get_base_vec
dm: crypt: use bio_add_page()
dm: dm-io.c: use bio_get_base_vec()
dm: dm.c: replace 'bio->bi_vcnt == 1' with !bio_multiple_segments
dm: dm-bufio.c: use bio_set_vec_table()
fs: logfs: use bio_set_vec_table()
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 kernel/power/swap.c: use bio_get_base_vec()
mm: page_io.c: use bio_get_base_vec()

 drivers/block/drbd/drbd_bitmap.c            |   4 +-
 drivers/block/drbd/drbd_receiver.c          |  14 +---
 drivers/block/floppy.c                      |   9 +--
 drivers/block/loop.c                        |   5 +-
 drivers/block/pktcdvd.c                     |   3 +-
 drivers/md/bcache/debug.c                   |  11 ++-
 drivers/md/bcache/io.c                      |   3 +-
 drivers/md/bcache/journal.c                 |   3 +-
 drivers/md/bcache/movinggc.c                |   6 +-
 drivers/md/bcache/super.c                   |  33 ++++++---
 drivers/md/bcache/writeback.c               |   4 +-
 drivers/md/dm-bufio.c                       |   3 +-
 drivers/md/dm-crypt.c                       |   8 +--
 drivers/md/dm-io.c                          |   7 +-
 drivers/md/dm.c                             |   3 +-
 drivers/staging/lustre/lustre/llite/lloop.c |   9 +--
 drivers/target/target_core_pscsi.c          |   8 +--
 fs/logfs/dev_bdev.c                         | 107 +++++++++++-----------------
 include/linux/bio.h                         |  21 ++++++
 kernel/power/swap.c                         |  10 ++-
 mm/page_io.c                                |  18 ++++-
 21 files changed, 155 insertions(+), 134 deletions(-)

Thanks,
Ming

Signature · 1 line
1.9.1