* [PATCH] receive: strip root subvol path during process_clone
@ 2016-06-14 22:55 Benedikt Morbach
2016-06-14 23:06 ` Benedikt Morbach
0 siblings, 1 reply; 6+ messages in thread
From: Benedikt Morbach @ 2016-06-14 22:55 UTC (permalink / raw)
To: linux-btrfs; +Cc: Benedikt Morbach
otherwise we get
ERROR: cannot open <subvol_path>: No such file or directory
because <full_root_path>/<subvol_path> doesn't exist, so openat() will fail below.
Signed-off-by: Benedikt Morbach <benedikt.morbach@googlemail.com>
---
cmds-receive.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/cmds-receive.c b/cmds-receive.c
index f4a3a4f..a975fdd 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -753,6 +753,17 @@ static int process_clone(const char *path, u64 offset, u64 len,
subvol_path = strdup(si->path);
}
+ /* strip the subvolume that we are receiving to from the start of subvol_path */
+ if (r->full_root_path &&
+ strstr(subvol_path, r->full_root_path) == subvol_path) {
+ size_t root_len = strlen(r->full_root_path);
+ size_t sub_len = strlen(subvol_path);
+
+ memmove(subvol_path,
+ subvol_path + root_len + 1,
+ sub_len - root_len);
+ }
+
ret = path_cat_out(full_clone_path, subvol_path, clone_path);
if (ret < 0) {
error("clone: target path invalid: %s", clone_path);
--
2.8.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] receive: strip root subvol path during process_clone
2016-06-14 22:55 [PATCH] receive: strip root subvol path during process_clone Benedikt Morbach
@ 2016-06-14 23:06 ` Benedikt Morbach
2016-06-14 23:26 ` [PATCH] btrfs-progs: receive: handle root subvol path in clone Benedikt Morbach
2016-06-17 17:18 ` [PATCH] receive: strip root subvol path during process_clone David Sterba
0 siblings, 2 replies; 6+ messages in thread
From: Benedikt Morbach @ 2016-06-14 23:06 UTC (permalink / raw)
To: linux-btrfs
Hi all,
this fixes http://thread.gmane.org/gmane.comp.file-systems.btrfs/56902
for me.
I got to this via gdb + good old debug printf and tbh I'm not entirely
clear about the semantics of process_clone, so some error handling
might be missing here?
Cheers
Benedikt
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] btrfs-progs: receive: handle root subvol path in clone
2016-06-14 23:06 ` Benedikt Morbach
@ 2016-06-14 23:26 ` Benedikt Morbach
2016-06-17 17:18 ` [PATCH] receive: strip root subvol path during process_clone David Sterba
1 sibling, 0 replies; 6+ messages in thread
From: Benedikt Morbach @ 2016-06-14 23:26 UTC (permalink / raw)
To: linux-btrfs; +Cc: Benedikt Morbach
otherwise we get
ERROR: cannot open <subvol_path>: No such file or directory
because <full_root_path>/<subvol_path> doesn't exist, so openat() will fail below.
Signed-off-by: Benedikt Morbach <benedikt.morbach@googlemail.com>
---
resend with 'btrfs-progs:' in the subject.
Sorry for the noise
cheers
cmds-receive.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/cmds-receive.c b/cmds-receive.c
index f4a3a4f..a975fdd 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -753,6 +753,17 @@ static int process_clone(const char *path, u64 offset, u64 len,
subvol_path = strdup(si->path);
}
+ /* strip the subvolume that we are receiving to from the start of subvol_path */
+ if (r->full_root_path &&
+ strstr(subvol_path, r->full_root_path) == subvol_path) {
+ size_t root_len = strlen(r->full_root_path);
+ size_t sub_len = strlen(subvol_path);
+
+ memmove(subvol_path,
+ subvol_path + root_len + 1,
+ sub_len - root_len);
+ }
+
ret = path_cat_out(full_clone_path, subvol_path, clone_path);
if (ret < 0) {
error("clone: target path invalid: %s", clone_path);
--
2.8.4
^ permalink raw reply related [flat|nested] 6+ messages in thread* Re: [PATCH] receive: strip root subvol path during process_clone
2016-06-14 23:06 ` Benedikt Morbach
2016-06-14 23:26 ` [PATCH] btrfs-progs: receive: handle root subvol path in clone Benedikt Morbach
@ 2016-06-17 17:18 ` David Sterba
2016-07-11 14:07 ` Benedikt Morbach
1 sibling, 1 reply; 6+ messages in thread
From: David Sterba @ 2016-06-17 17:18 UTC (permalink / raw)
To: Benedikt Morbach; +Cc: linux-btrfs
Hi,
On Wed, Jun 15, 2016 at 01:06:46AM +0200, Benedikt Morbach wrote:
> this fixes http://thread.gmane.org/gmane.comp.file-systems.btrfs/56902
> for me.
> I got to this via gdb + good old debug printf and tbh I'm not entirely
> clear about the semantics of process_clone, so some error handling
> might be missing here?
thanks for the fix. The mail thread holds enough information to
reproduce the issue, I'll get to that on Monday. I'm not sure about the
use of strstr to match the subvolume name so I want to write the tests
first and craft some paths to see how it works.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] receive: strip root subvol path during process_clone
2016-06-17 17:18 ` [PATCH] receive: strip root subvol path during process_clone David Sterba
@ 2016-07-11 14:07 ` Benedikt Morbach
2016-07-13 15:46 ` David Sterba
0 siblings, 1 reply; 6+ messages in thread
From: Benedikt Morbach @ 2016-07-11 14:07 UTC (permalink / raw)
To: dsterba, Benedikt Morbach, Btrfs BTRFS
Hi David,
On Fri, Jun 17, 2016 at 7:18 PM, David Sterba <dsterba@suse.cz> wrote:
> thanks for the fix. The mail thread holds enough information to
> reproduce the issue, I'll get to that on Monday. I'm not sure about the
> use of strstr to match the subvolume name so I want to write the tests
> first and craft some paths to see how it works.
any update on this? I've been running this patch for a few weeks now
with my hourly backups.
I could also take a stab at writing a test case but I think I'd need
some pointers for that. ;-)
I took a look at the send/receive patches that Filipe sent earlier and
afaict this isn't fixed in those.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] receive: strip root subvol path during process_clone
2016-07-11 14:07 ` Benedikt Morbach
@ 2016-07-13 15:46 ` David Sterba
0 siblings, 0 replies; 6+ messages in thread
From: David Sterba @ 2016-07-13 15:46 UTC (permalink / raw)
To: Benedikt Morbach; +Cc: dsterba, Btrfs BTRFS
On Mon, Jul 11, 2016 at 04:07:25PM +0200, Benedikt Morbach wrote:
> Hi David,
>
> On Fri, Jun 17, 2016 at 7:18 PM, David Sterba <dsterba@suse.cz> wrote:
> > thanks for the fix. The mail thread holds enough information to
> > reproduce the issue, I'll get to that on Monday. I'm not sure about the
> > use of strstr to match the subvolume name so I want to write the tests
> > first and craft some paths to see how it works.
>
> any update on this? I've been running this patch for a few weeks now
> with my hourly backups.
> I could also take a stab at writing a test case but I think I'd need
> some pointers for that. ;-)
Sorry, I got distracted. The things with paths are a bit complicated,
there's chroot support, explicit mountpoint (-m), so stripping the
root_path would not work in all cases.
Apparently the full_clone_path is wrong there as it's not relative to
root_path and thus openat(mnt_fd, ...) will fail, so instead of
stripping the path, we would need to provide the clone path relative to
root_path directly.
> I took a look at the send/receive patches that Filipe sent earlier and
> afaict this isn't fixed in those.
No, this is not related to kernel.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-07-13 15:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-14 22:55 [PATCH] receive: strip root subvol path during process_clone Benedikt Morbach
2016-06-14 23:06 ` Benedikt Morbach
2016-06-14 23:26 ` [PATCH] btrfs-progs: receive: handle root subvol path in clone Benedikt Morbach
2016-06-17 17:18 ` [PATCH] receive: strip root subvol path during process_clone David Sterba
2016-07-11 14:07 ` Benedikt Morbach
2016-07-13 15:46 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).