]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
btrfs: subpage: simplify the PAGECACHE_TAG_TOWRITE handling
authorQu Wenruo <wqu@suse.com>
Tue, 21 Oct 2025 03:51:48 +0000 (14:21 +1030)
committerDavid Sterba <dsterba@suse.com>
Mon, 24 Nov 2025 21:03:38 +0000 (22:03 +0100)
commit988f693a46d83dc832005a1403ae0471eb1f8964
treea2e72d5aafa7419debc7b2beacb4de0c01f853b1
parentca428e9b49c77b0bfc6ebbc8536ed854463b26e2
btrfs: subpage: simplify the PAGECACHE_TAG_TOWRITE handling

In function btrfs_subpage_set_writeback() we need to keep the
PAGECACHE_TAG_TOWRITE tag if the folio is still dirty.

This is a needed quirk for support async extents, as a subpage range can
almost suddenly go writeback, without touching other subpage ranges in
the same folio.

However we can simplify the handling by replace the open-coded tag
clearing by passing the @keep_write flag depending on if the folio is
dirty.

Since we're holding the subpage lock already, no one is able to change
the dirty/writeback flag, thus it's safe to check the folio dirty before
calling __folio_start_writeback().

Reviewed-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/subpage.c