Skip to content

Commit 56be9aa

Browse files
committed
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
2 parents 5bb6ba4 + c6bbfc7 commit 56be9aa

File tree

9 files changed

+36
-41
lines changed

9 files changed

+36
-41
lines changed

fs/btrfs/ctree.h

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -744,16 +744,11 @@ const char *btrfs_super_csum_driver(u16 csum_type);
744744
size_t __attribute_const__ btrfs_get_num_csums(void);
745745

746746
/*
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
748748
* unfinished IO.
749-
*
750-
* Rename the Private2 accessors to Ordered, to improve readability.
751749
*/
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)
758753

759754
#endif

fs/btrfs/inode.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1513,7 +1513,7 @@ static noinline int cow_file_range(struct btrfs_inode *inode,
15131513
* (which the caller expects to stay locked), don't clear any
15141514
* dirty bits and don't set any writeback bits
15151515
*
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
15171517
* properly setup for writepage.
15181518
*/
15191519
page_ops = (keep_locked ? 0 : PAGE_UNLOCK);
@@ -7294,7 +7294,7 @@ static void btrfs_invalidate_folio(struct folio *folio, size_t offset,
72947294
*
72957295
* But already submitted bio can still be finished on this folio.
72967296
* 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
72987298
* invalidate_folio to do the same ordered extent accounting twice
72997299
* on one folio.
73007300
*
@@ -7360,7 +7360,7 @@ static void btrfs_invalidate_folio(struct folio *folio, size_t offset,
73607360
range_len = range_end + 1 - cur;
73617361
if (!btrfs_folio_test_ordered(fs_info, folio, cur, range_len)) {
73627362
/*
7363-
* If Ordered (Private2) is cleared, it means endio has
7363+
* If Ordered is cleared, it means endio has
73647364
* already been executed for the range.
73657365
* We can't delete the extent states as
73667366
* btrfs_finish_ordered_io() may still use some of them.
@@ -7433,7 +7433,7 @@ static void btrfs_invalidate_folio(struct folio *folio, size_t offset,
74337433
}
74347434
/*
74357435
* 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
74377437
* did something wrong.
74387438
*/
74397439
ASSERT(!folio_test_ordered(folio));

fs/btrfs/ordered-data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,10 @@ static bool can_finish_ordered_extent(struct btrfs_ordered_extent *ordered,
346346
ASSERT(file_offset + len <= folio_pos(folio) + folio_size(folio));
347347

348348
/*
349-
* Ordered (Private2) bit indicates whether we still have
349+
* Ordered flag indicates whether we still have
350350
* pending io unfinished for the ordered extent.
351351
*
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.
353353
*/
354354
if (!btrfs_folio_test_ordered(fs_info, folio, file_offset, len))
355355
return false;

fs/buffer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1649,6 +1649,7 @@ void block_invalidate_folio(struct folio *folio, size_t offset, size_t length)
16491649
if (length == folio_size(folio))
16501650
filemap_release_folio(folio, 0);
16511651
out:
1652+
folio_clear_mappedtodisk(folio);
16521653
return;
16531654
}
16541655
EXPORT_SYMBOL(block_invalidate_folio);

fs/ceph/addr.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,9 @@ static int ceph_writepages_start(struct address_space *mapping,
10541054
if (!nr_folios && !locked_pages)
10551055
break;
10561056
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;
10581060
doutc(cl, "? %p idx %lu\n", page, page->index);
10591061
if (locked_pages == 0)
10601062
lock_page(page); /* first page */
@@ -1081,8 +1083,6 @@ static int ceph_writepages_start(struct address_space *mapping,
10811083
continue;
10821084
}
10831085
if (page_offset(page) >= ceph_wbc.i_size) {
1084-
struct folio *folio = page_folio(page);
1085-
10861086
doutc(cl, "folio at %lu beyond eof %llu\n",
10871087
folio->index, ceph_wbc.i_size);
10881088
if ((ceph_wbc.size_stable ||
@@ -1098,16 +1098,16 @@ static int ceph_writepages_start(struct address_space *mapping,
10981098
unlock_page(page);
10991099
break;
11001100
}
1101-
if (PageWriteback(page) ||
1102-
PagePrivate2(page) /* [DEPRECATED] */) {
1101+
if (folio_test_writeback(folio) ||
1102+
folio_test_private_2(folio) /* [DEPRECATED] */) {
11031103
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);
11061106
continue;
11071107
}
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] */
11111111
}
11121112

11131113
if (!clear_page_dirty_for_io(page)) {

fs/nilfs2/page.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,16 +99,16 @@ void nilfs_forget_buffer(struct buffer_head *bh)
9999
*/
100100
void nilfs_copy_buffer(struct buffer_head *dbh, struct buffer_head *sbh)
101101
{
102-
void *kaddr0, *kaddr1;
102+
void *saddr, *daddr;
103103
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;
105105
struct buffer_head *bh;
106106

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);
112112

113113
dbh->b_state = sbh->b_state & NILFS_BUFFER_INHERENT_BITS;
114114
dbh->b_blocknr = sbh->b_blocknr;
@@ -122,13 +122,13 @@ void nilfs_copy_buffer(struct buffer_head *dbh, struct buffer_head *sbh)
122122
unlock_buffer(bh);
123123
}
124124
if (bits & BIT(BH_Uptodate))
125-
SetPageUptodate(dpage);
125+
folio_mark_uptodate(dfolio);
126126
else
127-
ClearPageUptodate(dpage);
127+
folio_clear_uptodate(dfolio);
128128
if (bits & BIT(BH_Mapped))
129-
SetPageMappedToDisk(dpage);
129+
folio_set_mappedtodisk(dfolio);
130130
else
131-
ClearPageMappedToDisk(dpage);
131+
folio_clear_mappedtodisk(dfolio);
132132
}
133133

134134
/**

include/linux/page-flags.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ FOLIO_FLAG(swapbacked, FOLIO_HEAD_PAGE)
543543
* - PG_private and PG_private_2 cause release_folio() and co to be invoked
544544
*/
545545
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)
547547

548548
/* owner_2 can be set on tail pages for anon memory */
549549
FOLIO_FLAG(owner_2, FOLIO_HEAD_PAGE)
@@ -554,7 +554,7 @@ FOLIO_FLAG(owner_2, FOLIO_HEAD_PAGE)
554554
*/
555555
TESTPAGEFLAG(Writeback, writeback, PF_NO_TAIL)
556556
TESTSCFLAG(Writeback, writeback, PF_NO_TAIL)
557-
PAGEFLAG(MappedToDisk, mappedtodisk, PF_NO_TAIL)
557+
FOLIO_FLAG(mappedtodisk, FOLIO_HEAD_PAGE)
558558

559559
/* PG_readahead is only used for reads; PG_reclaim is only for writes */
560560
PAGEFLAG(Reclaim, reclaim, PF_NO_TAIL)

mm/migrate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ static int folio_expected_refs(struct address_space *mapping,
473473
* The number of remaining references must be:
474474
* 1 for anonymous folios without a mapping
475475
* 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.
477477
*/
478478
static int __folio_migrate_mapping(struct address_space *mapping,
479479
struct folio *newfolio, struct folio *folio, int expected_count)
@@ -787,7 +787,7 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst,
787787
* @mode: How to migrate the page.
788788
*
789789
* 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.
791791
*
792792
* Folios are locked upon entry and exit.
793793
*/

mm/truncate.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ static void truncate_cleanup_folio(struct folio *folio)
166166
* Hence dirty accounting check is placed after invalidation.
167167
*/
168168
folio_cancel_dirty(folio);
169-
folio_clear_mappedtodisk(folio);
170169
}
171170

172171
int truncate_inode_folio(struct address_space *mapping, struct folio *folio)

0 commit comments

Comments
 (0)