[PATCH] btrfs: remove btree_dirty_folio() inside DEBUG
From: Yunhui Cui
Date: Thu Aug 31 2023 - 23:18:56 EST
When the DEBUG compilation option is enabled (KCFLAGS=-DDEBUG),
the following compilation error will occur:
fs/btrfs/disk-io.c: In function ‘btree_dirty_folio’:
fs/btrfs/disk-io.c:538:16: error: ‘struct btrfs_subpage’ has no member named ‘dirty_bitmap’
ASSERT(subpage->dirty_bitmap);
^~
fs/btrfs/messages.h:181:29: note: in definition of macro ‘ASSERT’
#define ASSERT(expr) (void)(expr)
^~~~
fs/btrfs/disk-io.c:539:19: error: ‘BTRFS_SUBPAGE_BITMAP_SIZE’ undeclared (first use in this function); did you mean ‘BTRFS_FREE_SPACE_BITMAP_SIZE’?
while (cur_bit < BTRFS_SUBPAGE_BITMAP_SIZE) {
^~~~~~~~~~~~~~~~~~~~~~~~~
BTRFS_FREE_SPACE_BITMAP_SIZE
fs/btrfs/disk-io.c:539:19: note: each undeclared identifier is reported only once for each function it appears in
fs/btrfs/disk-io.c:545:22: error: ‘struct btrfs_subpage’ has no member named ‘dirty_bitmap’
if (!(tmp & subpage->dirty_bitmap)) {
^~
Signed-off-by: Yunhui Cui <cuiyunhui@xxxxxxxxxxxxx>
---
fs/btrfs/disk-io.c | 52 +---------------------------------------------
1 file changed, 1 insertion(+), 51 deletions(-)
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 0a96ea8c1d3a..f0252c70233a 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -515,62 +515,12 @@ static void btree_invalidate_folio(struct folio *folio, size_t offset,
}
}
-#ifdef DEBUG
-static bool btree_dirty_folio(struct address_space *mapping,
- struct folio *folio)
-{
- struct btrfs_fs_info *fs_info = btrfs_sb(mapping->host->i_sb);
- struct btrfs_subpage *subpage;
- struct extent_buffer *eb;
- int cur_bit = 0;
- u64 page_start = folio_pos(folio);
-
- if (fs_info->sectorsize == PAGE_SIZE) {
- eb = folio_get_private(folio);
- BUG_ON(!eb);
- BUG_ON(!test_bit(EXTENT_BUFFER_DIRTY, &eb->bflags));
- BUG_ON(!atomic_read(&eb->refs));
- btrfs_assert_tree_write_locked(eb);
- return filemap_dirty_folio(mapping, folio);
- }
- subpage = folio_get_private(folio);
-
- ASSERT(subpage->dirty_bitmap);
- while (cur_bit < BTRFS_SUBPAGE_BITMAP_SIZE) {
- unsigned long flags;
- u64 cur;
- u16 tmp = (1 << cur_bit);
-
- spin_lock_irqsave(&subpage->lock, flags);
- if (!(tmp & subpage->dirty_bitmap)) {
- spin_unlock_irqrestore(&subpage->lock, flags);
- cur_bit++;
- continue;
- }
- spin_unlock_irqrestore(&subpage->lock, flags);
- cur = page_start + cur_bit * fs_info->sectorsize;
-
- eb = find_extent_buffer(fs_info, cur);
- ASSERT(eb);
- ASSERT(test_bit(EXTENT_BUFFER_DIRTY, &eb->bflags));
- ASSERT(atomic_read(&eb->refs));
- btrfs_assert_tree_write_locked(eb);
- free_extent_buffer(eb);
-
- cur_bit += (fs_info->nodesize >> fs_info->sectorsize_bits);
- }
- return filemap_dirty_folio(mapping, folio);
-}
-#else
-#define btree_dirty_folio filemap_dirty_folio
-#endif
-
static const struct address_space_operations btree_aops = {
.writepages = btree_writepages,
.release_folio = btree_release_folio,
.invalidate_folio = btree_invalidate_folio,
.migrate_folio = btree_migrate_folio,
- .dirty_folio = btree_dirty_folio,
+ .dirty_folio = filemap_dirty_folio,
};
struct extent_buffer *btrfs_find_create_tree_block(
--
2.20.1