9p: Convert to cut-down fscache I/O API rewrite
Subsystems (2)
PATCH 1/1 9p: Convert to cut-down fscache I/O API rewrite
Hi Dominique,
Here's a draft of a patch to convert 9P to use the cut-down part of the fscache I/O API rewrite (I've removed all the cookie and object state machine changes for now). It compiles, but I've no way to test it. This is built on top of my fscache-netfs-lib branch:
https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=fscache-netfs-lib
I'm hoping to ask Linus to pull the netfs lib, afs and ceph changes in the next merge window.
Would you be able to give it a whirl?
David
---
commit 725145bde271b382e7e4e4ee2a9342a36f91b8fc
Author: David Howells <[email protected]> Date: Wed Nov 18 09:06:42 2020 +0000
9p: Convert to using the netfs helper lib to do reads and caching
Convert the 9p filesystem to use the netfs helper lib to handle readpage, readahead and write_begin, converting those into a common issue_op for the filesystem itself to handle. The netfs helper lib also handles reading from fscache if a cache is available, and interleaving reads from both sources.
This change also switches from the old fscache I/O API to the new one, meaning that fscache no longer keeps track of netfs pages and instead does async DIO between the backing files and the 9p file pagecache. As a part of this change, the handling of PG_fscache changes. It now just means that the cache has a write I/O operation in progress on a page (PG_locked is used for a read I/O op).
Note that this is a cut-down version of the fscache rewrite and does not change any of the cookie and cache coherency handling.
fs/9p/Kconfig +1 -0
@@ -2,6 +2,7 @@ config 9P_FS tristate "Plan 9 Resource Sharing Support (9P2000)" depends on INET && NET_9P + select NETFS_SUPPORT help If you say Y here, you will get experimental support for Plan 9 resource sharing via the 9P2000 protocol.
fs/9p/cache.c +0 -137
140 lines not on this page · raw message
fs/9p/cache.h +4 -94
116 lines not on this page · raw message
fs/9p/v9fs.h +9 -0
@@ -123,6 +123,15 @@ static inline struct v9fs_inode *V9FS_I(const struct inode *inode) { return container_of(inode, struct v9fs_inode, vfs_inode); } + +static inline struct fscache_cookie *v9fs_inode_cookie (struct v9fs_inode *v9inode) +{ +#ifdef CONFIG_9P_FSCACHE +return v9inode->fscache; +#else +return NULL ; +#endif +}extern int v9fs_show_options (struct seq_file *m,struct dentry *root);
fs/9p/vfs_addr.c +80 -97
277 lines not on this page · raw message
fs/9p/vfs_file.c +17 -4
@@ -555,14 +555,27 @@ v9fs_vm_page_mkwrite(struct vm_fault *vmf)p9_debug (P9_DEBUG_VFS ,"page %p fid %lx\n" , page, (unsigned long )filp->private_data); + v9inode =V9FS_I (inode); + +/* Wait for the page to be written to the cache before we allow it to +* be modified. We then assume the entire page will need writing back. +*/ +#ifdef CONFIG_V9FS_FSCACHE +if (PageFsCache (page) && +wait_on_page_bit_killable (page, PG_fscache) <0 ) +return VM_FAULT_RETRY ; +#endif + +if (PageWriteback (page) && +wait_on_page_bit_killable (page, PG_writeback) <0 ) +return VM_FAULT_RETRY ; +/* Update file times before taking page lock */ file_update_time (filp); - v9inode =V9FS_I (inode); -/* make sure the cache has finished storing the page */ -v9fs_fscache_wait_on_page_write (inode, page);BUG_ON (!v9inode->writeback_fid); -lock_page (page); +if (lock_page_killable (page) <0 ) +return VM_FAULT_RETRY ;if (page->mapping != inode->i_mapping) goto out_unlock;wait_for_stable_page (page);
Dominique Martinet
maintainerHi David,
David Howells wrote on Tue, Feb 02, 2021 at 11:04:23AM +0000:
Quoted 6 lines
Here's a draft of a patch to convert 9P to use the cut-down part of the fscache I/O API rewrite (I've removed all the cookie and object state machine changes for now). It compiles, but I've no way to test it. This is built on top of my fscache-netfs-lib branch:
https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=fscache-netfs-lib
Thanks for going the extra mile with all this, it's appreciated!
Quoted 4 lines
I'm hoping to ask Linus to pull the netfs lib, afs and ceph changes in the next merge window.
Would you be able to give it a whirl?
I'm afraid I won't have much time to give for the next merge window (in roughly 2-4 weeks iiuc)
I can probably find some time to run very basic tests from my usual setup but testing actual fscache capabilities will take more time and I'm quite short right now -- I honestly have no idea if anyone uses fscache or if it's even working right now so I'd rather take a moment to test it properly before/after, and it's time I don't have right now.
OTOH I'd support getting the netfs lib in as planned this merge window, and I'll definitely take the time to test this patch into my tree before the next one in ~3months.
I think the whole point of the rework you've done is we can do things more smoothly and there is no reason to rush it anymore, having the new lib get tested through afs/ceph in the real world can only be reassuring for other filesystems.
Cheers,
Signature · 1 line
Dominique