[PATCH] btrfs: Don't fail if we meet non-subvolume mountpoint
Cyrill Gorcunov
gorcunov at openvz.org
Thu Dec 5 01:46:34 PST 2013
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: Cyrill Gorcunov <gorcunov at openvz.org>
---
mount-btrfs.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/mount-btrfs.c b/mount-btrfs.c
index 90383dc3bd4a..cfa9182dd562 100644
--- a/mount-btrfs.c
+++ b/mount-btrfs.c
@@ -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)
--
1.8.3.1
--x+6KMIRAuhnl3hBn--
More information about the CRIU
mailing list