Commit 6a19114b authored by David Howells's avatar David Howells
Browse files

netfs: Rename netfs_read_*request to netfs_io_*request



Rename netfs_read_*request to netfs_io_*request so that the same structures
can be used for the write helpers too.

perl -p -i -e 's/netfs_read_(request|subrequest)/netfs_io_$1/g' \
   `git grep -l 'netfs_read_\(sub\|\)request'`
perl -p -i -e 's/nr_rd_ops/nr_outstanding/g' \
   `git grep -l nr_rd_ops`
perl -p -i -e 's/nr_wr_ops/nr_copy_ops/g' \
   `git grep -l nr_wr_ops`
perl -p -i -e 's/netfs_read_source/netfs_io_source/g' \
   `git grep -l 'netfs_read_source'`
perl -p -i -e 's/netfs_io_request_ops/netfs_request_ops/g' \
   `git grep -l 'netfs_io_request_ops'`
perl -p -i -e 's/init_rreq/init_request/g' \
   `git grep -l 'init_rreq'`

Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com

Link: https://lore.kernel.org/r/164622988070.3564931.7089670190434315183.stgit@warthog.procyon.org.uk/ # v1
Link: https://lore.kernel.org/r/164678195157.1200972.366609966927368090.stgit@warthog.procyon.org.uk/ # v2
Link: https://lore.kernel.org/r/164692891535.2099075.18435198075367420588.stgit@warthog.procyon.org.uk/ # v3
parent 5ac417d2
Loading
Loading
Loading
Loading
+20 −20
Original line number Diff line number Diff line
@@ -71,11 +71,11 @@ Read Helper Functions
Three read helpers are provided::

	void netfs_readahead(struct readahead_control *ractl,
			     const struct netfs_read_request_ops *ops,
			     const struct netfs_request_ops *ops,
			     void *netfs_priv);
	int netfs_readpage(struct file *file,
			   struct folio *folio,
			   const struct netfs_read_request_ops *ops,
			   const struct netfs_request_ops *ops,
			   void *netfs_priv);
	int netfs_write_begin(struct file *file,
			      struct address_space *mapping,
@@ -84,7 +84,7 @@ Three read helpers are provided::
			      unsigned int flags,
			      struct folio **_folio,
			      void **_fsdata,
			      const struct netfs_read_request_ops *ops,
			      const struct netfs_request_ops *ops,
			      void *netfs_priv);

Each corresponds to a VM operation, with the addition of a couple of parameters
@@ -116,7 +116,7 @@ occurs, the request will get partially completed if sufficient data is read.

Additionally, there is::

  * void netfs_subreq_terminated(struct netfs_read_subrequest *subreq,
  * void netfs_subreq_terminated(struct netfs_io_subrequest *subreq,
				 ssize_t transferred_or_error,
				 bool was_async);

@@ -132,7 +132,7 @@ Read Helper Structures
The read helpers make use of a couple of structures to maintain the state of
the read.  The first is a structure that manages a read request as a whole::

	struct netfs_read_request {
	struct netfs_io_request {
		struct inode		*inode;
		struct address_space	*mapping;
		struct netfs_cache_resources cache_resources;
@@ -140,7 +140,7 @@ the read. The first is a structure that manages a read request as a whole::
		loff_t			start;
		size_t			len;
		loff_t			i_size;
		const struct netfs_read_request_ops *netfs_ops;
		const struct netfs_request_ops *netfs_ops;
		unsigned int		debug_id;
		...
	};
@@ -187,8 +187,8 @@ The above fields are the ones the netfs can use. They are:
The second structure is used to manage individual slices of the overall read
request::

	struct netfs_read_subrequest {
		struct netfs_read_request *rreq;
	struct netfs_io_subrequest {
		struct netfs_io_request *rreq;
		loff_t			start;
		size_t			len;
		size_t			transferred;
@@ -244,23 +244,23 @@ Read Helper Operations
The network filesystem must provide the read helpers with a table of operations
through which it can issue requests and negotiate::

	struct netfs_read_request_ops {
		void (*init_rreq)(struct netfs_read_request *rreq, struct file *file);
	struct netfs_request_ops {
		void (*init_request)(struct netfs_io_request *rreq, struct file *file);
		bool (*is_cache_enabled)(struct inode *inode);
		int (*begin_cache_operation)(struct netfs_read_request *rreq);
		void (*expand_readahead)(struct netfs_read_request *rreq);
		bool (*clamp_length)(struct netfs_read_subrequest *subreq);
		void (*issue_op)(struct netfs_read_subrequest *subreq);
		bool (*is_still_valid)(struct netfs_read_request *rreq);
		int (*begin_cache_operation)(struct netfs_io_request *rreq);
		void (*expand_readahead)(struct netfs_io_request *rreq);
		bool (*clamp_length)(struct netfs_io_subrequest *subreq);
		void (*issue_op)(struct netfs_io_subrequest *subreq);
		bool (*is_still_valid)(struct netfs_io_request *rreq);
		int (*check_write_begin)(struct file *file, loff_t pos, unsigned len,
					 struct folio *folio, void **_fsdata);
		void (*done)(struct netfs_read_request *rreq);
		void (*done)(struct netfs_io_request *rreq);
		void (*cleanup)(struct address_space *mapping, void *netfs_priv);
	};

The operations are as follows:

 * ``init_rreq()``
 * ``init_request()``

   [Optional] This is called to initialise the request structure.  It is given
   the file for reference and can modify the ->netfs_priv value.
@@ -420,12 +420,12 @@ The network filesystem's ->begin_cache_operation() method is called to set up a
cache and this must call into the cache to do the work.  If using fscache, for
example, the cache would call::

	int fscache_begin_read_operation(struct netfs_read_request *rreq,
	int fscache_begin_read_operation(struct netfs_io_request *rreq,
					 struct fscache_cookie *cookie);

passing in the request pointer and the cookie corresponding to the file.

The netfs_read_request object contains a place for the cache to hang its
The netfs_io_request object contains a place for the cache to hang its
state::

	struct netfs_cache_resources {
@@ -443,7 +443,7 @@ operation table looks like the following::
		void (*expand_readahead)(struct netfs_cache_resources *cres,
					 loff_t *_start, size_t *_len, loff_t i_size);

		enum netfs_read_source (*prepare_read)(struct netfs_read_subrequest *subreq,
		enum netfs_io_source (*prepare_read)(struct netfs_io_subrequest *subreq,
						       loff_t i_size);

		int (*read)(struct netfs_cache_resources *cres,
+8 −8
Original line number Diff line number Diff line
@@ -31,9 +31,9 @@
 * v9fs_req_issue_op - Issue a read from 9P
 * @subreq: The read to make
 */
static void v9fs_req_issue_op(struct netfs_read_subrequest *subreq)
static void v9fs_req_issue_op(struct netfs_io_subrequest *subreq)
{
	struct netfs_read_request *rreq = subreq->rreq;
	struct netfs_io_request *rreq = subreq->rreq;
	struct p9_fid *fid = rreq->netfs_priv;
	struct iov_iter to;
	loff_t pos = subreq->start + subreq->transferred;
@@ -52,11 +52,11 @@ static void v9fs_req_issue_op(struct netfs_read_subrequest *subreq)
}

/**
 * v9fs_init_rreq - Initialise a read request
 * v9fs_init_request - Initialise a read request
 * @rreq: The read request
 * @file: The file being read from
 */
static void v9fs_init_rreq(struct netfs_read_request *rreq, struct file *file)
static void v9fs_init_request(struct netfs_io_request *rreq, struct file *file)
{
	struct p9_fid *fid = file->private_data;

@@ -65,7 +65,7 @@ static void v9fs_init_rreq(struct netfs_read_request *rreq, struct file *file)
}

/**
 * v9fs_req_cleanup - Cleanup request initialized by v9fs_init_rreq
 * v9fs_req_cleanup - Cleanup request initialized by v9fs_init_request
 * @mapping: unused mapping of request to cleanup
 * @priv: private data to cleanup, a fid, guaranted non-null.
 */
@@ -91,7 +91,7 @@ static bool v9fs_is_cache_enabled(struct inode *inode)
 * v9fs_begin_cache_operation - Begin a cache operation for a read
 * @rreq: The read request
 */
static int v9fs_begin_cache_operation(struct netfs_read_request *rreq)
static int v9fs_begin_cache_operation(struct netfs_io_request *rreq)
{
#ifdef CONFIG_9P_FSCACHE
	struct fscache_cookie *cookie = v9fs_inode_cookie(V9FS_I(rreq->inode));
@@ -102,8 +102,8 @@ static int v9fs_begin_cache_operation(struct netfs_read_request *rreq)
#endif
}

static const struct netfs_read_request_ops v9fs_req_ops = {
	.init_rreq		= v9fs_init_rreq,
static const struct netfs_request_ops v9fs_req_ops = {
	.init_request		= v9fs_init_request,
	.is_cache_enabled	= v9fs_is_cache_enabled,
	.begin_cache_operation	= v9fs_begin_cache_operation,
	.issue_op		= v9fs_req_issue_op,
+6 −6
Original line number Diff line number Diff line
@@ -240,7 +240,7 @@ void afs_put_read(struct afs_read *req)
static void afs_fetch_data_notify(struct afs_operation *op)
{
	struct afs_read *req = op->fetch.req;
	struct netfs_read_subrequest *subreq = req->subreq;
	struct netfs_io_subrequest *subreq = req->subreq;
	int error = op->error;

	if (error == -ECONNABORTED)
@@ -310,7 +310,7 @@ int afs_fetch_data(struct afs_vnode *vnode, struct afs_read *req)
	return afs_do_sync_operation(op);
}

static void afs_req_issue_op(struct netfs_read_subrequest *subreq)
static void afs_req_issue_op(struct netfs_io_subrequest *subreq)
{
	struct afs_vnode *vnode = AFS_FS_I(subreq->rreq->inode);
	struct afs_read *fsreq;
@@ -359,7 +359,7 @@ static int afs_symlink_readpage(struct file *file, struct page *page)
	return ret;
}

static void afs_init_rreq(struct netfs_read_request *rreq, struct file *file)
static void afs_init_request(struct netfs_io_request *rreq, struct file *file)
{
	rreq->netfs_priv = key_get(afs_file_key(file));
}
@@ -371,7 +371,7 @@ static bool afs_is_cache_enabled(struct inode *inode)
	return fscache_cookie_enabled(cookie) && cookie->cache_priv;
}

static int afs_begin_cache_operation(struct netfs_read_request *rreq)
static int afs_begin_cache_operation(struct netfs_io_request *rreq)
{
#ifdef CONFIG_AFS_FSCACHE
	struct afs_vnode *vnode = AFS_FS_I(rreq->inode);
@@ -396,8 +396,8 @@ static void afs_priv_cleanup(struct address_space *mapping, void *netfs_priv)
	key_put(netfs_priv);
}

const struct netfs_read_request_ops afs_req_ops = {
	.init_rreq		= afs_init_rreq,
const struct netfs_request_ops afs_req_ops = {
	.init_request		= afs_init_request,
	.is_cache_enabled	= afs_is_cache_enabled,
	.begin_cache_operation	= afs_begin_cache_operation,
	.check_write_begin	= afs_check_write_begin,
+2 −2
Original line number Diff line number Diff line
@@ -207,7 +207,7 @@ struct afs_read {
	loff_t			file_size;	/* File size returned by server */
	struct key		*key;		/* The key to use to reissue the read */
	struct afs_vnode	*vnode;		/* The file being read into. */
	struct netfs_read_subrequest *subreq;	/* Fscache helper read request this belongs to */
	struct netfs_io_subrequest *subreq;	/* Fscache helper read request this belongs to */
	afs_dataversion_t	data_version;	/* Version number returned by server */
	refcount_t		usage;
	unsigned int		call_debug_id;
@@ -1063,7 +1063,7 @@ extern const struct address_space_operations afs_file_aops;
extern const struct address_space_operations afs_symlink_aops;
extern const struct inode_operations afs_file_inode_operations;
extern const struct file_operations afs_file_operations;
extern const struct netfs_read_request_ops afs_req_ops;
extern const struct netfs_request_ops afs_req_ops;

extern int afs_cache_wb_key(struct afs_vnode *, struct afs_file *);
extern void afs_put_wb_key(struct afs_wb_key *);
+3 −3
Original line number Diff line number Diff line
@@ -382,18 +382,18 @@ static int cachefiles_write(struct netfs_cache_resources *cres,
 * Prepare a read operation, shortening it to a cached/uncached
 * boundary as appropriate.
 */
static enum netfs_read_source cachefiles_prepare_read(struct netfs_read_subrequest *subreq,
static enum netfs_io_source cachefiles_prepare_read(struct netfs_io_subrequest *subreq,
						      loff_t i_size)
{
	enum cachefiles_prepare_read_trace why;
	struct netfs_read_request *rreq = subreq->rreq;
	struct netfs_io_request *rreq = subreq->rreq;
	struct netfs_cache_resources *cres = &rreq->cache_resources;
	struct cachefiles_object *object;
	struct cachefiles_cache *cache;
	struct fscache_cookie *cookie = fscache_cres_cookie(cres);
	const struct cred *saved_cred;
	struct file *file = cachefiles_cres_file(cres);
	enum netfs_read_source ret = NETFS_DOWNLOAD_FROM_SERVER;
	enum netfs_io_source ret = NETFS_DOWNLOAD_FROM_SERVER;
	loff_t off, to;
	ino_t ino = file ? file_inode(file)->i_ino : 0;

Loading