2022-02-23 22:20:52

by Trond Myklebust

[permalink] [raw]
Subject: [PATCH v7 01/21] NFS: constify nfs_server_capable() and nfs_have_writebacks()

From: Trond Myklebust <[email protected]>

Signed-off-by: Trond Myklebust <[email protected]>
---
include/linux/nfs_fs.h | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 72a732a5103c..6e10725887d1 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -363,7 +363,7 @@ static inline void nfs_mark_for_revalidate(struct inode *inode)
spin_unlock(&inode->i_lock);
}

-static inline int nfs_server_capable(struct inode *inode, int cap)
+static inline int nfs_server_capable(const struct inode *inode, int cap)
{
return NFS_SERVER(inode)->caps & cap;
}
@@ -587,12 +587,11 @@ extern struct nfs_commit_data *nfs_commitdata_alloc(bool never_fail);
extern void nfs_commit_free(struct nfs_commit_data *data);
bool nfs_commit_end(struct nfs_mds_commit_info *cinfo);

-static inline int
-nfs_have_writebacks(struct inode *inode)
+static inline bool nfs_have_writebacks(const struct inode *inode)
{
if (S_ISREG(inode->i_mode))
return atomic_long_read(&NFS_I(inode)->nrequests) != 0;
- return 0;
+ return false;
}

/*
--
2.35.1


2022-02-24 01:29:26

by Trond Myklebust

[permalink] [raw]
Subject: [PATCH v7 02/21] NFS: Trace lookup revalidation failure

From: Trond Myklebust <[email protected]>

Enable tracing of lookup revalidation failures.

Signed-off-by: Trond Myklebust <[email protected]>
---
fs/nfs/dir.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index ebddc736eac2..1aa55cac9d9a 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -1474,9 +1474,7 @@ nfs_lookup_revalidate_done(struct inode *dir, struct dentry *dentry,
{
switch (error) {
case 1:
- dfprintk(LOOKUPCACHE, "NFS: %s(%pd2) is valid\n",
- __func__, dentry);
- return 1;
+ break;
case 0:
/*
* We can't d_drop the root of a disconnected tree:
@@ -1485,13 +1483,10 @@ nfs_lookup_revalidate_done(struct inode *dir, struct dentry *dentry,
* inodes on unmount and further oopses.
*/
if (inode && IS_ROOT(dentry))
- return 1;
- dfprintk(LOOKUPCACHE, "NFS: %s(%pd2) is invalid\n",
- __func__, dentry);
- return 0;
+ error = 1;
+ break;
}
- dfprintk(LOOKUPCACHE, "NFS: %s(%pd2) lookup returned error %d\n",
- __func__, dentry, error);
+ trace_nfs_lookup_revalidate_exit(dir, dentry, 0, error);
return error;
}

@@ -1623,9 +1618,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry,
goto out_bad;

trace_nfs_lookup_revalidate_enter(dir, dentry, flags);
- error = nfs_lookup_revalidate_dentry(dir, dentry, inode);
- trace_nfs_lookup_revalidate_exit(dir, dentry, flags, error);
- return error;
+ return nfs_lookup_revalidate_dentry(dir, dentry, inode);
out_valid:
return nfs_lookup_revalidate_done(dir, dentry, inode, 1);
out_bad:
--
2.35.1

2022-02-24 01:38:08

by Trond Myklebust

[permalink] [raw]
Subject: [PATCH v7 03/21] NFS: Use kzalloc() to avoid initialising the nfs_open_dir_context

From: Trond Myklebust <[email protected]>

Signed-off-by: Trond Myklebust <[email protected]>
---
fs/nfs/dir.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 1aa55cac9d9a..8f17aaebcd77 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -69,18 +69,15 @@ const struct address_space_operations nfs_dir_aops = {
.freepage = nfs_readdir_clear_array,
};

-static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode *dir)
+static struct nfs_open_dir_context *
+alloc_nfs_open_dir_context(struct inode *dir)
{
struct nfs_inode *nfsi = NFS_I(dir);
struct nfs_open_dir_context *ctx;
- ctx = kmalloc(sizeof(*ctx), GFP_KERNEL_ACCOUNT);
+
+ ctx = kzalloc(sizeof(*ctx), GFP_KERNEL_ACCOUNT);
if (ctx != NULL) {
- ctx->duped = 0;
ctx->attr_gencount = nfsi->attr_gencount;
- ctx->dir_cookie = 0;
- ctx->dup_cookie = 0;
- ctx->page_index = 0;
- ctx->eof = false;
spin_lock(&dir->i_lock);
if (list_empty(&nfsi->open_files) &&
(nfsi->cache_validity & NFS_INO_DATA_INVAL_DEFER))
--
2.35.1

2022-02-24 15:24:56

by Benjamin Coddington

[permalink] [raw]
Subject: Re: [PATCH v7 02/21] NFS: Trace lookup revalidation failure

On 23 Feb 2022, at 16:12, [email protected] wrote:

> From: Trond Myklebust <[email protected]>
>
> Enable tracing of lookup revalidation failures.
>
> Signed-off-by: Trond Myklebust <[email protected]>
> ---
> fs/nfs/dir.c | 17 +++++------------
> 1 file changed, 5 insertions(+), 12 deletions(-)
>
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index ebddc736eac2..1aa55cac9d9a 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -1474,9 +1474,7 @@ nfs_lookup_revalidate_done(struct inode *dir,
> struct dentry *dentry,
> {
> switch (error) {
> case 1:
> - dfprintk(LOOKUPCACHE, "NFS: %s(%pd2) is valid\n",
> - __func__, dentry);
> - return 1;
> + break;
> case 0:
> /*
> * We can't d_drop the root of a disconnected tree:
> @@ -1485,13 +1483,10 @@ nfs_lookup_revalidate_done(struct inode *dir,
> struct dentry *dentry,
> * inodes on unmount and further oopses.
> */
> if (inode && IS_ROOT(dentry))
> - return 1;
> - dfprintk(LOOKUPCACHE, "NFS: %s(%pd2) is invalid\n",
> - __func__, dentry);
> - return 0;
> + error = 1;
> + break;
> }
> - dfprintk(LOOKUPCACHE, "NFS: %s(%pd2) lookup returned error %d\n",
> - __func__, dentry, error);
> + trace_nfs_lookup_revalidate_exit(dir, dentry, 0, error);


There's a path through nfs4_lookup_revalidate that will now only produce
this exit tracepoint. Does it need the _enter tracepoint added?

Ben

2022-02-25 07:53:43

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH v7 02/21] NFS: Trace lookup revalidation failure

On Thu, 2022-02-24 at 09:14 -0500, Benjamin Coddington wrote:
> On 23 Feb 2022, at 16:12, [email protected] wrote:
>
> > From: Trond Myklebust <[email protected]>
> >
> > Enable tracing of lookup revalidation failures.
> >
> > Signed-off-by: Trond Myklebust <[email protected]>
> > ---
> >  fs/nfs/dir.c | 17 +++++------------
> >  1 file changed, 5 insertions(+), 12 deletions(-)
> >
> > diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> > index ebddc736eac2..1aa55cac9d9a 100644
> > --- a/fs/nfs/dir.c
> > +++ b/fs/nfs/dir.c
> > @@ -1474,9 +1474,7 @@ nfs_lookup_revalidate_done(struct inode *dir,
> > struct dentry *dentry,
> >  {
> >         switch (error) {
> >         case 1:
> > -               dfprintk(LOOKUPCACHE, "NFS: %s(%pd2) is valid\n",
> > -                       __func__, dentry);
> > -               return 1;
> > +               break;
> >         case 0:
> >                 /*
> >                  * We can't d_drop the root of a disconnected tree:
> > @@ -1485,13 +1483,10 @@ nfs_lookup_revalidate_done(struct inode
> > *dir,
> > struct dentry *dentry,
> >                  * inodes on unmount and further oopses.
> >                  */
> >                 if (inode && IS_ROOT(dentry))
> > -                       return 1;
> > -               dfprintk(LOOKUPCACHE, "NFS: %s(%pd2) is invalid\n",
> > -                               __func__, dentry);
> > -               return 0;
> > +                       error = 1;
> > +               break;
> >         }
> > -       dfprintk(LOOKUPCACHE, "NFS: %s(%pd2) lookup returned error
> > %d\n",
> > -                               __func__, dentry, error);
> > +       trace_nfs_lookup_revalidate_exit(dir, dentry, 0, error);
>
>
> There's a path through nfs4_lookup_revalidate that will now only
> produce
> this exit tracepoint.  Does it need the _enter tracepoint added?


You're thinking about the nfs_lookup_revalidate_delegated() path? The
_enter() tracepoint doesn't provide any useful information that isn't
already provided by the _exit(), AFAICS.

--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]