Skip to content

Commit e81fb41

Browse files
torvaldsdhowells
authored andcommitted
netfs: Further cleanups after struct netfs_inode wrapper introduced
Change the signature of netfs helper functions to take a struct netfs_inode pointer rather than a struct inode pointer where appropriate, thereby relieving the need for the network filesystem to convert its internal inode format down to the VFS inode only for netfslib to bounce it back up. For type safety, it's better not to do that (and it's less typing too). Give netfs_write_begin() an extra argument to pass in a pointer to the netfs_inode struct rather than deriving it internally from the file pointer. Note that the ->write_begin() and ->write_end() ops are intended to be replaced in the future by netfslib code that manages this without the need to call in twice for each page. netfs_readpage() and similar are intended to be pointed at directly by the address_space_operations table, so must stick to the signature dictated by the function pointers there. Changes ======= - Updated the kerneldoc comments and documentation [DH]. Signed-off-by: David Howells <[email protected]> cc: [email protected] Link: https://lore.kernel.org/r/CAHk-=wgkwKyNmNdKpQkqZ6DnmUL-x9hp0YBnUGjaPFEAdxDTbw@mail.gmail.com/
1 parent 102d841 commit e81fb41

File tree

14 files changed

+30
-30
lines changed

14 files changed

+30
-30
lines changed

Documentation/filesystems/netfs_library.rst

Lines changed: 5 additions & 4 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,

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ static int v9fs_write_begin(struct file *filp, struct address_space *mapping,
274274
* file. We need to do this before we get a lock on the page in case
275275
* there's more than one writer competing for the same cache block.
276276
*/
277-
retval = netfs_write_begin(filp, mapping, pos, len, &folio, fsdata);
277+
retval = netfs_write_begin(&v9inode->netfs, filp, mapping, pos, len, &folio, fsdata);
278278
if (retval < 0)
279279
return retval;
280280

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/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/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

fs/ceph/addr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,10 +1322,11 @@ static int ceph_write_begin(struct file *file, struct address_space *mapping,
13221322
struct page **pagep, void **fsdata)
13231323
{
13241324
struct inode *inode = file_inode(file);
1325+
struct ceph_inode_info *ci = ceph_inode(inode);
13251326
struct folio *folio = NULL;
13261327
int r;
13271328

1328-
r = netfs_write_begin(file, inode->i_mapping, pos, len, &folio, NULL);
1329+
r = netfs_write_begin(&ci->netfs, file, inode->i_mapping, pos, len, &folio, NULL);
13291330
if (r == 0)
13301331
folio_wait_fscache(folio);
13311332
if (r < 0) {

fs/ceph/cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void ceph_fscache_invalidate(struct inode *inode, bool dio_write);
2828

2929
static inline struct fscache_cookie *ceph_fscache_cookie(struct ceph_inode_info *ci)
3030
{
31-
return netfs_i_cookie(&ci->netfs.inode);
31+
return netfs_i_cookie(&ci->netfs);
3232
}
3333

3434
static inline void ceph_fscache_resize(struct inode *inode, loff_t to)

0 commit comments

Comments
 (0)