Linux NFS development
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@kernel.org>
To: NeilBrown <neilb@suse.de>
Cc: linux-nfs@vger.kernel.org, Jeff Layton <jlayton@kernel.org>,
	Chuck Lever <chuck.lever@oracle.com>,
	Trond Myklebust <trondmy@hammerspace.com>,
	snitzer@hammerspace.com
Subject: Re: [RFC PATCH v2 05/15] nfs: move nfs_stat_to_errno to nfs.h
Date: Tue, 11 Jun 2024 23:50:06 -0400	[thread overview]
Message-ID: <Zmka7ggqYsmn94Dd@kernel.org> (raw)
In-Reply-To: <171816263943.14261.9166283683437727145@noble.neil.brown.name>

On Wed, Jun 12, 2024 at 01:23:59PM +1000, NeilBrown wrote:
> On Wed, 12 Jun 2024, Mike Snitzer wrote:
> > From: Peng Tao <tao.peng@primarydata.com>
> > 
> > So that knfsd can use it to map nfs stat to sys errno as well.
> > 
> > Signed-off-by: Peng Tao <tao.peng@primarydata.com>
> > Signed-off-by: Lance Shelton <lance.shelton@hammerspace.com>
> > Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
> > Signed-off-by: Mike Snitzer <snitzer@kernel.org>
> > ---
> >  fs/nfs/nfs2xdr.c    | 69 ---------------------------------------------
> >  include/linux/nfs.h | 63 +++++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 63 insertions(+), 69 deletions(-)
> > 
> > diff --git a/fs/nfs/nfs2xdr.c b/fs/nfs/nfs2xdr.c
> > index c19093814296..f7ef44829f6e 100644
> > --- a/fs/nfs/nfs2xdr.c
> > +++ b/fs/nfs/nfs2xdr.c
> > @@ -27,9 +27,6 @@
> >  
> >  #define NFSDBG_FACILITY		NFSDBG_XDR
> >  
> > -/* Mapping from NFS error code to "errno" error code. */
> > -#define errno_NFSERR_IO		EIO
> > -
> >  /*
> >   * Declare the space requirements for NFS arguments and replies as
> >   * number of 32bit-words
> > @@ -64,8 +61,6 @@
> >  #define NFS_readdirres_sz	(1+NFS_pagepad_sz)
> >  #define NFS_statfsres_sz	(1+NFS_info_sz)
> >  
> > -static int nfs_stat_to_errno(enum nfs_stat);
> > -
> >  /*
> >   * Encode/decode NFSv2 basic data types
> >   *
> > @@ -1054,70 +1049,6 @@ static int nfs2_xdr_dec_statfsres(struct rpc_rqst *req, struct xdr_stream *xdr,
> >  	return nfs_stat_to_errno(status);
> >  }
> >  
> > -
> > -/*
> > - * We need to translate between nfs status return values and
> > - * the local errno values which may not be the same.
> > - */
> > -static const struct {
> > -	int stat;
> > -	int errno;
> > -} nfs_errtbl[] = {
> 
> Will this array appear in every .o file that is compiled using this .h
> file? That doesn't seem like a good idea.

Ouch, sure looks like it would.  Nice catch.

Mike


> > -	{ NFS_OK,		0		},
> > -	{ NFSERR_PERM,		-EPERM		},
> > -	{ NFSERR_NOENT,		-ENOENT		},
> > -	{ NFSERR_IO,		-errno_NFSERR_IO},
> > -	{ NFSERR_NXIO,		-ENXIO		},
> > -/*	{ NFSERR_EAGAIN,	-EAGAIN		}, */
> > -	{ NFSERR_ACCES,		-EACCES		},
> > -	{ NFSERR_EXIST,		-EEXIST		},
> > -	{ NFSERR_XDEV,		-EXDEV		},
> > -	{ NFSERR_NODEV,		-ENODEV		},
> > -	{ NFSERR_NOTDIR,	-ENOTDIR	},
> > -	{ NFSERR_ISDIR,		-EISDIR		},
> > -	{ NFSERR_INVAL,		-EINVAL		},
> > -	{ NFSERR_FBIG,		-EFBIG		},
> > -	{ NFSERR_NOSPC,		-ENOSPC		},
> > -	{ NFSERR_ROFS,		-EROFS		},
> > -	{ NFSERR_MLINK,		-EMLINK		},
> > -	{ NFSERR_NAMETOOLONG,	-ENAMETOOLONG	},
> > -	{ NFSERR_NOTEMPTY,	-ENOTEMPTY	},
> > -	{ NFSERR_DQUOT,		-EDQUOT		},
> > -	{ NFSERR_STALE,		-ESTALE		},
> > -	{ NFSERR_REMOTE,	-EREMOTE	},
> > -#ifdef EWFLUSH
> > -	{ NFSERR_WFLUSH,	-EWFLUSH	},
> > -#endif
> > -	{ NFSERR_BADHANDLE,	-EBADHANDLE	},
> > -	{ NFSERR_NOT_SYNC,	-ENOTSYNC	},
> > -	{ NFSERR_BAD_COOKIE,	-EBADCOOKIE	},
> > -	{ NFSERR_NOTSUPP,	-ENOTSUPP	},
> > -	{ NFSERR_TOOSMALL,	-ETOOSMALL	},
> > -	{ NFSERR_SERVERFAULT,	-EREMOTEIO	},
> > -	{ NFSERR_BADTYPE,	-EBADTYPE	},
> > -	{ NFSERR_JUKEBOX,	-EJUKEBOX	},
> > -	{ -1,			-EIO		}
> > -};
> > -
> > -/**
> > - * nfs_stat_to_errno - convert an NFS status code to a local errno
> > - * @status: NFS status code to convert
> > - *
> > - * Returns a local errno value, or -EIO if the NFS status code is
> > - * not recognized.  This function is used jointly by NFSv2 and NFSv3.
> > - */
> > -static int nfs_stat_to_errno(enum nfs_stat status)
> > -{
> > -	int i;
> > -
> > -	for (i = 0; nfs_errtbl[i].stat != -1; i++) {
> > -		if (nfs_errtbl[i].stat == (int)status)
> > -			return nfs_errtbl[i].errno;
> > -	}
> > -	dprintk("NFS: Unrecognized nfs status value: %u\n", status);
> > -	return nfs_errtbl[i].errno;
> > -}
> > -
> >  #define PROC(proc, argtype, restype, timer)				\
> >  [NFSPROC_##proc] = {							\
> >  	.p_proc	    =  NFSPROC_##proc,					\
> > diff --git a/include/linux/nfs.h b/include/linux/nfs.h
> > index ceb70a926b95..b94f51d17bc5 100644
> > --- a/include/linux/nfs.h
> > +++ b/include/linux/nfs.h
> > @@ -10,6 +10,7 @@
> >  
> >  #include <linux/sunrpc/msg_prot.h>
> >  #include <linux/string.h>
> > +#include <linux/errno.h>
> >  #include <linux/crc32.h>
> >  #include <uapi/linux/nfs.h>
> >  
> > @@ -46,6 +47,68 @@ enum nfs3_stable_how {
> >  	NFS_INVALID_STABLE_HOW = -1
> >  };
> >  
> > +/*
> > + * We need to translate between nfs status return values and
> > + * the local errno values which may not be the same.
> > + */
> > +static const struct {
> > +	int stat;
> > +	int errno;
> > +} nfs_common_errtbl[] = {
> > +	{ NFS_OK,		0		},
> > +	{ NFSERR_PERM,		-EPERM		},
> > +	{ NFSERR_NOENT,		-ENOENT		},
> > +	{ NFSERR_IO,		-EIO		},
> > +	{ NFSERR_NXIO,		-ENXIO		},
> > +/*	{ NFSERR_EAGAIN,	-EAGAIN		}, */
> > +	{ NFSERR_ACCES,		-EACCES		},
> > +	{ NFSERR_EXIST,		-EEXIST		},
> > +	{ NFSERR_XDEV,		-EXDEV		},
> > +	{ NFSERR_NODEV,		-ENODEV		},
> > +	{ NFSERR_NOTDIR,	-ENOTDIR	},
> > +	{ NFSERR_ISDIR,		-EISDIR		},
> > +	{ NFSERR_INVAL,		-EINVAL		},
> > +	{ NFSERR_FBIG,		-EFBIG		},
> > +	{ NFSERR_NOSPC,		-ENOSPC		},
> > +	{ NFSERR_ROFS,		-EROFS		},
> > +	{ NFSERR_MLINK,		-EMLINK		},
> > +	{ NFSERR_NAMETOOLONG,	-ENAMETOOLONG	},
> > +	{ NFSERR_NOTEMPTY,	-ENOTEMPTY	},
> > +	{ NFSERR_DQUOT,		-EDQUOT		},
> > +	{ NFSERR_STALE,		-ESTALE		},
> > +	{ NFSERR_REMOTE,	-EREMOTE	},
> > +#ifdef EWFLUSH
> > +	{ NFSERR_WFLUSH,	-EWFLUSH	},
> > +#endif
> > +	{ NFSERR_BADHANDLE,	-EBADHANDLE	},
> > +	{ NFSERR_NOT_SYNC,	-ENOTSYNC	},
> > +	{ NFSERR_BAD_COOKIE,	-EBADCOOKIE	},
> > +	{ NFSERR_NOTSUPP,	-ENOTSUPP	},
> > +	{ NFSERR_TOOSMALL,	-ETOOSMALL	},
> > +	{ NFSERR_SERVERFAULT,	-EREMOTEIO	},
> > +	{ NFSERR_BADTYPE,	-EBADTYPE	},
> > +	{ NFSERR_JUKEBOX,	-EJUKEBOX	},
> > +	{ -1,			-EIO		}
> > +};
> > +
> > +/**
> > + * nfs_stat_to_errno - convert an NFS status code to a local errno
> > + * @status: NFS status code to convert
> > + *
> > + * Returns a local errno value, or -EIO if the NFS status code is
> > + * not recognized.  This function is used jointly by NFSv2 and NFSv3.
> > + */
> > +static inline int nfs_stat_to_errno(enum nfs_stat status)
> > +{
> > +	int i;
> > +
> > +	for (i = 0; nfs_common_errtbl[i].stat != -1; i++) {
> > +		if (nfs_common_errtbl[i].stat == (int)status)
> > +			return nfs_common_errtbl[i].errno;
> > +	}
> > +	return nfs_common_errtbl[i].errno;
> > +}
> > +
> >  #ifdef CONFIG_CRC32
> >  /**
> >   * nfs_fhandle_hash - calculate the crc32 hash for the filehandle
> > -- 
> > 2.44.0
> > 
> > 
> 
> 

  reply	other threads:[~2024-06-12  3:50 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-12  3:07 [RFC PATCH v2 00/15] nfs/nfsd: add support for localio Mike Snitzer
2024-06-12  3:07 ` [RFC PATCH v2 01/15] nfs: pass nfs_client to nfs_initiate_pgio Mike Snitzer
2024-06-12  3:07 ` [RFC PATCH v2 02/15] nfs: pass descriptor thru nfs_initiate_pgio path Mike Snitzer
2024-06-12  3:07 ` [RFC PATCH v2 03/15] nfs: pass struct file to nfs_init_pgio and nfs_init_commit Mike Snitzer
2024-06-12  3:07 ` [RFC PATCH v2 04/15] sunrpc: add rpcauth_map_to_svc_cred_local Mike Snitzer
2024-06-12  4:28   ` NeilBrown
2024-06-12 18:32   ` Anna Schumaker
2024-06-12  3:07 ` [RFC PATCH v2 05/15] nfs: move nfs_stat_to_errno to nfs.h Mike Snitzer
2024-06-12  3:23   ` NeilBrown
2024-06-12  3:50     ` Mike Snitzer [this message]
2024-06-12  3:07 ` [RFC PATCH v2 06/15] nfs_common: add NFS LOCALIO protocol extension enablement Mike Snitzer
2024-06-12  3:07 ` [RFC PATCH v2 07/15] nfs/nfsd: add "localio" support Mike Snitzer
2024-06-12  4:36   ` NeilBrown
2024-06-12  4:51     ` Mike Snitzer
2024-06-12  3:07 ` [RFC PATCH v2 08/15] NFS: for localio don't call filesystem read() and write() routines directly Mike Snitzer
2024-06-12  4:39   ` NeilBrown
2024-06-12  3:07 ` [RFC PATCH v2 09/15] NFS: Enable localio for non-pNFS I/O Mike Snitzer
2024-06-12  5:12   ` NeilBrown
2024-06-12  3:07 ` [RFC PATCH v2 10/15] pnfs/flexfiles: Enable localio for flexfiles I/O Mike Snitzer
2024-06-12  3:07 ` [RFC PATCH v2 11/15] nfs: implement v3 and v4 client support for NFS_LOCALIO_PROGRAM Mike Snitzer
2024-06-12  3:07 ` [RFC PATCH v2 12/15] nfsd: implement v3 and v4 server " Mike Snitzer
2024-06-12  3:07 ` [RFC PATCH v2 13/15] nfs/nfsd: consolidate {encode,decode}_opaque_fixed in nfs_xdr.h Mike Snitzer
2024-06-12  3:07 ` [RFC PATCH v2 14/15] nfs/localio: move managing nfsd_open_local_fh symbol to nfs_common Mike Snitzer
2024-06-12  3:07 ` [RFC PATCH v2 15/15] nfs/nfsd: ensure localio server always uses its network namespace Mike Snitzer
2024-06-12  5:11   ` NeilBrown
2024-06-12  3:12 ` [RFC PATCH v2 00/15] nfs/nfsd: add support for localio Mike Snitzer

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=Zmka7ggqYsmn94Dd@kernel.org \
    --to=snitzer@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=snitzer@hammerspace.com \
    --cc=trondmy@hammerspace.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