Skip to contentSkip to conversation

mount: Report correct error in the fall_back cases.

PATCH In review Steve Dickson 1 participant 2 messages May 14, 2019 – May 20, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mount: Report correct error in the fall_back cases.

In mount auto negotiation, a v3 mount is tried when the v4 fails with error that could mean v4 is not supported.

When the v3 mount fails, the original v4 failure should be used to set the errno, not the v3 failure.

---
 utils/mount/stropts.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
utils/mount/stropts.c +13 -2
index 1bb7a73..901f995 100644
@@ -889,7 +889,7 @@ out:
  */
 static int nfs_autonegotiate(struct nfsmount_info *mi)
 {
-	int result;
+	int result, olderrno;
 
 	result = nfs_try_mount_v4(mi);
 check_result:
@@ -949,7 +949,18 @@ fall_back:
 	if (mi->version.v_mode == V_GENERAL)
 		/* v2,3 fallback not allowed */
 		return result;
-	return nfs_try_mount_v3v2(mi, FALSE);
+
+	/*
+	 * Save the original errno in case the v3 
+	 * mount fails from one of the fall_back cases. 
+	 * Report the first failure not the v3 mount failure
+	 */
+	olderrno = errno;
+	if ((result = nfs_try_mount_v3v2(mi, FALSE)))
+		return result;
+
+	errno = olderrno;
+	return result;
 }
 
 /*
Signature · 1 line
2.20.1
#1 lore raw
Quoted 9 lines · Steve Dickson

In mount auto negotiation, a v3 mount is tried when the v4 fails with error that could mean v4 is not supported.

When the v3 mount fails, the original v4 failure should be used to set the errno, not the v3 failure.

Committed....

steved,

Quoted 38 lines
---
 utils/mount/stropts.c | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
utils/mount/stropts.c +13 -2
index 1bb7a73..901f995 100644
@@ -889,7 +889,7 @@ out:
  */
 static int nfs_autonegotiate(struct nfsmount_info *mi)
 {
-	int result;
+	int result, olderrno;
 
 	result = nfs_try_mount_v4(mi);
 check_result:
@@ -949,7 +949,18 @@ fall_back:
 	if (mi->version.v_mode == V_GENERAL)
 		/* v2,3 fallback not allowed */
 		return result;
-	return nfs_try_mount_v3v2(mi, FALSE);
+
+	/*
+	 * Save the original errno in case the v3 
+	 * mount fails from one of the fall_back cases. 
+	 * Report the first failure not the v3 mount failure
+	 */
+	olderrno = errno;
+	if ((result = nfs_try_mount_v3v2(mi, FALSE)))
+		return result;
+
+	errno = olderrno;
+	return result;
 }
 
 /*