Skip to content

Commit 2e9d7e4

Browse files
committed
mm: Remove the PG_fscache alias for PG_private_2
Remove the PG_fscache alias for PG_private_2 and use the latter directly. Use of this flag for marking pages undergoing writing to the cache should be considered deprecated and the folios should be marked dirty instead and the write done in ->writepages(). Note that PG_private_2 itself should be considered deprecated and up for future removal by the MM folks too. Signed-off-by: David Howells <dhowells@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org> cc: Matthew Wilcox (Oracle) <willy@infradead.org> cc: Ilya Dryomov <idryomov@gmail.com> cc: Xiubo Li <xiubli@redhat.com> cc: Steve French <sfrench@samba.org> cc: Paulo Alcantara <pc@manguebit.com> cc: Ronnie Sahlberg <ronniesahlberg@gmail.com> cc: Shyam Prasad N <sprasad@microsoft.com> cc: Tom Talpey <tom@talpey.com> cc: Bharath SM <bharathsm@microsoft.com> cc: Trond Myklebust <trond.myklebust@hammerspace.com> cc: Anna Schumaker <anna@kernel.org> cc: netfs@lists.linux.dev cc: ceph-devel@vger.kernel.org cc: linux-cifs@vger.kernel.org cc: linux-nfs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org
1 parent 2ff1e97 commit 2e9d7e4

10 files changed

Lines changed: 33 additions & 104 deletions

File tree

fs/ceph/addr.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ const struct netfs_request_ops ceph_netfs_ops = {
500500
#ifdef CONFIG_CEPH_FSCACHE
501501
static void ceph_set_page_fscache(struct page *page)
502502
{
503-
set_page_fscache(page);
503+
folio_start_private_2(page_folio(page)); /* [DEPRECATED] */
504504
}
505505

506506
static void ceph_fscache_write_terminated(void *priv, ssize_t error, bool was_async)
@@ -800,7 +800,7 @@ static int ceph_writepage(struct page *page, struct writeback_control *wbc)
800800
return AOP_WRITEPAGE_ACTIVATE;
801801
}
802802

803-
wait_on_page_fscache(page);
803+
folio_wait_private_2(page_folio(page)); /* [DEPRECATED] */
804804

805805
err = writepage_nounlock(page, wbc);
806806
if (err == -ERESTARTSYS) {
@@ -1075,15 +1075,16 @@ static int ceph_writepages_start(struct address_space *mapping,
10751075
unlock_page(page);
10761076
break;
10771077
}
1078-
if (PageWriteback(page) || PageFsCache(page)) {
1078+
if (PageWriteback(page) ||
1079+
PagePrivate2(page) /* [DEPRECATED] */) {
10791080
if (wbc->sync_mode == WB_SYNC_NONE) {
10801081
doutc(cl, "%p under writeback\n", page);
10811082
unlock_page(page);
10821083
continue;
10831084
}
10841085
doutc(cl, "waiting on writeback %p\n", page);
10851086
wait_on_page_writeback(page);
1086-
wait_on_page_fscache(page);
1087+
folio_wait_private_2(page_folio(page)); /* [DEPRECATED] */
10871088
}
10881089

10891090
if (!clear_page_dirty_for_io(page)) {
@@ -1513,7 +1514,7 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping,
15131514
if (r < 0)
15141515
return r;
15151516

1516-
folio_wait_fscache(folio);
1517+
folio_wait_private_2(folio); /* [DEPRECATED] */
15171518
WARN_ON_ONCE(!folio_test_locked(folio));
15181519
*pagep = &folio->page;
15191520
return 0;

fs/netfs/buffered_read.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void netfs_rreq_unlock_folios(struct netfs_io_request *rreq)
7070
if (!folio_started && test_bit(NETFS_SREQ_COPY_TO_CACHE,
7171
&subreq->flags)) {
7272
trace_netfs_folio(folio, netfs_folio_trace_copy_to_cache);
73-
folio_start_fscache(folio);
73+
folio_start_private_2(folio);
7474
folio_started = true;
7575
}
7676
} else {
@@ -506,7 +506,7 @@ int netfs_write_begin(struct netfs_inode *ctx,
506506

507507
have_folio:
508508
if (test_bit(NETFS_ICTX_USE_PGPRIV2, &ctx->flags)) {
509-
ret = folio_wait_fscache_killable(folio);
509+
ret = folio_wait_private_2_killable(folio);
510510
if (ret < 0)
511511
goto error;
512512
}

fs/netfs/fscache_io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void __fscache_clear_page_bits(struct address_space *mapping,
183183

184184
rcu_read_lock();
185185
xas_for_each(&xas, page, last) {
186-
end_page_fscache(page);
186+
folio_end_private_2(page_folio(page));
187187
}
188188
rcu_read_unlock();
189189
}

fs/netfs/io.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ static void netfs_rreq_unmark_after_write(struct netfs_io_request *rreq,
129129
continue;
130130
unlocked = folio_next_index(folio) - 1;
131131
trace_netfs_folio(folio, netfs_folio_trace_end_copy);
132-
folio_end_fscache(folio);
132+
folio_end_private_2(folio);
133133
have_unlocked = true;
134134
}
135135
}

fs/nfs/file.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ static void nfs_invalidate_folio(struct folio *folio, size_t offset,
433433
return;
434434
/* Cancel any unstarted writes on this page */
435435
nfs_wb_folio_cancel(inode, folio);
436-
folio_wait_fscache(folio);
436+
folio_wait_private_2(folio); /* [DEPRECATED] */
437437
trace_nfs_invalidate_folio(inode, folio);
438438
}
439439

@@ -500,7 +500,7 @@ static int nfs_launder_folio(struct folio *folio)
500500
dfprintk(PAGECACHE, "NFS: launder_folio(%ld, %llu)\n",
501501
inode->i_ino, folio_pos(folio));
502502

503-
folio_wait_fscache(folio);
503+
folio_wait_private_2(folio); /* [DEPRECATED] */
504504
ret = nfs_wb_folio(inode, folio);
505505
trace_nfs_launder_folio_done(inode, folio, ret);
506506
return ret;
@@ -593,8 +593,8 @@ static vm_fault_t nfs_vm_page_mkwrite(struct vm_fault *vmf)
593593
sb_start_pagefault(inode->i_sb);
594594

595595
/* make sure the cache has finished storing the page */
596-
if (folio_test_fscache(folio) &&
597-
folio_wait_fscache_killable(folio) < 0) {
596+
if (folio_test_private_2(folio) && /* [DEPRECATED] */
597+
folio_wait_private_2_killable(folio) < 0) {
598598
ret = VM_FAULT_RETRY;
599599
goto out;
600600
}

fs/nfs/fscache.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ extern int nfs_netfs_read_folio(struct file *file, struct folio *folio);
103103

104104
static inline bool nfs_fscache_release_folio(struct folio *folio, gfp_t gfp)
105105
{
106-
if (folio_test_fscache(folio)) {
106+
if (folio_test_private_2(folio)) { /* [DEPRECATED] */
107107
if (current_is_kswapd() || !(gfp & __GFP_FS))
108108
return false;
109-
folio_wait_fscache(folio);
109+
folio_wait_private_2(folio);
110110
}
111111
fscache_note_page_release(netfs_i_cookie(netfs_inode(folio->mapping->host)));
112112
return true;

fs/nfs/write.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2120,10 +2120,10 @@ int nfs_migrate_folio(struct address_space *mapping, struct folio *dst,
21202120
if (folio_test_private(src))
21212121
return -EBUSY;
21222122

2123-
if (folio_test_fscache(src)) {
2123+
if (folio_test_private_2(src)) { /* [DEPRECATED] */
21242124
if (mode == MIGRATE_ASYNC)
21252125
return -EBUSY;
2126-
folio_wait_fscache(src);
2126+
folio_wait_private_2(src);
21272127
}
21282128

21292129
return migrate_folio(mapping, dst, src, mode);

fs/smb/client/file.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,12 +3032,12 @@ static ssize_t cifs_writepages_begin(struct address_space *mapping,
30323032
}
30333033

30343034
if (folio_test_writeback(folio) ||
3035-
folio_test_fscache(folio)) {
3035+
folio_test_private_2(folio)) { /* [DEPRECATED] */
30363036
folio_unlock(folio);
30373037
if (wbc->sync_mode != WB_SYNC_NONE) {
30383038
folio_wait_writeback(folio);
30393039
#ifdef CONFIG_CIFS_FSCACHE
3040-
folio_wait_fscache(folio);
3040+
folio_wait_private_2(folio);
30413041
#endif
30423042
goto lock_again;
30433043
}
@@ -4510,8 +4510,8 @@ static vm_fault_t cifs_page_mkwrite(struct vm_fault *vmf)
45104510
* be modified. We then assume the entire folio will need writing back.
45114511
*/
45124512
#ifdef CONFIG_CIFS_FSCACHE
4513-
if (folio_test_fscache(folio) &&
4514-
folio_wait_fscache_killable(folio) < 0)
4513+
if (folio_test_private_2(folio) && /* [DEPRECATED] */
4514+
folio_wait_private_2_killable(folio) < 0)
45154515
return VM_FAULT_RETRY;
45164516
#endif
45174517

@@ -4977,10 +4977,10 @@ static bool cifs_release_folio(struct folio *folio, gfp_t gfp)
49774977
{
49784978
if (folio_test_private(folio))
49794979
return 0;
4980-
if (folio_test_fscache(folio)) {
4980+
if (folio_test_private_2(folio)) { /* [DEPRECATED] */
49814981
if (current_is_kswapd() || !(gfp & __GFP_FS))
49824982
return false;
4983-
folio_wait_fscache(folio);
4983+
folio_wait_private_2(folio);
49844984
}
49854985
fscache_note_page_release(cifs_inode_cookie(folio->mapping->host));
49864986
return true;
@@ -4989,7 +4989,7 @@ static bool cifs_release_folio(struct folio *folio, gfp_t gfp)
49894989
static void cifs_invalidate_folio(struct folio *folio, size_t offset,
49904990
size_t length)
49914991
{
4992-
folio_wait_fscache(folio);
4992+
folio_wait_private_2(folio); /* [DEPRECATED] */
49934993
}
49944994

49954995
static int cifs_launder_folio(struct folio *folio)
@@ -5009,7 +5009,7 @@ static int cifs_launder_folio(struct folio *folio)
50095009
if (folio_clear_dirty_for_io(folio))
50105010
rc = cifs_writepage_locked(&folio->page, &wbc);
50115011

5012-
folio_wait_fscache(folio);
5012+
folio_wait_private_2(folio); /* [DEPRECATED] */
50135013
return rc;
50145014
}
50155015

include/linux/netfs.h

Lines changed: 4 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -21,94 +21,22 @@
2121

2222
enum netfs_sreq_ref_trace;
2323

24-
/*
25-
* Overload PG_private_2 to give us PG_fscache - this is used to indicate that
26-
* a page is currently backed by a local disk cache
27-
*/
28-
#define folio_test_fscache(folio) folio_test_private_2(folio)
29-
#define PageFsCache(page) PagePrivate2((page))
30-
#define SetPageFsCache(page) SetPagePrivate2((page))
31-
#define ClearPageFsCache(page) ClearPagePrivate2((page))
32-
#define TestSetPageFsCache(page) TestSetPagePrivate2((page))
33-
#define TestClearPageFsCache(page) TestClearPagePrivate2((page))
34-
3524
/**
36-
* folio_start_fscache - Start an fscache write on a folio.
25+
* folio_start_private_2 - Start an fscache write on a folio. [DEPRECATED]
3726
* @folio: The folio.
3827
*
3928
* Call this function before writing a folio to a local cache. Starting a
4029
* second write before the first one finishes is not allowed.
30+
*
31+
* Note that this should no longer be used.
4132
*/
42-
static inline void folio_start_fscache(struct folio *folio)
33+
static inline void folio_start_private_2(struct folio *folio)
4334
{
4435
VM_BUG_ON_FOLIO(folio_test_private_2(folio), folio);
4536
folio_get(folio);
4637
folio_set_private_2(folio);
4738
}
4839

49-
/**
50-
* folio_end_fscache - End an fscache write on a folio.
51-
* @folio: The folio.
52-
*
53-
* Call this function after the folio has been written to the local cache.
54-
* This will wake any sleepers waiting on this folio.
55-
*/
56-
static inline void folio_end_fscache(struct folio *folio)
57-
{
58-
folio_end_private_2(folio);
59-
}
60-
61-
/**
62-
* folio_wait_fscache - Wait for an fscache write on this folio to end.
63-
* @folio: The folio.
64-
*
65-
* If this folio is currently being written to a local cache, wait for
66-
* the write to finish. Another write may start after this one finishes,
67-
* unless the caller holds the folio lock.
68-
*/
69-
static inline void folio_wait_fscache(struct folio *folio)
70-
{
71-
folio_wait_private_2(folio);
72-
}
73-
74-
/**
75-
* folio_wait_fscache_killable - Wait for an fscache write on this folio to end.
76-
* @folio: The folio.
77-
*
78-
* If this folio is currently being written to a local cache, wait
79-
* for the write to finish or for a fatal signal to be received.
80-
* Another write may start after this one finishes, unless the caller
81-
* holds the folio lock.
82-
*
83-
* Return:
84-
* - 0 if successful.
85-
* - -EINTR if a fatal signal was encountered.
86-
*/
87-
static inline int folio_wait_fscache_killable(struct folio *folio)
88-
{
89-
return folio_wait_private_2_killable(folio);
90-
}
91-
92-
static inline void set_page_fscache(struct page *page)
93-
{
94-
folio_start_fscache(page_folio(page));
95-
}
96-
97-
static inline void end_page_fscache(struct page *page)
98-
{
99-
folio_end_private_2(page_folio(page));
100-
}
101-
102-
static inline void wait_on_page_fscache(struct page *page)
103-
{
104-
folio_wait_private_2(page_folio(page));
105-
}
106-
107-
static inline int wait_on_page_fscache_killable(struct page *page)
108-
{
109-
return folio_wait_private_2_killable(page_folio(page));
110-
}
111-
11240
/* Marks used on xarray-based buffers */
11341
#define NETFS_BUF_PUT_MARK XA_MARK_0 /* - Page needs putting */
11442
#define NETFS_BUF_PAGECACHE_MARK XA_MARK_1 /* - Page needs wb/dirty flag wrangling */

mm/filemap.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,7 +1540,7 @@ EXPORT_SYMBOL(folio_end_private_2);
15401540
* folio_wait_private_2 - Wait for PG_private_2 to be cleared on a folio.
15411541
* @folio: The folio to wait on.
15421542
*
1543-
* Wait for PG_private_2 (aka PG_fscache) to be cleared on a folio.
1543+
* Wait for PG_private_2 to be cleared on a folio.
15441544
*/
15451545
void folio_wait_private_2(struct folio *folio)
15461546
{
@@ -1553,8 +1553,8 @@ EXPORT_SYMBOL(folio_wait_private_2);
15531553
* folio_wait_private_2_killable - Wait for PG_private_2 to be cleared on a folio.
15541554
* @folio: The folio to wait on.
15551555
*
1556-
* Wait for PG_private_2 (aka PG_fscache) to be cleared on a folio or until a
1557-
* fatal signal is received by the calling task.
1556+
* Wait for PG_private_2 to be cleared on a folio or until a fatal signal is
1557+
* received by the calling task.
15581558
*
15591559
* Return:
15601560
* - 0 if successful.

0 commit comments

Comments
 (0)