Skip to contentSkip to conversation

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

PATCH Superseded Dexuan Cui 2 participants 4 messages Sep 23, 2014 – Sep 24, 2014 Hyper-V/Azure core and drivers

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Dexuan Cui

author maintainer
#0 lore raw

PATCH v2 1/1 Tools: hv: vssdaemon: ignore the EBUSY on multiple freezing the same partition

v2: I added "errno = 0;" in the ioctl()

---
 tools/hv/hv_vss_daemon.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
tools/hv/hv_vss_daemon.c +28 -0
index 6a213b8..c1af658 100644
@@ -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;
Signature · 1 line
1.9.1
author maintainer
#1 lore raw
Quoted 11 lines

-----Original Message-----
From: [email protected] [mailto:linux-kernel- [email protected]] On Behalf Of Dexuan Cui
Sent: Tuesday, September 23, 2014 13:01 PM
To: [email protected]; [email protected]; driverdev- [email protected]; [email protected]; [email protected]; [email protected]
Cc: KY Srinivasan; Haiyang Zhang
Subject: [PATCH v2] Tools: hv: vssdaemon: ignore the EBUSY on multiple freezing the same partition

Quoted 1 line

v2: I added "errno = 0;" in the ioctl()

typo -- "in the ioctl(") should be "before the ioctl()".

Thanks,
-- Dexuan

#2 lore raw
In reply to Dexuan Cui
Quoted 1 line · Dexuan Cui

v2: I added "errno = 0;" in the ioctl()

That does not belong in the changelog, put it below the --- line.

Also, you need a changelog description here, it can't be empty.

greg k-h

author maintainer
#3 lore raw
Quoted 11 lines

-----Original Message-----
From: [email protected] [mailto:linux-kernel- [email protected]] On Behalf Of Greg KH
Sent: Wednesday, September 24, 2014 14:32 PM
To: Dexuan Cui
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Haiyang Zhang
Subject: Re: [PATCH v2] Tools: hv: vssdaemon: ignore the EBUSY on multiple freezing the same partition

Quoted 8 lines
Quoted 1 line · Dexuan Cui

v2: I added "errno = 0;" in the ioctl()

That does not belong in the changelog, put it below the --- line.

Also, you need a changelog description here, it can't be empty.

greg k-h

Thanks for pointing this out! I'll fix it.

Thanks,
-- Dexuan