Skip to content

RFC btrfs: refactor how we handle btrfs_io_context and slightly reduce memory usage for both btrfs_bio and btrfs_io_context

Qu Wenruo linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest3 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3btrfs: add btrfs_bio::bioc pointer for further modificationfs/btrfs/volumes.c fs/btrfs/volumes.h+5 -50 replies
2/3btrfs: remove redundant parameters for submit_stripe_bio()fs/btrfs/volumes.c+6 -40 replies
3/3btrfs: replace btrfs_bio::device member with stripe_numfs/btrfs/compression.c fs/btrfs/ctree.h fs/btrfs/extent_io.c +4 more+42 -150 replies

Reviews trailers per patch

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

Read the v1 thread

Cover letter [PATCH RFC 0/3] btrfs: refactor how we handle btrfs_io_context and slightly reduce memory usage for both btrfs_bio and btrfs_io_context

Currently btrfs_io_context is utilized as both bio->bi_private for mirrored stripes, and stripes mapping for RAID56.

This makes some members like btrfs_io_context::private to be there.

But in fact, since almost all bios in btrfs have btrfs_bio structure appended, we don't really need to reuse bio::bi_private for mirrored profiles.

So this patchset will:

- Introduce btrfs_bio::bioc member
So that btrfs_io_context don't need to hold @private. This modification is still a net increase for memory usage, just a trade-off between btrfs_io_context and btrfs_bio.

- Replace btrfs_bio::device with btrfs_bio::stripe_num This reclaim the memory usage increase for btrfs_bio.

But unfortunately, due to the short life time of btrfs_io_context, we don't have as good device status accounting as the old code.

Now for csum error, we can no longer distinguish source and target device of dev-replace.

This is the biggest blockage, and that's why it's RFC.

The result of the patchset is:

btrfs_bio: size: 240 -> 240
btrfs_io_context: size: 88 -> 80

Although to really reduce btrfs_bio, the main target should be csum_inline.

Qu Wenruo (3):
btrfs: add btrfs_bio::bioc pointer for further modification
btrfs: remove redundant parameters for submit_stripe_bio()
btrfs: replace btrfs_bio::device member with stripe_num

 fs/btrfs/compression.c |  6 ++----
 fs/btrfs/ctree.h       |  2 ++
 fs/btrfs/extent_io.c   |  2 --
 fs/btrfs/inode.c       | 30 +++++++++++++++++++++++++++---
 fs/btrfs/raid56.c      |  1 -
 fs/btrfs/volumes.c     | 23 +++++++++++++----------
 fs/btrfs/volumes.h     | 11 ++++++++---
 7 files changed, 52 insertions(+), 23 deletions(-)
Signature · 1 line
2.33.0