Commit ea81fdf0 authored by Alex Ng's avatar Alex Ng Committed by Greg Kroah-Hartman

Tools: hv: vss: Skip freezing filesystems backed by loop

Since a loop device is backed by a file, a backup will already result in
its parent filesystem being frozen. It's sufficient to just freeze the
parent filesystem, so we can skip the loop device.

This avoids a situation where a loop device and its parent filesystem are
both frozen and then thawed out of order. For example, if the loop device
is enumerated first, we would thaw it while its parent filesystem is still
frozen. The thaw operation fails and the loop device remains frozen.
Signed-off-by: default avatarAlex Ng <alexng@messages.microsoft.com>
Signed-off-by: default avatarVyronas Tsingaras <vyronas@vtsingaras.me>
Signed-off-by: default avatarK. Y. Srinivasan <kys@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 5f972797
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/poll.h> #include <sys/poll.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <mntent.h> #include <mntent.h>
...@@ -30,6 +31,7 @@ ...@@ -30,6 +31,7 @@
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/major.h>
#include <linux/hyperv.h> #include <linux/hyperv.h>
#include <syslog.h> #include <syslog.h>
#include <getopt.h> #include <getopt.h>
...@@ -70,6 +72,7 @@ static int vss_operate(int operation) ...@@ -70,6 +72,7 @@ static int vss_operate(int operation)
char match[] = "/dev/"; char match[] = "/dev/";
FILE *mounts; FILE *mounts;
struct mntent *ent; struct mntent *ent;
struct stat sb;
char errdir[1024] = {0}; char errdir[1024] = {0};
unsigned int cmd; unsigned int cmd;
int error = 0, root_seen = 0, save_errno = 0; int error = 0, root_seen = 0, save_errno = 0;
...@@ -92,6 +95,10 @@ static int vss_operate(int operation) ...@@ -92,6 +95,10 @@ static int vss_operate(int operation)
while ((ent = getmntent(mounts))) { while ((ent = getmntent(mounts))) {
if (strncmp(ent->mnt_fsname, match, strlen(match))) if (strncmp(ent->mnt_fsname, match, strlen(match)))
continue; continue;
if (stat(ent->mnt_fsname, &sb) == -1)
continue;
if (S_ISBLK(sb.st_mode) && major(sb.st_rdev) == LOOP_MAJOR)
continue;
if (hasmntopt(ent, MNTOPT_RO) != NULL) if (hasmntopt(ent, MNTOPT_RO) != NULL)
continue; continue;
if (strcmp(ent->mnt_type, "vfat") == 0) if (strcmp(ent->mnt_type, "vfat") == 0)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment