nfsd: move nfserrno() to vfs.c
authorJeff Layton <jlayton@kernel.org>
Tue, 18 Oct 2022 11:47:55 +0000 (07:47 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 28 Nov 2022 17:54:44 +0000 (12:54 -0500)
nfserrno() is common to all nfs versions, but nfsproc.c is specifically
for NFSv2. Move it to vfs.c, and the prototype to vfs.h.

While we're in here, remove the #ifdef EDQUOT check in this function.
It's apparently a holdover from the initial merge of the nfsd code in
1997. No other place in the kernel checks that that symbol is defined
before using it, so I think we can dispense with it here.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/blocklayout.c
fs/nfsd/blocklayoutxdr.c
fs/nfsd/export.h
fs/nfsd/flexfilelayout.c
fs/nfsd/nfs4idmap.c
fs/nfsd/nfsproc.c
fs/nfsd/vfs.c
fs/nfsd/vfs.h

index b6d01d5..04697f8 100644 (file)
@@ -12,6 +12,7 @@
 #include "blocklayoutxdr.h"
 #include "pnfs.h"
 #include "filecache.h"
+#include "vfs.h"
 
 #define NFSDDBG_FACILITY       NFSDDBG_PNFS
 
index 4425433..8e9c1a0 100644 (file)
@@ -9,6 +9,7 @@
 
 #include "nfsd.h"
 #include "blocklayoutxdr.h"
+#include "vfs.h"
 
 #define NFSDDBG_FACILITY       NFSDDBG_PNFS
 
index ee0e3ab..d03f7f6 100644 (file)
@@ -115,7 +115,6 @@ struct svc_export * rqst_find_fsidzero_export(struct svc_rqst *);
 int                    exp_rootfh(struct net *, struct auth_domain *,
                                        char *path, struct knfsd_fh *, int maxsize);
 __be32                 exp_pseudoroot(struct svc_rqst *, struct svc_fh *);
-__be32                 nfserrno(int errno);
 
 static inline void exp_put(struct svc_export *exp)
 {
index 070f90e..3ca5304 100644 (file)
@@ -15,6 +15,7 @@
 
 #include "flexfilelayoutxdr.h"
 #include "pnfs.h"
+#include "vfs.h"
 
 #define NFSDDBG_FACILITY       NFSDDBG_PNFS
 
index e70a1a2..5e9809a 100644 (file)
@@ -41,6 +41,7 @@
 #include "idmap.h"
 #include "nfsd.h"
 #include "netns.h"
+#include "vfs.h"
 
 /*
  * Turn off idmapping when using AUTH_SYS.
index 82b3dde..52fc222 100644 (file)
@@ -848,65 +848,3 @@ const struct svc_version nfsd_version2 = {
        .vs_dispatch    = nfsd_dispatch,
        .vs_xdrsize     = NFS2_SVC_XDRSIZE,
 };
-
-/*
- * Map errnos to NFS errnos.
- */
-__be32
-nfserrno (int errno)
-{
-       static struct {
-               __be32  nfserr;
-               int     syserr;
-       } nfs_errtbl[] = {
-               { nfs_ok, 0 },
-               { nfserr_perm, -EPERM },
-               { nfserr_noent, -ENOENT },
-               { nfserr_io, -EIO },
-               { nfserr_nxio, -ENXIO },
-               { nfserr_fbig, -E2BIG },
-               { nfserr_stale, -EBADF },
-               { nfserr_acces, -EACCES },
-               { nfserr_exist, -EEXIST },
-               { nfserr_xdev, -EXDEV },
-               { nfserr_mlink, -EMLINK },
-               { 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 },
-#ifdef EDQUOT
-               { nfserr_dquot, -EDQUOT },
-#endif
-               { nfserr_stale, -ESTALE },
-               { nfserr_jukebox, -ETIMEDOUT },
-               { nfserr_jukebox, -ERESTARTSYS },
-               { nfserr_jukebox, -EAGAIN },
-               { nfserr_jukebox, -EWOULDBLOCK },
-               { nfserr_jukebox, -ENOMEM },
-               { nfserr_io, -ETXTBSY },
-               { nfserr_notsupp, -EOPNOTSUPP },
-               { nfserr_toosmall, -ETOOSMALL },
-               { nfserr_serverfault, -ESERVERFAULT },
-               { nfserr_serverfault, -ENFILE },
-               { nfserr_io, -EREMOTEIO },
-               { nfserr_stale, -EOPENSTALE },
-               { nfserr_io, -EUCLEAN },
-               { nfserr_perm, -ENOKEY },
-               { nfserr_no_grace, -ENOGRACE},
-       };
-       int     i;
-
-       for (i = 0; i < ARRAY_SIZE(nfs_errtbl); i++) {
-               if (nfs_errtbl[i].syserr == errno)
-                       return nfs_errtbl[i].nfserr;
-       }
-       WARN_ONCE(1, "nfsd: non-standard errno: %d\n", errno);
-       return nfserr_io;
-}
-
index d6d90d6..278ebc6 100644 (file)
 
 #define NFSDDBG_FACILITY               NFSDDBG_FILEOP
 
+/**
+ * nfserrno - Map Linux errnos to NFS errnos
+ * @errno: POSIX(-ish) error code to be mapped
+ *
+ * Returns the appropriate (net-endian) nfserr_* (or nfs_ok if errno is 0). If
+ * it's an error we don't expect, log it once and return nfserr_io.
+ */
+__be32
+nfserrno (int errno)
+{
+       static struct {
+               __be32  nfserr;
+               int     syserr;
+       } nfs_errtbl[] = {
+               { nfs_ok, 0 },
+               { nfserr_perm, -EPERM },
+               { nfserr_noent, -ENOENT },
+               { nfserr_io, -EIO },
+               { nfserr_nxio, -ENXIO },
+               { nfserr_fbig, -E2BIG },
+               { nfserr_stale, -EBADF },
+               { nfserr_acces, -EACCES },
+               { nfserr_exist, -EEXIST },
+               { nfserr_xdev, -EXDEV },
+               { nfserr_mlink, -EMLINK },
+               { 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_jukebox, -ETIMEDOUT },
+               { nfserr_jukebox, -ERESTARTSYS },
+               { nfserr_jukebox, -EAGAIN },
+               { nfserr_jukebox, -EWOULDBLOCK },
+               { nfserr_jukebox, -ENOMEM },
+               { nfserr_io, -ETXTBSY },
+               { nfserr_notsupp, -EOPNOTSUPP },
+               { nfserr_toosmall, -ETOOSMALL },
+               { nfserr_serverfault, -ESERVERFAULT },
+               { nfserr_serverfault, -ENFILE },
+               { nfserr_io, -EREMOTEIO },
+               { nfserr_stale, -EOPENSTALE },
+               { nfserr_io, -EUCLEAN },
+               { nfserr_perm, -ENOKEY },
+               { nfserr_no_grace, -ENOGRACE},
+       };
+       int     i;
+
+       for (i = 0; i < ARRAY_SIZE(nfs_errtbl); i++) {
+               if (nfs_errtbl[i].syserr == errno)
+                       return nfs_errtbl[i].nfserr;
+       }
+       WARN_ONCE(1, "nfsd: non-standard errno: %d\n", errno);
+       return nfserr_io;
+}
+
 /* 
  * Called from nfsd_lookup and encode_dirent. Check if we have crossed 
  * a mount point.
index 120521b..8ddd687 100644 (file)
@@ -60,6 +60,7 @@ static inline void nfsd_attrs_free(struct nfsd_attrs *attrs)
        posix_acl_release(attrs->na_dpacl);
 }
 
+__be32         nfserrno (int errno);
 int            nfsd_cross_mnt(struct svc_rqst *rqstp, struct dentry **dpp,
                                struct svc_export **expp);
 __be32         nfsd_lookup(struct svc_rqst *, struct svc_fh *,