mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-24 11:25:43 +00:00
btrfs: fix a compilation error if DEBUG is defined in btree_dirty_folio
commit5e0e879926
upstream. [BUG] After commit72a69cd030
("btrfs: subpage: pack all subpage bitmaps into a larger bitmap"), the DEBUG section of btree_dirty_folio() would no longer compile. [CAUSE] If DEBUG is defined, we would do extra checks for btree_dirty_folio(), mostly to make sure the range we marked dirty has an extent buffer and that extent buffer is dirty. For subpage, we need to iterate through all the extent buffers covered by that page range, and make sure they all matches the criteria. However commit72a69cd030
("btrfs: subpage: pack all subpage bitmaps into a larger bitmap") changes how we store the bitmap, we pack all the 16 bits bitmaps into a larger bitmap, which would save some space. This means we no longer have btrfs_subpage::dirty_bitmap, instead the dirty bitmap is starting at btrfs_subpage_info::dirty_offset, and has a length of btrfs_subpage_info::bitmap_nr_bits. [FIX] Although I'm not sure if it still makes sense to maintain such code, at least let it compile. This patch would let us test the bits one by one through the bitmaps. CC: stable@vger.kernel.org # 6.1+ Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
32247b9526
commit
52932bbc6d
1 changed files with 8 additions and 6 deletions
|
@ -859,6 +859,7 @@ static bool btree_dirty_folio(struct address_space *mapping,
|
||||||
struct folio *folio)
|
struct folio *folio)
|
||||||
{
|
{
|
||||||
struct btrfs_fs_info *fs_info = btrfs_sb(mapping->host->i_sb);
|
struct btrfs_fs_info *fs_info = btrfs_sb(mapping->host->i_sb);
|
||||||
|
struct btrfs_subpage_info *spi = fs_info->subpage_info;
|
||||||
struct btrfs_subpage *subpage;
|
struct btrfs_subpage *subpage;
|
||||||
struct extent_buffer *eb;
|
struct extent_buffer *eb;
|
||||||
int cur_bit = 0;
|
int cur_bit = 0;
|
||||||
|
@ -872,18 +873,19 @@ static bool btree_dirty_folio(struct address_space *mapping,
|
||||||
btrfs_assert_tree_write_locked(eb);
|
btrfs_assert_tree_write_locked(eb);
|
||||||
return filemap_dirty_folio(mapping, folio);
|
return filemap_dirty_folio(mapping, folio);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ASSERT(spi);
|
||||||
subpage = folio_get_private(folio);
|
subpage = folio_get_private(folio);
|
||||||
|
|
||||||
ASSERT(subpage->dirty_bitmap);
|
for (cur_bit = spi->dirty_offset;
|
||||||
while (cur_bit < BTRFS_SUBPAGE_BITMAP_SIZE) {
|
cur_bit < spi->dirty_offset + spi->bitmap_nr_bits;
|
||||||
|
cur_bit++) {
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
u64 cur;
|
u64 cur;
|
||||||
u16 tmp = (1 << cur_bit);
|
|
||||||
|
|
||||||
spin_lock_irqsave(&subpage->lock, flags);
|
spin_lock_irqsave(&subpage->lock, flags);
|
||||||
if (!(tmp & subpage->dirty_bitmap)) {
|
if (!test_bit(cur_bit, subpage->bitmaps)) {
|
||||||
spin_unlock_irqrestore(&subpage->lock, flags);
|
spin_unlock_irqrestore(&subpage->lock, flags);
|
||||||
cur_bit++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&subpage->lock, flags);
|
spin_unlock_irqrestore(&subpage->lock, flags);
|
||||||
|
@ -896,7 +898,7 @@ static bool btree_dirty_folio(struct address_space *mapping,
|
||||||
btrfs_assert_tree_write_locked(eb);
|
btrfs_assert_tree_write_locked(eb);
|
||||||
free_extent_buffer(eb);
|
free_extent_buffer(eb);
|
||||||
|
|
||||||
cur_bit += (fs_info->nodesize >> fs_info->sectorsize_bits);
|
cur_bit += (fs_info->nodesize >> fs_info->sectorsize_bits) - 1;
|
||||||
}
|
}
|
||||||
return filemap_dirty_folio(mapping, folio);
|
return filemap_dirty_folio(mapping, folio);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue