public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Dai Ngo <dai.ngo@oracle.com>,
	chuck.lever@oracle.com, neilb@suse.de,  okorniev@redhat.com,
	tom@talpey.com
Cc: linux-nfs@vger.kernel.org, sagi@grimberg.me
Subject: Re: [PATCH 1/1] NFSD: release read access of nfs4_file when a write delegation is returned
Date: Tue, 13 May 2025 13:27:24 -0400	[thread overview]
Message-ID: <40fcc037506a8964a836bbe9e7ece752ad67be18.camel@kernel.org> (raw)
In-Reply-To: <1747152651-23087-1-git-send-email-dai.ngo@oracle.com>

On Tue, 2025-05-13 at 09:10 -0700, Dai Ngo wrote:
> When a write delegation is returned, check if read access was added
> to nfs4_file when client opens file with WRONLY, and release it.
> 
> Signed-off-by: Dai Ngo <dai.ngo@oracle.com>
> ---
>  fs/nfsd/nfs4state.c | 9 ++++++++-
>  fs/nfsd/state.h     | 1 +
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index 2bd63594d8da..5e47d9f85ab5 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -1207,14 +1207,19 @@ nfs4_inc_and_copy_stateid(stateid_t *dst, struct nfs4_stid *stid)
>  static void put_deleg_file(struct nfs4_file *fp)
>  {
>  	struct nfsd_file *nf = NULL;
> +	struct nfsd_file *rnf = NULL;
>  
>  	spin_lock(&fp->fi_lock);
> -	if (--fp->fi_delegees == 0)
> +	if (--fp->fi_delegees == 0) {
>  		swap(nf, fp->fi_deleg_file);
> +		swap(rnf, fp->fi_rdeleg_file);
> +	}
>  	spin_unlock(&fp->fi_lock);
>  
>  	if (nf)
>  		nfsd_file_put(nf);
> +	if (rnf)
> +		nfs4_file_put_access(fp, NFS4_SHARE_ACCESS_READ);
>  }
>  
>  static void nfs4_unlock_deleg_lease(struct nfs4_delegation *dp)
> @@ -4738,6 +4743,7 @@ static void nfsd4_file_init(const struct svc_fh *fh, struct nfs4_file *fp)
>  	INIT_LIST_HEAD(&fp->fi_clnt_odstate);
>  	fh_copy_shallow(&fp->fi_fhandle, &fh->fh_handle);
>  	fp->fi_deleg_file = NULL;
> +	fp->fi_rdeleg_file = NULL;
>  	fp->fi_had_conflict = false;
>  	fp->fi_share_deny = 0;
>  	memset(fp->fi_fds, 0, sizeof(fp->fi_fds));
> @@ -6171,6 +6177,7 @@ nfsd4_add_rdaccess_to_wrdeleg(struct svc_rqst *rqstp, struct nfsd4_open *open,
>  		__nfs4_file_get_access(fp, NFS4_SHARE_ACCESS_READ);
>  		fp = stp->st_stid.sc_file;
>  		fp->fi_fds[O_RDONLY] = nf;
> +		fp->fi_rdeleg_file = nf;
>  		spin_unlock(&fp->fi_lock);
>  	}
>  	return true;
> diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h
> index 1995bca158b8..8adc2550129e 100644
> --- a/fs/nfsd/state.h
> +++ b/fs/nfsd/state.h
> @@ -665,6 +665,7 @@ struct nfs4_file {
>  	atomic_t		fi_access[2];
>  	u32			fi_share_deny;
>  	struct nfsd_file	*fi_deleg_file;
> +	struct nfsd_file	*fi_rdeleg_file;
>  	int			fi_delegees;
>  	struct knfsd_fh		fi_fhandle;
>  	bool			fi_had_conflict;

Reviewed-by: Jeff Layton <jlayton@kernel.org>

  reply	other threads:[~2025-05-13 17:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-13 16:10 [PATCH 1/1] NFSD: release read access of nfs4_file when a write delegation is returned Dai Ngo
2025-05-13 17:27 ` Jeff Layton [this message]
2025-05-15 19:54 ` Chuck Lever

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=40fcc037506a8964a836bbe9e7ece752ad67be18.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=dai.ngo@oracle.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=okorniev@redhat.com \
    --cc=sagi@grimberg.me \
    --cc=tom@talpey.com \
    /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