Commit e81fb419 authored by Linus Torvalds's avatar Linus Torvalds Committed by David Howells
Browse files

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: default avatarDavid Howells <dhowells@redhat.com>
cc: linux-cachefs@redhat.com
Link: https://lore.kernel.org/r/CAHk-=wgkwKyNmNdKpQkqZ6DnmUL-x9hp0YBnUGjaPFEAdxDTbw@mail.gmail.com/
parent 102d8410
Loading
Loading
Loading
Loading
+5 −4
Original line number Diff line number Diff line
@@ -79,7 +79,7 @@ To help deal with the per-inode context, a number helper functions are
provided.  Firstly, a function to perform basic initialisation on a context and
set the operations table pointer::

	void netfs_inode_init(struct inode *inode,
	void netfs_inode_init(struct netfs_inode *ctx,
			      const struct netfs_request_ops *ops);

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::
and finally, a function to get the cache cookie pointer from the context
attached to an inode (or NULL if fscache is disabled)::

	struct fscache_cookie *netfs_i_cookie(struct inode *inode);
	struct fscache_cookie *netfs_i_cookie(struct netfs_inode *ctx);


Buffered Read Helpers
@@ -137,7 +137,8 @@ Three read helpers are provided::
	void netfs_readahead(struct readahead_control *ractl);
	int netfs_read_folio(struct file *file,
			     struct folio *folio);
	int netfs_write_begin(struct file *file,
	int netfs_write_begin(struct netfs_inode *ctx,
			      struct file *file,
			      struct address_space *mapping,
			      loff_t pos,
			      unsigned int len,
+1 −1
Original line number Diff line number Diff line
@@ -124,7 +124,7 @@ static inline struct v9fs_inode *V9FS_I(const struct inode *inode)
static inline struct fscache_cookie *v9fs_inode_cookie(struct v9fs_inode *v9inode)
{
#ifdef CONFIG_9P_FSCACHE
	return netfs_i_cookie(&v9inode->netfs.inode);
	return netfs_i_cookie(&v9inode->netfs);
#else
	return NULL;
#endif
+1 −1
Original line number Diff line number Diff line
@@ -274,7 +274,7 @@ static int v9fs_write_begin(struct file *filp, struct address_space *mapping,
	 * file.  We need to do this before we get a lock on the page in case
	 * there's more than one writer competing for the same cache block.
	 */
	retval = netfs_write_begin(filp, mapping, pos, len, &folio, fsdata);
	retval = netfs_write_begin(&v9inode->netfs, filp, mapping, pos, len, &folio, fsdata);
	if (retval < 0)
		return retval;

+2 −1
Original line number Diff line number Diff line
@@ -252,7 +252,8 @@ void v9fs_free_inode(struct inode *inode)
 */
static void v9fs_set_netfs_context(struct inode *inode)
{
	netfs_inode_init(inode, &v9fs_req_ops);
	struct v9fs_inode *v9inode = V9FS_I(inode);
	netfs_inode_init(&v9inode->netfs, &v9fs_req_ops);
}

int v9fs_init_inode(struct v9fs_session_info *v9ses,
+1 −1
Original line number Diff line number Diff line
@@ -76,7 +76,7 @@ struct inode *afs_iget_pseudo_dir(struct super_block *sb, bool root)
	/* there shouldn't be an existing inode */
	BUG_ON(!(inode->i_state & I_NEW));

	netfs_inode_init(inode, NULL);
	netfs_inode_init(&vnode->netfs, NULL);
	inode->i_size		= 0;
	inode->i_mode		= S_IFDIR | S_IRUGO | S_IXUGO;
	if (root) {
Loading