Commit c9c4ff12 authored by David Howells's avatar David Howells
Browse files

netfs: Move pinning-for-writeback from fscache to netfs



Move the resource pinning-for-writeback from fscache code to netfslib code.
This is used to keep a cache backing object pinned whilst we have dirty
pages on the netfs inode in the pagecache such that VM writeback will be
able to reach it.

Whilst we're at it, switch the parameters of netfs_unpin_writeback() to
match ->write_inode() so that it can be used for that directly.

Note that this mechanism could be more generically useful than that for
network filesystems.  Quite often they have to keep around other resources
(e.g. authentication tokens or network connections) until the writeback is
complete.

Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Reviewed-by: default avatarJeff Layton <jlayton@kernel.org>
cc: linux-cachefs@redhat.com
cc: linux-fsdevel@vger.kernel.org
cc: linux-mm@kvack.org
parent 7eb5b3e3
Loading
Loading
Loading
Loading
+9 −24
Original line number Diff line number Diff line
@@ -317,25 +317,10 @@ static int v9fs_write_end(struct file *filp, struct address_space *mapping,
	return copied;
}

#ifdef CONFIG_9P_FSCACHE
/*
 * Mark a page as having been made dirty and thus needing writeback.  We also
 * need to pin the cache object to write back to.
 */
static bool v9fs_dirty_folio(struct address_space *mapping, struct folio *folio)
{
	struct v9fs_inode *v9inode = V9FS_I(mapping->host);

	return fscache_dirty_folio(mapping, folio, v9fs_inode_cookie(v9inode));
}
#else
#define v9fs_dirty_folio filemap_dirty_folio
#endif

const struct address_space_operations v9fs_addr_operations = {
	.read_folio	= netfs_read_folio,
	.readahead	= netfs_readahead,
	.dirty_folio = v9fs_dirty_folio,
	.dirty_folio	= netfs_dirty_folio,
	.writepage	= v9fs_vfs_writepage,
	.write_begin	= v9fs_write_begin,
	.write_end	= v9fs_write_end,
+1 −2
Original line number Diff line number Diff line
@@ -376,8 +376,7 @@ void v9fs_evict_inode(struct inode *inode)

#ifdef CONFIG_9P_FSCACHE
	version = cpu_to_le32(v9inode->qid.version);
	fscache_clear_inode_writeback(v9fs_inode_cookie(v9inode), inode,
				      &version);
	netfs_clear_inode_writeback(inode, &version);
#endif

	clear_inode(inode);
+2 −12
Original line number Diff line number Diff line
@@ -289,31 +289,21 @@ static int v9fs_drop_inode(struct inode *inode)
static int v9fs_write_inode(struct inode *inode,
			    struct writeback_control *wbc)
{
	struct v9fs_inode *v9inode;

	/*
	 * send an fsync request to server irrespective of
	 * wbc->sync_mode.
	 */
	p9_debug(P9_DEBUG_VFS, "%s: inode %p\n", __func__, inode);

	v9inode = V9FS_I(inode);
	fscache_unpin_writeback(wbc, v9fs_inode_cookie(v9inode));

	return 0;
	return netfs_unpin_writeback(inode, wbc);
}

static int v9fs_write_inode_dotl(struct inode *inode,
				 struct writeback_control *wbc)
{
	struct v9fs_inode *v9inode;

	v9inode = V9FS_I(inode);
	p9_debug(P9_DEBUG_VFS, "%s: inode %p\n", __func__, inode);

	fscache_unpin_writeback(wbc, v9fs_inode_cookie(v9inode));

	return 0;
	return netfs_unpin_writeback(inode, wbc);
}

static const struct super_operations v9fs_super_ops = {
+1 −7
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ const struct inode_operations afs_file_inode_operations = {
const struct address_space_operations afs_file_aops = {
	.read_folio	= netfs_read_folio,
	.readahead	= netfs_readahead,
	.dirty_folio	= afs_dirty_folio,
	.dirty_folio	= netfs_dirty_folio,
	.launder_folio	= afs_launder_folio,
	.release_folio	= afs_release_folio,
	.invalidate_folio = afs_invalidate_folio,
@@ -386,12 +386,6 @@ const struct netfs_request_ops afs_req_ops = {
	.issue_read		= afs_issue_read,
};

int afs_write_inode(struct inode *inode, struct writeback_control *wbc)
{
	fscache_unpin_writeback(wbc, afs_vnode_cache(AFS_FS_I(inode)));
	return 0;
}

/*
 * Adjust the dirty region of the page on truncation or full invalidation,
 * getting rid of the markers altogether if the region is entirely invalidated.
+1 −1
Original line number Diff line number Diff line
@@ -823,7 +823,7 @@ void afs_evict_inode(struct inode *inode)
	truncate_inode_pages_final(&inode->i_data);

	afs_set_cache_aux(vnode, &aux);
	fscache_clear_inode_writeback(afs_vnode_cache(vnode), inode, &aux);
	netfs_clear_inode_writeback(inode, &aux);
	clear_inode(inode);

	while (!list_empty(&vnode->wb_keys)) {
Loading