Skip to content

Commit 045fb9c

Browse files
committed
Merge branch 'fscache-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs
Pull fscache cleanups from David Howells: - fix checker complaint in afs - two netfs cleanups: - netfs_inode calling convention cleanup plus the requisite documentation changes - replace the ->cleanup op with a ->free_request op. This is possible as the I/O request is now always available at the cleanup point as the stuff to be cleaned up is no longer passed into the API functions, but rather obtained by ->init_request. * 'fscache-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs: netfs: Rename the netfs_io_request cleanup op and give it an op pointer netfs: Further cleanups after struct netfs_inode wrapper introduced afs: Fix some checker issues
2 parents b098915 + 40a8110 commit 045fb9c

File tree

17 files changed

+60
-62
lines changed

17 files changed

+60
-62
lines changed

Documentation/filesystems/netfs_library.rst

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ To help deal with the per-inode context, a number helper functions are
7979
provided. Firstly, a function to perform basic initialisation on a context and
8080
set the operations table pointer::
8181

82-
void netfs_inode_init(struct inode *inode,
82+
void netfs_inode_init(struct netfs_inode *ctx,
8383
const struct netfs_request_ops *ops);
8484

8585
then a function to cast from the VFS inode structure to the netfs context::
@@ -89,7 +89,7 @@ then a function to cast from the VFS inode structure to the netfs context::
8989
and finally, a function to get the cache cookie pointer from the context
9090
attached to an inode (or NULL if fscache is disabled)::
9191

92-
struct fscache_cookie *netfs_i_cookie(struct inode *inode);
92+
struct fscache_cookie *netfs_i_cookie(struct netfs_inode *ctx);
9393

9494

9595
Buffered Read Helpers
@@ -136,8 +136,9 @@ Three read helpers are provided::
136136

137137
void netfs_readahead(struct readahead_control *ractl);
138138
int netfs_read_folio(struct file *file,
139-
struct folio *folio);
140-
int netfs_write_begin(struct file *file,
139+
struct folio *folio);
140+
int netfs_write_begin(struct netfs_inode *ctx,
141+
struct file *file,
141142
struct address_space *mapping,
142143
loff_t pos,
143144
unsigned int len,
@@ -157,9 +158,10 @@ The helpers manage the read request, calling back into the network filesystem
157158
through the suppplied table of operations. Waits will be performed as
158159
necessary before returning for helpers that are meant to be synchronous.
159160

160-
If an error occurs and netfs_priv is non-NULL, ops->cleanup() will be called to
161-
deal with it. If some parts of the request are in progress when an error
162-
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.
163165

164166
Additionally, there is::
165167

@@ -207,8 +209,7 @@ The above fields are the ones the netfs can use. They are:
207209
* ``netfs_priv``
208210

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

213214
* ``start``
214215
* ``len``
@@ -293,6 +294,7 @@ through which it can issue requests and negotiate::
293294

294295
struct netfs_request_ops {
295296
void (*init_request)(struct netfs_io_request *rreq, struct file *file);
297+
void (*free_request)(struct netfs_io_request *rreq);
296298
int (*begin_cache_operation)(struct netfs_io_request *rreq);
297299
void (*expand_readahead)(struct netfs_io_request *rreq);
298300
bool (*clamp_length)(struct netfs_io_subrequest *subreq);
@@ -301,15 +303,19 @@ through which it can issue requests and negotiate::
301303
int (*check_write_begin)(struct file *file, loff_t pos, unsigned len,
302304
struct folio *folio, void **_fsdata);
303305
void (*done)(struct netfs_io_request *rreq);
304-
void (*cleanup)(struct address_space *mapping, void *netfs_priv);
305306
};
306307

307308
The operations are as follows:
308309

309310
* ``init_request()``
310311

311312
[Optional] This is called to initialise the request structure. It is given
312-
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.
313319

314320
* ``begin_cache_operation()``
315321

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

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

392393

393394
Read Helper Procedure

fs/9p/v9fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static inline struct v9fs_inode *V9FS_I(const struct inode *inode)
124124
static inline struct fscache_cookie *v9fs_inode_cookie(struct v9fs_inode *v9inode)
125125
{
126126
#ifdef CONFIG_9P_FSCACHE
127-
return netfs_i_cookie(&v9inode->netfs.inode);
127+
return netfs_i_cookie(&v9inode->netfs);
128128
#else
129129
return NULL;
130130
#endif

fs/9p/vfs_addr.c

Lines changed: 6 additions & 7 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
/**
@@ -274,7 +273,7 @@ static int v9fs_write_begin(struct file *filp, struct address_space *mapping,
274273
* file. We need to do this before we get a lock on the page in case
275274
* there's more than one writer competing for the same cache block.
276275
*/
277-
retval = netfs_write_begin(filp, mapping, pos, len, &folio, fsdata);
276+
retval = netfs_write_begin(&v9inode->netfs, filp, mapping, pos, len, &folio, fsdata);
278277
if (retval < 0)
279278
return retval;
280279

fs/9p/vfs_inode.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ void v9fs_free_inode(struct inode *inode)
252252
*/
253253
static void v9fs_set_netfs_context(struct inode *inode)
254254
{
255-
netfs_inode_init(inode, &v9fs_req_ops);
255+
struct v9fs_inode *v9inode = V9FS_I(inode);
256+
netfs_inode_init(&v9inode->netfs, &v9fs_req_ops);
256257
}
257258

258259
int v9fs_init_inode(struct v9fs_session_info *v9ses,

fs/afs/dynroot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct inode *afs_iget_pseudo_dir(struct super_block *sb, bool root)
7676
/* there shouldn't be an existing inode */
7777
BUG_ON(!(inode->i_state & I_NEW));
7878

79-
netfs_inode_init(inode, NULL);
79+
netfs_inode_init(&vnode->netfs, NULL);
8080
inode->i_size = 0;
8181
inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
8282
if (root) {

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/afs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static noinline void dump_vnode(struct afs_vnode *vnode, struct afs_vnode *paren
5858
*/
5959
static void afs_set_netfs_context(struct afs_vnode *vnode)
6060
{
61-
netfs_inode_init(&vnode->netfs.inode, &afs_req_ops);
61+
netfs_inode_init(&vnode->netfs, &afs_req_ops);
6262
}
6363

6464
/*

fs/afs/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,7 @@ struct afs_vnode {
670670
static inline struct fscache_cookie *afs_vnode_cache(struct afs_vnode *vnode)
671671
{
672672
#ifdef CONFIG_AFS_FSCACHE
673-
return netfs_i_cookie(&vnode->netfs.inode);
673+
return netfs_i_cookie(&vnode->netfs);
674674
#else
675675
return NULL;
676676
#endif

fs/afs/volume.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
#include <linux/slab.h>
1010
#include "internal.h"
1111

12-
unsigned __read_mostly afs_volume_gc_delay = 10;
13-
unsigned __read_mostly afs_volume_record_life = 60 * 60;
12+
static unsigned __read_mostly afs_volume_record_life = 60 * 60;
1413

1514
/*
1615
* Insert a volume into a cell. If there's an existing volume record, that is

fs/afs/write.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ int afs_write_begin(struct file *file, struct address_space *mapping,
6060
* file. We need to do this before we get a lock on the page in case
6161
* there's more than one writer competing for the same cache block.
6262
*/
63-
ret = netfs_write_begin(file, mapping, pos, len, &folio, fsdata);
63+
ret = netfs_write_begin(&vnode->netfs, file, mapping, pos, len, &folio, fsdata);
6464
if (ret < 0)
6565
return ret;
6666

0 commit comments

Comments
 (0)