Skip to content

Commit

Permalink
netfs: Rename netfs_read_*request to netfs_io_*request
Browse files Browse the repository at this point in the history
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: David Howells <[email protected]>
Reviewed-by: Jeff Layton <[email protected]>
cc: [email protected]
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
  • Loading branch information
dhowells committed Mar 9, 2022
1 parent c414049 commit 2f7dfbc
Show file tree
Hide file tree
Showing 11 changed files with 177 additions and 177 deletions.
40 changes: 20 additions & 20 deletions Documentation/filesystems/netfs_library.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down Expand Up @@ -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);

Expand All @@ -132,15 +132,15 @@ 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;
void *netfs_priv;
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;
...
};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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,
Expand Down
16 changes: 8 additions & 8 deletions fs/9p/vfs_addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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.
*/
Expand All @@ -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));
Expand All @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions fs/afs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}
Expand All @@ -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);
Expand All @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions fs/afs/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 *);
Expand Down
6 changes: 3 additions & 3 deletions fs/cachefiles/io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
16 changes: 8 additions & 8 deletions fs/ceph/addr.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ static int ceph_releasepage(struct page *page, gfp_t gfp)
return 1;
}

static void ceph_netfs_expand_readahead(struct netfs_read_request *rreq)
static void ceph_netfs_expand_readahead(struct netfs_io_request *rreq)
{
struct inode *inode = rreq->inode;
struct ceph_inode_info *ci = ceph_inode(inode);
Expand All @@ -200,7 +200,7 @@ static void ceph_netfs_expand_readahead(struct netfs_read_request *rreq)
rreq->len = roundup(rreq->len, lo->stripe_unit);
}

static bool ceph_netfs_clamp_length(struct netfs_read_subrequest *subreq)
static bool ceph_netfs_clamp_length(struct netfs_io_subrequest *subreq)
{
struct inode *inode = subreq->rreq->inode;
struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
Expand All @@ -219,7 +219,7 @@ static void finish_netfs_read(struct ceph_osd_request *req)
{
struct ceph_fs_client *fsc = ceph_inode_to_client(req->r_inode);
struct ceph_osd_data *osd_data = osd_req_op_extent_osd_data(req, 0);
struct netfs_read_subrequest *subreq = req->r_priv;
struct netfs_io_subrequest *subreq = req->r_priv;
int num_pages;
int err = req->r_result;

Expand All @@ -245,9 +245,9 @@ static void finish_netfs_read(struct ceph_osd_request *req)
iput(req->r_inode);
}

static bool ceph_netfs_issue_op_inline(struct netfs_read_subrequest *subreq)
static bool ceph_netfs_issue_op_inline(struct netfs_io_subrequest *subreq)
{
struct netfs_read_request *rreq = subreq->rreq;
struct netfs_io_request *rreq = subreq->rreq;
struct inode *inode = rreq->inode;
struct ceph_mds_reply_info_parsed *rinfo;
struct ceph_mds_reply_info_in *iinfo;
Expand Down Expand Up @@ -298,9 +298,9 @@ static bool ceph_netfs_issue_op_inline(struct netfs_read_subrequest *subreq)
return true;
}

static void ceph_netfs_issue_op(struct netfs_read_subrequest *subreq)
static void ceph_netfs_issue_op(struct netfs_io_subrequest *subreq)
{
struct netfs_read_request *rreq = subreq->rreq;
struct netfs_io_request *rreq = subreq->rreq;
struct inode *inode = rreq->inode;
struct ceph_inode_info *ci = ceph_inode(inode);
struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
Expand Down Expand Up @@ -364,7 +364,7 @@ static void ceph_readahead_cleanup(struct address_space *mapping, void *priv)
ceph_put_cap_refs(ci, got);
}

static const struct netfs_read_request_ops ceph_netfs_read_ops = {
static const struct netfs_request_ops ceph_netfs_read_ops = {
.is_cache_enabled = ceph_is_cache_enabled,
.begin_cache_operation = ceph_begin_cache_operation,
.issue_op = ceph_netfs_issue_op,
Expand Down
4 changes: 2 additions & 2 deletions fs/ceph/cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ static inline int ceph_fscache_set_page_dirty(struct page *page)
return fscache_set_page_dirty(page, ceph_fscache_cookie(ci));
}

static inline int ceph_begin_cache_operation(struct netfs_read_request *rreq)
static inline int ceph_begin_cache_operation(struct netfs_io_request *rreq)
{
struct fscache_cookie *cookie = ceph_fscache_cookie(ceph_inode(rreq->inode));

Expand Down Expand Up @@ -143,7 +143,7 @@ static inline bool ceph_is_cache_enabled(struct inode *inode)
return false;
}

static inline int ceph_begin_cache_operation(struct netfs_read_request *rreq)
static inline int ceph_begin_cache_operation(struct netfs_io_request *rreq)
{
return -ENOBUFS;
}
Expand Down
Loading

0 comments on commit 2f7dfbc

Please sign in to comment.