From: Jingbo Xu <jefflexu@linux.alibaba.com>
To: dhowells@redhat.com, jlayton@kernel.org,
linux-cachefs@redhat.com, linux-erofs@lists.ozlabs.org
Cc: linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org,
linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 8/9] fscache,netfs: move PageFsCache() family helpers to fscache.h
Date: Thu, 27 Oct 2022 16:35:46 +0800 [thread overview]
Message-ID: <20221027083547.46933-9-jefflexu@linux.alibaba.com> (raw)
In-Reply-To: <20221027083547.46933-1-jefflexu@linux.alibaba.com>
Later all structures transformed with "fscache_" prefix will be moved to
fscache.h from netfs.h, and then netfs.h will include fscache.h rather
than the other way around. If that's the case, the PageFsCache() family
helpers also needs to be moved to fscache.h, since end_page_fscache() is
referenced inside fscache.
Besides, it's also quite reasonable to move these helpers to fscache.h
given their names.
This is a cleanup without logic change.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
include/linux/fscache.h | 90 +++++++++++++++++++++++++++++++++++++++++
include/linux/netfs.h | 89 ----------------------------------------
2 files changed, 90 insertions(+), 89 deletions(-)
diff --git a/include/linux/fscache.h b/include/linux/fscache.h
index 9df2988be804..034d009c0de7 100644
--- a/include/linux/fscache.h
+++ b/include/linux/fscache.h
@@ -17,6 +17,7 @@
#include <linux/fs.h>
#include <linux/netfs.h>
#include <linux/writeback.h>
+#include <linux/pagemap.h>
#if defined(CONFIG_FSCACHE) || defined(CONFIG_FSCACHE_MODULE)
#define __fscache_available (1)
@@ -695,4 +696,93 @@ void fscache_note_page_release(struct fscache_cookie *cookie)
clear_bit(FSCACHE_COOKIE_NO_DATA_TO_READ, &cookie->flags);
}
+/*
+ * Overload PG_private_2 to give us PG_fscache - this is used to indicate that
+ * a page is currently backed by a local disk cache
+ */
+#define folio_test_fscache(folio) folio_test_private_2(folio)
+#define PageFsCache(page) PagePrivate2((page))
+#define SetPageFsCache(page) SetPagePrivate2((page))
+#define ClearPageFsCache(page) ClearPagePrivate2((page))
+#define TestSetPageFsCache(page) TestSetPagePrivate2((page))
+#define TestClearPageFsCache(page) TestClearPagePrivate2((page))
+
+/**
+ * folio_start_fscache - Start an fscache write on a folio.
+ * @folio: The folio.
+ *
+ * Call this function before writing a folio to a local cache. Starting a
+ * second write before the first one finishes is not allowed.
+ */
+static inline void folio_start_fscache(struct folio *folio)
+{
+ VM_BUG_ON_FOLIO(folio_test_private_2(folio), folio);
+ folio_get(folio);
+ folio_set_private_2(folio);
+}
+
+/**
+ * folio_end_fscache - End an fscache write on a folio.
+ * @folio: The folio.
+ *
+ * Call this function after the folio has been written to the local cache.
+ * This will wake any sleepers waiting on this folio.
+ */
+static inline void folio_end_fscache(struct folio *folio)
+{
+ folio_end_private_2(folio);
+}
+
+/**
+ * folio_wait_fscache - Wait for an fscache write on this folio to end.
+ * @folio: The folio.
+ *
+ * If this folio is currently being written to a local cache, wait for
+ * the write to finish. Another write may start after this one finishes,
+ * unless the caller holds the folio lock.
+ */
+static inline void folio_wait_fscache(struct folio *folio)
+{
+ folio_wait_private_2(folio);
+}
+
+/**
+ * folio_wait_fscache_killable - Wait for an fscache write on this folio to end.
+ * @folio: The folio.
+ *
+ * If this folio is currently being written to a local cache, wait
+ * for the write to finish or for a fatal signal to be received.
+ * Another write may start after this one finishes, unless the caller
+ * holds the folio lock.
+ *
+ * Return:
+ * - 0 if successful.
+ * - -EINTR if a fatal signal was encountered.
+ */
+static inline int folio_wait_fscache_killable(struct folio *folio)
+{
+ return folio_wait_private_2_killable(folio);
+}
+
+static inline void set_page_fscache(struct page *page)
+{
+ folio_start_fscache(page_folio(page));
+}
+
+static inline void end_page_fscache(struct page *page)
+{
+ folio_end_private_2(page_folio(page));
+}
+
+static inline void wait_on_page_fscache(struct page *page)
+{
+ folio_wait_private_2(page_folio(page));
+}
+
+static inline int wait_on_page_fscache_killable(struct page *page)
+{
+ return folio_wait_private_2_killable(page_folio(page));
+}
+
+
#endif /* _LINUX_FSCACHE_H */
diff --git a/include/linux/netfs.h b/include/linux/netfs.h
index 146a13e6a9d2..2ad4e1e88106 100644
--- a/include/linux/netfs.h
+++ b/include/linux/netfs.h
@@ -16,98 +16,9 @@
#include <linux/workqueue.h>
#include <linux/fs.h>
-#include <linux/pagemap.h>
enum netfs_sreq_ref_trace;
-/*
- * Overload PG_private_2 to give us PG_fscache - this is used to indicate that
- * a page is currently backed by a local disk cache
- */
-#define folio_test_fscache(folio) folio_test_private_2(folio)
-#define PageFsCache(page) PagePrivate2((page))
-#define SetPageFsCache(page) SetPagePrivate2((page))
-#define ClearPageFsCache(page) ClearPagePrivate2((page))
-#define TestSetPageFsCache(page) TestSetPagePrivate2((page))
-#define TestClearPageFsCache(page) TestClearPagePrivate2((page))
-
-/**
- * folio_start_fscache - Start an fscache write on a folio.
- * @folio: The folio.
- *
- * Call this function before writing a folio to a local cache. Starting a
- * second write before the first one finishes is not allowed.
- */
-static inline void folio_start_fscache(struct folio *folio)
-{
- VM_BUG_ON_FOLIO(folio_test_private_2(folio), folio);
- folio_get(folio);
- folio_set_private_2(folio);
-}
-
-/**
- * folio_end_fscache - End an fscache write on a folio.
- * @folio: The folio.
- *
- * Call this function after the folio has been written to the local cache.
- * This will wake any sleepers waiting on this folio.
- */
-static inline void folio_end_fscache(struct folio *folio)
-{
- folio_end_private_2(folio);
-}
-
-/**
- * folio_wait_fscache - Wait for an fscache write on this folio to end.
- * @folio: The folio.
- *
- * If this folio is currently being written to a local cache, wait for
- * the write to finish. Another write may start after this one finishes,
- * unless the caller holds the folio lock.
- */
-static inline void folio_wait_fscache(struct folio *folio)
-{
- folio_wait_private_2(folio);
-}
-
-/**
- * folio_wait_fscache_killable - Wait for an fscache write on this folio to end.
- * @folio: The folio.
- *
- * If this folio is currently being written to a local cache, wait
- * for the write to finish or for a fatal signal to be received.
- * Another write may start after this one finishes, unless the caller
- * holds the folio lock.
- *
- * Return:
- * - 0 if successful.
- * - -EINTR if a fatal signal was encountered.
- */
-static inline int folio_wait_fscache_killable(struct folio *folio)
-{
- return folio_wait_private_2_killable(folio);
-}
-
-static inline void set_page_fscache(struct page *page)
-{
- folio_start_fscache(page_folio(page));
-}
-
-static inline void end_page_fscache(struct page *page)
-{
- folio_end_private_2(page_folio(page));
-}
-
-static inline void wait_on_page_fscache(struct page *page)
-{
- folio_wait_private_2(page_folio(page));
-}
-
-static inline int wait_on_page_fscache_killable(struct page *page)
-{
- return folio_wait_private_2_killable(page_folio(page));
-}
-
enum fscache_io_source {
FSCACHE_FILL_WITH_ZEROES,
FSCACHE_DOWNLOAD_FROM_SERVER,
--
2.19.1.6.gb485710b
next prev parent reply other threads:[~2022-10-27 8:36 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-27 8:35 [PATCH 0/9] fscache,netfs: decouple raw fscache APIs from libnetfs Jingbo Xu
2022-10-27 8:35 ` [PATCH 1/9] fscache: decouple prepare_read() from netfs_io_subrequest Jingbo Xu
2022-10-27 8:35 ` [PATCH 2/9] fscache,netfs: rename netfs_io_source as fscache_io_source Jingbo Xu
2022-10-27 13:04 ` David Howells
2022-10-27 8:35 ` [PATCH 3/9] fscache,netfs: rename netfs_io_terminated_t as fscache_io_terminated_t Jingbo Xu
2022-10-27 13:06 ` David Howells
2022-10-27 8:35 ` [PATCH 4/9] fscache,netfs: rename netfs_read_from_hole as fscache_read_from_hole Jingbo Xu
2022-10-27 13:09 ` David Howells
2022-10-27 8:35 ` [PATCH 5/9] fscache,netfs: rename netfs_cache_ops as fscache_ops Jingbo Xu
2022-10-27 13:10 ` David Howells
2022-10-27 8:35 ` [PATCH 6/9] fscache,netfs: rename netfs_cache_resources as fscache_resources Jingbo Xu
2022-10-27 13:08 ` David Howells
2022-10-27 8:35 ` [PATCH 7/9] fscache,netfs: define flags for prepare_read() Jingbo Xu
2022-10-27 13:11 ` David Howells
2022-10-27 8:35 ` Jingbo Xu [this message]
2022-10-27 13:06 ` [PATCH 8/9] fscache,netfs: move PageFsCache() family helpers to fscache.h David Howells
2022-10-27 8:35 ` [PATCH 9/9] fscache,netfs: move "fscache_" prefixed structures " Jingbo Xu
2022-10-27 13:13 ` David Howells
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221027083547.46933-9-jefflexu@linux.alibaba.com \
--to=jefflexu@linux.alibaba.com \
--cc=dhowells@redhat.com \
--cc=jlayton@kernel.org \
--cc=linux-afs@lists.infradead.org \
--cc=linux-cachefs@redhat.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-erofs@lists.ozlabs.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox