Commit 921cf873 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

btrfs: Don't fail if we meet non-subvolume mountpoint

If mount point is not a subvolume we need more complex logic
to figure out which subvolumes it might have. It'll be addressed
later, at moment simply don't fail in such case: for worst
scenarion we will fail later in CRIU code when devs are not
matching, in best case if application is not using notify,
sockets or deleted files -- we should continue without errors.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent fe5f60b9
......@@ -397,13 +397,14 @@ static void btrfs_show_subvolumes(struct btrfs_subvol_root *r)
}
}
static void *btrfs_parse_volume(struct mount_info *m)
static int btrfs_parse_volume(struct mount_info *m)
{
struct btrfs_ioctl_search_args tree_args;
struct btrfs_ioctl_search_header sh;
struct btrfs_ioctl_search_key *sk = &tree_args.key;
struct btrfs_subvol_root *r, *result = NULL;
struct btrfs_subvol_root *r;
int result = -1;
unsigned long off, i;
int ret = -1, fd = -1;
......@@ -426,11 +427,19 @@ static void *btrfs_parse_volume(struct mount_info *m)
goto err;
}
if (stat(m->mountpoint, &st)) {
if (fstat(fd, &st)) {
pr_perror("Can't get stat on %s", m->mountpoint);
goto err;
}
/*
* It is not a subvolume, nothing to do yet.
*/
if (st.st_ino != BTRFS_FIRST_FREE_OBJECTID) {
result = 0;
goto err;
}
r = btrfs_create_root(fd, m, &st);
if (!r) {
pr_err("Can't create btrfs root for %s\n", m->mountpoint);
......@@ -485,17 +494,17 @@ static void *btrfs_parse_volume(struct mount_info *m)
goto err;
BUG_ON(m->private);
m->private = (void *)result;
m->private = (void *)r;
btrfs_show_subvolumes(r);
result = r;
result = 0;
err:
close_safe(&fd);
return (void *)result;
return result;
}
int btrfs_parse_mountinfo(struct mount_info *m)
{
return btrfs_parse_volume(m) ? 0 : -1;
return btrfs_parse_volume(m);
}
bool is_btrfs_subvol(dev_t vol_id, dev_t dev_id)
......
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