Skip to contentSkip to conversation

mount.nfs: improve EPROTO error message for RDMA mounts

PATCH In review Dan Aloni 2 participants 2 messages Sep 19, 2024 – Sep 20, 2024

Subsystems (2)
lore
Share & tools
lore

Dan Aloni

author
#0 lore raw

PATCH 1/1 mount.nfs: improve EPROTO error message for RDMA mounts

When mounting NFS shares using RDMA, users may encounter this rather unclear error message:

mount.nfs: Protocol error

Often there are either no RDMA interfaces existing, or that routing is being done via other interfaces. This patch enhances the mount_error function to provide a more informative message in such cases.

---
 utils/mount/error.c     | 12 +++++++++++-
 utils/mount/error.h     |  4 +++-
 utils/mount/network.c   |  2 +-
 utils/mount/network.h   |  2 ++
 utils/mount/nfs4mount.c |  2 +-
 utils/mount/nfsmount.c  |  2 +-
 utils/mount/stropts.c   |  8 ++++----
 utils/mount/utils.c     |  6 +++---
 8 files changed, 26 insertions(+), 12 deletions(-)
utils/mount/error.c +11 -1
index 9ddbcc096f72..d6cbdea1933b 100644
@@ -40,6 +40,7 @@
 #include "nls.h"
 #include "mount.h"
 #include "error.h"
+#include "network.h"
 
 #ifdef HAVE_RPCSVC_NFS_PROT_H
 #include <rpcsvc/nfs_prot.h>
@@ -199,7 +200,8 @@ void sys_mount_errors(char *server, int error, int will_retry, int bg)
  * @error: errno value to report
  *
  */
-void mount_error(const char *spec, const char *mount_point, int error)
+void mount_error(const char *spec, const char *mount_point, int error,
+		 struct mount_options *options)
 {
 	switch(error) {
 	case EACCES:
@@ -250,6 +252,14 @@ void mount_error(const char *spec, const char *mount_point, int error)
 	case EALREADY:
 		/* Error message has already been provided */
 		break;
+	case EPROTO:
+		if (options && po_rightmost(options, nfs_transport_opttbl) == 2)
+			nfs_error(_("%s: %s: is routing being done via an interface supporting RDMA?"),
+				  progname, strerror(error));
+		else
+			nfs_error(_("%s: %s"),
+				  progname, strerror(error));
+		break;
 	default:
 		nfs_error(_("%s: %s for %s on %s"),
 			  progname, strerror(error), spec, mount_point);
utils/mount/error.h +3 -1
index ef80fd079b48..f9f282233563 100644
@@ -24,9 +24,11 @@
 #ifndef _NFS_UTILS_MOUNT_ERROR_H
 #define _NFS_UTILS_MOUNT_ERROR_H
 
+#include "parse_opt.h"
+
 char *nfs_strerror(unsigned int);
 
-void mount_error(const char *, const char *, int);
+void mount_error(const char *, const char *, int, struct mount_options *);
 void rpc_mount_errors(char *, int, int);
 void sys_mount_errors(char *, int, int, int);
 
utils/mount/network.c +1 -1
index 01ead49f0008..64293f6f8d51 100644
@@ -88,7 +88,7 @@ static const char *nfs_nfs_pgmtbl[] = {
 	NULL,
 };
 
-static const char *nfs_transport_opttbl[] = {
+const char *nfs_transport_opttbl[] = {
 	"udp",
 	"tcp",
 	"rdma",
utils/mount/network.h +2 -0
index 0fc98acd4bcb..26f4eec775df 100644
@@ -93,4 +93,6 @@ void mnt_closeclnt(CLIENT *, int);
 int nfs_umount_do_umnt(struct mount_options *options,
 		       char **hostname, char **dirname);
 
+extern const char *nfs_transport_opttbl[];
+
 #endif	/* _NFS_UTILS_MOUNT_NETWORK_H */
utils/mount/nfs4mount.c +1 -1
index 3e4f1e255ca7..0fe142a7843e 100644
@@ -469,7 +469,7 @@ int nfs4mount(const char *spec, const char *node, int flags,
 	if (!fake) {
 		if (mount(spec, node, "nfs4",
 				flags & ~(MS_USER|MS_USERS), &data)) {
-			mount_error(spec, node, errno);
+			mount_error(spec, node, errno, NULL);
 			goto fail;
 		}
 	}
utils/mount/nfsmount.c +1 -1
index 3d95da9456de..a1c92fe83fa0 100644
@@ -858,7 +858,7 @@ noauth_flavors:
 	if (!fake) {
 		if (mount(spec, node, "nfs",
 				flags & ~(MS_USER|MS_USERS), &data)) {
-			mount_error(spec, node, errno);
+			mount_error(spec, node, errno, NULL);
 			goto fail;
 		}
 	}
utils/mount/stropts.c +4 -4
index a92c420011a4..2d5fa1f2e86e 100644
@@ -1143,7 +1143,7 @@ static int nfsmount_fg(struct nfsmount_info *mi)
 		}
 	}
 
-	mount_error(mi->spec, mi->node, errno);
+	mount_error(mi->spec, mi->node, errno, mi->options);
 	return EX_FAIL;
 }
 
@@ -1160,7 +1160,7 @@ static int nfsmount_parent(struct nfsmount_info *mi)
 		return EX_SUCCESS;
 
 	if (nfs_is_permanent_error(errno)) {
-		mount_error(mi->spec, mi->node, errno);
+		mount_error(mi->spec, mi->node, errno, mi->options);
 		return EX_FAIL;
 	}
 
@@ -1237,7 +1237,7 @@ static int nfs_remount(struct nfsmount_info *mi)
 {
 	if (nfs_sys_mount(mi, mi->options))
 		return EX_SUCCESS;
-	mount_error(mi->spec, mi->node, errno);
+	mount_error(mi->spec, mi->node, errno, mi->options);
 	return EX_FAIL;
 }
 
@@ -1261,7 +1261,7 @@ static int nfsmount_start(struct nfsmount_info *mi)
 	 * NFS v2 has been deprecated
 	 */
 	if (mi->version.major == 2) {
-		mount_error(mi->spec, mi->node, EOPNOTSUPP);
+		mount_error(mi->spec, mi->node, EOPNOTSUPP, mi->options);
 		return EX_FAIL;
 	}
 
utils/mount/utils.c +3 -3
index 865a4a05f3fc..b7562a474f88 100644
@@ -123,15 +123,15 @@ int chk_mountpoint(const char *mount_point)
 	struct stat sb;
 
 	if (stat(mount_point, &sb) < 0){
-		mount_error(NULL, mount_point, errno);
+		mount_error(NULL, mount_point, errno, NULL);
 		return 1;
 	}
 	if (S_ISDIR(sb.st_mode) == 0){
-		mount_error(NULL, mount_point, ENOTDIR);
+		mount_error(NULL, mount_point, ENOTDIR, NULL);
 		return 1;
 	}
 	if (getuid() != 0 && geteuid() != 0 && access(mount_point, X_OK) < 0) {
-		mount_error(NULL, mount_point, errno);
+		mount_error(NULL, mount_point, errno, NULL);
 		return 1;
 	}
 
Signature · 1 line
2.43.5
#1 lore raw
Quoted 10 lines · Dan Aloni

When mounting NFS shares using RDMA, users may encounter this rather unclear error message:

mount.nfs: Protocol error

Often there are either no RDMA interfaces existing, or that routing is being done via other interfaces. This patch enhances the mount_error function to provide a more informative message in such cases.

Committed... (tag: nfs-utils-2-7-2-rc1)

steved.

Quoted 178 lines
---
  utils/mount/error.c     | 12 +++++++++++-
  utils/mount/error.h     |  4 +++-
  utils/mount/network.c   |  2 +-
  utils/mount/network.h   |  2 ++
  utils/mount/nfs4mount.c |  2 +-
  utils/mount/nfsmount.c  |  2 +-
  utils/mount/stropts.c   |  8 ++++----
  utils/mount/utils.c     |  6 +++---
  8 files changed, 26 insertions(+), 12 deletions(-)
utils/mount/error.c +11 -1
index 9ddbcc096f72..d6cbdea1933b 100644
@@ -40,6 +40,7 @@
  #include "nls.h"
  #include "mount.h"
  #include "error.h"
+#include "network.h"
 
  #ifdef HAVE_RPCSVC_NFS_PROT_H
  #include <rpcsvc/nfs_prot.h>
@@ -199,7 +200,8 @@ void sys_mount_errors(char *server, int error, int will_retry, int bg)
   * @error: errno value to report
   *
   */
-void mount_error(const char *spec, const char *mount_point, int error)
+void mount_error(const char *spec, const char *mount_point, int error,
+		 struct mount_options *options)
  {
  	switch(error) {
  	case EACCES:
@@ -250,6 +252,14 @@ void mount_error(const char *spec, const char *mount_point, int error)
  	case EALREADY:
  		/* Error message has already been provided */
  		break;
+	case EPROTO:
+		if (options && po_rightmost(options, nfs_transport_opttbl) == 2)
+			nfs_error(_("%s: %s: is routing being done via an interface supporting RDMA?"),
+				  progname, strerror(error));
+		else
+			nfs_error(_("%s: %s"),
+				  progname, strerror(error));
+		break;
  	default:
  		nfs_error(_("%s: %s for %s on %s"),
  			  progname, strerror(error), spec, mount_point);
utils/mount/error.h +3 -1
index ef80fd079b48..f9f282233563 100644
@@ -24,9 +24,11 @@
  #ifndef _NFS_UTILS_MOUNT_ERROR_H
  #define _NFS_UTILS_MOUNT_ERROR_H
 
+#include "parse_opt.h"
+
  char *nfs_strerror(unsigned int);
 
-void mount_error(const char *, const char *, int);
+void mount_error(const char *, const char *, int, struct mount_options *);
  void rpc_mount_errors(char *, int, int);
  void sys_mount_errors(char *, int, int, int);
 
utils/mount/network.c +1 -1
index 01ead49f0008..64293f6f8d51 100644
@@ -88,7 +88,7 @@ static const char *nfs_nfs_pgmtbl[] = {
  	NULL,
  };
 
-static const char *nfs_transport_opttbl[] = {
+const char *nfs_transport_opttbl[] = {
  	"udp",
  	"tcp",
  	"rdma",
utils/mount/network.h +2 -0
index 0fc98acd4bcb..26f4eec775df 100644
@@ -93,4 +93,6 @@ void mnt_closeclnt(CLIENT *, int);
  int nfs_umount_do_umnt(struct mount_options *options,
  		       char **hostname, char **dirname);
 
+extern const char *nfs_transport_opttbl[];
+
  #endif	/* _NFS_UTILS_MOUNT_NETWORK_H */
utils/mount/nfs4mount.c +1 -1
index 3e4f1e255ca7..0fe142a7843e 100644
@@ -469,7 +469,7 @@ int nfs4mount(const char *spec, const char *node, int flags,
  	if (!fake) {
  		if (mount(spec, node, "nfs4",
  				flags & ~(MS_USER|MS_USERS), &data)) {
-			mount_error(spec, node, errno);
+			mount_error(spec, node, errno, NULL);
  			goto fail;
  		}
  	}
utils/mount/nfsmount.c +1 -1
index 3d95da9456de..a1c92fe83fa0 100644
@@ -858,7 +858,7 @@ noauth_flavors:
  	if (!fake) {
  		if (mount(spec, node, "nfs",
  				flags & ~(MS_USER|MS_USERS), &data)) {
-			mount_error(spec, node, errno);
+			mount_error(spec, node, errno, NULL);
  			goto fail;
  		}
  	}
utils/mount/stropts.c +4 -4
index a92c420011a4..2d5fa1f2e86e 100644
@@ -1143,7 +1143,7 @@ static int nfsmount_fg(struct nfsmount_info *mi)
  		}
  	}
 
-	mount_error(mi->spec, mi->node, errno);
+	mount_error(mi->spec, mi->node, errno, mi->options);
  	return EX_FAIL;
  }
 
@@ -1160,7 +1160,7 @@ static int nfsmount_parent(struct nfsmount_info *mi)
  		return EX_SUCCESS;
 
  	if (nfs_is_permanent_error(errno)) {
-		mount_error(mi->spec, mi->node, errno);
+		mount_error(mi->spec, mi->node, errno, mi->options);
  		return EX_FAIL;
  	}
 
@@ -1237,7 +1237,7 @@ static int nfs_remount(struct nfsmount_info *mi)
  {
  	if (nfs_sys_mount(mi, mi->options))
  		return EX_SUCCESS;
-	mount_error(mi->spec, mi->node, errno);
+	mount_error(mi->spec, mi->node, errno, mi->options);
  	return EX_FAIL;
  }
 
@@ -1261,7 +1261,7 @@ static int nfsmount_start(struct nfsmount_info *mi)
  	 * NFS v2 has been deprecated
  	 */
  	if (mi->version.major == 2) {
-		mount_error(mi->spec, mi->node, EOPNOTSUPP);
+		mount_error(mi->spec, mi->node, EOPNOTSUPP, mi->options);
  		return EX_FAIL;
  	}
 
utils/mount/utils.c +3 -3
index 865a4a05f3fc..b7562a474f88 100644
@@ -123,15 +123,15 @@ int chk_mountpoint(const char *mount_point)
  	struct stat sb;
 
  	if (stat(mount_point, &sb) < 0){
-		mount_error(NULL, mount_point, errno);
+		mount_error(NULL, mount_point, errno, NULL);
  		return 1;
  	}
  	if (S_ISDIR(sb.st_mode) == 0){
-		mount_error(NULL, mount_point, ENOTDIR);
+		mount_error(NULL, mount_point, ENOTDIR, NULL);
  		return 1;
  	}
  	if (getuid() != 0 && geteuid() != 0 && access(mount_point, X_OK) < 0) {
-		mount_error(NULL, mount_point, errno);
+		mount_error(NULL, mount_point, errno, NULL);
  		return 1;
  	}