linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Chuck Lever <chuck.lever@oracle.com>, Neil Brown <neilb@suse.de>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
	Trond Myklebust <trondmy@kernel.org>,
	Anna Schumaker <anna@kernel.org>,
	Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>
Cc: Tom Haynes <loghyr@gmail.com>,
	linux-nfs@vger.kernel.org,  linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH v4 01/11] nfsd: fix initial getattr on write delegation
Date: Fri, 06 Sep 2024 10:08:29 -0400	[thread overview]
Message-ID: <f20e49db181de1152ffb1b102450963937b4ec4f.camel@kernel.org> (raw)
In-Reply-To: <20240905-delstid-v4-1-d3e5fd34d107@kernel.org>

On Thu, 2024-09-05 at 08:41 -0400, Jeff Layton wrote:
> At this point in compound processing, currentfh refers to the parent of
> the file, not the file itself. Get the correct dentry from the delegation
> stateid instead.
> 
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/nfsd/nfs4state.c | 31 +++++++++++++++++++++++--------
>  1 file changed, 23 insertions(+), 8 deletions(-)
> 
> diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> index df69dc6af467..db90677fc016 100644
> --- a/fs/nfsd/nfs4state.c
> +++ b/fs/nfsd/nfs4state.c
> @@ -5914,6 +5914,26 @@ static void nfsd4_open_deleg_none_ext(struct nfsd4_open *open, int status)
>  	}
>  }
>  
> +static bool
> +nfs4_delegation_stat(struct nfs4_delegation *dp, struct svc_fh *currentfh,
> +		     struct kstat *stat)
> +{
> +	struct nfsd_file *nf = find_rw_file(dp->dl_stid.sc_file);
> +	struct path path;
> +
> +	if (!nf)
> +		return false;
> +
> +	path.mnt = currentfh->fh_export->ex_path.mnt;
> +	path.dentry = file_dentry(nf->nf_file);
> +
> +	if (vfs_getattr(&path, stat,
> +			(STATX_INO | STATX_SIZE | STATX_CTIME | STATX_CHANGE_COOKIE),

Minor oversight here.

I added STATX_INO when I was debugging, but we don't need it here. We
should probably drop that flag (though it's mostly harmless). Chuck,
would you be ok with fixing that up?

> +			AT_STATX_SYNC_AS_STAT))
> +		return false;
> +	return true;
> +}
> +
>  /*
>   * The Linux NFS server does not offer write delegations to NFSv4.0
>   * clients in order to avoid conflicts between write delegations and
> @@ -5949,7 +5969,6 @@ nfs4_open_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp,
>  	int cb_up;
>  	int status = 0;
>  	struct kstat stat;
> -	struct path path;
>  
>  	cb_up = nfsd4_cb_channel_good(oo->oo_owner.so_client);
>  	open->op_recall = false;
> @@ -5985,20 +6004,16 @@ nfs4_open_delegation(struct nfsd4_open *open, struct nfs4_ol_stateid *stp,
>  	memcpy(&open->op_delegate_stateid, &dp->dl_stid.sc_stateid, sizeof(dp->dl_stid.sc_stateid));
>  
>  	if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE) {
> -		open->op_delegate_type = NFS4_OPEN_DELEGATE_WRITE;
> -		trace_nfsd_deleg_write(&dp->dl_stid.sc_stateid);
> -		path.mnt = currentfh->fh_export->ex_path.mnt;
> -		path.dentry = currentfh->fh_dentry;
> -		if (vfs_getattr(&path, &stat,
> -				(STATX_SIZE | STATX_CTIME | STATX_CHANGE_COOKIE),
> -				AT_STATX_SYNC_AS_STAT)) {
> +		if (!nfs4_delegation_stat(dp, currentfh, &stat)) {
>  			nfs4_put_stid(&dp->dl_stid);
>  			destroy_delegation(dp);
>  			goto out_no_deleg;
>  		}
> +		open->op_delegate_type = NFS4_OPEN_DELEGATE_WRITE;
>  		dp->dl_cb_fattr.ncf_cur_fsize = stat.size;
>  		dp->dl_cb_fattr.ncf_initial_cinfo =
>  			nfsd4_change_attribute(&stat, d_inode(currentfh->fh_dentry));
> +		trace_nfsd_deleg_write(&dp->dl_stid.sc_stateid);
>  	} else {
>  		open->op_delegate_type = NFS4_OPEN_DELEGATE_READ;
>  		trace_nfsd_deleg_read(&dp->dl_stid.sc_stateid);
> 

Thanks!
-- 
Jeff Layton <jlayton@kernel.org>

  parent reply	other threads:[~2024-09-06 14:08 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-05 12:41 [PATCH v4 00/11] nfsd: implement the "delstid" draft Jeff Layton
2024-09-05 12:41 ` [PATCH v4 01/11] nfsd: fix initial getattr on write delegation Jeff Layton
2024-09-05 15:46   ` Chuck Lever
2024-09-05 17:37     ` Jeff Layton
2024-09-06 14:08   ` Jeff Layton [this message]
2024-09-06 14:36     ` Chuck Lever
2024-09-08 18:00   ` Chuck Lever
2024-09-08 20:40     ` Jeff Layton
2024-12-27  6:42       ` Cedric Blancher
2024-12-27  7:53   ` Cedric Blancher
2024-12-27 17:59     ` Chuck Lever
2024-09-05 12:41 ` [PATCH v4 02/11] nfsd: drop the ncf_cb_bmap field Jeff Layton
2024-09-05 12:41 ` [PATCH v4 03/11] nfsd: don't request change attr in CB_GETATTR once file is modified Jeff Layton
2024-09-05 12:41 ` [PATCH v4 04/11] nfsd: drop the nfsd4_fattr_args "size" field Jeff Layton
2024-09-05 12:41 ` [PATCH v4 05/11] nfsd: have nfsd4_deleg_getattr_conflict pass back write deleg pointer Jeff Layton
2024-09-05 12:41 ` [PATCH v4 06/11] nfs_common: make include/linux/nfs4.h include generated nfs4.h Jeff Layton
2024-09-05 12:41 ` [PATCH v4 07/11] nfsd: add support for FATTR4_OPEN_ARGUMENTS Jeff Layton
2024-09-05 12:41 ` [PATCH v4 08/11] nfsd: implement OPEN_ARGS_SHARE_ACCESS_WANT_OPEN_XOR_DELEGATION Jeff Layton
2024-09-05 12:41 ` [PATCH v4 09/11] fs: handle delegated timestamps in setattr_copy_mgtime Jeff Layton
2024-09-05 15:44   ` Chuck Lever
2024-09-05 17:46     ` Jeff Layton
2024-09-07 10:21       ` Christian Brauner
2024-09-07 10:22   ` (subset) " Christian Brauner
2024-09-05 12:41 ` [PATCH v4 10/11] nfsd: add support for delegated timestamps Jeff Layton
2024-09-05 12:41 ` [PATCH v4 11/11] nfsd: handle delegated timestamps in SETATTR Jeff Layton
2024-09-05 18:09 ` [PATCH v4 00/11] nfsd: implement the "delstid" draft cel

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=f20e49db181de1152ffb1b102450963937b4ec4f.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=anna@kernel.org \
    --cc=brauner@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=jack@suse.cz \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=loghyr@gmail.com \
    --cc=neilb@suse.de \
    --cc=okorniev@redhat.com \
    --cc=tom@talpey.com \
    --cc=trondmy@kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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).