Skip to content

Commit e621900

Browse files
author
Matthew Wilcox (Oracle)
committed
fs: Convert __set_page_dirty_buffers to block_dirty_folio
Convert all callers; mostly this is just changing the aops to point at it, but a few implementations need a little more work. 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 af7afdc commit e621900

File tree

32 files changed

+76
-85
lines changed

32 files changed

+76
-85
lines changed

block/fops.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ static int blkdev_writepages(struct address_space *mapping,
429429
}
430430

431431
const struct address_space_operations def_blk_aops = {
432-
.set_page_dirty = __set_page_dirty_buffers,
432+
.dirty_folio = block_dirty_folio,
433433
.invalidate_folio = block_invalidate_folio,
434434
.readpage = blkdev_readpage,
435435
.readahead = blkdev_readahead,

fs/adfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static sector_t _adfs_bmap(struct address_space *mapping, sector_t block)
7373
}
7474

7575
static const struct address_space_operations adfs_aops = {
76-
.set_page_dirty = __set_page_dirty_buffers,
76+
.dirty_folio = block_dirty_folio,
7777
.invalidate_folio = block_invalidate_folio,
7878
.readpage = adfs_readpage,
7979
.writepage = adfs_writepage,

fs/affs/file.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ static sector_t _affs_bmap(struct address_space *mapping, sector_t block)
453453
}
454454

455455
const struct address_space_operations affs_aops = {
456-
.set_page_dirty = __set_page_dirty_buffers,
456+
.dirty_folio = block_dirty_folio,
457457
.invalidate_folio = block_invalidate_folio,
458458
.readpage = affs_readpage,
459459
.writepage = affs_writepage,
@@ -835,7 +835,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
835835
}
836836

837837
const struct address_space_operations affs_aops_ofs = {
838-
.set_page_dirty = __set_page_dirty_buffers,
838+
.dirty_folio = block_dirty_folio,
839839
.invalidate_folio = block_invalidate_folio,
840840
.readpage = affs_readpage_ofs,
841841
//.writepage = affs_writepage_ofs,

fs/bfs/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static sector_t bfs_bmap(struct address_space *mapping, sector_t block)
188188
}
189189

190190
const struct address_space_operations bfs_aops = {
191-
.set_page_dirty = __set_page_dirty_buffers,
191+
.dirty_folio = block_dirty_folio,
192192
.invalidate_folio = block_invalidate_folio,
193193
.readpage = bfs_readpage,
194194
.writepage = bfs_writepage,

fs/buffer.c

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -613,17 +613,14 @@ EXPORT_SYMBOL(mark_buffer_dirty_inode);
613613
* FIXME: may need to call ->reservepage here as well. That's rather up to the
614614
* address_space though.
615615
*/
616-
int __set_page_dirty_buffers(struct page *page)
616+
bool block_dirty_folio(struct address_space *mapping, struct folio *folio)
617617
{
618-
int newly_dirty;
619-
struct address_space *mapping = page_mapping(page);
620-
621-
if (unlikely(!mapping))
622-
return !TestSetPageDirty(page);
618+
struct buffer_head *head;
619+
bool newly_dirty;
623620

624621
spin_lock(&mapping->private_lock);
625-
if (page_has_buffers(page)) {
626-
struct buffer_head *head = page_buffers(page);
622+
head = folio_buffers(folio);
623+
if (head) {
627624
struct buffer_head *bh = head;
628625

629626
do {
@@ -635,21 +632,21 @@ int __set_page_dirty_buffers(struct page *page)
635632
* Lock out page's memcg migration to keep PageDirty
636633
* synchronized with per-memcg dirty page counters.
637634
*/
638-
lock_page_memcg(page);
639-
newly_dirty = !TestSetPageDirty(page);
635+
folio_memcg_lock(folio);
636+
newly_dirty = !folio_test_set_dirty(folio);
640637
spin_unlock(&mapping->private_lock);
641638

642639
if (newly_dirty)
643-
__set_page_dirty(page, mapping, 1);
640+
__folio_mark_dirty(folio, mapping, 1);
644641

645-
unlock_page_memcg(page);
642+
folio_memcg_unlock(folio);
646643

647644
if (newly_dirty)
648645
__mark_inode_dirty(mapping->host, I_DIRTY_PAGES);
649646

650647
return newly_dirty;
651648
}
652-
EXPORT_SYMBOL(__set_page_dirty_buffers);
649+
EXPORT_SYMBOL(block_dirty_folio);
653650

654651
/*
655652
* Write out and wait upon a list of buffers.
@@ -1548,7 +1545,7 @@ EXPORT_SYMBOL(block_invalidate_folio);
15481545

15491546
/*
15501547
* We attach and possibly dirty the buffers atomically wrt
1551-
* __set_page_dirty_buffers() via private_lock. try_to_free_buffers
1548+
* block_dirty_folio() via private_lock. try_to_free_buffers
15521549
* is already excluded via the page lock.
15531550
*/
15541551
void create_empty_buffers(struct page *page,
@@ -1723,12 +1720,12 @@ int __block_write_full_page(struct inode *inode, struct page *page,
17231720
(1 << BH_Dirty)|(1 << BH_Uptodate));
17241721

17251722
/*
1726-
* Be very careful. We have no exclusion from __set_page_dirty_buffers
1723+
* Be very careful. We have no exclusion from block_dirty_folio
17271724
* here, and the (potentially unmapped) buffers may become dirty at
17281725
* any time. If a buffer becomes dirty here after we've inspected it
17291726
* then we just miss that fact, and the page stays dirty.
17301727
*
1731-
* Buffers outside i_size may be dirtied by __set_page_dirty_buffers;
1728+
* Buffers outside i_size may be dirtied by block_dirty_folio;
17321729
* handle that here by just cleaning them.
17331730
*/
17341731

@@ -3182,7 +3179,7 @@ EXPORT_SYMBOL(sync_dirty_buffer);
31823179
*
31833180
* The same applies to regular filesystem pages: if all the buffers are
31843181
* clean then we set the page clean and proceed. To do that, we require
3185-
* total exclusion from __set_page_dirty_buffers(). That is obtained with
3182+
* total exclusion from block_dirty_folio(). That is obtained with
31863183
* private_lock.
31873184
*
31883185
* try_to_free_buffers() is non-blocking.
@@ -3249,7 +3246,7 @@ int try_to_free_buffers(struct page *page)
32493246
* the page also.
32503247
*
32513248
* private_lock must be held over this entire operation in order
3252-
* to synchronise against __set_page_dirty_buffers and prevent the
3249+
* to synchronise against block_dirty_folio and prevent the
32533250
* dirty bit from being lost.
32543251
*/
32553252
if (ret)

fs/ecryptfs/mmap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ const struct address_space_operations ecryptfs_aops = {
545545
* feedback.
546546
*/
547547
#ifdef CONFIG_BLOCK
548-
.set_page_dirty = __set_page_dirty_buffers,
548+
.dirty_folio = block_dirty_folio,
549549
.invalidate_folio = block_invalidate_folio,
550550
#endif
551551
.writepage = ecryptfs_writepage,

fs/exfat/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ int exfat_block_truncate_page(struct inode *inode, loff_t from)
490490
}
491491

492492
static const struct address_space_operations exfat_aops = {
493-
.set_page_dirty = __set_page_dirty_buffers,
493+
.dirty_folio = block_dirty_folio,
494494
.invalidate_folio = block_invalidate_folio,
495495
.readpage = exfat_readpage,
496496
.readahead = exfat_readahead,

fs/ext2/inode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -967,8 +967,8 @@ ext2_dax_writepages(struct address_space *mapping, struct writeback_control *wbc
967967
}
968968

969969
const struct address_space_operations ext2_aops = {
970-
.set_page_dirty = __set_page_dirty_buffers,
971-
.invalidate_folio = block_invalidate_folio,
970+
.dirty_folio = block_dirty_folio,
971+
.invalidate_folio = block_invalidate_folio,
972972
.readpage = ext2_readpage,
973973
.readahead = ext2_readahead,
974974
.writepage = ext2_writepage,
@@ -983,8 +983,8 @@ const struct address_space_operations ext2_aops = {
983983
};
984984

985985
const struct address_space_operations ext2_nobh_aops = {
986-
.set_page_dirty = __set_page_dirty_buffers,
987-
.invalidate_folio = block_invalidate_folio,
986+
.dirty_folio = block_dirty_folio,
987+
.invalidate_folio = block_invalidate_folio,
988988
.readpage = ext2_readpage,
989989
.readahead = ext2_readahead,
990990
.writepage = ext2_nobh_writepage,

fs/ext4/inode.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3560,11 +3560,11 @@ static bool ext4_journalled_dirty_folio(struct address_space *mapping,
35603560
return filemap_dirty_folio(mapping, folio);
35613561
}
35623562

3563-
static int ext4_set_page_dirty(struct page *page)
3563+
static bool ext4_dirty_folio(struct address_space *mapping, struct folio *folio)
35643564
{
3565-
WARN_ON_ONCE(!PageLocked(page) && !PageDirty(page));
3566-
WARN_ON_ONCE(!page_has_buffers(page));
3567-
return __set_page_dirty_buffers(page);
3565+
WARN_ON_ONCE(!folio_test_locked(folio) && !folio_test_dirty(folio));
3566+
WARN_ON_ONCE(!folio_buffers(folio));
3567+
return block_dirty_folio(mapping, folio);
35683568
}
35693569

35703570
static int ext4_iomap_swap_activate(struct swap_info_struct *sis,
@@ -3581,7 +3581,7 @@ static const struct address_space_operations ext4_aops = {
35813581
.writepages = ext4_writepages,
35823582
.write_begin = ext4_write_begin,
35833583
.write_end = ext4_write_end,
3584-
.set_page_dirty = ext4_set_page_dirty,
3584+
.dirty_folio = ext4_dirty_folio,
35853585
.bmap = ext4_bmap,
35863586
.invalidate_folio = ext4_invalidate_folio,
35873587
.releasepage = ext4_releasepage,
@@ -3616,7 +3616,7 @@ static const struct address_space_operations ext4_da_aops = {
36163616
.writepages = ext4_writepages,
36173617
.write_begin = ext4_da_write_begin,
36183618
.write_end = ext4_da_write_end,
3619-
.set_page_dirty = ext4_set_page_dirty,
3619+
.dirty_folio = ext4_dirty_folio,
36203620
.bmap = ext4_bmap,
36213621
.invalidate_folio = ext4_invalidate_folio,
36223622
.releasepage = ext4_releasepage,

fs/fat/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ int fat_block_truncate_page(struct inode *inode, loff_t from)
342342
}
343343

344344
static const struct address_space_operations fat_aops = {
345-
.set_page_dirty = __set_page_dirty_buffers,
345+
.dirty_folio = block_dirty_folio,
346346
.invalidate_folio = block_invalidate_folio,
347347
.readpage = fat_readpage,
348348
.readahead = fat_readahead,

0 commit comments

Comments
 (0)