Skip to content

btrfs: introduce btrfs_bio::async_csum

Qu Wenruo linux-btrfs 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest7 patches 17 repliesIn review
  2. v14 patches 8 repliesSuperseded

Changes in v2 from the cover letter

- Fix a race where csum generation can be completely skipped If the lower storage layer advanced the bi_iter before we finished calculating the checksum, bio_one_bio() may skip generating csum completely.

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7btrfs: replace BTRFS_MAX_BIO_SECTORS with BIO_MAX_VECSfs/btrfs/bio.h fs/btrfs/direct-io.c+1 -80 replies
2/7btrfs: headers cleanup to remove unnecessary local includesfs/btrfs/accessors.h fs/btrfs/btrfs_inode.h fs/btrfs/compression.h +18 more+21 -220 replies
3/7btrfs: remove btrfs_bio::fs_info by extracting it from btrfs_bio::inodefs/btrfs/bio.c fs/btrfs/bio.h fs/btrfs/compression.c +6 more+84 -800 replies
4/7btrfs: make sure all btrfs_bio::end_io is called in task contextfs/btrfs/bio.c+46 -180 replies
5/7btrfs: remove btrfs_fs_info::compressed_write_workersfs/btrfs/compression.c fs/btrfs/compression.h fs/btrfs/disk-io.c +1 more+12 -320 replies
6/7btrfs: relax btrfs_inode::ordered_tree_lockfs/btrfs/extent_io.c fs/btrfs/inode.c fs/btrfs/ordered-data.c +1 more+31 -390 replies
7/7btrfs: introduce btrfs_bio::async_csumfs/btrfs/bio.c fs/btrfs/bio.h fs/btrfs/file-item.c +1 more+69 -2516 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/7] btrfs: introduce btrfs_bio::async_csum

[CHANGELOG]
v2:
- Fix a race where csum generation can be completely skipped If the lower storage layer advanced the bi_iter before we finished calculating the checksum, bio_one_bio() may skip generating csum completely.

Unfortunately to solve this, a new bvec_iter must be introduced and cause the size of btrfs_bio to increase.

- Remove btrfs_bio::fs_info by always requireing btrfs_bio::inode For scrub, use btree inode instead, and for the only function that requires to be called by scrub, btrfs_submit_repair_write(), use a new member, btrfs_bio::is_scrub, to check the callers.

- Add a new patch to cleanup the recursive including problems The idea is to keep the btrfs headers inside .h files to minimal, thus lower risk of recursive including.

- Remove BTRFS_MAX_BIO_SECTORS macro
It's the same as BIO_MAX_VECS, and only utilized once.

The new async_csum feature will allow btrfs to calculate checksum for data write bios and submit them in parallel.

This will reduce latency and improve write throughput when data checksum is utilized.

This will slightly reclaim the performance drop after commit 968f19c5b1b7 ("btrfs: always fallback to buffered write if the inode requires checksum").

Patch 1 is a minor cleanup to remove a single-used macro. Patch 2 is a preparation to remove btrfs_bio::fs_info, the core is to avoid recursive including.
Patch 3 is to remove btrfs_bio::fs_info, as soon we will increase the size of btrfs_bio by 16 bytes.

Patch 4~6 are preparations to make sure btrfs_bio::end_io() is called in task context.

Patch 7 enables the async checksum generation for data writes, under experimental flags.

The series will increase btrfs_bio size by 8 bytes (+16 for the new structurs, -8 for the removal of btrfs_bio::fs_info).

Since the new async_csum should be better than the csum offload anyway, we may want to deprecate the csum offload feature completely in the future.
Thankfully csum offload feature is still behind the experimental flag, thus it should not affect end users.

Qu Wenruo (7):
btrfs: replace BTRFS_MAX_BIO_SECTORS with BIO_MAX_VECS
btrfs: headers cleanup to remove unnecessary local includes
btrfs: remove btrfs_bio::fs_info by extracting it from
btrfs_bio::inode
btrfs: make sure all btrfs_bio::end_io is called in task context
btrfs: remove btrfs_fs_info::compressed_write_workers
btrfs: relax btrfs_inode::ordered_tree_lock
btrfs: introduce btrfs_bio::async_csum

 fs/btrfs/accessors.h    |   1 +
 fs/btrfs/bio.c          | 136 ++++++++++++++++++++++++++--------------
 fs/btrfs/bio.h          |  32 ++++++----
 fs/btrfs/btrfs_inode.h  |   8 +--
 fs/btrfs/compression.c  |  33 +++-------
 fs/btrfs/compression.h  |  13 ++--
 fs/btrfs/ctree.h        |   2 -
 fs/btrfs/defrag.c       |   1 +
 fs/btrfs/dir-item.c     |   1 +
 fs/btrfs/direct-io.c    |   8 +--
 fs/btrfs/disk-io.c      |  10 +--
 fs/btrfs/disk-io.h      |   3 +-
 fs/btrfs/extent-tree.c  |   1 +
 fs/btrfs/extent_io.c    |  27 ++++----
 fs/btrfs/extent_io.h    |   1 -
 fs/btrfs/extent_map.h   |   3 +-
 fs/btrfs/file-item.c    |  64 +++++++++++++------
 fs/btrfs/file-item.h    |   4 +-
 fs/btrfs/fs.h           |   1 -
 fs/btrfs/inode.c        |  12 ++--
 fs/btrfs/ordered-data.c |  57 ++++++++---------
 fs/btrfs/scrub.c        |  49 ++++++++-------
 fs/btrfs/space-info.c   |   1 +
 fs/btrfs/subpage.h      |   1 -
 fs/btrfs/transaction.c  |   2 +
 fs/btrfs/transaction.h  |   4 --
 fs/btrfs/tree-log.c     |   5 +-
 fs/btrfs/tree-log.h     |   3 +-
 fs/btrfs/zoned.c        |   4 +-
 fs/btrfs/zoned.h        |   1 -
 30 files changed, 264 insertions(+), 224 deletions(-)
Signature · 1 line
2.51.0