Skip to contentSkip to conversation

mount.nfs: Only ignore EBUSY when a filesystem is already mount

PATCH In review Steve Dickson 1 participant 2 messages Oct 20, 2018 – Oct 22, 2018

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

PATCH 1/1 mount.nfs: Only ignore EBUSY when a filesystem is already mount

EBUSY errors can be caused by using the -o sharecache flag and different context= values. So make sure the filesytem is mounted before ignoring the EBUSY error.

---
 utils/mount/Makefile.am |  1 +
 utils/mount/stropts.c   | 16 ++++++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)
utils/mount/Makefile.am +1 -0
index 7b97c31..ad0be93 100644
@@ -27,6 +27,7 @@ endif
 
 mount_nfs_LDADD = ../../support/nfs/libnfs.la \
 		  ../../support/export/libexport.a \
+		  ../../support/misc/libmisc.a \
 		  $(LIBTIRPC)
 
 mount_nfs_SOURCES = $(mount_common)
utils/mount/stropts.c +10 -6
index 4d2e37e..eed0356 100644
@@ -48,6 +48,7 @@
 #include "version.h"
 #include "parse_dev.h"
 #include "conffile.h"
+#include "misc.h"
 
 #ifndef NFS_PROGRAM
 #define NFS_PROGRAM	(100003)
@@ -1078,12 +1079,15 @@ static int nfsmount_fg(struct nfsmount_info *mi)
 		if (nfs_try_mount(mi))
 			return EX_SUCCESS;
 
-		if (errno == EBUSY)
-			/* The only cause of EBUSY is if exactly the desired
-			 * filesystem is already mounted.  That can arguably
-			 * be seen as success.  "mount -a" tries to optimise
-			 * out this case but sometimes fails.  Help it out
-			 * by pretending everything is rosy
+#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
+		if (errno == EBUSY && is_mountpoint(mi->node))
+#pragma GCC diagnostic warning "-Wdiscarded-qualifiers"
+			/*
+			 * EBUSY can happen when mounting a filesystem that
+			 * is already mounted or when the context= are
+			 * different when using the -o sharecache
+			 *
+			 * Only error out in the latter case.
 			 */
 			return EX_SUCCESS;
 
Signature · 1 line
2.17.2
#1 lore raw
Quoted 8 lines · Steve Dickson

EBUSY errors can be caused by using the -o sharecache flag and different context= values. So make sure the filesytem is mounted before ignoring the EBUSY error.

Committed...

steved.

Quoted 52 lines
---
 utils/mount/Makefile.am |  1 +
 utils/mount/stropts.c   | 16 ++++++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)
utils/mount/Makefile.am +1 -0
index 7b97c31..ad0be93 100644
@@ -27,6 +27,7 @@ endif
 
 mount_nfs_LDADD = ../../support/nfs/libnfs.la \
 		  ../../support/export/libexport.a \
+		  ../../support/misc/libmisc.a \
 		  $(LIBTIRPC)
 
 mount_nfs_SOURCES = $(mount_common)
utils/mount/stropts.c +10 -6
index 4d2e37e..eed0356 100644
@@ -48,6 +48,7 @@
 #include "version.h"
 #include "parse_dev.h"
 #include "conffile.h"
+#include "misc.h"
 
 #ifndef NFS_PROGRAM
 #define NFS_PROGRAM	(100003)
@@ -1078,12 +1079,15 @@ static int nfsmount_fg(struct nfsmount_info *mi)
 		if (nfs_try_mount(mi))
 			return EX_SUCCESS;
 
-		if (errno == EBUSY)
-			/* The only cause of EBUSY is if exactly the desired
-			 * filesystem is already mounted.  That can arguably
-			 * be seen as success.  "mount -a" tries to optimise
-			 * out this case but sometimes fails.  Help it out
-			 * by pretending everything is rosy
+#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
+		if (errno == EBUSY && is_mountpoint(mi->node))
+#pragma GCC diagnostic warning "-Wdiscarded-qualifiers"
+			/*
+			 * EBUSY can happen when mounting a filesystem that
+			 * is already mounted or when the context= are
+			 * different when using the -o sharecache
+			 *
+			 * Only error out in the latter case.
 			 */
 			return EX_SUCCESS;