linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] Tools: hv: vssdaemon: freeze/thaw logic improvement for the failure case
@ 2014-11-10 16:37 Vitaly Kuznetsov
  2014-11-10 16:37 ` [PATCH v2 1/2] Tools: hv: vssdaemon: report freeze errors Vitaly Kuznetsov
  2014-11-10 16:37 ` [PATCH v2 2/2] Tools: hv: vssdaemon: skip all filesystems mounted readonly Vitaly Kuznetsov
  0 siblings, 2 replies; 7+ messages in thread
From: Vitaly Kuznetsov @ 2014-11-10 16:37 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, Greg Kroah-Hartman
  Cc: devel, linux-kernel, Dexuan Cui

This patch series addresses the following issues:
- Verbosely report errors during freeze (mountpoint, exact error);
- Skip all readonly-mounted filesystems instead of skipping iso9660 only.

Changes since v1:
- Rebase on top of 'char-misc-next';
- "Tools: hv: vssdaemon: thaw everything in case of freeze" was thrown away as Dexuan's 
  "Tools: hv: vssdaemon: ignore the EBUSY on multiple freezing the same partition" contains
  the same change;
- "Tools: hv: vssdaemon: consult with errno in case of failure only" was replaced with
  "Tools: hv: vssdaemon: report freeze errors".

Vitaly Kuznetsov (2):
  Tools: hv: vssdaemon: report freeze errors
  Tools: hv: vssdaemon: skip all filesystems mounted readonly

 tools/hv/hv_vss_daemon.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

-- 
1.9.3


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

* [PATCH v2 1/2] Tools: hv: vssdaemon: report freeze errors
  2014-11-10 16:37 [PATCH v2 0/2] Tools: hv: vssdaemon: freeze/thaw logic improvement for the failure case Vitaly Kuznetsov
@ 2014-11-10 16:37 ` Vitaly Kuznetsov
  2014-11-11  3:07   ` Dexuan Cui
  2014-11-19 23:12   ` KY Srinivasan
  2014-11-10 16:37 ` [PATCH v2 2/2] Tools: hv: vssdaemon: skip all filesystems mounted readonly Vitaly Kuznetsov
  1 sibling, 2 replies; 7+ messages in thread
From: Vitaly Kuznetsov @ 2014-11-10 16:37 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, Greg Kroah-Hartman
  Cc: devel, linux-kernel, Dexuan Cui

When ioctl(fd, FIFREEZE, 0) results in an error we cannot report it
to syslog instantly since that can cause write to a frozen disk.
However, the name of the filesystem which caused the error and errno
are valuable and we would like to get a nice human-readable message
in the log. Save errno before calling vss_operate(VSS_OP_THAW) and
report the error right after.

Unfortunately, FITHAW errors cannot be reported the same way as we
need to finish thawing all filesystems before calling syslog().

We should also avoid calling endmntent() for the second time in
case we encountered an error during freezing of '/' as it usually
results in SEGSEGV.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 tools/hv/hv_vss_daemon.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
index b720d8f..ee44f0d 100644
--- a/tools/hv/hv_vss_daemon.c
+++ b/tools/hv/hv_vss_daemon.c
@@ -82,7 +82,7 @@ static int vss_operate(int operation)
 	FILE *mounts;
 	struct mntent *ent;
 	unsigned int cmd;
-	int error = 0, root_seen = 0;
+	int error = 0, root_seen = 0, save_errno = 0;
 
 	switch (operation) {
 	case VSS_OP_FREEZE:
@@ -114,7 +114,6 @@ static int vss_operate(int operation)
 		if (error && operation == VSS_OP_FREEZE)
 			goto err;
 	}
-	endmntent(mounts);
 
 	if (root_seen) {
 		error |= vss_do_freeze("/", cmd);
@@ -122,10 +121,19 @@ static int vss_operate(int operation)
 			goto err;
 	}
 
-	return error;
+	goto out;
 err:
-	endmntent(mounts);
+	save_errno = errno;
 	vss_operate(VSS_OP_THAW);
+	/* Call syslog after we thaw all filesystems */
+	if (ent)
+		syslog(LOG_ERR, "FREEZE of %s failed; error:%d %s",
+		       ent->mnt_dir, save_errno, strerror(save_errno));
+	else
+		syslog(LOG_ERR, "FREEZE of / failed; error:%d %s", save_errno,
+		       strerror(save_errno));
+out:
+	endmntent(mounts);
 	return error;
 }
 
-- 
1.9.3


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

* [PATCH v2 2/2] Tools: hv: vssdaemon: skip all filesystems mounted readonly
  2014-11-10 16:37 [PATCH v2 0/2] Tools: hv: vssdaemon: freeze/thaw logic improvement for the failure case Vitaly Kuznetsov
  2014-11-10 16:37 ` [PATCH v2 1/2] Tools: hv: vssdaemon: report freeze errors Vitaly Kuznetsov
@ 2014-11-10 16:37 ` Vitaly Kuznetsov
  2014-11-11  3:08   ` Dexuan Cui
  2014-11-19 23:01   ` KY Srinivasan
  1 sibling, 2 replies; 7+ messages in thread
From: Vitaly Kuznetsov @ 2014-11-10 16:37 UTC (permalink / raw)
  To: K. Y. Srinivasan, Haiyang Zhang, Greg Kroah-Hartman
  Cc: devel, linux-kernel, Dexuan Cui

Instead of making a list of exceptions for readonly filesystems
in addition to iso9660 we already have it is better to skip freeze
operation for all readonly-mounted filesystems.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
---
 tools/hv/hv_vss_daemon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
index ee44f0d..5e63f70 100644
--- a/tools/hv/hv_vss_daemon.c
+++ b/tools/hv/hv_vss_daemon.c
@@ -102,7 +102,7 @@ static int vss_operate(int operation)
 	while ((ent = getmntent(mounts))) {
 		if (strncmp(ent->mnt_fsname, match, strlen(match)))
 			continue;
-		if (strcmp(ent->mnt_type, "iso9660") == 0)
+		if (hasmntopt(ent, MNTOPT_RO) != NULL)
 			continue;
 		if (strcmp(ent->mnt_type, "vfat") == 0)
 			continue;
-- 
1.9.3


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

* RE: [PATCH v2 1/2] Tools: hv: vssdaemon: report freeze errors
  2014-11-10 16:37 ` [PATCH v2 1/2] Tools: hv: vssdaemon: report freeze errors Vitaly Kuznetsov
@ 2014-11-11  3:07   ` Dexuan Cui
  2014-11-19 23:12   ` KY Srinivasan
  1 sibling, 0 replies; 7+ messages in thread
From: Dexuan Cui @ 2014-11-11  3:07 UTC (permalink / raw)
  To: Vitaly Kuznetsov, KY Srinivasan, Haiyang Zhang, Greg Kroah-Hartman
  Cc: devel, linux-kernel

> -----Original Message-----
> From: Vitaly Kuznetsov
> Sent: Tuesday, November 11, 2014 0:37 AM
> To: KY Srinivasan; Haiyang Zhang; Greg Kroah-Hartman
> Cc: devel@linuxdriverproject.org; linux-kernel@vger.kernel.org; Dexuan Cui
> Subject: [PATCH v2 1/2] Tools: hv: vssdaemon: report freeze errors
> 
> When ioctl(fd, FIFREEZE, 0) results in an error we cannot report it
> to syslog instantly since that can cause write to a frozen disk.
> However, the name of the filesystem which caused the error and errno
> are valuable and we would like to get a nice human-readable message
> in the log. Save errno before calling vss_operate(VSS_OP_THAW) and
> report the error right after.
> 
> Unfortunately, FITHAW errors cannot be reported the same way as we
> need to finish thawing all filesystems before calling syslog().
> 
> We should also avoid calling endmntent() for the second time in
> case we encountered an error during freezing of '/' as it usually
> results in SEGSEGV.
> 
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
>  tools/hv/hv_vss_daemon.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)

Hi Vitaly,
Thanks for the patch -- it does improve the error handling!
 
Acked-by: Dexuan Cui <decui@microsoft.com>

-- Dexuan

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

* RE: [PATCH v2 2/2] Tools: hv: vssdaemon: skip all filesystems mounted readonly
  2014-11-10 16:37 ` [PATCH v2 2/2] Tools: hv: vssdaemon: skip all filesystems mounted readonly Vitaly Kuznetsov
@ 2014-11-11  3:08   ` Dexuan Cui
  2014-11-19 23:01   ` KY Srinivasan
  1 sibling, 0 replies; 7+ messages in thread
From: Dexuan Cui @ 2014-11-11  3:08 UTC (permalink / raw)
  To: Vitaly Kuznetsov, KY Srinivasan, Haiyang Zhang, Greg Kroah-Hartman
  Cc: devel, linux-kernel

> -----Original Message-----
> From: Vitaly Kuznetsov
> Sent: Tuesday, November 11, 2014 0:37 AM
> To: KY Srinivasan; Haiyang Zhang; Greg Kroah-Hartman
> Cc: devel@linuxdriverproject.org; linux-kernel@vger.kernel.org; Dexuan Cui
> Subject: [PATCH v2 2/2] Tools: hv: vssdaemon: skip all filesystems mounted
> readonly
> 
> Instead of making a list of exceptions for readonly filesystems
> in addition to iso9660 we already have it is better to skip freeze
> operation for all readonly-mounted filesystems.
> 
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
> ---
>  tools/hv/hv_vss_daemon.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c
> index ee44f0d..5e63f70 100644
> --- a/tools/hv/hv_vss_daemon.c
> +++ b/tools/hv/hv_vss_daemon.c
> @@ -102,7 +102,7 @@ static int vss_operate(int operation)
>  	while ((ent = getmntent(mounts))) {
>  		if (strncmp(ent->mnt_fsname, match, strlen(match)))
>  			continue;
> -		if (strcmp(ent->mnt_type, "iso9660") == 0)
> +		if (hasmntopt(ent, MNTOPT_RO) != NULL)
>  			continue;
>  		if (strcmp(ent->mnt_type, "vfat") == 0)
>  			continue;
> --

Acked-by: Dexuan Cui <decui@microsoft.com>

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

* RE: [PATCH v2 2/2] Tools: hv: vssdaemon: skip all filesystems mounted readonly
  2014-11-10 16:37 ` [PATCH v2 2/2] Tools: hv: vssdaemon: skip all filesystems mounted readonly Vitaly Kuznetsov
  2014-11-11  3:08   ` Dexuan Cui
@ 2014-11-19 23:01   ` KY Srinivasan
  1 sibling, 0 replies; 7+ messages in thread
From: KY Srinivasan @ 2014-11-19 23:01 UTC (permalink / raw)
  To: Vitaly Kuznetsov, Haiyang Zhang, Greg Kroah-Hartman
  Cc: devel, linux-kernel, Dexuan Cui



> -----Original Message-----
> From: Vitaly Kuznetsov [mailto:vkuznets@redhat.com]
> Sent: Monday, November 10, 2014 8:37 AM
> To: KY Srinivasan; Haiyang Zhang; Greg Kroah-Hartman
> Cc: devel@linuxdriverproject.org; linux-kernel@vger.kernel.org; Dexuan Cui
> Subject: [PATCH v2 2/2] Tools: hv: vssdaemon: skip all filesystems mounted
> readonly
> 
> Instead of making a list of exceptions for readonly filesystems in addition to
> iso9660 we already have it is better to skip freeze operation for all readonly-
> mounted filesystems.
> 
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>

> ---
>  tools/hv/hv_vss_daemon.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c index
> ee44f0d..5e63f70 100644
> --- a/tools/hv/hv_vss_daemon.c
> +++ b/tools/hv/hv_vss_daemon.c
> @@ -102,7 +102,7 @@ static int vss_operate(int operation)
>  	while ((ent = getmntent(mounts))) {
>  		if (strncmp(ent->mnt_fsname, match, strlen(match)))
>  			continue;
> -		if (strcmp(ent->mnt_type, "iso9660") == 0)
> +		if (hasmntopt(ent, MNTOPT_RO) != NULL)
>  			continue;
>  		if (strcmp(ent->mnt_type, "vfat") == 0)
>  			continue;
> --
> 1.9.3


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

* RE: [PATCH v2 1/2] Tools: hv: vssdaemon: report freeze errors
  2014-11-10 16:37 ` [PATCH v2 1/2] Tools: hv: vssdaemon: report freeze errors Vitaly Kuznetsov
  2014-11-11  3:07   ` Dexuan Cui
@ 2014-11-19 23:12   ` KY Srinivasan
  1 sibling, 0 replies; 7+ messages in thread
From: KY Srinivasan @ 2014-11-19 23:12 UTC (permalink / raw)
  To: Vitaly Kuznetsov, Haiyang Zhang, Greg Kroah-Hartman
  Cc: devel, linux-kernel, Dexuan Cui



> -----Original Message-----
> From: Vitaly Kuznetsov [mailto:vkuznets@redhat.com]
> Sent: Monday, November 10, 2014 8:37 AM
> To: KY Srinivasan; Haiyang Zhang; Greg Kroah-Hartman
> Cc: devel@linuxdriverproject.org; linux-kernel@vger.kernel.org; Dexuan Cui
> Subject: [PATCH v2 1/2] Tools: hv: vssdaemon: report freeze errors
> 
> When ioctl(fd, FIFREEZE, 0) results in an error we cannot report it to syslog
> instantly since that can cause write to a frozen disk.
> However, the name of the filesystem which caused the error and errno are
> valuable and we would like to get a nice human-readable message in the log.
> Save errno before calling vss_operate(VSS_OP_THAW) and report the error
> right after.
> 
> Unfortunately, FITHAW errors cannot be reported the same way as we need
> to finish thawing all filesystems before calling syslog().
> 
> We should also avoid calling endmntent() for the second time in case we
> encountered an error during freezing of '/' as it usually results in SEGSEGV.
> 
> Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: K. Y. Srinivasan <kys@microsoft.com>

> ---
>  tools/hv/hv_vss_daemon.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/hv/hv_vss_daemon.c b/tools/hv/hv_vss_daemon.c index
> b720d8f..ee44f0d 100644
> --- a/tools/hv/hv_vss_daemon.c
> +++ b/tools/hv/hv_vss_daemon.c
> @@ -82,7 +82,7 @@ static int vss_operate(int operation)
>  	FILE *mounts;
>  	struct mntent *ent;
>  	unsigned int cmd;
> -	int error = 0, root_seen = 0;
> +	int error = 0, root_seen = 0, save_errno = 0;
> 
>  	switch (operation) {
>  	case VSS_OP_FREEZE:
> @@ -114,7 +114,6 @@ static int vss_operate(int operation)
>  		if (error && operation == VSS_OP_FREEZE)
>  			goto err;
>  	}
> -	endmntent(mounts);
> 
>  	if (root_seen) {
>  		error |= vss_do_freeze("/", cmd);
> @@ -122,10 +121,19 @@ static int vss_operate(int operation)
>  			goto err;
>  	}
> 
> -	return error;
> +	goto out;
>  err:
> -	endmntent(mounts);
> +	save_errno = errno;
>  	vss_operate(VSS_OP_THAW);
> +	/* Call syslog after we thaw all filesystems */
> +	if (ent)
> +		syslog(LOG_ERR, "FREEZE of %s failed; error:%d %s",
> +		       ent->mnt_dir, save_errno, strerror(save_errno));
> +	else
> +		syslog(LOG_ERR, "FREEZE of / failed; error:%d %s",
> save_errno,
> +		       strerror(save_errno));
> +out:
> +	endmntent(mounts);
>  	return error;
>  }
> 
> --
> 1.9.3


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

end of thread, other threads:[~2014-11-19 23:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-11-10 16:37 [PATCH v2 0/2] Tools: hv: vssdaemon: freeze/thaw logic improvement for the failure case Vitaly Kuznetsov
2014-11-10 16:37 ` [PATCH v2 1/2] Tools: hv: vssdaemon: report freeze errors Vitaly Kuznetsov
2014-11-11  3:07   ` Dexuan Cui
2014-11-19 23:12   ` KY Srinivasan
2014-11-10 16:37 ` [PATCH v2 2/2] Tools: hv: vssdaemon: skip all filesystems mounted readonly Vitaly Kuznetsov
2014-11-11  3:08   ` Dexuan Cui
2014-11-19 23:01   ` KY Srinivasan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).