linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anna Schumaker <schumaker.anna@gmail.com>
To: trondmy@kernel.org
Cc: Linux NFS Mailing List <linux-nfs@vger.kernel.org>
Subject: Re: [PATCH 2/4] pNFS: We want return-on-close to complete when evicting the inode
Date: Wed, 6 Jan 2021 10:25:01 -0500	[thread overview]
Message-ID: <CAFX2Jfmqs2oEN3KtjfSViyhFqdt=v9ty3oGz4HiqpWw=xNVh9A@mail.gmail.com> (raw)
In-Reply-To: <20210105152620.754453-2-trondmy@kernel.org>

Hi Trond,

On Tue, Jan 5, 2021 at 10:30 AM <trondmy@kernel.org> wrote:
>
> From: Trond Myklebust <trond.myklebust@hammerspace.com>
>
> If the inode is being evicted, it should be safe to run return-on-close,
> so we should do it to ensure we don't inadvertently leak layout segments.
>
> Fixes: 1c5bd76d17cc ("pNFS: Enable layoutreturn operation for return-on-close")
> Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> ---
>  fs/nfs/nfs4proc.c | 26 ++++++++++----------------
>  fs/nfs/pnfs.c     |  8 +++-----
>  fs/nfs/pnfs.h     |  6 ++----
>  3 files changed, 15 insertions(+), 25 deletions(-)
>
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index 0ce04e0e5d82..bbca5c46e400 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -3536,10 +3536,8 @@ static void nfs4_close_done(struct rpc_task *task, void *data)
>         trace_nfs4_close(state, &calldata->arg, &calldata->res, task->tk_status);
>
>         /* Handle Layoutreturn errors */
> -       if (pnfs_roc_done(task, calldata->inode,
> -                               &calldata->arg.lr_args,
> -                               &calldata->res.lr_res,
> -                               &calldata->res.lr_ret) == -EAGAIN)
> +       if (pnfs_roc_done(task, &calldata->arg.lr_args, &calldata->res.lr_res,
> +                         &calldata->res.lr_ret) == -EAGAIN)
>                 goto out_restart;
>
>         /* hmm. we are done with the inode, and in the process of freeing
> @@ -6384,10 +6382,8 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata)
>         trace_nfs4_delegreturn_exit(&data->args, &data->res, task->tk_status);
>
>         /* Handle Layoutreturn errors */
> -       if (pnfs_roc_done(task, data->inode,
> -                               &data->args.lr_args,
> -                               &data->res.lr_res,
> -                               &data->res.lr_ret) == -EAGAIN)
> +       if (pnfs_roc_done(task, &data->args.lr_args, &data->res.lr_res,
> +                         &data->res.lr_ret) == -EAGAIN)
>                 goto out_restart;
>
>         switch (task->tk_status) {
> @@ -6441,10 +6437,10 @@ static void nfs4_delegreturn_release(void *calldata)
>         struct nfs4_delegreturndata *data = calldata;
>         struct inode *inode = data->inode;
>
> +       if (data->lr.roc)
> +               pnfs_roc_release(&data->lr.arg, &data->lr.res,
> +                                data->res.lr_ret);
>         if (inode) {
> -               if (data->lr.roc)
> -                       pnfs_roc_release(&data->lr.arg, &data->lr.res,
> -                                       data->res.lr_ret);
>                 nfs_post_op_update_inode_force_wcc(inode, &data->fattr);
>                 nfs_iput_and_deactive(inode);
>         }
> @@ -6520,16 +6516,14 @@ static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred,
>         nfs_fattr_init(data->res.fattr);
>         data->timestamp = jiffies;
>         data->rpc_status = 0;
> -       data->lr.roc = pnfs_roc(inode, &data->lr.arg, &data->lr.res, cred);
>         data->inode = nfs_igrab_and_active(inode);
> -       if (data->inode) {
> +       if (data->inode || issync) {
> +               data->lr.roc = pnfs_roc(inode, &data->lr.arg, &data->lr.res,
> +                                       cred);
>                 if (data->lr.roc) {
>                         data->args.lr_args = &data->lr.arg;
>                         data->res.lr_res = &data->lr.res;
>                 }
> -       } else if (data->lr.roc) {
> -               pnfs_roc_release(&data->lr.arg, &data->lr.res, 0);
> -               data->lr.roc = false;
>         }
>
>         task_setup_data.callback_data = data;
> diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c
> index ccc89fab1802..a18b1992b2fb 100644
> --- a/fs/nfs/pnfs.c
> +++ b/fs/nfs/pnfs.c
> @@ -1509,10 +1509,8 @@ bool pnfs_roc(struct inode *ino,
>         return false;
>  }
>
> -int pnfs_roc_done(struct rpc_task *task, struct inode *inode,
> -               struct nfs4_layoutreturn_args **argpp,
> -               struct nfs4_layoutreturn_res **respp,
> -               int *ret)
> +int pnfs_roc_done(struct rpc_task *task, struct nfs4_layoutreturn_args **argpp,
> +                 struct nfs4_layoutreturn_res **respp, int *ret)
>  {
>         struct nfs4_layoutreturn_args *arg = *argpp;
>         int retval = -EAGAIN;
> @@ -1545,7 +1543,7 @@ int pnfs_roc_done(struct rpc_task *task, struct inode *inode,
>                 return 0;
>         case -NFS4ERR_OLD_STATEID:
>                 if (!nfs4_layout_refresh_old_stateid(&arg->stateid,
> -                                       &arg->range, inode))
> +                                                    &arg->range, arg->inode))
>                         break;
>                 *ret = -NFS4ERR_NOMATCHING_LAYOUT;
>                 return -EAGAIN;
> diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h
> index bbd3de1025f2..4d5ee568411d 100644
> --- a/fs/nfs/pnfs.h
> +++ b/fs/nfs/pnfs.h
> @@ -297,10 +297,8 @@ bool pnfs_roc(struct inode *ino,
>                 struct nfs4_layoutreturn_args *args,
>                 struct nfs4_layoutreturn_res *res,
>                 const struct cred *cred);
> -int pnfs_roc_done(struct rpc_task *task, struct inode *inode,
> -               struct nfs4_layoutreturn_args **argpp,
> -               struct nfs4_layoutreturn_res **respp,
> -               int *ret);
> +int pnfs_roc_done(struct rpc_task *task, struct nfs4_layoutreturn_args **argpp,
> +                 struct nfs4_layoutreturn_res **respp, int *ret);

I think you also need to make this change to the fallback definition
(for CONFIG_NFS_V4=n)

Thanks,
Anna

>  void pnfs_roc_release(struct nfs4_layoutreturn_args *args,
>                 struct nfs4_layoutreturn_res *res,
>                 int ret);
> --
> 2.29.2
>

      parent reply	other threads:[~2021-01-06 15:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-05 15:26 [PATCH 1/4] pNFS: Mark layout for return if return-on-close was not sent trondmy
2021-01-05 15:26 ` [PATCH 2/4] pNFS: We want return-on-close to complete when evicting the inode trondmy
2021-01-05 15:26   ` [PATCH 3/4] pNFS: Clean up pnfs_layoutreturn_free_lsegs() trondmy
2021-01-05 15:26     ` [PATCH 4/4] pNFS: Stricter ordering of layoutget and layoutreturn trondmy
2021-01-06 15:25   ` Anna Schumaker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAFX2Jfmqs2oEN3KtjfSViyhFqdt=v9ty3oGz4HiqpWw=xNVh9A@mail.gmail.com' \
    --to=schumaker.anna@gmail.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=trondmy@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).