Various NFS fscache cleanups
Subsystems (2)
v2 cover Various NFS fscache cleanups
This patchset is on top of David Howells patchset he just posted as v3 of "fscache: Replace and remove old I/O API" and is based on his fscache-remove-old-io branch at
https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=fscache-remove-old-io
NOTE: fscache-remove-old-io was previously "fscache-iter-3" but it's been renamed to better reflect the purpose.
The series is also at:
https://github.com/DaveWysochanskiRH/kernel.git
https://github.com/DaveWysochanskiRH/kernel/tree/fscache-remove-old-io-nfs-fixes
Testing is looking ok so far and is still ongoing at BakeAThon and in my local testbed with tracepoints enabled via:
trace-cmd start -e fscache:* -e nfs:* -e nfs4:* -e cachefiles:*
Changes in v2 of this series
- Dropped first patch of v1 series (dhowells updated his patch)
- Don't rename or change the value of NFSDBG_FSCACHE (Trond)
- Rename nfs_readpage_from_fscache and nfs_readpage_to_fscache
- Rename enable/disable tracepoints to start with "nfs_fscache"
- Rename fscache IO tracepoints to better reflect the new function names
- Place the fscache IO tracepoints at begin and end of the functions
Dave Wysochanski (7):
NFS: Use nfs_i_fscache() consistently within NFS fscache code
NFS: Cleanup usage of nfs_inode in fscache interface and handle i_size
properly
NFS: Convert NFS fscache enable/disable dfprintks to tracepoints
NFS: Rename fscache read and write pages functions
NFS: Replace dfprintks with tracepoints in read and write page
functions
NFS: Remove remaining dfprintks related to fscache cookies
NFS: Remove remaining usages of NFSDBG_FSCACHE
fs/nfs/fscache-index.c | 2 - fs/nfs/fscache.c | 76 +++++++++++++---------------------- fs/nfs/fscache.h | 25 ++++++------ fs/nfs/nfstrace.h | 98 +++++++++++++++++++++++++++++++++++++++++++++ fs/nfs/read.c | 4 +- include/uapi/linux/nfs_fs.h | 2 +- 6 files changed, 140 insertions(+), 67 deletions(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/7 NFS: Use nfs_i_fscache() consistently within NFS fscache code
The nfs_i_fscache() is the API defined to check whether fscache is enabled on an NFS inode or not, so use it consistently through the code.
--- fs/nfs/fscache.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/nfs/fscache.h +4 -4
@@ -105,7 +105,7 @@ extern void __nfs_read_completion_to_fscache(struct nfs_pgio_header *hdr,static inline int nfs_readpage_from_fscache (struct inode *inode,struct page *page) { -if (NFS_I (inode)->fscache) +if (nfs_i_fscache (inode))return __nfs_readpage_from_fscache (inode, page);return -ENOBUFS ; }
@@ -117,7 +117,7 @@ static inline int nfs_readpage_from_fscache(struct inode *inode,static inline void nfs_readpage_to_fscache (struct inode *inode,struct page *page) { -if (NFS_I (inode)->fscache) +if (nfs_i_fscache (inode))__nfs_readpage_to_fscache (inode, page); }
@@ -126,7 +126,7 @@ static inline void nfs_readpage_to_fscache(struct inode *inode,*/ static inline void nfs_fscache_invalidate (struct inode *inode) { -fscache_invalidate (NFS_I (inode)->fscache); +fscache_invalidate (nfs_i_fscache (inode)); }/*
@@ -134,7 +134,7 @@ static inline void nfs_fscache_invalidate(struct inode *inode)*/ static inline void nfs_fscache_wait_on_invalidate (struct inode *inode) { -fscache_wait_on_invalidate (NFS_I (inode)->fscache); +fscache_wait_on_invalidate (nfs_i_fscache (inode)); }/*
Signature · 1 line
1.8.3.1
PATCH v2 2/7 NFS: Cleanup usage of nfs_inode in fscache interface and handle i_size properly
In reply to Dave WysochanskiA number of places in the fscache interface used nfs_inode when inode could be used, simplifying the code. Also, handle the read of i_size properly by utilizing the i_size_read() interface.
--- fs/nfs/fscache.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-)
fs/nfs/fscache.c +12 -12
@@ -226,16 +226,16 @@ void nfs_fscache_release_super_cookie(struct super_block *sb) }static void nfs_fscache_update_auxdata (struct nfs_fscache_inode_auxdata *auxdata, -struct nfs_inode *nfsi) +struct inode *inode) {memset (auxdata,0 ,sizeof (*auxdata)); - auxdata->mtime_sec = nfsi->vfs_inode.i_mtime.tv_sec; - auxdata->mtime_nsec = nfsi->vfs_inode.i_mtime.tv_nsec; - auxdata->ctime_sec = nfsi->vfs_inode.i_ctime.tv_sec; - auxdata->ctime_nsec = nfsi->vfs_inode.i_ctime.tv_nsec; + auxdata->mtime_sec = inode->i_mtime.tv_sec; + auxdata->mtime_nsec = inode->i_mtime.tv_nsec; + auxdata->ctime_sec = inode->i_ctime.tv_sec; + auxdata->ctime_nsec = inode->i_ctime.tv_nsec; -if (NFS_SERVER (&nfsi->vfs_inode)->nfs_client->rpc_ops->version ==4 ) - auxdata->change_attr =inode_peek_iversion_raw (&nfsi->vfs_inode); +if (NFS_SERVER (inode)->nfs_client->rpc_ops->version ==4 ) + auxdata->change_attr =inode_peek_iversion_raw (inode); }/*
@@ -251,13 +251,13 @@ void nfs_fscache_init_inode(struct inode *inode)if (!(nfss->fscache &&S_ISREG (inode->i_mode)))return ; -nfs_fscache_update_auxdata (&auxdata, nfsi); +nfs_fscache_update_auxdata (&auxdata, inode); nfsi->fscache =fscache_acquire_cookie (NFS_SB (inode->i_sb)->fscache, &nfs_fscache_inode_object_def, nfsi->fh.data, nfsi->fh.size, &auxdata,sizeof (auxdata), - nfsi, nfsi->vfs_inode.i_size, false); + nfsi,i_size_read (inode), false); }/*
@@ -271,7 +271,7 @@ void nfs_fscache_clear_inode(struct inode *inode)dfprintk (FSCACHE ,"NFS: clear cookie (0x%p/0x%p)\n" , nfsi, cookie); -nfs_fscache_update_auxdata (&auxdata, nfsi); +nfs_fscache_update_auxdata (&auxdata, inode);fscache_relinquish_cookie (cookie, &auxdata, false); nfsi->fscache =NULL ; }
@@ -311,7 +311,7 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp)if (!fscache_cookie_valid (cookie))return ; -nfs_fscache_update_auxdata (&auxdata, nfsi); +nfs_fscache_update_auxdata (&auxdata, inode);if (inode_is_open_for_write (inode)) {dfprintk (FSCACHE ,"NFS: nfsi 0x%p disabling cache\n" , nfsi);
@@ -319,7 +319,7 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp)fscache_disable_cookie (cookie, &auxdata, true); }else {dfprintk (FSCACHE ,"NFS: nfsi 0x%p enabling cache\n" , nfsi); -fscache_enable_cookie (cookie, &auxdata, nfsi->vfs_inode.i_size, +fscache_enable_cookie (cookie, &auxdata,i_size_read (inode), nfs_fscache_can_enable, inode);if (fscache_cookie_enabled (cookie))set_bit (NFS_INO_FSCACHE , &NFS_I (inode)->flags);
Signature · 1 line
1.8.3.1
PATCH v2 3/7 NFS: Convert NFS fscache enable/disable dfprintks to tracepoints
In reply to Dave WysochanskiConvert the enable / disable NFS fscache dfprintks to tracepoints. Utilize the existing NFS inode trace event class, which allows us to keep the same output format to other NFS inode tracepoints. Start the names of the tracepoints with "nfs_fscache" for easy identification.
--- fs/nfs/fscache.c | 5 +++-- fs/nfs/nfstrace.h | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-)
fs/nfs/fscache.c +3 -2
@@ -19,6 +19,7 @@#include "internal.h" #include "iostat.h" #include "fscache.h" +#include "nfstrace.h" #define NFSDBG_FACILITY NFSDBG_FSCACHE
@@ -314,11 +315,11 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp)nfs_fscache_update_auxdata (&auxdata, inode);if (inode_is_open_for_write (inode)) { -dfprintk (FSCACHE ,"NFS: nfsi 0x%p disabling cache\n" , nfsi); +trace_nfs_fscache_disable_inode (inode);clear_bit (NFS_INO_FSCACHE , &nfsi->flags);fscache_disable_cookie (cookie, &auxdata, true); }else { -dfprintk (FSCACHE ,"NFS: nfsi 0x%p enabling cache\n" , nfsi); +trace_nfs_fscache_enable_inode (inode);fscache_enable_cookie (cookie, &auxdata,i_size_read (inode), nfs_fscache_can_enable, inode);if (fscache_cookie_enabled (cookie))
fs/nfs/nfstrace.h +2 -0
@@ -209,6 +209,8 @@DEFINE_NFS_INODE_EVENT (nfs_fsync_enter);DEFINE_NFS_INODE_EVENT_DONE (nfs_fsync_exit);DEFINE_NFS_INODE_EVENT (nfs_access_enter); +DEFINE_NFS_INODE_EVENT (nfs_fscache_enable_inode); +DEFINE_NFS_INODE_EVENT (nfs_fscache_disable_inode); TRACE_EVENT(nfs_access_exit, TP_PROTO(
Signature · 1 line
1.8.3.1
PATCH v2 4/7 NFS: Rename fscache read and write pages functions
In reply to Dave WysochanskiRename NFS fscache functions to read from and write to the cache to better reflect the new fscache fallback API naming.
--- fs/nfs/fscache.c | 4 ++-- fs/nfs/fscache.h | 17 ++++++++--------- fs/nfs/read.c | 4 ++-- 3 files changed, 12 insertions(+), 13 deletions(-)
fs/nfs/fscache.c +2 -2
@@ -331,7 +331,7 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp)/* * Retrieve a page from fscache */ -int __nfs_readpage_from_fscache (struct inode *inode,struct page *page) +int __nfs_fscache_read_page (struct inode *inode,struct page *page) {int ret;
@@ -364,7 +364,7 @@ int __nfs_readpage_from_fscache(struct inode *inode, struct page *page)/* * Store a newly fetched page in fscache */ -void __nfs_readpage_to_fscache (struct inode *inode,struct page *page) +void __nfs_fscache_write_page (struct inode *inode,struct page *page) {int ret;
fs/nfs/fscache.h +8 -9
@@ -94,19 +94,18 @@ struct nfs_fscache_inode_auxdata {extern void nfs_fscache_clear_inode (struct inode *);extern void nfs_fscache_open_file (struct inode *,struct file *); -extern int __nfs_readpage_from_fscache (struct inode *,struct page *); +extern int __nfs_fscache_read_page (struct inode *,struct page *);extern void __nfs_read_completion_to_fscache (struct nfs_pgio_header *hdr,unsigned long bytes); -extern void __nfs_readpage_to_fscache (struct inode *,struct page *); +extern void __nfs_fscache_write_page (struct inode *,struct page *);/* * Retrieve a page from an inode data storage object. */ -static inline int nfs_readpage_from_fscache (struct inode *inode, -struct page *page) +static inline int nfs_fscache_read_page (struct inode *inode,struct page *page) {if (nfs_i_fscache (inode)) -return __nfs_readpage_from_fscache (inode, page); +return __nfs_fscache_read_page (inode, page);return -ENOBUFS ; }
@@ -114,11 +113,11 @@ static inline int nfs_readpage_from_fscache(struct inode *inode,* Store a page newly fetched from the server in an inode data storage object * in the cache. */ -static inline void nfs_readpage_to_fscache (struct inode *inode, +static inline void nfs_fscache_write_page (struct inode *inode,struct page *page) {if (nfs_i_fscache (inode)) -__nfs_readpage_to_fscache (inode, page); +__nfs_fscache_write_page (inode, page); }/*
@@ -161,12 +160,12 @@ static inline void nfs_fscache_clear_inode(struct inode *inode) {}static inline void nfs_fscache_open_file (struct inode *inode,struct file *filp) {} -static inline int nfs_readpage_from_fscache (struct inode *inode, +static inline int nfs_fscache_read_page (struct inode *inode,struct page *page) {return -ENOBUFS ; } -static inline void nfs_readpage_to_fscache (struct inode *inode, +static inline void nfs_fscache_write_page (struct inode *inode,struct page *page) {}
fs/nfs/read.c +2 -2
@@ -123,7 +123,7 @@ static void nfs_readpage_release(struct nfs_page *req, int error)struct address_space *mapping =page_file_mapping (page);if (PageUptodate (page)) -nfs_readpage_to_fscache (inode, page); +nfs_fscache_write_page (inode, page);else if (!PageError (page) && !PagePrivate (page))generic_error_remove_page (mapping, page);unlock_page (page);
@@ -306,7 +306,7 @@ static void nfs_readpage_result(struct rpc_task *task, aligned_len = min_t(unsigned int, ALIGN(len, rsize), PAGE_SIZE);if (!IS_SYNC (page->mapping->host)) { - error =nfs_readpage_from_fscache (page->mapping->host, page); + error =nfs_fscache_read_page (page->mapping->host, page);if (error ==0 ) goto out_unlock; }
Signature · 1 line
1.8.3.1
PATCH v2 5/7 NFS: Replace dfprintks with tracepoints in read and write page functions
In reply to Dave WysochanskiMost of fscache and other NFS IO paths are now using tracepoints. Remove the dfprintks in the NFS fscache read/write page functions and replace with tracepoints at the begin and end of the functions.
--- fs/nfs/fscache.c | 29 ++++++----------- fs/nfs/nfstrace.h | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 106 insertions(+), 19 deletions(-)
fs/nfs/fscache.c +10 -19
@@ -335,30 +335,27 @@ int __nfs_fscache_read_page(struct inode *inode, struct page *page) {int ret; -dfprintk (FSCACHE , -"NFS: readpage_from_fscache(fsc:%p/p:%p(i:%lx f:%lx)/0x%p)\n" , -nfs_i_fscache (inode), page, page->index, page->flags, inode); - +trace_nfs_fscache_read_page (inode, page);if (PageChecked (page)) { -dfprintk (FSCACHE ,"NFS: readpage_from_fscache: PageChecked\n" );ClearPageChecked (page); -return 1 ; + ret =1 ; + goto out; } ret =fscache_fallback_read_page (nfs_i_fscache (inode), page);if (ret <0 ) {nfs_inc_fscache_stats (inode,NFSIOS_FSCACHE_PAGES_READ_FAIL ); -dfprintk (FSCACHE , -"NFS: readpage_from_fscache failed %d\n" , ret);SetPageChecked (page); -return ret; + goto out; }/* Read completed synchronously */ -dfprintk (FSCACHE ,"NFS: readpage_from_fscache: read successful\n" );nfs_inc_fscache_stats (inode,NFSIOS_FSCACHE_PAGES_READ_OK );SetPageUptodate (page); -return 0 ; + ret =0 ; +out: +trace_nfs_fscache_read_page_done (inode, page, ret); +return ret; }/*
@@ -368,20 +365,14 @@ void __nfs_fscache_write_page(struct inode *inode, struct page *page) {int ret; -dfprintk (FSCACHE , -"NFS: readpage_to_fscache(fsc:%p/p:%p(i:%lx f:%lx))\n" , -nfs_i_fscache (inode), page, page->index, page->flags); - +trace_nfs_fscache_write_page (inode, page); ret =fscache_fallback_write_page (nfs_i_fscache (inode), page); -dfprintk (FSCACHE , -"NFS: readpage_to_fscache: p:%p(i:%lu f:%lx) ret %d\n" , - page, page->index, page->flags, ret); -if (ret !=0 ) {nfs_inc_fscache_stats (inode,NFSIOS_FSCACHE_PAGES_WRITTEN_FAIL );nfs_inc_fscache_stats (inode,NFSIOS_FSCACHE_PAGES_UNCACHED ); }else {nfs_inc_fscache_stats (inode,NFSIOS_FSCACHE_PAGES_WRITTEN_OK ); } +trace_nfs_fscache_write_page_done (inode, page, ret); }
fs/nfs/nfstrace.h +96 -0
102 lines not on this page · raw message
Signature · 1 line
1.8.3.1
PATCH v2 6/7 NFS: Remove remaining dfprintks related to fscache cookies
In reply to Dave WysochanskiThe fscache cookie APIs including fscache_acquire_cookie() and fscache_relinquish_cookie() now have very good tracing. Thus, there is no real need for dfprintks in the NFS fscache interface.
--- fs/nfs/fscache.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-)
fs/nfs/fscache.c +1 -13
@@ -21,7 +21,7 @@#include "fscache.h" #include "nfstrace.h" -#define NFSDBG_FACILITY NFSDBG_FSCACHE +#define NFSDBG_FACILITY NFSDBG_FSCACHEstatic struct rb_root nfs_fscache_keys =RB_ROOT ;static DEFINE_SPINLOCK (nfs_fscache_keys_lock);
@@ -86,8 +86,6 @@ void nfs_fscache_get_client_cookie(struct nfs_client *clp) &key, len,NULL ,0 , clp, 0, true); -dfprintk (FSCACHE ,"NFS: get client cookie (0x%p/0x%p)\n" , - clp, clp->fscache); }/*
@@ -95,9 +93,6 @@ void nfs_fscache_get_client_cookie(struct nfs_client *clp)*/ void nfs_fscache_release_client_cookie (struct nfs_client *clp) { -dfprintk (FSCACHE ,"NFS: releasing client cookie (0x%p/0x%p)\n" , - clp, clp->fscache); -fscache_relinquish_cookie (clp->fscache,NULL , false); clp->fscache =NULL ; }
@@ -191,8 +186,6 @@ void nfs_fscache_get_super_cookie(struct super_block *sb, const char *uniq, intsizeof (key->key) + ulen,NULL ,0 , nfss, 0, true); -dfprintk (FSCACHE ,"NFS: get superblock cookie (0x%p/0x%p)\n" , - nfss, nfss->fscache);return ; non_unique:
@@ -211,9 +204,6 @@ void nfs_fscache_release_super_cookie(struct super_block *sb) {struct nfs_server *nfss =NFS_SB (sb); -dfprintk (FSCACHE ,"NFS: releasing superblock cookie (0x%p/0x%p)\n" , - nfss, nfss->fscache); -fscache_relinquish_cookie (nfss->fscache,NULL , false); nfss->fscache =NULL ;
@@ -270,8 +260,6 @@ void nfs_fscache_clear_inode(struct inode *inode)struct nfs_inode *nfsi =NFS_I (inode);struct fscache_cookie *cookie =nfs_i_fscache (inode); -dfprintk (FSCACHE ,"NFS: clear cookie (0x%p/0x%p)\n" , nfsi, cookie); -nfs_fscache_update_auxdata (&auxdata, inode);fscache_relinquish_cookie (cookie, &auxdata, false); nfsi->fscache =NULL ;
Signature · 1 line
1.8.3.1
PATCH v2 7/7 NFS: Remove remaining usages of NFSDBG_FSCACHE
In reply to Dave WysochanskiThe NFS fscache interface has removed all dfprintks so remove the NFSDBG_FSCACHE defines.
--- fs/nfs/fscache-index.c | 2 -- fs/nfs/fscache.c | 2 -- include/uapi/linux/nfs_fs.h | 2 +- 3 files changed, 1 insertion(+), 5 deletions(-)
fs/nfs/fscache-index.c +0 -2
@@ -17,8 +17,6 @@#include "internal.h" #include "fscache.h" -#define NFSDBG_FACILITY NFSDBG_FSCACHE -/* * Define the NFS filesystem for FS-Cache. Upon registration FS-Cache sticks * the cookie for the top-level index object for NFS into here. The top-level
fs/nfs/fscache.c +0 -2
@@ -21,8 +21,6 @@#include "fscache.h" #include "nfstrace.h" -#define NFSDBG_FACILITY NFSDBG_FSCACHE -static struct rb_root nfs_fscache_keys =RB_ROOT ;static DEFINE_SPINLOCK (nfs_fscache_keys_lock);
include/uapi/linux/nfs_fs.h +1 -1
@@ -52,7 +52,7 @@#define NFSDBG_CALLBACK 0x0100#define NFSDBG_CLIENT 0x0200#define NFSDBG_MOUNT 0x0400 -#define NFSDBG_FSCACHE 0x0800 +#define NFSDBG_FSCACHE 0x0800/* unused */ #define NFSDBG_PNFS 0x1000#define NFSDBG_PNFS_LD 0x2000#define NFSDBG_STATE 0x4000
Signature · 1 line
1.8.3.1
Quoted 43 lines · Dave Wysochanski
This patchset is on top of David Howells patchset he just posted as v3 of "fscache: Replace and remove old I/O API" and is based on his fscache-remove-old-io branch at
https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git/log/?h=fscache-remove-old-io
NOTE: fscache-remove-old-io was previously "fscache-iter-3" but it's been renamed to better reflect the purpose.The series is also at:
https://github.com/DaveWysochanskiRH/kernel.git
https://github.com/DaveWysochanskiRH/kernel/tree/fscache-remove-old-io-nfs-fixesTesting is looking ok so far and is still ongoing at BakeAThon and in my local testbed with tracepoints enabled via:
trace-cmd start -e fscache:* -e nfs:* -e nfs4:* -e cachefiles:*Changes in v2 of this series
- Dropped first patch of v1 series (dhowells updated his patch)
- Don't rename or change the value ofNFSDBG_FSCACHE(Trond)
- Renamenfs_readpage_from_fscacheandnfs_readpage_to_fscache
- Rename enable/disable tracepoints to start with "nfs_fscache"
- Rename fscache IO tracepoints to better reflect the new function names
- Place the fscache IO tracepoints at begin and end of the functionsDave Wysochanski (7):
NFS: Usenfs_i_fscache()consistently within NFS fscache code
NFS: Cleanup usage ofnfs_inodein fscache interface and handlei_size
properly
NFS: Convert NFS fscache enable/disable dfprintks to tracepoints
NFS: Rename fscache read and write pages functions
NFS: Replace dfprintks with tracepoints in read and write page
functions
NFS: Remove remaining dfprintks related to fscache cookies
NFS: Remove remaining usages ofNFSDBG_FSCACHEfs/nfs/fscache-index.c | 2 - fs/nfs/fscache.c | 76 +++++++++++++---------------------- fs/nfs/fscache.h | 25 ++++++------ fs/nfs/nfstrace.h | 98 +++++++++++++++++++++++++++++++++++++++++++++ fs/nfs/read.c | 4 +- include/uapi/linux/nfs_fs.h | 2 +- 6 files changed, 140 insertions(+), 67 deletions(-)
Quoted 3 lines
--
1.8.3.1
Just a report on the testing of this patchset, which also tested dhowells fscache-remove-old-io branch. Overall this looks very stable.
I ran some custom unit tests as well as many xfstest runs. I saw no oops or other significant problems during any of the runs. I saw no differences in Failures on xfstest runs between 5.15.0-rc4 and this set.
I ran the following configurations of servers and NFS options for the runs (5.15.0-rc4, then 5.15.0-rc4 + this patchset).
1. hammerspace (pnfs flexfiles): vers=4.1,fsc; vers=4.1,nofsc; vers=4.2,fsc; vers=4.2,nofsc
2. ontap9.x (pnfs filelayout): vers=4.1,fsc; vers=4.1,nofsc
3. rhel7u8 (3.10.0-1127.8.2.el7): vers=3,nofsc; vers=4.0,nofsc; vers=4.0,fsc; vers=4.2,fsc; vers=4.2,nofsc
4. rhel8 (4.18.0-193.28.1.el8): vers=4.2,fsc