Skip to content

RFC btrfs: remove folio ordered flag

Qu Wenruo linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest4 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4btrfs: unify folio dirty flag clearingfs/btrfs/extent_io.c fs/btrfs/extent_io.h fs/btrfs/inode.c+26 -130 replies
2/4btrfs: use dirty flag to check if an ordered extent needs to be truncatedfs/btrfs/inode.c+13 -80 replies
3/4btrfs: remove folio_test_ordered() usagefs/btrfs/extent_io.c fs/btrfs/inode.c fs/btrfs/ordered-data.h+17 -140 replies
4/4btrfs: remove folio ordered flag and subpage bitmapfs/btrfs/extent_io.c fs/btrfs/extent_io.h fs/btrfs/fs.h +3 more+7 -920 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/4] btrfs: remove folio ordered flag

Btrfs has a long history using an internal folio flag called ordered, which is to indicate if an fs block is covered by an ordered extent.

However this means we need to synchronize between ordered extents, which are managed by a per-inode ordered tree, and folio flag/subpage bitmap.

Furthermore with huge folio support, the ordered bitmap can be as large as 64 bytes (512 bits), which is not a small amount.

The series is going to remove folio ordered flag completely, along with the ordered subpage bitmap.

Most call sites of folio_test_ordered() are just inside ASSERT()s, so it's not too hard to remove them.

But there is a special call site inside btrfs_invalidate_folio() where we use ordered flag to check if we can skip an ordered extent. This is worked around by using the fact that we have waited for writeback of the folio, so that endio should have already finished for the writeback range. Then check dirty flags to determine if we can skip the OE range.

To get a reliable dirty flag for both sub-folio and full-folio cases, we can not clear the folio dirty flag early, so the first patch is introduced to change the folio dirty flag clearing timing, then the second patch can remove the folio_test_ordered() usage.

Then the third patch is to remove the remaining folio_test_ordered() usage, and finally we can remove the whole ordered flag/subpage bitmap completely.

[REASON FOR RFC]
I'm not sure if we should remove the folio ordered flag completely, or keep it an internal debug feature for a while.

The main concern is that we're removing quite some ASSERT()s, some are never hit, but at least one is very useful and had triggered several times during development, exposing bugs.

In the long run, we will eventually remove the folio ordered flag/subpage bitmap so that we can align btrfs_folio_state with iomap_folio_state, so ordered flags should still be gone eventually.

Another point of concern is the new btrfs_ordered_extent_in_range() helper for extent_writepage_io().
Previously we're just doing a folio flag check, now we have to do an rbtree search.
I hope the overhead is not that huge.

Qu Wenruo (4):
btrfs: unify folio dirty flag clearing
btrfs: use dirty flag to check if an ordered extent needs to be
truncated
btrfs: remove folio_test_ordered() usage
btrfs: remove folio ordered flag and subpage bitmap

 fs/btrfs/extent_io.c    | 35 ++++++++++--------------
 fs/btrfs/extent_io.h    | 12 ++++++++-
 fs/btrfs/fs.h           |  8 ------
 fs/btrfs/inode.c        | 60 ++++++++++-------------------------------
 fs/btrfs/ordered-data.h | 16 +++++++++++
 fs/btrfs/subpage.c      | 41 ++--------------------------
 fs/btrfs/subpage.h      | 12 +++------
 7 files changed, 60 insertions(+), 124 deletions(-)
Signature · 1 line
2.54.0