]> www.infradead.org Git - users/jedix/linux-maple.git/commit
btrfs: make extent_range_clear_dirty_for_io() to handle sector size < page size cases
authorQu Wenruo <wqu@suse.com>
Tue, 10 Sep 2024 06:42:57 +0000 (16:12 +0930)
committerDavid Sterba <dsterba@suse.com>
Mon, 11 Nov 2024 13:34:12 +0000 (14:34 +0100)
commita4ef54dbb576032ba31a646a5ffc8a26a83cb92c
tree609ff8ee2586d94d29eadf8a19e99cddfb314f7f
parenta8706d0271a8ef7d8d0916d78ab4821e9ccb7464
btrfs: make extent_range_clear_dirty_for_io() to handle sector size < page size cases

For btrfs with sector size < page size (e.g. 4K sector size, 64K page
size), and enable the sector perfect compression support, then the
following dirty range can lead to problems:

   0     32K     64K     96K    128K
   |     |///////||//////|    |/|
                              124K

In above case, if we start writeback for that inode, the last dirty
range [124K, 128K) will not be submitted and cause reserved space
leakage:

- Start writeback for page 0
  We find the range [32K, 96K) is suitable for compression, and queue it
  into a workqueue to do the delayed compression and submission.

- Compression happens for range [32K, 96K)
  Function extent_range_clear_dirty_for_io() is called, however it is
  only doing full page handling, not considering any the extra bitmaps
  for subpage cases.

  That function will clear page dirty for both page 0 and page 64K.

- Writeback for the inode is done
  Because page 64K has its dirty flag cleared, it will not be considered
  as a writeback target.

This means the range [124K, 128K) will not be submitted, and reserved
space for it will be leaked.

Fix this problem by using the subpage helper to clear the dirty flag.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/inode.c