Skip to content

Commit 5e0e879

Browse files
adam900710kdave
authored andcommitted
btrfs: fix a compilation error if DEBUG is defined in btree_dirty_folio
[BUG] After commit 72a69cd ("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 commit 72a69cd ("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: [email protected] # 6.1+ Signed-off-by: Qu Wenruo <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 4ca8e03 commit 5e0e879

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

fs/btrfs/disk-io.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ static bool btree_dirty_folio(struct address_space *mapping,
520520
struct folio *folio)
521521
{
522522
struct btrfs_fs_info *fs_info = btrfs_sb(mapping->host->i_sb);
523+
struct btrfs_subpage_info *spi = fs_info->subpage_info;
523524
struct btrfs_subpage *subpage;
524525
struct extent_buffer *eb;
525526
int cur_bit = 0;
@@ -533,18 +534,19 @@ static bool btree_dirty_folio(struct address_space *mapping,
533534
btrfs_assert_tree_write_locked(eb);
534535
return filemap_dirty_folio(mapping, folio);
535536
}
537+
538+
ASSERT(spi);
536539
subpage = folio_get_private(folio);
537540

538-
ASSERT(subpage->dirty_bitmap);
539-
while (cur_bit < BTRFS_SUBPAGE_BITMAP_SIZE) {
541+
for (cur_bit = spi->dirty_offset;
542+
cur_bit < spi->dirty_offset + spi->bitmap_nr_bits;
543+
cur_bit++) {
540544
unsigned long flags;
541545
u64 cur;
542-
u16 tmp = (1 << cur_bit);
543546

544547
spin_lock_irqsave(&subpage->lock, flags);
545-
if (!(tmp & subpage->dirty_bitmap)) {
548+
if (!test_bit(cur_bit, subpage->bitmaps)) {
546549
spin_unlock_irqrestore(&subpage->lock, flags);
547-
cur_bit++;
548550
continue;
549551
}
550552
spin_unlock_irqrestore(&subpage->lock, flags);
@@ -557,7 +559,7 @@ static bool btree_dirty_folio(struct address_space *mapping,
557559
btrfs_assert_tree_write_locked(eb);
558560
free_extent_buffer(eb);
559561

560-
cur_bit += (fs_info->nodesize >> fs_info->sectorsize_bits);
562+
cur_bit += (fs_info->nodesize >> fs_info->sectorsize_bits) - 1;
561563
}
562564
return filemap_dirty_folio(mapping, folio);
563565
}

0 commit comments

Comments
 (0)