[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1411448455-12768-1-git-send-email-decui@microsoft.com>
Date: Mon, 22 Sep 2014 22:00:55 -0700
From: Dexuan Cui <decui@...rosoft.com>
To: gregkh@...uxfoundation.org, linux-kernel@...r.kernel.org,
driverdev-devel@...uxdriverproject.org, olaf@...fle.de,
apw@...onical.com, jasowang@...hat.com
Cc: kys@...rosoft.com, haiyangz@...rosoft.com
Subject: [PATCH v2] Tools: hv: vssdaemon: ignore the EBUSY on multiple freezing the same partition
v2: I added "errno = 0;" in the ioctl()
Signed-off-by: Dexuan Cui <decui@...rosoft.com>
Reviewed-by: K. Y. Srinivasan <kys@...rosoft.com>
---
tools/hv/hv_vss_daemon.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
index 6a213b8..c1af658 100644
--- a/tools/hv/hv_vss_daemon.c
+++ b/tools/hv/hv_vss_daemon.c
@@ -50,7 +50,35 @@ static int vss_do_freeze(char *dir, unsigned int cmd, char *fs_op)
if (fd < 0)
return 1;
+
+ /* A successful syscall doesn't set errno to 0. Without this line,
+ * the below strerror(errno) can accidently show the errno of the
+ * previous failed syscall.
+ */
+ errno = 0;
+
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists