Skip to content

Commit 40a8110

Browse files
committed
netfs: Rename the netfs_io_request cleanup op and give it an op pointer
The netfs_io_request cleanup op is now always in a position to be given a pointer to a netfs_io_request struct, so this can be passed in instead of the mapping and private data arguments (both of which are included in the struct). So rename the ->cleanup op to ->free_request (to match ->init_request) and pass in the I/O pointer. Signed-off-by: David Howells <[email protected]> Reviewed-by: Jeff Layton <[email protected]> cc: [email protected]
1 parent e81fb41 commit 40a8110

File tree

6 files changed

+29
-30
lines changed

6 files changed

+29
-30
lines changed

Documentation/filesystems/netfs_library.rst

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,10 @@ The helpers manage the read request, calling back into the network filesystem
158158
through the suppplied table of operations. Waits will be performed as
159159
necessary before returning for helpers that are meant to be synchronous.
160160

161-
If an error occurs and netfs_priv is non-NULL, ops->cleanup() will be called to
162-
deal with it. If some parts of the request are in progress when an error
163-
occurs, the request will get partially completed if sufficient data is read.
161+
If an error occurs, the ->free_request() will be called to clean up the
162+
netfs_io_request struct allocated. If some parts of the request are in
163+
progress when an error occurs, the request will get partially completed if
164+
sufficient data is read.
164165

165166
Additionally, there is::
166167

@@ -208,8 +209,7 @@ The above fields are the ones the netfs can use. They are:
208209
* ``netfs_priv``
209210

210211
The network filesystem's private data. The value for this can be passed in
211-
to the helper functions or set during the request. The ->cleanup() op will
212-
be called if this is non-NULL at the end.
212+
to the helper functions or set during the request.
213213

214214
* ``start``
215215
* ``len``
@@ -294,6 +294,7 @@ through which it can issue requests and negotiate::
294294

295295
struct netfs_request_ops {
296296
void (*init_request)(struct netfs_io_request *rreq, struct file *file);
297+
void (*free_request)(struct netfs_io_request *rreq);
297298
int (*begin_cache_operation)(struct netfs_io_request *rreq);
298299
void (*expand_readahead)(struct netfs_io_request *rreq);
299300
bool (*clamp_length)(struct netfs_io_subrequest *subreq);
@@ -302,15 +303,19 @@ through which it can issue requests and negotiate::
302303
int (*check_write_begin)(struct file *file, loff_t pos, unsigned len,
303304
struct folio *folio, void **_fsdata);
304305
void (*done)(struct netfs_io_request *rreq);
305-
void (*cleanup)(struct address_space *mapping, void *netfs_priv);
306306
};
307307

308308
The operations are as follows:
309309

310310
* ``init_request()``
311311

312312
[Optional] This is called to initialise the request structure. It is given
313-
the file for reference and can modify the ->netfs_priv value.
313+
the file for reference.
314+
315+
* ``free_request()``
316+
317+
[Optional] This is called as the request is being deallocated so that the
318+
filesystem can clean up any state it has attached there.
314319

315320
* ``begin_cache_operation()``
316321

@@ -384,11 +389,6 @@ The operations are as follows:
384389
[Optional] This is called after the folios in the request have all been
385390
unlocked (and marked uptodate if applicable).
386391

387-
* ``cleanup``
388-
389-
[Optional] This is called as the request is being deallocated so that the
390-
filesystem can clean up ->netfs_priv.
391-
392392

393393

394394
Read Helper Procedure

fs/9p/vfs_addr.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,12 @@ static int v9fs_init_request(struct netfs_io_request *rreq, struct file *file)
6666
}
6767

6868
/**
69-
* v9fs_req_cleanup - Cleanup request initialized by v9fs_init_request
70-
* @mapping: unused mapping of request to cleanup
71-
* @priv: private data to cleanup, a fid, guaranted non-null.
69+
* v9fs_free_request - Cleanup request initialized by v9fs_init_rreq
70+
* @rreq: The I/O request to clean up
7271
*/
73-
static void v9fs_req_cleanup(struct address_space *mapping, void *priv)
72+
static void v9fs_free_request(struct netfs_io_request *rreq)
7473
{
75-
struct p9_fid *fid = priv;
74+
struct p9_fid *fid = rreq->netfs_priv;
7675

7776
p9_client_clunk(fid);
7877
}
@@ -94,9 +93,9 @@ static int v9fs_begin_cache_operation(struct netfs_io_request *rreq)
9493

9594
const struct netfs_request_ops v9fs_req_ops = {
9695
.init_request = v9fs_init_request,
96+
.free_request = v9fs_free_request,
9797
.begin_cache_operation = v9fs_begin_cache_operation,
9898
.issue_read = v9fs_issue_read,
99-
.cleanup = v9fs_req_cleanup,
10099
};
101100

102101
/**

fs/afs/file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -382,17 +382,17 @@ static int afs_check_write_begin(struct file *file, loff_t pos, unsigned len,
382382
return test_bit(AFS_VNODE_DELETED, &vnode->flags) ? -ESTALE : 0;
383383
}
384384

385-
static void afs_priv_cleanup(struct address_space *mapping, void *netfs_priv)
385+
static void afs_free_request(struct netfs_io_request *rreq)
386386
{
387-
key_put(netfs_priv);
387+
key_put(rreq->netfs_priv);
388388
}
389389

390390
const struct netfs_request_ops afs_req_ops = {
391391
.init_request = afs_init_request,
392+
.free_request = afs_free_request,
392393
.begin_cache_operation = afs_begin_cache_operation,
393394
.check_write_begin = afs_check_write_begin,
394395
.issue_read = afs_issue_read,
395-
.cleanup = afs_priv_cleanup,
396396
};
397397

398398
int afs_write_inode(struct inode *inode, struct writeback_control *wbc)

fs/ceph/addr.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,24 +394,23 @@ static int ceph_init_request(struct netfs_io_request *rreq, struct file *file)
394394
return 0;
395395
}
396396

397-
static void ceph_readahead_cleanup(struct address_space *mapping, void *priv)
397+
static void ceph_netfs_free_request(struct netfs_io_request *rreq)
398398
{
399-
struct inode *inode = mapping->host;
400-
struct ceph_inode_info *ci = ceph_inode(inode);
401-
int got = (uintptr_t)priv;
399+
struct ceph_inode_info *ci = ceph_inode(rreq->inode);
400+
int got = (uintptr_t)rreq->netfs_priv;
402401

403402
if (got)
404403
ceph_put_cap_refs(ci, got);
405404
}
406405

407406
const struct netfs_request_ops ceph_netfs_ops = {
408407
.init_request = ceph_init_request,
408+
.free_request = ceph_netfs_free_request,
409409
.begin_cache_operation = ceph_begin_cache_operation,
410410
.issue_read = ceph_netfs_issue_read,
411411
.expand_readahead = ceph_netfs_expand_readahead,
412412
.clamp_length = ceph_netfs_clamp_length,
413413
.check_write_begin = ceph_netfs_check_write_begin,
414-
.cleanup = ceph_readahead_cleanup,
415414
};
416415

417416
#ifdef CONFIG_CEPH_FSCACHE

fs/netfs/objects.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ static void netfs_free_request(struct work_struct *work)
7575
struct netfs_io_request *rreq =
7676
container_of(work, struct netfs_io_request, work);
7777

78-
netfs_clear_subrequests(rreq, false);
79-
if (rreq->netfs_priv)
80-
rreq->netfs_ops->cleanup(rreq->mapping, rreq->netfs_priv);
8178
trace_netfs_rreq(rreq, netfs_rreq_trace_free);
79+
netfs_clear_subrequests(rreq, false);
80+
if (rreq->netfs_ops->free_request)
81+
rreq->netfs_ops->free_request(rreq);
8282
if (rreq->cache_resources.ops)
8383
rreq->cache_resources.ops->end_operation(&rreq->cache_resources);
8484
kfree(rreq);

include/linux/netfs.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,15 +206,16 @@ struct netfs_io_request {
206206
*/
207207
struct netfs_request_ops {
208208
int (*init_request)(struct netfs_io_request *rreq, struct file *file);
209+
void (*free_request)(struct netfs_io_request *rreq);
209210
int (*begin_cache_operation)(struct netfs_io_request *rreq);
211+
210212
void (*expand_readahead)(struct netfs_io_request *rreq);
211213
bool (*clamp_length)(struct netfs_io_subrequest *subreq);
212214
void (*issue_read)(struct netfs_io_subrequest *subreq);
213215
bool (*is_still_valid)(struct netfs_io_request *rreq);
214216
int (*check_write_begin)(struct file *file, loff_t pos, unsigned len,
215217
struct folio *folio, void **_fsdata);
216218
void (*done)(struct netfs_io_request *rreq);
217-
void (*cleanup)(struct address_space *mapping, void *netfs_priv);
218219
};
219220

220221
/*

0 commit comments

Comments
 (0)