Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'vfs-6.13.pagecache' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs

Pull vfs pagecache updates from Christian Brauner:
"Cleanup filesystem page flag usage: This continues the work to make
the mappedtodisk/owner_2 flag available to filesystems which don't use
buffer heads. Further patches remove uses of Private2. This brings us
very close to being rid of it entirely"

* tag 'vfs-6.13.pagecache' of git://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs:
migrate: Remove references to Private2
ceph: Remove call to PagePrivate2()
btrfs: Switch from using the private_2 flag to owner_2
mm: Remove PageMappedToDisk
nilfs2: Convert nilfs_copy_buffer() to use folios
fs: Move clearing of mappedtodisk to buffer.c

+36 -41
+4 -9
fs/btrfs/ctree.h
··· 744 744 size_t __attribute_const__ btrfs_get_num_csums(void); 745 745 746 746 /* 747 - * We use page status Private2 to indicate there is an ordered extent with 747 + * We use folio flag owner_2 to indicate there is an ordered extent with 748 748 * unfinished IO. 749 - * 750 - * Rename the Private2 accessors to Ordered, to improve readability. 751 749 */ 752 - #define PageOrdered(page) PagePrivate2(page) 753 - #define SetPageOrdered(page) SetPagePrivate2(page) 754 - #define ClearPageOrdered(page) ClearPagePrivate2(page) 755 - #define folio_test_ordered(folio) folio_test_private_2(folio) 756 - #define folio_set_ordered(folio) folio_set_private_2(folio) 757 - #define folio_clear_ordered(folio) folio_clear_private_2(folio) 750 + #define folio_test_ordered(folio) folio_test_owner_2(folio) 751 + #define folio_set_ordered(folio) folio_set_owner_2(folio) 752 + #define folio_clear_ordered(folio) folio_clear_owner_2(folio) 758 753 759 754 #endif
+4 -4
fs/btrfs/inode.c
··· 1513 1513 * (which the caller expects to stay locked), don't clear any 1514 1514 * dirty bits and don't set any writeback bits 1515 1515 * 1516 - * Do set the Ordered (Private2) bit so we know this page was 1516 + * Do set the Ordered flag so we know this page was 1517 1517 * properly setup for writepage. 1518 1518 */ 1519 1519 page_ops = (keep_locked ? 0 : PAGE_UNLOCK); ··· 7294 7294 * 7295 7295 * But already submitted bio can still be finished on this folio. 7296 7296 * Furthermore, endio function won't skip folio which has Ordered 7297 - * (Private2) already cleared, so it's possible for endio and 7297 + * already cleared, so it's possible for endio and 7298 7298 * invalidate_folio to do the same ordered extent accounting twice 7299 7299 * on one folio. 7300 7300 * ··· 7360 7360 range_len = range_end + 1 - cur; 7361 7361 if (!btrfs_folio_test_ordered(fs_info, folio, cur, range_len)) { 7362 7362 /* 7363 - * If Ordered (Private2) is cleared, it means endio has 7363 + * If Ordered is cleared, it means endio has 7364 7364 * already been executed for the range. 7365 7365 * We can't delete the extent states as 7366 7366 * btrfs_finish_ordered_io() may still use some of them. ··· 7433 7433 } 7434 7434 /* 7435 7435 * We have iterated through all ordered extents of the page, the page 7436 - * should not have Ordered (Private2) anymore, or the above iteration 7436 + * should not have Ordered anymore, or the above iteration 7437 7437 * did something wrong. 7438 7438 */ 7439 7439 ASSERT(!folio_test_ordered(folio));
+2 -2
fs/btrfs/ordered-data.c
··· 346 346 ASSERT(file_offset + len <= folio_pos(folio) + folio_size(folio)); 347 347 348 348 /* 349 - * Ordered (Private2) bit indicates whether we still have 349 + * Ordered flag indicates whether we still have 350 350 * pending io unfinished for the ordered extent. 351 351 * 352 - * If there's no such bit, we need to skip to next range. 352 + * If it's not set, we need to skip to next range. 353 353 */ 354 354 if (!btrfs_folio_test_ordered(fs_info, folio, file_offset, len)) 355 355 return false;
+1
fs/buffer.c
··· 1649 1649 if (length == folio_size(folio)) 1650 1650 filemap_release_folio(folio, 0); 1651 1651 out: 1652 + folio_clear_mappedtodisk(folio); 1652 1653 return; 1653 1654 } 1654 1655 EXPORT_SYMBOL(block_invalidate_folio);
+10 -10
fs/ceph/addr.c
··· 1054 1054 if (!nr_folios && !locked_pages) 1055 1055 break; 1056 1056 for (i = 0; i < nr_folios && locked_pages < max_pages; i++) { 1057 - page = &fbatch.folios[i]->page; 1057 + struct folio *folio = fbatch.folios[i]; 1058 + 1059 + page = &folio->page; 1058 1060 doutc(cl, "? %p idx %lu\n", page, page->index); 1059 1061 if (locked_pages == 0) 1060 1062 lock_page(page); /* first page */ ··· 1083 1081 continue; 1084 1082 } 1085 1083 if (page_offset(page) >= ceph_wbc.i_size) { 1086 - struct folio *folio = page_folio(page); 1087 - 1088 1084 doutc(cl, "folio at %lu beyond eof %llu\n", 1089 1085 folio->index, ceph_wbc.i_size); 1090 1086 if ((ceph_wbc.size_stable || ··· 1098 1098 unlock_page(page); 1099 1099 break; 1100 1100 } 1101 - if (PageWriteback(page) || 1102 - PagePrivate2(page) /* [DEPRECATED] */) { 1101 + if (folio_test_writeback(folio) || 1102 + folio_test_private_2(folio) /* [DEPRECATED] */) { 1103 1103 if (wbc->sync_mode == WB_SYNC_NONE) { 1104 - doutc(cl, "%p under writeback\n", page); 1105 - unlock_page(page); 1104 + doutc(cl, "%p under writeback\n", folio); 1105 + folio_unlock(folio); 1106 1106 continue; 1107 1107 } 1108 - doutc(cl, "waiting on writeback %p\n", page); 1109 - wait_on_page_writeback(page); 1110 - folio_wait_private_2(page_folio(page)); /* [DEPRECATED] */ 1108 + doutc(cl, "waiting on writeback %p\n", folio); 1109 + folio_wait_writeback(folio); 1110 + folio_wait_private_2(folio); /* [DEPRECATED] */ 1111 1111 } 1112 1112 1113 1113 if (!clear_page_dirty_for_io(page)) {
+11 -11
fs/nilfs2/page.c
··· 99 99 */ 100 100 void nilfs_copy_buffer(struct buffer_head *dbh, struct buffer_head *sbh) 101 101 { 102 - void *kaddr0, *kaddr1; 102 + void *saddr, *daddr; 103 103 unsigned long bits; 104 - struct page *spage = sbh->b_page, *dpage = dbh->b_page; 104 + struct folio *sfolio = sbh->b_folio, *dfolio = dbh->b_folio; 105 105 struct buffer_head *bh; 106 106 107 - kaddr0 = kmap_local_page(spage); 108 - kaddr1 = kmap_local_page(dpage); 109 - memcpy(kaddr1 + bh_offset(dbh), kaddr0 + bh_offset(sbh), sbh->b_size); 110 - kunmap_local(kaddr1); 111 - kunmap_local(kaddr0); 107 + saddr = kmap_local_folio(sfolio, bh_offset(sbh)); 108 + daddr = kmap_local_folio(dfolio, bh_offset(dbh)); 109 + memcpy(daddr, saddr, sbh->b_size); 110 + kunmap_local(daddr); 111 + kunmap_local(saddr); 112 112 113 113 dbh->b_state = sbh->b_state & NILFS_BUFFER_INHERENT_BITS; 114 114 dbh->b_blocknr = sbh->b_blocknr; ··· 122 122 unlock_buffer(bh); 123 123 } 124 124 if (bits & BIT(BH_Uptodate)) 125 - SetPageUptodate(dpage); 125 + folio_mark_uptodate(dfolio); 126 126 else 127 - ClearPageUptodate(dpage); 127 + folio_clear_uptodate(dfolio); 128 128 if (bits & BIT(BH_Mapped)) 129 - SetPageMappedToDisk(dpage); 129 + folio_set_mappedtodisk(dfolio); 130 130 else 131 - ClearPageMappedToDisk(dpage); 131 + folio_clear_mappedtodisk(dfolio); 132 132 } 133 133 134 134 /**
+2 -2
include/linux/page-flags.h
··· 543 543 * - PG_private and PG_private_2 cause release_folio() and co to be invoked 544 544 */ 545 545 PAGEFLAG(Private, private, PF_ANY) 546 - PAGEFLAG(Private2, private_2, PF_ANY) TESTSCFLAG(Private2, private_2, PF_ANY) 546 + FOLIO_FLAG(private_2, FOLIO_HEAD_PAGE) 547 547 548 548 /* owner_2 can be set on tail pages for anon memory */ 549 549 FOLIO_FLAG(owner_2, FOLIO_HEAD_PAGE) ··· 554 554 */ 555 555 TESTPAGEFLAG(Writeback, writeback, PF_NO_TAIL) 556 556 TESTSCFLAG(Writeback, writeback, PF_NO_TAIL) 557 - PAGEFLAG(MappedToDisk, mappedtodisk, PF_NO_TAIL) 557 + FOLIO_FLAG(mappedtodisk, FOLIO_HEAD_PAGE) 558 558 559 559 /* PG_readahead is only used for reads; PG_reclaim is only for writes */ 560 560 PAGEFLAG(Reclaim, reclaim, PF_NO_TAIL)
+2 -2
mm/migrate.c
··· 473 473 * The number of remaining references must be: 474 474 * 1 for anonymous folios without a mapping 475 475 * 2 for folios with a mapping 476 - * 3 for folios with a mapping and PagePrivate/PagePrivate2 set. 476 + * 3 for folios with a mapping and the private flag set. 477 477 */ 478 478 static int __folio_migrate_mapping(struct address_space *mapping, 479 479 struct folio *newfolio, struct folio *folio, int expected_count) ··· 787 787 * @mode: How to migrate the page. 788 788 * 789 789 * Common logic to directly migrate a single LRU folio suitable for 790 - * folios that do not use PagePrivate/PagePrivate2. 790 + * folios that do not have private data. 791 791 * 792 792 * Folios are locked upon entry and exit. 793 793 */
-1
mm/truncate.c
··· 166 166 * Hence dirty accounting check is placed after invalidation. 167 167 */ 168 168 folio_cancel_dirty(folio); 169 - folio_clear_mappedtodisk(folio); 170 169 } 171 170 172 171 int truncate_inode_folio(struct address_space *mapping, struct folio *folio)