Skip to content

Commit 99bff93

Browse files
committed
netfs, mm: Add set/end/wait_on_page_fscache() aliases
Add set/end/wait_on_page_fscache() as aliases of set/end/wait_page_private_2(). These allow a page to marked with PG_fscache, the flag to be removed and waiters woken and waiting for the flag to be cleared. A ref on the page is also taken and dropped. [Linus suggested putting the fscache-themed functions into the caching-specific headers rather than pagemap.h[1]] Changes: v5: - Mirror the changes to the core routines[2]. Signed-off-by: David Howells <dhowells@redhat.com> Tested-by: Jeff Layton <jlayton@kernel.org> Tested-by: Dave Wysochanski <dwysocha@redhat.com> Tested-By: Marc Dionne <marc.dionne@auristor.com> cc: Linus Torvalds <torvalds@linux-foundation.org> cc: Matthew Wilcox <willy@infradead.org> cc: linux-mm@kvack.org cc: linux-cachefs@redhat.com cc: linux-afs@lists.infradead.org cc: linux-nfs@vger.kernel.org cc: linux-cifs@vger.kernel.org cc: ceph-devel@vger.kernel.org cc: v9fs-developer@lists.sourceforge.net cc: linux-fsdevel@vger.kernel.org Link: https://lore.kernel.org/r/1330473.1612974547@warthog.procyon.org.uk/ Link: https://lore.kernel.org/r/CAHk-=wjgA-74ddehziVk=XAEMTKswPu1Yw4uaro1R3ibs27ztw@mail.gmail.com/ [1] Link: https://lore.kernel.org/r/161340393568.1303470.4997526899111310530.stgit@warthog.procyon.org.uk/ # v3 Link: https://lore.kernel.org/r/161539536093.286939.5076448803512118764.stgit@warthog.procyon.org.uk/ # v4 Link: https://lore.kernel.org/r/2499407.1616505440@warthog.procyon.org.uk/ [2] Link: https://lore.kernel.org/r/161653793873.2770958.12157243390965814502.stgit@warthog.procyon.org.uk/ # v5 Link: https://lore.kernel.org/r/161789075327.6155.7432127924219092385.stgit@warthog.procyon.org.uk/ # v6
1 parent b533a83 commit 99bff93

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

include/linux/netfs.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,61 @@
2626
#define TestSetPageFsCache(page) TestSetPagePrivate2((page))
2727
#define TestClearPageFsCache(page) TestClearPagePrivate2((page))
2828

29+
/**
30+
* set_page_fscache - Set PG_fscache on a page and take a ref
31+
* @page: The page.
32+
*
33+
* Set the PG_fscache (PG_private_2) flag on a page and take the reference
34+
* needed for the VM to handle its lifetime correctly. This sets the flag and
35+
* takes the reference unconditionally, so care must be taken not to set the
36+
* flag again if it's already set.
37+
*/
38+
static inline void set_page_fscache(struct page *page)
39+
{
40+
set_page_private_2(page);
41+
}
42+
43+
/**
44+
* end_page_fscache - Clear PG_fscache and release any waiters
45+
* @page: The page
46+
*
47+
* Clear the PG_fscache (PG_private_2) bit on a page and wake up any sleepers
48+
* waiting for this. The page ref held for PG_private_2 being set is released.
49+
*
50+
* This is, for example, used when a netfs page is being written to a local
51+
* disk cache, thereby allowing writes to the cache for the same page to be
52+
* serialised.
53+
*/
54+
static inline void end_page_fscache(struct page *page)
55+
{
56+
end_page_private_2(page);
57+
}
58+
59+
/**
60+
* wait_on_page_fscache - Wait for PG_fscache to be cleared on a page
61+
* @page: The page to wait on
62+
*
63+
* Wait for PG_fscache (aka PG_private_2) to be cleared on a page.
64+
*/
65+
static inline void wait_on_page_fscache(struct page *page)
66+
{
67+
wait_on_page_private_2(page);
68+
}
69+
70+
/**
71+
* wait_on_page_fscache_killable - Wait for PG_fscache to be cleared on a page
72+
* @page: The page to wait on
73+
*
74+
* Wait for PG_fscache (aka PG_private_2) to be cleared on a page or until a
75+
* fatal signal is received by the calling task.
76+
*
77+
* Return:
78+
* - 0 if successful.
79+
* - -EINTR if a fatal signal was encountered.
80+
*/
81+
static inline int wait_on_page_fscache_killable(struct page *page)
82+
{
83+
return wait_on_page_private_2_killable(page);
84+
}
85+
2986
#endif /* _LINUX_NETFS_H */

0 commit comments

Comments
 (0)