/[gentoo-x86]/sys-fs/btrfs-progs/files/btrfs-progs-3.12-fix-send-subvol-492776.patch
Gentoo

Contents of /sys-fs/btrfs-progs/files/btrfs-progs-3.12-fix-send-subvol-492776.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Sat Nov 30 20:55:15 2013 UTC (4 years, 9 months ago) by slyfox
Branch: MAIN
CVS Tags: HEAD
Fix 'btrfs send' on funky subvol paths (bug #492776 by Thomas Scheiblauer).

(Portage version: 2.2.7_p18/cvs/Linux x86_64, signed Manifest commit with key 611FF3AA)

1 Gentoo-bug: http://bugs.gentoo.org/492776
2
3 From: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
4
5 Steps to reproduce:
6 # mkfs.btrfs -f /dev/sda
7 # mount /dev/sda /mnt
8 # btrfs subvolume create /mnt/foo
9 # umount /mnt
10 # mount -o subvol=foo /dev/sda /mnt
11 # btrfs sub snapshot -r /mnt /mnt/snap
12 # btrfs send /mnt/snap > /dev/null
13
14 We will fail to send '/mnt/snap',this is because btrfs send try to
15 open '/mnt/snap' by btrfs internal subvolume path 'foo/snap' rather
16 than relative path based on mounted point, this will return us 'no
17 such file or directory',this is not right, fix it.
18
19 Reported-by: Thomas Scheiblauer <tom@sharkbay.at>
20 Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
21 ---
22 v1->v2:
23 code cleanups(thanks to Stefan)
24 ---
25 cmds-send.c | 34 ++++++----------------------------
26 1 file changed, 6 insertions(+), 28 deletions(-)
27
28 diff --git a/cmds-send.c b/cmds-send.c
29 index 53e9a53..6fdfd7f 100644
30 --- a/cmds-send.c
31 +++ b/cmds-send.c
32 @@ -282,31 +282,21 @@ out:
33 return ERR_PTR(ret);
34 }
35
36 -static int do_send(struct btrfs_send *send, u64 root_id, u64 parent_root_id,
37 - int is_first_subvol, int is_last_subvol)
38 +static int do_send(struct btrfs_send *send, u64 parent_root_id,
39 + int is_first_subvol, int is_last_subvol, char *subvol)
40 {
41 int ret;
42 pthread_t t_read;
43 pthread_attr_t t_attr;
44 struct btrfs_ioctl_send_args io_send;
45 - struct subvol_info *si;
46 void *t_err = NULL;
47 int subvol_fd = -1;
48 int pipefd[2] = {-1, -1};
49
50 - si = subvol_uuid_search(&send->sus, root_id, NULL, 0, NULL,
51 - subvol_search_by_root_id);
52 - if (!si) {
53 - ret = -ENOENT;
54 - fprintf(stderr, "ERROR: could not find subvol info for %llu",
55 - root_id);
56 - goto out;
57 - }
58 -
59 - subvol_fd = openat(send->mnt_fd, si->path, O_RDONLY | O_NOATIME);
60 + subvol_fd = openat(send->mnt_fd, subvol, O_RDONLY | O_NOATIME);
61 if (subvol_fd < 0) {
62 ret = -errno;
63 - fprintf(stderr, "ERROR: open %s failed. %s\n", si->path,
64 + fprintf(stderr, "ERROR: open %s failed. %s\n", subvol,
65 strerror(-ret));
66 goto out;
67 }
68 @@ -385,10 +375,6 @@ out:
69 close(pipefd[0]);
70 if (pipefd[1] != -1)
71 close(pipefd[1]);
72 - if (si) {
73 - free(si->path);
74 - free(si);
75 - }
76 return ret;
77 }
78
79 @@ -664,14 +650,6 @@ int cmd_send(int argc, char **argv)
80 goto out;
81 }
82
83 - ret = get_root_id(&send, get_subvol_name(send.root_path, subvol),
84 - &root_id);
85 - if (ret < 0) {
86 - fprintf(stderr, "ERROR: could not resolve root_id "
87 - "for %s\n", subvol);
88 - goto out;
89 - }
90 -
91 if (!full_send && !parent_root_id) {
92 ret = find_good_parent(&send, root_id, &parent_root_id);
93 if (ret < 0) {
94 @@ -700,8 +678,8 @@ int cmd_send(int argc, char **argv)
95 is_first_subvol = 1;
96 is_last_subvol = 1;
97 }
98 - ret = do_send(&send, root_id, parent_root_id,
99 - is_first_subvol, is_last_subvol);
100 + ret = do_send(&send, parent_root_id, is_first_subvol,
101 + is_last_subvol, subvol);
102 if (ret < 0)
103 goto out;
104
105 --
106 1.8.4
107
108 --
109 To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
110 the body of a message to majordomo@vger.kernel.org
111 More majordomo info at http://vger.kernel.org/majordomo-info.html

  ViewVC Help
Powered by ViewVC 1.1.20