Received: by 2002:ab2:6c55:0:b0:1fd:c486:4f03 with SMTP id v21csp195772lqp; Tue, 11 Jun 2024 20:50:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUAB67CpJ8cf//Y67a3UsYz6YcsvxcPMsBHJZMjVfPEbHqvYDldMxhOPS19y5fYHOhM4LL88NEqQdpG0ii3AJw5kjj1t5Ufh+4h7CIVnQ== X-Google-Smtp-Source: AGHT+IEP268tYpFuuW8HyOdoA02xKM8qfEM8K8Azv8J1JoLwcLjIzUOHe1YeBDlGdZITw/3080ZU X-Received: by 2002:ac8:5754:0:b0:440:29e8:81a7 with SMTP id d75a77b69052e-4415abff04fmr6162691cf.35.1718164210180; Tue, 11 Jun 2024 20:50:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718164210; cv=pass; d=google.com; s=arc-20160816; b=PqGbLmExOUNrSWnyEivwPKQdLWaLI1NKXtbRGoJlZxEwKWIMcl9FKYdY5HR6KBxBic T3JBptWOBUMHHKdqooUu08tQVzHnqoSYLKd8UWGMPG26KpMrCo2c85foalUMk3yo6rkZ 5jnLIbGPDceeNnCVlY3lQ7kEK9pcj2v/RDVvESIbwofswKzaJDoPkWeubC7w4HJGkAju h5f12X4AIeWnYk65b85rZkB4BKD794IeMyXl0Mme9pGuUJL2p09+4511sEEsCTN2XNIV SyzwXEpnO2jAVO5RJ16NzFHHnENgxKH1rUjHsMs+Gb6rTkAFiyj+Q6cWeHm+WMBhcvOc 95Rg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=c8GmhhA7WLlNsA/xZgMK6KYqW++Vjo+UE3oLDUWkihY=; fh=is3DGb2W2smkNHChSy6HqtxoLStcd4pUCynGDk0srG8=; b=Ya+Wy2njP0XwP0P3zMqlqZs03P4lIx8zadOQ7bB2f6MFLC0TvNyy7SLUD5i/fOoDsg CZ5bc5ej7WOwY9hS0o2iGejsU8ayaxpFzN303bTfruKIJLYHHX56aCktyvjLOwaw8tob YabvjejHA9yn4ZDpfdfDs6lLmH1mqSRresheshAoSSmPHDnt2sKtyVlNJ5YoMmD06J3S ydxPZb6xsHSjgQvK7Wpvlof82NbvLs1frWqCnch4r8IGPZXviRS5tpwUhDJszWdABNlW p+pwlFQVMkTAgYvVI0hmi3suuYMbpGclB9PDIGwlnPti/53O6Y1jGiN9a8r1HEoBpbN1 f/2Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="oelF/STy"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3677-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3677-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d75a77b69052e-4405e1819b5si85846861cf.463.2024.06.11.20.50.09 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 20:50:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3677-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="oelF/STy"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-nfs+bounces-3677-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3677-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id BD6141C2331D for ; Wed, 12 Jun 2024 03:50:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 615FF171C4; Wed, 12 Jun 2024 03:50:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oelF/STy" X-Original-To: linux-nfs@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B002171AF for ; Wed, 12 Jun 2024 03:50:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718164208; cv=none; b=rKTfgKXECi7OjsjOQwOaWsPEYXhNSvbYkz8fRowkqdPmvVQQFKZMDUM2/ZbU86w+lMRW1zt5yB4Y2TklFDm1iH+qJ3jitQGWYXAz0ITwN4mvFzpwuPBdJWPwLmkH+rX6tmnnI+tMBvaVGyuGjlBT+KcEQSVRqIw/fbuK4mlWhH0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718164208; c=relaxed/simple; bh=EJcjUlGOSGdSnyRm1dEgo2zWPR2rH/FbeOTuXXg5SCE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QtN/MmTNgnMi4j/3Chom2Jzi56mjM1Pe100kv9m44+DiTWH6SwVKH9LnI83NRlXCBbxlGoYpoyFD2nr4lzJDC7u8KP5tzPEvJev3wFfRFfl8U4MI7aVjM1ocN0mv9OV8Uz+O3HFNZEL4CK0mEhG6N2BmofQlFORlbgX9hjdFGe0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oelF/STy; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BC643C32786; Wed, 12 Jun 2024 03:50:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1718164208; bh=EJcjUlGOSGdSnyRm1dEgo2zWPR2rH/FbeOTuXXg5SCE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oelF/STykecZipxcv02wSf8MQdX/npJncQGcqjcKtrq4vN78YwDzwcj0gbero0eiB A9qCcws5Z9S/LYnzE71ai++uhjY22Skjun7urOJJtMLiRsHZw96xaRtv84rdkcFCeI cQSxsxTTOqN+RJT6pYr9/Ftgl16DBalQ6pTGRZclfqLLwfV6AIc0uOU2fOlfPlGN7x Q1u7nBmDKWcJuMAxyYsZR1AI8w+gskRtdHIAkzHIXmuGqNTyS6thCidtNQw2lNskfH JMcGrd8n0DToIPQWLi/n/+L1+kzW/aleode13PApdgMqsSPirQEiMJ5ZTLBCk69QH1 JG9zY0wz/+4lA== Date: Tue, 11 Jun 2024 23:50:06 -0400 From: Mike Snitzer To: NeilBrown Cc: linux-nfs@vger.kernel.org, Jeff Layton , Chuck Lever , Trond Myklebust , snitzer@hammerspace.com Subject: Re: [RFC PATCH v2 05/15] nfs: move nfs_stat_to_errno to nfs.h Message-ID: References: <20240612030752.31754-1-snitzer@kernel.org> <20240612030752.31754-6-snitzer@kernel.org> <171816263943.14261.9166283683437727145@noble.neil.brown.name> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 > > > > So that knfsd can use it to map nfs stat to sys errno as well. > > > > Signed-off-by: Peng Tao > > Signed-off-by: Lance Shelton > > Signed-off-by: Trond Myklebust > > Signed-off-by: Mike Snitzer > > --- > > 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 > > #include > > +#include > > #include > > #include > > > > @@ -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 > > > > > >