]> git.ipfire.org Git - thirdparty/linux.git/commit
btrfs: subpage: make reader lock utilize bitmap
authorQu Wenruo <wqu@suse.com>
Sat, 17 Feb 2024 06:29:49 +0000 (16:59 +1030)
committerDavid Sterba <dsterba@suse.com>
Tue, 5 Mar 2024 16:13:23 +0000 (17:13 +0100)
commit8e7e9c672fd810a099dc2ac92a80e8e95cd5b0dc
tree60a6f6d218ebc78fea0016aae795d72bffb40bbc
parent621b9ff18c009ed6512df93b63fcf7dbac4cb4e0
btrfs: subpage: make reader lock utilize bitmap

Currently btrfs_subpage utilizes its atomic member @reader to manage the
reader counter.  However it is only utilized to prevent the page to be
released/unlocked when we still have reads underway.

In that use case, we don't really allow multiple readers on the same
subpage sector.  So here we can introduce a new locked bitmap to
represent exactly which subpage range is locked for read.

In theory we can remove btrfs_subpage::reader as it's just the set bits
of the new locked bitmap.  But unfortunately bitmap doesn't provide such
handy API yet, so we still keep the reader counter.

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
fs/btrfs/subpage.h