NFSD: Name the fh_maxsize value that carries no NFS version

nfsd_set_fh_dentry() selects behavior specific to an NFS protocol
version by matching fh_maxsize against NFS_FHSIZE, NFS3_FHSIZE, or
NFS4_FHSIZE. A filehandle that reaches NFSD outside an NFS request has
no such version. nlm_fopen() opts out of the switch by passing a bare
0, which matches no arm, and the literal says nothing about why, so an
adjacent comment has to carry it.

Reviewed-by: NeilBrown <neil@brown.name>
Reviewed-by: Mike Snitzer <snitzer@kernel.org>
Link: https://patch.msgid.link/20260728165911.462534-5-cel@kernel.org
Signed-off-by: Chuck Lever <cel@kernel.org>
This commit is contained in:
Chuck Lever 2026-07-28 12:59:10 -04:00
parent 0922565599
commit dc8fd3caff
3 changed files with 17 additions and 2 deletions

View File

@ -34,8 +34,7 @@ static int nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f,
int access;
struct svc_fh fh;
/* must initialize before using! but maxsize doesn't matter */
fh_init(&fh,0);
fh_init(&fh, NFSD_FHSIZE_UNSPEC);
fh.fh_handle.fh_size = f->size;
memcpy(&fh.fh_handle.fh_raw, f->data, f->size);
fh.fh_export = NULL;

View File

@ -335,6 +335,8 @@ static __be32 nfsd_set_fh_dentry(struct svc_rqst *rqstp, struct net *net,
}
switch (fhp->fh_maxsize) {
case NFSD_FHSIZE_UNSPEC:
break;
case NFS4_FHSIZE:
if (dentry->d_sb->s_export_op->flags & EXPORT_OP_NOATOMIC_ATTR)
fhp->fh_no_atomic_attr = true;

View File

@ -246,6 +246,20 @@ fh_copy_shallow(struct knfsd_fh *dst, const struct knfsd_fh *src)
memcpy(&dst->fh_raw, &src->fh_raw, src->fh_size);
}
#define NFSD_FHSIZE_UNSPEC 0
/**
* fh_init - Prepare a file handle for fh_compose() or fh_verify()
* @fhp: File handle to initialize
* @maxsize: Largest file handle, in bytes, to build in @fhp
*
* @maxsize bounds the handle fh_compose() may build: NFS_FHSIZE,
* NFS3_FHSIZE, and NFS4_FHSIZE additionally select version-specific
* handling in fh_verify(). Callers that only verify an incoming
* handle pass NFSD_FHSIZE_UNSPEC, which cannot be composed.
*
* Return: @fhp
*/
static __inline__ struct svc_fh *
fh_init(struct svc_fh *fhp, int maxsize)
{