[9/9] fscache,netfs: move "fscache_" prefixed structures to fscache.h
Commit Message
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(-)
Comments
Hi Jingbo,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on xiang-erofs/dev-test]
[also build test ERROR on trondmy-nfs/linux-next cifs/for-next linus/master v6.1-rc2 next-20221027]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Jingbo-Xu/fscache-netfs-decouple-raw-fscache-APIs-from-libnetfs/20221027-163946
base: https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git dev-test
patch link: https://lore.kernel.org/r/20221027083547.46933-10-jefflexu%40linux.alibaba.com
patch subject: [PATCH 9/9] fscache,netfs: move "fscache_" prefixed structures to fscache.h
config: sh-allmodconfig
compiler: sh4-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/a3c5c0f70f13603ed27cc7f5245981eb46dad405
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Jingbo-Xu/fscache-netfs-decouple-raw-fscache-APIs-from-libnetfs/20221027-163946
git checkout a3c5c0f70f13603ed27cc7f5245981eb46dad405
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=sh SHELL=/bin/bash fs/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
fs/fscache/stats.c: In function 'fscache_stats_show':
>> fs/fscache/stats.c:100:9: error: implicit declaration of function 'netfs_stats_show' [-Werror=implicit-function-declaration]
100 | netfs_stats_show(m);
| ^~~~~~~~~~~~~~~~
cc1: some warnings being treated as errors
vim +/netfs_stats_show +100 fs/fscache/stats.c
8e7a867bb7309fb David Howells 2021-10-20 51
1e1236b841166f1 David Howells 2021-10-20 52 /*
1e1236b841166f1 David Howells 2021-10-20 53 * display the general statistics
1e1236b841166f1 David Howells 2021-10-20 54 */
1e1236b841166f1 David Howells 2021-10-20 55 int fscache_stats_show(struct seq_file *m, void *v)
1e1236b841166f1 David Howells 2021-10-20 56 {
1e1236b841166f1 David Howells 2021-10-20 57 seq_puts(m, "FS-Cache statistics\n");
7f3283aba39a0f3 David Howells 2021-10-20 58 seq_printf(m, "Cookies: n=%d v=%d vcol=%u voom=%u\n",
7f3283aba39a0f3 David Howells 2021-10-20 59 atomic_read(&fscache_n_cookies),
62ab63352350e88 David Howells 2021-10-20 60 atomic_read(&fscache_n_volumes),
62ab63352350e88 David Howells 2021-10-20 61 atomic_read(&fscache_n_volumes_collision),
62ab63352350e88 David Howells 2021-10-20 62 atomic_read(&fscache_n_volumes_nomem)
62ab63352350e88 David Howells 2021-10-20 63 );
1e1236b841166f1 David Howells 2021-10-20 64
7f3283aba39a0f3 David Howells 2021-10-20 65 seq_printf(m, "Acquire: n=%u ok=%u oom=%u\n",
7f3283aba39a0f3 David Howells 2021-10-20 66 atomic_read(&fscache_n_acquires),
7f3283aba39a0f3 David Howells 2021-10-20 67 atomic_read(&fscache_n_acquires_ok),
7f3283aba39a0f3 David Howells 2021-10-20 68 atomic_read(&fscache_n_acquires_oom));
7f3283aba39a0f3 David Howells 2021-10-20 69
12bb21a29c19aae David Howells 2021-10-20 70 seq_printf(m, "LRU : n=%u exp=%u rmv=%u drp=%u at=%ld\n",
12bb21a29c19aae David Howells 2021-10-20 71 atomic_read(&fscache_n_cookies_lru),
12bb21a29c19aae David Howells 2021-10-20 72 atomic_read(&fscache_n_cookies_lru_expired),
12bb21a29c19aae David Howells 2021-10-20 73 atomic_read(&fscache_n_cookies_lru_removed),
12bb21a29c19aae David Howells 2021-10-20 74 atomic_read(&fscache_n_cookies_lru_dropped),
12bb21a29c19aae David Howells 2021-10-20 75 timer_pending(&fscache_cookie_lru_timer) ?
12bb21a29c19aae David Howells 2021-10-20 76 fscache_cookie_lru_timer.expires - jiffies : 0);
12bb21a29c19aae David Howells 2021-10-20 77
d24af13e2e2358a David Howells 2021-10-20 78 seq_printf(m, "Invals : n=%u\n",
d24af13e2e2358a David Howells 2021-10-20 79 atomic_read(&fscache_n_invalidates));
d24af13e2e2358a David Howells 2021-10-20 80
16a96bdf92d5af0 David Howells 2021-10-20 81 seq_printf(m, "Updates: n=%u rsz=%u rsn=%u\n",
16a96bdf92d5af0 David Howells 2021-10-20 82 atomic_read(&fscache_n_updates),
16a96bdf92d5af0 David Howells 2021-10-20 83 atomic_read(&fscache_n_resizes),
16a96bdf92d5af0 David Howells 2021-10-20 84 atomic_read(&fscache_n_resizes_null));
7f3283aba39a0f3 David Howells 2021-10-20 85
7f3283aba39a0f3 David Howells 2021-10-20 86 seq_printf(m, "Relinqs: n=%u rtr=%u drop=%u\n",
7f3283aba39a0f3 David Howells 2021-10-20 87 atomic_read(&fscache_n_relinquishes),
7f3283aba39a0f3 David Howells 2021-10-20 88 atomic_read(&fscache_n_relinquishes_retire),
7f3283aba39a0f3 David Howells 2021-10-20 89 atomic_read(&fscache_n_relinquishes_dropped));
7f3283aba39a0f3 David Howells 2021-10-20 90
9f08ebc3438baaa David Howells 2021-10-22 91 seq_printf(m, "NoSpace: nwr=%u ncr=%u cull=%u\n",
3929eca769b5a23 David Howells 2021-10-21 92 atomic_read(&fscache_n_no_write_space),
9f08ebc3438baaa David Howells 2021-10-22 93 atomic_read(&fscache_n_no_create_space),
9f08ebc3438baaa David Howells 2021-10-22 94 atomic_read(&fscache_n_culled));
3929eca769b5a23 David Howells 2021-10-21 95
8e7a867bb7309fb David Howells 2021-10-20 96 seq_printf(m, "IO : rd=%u wr=%u\n",
8e7a867bb7309fb David Howells 2021-10-20 97 atomic_read(&fscache_n_read),
8e7a867bb7309fb David Howells 2021-10-20 98 atomic_read(&fscache_n_write));
8e7a867bb7309fb David Howells 2021-10-20 99
1e1236b841166f1 David Howells 2021-10-20 @100 netfs_stats_show(m);
Jingbo Xu <jefflexu@linux.alibaba.com> wrote:
> 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>
Please don't do that. fscache is based on netfslib, not the other way around.
If anything, I'm tempted to move fscache into netfslib.
David
@@ -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>
@@ -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);
@@ -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
@@ -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
@@ -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 *);