Skip to content

Commit 4498a8e

Browse files
committed
netfs, fscache: Remove ->begin_cache_operation
Remove ->begin_cache_operation() in favour of just calling fscache directly. Signed-off-by: David Howells <[email protected]> Reviewed-by: Jeff Layton <[email protected]> cc: Christian Brauner <[email protected]> cc: [email protected] cc: [email protected]
1 parent 915cd30 commit 4498a8e

File tree

9 files changed

+23
-89
lines changed

9 files changed

+23
-89
lines changed

Documentation/filesystems/netfs_library.rst

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,6 @@ through which it can issue requests and negotiate::
295295
struct netfs_request_ops {
296296
void (*init_request)(struct netfs_io_request *rreq, struct file *file);
297297
void (*free_request)(struct netfs_io_request *rreq);
298-
int (*begin_cache_operation)(struct netfs_io_request *rreq);
299298
void (*expand_readahead)(struct netfs_io_request *rreq);
300299
bool (*clamp_length)(struct netfs_io_subrequest *subreq);
301300
void (*issue_read)(struct netfs_io_subrequest *subreq);
@@ -317,20 +316,6 @@ The operations are as follows:
317316
[Optional] This is called as the request is being deallocated so that the
318317
filesystem can clean up any state it has attached there.
319318

320-
* ``begin_cache_operation()``
321-
322-
[Optional] This is called to ask the network filesystem to call into the
323-
cache (if present) to initialise the caching state for this read. The netfs
324-
library module cannot access the cache directly, so the cache should call
325-
something like fscache_begin_read_operation() to do this.
326-
327-
The cache gets to store its state in ->cache_resources and must set a table
328-
of operations of its own there (though of a different type).
329-
330-
This should return 0 on success and an error code otherwise. If an error is
331-
reported, the operation may proceed anyway, just without local caching (only
332-
out of memory and interruption errors cause failure here).
333-
334319
* ``expand_readahead()``
335320

336321
[Optional] This is called to allow the filesystem to expand the size of a
@@ -460,14 +445,14 @@ When implementing a local cache to be used by the read helpers, two things are
460445
required: some way for the network filesystem to initialise the caching for a
461446
read request and a table of operations for the helpers to call.
462447

463-
The network filesystem's ->begin_cache_operation() method is called to set up a
464-
cache and this must call into the cache to do the work. If using fscache, for
465-
example, the cache would call::
448+
To begin a cache operation on an fscache object, the following function is
449+
called::
466450

467451
int fscache_begin_read_operation(struct netfs_io_request *rreq,
468452
struct fscache_cookie *cookie);
469453

470-
passing in the request pointer and the cookie corresponding to the file.
454+
passing in the request pointer and the cookie corresponding to the file. This
455+
fills in the cache resources mentioned below.
471456

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

fs/9p/vfs_addr.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,9 @@ static void v9fs_free_request(struct netfs_io_request *rreq)
8282
p9_fid_put(fid);
8383
}
8484

85-
/**
86-
* v9fs_begin_cache_operation - Begin a cache operation for a read
87-
* @rreq: The read request
88-
*/
89-
static int v9fs_begin_cache_operation(struct netfs_io_request *rreq)
90-
{
91-
#ifdef CONFIG_9P_FSCACHE
92-
struct fscache_cookie *cookie = v9fs_inode_cookie(V9FS_I(rreq->inode));
93-
94-
return fscache_begin_read_operation(&rreq->cache_resources, cookie);
95-
#else
96-
return -ENOBUFS;
97-
#endif
98-
}
99-
10085
const struct netfs_request_ops v9fs_req_ops = {
10186
.init_request = v9fs_init_request,
10287
.free_request = v9fs_free_request,
103-
.begin_cache_operation = v9fs_begin_cache_operation,
10488
.issue_read = v9fs_issue_read,
10589
};
10690

fs/afs/file.c

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -366,18 +366,6 @@ static int afs_init_request(struct netfs_io_request *rreq, struct file *file)
366366
return 0;
367367
}
368368

369-
static int afs_begin_cache_operation(struct netfs_io_request *rreq)
370-
{
371-
#ifdef CONFIG_AFS_FSCACHE
372-
struct afs_vnode *vnode = AFS_FS_I(rreq->inode);
373-
374-
return fscache_begin_read_operation(&rreq->cache_resources,
375-
afs_vnode_cache(vnode));
376-
#else
377-
return -ENOBUFS;
378-
#endif
379-
}
380-
381369
static int afs_check_write_begin(struct file *file, loff_t pos, unsigned len,
382370
struct folio **foliop, void **_fsdata)
383371
{
@@ -394,7 +382,6 @@ static void afs_free_request(struct netfs_io_request *rreq)
394382
const struct netfs_request_ops afs_req_ops = {
395383
.init_request = afs_init_request,
396384
.free_request = afs_free_request,
397-
.begin_cache_operation = afs_begin_cache_operation,
398385
.check_write_begin = afs_check_write_begin,
399386
.issue_read = afs_issue_read,
400387
};

fs/ceph/addr.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,6 @@ static void ceph_netfs_free_request(struct netfs_io_request *rreq)
509509
const struct netfs_request_ops ceph_netfs_ops = {
510510
.init_request = ceph_init_request,
511511
.free_request = ceph_netfs_free_request,
512-
.begin_cache_operation = ceph_begin_cache_operation,
513512
.issue_read = ceph_netfs_issue_read,
514513
.expand_readahead = ceph_netfs_expand_readahead,
515514
.clamp_length = ceph_netfs_clamp_length,

fs/ceph/cache.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,6 @@ static inline int ceph_fscache_dirty_folio(struct address_space *mapping,
5757
return fscache_dirty_folio(mapping, folio, ceph_fscache_cookie(ci));
5858
}
5959

60-
static inline int ceph_begin_cache_operation(struct netfs_io_request *rreq)
61-
{
62-
struct fscache_cookie *cookie = ceph_fscache_cookie(ceph_inode(rreq->inode));
63-
64-
return fscache_begin_read_operation(&rreq->cache_resources, cookie);
65-
}
66-
6760
static inline bool ceph_is_cache_enabled(struct inode *inode)
6861
{
6962
return fscache_cookie_enabled(ceph_fscache_cookie(ceph_inode(inode)));
@@ -135,11 +128,6 @@ static inline bool ceph_is_cache_enabled(struct inode *inode)
135128
return false;
136129
}
137130

138-
static inline int ceph_begin_cache_operation(struct netfs_io_request *rreq)
139-
{
140-
return -ENOBUFS;
141-
}
142-
143131
static inline void ceph_fscache_note_page_release(struct inode *inode)
144132
{
145133
}

fs/netfs/buffered_read.c

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,15 @@ static void netfs_rreq_expand(struct netfs_io_request *rreq,
147147
}
148148
}
149149

150+
/*
151+
* Begin an operation, and fetch the stored zero point value from the cookie if
152+
* available.
153+
*/
154+
static int netfs_begin_cache_read(struct netfs_io_request *rreq, struct netfs_inode *ctx)
155+
{
156+
return fscache_begin_read_operation(&rreq->cache_resources, netfs_i_cookie(ctx));
157+
}
158+
150159
/**
151160
* netfs_readahead - Helper to manage a read request
152161
* @ractl: The description of the readahead request
@@ -180,11 +189,9 @@ void netfs_readahead(struct readahead_control *ractl)
180189
if (IS_ERR(rreq))
181190
return;
182191

183-
if (ctx->ops->begin_cache_operation) {
184-
ret = ctx->ops->begin_cache_operation(rreq);
185-
if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS)
186-
goto cleanup_free;
187-
}
192+
ret = netfs_begin_cache_read(rreq, ctx);
193+
if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS)
194+
goto cleanup_free;
188195

189196
netfs_stat(&netfs_n_rh_readahead);
190197
trace_netfs_read(rreq, readahead_pos(ractl), readahead_length(ractl),
@@ -238,11 +245,9 @@ int netfs_read_folio(struct file *file, struct folio *folio)
238245
goto alloc_error;
239246
}
240247

241-
if (ctx->ops->begin_cache_operation) {
242-
ret = ctx->ops->begin_cache_operation(rreq);
243-
if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS)
244-
goto discard;
245-
}
248+
ret = netfs_begin_cache_read(rreq, ctx);
249+
if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS)
250+
goto discard;
246251

247252
netfs_stat(&netfs_n_rh_readpage);
248253
trace_netfs_read(rreq, rreq->start, rreq->len, netfs_read_trace_readpage);
@@ -390,11 +395,9 @@ int netfs_write_begin(struct netfs_inode *ctx,
390395
rreq->no_unlock_folio = folio_index(folio);
391396
__set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags);
392397

393-
if (ctx->ops->begin_cache_operation) {
394-
ret = ctx->ops->begin_cache_operation(rreq);
395-
if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS)
396-
goto error_put;
397-
}
398+
ret = netfs_begin_cache_read(rreq, ctx);
399+
if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS)
400+
goto error_put;
398401

399402
netfs_stat(&netfs_n_rh_write_begin);
400403
trace_netfs_read(rreq, pos, len, netfs_read_trace_write_begin);

fs/nfs/fscache.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -274,12 +274,6 @@ static void nfs_netfs_free_request(struct netfs_io_request *rreq)
274274
put_nfs_open_context(rreq->netfs_priv);
275275
}
276276

277-
static inline int nfs_netfs_begin_cache_operation(struct netfs_io_request *rreq)
278-
{
279-
return fscache_begin_read_operation(&rreq->cache_resources,
280-
netfs_i_cookie(netfs_inode(rreq->inode)));
281-
}
282-
283277
static struct nfs_netfs_io_data *nfs_netfs_alloc(struct netfs_io_subrequest *sreq)
284278
{
285279
struct nfs_netfs_io_data *netfs;
@@ -387,7 +381,6 @@ void nfs_netfs_read_completion(struct nfs_pgio_header *hdr)
387381
const struct netfs_request_ops nfs_netfs_ops = {
388382
.init_request = nfs_netfs_init_request,
389383
.free_request = nfs_netfs_free_request,
390-
.begin_cache_operation = nfs_netfs_begin_cache_operation,
391384
.issue_read = nfs_netfs_issue_read,
392385
.clamp_length = nfs_netfs_clamp_length
393386
};

include/linux/fscache.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,6 @@ const struct netfs_cache_ops *fscache_operation_valid(const struct netfs_cache_r
437437
* indicates the cache resources to which the operation state should be
438438
* attached; @cookie indicates the cache object that will be accessed.
439439
*
440-
* This is intended to be called from the ->begin_cache_operation() netfs lib
441-
* operation as implemented by the network filesystem.
442-
*
443440
* @cres->inval_counter is set from @cookie->inval_counter for comparison at
444441
* the end of the operation. This allows invalidation during the operation to
445442
* be detected by the caller.

include/linux/netfs.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,6 @@ struct netfs_io_request {
208208
struct netfs_request_ops {
209209
int (*init_request)(struct netfs_io_request *rreq, struct file *file);
210210
void (*free_request)(struct netfs_io_request *rreq);
211-
int (*begin_cache_operation)(struct netfs_io_request *rreq);
212211

213212
void (*expand_readahead)(struct netfs_io_request *rreq);
214213
bool (*clamp_length)(struct netfs_io_subrequest *subreq);
@@ -229,8 +228,7 @@ enum netfs_read_from_hole {
229228
};
230229

231230
/*
232-
* Table of operations for access to a cache. This is obtained by
233-
* rreq->ops->begin_cache_operation().
231+
* Table of operations for access to a cache.
234232
*/
235233
struct netfs_cache_ops {
236234
/* End an operation */

0 commit comments

Comments
 (0)