public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* RE: [PATCH v2] Tools: hv: vssdaemon: ignore the EBUSY on multiple freezing the same partition
  2014-09-23  5:00 [PATCH v2] Tools: hv: vssdaemon: ignore the EBUSY on multiple freezing the same partition Dexuan Cui
@ 2014-09-23  4:05 ` Dexuan Cui
  2014-09-24  6:32 ` Greg KH
  1 sibling, 0 replies; 4+ messages in thread
From: Dexuan Cui @ 2014-09-23  4:05 UTC (permalink / raw)
  To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org,
	driverdev-devel@linuxdriverproject.org, olaf@aepfle.de,
	apw@canonical.com, jasowang@redhat.com
  Cc: KY Srinivasan, Haiyang Zhang

> -----Original Message-----
> From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-
> owner@vger.kernel.org] On Behalf Of Dexuan Cui
> Sent: Tuesday, September 23, 2014 13:01 PM
> To: gregkh@linuxfoundation.org; linux-kernel@vger.kernel.org; driverdev-
> devel@linuxdriverproject.org; olaf@aepfle.de; apw@canonical.com;
> jasowang@redhat.com
> Cc: KY Srinivasan; Haiyang Zhang
> Subject: [PATCH v2] Tools: hv: vssdaemon: ignore the EBUSY on multiple
> freezing the same partition
> 
> v2: I added "errno = 0;" in the ioctl()
typo --   "in the ioctl(")  should be "before the ioctl()".

Thanks,
-- Dexuan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2] Tools: hv: vssdaemon: ignore the EBUSY on multiple freezing the same partition
@ 2014-09-23  5:00 Dexuan Cui
  2014-09-23  4:05 ` Dexuan Cui
  2014-09-24  6:32 ` Greg KH
  0 siblings, 2 replies; 4+ messages in thread
From: Dexuan Cui @ 2014-09-23  5:00 UTC (permalink / raw)
  To: gregkh, linux-kernel, driverdev-devel, olaf, apw, jasowang; +Cc: kys, haiyangz

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

Signed-off-by: Dexuan Cui <decui@microsoft.com>
Reviewed-by: K. Y. Srinivasan <kys@microsoft.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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] Tools: hv: vssdaemon: ignore the EBUSY on multiple freezing the same partition
  2014-09-23  5:00 [PATCH v2] Tools: hv: vssdaemon: ignore the EBUSY on multiple freezing the same partition Dexuan Cui
  2014-09-23  4:05 ` Dexuan Cui
@ 2014-09-24  6:32 ` Greg KH
  2014-09-24  8:57   ` Dexuan Cui
  1 sibling, 1 reply; 4+ messages in thread
From: Greg KH @ 2014-09-24  6:32 UTC (permalink / raw)
  To: Dexuan Cui; +Cc: linux-kernel, driverdev-devel, olaf, apw, jasowang, haiyangz

On Mon, Sep 22, 2014 at 10:00:55PM -0700, Dexuan Cui wrote:
> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH v2] Tools: hv: vssdaemon: ignore the EBUSY on multiple freezing the same partition
  2014-09-24  6:32 ` Greg KH
@ 2014-09-24  8:57   ` Dexuan Cui
  0 siblings, 0 replies; 4+ messages in thread
From: Dexuan Cui @ 2014-09-24  8:57 UTC (permalink / raw)
  To: Greg KH
  Cc: linux-kernel@vger.kernel.org,
	driverdev-devel@linuxdriverproject.org, olaf@aepfle.de,
	apw@canonical.com, jasowang@redhat.com, Haiyang Zhang

> -----Original Message-----
> From: linux-kernel-owner@vger.kernel.org [mailto:linux-kernel-
> owner@vger.kernel.org] On Behalf Of Greg KH
> Sent: Wednesday, September 24, 2014 14:32 PM
> To: Dexuan Cui
> Cc: linux-kernel@vger.kernel.org; driverdev-devel@linuxdriverproject.org;
> olaf@aepfle.de; apw@canonical.com; jasowang@redhat.com; Haiyang
> Zhang
> Subject: Re: [PATCH v2] Tools: hv: vssdaemon: ignore the EBUSY on multiple
> freezing the same partition
> 
> On Mon, Sep 22, 2014 at 10:00:55PM -0700, Dexuan Cui wrote:
> > 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-09-24  9:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-23  5:00 [PATCH v2] Tools: hv: vssdaemon: ignore the EBUSY on multiple freezing the same partition Dexuan Cui
2014-09-23  4:05 ` Dexuan Cui
2014-09-24  6:32 ` Greg KH
2014-09-24  8:57   ` Dexuan Cui

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox