[PATCH] Tools: hv: vssdaemon: ignore the EBUSY on multiple freezing the same partition

Dexuan Cui decui at microsoft.com
Mon Sep 22 18:02:13 UTC 2014


Signed-off-by: Dexuan Cui <decui at microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys at microsoft.com>
---
 tools/hv/hv_vss_daemon.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
index 6a213b8..19567c5 100644
--- a/tools/hv/hv_vss_daemon.c
+++ b/tools/hv/hv_vss_daemon.c
@@ -51,6 +51,27 @@ static int vss_do_freeze(char *dir, unsigned int cmd, char *fs_op)
 	if (fd < 0)
 		return 1;
 	ret = ioctl(fd, cmd, 0);
+
+	/*
+	 * If a partition is mounted more than once, only the first
+	 * FREEZE/THAW can succeed and the later ones will get
+	 * EBUSY/EINVAL respectively: there could be 2 cases:
+	 * 1) a user may mount the same partition to differnt directories
+	 *  by mistake or on purpose;
+	 * 2) The subvolume of btrfs appears to have the same partition
+	 * mounted more than once.
+	 */
+	if (ret) {
+		if ((cmd == FIFREEZE && errno == EBUSY) ||
+		    (cmd == FITHAW && errno == EINVAL)) {
+			syslog(LOG_INFO, "VSS: %s of %s: %s: ignored\n",
+				fs_op, dir,
+				errno == EBUSY ? "EBUSY" : "EINVAL");
+			close(fd);
+			return 0;
+		}
+	}
+
 	syslog(LOG_INFO, "VSS: %s of %s: %s\n", fs_op, dir, strerror(errno));
 	close(fd);
 	return !!ret;
-- 
1.9.1



More information about the devel mailing list