* amd/conf.c (gopt_forced_unmounts): check Linux kernel version
authorErez Zadok <ezk@cs.sunysb.edu>
Mon, 25 Jul 2005 23:49:41 +0000 (23:49 +0000)
committerErez Zadok <ezk@cs.sunysb.edu>
Mon, 25 Jul 2005 23:49:41 +0000 (23:49 +0000)
and alert if your version may be too old for MNT_FORCE to work
(before 2.4.0) or for MNT_DETACH to work (before 2.6.0).
Otherwise it may be impossible to pin down the exact kernel
version in which we should enable this feature.

* conf/umount/umount_linux.c (umount2_fs): if MNT_FORCE returned
EBUSY, then don't try to stat(2) before MNT_DETACH because it
could hang.

ChangeLog
amd/conf.c
conf/umount/umount_linux.c

index 77613b177f3cc9dcf98628a59b0cbf0233d0855e..c18243284c0063ea8046998923b1e86ff2d77b2f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2005-07-25  Erez Zadok  <ezk@cs.sunysb.edu>
+
+       * amd/conf.c (gopt_forced_unmounts): check Linux kernel version
+       and alert if your version may be too old for MNT_FORCE to work
+       (before 2.4.0) or for MNT_DETACH to work (before 2.6.0).
+       Otherwise it may be impossible to pin down the exact kernel
+       version in which we should enable this feature.
+
+       * conf/umount/umount_linux.c (umount2_fs): if MNT_FORCE returned
+       EBUSY, then don't try to stat(2) before MNT_DETACH because it
+       could hang.
+
 2005-07-21  Erez Zadok  <ezk@cs.sunysb.edu>
 
        * conf/umount/umount_linux.c (umount_fs): cleanup this function,
index 73877c5abf213493f2e9e7247c08c19439e39230..be7be77ff9e062164412579255cfb1ab86902b4d 100644 (file)
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: conf.c,v 1.33 2005/07/20 03:32:30 ezk Exp $
+ * $Id: conf.c,v 1.34 2005/07/25 23:49:41 ezk Exp $
  *
  */
 
@@ -502,6 +502,27 @@ gopt_forced_unmounts(const char *val)
     fprintf(stderr, "conf: forced_unmounts unsupported on this system.\n");
     return 1;
 #else /* defined(MNT2_GEN_OPT_DETACH) || defined(MNT2_GEN_OPT_FORCE) */
+# ifdef __linux__
+    /*
+     * HACK ALERT: Linux has had MNT_FORCE since 2.2, but it hasn't gotten
+     * stable until 2.4.  And it had MNT_DETACH since 2.4, but it hasn't
+     * gotten stable since 2.6.  So alert users if they're trying to use a
+     * feature that may not work well on their older kernel.
+     */
+    {
+      struct utsname un;
+      if (uname(&un) >= 0) {
+#  ifdef MNT2_GEN_OPT_FORCE
+       if (strcmp(un.release, "2.4.0") < 0)
+         fprintf(stderr, "warning: forced-unmounts (MNT_FORCE) may not work well before 2.4.0\n");
+#  endif /* MNT2_GEN_OPT_FORCE */
+#  ifdef MNT2_GEN_OPT_DETACH
+       if (strcmp(un.release, "2.6.0") < 0)
+         fprintf(stderr, "warning: lazy-unmounts (MNT_DETACH) may not work well before 2.6.0\n");
+#  endif /* MNT2_GEN_OPT_DETACH */
+      }
+    }
+# endif /* __linux__ */
     gopt.flags |= CFM_FORCED_UNMOUNTS;
     return 0;
 #endif /* defined(MNT2_GEN_OPT_DETACH) || defined(MNT2_GEN_OPT_FORCE) */
index 041b67703415e05ac89337384b2bc38445f7d6c8..6ab85df185e5c09507db61d667a9678ff11365ff 100644 (file)
@@ -37,7 +37,7 @@
  * SUCH DAMAGE.
  *
  *
- * $Id: umount_linux.c,v 1.7 2005/07/21 05:22:47 ezk Exp $
+ * $Id: umount_linux.c,v 1.8 2005/07/25 23:49:41 ezk Exp $
  *
  */
 
@@ -246,9 +246,17 @@ umount2_fs(const char *mntdir, u_int unmount_flags)
    * only do the forced unmount if the older Amd process died.
    */
   if (unmount_flags & AMU_UMOUNT_DETACH) {
-    struct stat dummy;
-    dlog("umount_fs: try stat() before unmount/detach");
-    error = stat(mntdir, &dummy);
+    /*
+     * If I got an EBUSY from the above FORCE, then don't try to stat(), or
+     * it will hang.
+     */
+    if (error < 0 && errno == EBUSY) {
+      error = 0;
+    } else {
+      struct stat dummy;
+      dlog("umount_fs: try stat() before unmount/detach");
+      error = stat(mntdir, &dummy);
+    }
     if (!error || (errno == ESTALE || errno == EIO)) {
       if (error < 0)
        plog(XLOG_INFO, "unmount2_fs: trying unmount/detach of %s (%m)",