Skip to content

Commit 0079c3b

Browse files
author
Matthew Wilcox (Oracle)
committed
btrfs: Convert from set_page_dirty to dirty_folio
Optimise the non-DEBUG case to just call filemap_dirty_folio directly. The DEBUG case doesn't actually compile, but convert it to dirty_folio anyway. Signed-off-by: Matthew Wilcox (Oracle) <[email protected]> Tested-by: Damien Le Moal <[email protected]> Acked-by: Damien Le Moal <[email protected]> Tested-by: Mike Marshall <[email protected]> # orangefs Tested-by: David Howells <[email protected]> # afs
1 parent 8fb72b4 commit 0079c3b

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

fs/btrfs/disk-io.c

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,26 +1014,25 @@ static void btree_invalidate_folio(struct folio *folio, size_t offset,
10141014
}
10151015
}
10161016

1017-
static int btree_set_page_dirty(struct page *page)
1018-
{
10191017
#ifdef DEBUG
1020-
struct btrfs_fs_info *fs_info = btrfs_sb(page->mapping->host->i_sb);
1018+
static bool btree_dirty_folio(struct address_space *mapping,
1019+
struct folio *folio)
1020+
{
1021+
struct btrfs_fs_info *fs_info = btrfs_sb(mapping->host->i_sb);
10211022
struct btrfs_subpage *subpage;
10221023
struct extent_buffer *eb;
10231024
int cur_bit = 0;
1024-
u64 page_start = page_offset(page);
1025+
u64 page_start = folio_pos(folio);
10251026

10261027
if (fs_info->sectorsize == PAGE_SIZE) {
1027-
BUG_ON(!PagePrivate(page));
1028-
eb = (struct extent_buffer *)page->private;
1028+
eb = folio_get_private(folio);
10291029
BUG_ON(!eb);
10301030
BUG_ON(!test_bit(EXTENT_BUFFER_DIRTY, &eb->bflags));
10311031
BUG_ON(!atomic_read(&eb->refs));
10321032
btrfs_assert_tree_write_locked(eb);
1033-
return __set_page_dirty_nobuffers(page);
1033+
return filemap_dirty_folio(mapping, folio);
10341034
}
1035-
ASSERT(PagePrivate(page) && page->private);
1036-
subpage = (struct btrfs_subpage *)page->private;
1035+
subpage = folio_get_private(folio);
10371036

10381037
ASSERT(subpage->dirty_bitmap);
10391038
while (cur_bit < BTRFS_SUBPAGE_BITMAP_SIZE) {
@@ -1059,9 +1058,11 @@ static int btree_set_page_dirty(struct page *page)
10591058

10601059
cur_bit += (fs_info->nodesize >> fs_info->sectorsize_bits);
10611060
}
1062-
#endif
1063-
return __set_page_dirty_nobuffers(page);
1061+
return filemap_dirty_folio(mapping, folio);
10641062
}
1063+
#else
1064+
#define btree_dirty_folio filemap_dirty_folio
1065+
#endif
10651066

10661067
static const struct address_space_operations btree_aops = {
10671068
.writepages = btree_writepages,
@@ -1070,7 +1071,7 @@ static const struct address_space_operations btree_aops = {
10701071
#ifdef CONFIG_MIGRATION
10711072
.migratepage = btree_migratepage,
10721073
#endif
1073-
.set_page_dirty = btree_set_page_dirty,
1074+
.dirty_folio = btree_dirty_folio,
10741075
};
10751076

10761077
struct extent_buffer *btrfs_find_create_tree_block(

0 commit comments

Comments
 (0)