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 9/9] fscache,netfs: move "fscache_" prefixed structures to fscache.h
Date: Thu, 27 Oct 2022 16:35:47 +0800 [thread overview]
Message-ID: <20221027083547.46933-10-jefflexu@linux.alibaba.com> (raw)
In-Reply-To: <20221027083547.46933-1-jefflexu@linux.alibaba.com>
Since all related structures has been transformed with "fscache_"
prefix, move all these structures to fscache.h as a final cleanup.
Besides, make netfs.h include fscache.h rather than the other way
around. This is an intuitive change since libnetfs lives one layer
above fscache, accessing backing files with facache.
This is a cleanup without logic change.
Signed-off-by: Jingbo Xu <jefflexu@linux.alibaba.com>
---
fs/afs/internal.h | 2 +-
fs/erofs/fscache.c | 1 +
fs/nfs/fscache.h | 2 +-
include/linux/fscache.h | 80 ++++++++++++++++++++++++++++++++++++++++-
include/linux/netfs.h | 80 +----------------------------------------
5 files changed, 83 insertions(+), 82 deletions(-)
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 723d162078a3..5d1314265e3d 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -14,7 +14,7 @@
#include <linux/key.h>
#include <linux/workqueue.h>
#include <linux/sched.h>
-#include <linux/fscache.h>
+#include <linux/netfs.h>
#include <linux/backing-dev.h>
#include <linux/uuid.h>
#include <linux/mm_types.h>
diff --git a/fs/erofs/fscache.c b/fs/erofs/fscache.c
index e30a42a35ae7..69531be66b28 100644
--- a/fs/erofs/fscache.c
+++ b/fs/erofs/fscache.c
@@ -4,6 +4,7 @@
* Copyright (C) 2022, Bytedance Inc. All rights reserved.
*/
#include <linux/fscache.h>
+#include <linux/netfs.h>
#include "internal.h"
static DEFINE_MUTEX(erofs_domain_list_lock);
diff --git a/fs/nfs/fscache.h b/fs/nfs/fscache.h
index 2a37af880978..a0715f83a529 100644
--- a/fs/nfs/fscache.h
+++ b/fs/nfs/fscache.h
@@ -12,7 +12,7 @@
#include <linux/nfs_fs.h>
#include <linux/nfs_mount.h>
#include <linux/nfs4_mount.h>
-#include <linux/fscache.h>
+#include <linux/netfs.h>
#include <linux/iversion.h>
#ifdef CONFIG_NFS_FSCACHE
diff --git a/include/linux/fscache.h b/include/linux/fscache.h
index 034d009c0de7..457226a396d2 100644
--- a/include/linux/fscache.h
+++ b/include/linux/fscache.h
@@ -15,7 +15,6 @@
#define _LINUX_FSCACHE_H
#include <linux/fs.h>
-#include <linux/netfs.h>
#include <linux/writeback.h>
#include <linux/pagemap.h>
@@ -151,6 +150,85 @@ struct fscache_cookie {
#define FSCACHE_REQ_COPY_TO_CACHE 0 /* Set if should copy the data to the cache */
#define FSCACHE_REQ_ONDEMAND 1 /* Set if it's from on-demand read mode */
+enum fscache_io_source {
+ FSCACHE_FILL_WITH_ZEROES,
+ FSCACHE_DOWNLOAD_FROM_SERVER,
+ FSCACHE_READ_FROM_CACHE,
+ FSCACHE_INVALID_READ,
+} __mode(byte);
+
+typedef void (*fscache_io_terminated_t)(void *priv, ssize_t transferred_or_error,
+ bool was_async);
+
+/*
+ * Resources required to do operations on a cache.
+ */
+struct fscache_resources {
+ const struct fscache_ops *ops;
+ void *cache_priv;
+ void *cache_priv2;
+ unsigned int debug_id; /* Cookie debug ID */
+ unsigned int inval_counter; /* object->inval_counter at begin_op */
+};
+
+/*
+ * How to handle reading from a hole.
+ */
+enum fscache_read_from_hole {
+ FSCACHE_READ_HOLE_IGNORE,
+ FSCACHE_READ_HOLE_CLEAR,
+ FSCACHE_READ_HOLE_FAIL,
+};
+
+/*
+ * Table of operations for access to a cache. This is obtained by
+ * rreq->ops->begin_cache_operation().
+ */
+struct fscache_ops {
+ /* End an operation */
+ void (*end_operation)(struct fscache_resources *cres);
+
+ /* Read data from the cache */
+ int (*read)(struct fscache_resources *cres,
+ loff_t start_pos,
+ struct iov_iter *iter,
+ enum fscache_read_from_hole read_hole,
+ fscache_io_terminated_t term_func,
+ void *term_func_priv);
+
+ /* Write data to the cache */
+ int (*write)(struct fscache_resources *cres,
+ loff_t start_pos,
+ struct iov_iter *iter,
+ fscache_io_terminated_t term_func,
+ void *term_func_priv);
+
+ /* Expand readahead request */
+ void (*expand_readahead)(struct fscache_resources *cres,
+ loff_t *_start, size_t *_len, loff_t i_size);
+
+ /* Prepare a read operation, shortening it to a cached/uncached
+ * boundary as appropriate.
+ */
+ enum fscache_io_source (*prepare_read)(struct fscache_resources *cres,
+ loff_t *_start, size_t *_len,
+ unsigned long *_flags, loff_t i_size);
+
+ /* Prepare a write operation, working out what part of the write we can
+ * actually do.
+ */
+ int (*prepare_write)(struct fscache_resources *cres,
+ loff_t *_start, size_t *_len, loff_t i_size,
+ bool no_space_allocated_yet);
+
+ /* Query the occupancy of the cache in a region, returning where the
+ * next chunk of data starts and how long it is.
+ */
+ int (*query_occupancy)(struct fscache_resources *cres,
+ loff_t start, size_t len, size_t granularity,
+ loff_t *_data_start, size_t *_data_len);
+};
+
/*
* slow-path functions for when there is actually caching available, and the
* netfs does actually have a valid token
diff --git a/include/linux/netfs.h b/include/linux/netfs.h
index 2ad4e1e88106..1977f953633a 100644
--- a/include/linux/netfs.h
+++ b/include/linux/netfs.h
@@ -16,19 +16,10 @@
#include <linux/workqueue.h>
#include <linux/fs.h>
+#include <linux/fscache.h>
enum netfs_sreq_ref_trace;
-enum fscache_io_source {
- FSCACHE_FILL_WITH_ZEROES,
- FSCACHE_DOWNLOAD_FROM_SERVER,
- FSCACHE_READ_FROM_CACHE,
- FSCACHE_INVALID_READ,
-} __mode(byte);
-
-typedef void (*fscache_io_terminated_t)(void *priv, ssize_t transferred_or_error,
- bool was_async);
-
/*
* Per-inode context. This wraps the VFS inode.
*/
@@ -41,17 +32,6 @@ struct netfs_inode {
loff_t remote_i_size; /* Size of the remote file */
};
-/*
- * Resources required to do operations on a cache.
- */
-struct fscache_resources {
- const struct fscache_ops *ops;
- void *cache_priv;
- void *cache_priv2;
- unsigned int debug_id; /* Cookie debug ID */
- unsigned int inval_counter; /* object->inval_counter at begin_op */
-};
-
/*
* Descriptor for a single component subrequest.
*/
@@ -128,64 +108,6 @@ struct netfs_request_ops {
void (*done)(struct netfs_io_request *rreq);
};
-/*
- * How to handle reading from a hole.
- */
-enum fscache_read_from_hole {
- FSCACHE_READ_HOLE_IGNORE,
- FSCACHE_READ_HOLE_CLEAR,
- FSCACHE_READ_HOLE_FAIL,
-};
-
-/*
- * Table of operations for access to a cache. This is obtained by
- * rreq->ops->begin_cache_operation().
- */
-struct fscache_ops {
- /* End an operation */
- void (*end_operation)(struct fscache_resources *cres);
-
- /* Read data from the cache */
- int (*read)(struct fscache_resources *cres,
- loff_t start_pos,
- struct iov_iter *iter,
- enum fscache_read_from_hole read_hole,
- fscache_io_terminated_t term_func,
- void *term_func_priv);
-
- /* Write data to the cache */
- int (*write)(struct fscache_resources *cres,
- loff_t start_pos,
- struct iov_iter *iter,
- fscache_io_terminated_t term_func,
- void *term_func_priv);
-
- /* Expand readahead request */
- void (*expand_readahead)(struct fscache_resources *cres,
- loff_t *_start, size_t *_len, loff_t i_size);
-
- /* Prepare a read operation, shortening it to a cached/uncached
- * boundary as appropriate.
- */
- enum fscache_io_source (*prepare_read)(struct fscache_resources *cres,
- loff_t *_start, size_t *_len,
- unsigned long *_flags, loff_t i_size);
-
- /* Prepare a write operation, working out what part of the write we can
- * actually do.
- */
- int (*prepare_write)(struct fscache_resources *cres,
- loff_t *_start, size_t *_len, loff_t i_size,
- bool no_space_allocated_yet);
-
- /* Query the occupancy of the cache in a region, returning where the
- * next chunk of data starts and how long it is.
- */
- int (*query_occupancy)(struct fscache_resources *cres,
- loff_t start, size_t len, size_t granularity,
- loff_t *_data_start, size_t *_data_len);
-};
-
struct readahead_control;
void netfs_readahead(struct readahead_control *);
int netfs_read_folio(struct file *, struct folio *);
--
2.19.1.6.gb485710b
next prev parent reply other threads:[~2022-10-27 8:37 UTC|newest]
Thread overview: 19+ 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 8:35 ` [PATCH 3/9] fscache,netfs: rename netfs_io_terminated_t as fscache_io_terminated_t Jingbo Xu
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 8:35 ` [PATCH 5/9] fscache,netfs: rename netfs_cache_ops as fscache_ops Jingbo Xu
2022-10-27 8:35 ` [PATCH 6/9] fscache,netfs: rename netfs_cache_resources as fscache_resources Jingbo Xu
2022-10-27 8:35 ` [PATCH 7/9] fscache,netfs: define flags for prepare_read() Jingbo Xu
2022-10-27 8:35 ` [PATCH 8/9] fscache,netfs: move PageFsCache() family helpers to fscache.h Jingbo Xu
2022-10-27 8:35 ` Jingbo Xu [this message]
2022-10-27 11:52 ` [PATCH 9/9] fscache,netfs: move "fscache_" prefixed structures " kernel test robot
2022-10-27 13:04 ` [PATCH 2/9] fscache,netfs: rename netfs_io_source as fscache_io_source David Howells
2022-10-27 13:06 ` [PATCH 8/9] fscache,netfs: move PageFsCache() family helpers to fscache.h David Howells
2022-10-27 13:06 ` [PATCH 3/9] fscache,netfs: rename netfs_io_terminated_t as fscache_io_terminated_t David Howells
2022-10-27 13:08 ` [PATCH 6/9] fscache,netfs: rename netfs_cache_resources as fscache_resources David Howells
2022-10-27 13:09 ` [PATCH 4/9] fscache,netfs: rename netfs_read_from_hole as fscache_read_from_hole David Howells
2022-10-27 13:10 ` [PATCH 5/9] fscache,netfs: rename netfs_cache_ops as fscache_ops David Howells
2022-10-27 13:11 ` [PATCH 7/9] fscache,netfs: define flags for prepare_read() David Howells
2022-10-27 13:13 ` [PATCH 9/9] fscache,netfs: move "fscache_" prefixed structures to fscache.h 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-10-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;
as well as URLs for NNTP newsgroup(s).