Skip to content

Commit c6bbfc7

Browse files
committed
Merge patch series "Filesystem page flags cleanup"
Matthew Wilcox (Oracle) <[email protected]> says: The first four patches continue the work begun in 02e1960 to make the mappedtodisk/owner_2 flag available to filesystems which don't use buffer heads. The last two remove uses of Private2 (we're achingly close to being rid of it entirely, but that doesn't seem like it'll land this merge window). * patches from https://lore.kernel.org/r/[email protected]: 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 Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
2 parents 9852d85 + 7735348 commit c6bbfc7

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);
@@ -7292,7 +7292,7 @@ static void btrfs_invalidate_folio(struct folio *folio, size_t offset,
72927292
*
72937293
* But already submitted bio can still be finished on this folio.
72947294
* Furthermore, endio function won't skip folio which has Ordered
7295-
* (Private2) already cleared, so it's possible for endio and
7295+
* already cleared, so it's possible for endio and
72967296
* invalidate_folio to do the same ordered extent accounting twice
72977297
* on one folio.
72987298
*
@@ -7358,7 +7358,7 @@ static void btrfs_invalidate_folio(struct folio *folio, size_t offset,
73587358
range_len = range_end + 1 - cur;
73597359
if (!btrfs_folio_test_ordered(fs_info, folio, cur, range_len)) {
73607360
/*
7361-
* If Ordered (Private2) is cleared, it means endio has
7361+
* If Ordered is cleared, it means endio has
73627362
* already been executed for the range.
73637363
* We can't delete the extent states as
73647364
* btrfs_finish_ordered_io() may still use some of them.
@@ -7431,7 +7431,7 @@ static void btrfs_invalidate_folio(struct folio *folio, size_t offset,
74317431
}
74327432
/*
74337433
* We have iterated through all ordered extents of the page, the page
7434-
* should not have Ordered (Private2) anymore, or the above iteration
7434+
* should not have Ordered anymore, or the above iteration
74357435
* did something wrong.
74367436
*/
74377437
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
@@ -1051,7 +1051,9 @@ static int ceph_writepages_start(struct address_space *mapping,
10511051
if (!nr_folios && !locked_pages)
10521052
break;
10531053
for (i = 0; i < nr_folios && locked_pages < max_pages; i++) {
1054-
page = &fbatch.folios[i]->page;
1054+
struct folio *folio = fbatch.folios[i];
1055+
1056+
page = &folio->page;
10551057
doutc(cl, "? %p idx %lu\n", page, page->index);
10561058
if (locked_pages == 0)
10571059
lock_page(page); /* first page */
@@ -1078,8 +1080,6 @@ static int ceph_writepages_start(struct address_space *mapping,
10781080
continue;
10791081
}
10801082
if (page_offset(page) >= ceph_wbc.i_size) {
1081-
struct folio *folio = page_folio(page);
1082-
10831083
doutc(cl, "folio at %lu beyond eof %llu\n",
10841084
folio->index, ceph_wbc.i_size);
10851085
if ((ceph_wbc.size_stable ||
@@ -1095,16 +1095,16 @@ static int ceph_writepages_start(struct address_space *mapping,
10951095
unlock_page(page);
10961096
break;
10971097
}
1098-
if (PageWriteback(page) ||
1099-
PagePrivate2(page) /* [DEPRECATED] */) {
1098+
if (folio_test_writeback(folio) ||
1099+
folio_test_private_2(folio) /* [DEPRECATED] */) {
11001100
if (wbc->sync_mode == WB_SYNC_NONE) {
1101-
doutc(cl, "%p under writeback\n", page);
1102-
unlock_page(page);
1101+
doutc(cl, "%p under writeback\n", folio);
1102+
folio_unlock(folio);
11031103
continue;
11041104
}
1105-
doutc(cl, "waiting on writeback %p\n", page);
1106-
wait_on_page_writeback(page);
1107-
folio_wait_private_2(page_folio(page)); /* [DEPRECATED] */
1105+
doutc(cl, "waiting on writeback %p\n", folio);
1106+
folio_wait_writeback(folio);
1107+
folio_wait_private_2(folio); /* [DEPRECATED] */
11081108
}
11091109

11101110
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
@@ -98,16 +98,16 @@ void nilfs_forget_buffer(struct buffer_head *bh)
9898
*/
9999
void nilfs_copy_buffer(struct buffer_head *dbh, struct buffer_head *sbh)
100100
{
101-
void *kaddr0, *kaddr1;
101+
void *saddr, *daddr;
102102
unsigned long bits;
103-
struct page *spage = sbh->b_page, *dpage = dbh->b_page;
103+
struct folio *sfolio = sbh->b_folio, *dfolio = dbh->b_folio;
104104
struct buffer_head *bh;
105105

106-
kaddr0 = kmap_local_page(spage);
107-
kaddr1 = kmap_local_page(dpage);
108-
memcpy(kaddr1 + bh_offset(dbh), kaddr0 + bh_offset(sbh), sbh->b_size);
109-
kunmap_local(kaddr1);
110-
kunmap_local(kaddr0);
106+
saddr = kmap_local_folio(sfolio, bh_offset(sbh));
107+
daddr = kmap_local_folio(dfolio, bh_offset(dbh));
108+
memcpy(daddr, saddr, sbh->b_size);
109+
kunmap_local(daddr);
110+
kunmap_local(saddr);
111111

112112
dbh->b_state = sbh->b_state & NILFS_BUFFER_INHERENT_BITS;
113113
dbh->b_blocknr = sbh->b_blocknr;
@@ -121,13 +121,13 @@ void nilfs_copy_buffer(struct buffer_head *dbh, struct buffer_head *sbh)
121121
unlock_buffer(bh);
122122
}
123123
if (bits & BIT(BH_Uptodate))
124-
SetPageUptodate(dpage);
124+
folio_mark_uptodate(dfolio);
125125
else
126-
ClearPageUptodate(dpage);
126+
folio_clear_uptodate(dfolio);
127127
if (bits & BIT(BH_Mapped))
128-
SetPageMappedToDisk(dpage);
128+
folio_set_mappedtodisk(dfolio);
129129
else
130-
ClearPageMappedToDisk(dpage);
130+
folio_clear_mappedtodisk(dfolio);
131131
}
132132

133133
/**

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
@@ -472,7 +472,7 @@ static int folio_expected_refs(struct address_space *mapping,
472472
* The number of remaining references must be:
473473
* 1 for anonymous folios without a mapping
474474
* 2 for folios with a mapping
475-
* 3 for folios with a mapping and PagePrivate/PagePrivate2 set.
475+
* 3 for folios with a mapping and the private flag set.
476476
*/
477477
static int __folio_migrate_mapping(struct address_space *mapping,
478478
struct folio *newfolio, struct folio *folio, int expected_count)
@@ -786,7 +786,7 @@ static int __migrate_folio(struct address_space *mapping, struct folio *dst,
786786
* @mode: How to migrate the page.
787787
*
788788
* Common logic to directly migrate a single LRU folio suitable for
789-
* folios that do not use PagePrivate/PagePrivate2.
789+
* folios that do not have private data.
790790
*
791791
* Folios are locked upon entry and exit.
792792
*/

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)