Cleanups for NFS fscache and convert from dfprintk to trace events
Subsystems (2)
cover Cleanups for NFS fscache and convert from dfprintk to trace events
This is a re-post of these patches, unchanged from previous postings [1][2], rebased on top of 5.17-rc5.
The patches were dependent on dhowells patchset which was taken in the last merge window, so they apply on 5.17-rc5 cleanly now.
[1] https://marc.info/?l=linux-nfs&m=164225455702418&w=2
[2] https://marc.info/?l=linux-nfs&m=163976362831065&w=2
Dave Wysochanski (4):
NFS: Cleanup usage of nfs_inode in fscache interface
NFS: Rename fscache read and write pages functions
NFS: Replace dfprintks with tracepoints in fscache read and write page functions
NFS: Remove remaining dfprintks related to fscache and remove NFSDBG_FSCACHE
fs/nfs/fscache.c | 53 +++++++-------------- fs/nfs/fscache.h | 45 ++++++++---------- fs/nfs/nfstrace.h | 91 +++++++++++++++++++++++++++++++++++++ fs/nfs/read.c | 4 +- include/uapi/linux/nfs_fs.h | 2 +- 5 files changed, 130 insertions(+), 65 deletions(-)
Signature · 1 line
2.27.1
PATCH 1/4 NFS: Cleanup usage of nfs_inode in fscache interface
A number of places in the fscache interface used nfs_inode when inode could be used, simplifying the code.
--- fs/nfs/fscache.c | 10 ++++------ fs/nfs/fscache.h | 18 +++++++++--------- 2 files changed, 13 insertions(+), 15 deletions(-)
fs/nfs/fscache.c +4 -6
@@ -173,7 +173,7 @@ 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, 0,
@@ -181,7 +181,7 @@ void nfs_fscache_init_inode(struct inode *inode) nfsi->fh.size, &auxdata,/* aux_data */ sizeof (auxdata), - i_size_read(&nfsi->vfs_inode)); + i_size_read(inode)); }/*
@@ -220,7 +220,6 @@ void nfs_fscache_clear_inode(struct inode *inode)void nfs_fscache_open_file (struct inode *inode,struct file *filp) {struct nfs_fscache_inode_auxdata auxdata; -struct nfs_inode *nfsi =NFS_I (inode);struct fscache_cookie *cookie =nfs_i_fscache (inode);bool open_for_write =inode_is_open_for_write (inode);
@@ -230,7 +229,7 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp)fscache_use_cookie (cookie, open_for_write);if (open_for_write) {dfprintk (FSCACHE ,"NFS: nfsi 0x%p disabling cache\n" , nfsi); -nfs_fscache_update_auxdata (&auxdata, nfsi); +nfs_fscache_update_auxdata (&auxdata, inode);fscache_invalidate (cookie, &auxdata,i_size_read (inode),FSCACHE_INVAL_DIO_WRITE ); }
@@ -240,11 +239,10 @@ EXPORT_SYMBOL_GPL(nfs_fscache_open_file);void nfs_fscache_release_file (struct inode *inode,struct file *filp) {struct nfs_fscache_inode_auxdata auxdata; -struct nfs_inode *nfsi =NFS_I (inode);struct fscache_cookie *cookie =nfs_i_fscache (inode);if (fscache_cookie_valid (cookie)) { -nfs_fscache_update_auxdata (&auxdata, nfsi); +nfs_fscache_update_auxdata (&auxdata, inode);fscache_unuse_cookie (cookie, &auxdata,NULL ); } }
fs/nfs/fscache.h +9 -9
@@ -86,16 +86,16 @@ static inline void nfs_readpage_to_fscache(struct inode *inode, }static inline 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); }/*
@@ -107,9 +107,9 @@ static inline void nfs_fscache_invalidate(struct inode *inode, int flags)struct nfs_inode *nfsi =NFS_I (inode);if (nfsi->fscache) { -nfs_fscache_update_auxdata (&auxdata, nfsi); +nfs_fscache_update_auxdata (&auxdata, inode);fscache_invalidate (nfsi->fscache, &auxdata, -i_size_read (&nfsi->vfs_inode), flags); +i_size_read (inode), flags); } }
Signature · 1 line
2.27.1
PATCH 2/4 NFS: Rename fscache read and write pages functions
In reply to Dave WysochanskiRename NFS fscache functions in a more consistent fashion to better reflect when we read from and write to fscache.
--- fs/nfs/fscache.c | 6 +++--- fs/nfs/fscache.h | 27 ++++++++++----------------- fs/nfs/read.c | 4 ++-- 3 files changed, 15 insertions(+), 22 deletions(-)
fs/nfs/fscache.c +3 -3
@@ -317,7 +317,7 @@ static int fscache_fallback_write_page(struct inode *inode, struct page *page,/* * 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;
@@ -351,7 +351,7 @@ int __nfs_readpage_from_fscache(struct inode *inode, struct page *page)* Store a newly fetched page in fscache. We can be certain there's no page * stored in the cache as yet otherwise we would've read it from there. */ -void __nfs_readpage_to_fscache (struct inode *inode,struct page *page) +void __nfs_fscache_write_page (struct inode *inode,struct page *page) {int ret;
@@ -362,7 +362,7 @@ void __nfs_readpage_to_fscache(struct inode *inode, struct page *page) ret =fscache_fallback_write_page (inode, page, true);dfprintk (FSCACHE , -"NFS: readpage_to_fscache: p:%p(i:%lu f:%lx) ret %d\n" , +"NFS: nfs_fscache_write_page: p:%p(i:%lu f:%lx) ret %d\n" , page, page->index, page->flags, ret);if (ret !=0 ) {
fs/nfs/fscache.h +10 -17
@@ -45,10 +45,8 @@ extern void nfs_fscache_clear_inode(struct inode *);extern void nfs_fscache_open_file (struct inode *,struct file *);extern void nfs_fscache_release_file (struct inode *,struct file *); -extern int __nfs_readpage_from_fscache (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 int __nfs_fscache_read_page (struct inode *,struct page *); +extern void __nfs_fscache_write_page (struct inode *,struct page *);static inline int nfs_fscache_release_page (struct page *page,gfp_t gfp) {
@@ -66,11 +64,10 @@ static inline int nfs_fscache_release_page(struct page *page, gfp_t gfp)/* * 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 (inode)->fscache) -return __nfs_readpage_from_fscache (inode, page); +if (nfs_i_fscache (inode)) +return __nfs_fscache_read_page (inode, page);return -ENOBUFS ; }
@@ -78,11 +75,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 (inode)->fscache) -__nfs_readpage_to_fscache (inode, page); +if (nfs_i_fscache (inode)) +__nfs_fscache_write_page (inode, page); } static inline void nfs_fscache_update_auxdata(struct nfs_fscache_inode_auxdata *auxdata,
@@ -136,15 +133,11 @@ static inline int nfs_fscache_release_page(struct page *page, gfp_t gfp) {return 1 ;/* True: may release page */ } -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) {return -ENOBUFS ; } -static inline void nfs_readpage_to_fscache (struct inode *inode, -struct page *page) {} - - +static inline void nfs_fscache_write_page (struct inode *inode,struct page *page) {}static inline void nfs_fscache_invalidate (struct inode *inode,int flags) {}static inline const char *nfs_server_fscache_state (struct nfs_server *server)
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 @@ readpage_async_filler(void *data, struct page *page) 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
2.27.1
PATCH 3/4 NFS: Replace dfprintks with tracepoints in fscache 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 | 91 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+), 18 deletions(-)
fs/nfs/fscache.c +11 -18
@@ -19,6 +19,7 @@#include "internal.h" #include "iostat.h" #include "fscache.h" +#include "nfstrace.h" #define NFSDBG_FACILITY NFSDBG_FSCACHE
@@ -321,30 +322,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 (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_exit (inode, page, ret); +return ret; }/*
@@ -355,20 +353,15 @@ 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 (inode, page, true); -dfprintk (FSCACHE , -"NFS: nfs_fscache_write_page: 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_exit (inode, page, ret); }
fs/nfs/nfstrace.h +91 -0
97 lines not on this page · raw message
Signature · 1 line
2.27.1
PATCH 4/4 NFS: Remove remaining dfprintks related to fscache and remove NFSDBG_FSCACHE
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.
The NFS fscache interface has removed all dfprintks so remove the NFSDBG_FSCACHE defines.
--- fs/nfs/fscache.c | 10 ---------- include/uapi/linux/nfs_fs.h | 2 +- 2 files changed, 1 insertion(+), 11 deletions(-)
fs/nfs/fscache.c +0 -10
@@ -21,8 +21,6 @@#include "fscache.h" #include "nfstrace.h" -#define NFSDBG_FACILITY NFSDBG_FSCACHE -#define NFS_MAX_KEY_LEN 1000static bool nfs_append_int (char *key,int *_len,unsigned long long x)
@@ -129,8 +127,6 @@ int nfs_fscache_get_super_cookie(struct super_block *sb, const char *uniq, int u vcookie =fscache_acquire_volume (key,NULL ,/* preferred_cache */ NULL ,0 /* coherency_data */ ); -dfprintk (FSCACHE ,"NFS: get superblock cookie (0x%p/0x%p)\n" , - nfss, vcookie);if (IS_ERR (vcookie)) {if (vcookie !=ERR_PTR (-EBUSY )) {kfree (key);
@@ -153,9 +149,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_volume (nfss->fscache,NULL , false); nfss->fscache =NULL ;kfree (nfss->fscache_uniq);
@@ -193,8 +186,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); -fscache_relinquish_cookie (cookie, false); nfsi->fscache =NULL ; }
@@ -229,7 +220,6 @@ void nfs_fscache_open_file(struct inode *inode, struct file *filp)fscache_use_cookie (cookie, open_for_write);if (open_for_write) { -dfprintk (FSCACHE ,"NFS: nfsi 0x%p disabling cache\n" , nfsi);nfs_fscache_update_auxdata (&auxdata, inode);fscache_invalidate (cookie, &auxdata,i_size_read (inode),FSCACHE_INVAL_DIO_WRITE );
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
2.27.1