]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Ignore EBUSY when freezing filesystems.
authorVMware, Inc <>
Thu, 22 Dec 2011 00:26:34 +0000 (16:26 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 22 Dec 2011 00:26:34 +0000 (16:26 -0800)
Thanks to bind mounts (and apparently some other changes in Fedora 15), we
may try to freeze the same superblock more than once. Ignore the EBUSY
errors the kernel returns in these cases.

Log some more information and fix a memory leak in the process.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/syncDriver/syncDriverLinux.c

index af785795d255f6e0e3a0cdfa894dceaa7cc0b582..81d16e80ca916b6f77b4d127aee952455709ae82 100644 (file)
@@ -192,15 +192,27 @@ LinuxDriver_Freeze(const char *paths,
           * supported on the device, we get EOPNOTSUPP. Ignore the latter,
           * since freezing does not make sense for all fs types, and some
           * Linux fs drivers may not have been hooked up in the running kernel.
+          *
+          * Also ignore EBUSY since we may try to freeze the same superblock
+          * more than once depending on the OS configuration (e.g., usage of
+          * bind mounts).
           */
          close(fd);
-         if (ioctlerr != EOPNOTSUPP) {
-            Debug(LGPFX "ioctl failed: %d (%s)\n", ioctlerr, strerror(ioctlerr));
-            err = first ? SD_UNAVAILABLE : SD_ERROR;
+         if (ioctlerr != EBUSY && ioctlerr != EOPNOTSUPP) {
+            Debug(LGPFX "failed to freeze '%s': %d (%s)\n",
+                  path, ioctlerr, strerror(ioctlerr));
+            err = first && ioctlerr == ENOTTY ? SD_UNAVAILABLE : SD_ERROR;
+            free(path);
             break;
          }
       } else {
+         Debug(LGPFX "successfully froze '%s'.\n", path);
          if (!DynBuf_Append(&fds, &fd, sizeof fd)) {
+            if (ioctl(fd, FITHAW) == -1) {
+               Warning(LGPFX "failed to thaw '%s': %d (%s)\n",
+                       path, errno, strerror(errno));
+            }
+            free(path);
             close(fd);
             err = SD_ERROR;
             break;
@@ -208,6 +220,7 @@ LinuxDriver_Freeze(const char *paths,
          count++;
       }
 
+      free(path);
       first = FALSE;
    }