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