Skip to content

RFC btrfs: experimental compression support for subpage

Qu Wenruo linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest8 patches 5 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8btrfs: don't pass compressed pages to btrfs_writepage_endio_finish_ordered()fs/btrfs/inode.c+1 -40 replies
2/8btrfs: make btrfs_subpage_end_and_test_writer() to handle pages not locked by btrfs_page_start_writer_lock()fs/btrfs/subpage.c+23 -10 replies
3/8btrfs: make compress_file_range() to be subpage compatiblefs/btrfs/inode.c+1 -10 replies
4/8btrfs: make btrfs_submit_compressed_write() to be subpage compatiblefs/btrfs/compression.c+2 -10 replies
5/8btrfs: use async_chunk::async_cow to replace the confusing pending pointerfs/btrfs/inode.c+7 -90 replies
6/8btrfs: make end_compressed_bio_writeback() to be subpage compatblefs/btrfs/compression.c+4 -10 replies
7/8btrfs: make extent_write_locked_range() to be subpage compatiblefs/btrfs/extent_io.c+5 -21 reply
8/8btrfs: only allow subpage compression if the range fully covers the first pagefs/btrfs/inode.c+23 -30 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/8] btrfs: experimental compression support for subpage

This patchset is based on my previously submitted compression refactor, which is further based on subpage patchset.

It can be fetched from the following repo:
https://github.com/adam900710/linux/tree/compression

It only has been lightly tested, no stress test/full fstests run yet. The reason for such a unstable patchset is to get feedback on how to continue the development, aka the feedback for the last patch.

The first 7 patches are mostly cleanups to make compression path to be more subpage compatible.

The RFC is for the last patch, which will enable subpage compression in a pretty controversial way.

The reason is copied from that patch:

```
This mechanism allows btrfs to continue handling next ranges, without
waiting for the time consuming compression.

But this has a problem for subpage case, as we could have the following
delalloc range for a page:

0		32K		64K
|	|///////|	|///////|
		\- A		\- B

In above case, if we pass both range to cow_file_range_async(), both
range A and range B will try to unlock the full page [0, 64K).

And which finishes later than the other range will try to do other page
operatioins like end_page_writeback() on a unlocked page, triggering VM
layer BUG_ON().

Currently I don't have any perfect solution to this, but two
workarounds:

- Only allow compression for fully page aligned range

  This is what I did in this patch.
  By this, the compressed range can exclusively lock the first page
  (and other pages), so they are completely safe to do whatever they
  want.
  The problem is, we will not compress a lot of small writes.
  This is especially problematic as our target page size is 64K, not
  a small size.

- Make cow_file_range_async() to behave like cow_file_range() for
  subpage

  This needs several behavier change, and are all subpage specific:
  * Skip the first page of the range when finished
    Just like cow_file_range()
  * Have a way to wait for the async_cow to finish before handling the
    next delalloc range

  The biggest problem here is the performance impact.
  Although by this we can compress all sector aligned ranges, we will
  waste time waiting for the async_cow to finish.
  This is completely denying the meaning of "async" part.
  Now to mention there are tons of code needs to be changed.

Thus I choose the current way to only compress ranges which is fully
page aligned.
The cost is we will skip a lot of small writes for 64K page size.
```

Any feedback on this part would be pretty helpful.

Qu Wenruo (8):
btrfs: don't pass compressed pages to
btrfs_writepage_endio_finish_ordered()
btrfs: make btrfs_subpage_end_and_test_writer() to handle pages not
locked by btrfs_page_start_writer_lock()
btrfs: make compress_file_range() to be subpage compatible
btrfs: make btrfs_submit_compressed_write() to be subpage compatible
btrfs: use async_chunk::async_cow to replace the confusing pending
pointer
btrfs: make end_compressed_bio_writeback() to be subpage compatble
btrfs: make extent_write_locked_range() to be subpage compatible
btrfs: only allow subpage compression if the range fully covers the
first page

 fs/btrfs/compression.c |  8 +++++--
 fs/btrfs/extent_io.c   |  7 ++++--
 fs/btrfs/inode.c       | 49 +++++++++++++++++++++++++++---------------
 fs/btrfs/subpage.c     | 24 ++++++++++++++++++++-
 4 files changed, 66 insertions(+), 22 deletions(-)
Signature · 1 line
2.32.0