Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp1076673lqt; Fri, 7 Jun 2024 07:27:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWvospiEfY9+jD5OBPh9p1UpkweXbfcYRZl3z+uGQkCCsHUpmVFD8AOkkNqKNQOTAyUF/Uh2wRmemOnuMOoXS5Q+IKApONik1CQ9ijdwg== X-Google-Smtp-Source: AGHT+IHmW76RBW0H+kBYG7bRCugi7+eYtWr0/Nl/1U8lyCoE1o8KyYYeB1NQ6Yovd1gwx+WsbZ5u X-Received: by 2002:a05:6a20:8417:b0:1b2:b60a:a42d with SMTP id adf61e73a8af0-1b2f968d9f8mr2902039637.4.1717770432038; Fri, 07 Jun 2024 07:27:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717770432; cv=pass; d=google.com; s=arc-20160816; b=xWXIg5Cdv8NH4T4XQ/0mP3B+6lCs3r1N3YVNpDbrGdFV9wBP94Jy6CvZs2WgN36SlP TZFJ35ETSmGr8g33N+Hb7exlCSdc4brMeMOEpABBjZ6Uua4EsJRo1y2PaPBSBRh9PBFA KAmMjbkjHzaKmreDV2SJNTwa/ylOhDMRmeSDe+OHNDV/QfwFXY7R3UKbtJx5blNu+vWn q7C0kRqD1a4b+oefgv2/ELV1m+stFifFOZxbbbZZf0+ZFNl+nN6gdLSqb0GHxftBnuLE Vg5lxwek4Lu6Hl/B5IheuTppG5F5lV9Zteq2fko4b2iJCv7lt23lY8mvCN4dSjcAmkDZ FQkw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=cgxgLWn6Ffrlu3oKMuNrnHIwmF3QqJ7i4ICNZ4MC3JM=; fh=OUKZWod6C22emJS3X689dwhO5bDgGbDS06P/Z6+EGqk=; b=rwnWq622PJSrHVmfCGuE1b5lDHXSgdSlsZCoTW4Wvo8L1bRLGhS7hirNRf3ppIHXqw AsY7sj7cmroBbV+SM+kEnCsk1DdAY1934XxSvhdDuQsxM26XxNUjnrqU1D9Yp1jzknsU dYzH7jhxyL1Qwtar/SPMkUf0lvyLXFXgeOfVkpXYJRNXIVP9vPi7MzAhNeOSJzV1SvB+ JBNAwpz4uRjn/gAQ7buDSqSq4yOkIQIHqQvTguG5rAfxTaCRTpWZ2gNlyy9iNxIYnGkN Yh8bXppRGBCesOZcj46CdYT3sxJZmA4+Gzg5717kBTKtxOnEIRd2K0MYk1GN96MXZ4qU 00cw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-nfs+bounces-3593-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3593-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d2e1a72fcca58-703fd39088csi3064404b3a.71.2024.06.07.07.27.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:27:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs+bounces-3593-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-nfs+bounces-3593-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-nfs+bounces-3593-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9D416284092 for ; Fri, 7 Jun 2024 14:27:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B04D4195999; Fri, 7 Jun 2024 14:27:03 +0000 (UTC) X-Original-To: linux-nfs@vger.kernel.org Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 300EC194A7D for ; Fri, 7 Jun 2024 14:27:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717770423; cv=none; b=rzW7uA98ukDOEI1Vr1l1np5K37Lj/K1KqE2NdVkQ5GdB0M38ycSaE03kdfbYEi+f1Ji/+PgW13wOpkZKcLm7yiK1x0u0N1uqexnV4V/ZSa/doc+1jHMbMigCmBrwUmpoRCaRX26/s6PSNIe05nFOvwX/pmOAG6OYS9U5nssETgk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717770423; c=relaxed/simple; bh=aG8k34g9i3eVZnS6rlNNs65QjqJFgFWblLXRSOGkIxA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NojaBQSPB5K5ErUkis2K4MrfgQodApXpsjPbl1URbx8DG/67xEwTsy29odJVSwlim4PMtIXN1L0O7Zw5n1PHaqYsOge+nzZ+PAqInJduImcYSUsP3rcrNNcNO740tLC6Ak5SseVCNf7aWCFwTHej0NO7/UkAaNDYc+Pew3N4bl0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=snitzer.net; arc=none smtp.client-ip=209.85.222.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=snitzer.net Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-7952b60b4eeso141847185a.3 for ; Fri, 07 Jun 2024 07:27:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717770421; x=1718375221; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cgxgLWn6Ffrlu3oKMuNrnHIwmF3QqJ7i4ICNZ4MC3JM=; b=GCkmZE0oxo+QHQUUBxmsz8QoZAGLX+HPYXuVb6kBIqmVv8QO0FvHWiyEn5WHjmVdSh eW3I9xIHO9QGVojrDiK5ljBcowUX6ORf4ahx6hmkTxu9gw6/h8Gw36nK4ddM4RY/Zred TZKB+doND8uzFEHkdVfcmyggsdbWpYs2IA7YUOb/6uIIO16NKbCMboDG4JljoRKVtsev AOIYx53ZvW3R5amdltZ9q3nupoYPGFst5MohV6YAyQ5MectdBppeRVJq+hPr5l/rBOc1 LGZ4cPCXD0xTmOyiJZjqVsfR+fmdhyb0oa/Qi6oI8PYjJbqTeUsLKQ6+cx9PcTUWRqkj fRhA== X-Gm-Message-State: AOJu0Yw8CV+67f/Fx9cs25XJX2/A+D8VOeTq+6klYgxE6y1q+BhqXaob d6lOkWNvTcuKFll9wq6zJcHaX8K9WIuXr+9ZX5CcqcSQeJzKGLnjJrnMUb4sTpFFaef2x4yFb5W jsY5GsA== X-Received: by 2002:a05:620a:244f:b0:795:2ce7:4dfd with SMTP id af79cd13be357-7953c2e88d0mr296178085a.9.1717770420748; Fri, 07 Jun 2024 07:27:00 -0700 (PDT) Received: from localhost (pool-68-160-141-91.bstnma.fios.verizon.net. [68.160.141.91]) by smtp.gmail.com with ESMTPSA id af79cd13be357-795328139fdsm171981185a.23.2024.06.07.07.27.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:27:00 -0700 (PDT) From: Mike Snitzer To: linux-nfs@vger.kernel.org Cc: Jeff Layton , Chuck Lever , Trond Myklebust , snitzer@hammerspace.com Subject: [for-6.11 PATCH 08/29] nfs: move nfs_stat_to_errno to nfs.h Date: Fri, 7 Jun 2024 10:26:25 -0400 Message-ID: <20240607142646.20924-9-snitzer@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240607142646.20924-1-snitzer@kernel.org> References: <20240607142646.20924-1-snitzer@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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[] = { - { 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