netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Trond Myklebust <trondmy@hammerspace.com>,
	"chuck.lever@oracle.com" <chuck.lever@oracle.com>
Cc: "senozhatsky@chromium.org" <senozhatsky@chromium.org>,
	 "sfrench@samba.org" <sfrench@samba.org>,
	"ecryptfs@vger.kernel.org" <ecryptfs@vger.kernel.org>,
	 "linux-unionfs@vger.kernel.org" <linux-unionfs@vger.kernel.org>,
	"davem@davemloft.net" <davem@davemloft.net>,
	 "viro@zeniv.linux.org.uk" <viro@zeniv.linux.org.uk>,
	"anna@kernel.org" <anna@kernel.org>,
	"jack@suse.cz" <jack@suse.cz>, "tom@talpey.com" <tom@talpey.com>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	 "linux-fsdevel@vger.kernel.org" <linux-fsdevel@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"ronniesahlberg@gmail.com" <ronniesahlberg@gmail.com>,
	"samba-technical@lists.samba.org"
	<samba-technical@lists.samba.org>,
	"dhowells@redhat.com" <dhowells@redhat.com>,
	 "Dai.Ngo@oracle.com" <Dai.Ngo@oracle.com>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"rafael@kernel.org" <rafael@kernel.org>,
	"alex.aring@gmail.com" <alex.aring@gmail.com>,
	 "pc@manguebit.com" <pc@manguebit.com>,
	"amir73il@gmail.com" <amir73il@gmail.com>,
	 "kolga@netapp.com" <kolga@netapp.com>,
	"sprasad@microsoft.com" <sprasad@microsoft.com>,
	 "code@tyhicks.com" <code@tyhicks.com>,
	"brauner@kernel.org" <brauner@kernel.org>,
	 "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
	"edumazet@google.com" <edumazet@google.com>,
	 "linux-cifs@vger.kernel.org" <linux-cifs@vger.kernel.org>,
	"linkinjeon@kernel.org" <linkinjeon@kernel.org>,
	 "neilb@suse.de" <neilb@suse.de>,
	"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
	 "netfs@lists.linux.dev" <netfs@lists.linux.dev>,
	"miklos@szeredi.hu" <miklos@szeredi.hu>
Subject: Re: [PATCH RFC 11/24] nfsd: allow DELEGRETURN on directories
Date: Mon, 18 Mar 2024 07:22:04 -0400	[thread overview]
Message-ID: <5d6688d419f19512a8170ca915ec5825df8f489a.camel@kernel.org> (raw)
In-Reply-To: <d3d8483b1248e4bccadb8591019dbe7c4aeb3d1c.camel@hammerspace.com>

On Sun, 2024-03-17 at 16:03 +0000, Trond Myklebust wrote:
> On Sun, 2024-03-17 at 11:09 -0400, Chuck Lever wrote:
> > On Fri, Mar 15, 2024 at 12:53:02PM -0400, Jeff Layton wrote:
> > > fh_verify only allows you to filter on a single type of inode, so
> > > have
> > > nfsd4_delegreturn not filter by type. Once fh_verify returns, do
> > > the
> > > appropriate check of the type and return an error if it's not a
> > > regular
> > > file or directory.
> > > 
> > > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > > ---
> > >  fs/nfsd/nfs4state.c | 14 +++++++++++++-
> > >  1 file changed, 13 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> > > index 17d09d72632b..c52e807f9672 100644
> > > --- a/fs/nfsd/nfs4state.c
> > > +++ b/fs/nfsd/nfs4state.c
> > > @@ -7425,12 +7425,24 @@ nfsd4_delegreturn(struct svc_rqst *rqstp,
> > > struct nfsd4_compound_state *cstate,
> > >  	struct nfs4_delegation *dp;
> > >  	stateid_t *stateid = &dr->dr_stateid;
> > >  	struct nfs4_stid *s;
> > > +	umode_t mode;
> > >  	__be32 status;
> > >  	struct nfsd_net *nn = net_generic(SVC_NET(rqstp),
> > > nfsd_net_id);
> > >  
> > > -	if ((status = fh_verify(rqstp, &cstate->current_fh,
> > > S_IFREG, 0)))
> > > +	if ((status = fh_verify(rqstp, &cstate->current_fh, 0,
> > > 0)))
> > >  		return status;
> > >  
> > > +	mode = d_inode(cstate->current_fh.fh_dentry)->i_mode &
> > > S_IFMT;
> > > +	switch(mode) {
> > > +	case S_IFREG:
> > > +	case S_IFDIR:
> > > +		break;
> > > +	case S_IFLNK:
> > > +		return nfserr_symlink;
> > > +	default:
> > > +		return nfserr_inval;
> > > +	}
> > > +
> > 
> > RFC 8881 Section 15.2 does not list NFS4ERR_SYMLINK among the
> > valid status codes for the DELEGRETURN operation. Maybe the naked
> > fh_verify() call has gotten it wrong all these years...?
> 
> The WANT_DELEGATION operation allows the server to hand out delegations
> for aggressive caching of symlinks. It is not an error to return that
> delegation using DELEGRETURN.
> 
> Furthermore, provided that the presented stateid is actually valid, it
> is also sufficient to uniquely identify the file to which it is
> associated (see RFC8881 Section 8.2.4), so the filehandle should be
> considered mostly irrelevant for operations like DELEGRETURN.
> 

Ok. I think we can probably just drop the switch altogether. We already
don't validate that the stateid is associated with current_fh, AFAICT.
It looks possible to send a valid stateid alongside an FH that refers to
a completely different file, and we'll just accept it.

-- 
Jeff Layton <jlayton@kernel.org>

  reply	other threads:[~2024-03-18 11:22 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-15 16:52 [PATCH RFC 00/24] vfs, nfsd, nfs: implement directory delegations Jeff Layton
2024-03-15 16:52 ` [PATCH RFC 01/24] filelock: push the S_ISREG check down to ->setlease handlers Jeff Layton
2024-03-15 16:52 ` [PATCH RFC 02/24] filelock: add a lm_set_conflict lease_manager callback Jeff Layton
2024-03-17 14:56   ` Chuck Lever
2024-03-18 11:07     ` Jeff Layton
2024-03-20 13:13   ` Christian Brauner
2024-03-20 13:17     ` Jeff Layton
2024-03-15 16:52 ` [PATCH RFC 03/24] vfs: add try_break_deleg calls for parents to vfs_{link,rename,unlink} Jeff Layton
2024-03-16 23:57   ` Al Viro
2024-03-17 14:09     ` Jeff Layton
2024-03-15 16:52 ` [PATCH RFC 04/24] vfs: allow mkdir to wait for delegation break on parent Jeff Layton
2024-03-15 16:52 ` [PATCH RFC 05/24] vfs: allow rmdir " Jeff Layton
2024-03-15 16:52 ` [PATCH RFC 06/24] vfs: break parent dir delegations in open(..., O_CREAT) codepath Jeff Layton
2024-03-17  0:19   ` Al Viro
2024-03-17 12:23     ` Jeff Layton
2024-03-18  8:25   ` Stefan Metzmacher
2024-03-18 10:21     ` Jeff Layton
2024-03-15 16:52 ` [PATCH RFC 07/24] vfs: make vfs_create break delegations on parent directory Jeff Layton
2024-03-15 16:52 ` [PATCH RFC 08/24] vfs: make vfs_mknod " Jeff Layton
2024-03-20 13:42   ` Christian Brauner
2024-03-20 20:12     ` Jeff Layton
2024-03-22 14:13       ` Christian Brauner
2024-03-15 16:53 ` [PATCH RFC 09/24] filelock: lift the ban on directory leases in generic_setlease Jeff Layton
2024-03-15 16:53 ` [PATCH RFC 10/24] nfsd: allow filecache to hold S_IFDIR files Jeff Layton
2024-03-15 16:53 ` [PATCH RFC 11/24] nfsd: allow DELEGRETURN on directories Jeff Layton
2024-03-17 15:09   ` Chuck Lever
2024-03-17 16:03     ` Trond Myklebust
2024-03-18 11:22       ` Jeff Layton [this message]
2024-03-15 16:53 ` [PATCH RFC 12/24] nfsd: encoders and decoders for GET_DIR_DELEGATION Jeff Layton
2024-03-17 15:34   ` Chuck Lever
2024-03-18 16:12     ` Jeff Layton
2024-03-18 16:19       ` Chuck Lever
2024-03-15 16:53 ` [PATCH RFC 13/24] nfsd: check for delegation conflicts vs. the same client Jeff Layton
2024-03-15 16:53 ` [PATCH RFC 14/24] nfsd: wire up GET_DIR_DELEGATION handling Jeff Layton
2024-03-17 15:42   ` Chuck Lever
2024-03-15 16:53 ` [PATCH RFC 15/24] nfs: fix nfs_stateid_hash prototype when CONFIG_CRC32 isn't set Jeff Layton
2024-03-15 16:53 ` [PATCH RFC 16/24] nfs: remove unused NFS_CALL macro Jeff Layton
2024-03-15 16:53 ` [PATCH RFC 17/24] nfs: add cache_validity to the nfs_inode_event tracepoints Jeff Layton
2024-03-15 16:53 ` [PATCH RFC 18/24] nfs: add a tracepoint to nfs_inode_detach_delegation_locked Jeff Layton
2024-03-15 16:53 ` [PATCH RFC 19/24] nfs: new tracepoint in nfs_delegation_need_return Jeff Layton
2024-03-15 16:53 ` [PATCH RFC 20/24] nfs: new tracepoint in match_stateid operation Jeff Layton
2024-03-15 16:53 ` [PATCH RFC 21/24] nfs: add a GDD_GETATTR rpc operation Jeff Layton
2024-03-15 20:50   ` Anna Schumaker
2024-03-15 21:29     ` Jeff Layton
2024-03-15 16:53 ` [PATCH RFC 22/24] nfs: skip dentry revalidation when parent dir has a delegation Jeff Layton
2024-03-15 16:53 ` [PATCH RFC 23/24] nfs: optionally request a delegation on GETATTR Jeff Layton
2024-03-15 16:53 ` [PATCH RFC 24/24] nfs: add a module parameter to disable directory delegations Jeff Layton

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=5d6688d419f19512a8170ca915ec5825df8f489a.camel@kernel.org \
    --to=jlayton@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=alex.aring@gmail.com \
    --cc=amir73il@gmail.com \
    --cc=anna@kernel.org \
    --cc=brauner@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=code@tyhicks.com \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=ecryptfs@vger.kernel.org \
    --cc=edumazet@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jack@suse.cz \
    --cc=kolga@netapp.com \
    --cc=kuba@kernel.org \
    --cc=linkinjeon@kernel.org \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=linux-unionfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=neilb@suse.de \
    --cc=netdev@vger.kernel.org \
    --cc=netfs@lists.linux.dev \
    --cc=pabeni@redhat.com \
    --cc=pc@manguebit.com \
    --cc=rafael@kernel.org \
    --cc=ronniesahlberg@gmail.com \
    --cc=samba-technical@lists.samba.org \
    --cc=senozhatsky@chromium.org \
    --cc=sfrench@samba.org \
    --cc=sprasad@microsoft.com \
    --cc=tom@talpey.com \
    --cc=trondmy@hammerspace.com \
    --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).