Robert Buhren
2012-Aug-13 10:22 UTC
Testing new send/receive: "ERROR: could not resolve root_id for"
Hello, i wanted to test the new send/receive feature and i can''t manage to send a snapshot to a file. I always get the error "ERROR: could not resolve root_id for". I''m using kernel 3.6-rc1 and the latest btrfs progs from git. This is what i''m doing: mount -o subvolid=0,discard,compress=lzo /dev/sda4 /mnt/ROOT_BTRFS [root@robert-laptop mnt]# /home/robert/ArchLinux/btrfs-progs/btrfs subvolume list ROOT_BTRFS/ ID 256 top level 5 path btrfs_root <--- my rootfs subvolume ID 265 top level 5 path btrfs_root-11082012-0023 <--- a "normal" snapshot" ID 268 top level 5 path root_send <--- a read only snapshot i try to use with send [root@robert-laptop ~]# cd /mnt/ROOT_BTRFS/ [root@robert-laptop ROOT_BTRFS]# /home/robert/ArchLinux/btrfs-progs/btrfs send root_send > outROOT At subvol root_send ERROR: could not resolve root_id for /mnt/ROOT_BTRFS/root_send Am i somehow misunderstanding how the send/receive feature should work? My idea is to send the "root_send" snapshot to a file and then replay that file later on a backup btrfs partition. Once i''ve done that i can just send incremental differences to the backup partition. Is that how "send/receive" is supposed to work? If you need further information just tell me. Thanks in advance, Robert PS: Please respond to my email address as i''m not subscribed to the list. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Arne Jansen
2012-Aug-19 14:59 UTC
Re: Testing new send/receive: "ERROR: could not resolve root_id for"
The problem here is that you nest multiple mounts of the same fs. This confuses find_mount_root which determines the upper-level mount as the mountpoint instead of the lower-level one. It does that because it searches upwards for the first change in the fsid. As you nested the name fs, the fsid does not change when it crosses the boundary, so it misses the mountpoint. What is the accepted way to find a mountpoint? I''ve seen lots of code that searches the mnttab, is there a more convenient way? -Arne On 08/13/2012 12:22 PM, Robert Buhren wrote:> Hello, > > i wanted to test the new send/receive feature and i can''t manage to send > a snapshot to a file. I always get the error > "ERROR: could not resolve root_id for". > > I''m using kernel 3.6-rc1 and the latest btrfs progs from git. > > This is what i''m doing: > > mount -o subvolid=0,discard,compress=lzo /dev/sda4 /mnt/ROOT_BTRFS > > [root@robert-laptop mnt]# /home/robert/ArchLinux/btrfs-progs/btrfs > subvolume list ROOT_BTRFS/ > ID 256 top level 5 path btrfs_root <--- my rootfs subvolume > ID 265 top level 5 path btrfs_root-11082012-0023 <--- a "normal" > snapshot" > ID 268 top level 5 path root_send <--- a read only snapshot i try to use > with send > > [root@robert-laptop ~]# cd /mnt/ROOT_BTRFS/ > [root@robert-laptop ROOT_BTRFS]# > /home/robert/ArchLinux/btrfs-progs/btrfs send root_send > outROOT > At subvol root_send > ERROR: could not resolve root_id for /mnt/ROOT_BTRFS/root_send > > Am i somehow misunderstanding how the send/receive feature should work? > My idea is to send the "root_send" snapshot to a file and then replay > that file later on a backup btrfs partition. Once i''ve done that i can > just send incremental differences to the backup partition. Is that how > "send/receive" is supposed to work? > > If you need further information just tell me. > > Thanks in advance, > > Robert > > > PS: Please respond to my email address as i''m not subscribed to the list. > > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jan Schmidt
2012-Aug-20 11:57 UTC
[PATCH] Btrfs-progs: replace find_mount_root from send code
Hi Robert, i made a quick patch, can you please give it a try? Can be applied with "git am --scissors". Thanks, -Jan -- >8 -- find_mount_root had the problem that it tried to conclude from a file system path to a mount point, taking the fsid as an indicator. This only works if no two subvolumes (sharing the same btrfs fsid) are mounted in the same hierarchy. Now instead, we''re parsing /etc/mtab and look for the longest match. Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net> --- cmds-send.c | 88 ++++++++++++++--------------------------------------------- 1 files changed, 21 insertions(+), 67 deletions(-) diff --git a/cmds-send.c b/cmds-send.c index 8a0c110..41ea523 100644 --- a/cmds-send.c +++ b/cmds-send.c @@ -28,6 +28,7 @@ #include <sys/types.h> #include <sys/ioctl.h> #include <libgen.h> +#include <mntent.h> #include <uuid/uuid.h> @@ -55,82 +56,35 @@ struct btrfs_send { int find_mount_root(const char *path, char **mount_root) { - int ret; - char *cur; - char fsid[BTRFS_FSID_SIZE]; + FILE *mnttab; int fd; - struct stat st; - char *tmp; - char *dup = NULL; - - struct btrfs_ioctl_fs_info_args args; + struct mntent *ent; + int len; + int longest_matchlen = 0; + char *longest_match = NULL; fd = open(path, O_RDONLY | O_NOATIME); - if (fd < 0) { - ret = -errno; - goto out; - } - - ret = fstat(fd, &st); - if (fd < 0) { - ret = -errno; - goto out; - } - if (!S_ISDIR(st.st_mode)) { - ret = -ENOTDIR; - goto out; - } - - ret = ioctl(fd, BTRFS_IOC_FS_INFO, &args); - if (fd < 0) { - ret = -errno; - goto out; - } - memcpy(fsid, args.fsid, BTRFS_FSID_SIZE); + if (fd < 0) + return -errno; close(fd); - fd = -1; - cur = strdup(path); - - while (1) { - dup = strdup(cur); - tmp = dirname(dup); - - if (!tmp) - break; - fd = open(tmp, O_RDONLY | O_NOATIME); - if (fd < 0) { - ret = -errno; - goto out; + mnttab = fopen("/etc/mtab", "r"); + while ((ent = getmntent(mnttab))) { + len = strlen(ent->mnt_dir); + if (strncmp(ent->mnt_dir, path, len) == 0) { + /* match found */ + if (longest_matchlen < len) { + free(longest_match); + longest_matchlen = len; + longest_match = strdup(ent->mnt_dir); + } } - - ret = ioctl(fd, BTRFS_IOC_FS_INFO, &args); - close(fd); - fd = -1; - if (ret < 0) - break; - if (memcmp(fsid, args.fsid, BTRFS_FSID_SIZE) != 0) - break; - - free(cur); - cur = strdup(tmp); - free(dup); - dup = NULL; - if (strcmp(cur, "/") == 0) - break; - if (strcmp(cur, ".") == 0) - break; } - ret = 0; - *mount_root = realpath(cur, NULL); + *mount_root = realpath(longest_match, NULL); + free(longest_match); -out: - if (dup) - free(dup); - if (fd != -1) - close(fd); - return ret; + return 0; } static int get_root_id(struct btrfs_send *s, const char *path, u64 *root_id) -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Robert Buhren
2012-Aug-23 08:54 UTC
Re: [PATCH] Btrfs-progs: replace find_mount_root from send code
Hi Jan, thanks for the patch! Sending works. But i got some trouble on the receiving side. Here''s my complete test-setup: I have two btrfs partitions: mount | grep btrfs: /dev/loop0 on /mnt/TEST_ROOT type btrfs (rw,relatime,compress=lzo,space_cache) # default-subvolume /dev/loop0 on /mnt/TEST_ROOT/root_volid0 type btrfs (rw,relatime,compress=lzo,space_cache) # subvolid= 0 /dev/loop1 on /mnt/TEST_ROOT/backup_volid0 type btrfs (rw,relatime,compress=lzo,space_cache) With the patch this works now: btrfs subvolume snapshot -r /mnt/TEST_ROOT/root_volid0/root/ /mnt/TEST_ROOT/root_volid0/root_snap btrfs send /mnt/TEST_ROOT/root_volid0/root_snap > root_snap_send But when i try to receive it on the /mnt/TEST_ROOT/backup_volid0 btrfs partition i get: btrfs receive -f root_snap_send /mnt/TEST_ROOT/backup_volid0/ ERROR: utimes failed. Bad file descriptor i also tried "cat root_snap_send | btrfs receive /mnt/TEST_ROOT/backup_volid0". But the result is the same. What''s interesting is that there is actually a subvolume "root_snap" created in "backup_volid0", but it''s empty. I''m on linux-3.6-rc2 and btrfs-progs from git. If further Information is needed, just tell me. Regards, Robert On 20.08.2012 13:57, Jan Schmidt wrote:> Hi Robert, > > i made a quick patch, can you please give it a try? Can be applied with > "git am --scissors". > > Thanks, > -Jan > > -- >8 -- > > find_mount_root had the problem that it tried to conclude from a file system > path to a mount point, taking the fsid as an indicator. This only works if > no two subvolumes (sharing the same btrfs fsid) are mounted in the same > hierarchy. > > Now instead, we''re parsing /etc/mtab and look for the longest match. > > Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net> > --- > cmds-send.c | 88 ++++++++++++++--------------------------------------------- > 1 files changed, 21 insertions(+), 67 deletions(-) > > diff --git a/cmds-send.c b/cmds-send.c > index 8a0c110..41ea523 100644 > --- a/cmds-send.c > +++ b/cmds-send.c > @@ -28,6 +28,7 @@ > #include <sys/types.h> > #include <sys/ioctl.h> > #include <libgen.h> > +#include <mntent.h> > > #include <uuid/uuid.h> > > @@ -55,82 +56,35 @@ struct btrfs_send { > > int find_mount_root(const char *path, char **mount_root) > { > - int ret; > - char *cur; > - char fsid[BTRFS_FSID_SIZE]; > + FILE *mnttab; > int fd; > - struct stat st; > - char *tmp; > - char *dup = NULL; > - > - struct btrfs_ioctl_fs_info_args args; > + struct mntent *ent; > + int len; > + int longest_matchlen = 0; > + char *longest_match = NULL; > > fd = open(path, O_RDONLY | O_NOATIME); > - if (fd < 0) { > - ret = -errno; > - goto out; > - } > - > - ret = fstat(fd, &st); > - if (fd < 0) { > - ret = -errno; > - goto out; > - } > - if (!S_ISDIR(st.st_mode)) { > - ret = -ENOTDIR; > - goto out; > - } > - > - ret = ioctl(fd, BTRFS_IOC_FS_INFO, &args); > - if (fd < 0) { > - ret = -errno; > - goto out; > - } > - memcpy(fsid, args.fsid, BTRFS_FSID_SIZE); > + if (fd < 0) > + return -errno; > close(fd); > - fd = -1; > > - cur = strdup(path); > - > - while (1) { > - dup = strdup(cur); > - tmp = dirname(dup); > - > - if (!tmp) > - break; > - fd = open(tmp, O_RDONLY | O_NOATIME); > - if (fd < 0) { > - ret = -errno; > - goto out; > + mnttab = fopen("/etc/mtab", "r"); > + while ((ent = getmntent(mnttab))) { > + len = strlen(ent->mnt_dir); > + if (strncmp(ent->mnt_dir, path, len) == 0) { > + /* match found */ > + if (longest_matchlen < len) { > + free(longest_match); > + longest_matchlen = len; > + longest_match = strdup(ent->mnt_dir); > + } > } > - > - ret = ioctl(fd, BTRFS_IOC_FS_INFO, &args); > - close(fd); > - fd = -1; > - if (ret < 0) > - break; > - if (memcmp(fsid, args.fsid, BTRFS_FSID_SIZE) != 0) > - break; > - > - free(cur); > - cur = strdup(tmp); > - free(dup); > - dup = NULL; > - if (strcmp(cur, "/") == 0) > - break; > - if (strcmp(cur, ".") == 0) > - break; > } > > - ret = 0; > - *mount_root = realpath(cur, NULL); > + *mount_root = realpath(longest_match, NULL); > + free(longest_match); > > -out: > - if (dup) > - free(dup); > - if (fd != -1) > - close(fd); > - return ret; > + return 0; > } > > static int get_root_id(struct btrfs_send *s, const char *path, u64 *root_id)-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
David Sterba
2012-Aug-24 13:33 UTC
Re: [PATCH] Btrfs-progs: replace find_mount_root from send code
On Thu, Aug 23, 2012 at 10:54:54AM +0200, Robert Buhren wrote:> I''m on linux-3.6-rc2 and btrfs-progs from git.Please try it with Chris'' for-linus branch, it contains a fair portion of send-related fixes and from brief look they may be related to the errors you see. david -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Robert Buhren
2012-Aug-25 08:24 UTC
Re: [PATCH] Btrfs-progs: replace find_mount_root from send code
On 24.08.2012 15:33, David Sterba wrote:> On Thu, Aug 23, 2012 at 10:54:54AM +0200, Robert Buhren wrote: >> I''m on linux-3.6-rc2 and btrfs-progs from git. > Please try it with Chris'' for-linus branch, it contains a fair portion > of send-related fixes and from brief look they may be related to the > errors you see. > > davidHi David, i just tried it with a kernel from the "for-linus" branch. But i still get the same error. Just to be sure: You ment this branch: http://git.kernel.org/?p=linux/kernel/git/mason/linux-btrfs.git;a=shortlog;h=refs/heads/for-linus right? Regards, Robert -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Alex Lyakas
2012-Aug-27 09:16 UTC
Re: [PATCH] Btrfs-progs: replace find_mount_root from send code
Hi Robert, do you think you can make the "root_snap_send" file of yours available anywhere (not sure how big it is)? Also, I am not sure I understand how you btrfs tree looks like WRT to where all subvolumes are mounted (but all others seem to understand well). You mentioned:> /dev/loop0 on /mnt/TEST_ROOT type btrfs (rw,relatime,compress=lzo,space_cache) # default-subvolume > /dev/loop0 on /mnt/TEST_ROOT/root_volid0 type btrfs (rw,relatime,compress=lzo,space_cache) # subvolid= 0 > /dev/loop1 on /mnt/TEST_ROOT/backup_volid0 type btrfs (rw,relatime,compress=lzo,space_cache)> btrfs subvolume snapshot -r /mnt/TEST_ROOT/root_volid0/root/ /mnt/TEST_ROOT/root_volid0/root_snapAre you trying to snapshot a directory here? I.e., what is "root" within "root_volid0"? Can you pls list all subvolumes you have on your source filesystem (the one you are trying to backup), and where each one is mounted? Again, looks like I''m the only one confused about this, so apologies. You can also possibly use the "tree" utility to better visualize your fs tree, like: tree -A --inodes --noreport /mnt/TEST_ROOT Jan, David, hope it''s ok with you if I''ll try to debug this. Thanks, Alex. On Sat, Aug 25, 2012 at 11:24 AM, Robert Buhren <robert@robertbuhren.de> wrote:> On 24.08.2012 15:33, David Sterba wrote: >> >> On Thu, Aug 23, 2012 at 10:54:54AM +0200, Robert Buhren wrote: >>> >>> I''m on linux-3.6-rc2 and btrfs-progs from git. >> >> Please try it with Chris'' for-linus branch, it contains a fair portion >> of send-related fixes and from brief look they may be related to the >> errors you see. >> >> david > > Hi David, > > i just tried it with a kernel from the "for-linus" branch. But i still get > the same error. > Just to be sure: > You ment this branch: > http://git.kernel.org/?p=linux/kernel/git/mason/linux-btrfs.git;a=shortlog;h=refs/heads/for-linus > > right? > > > Regards, > > Robert > > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Robert Buhren
2012-Aug-27 18:37 UTC
Re: [PATCH] Btrfs-progs: replace find_mount_root from send code
Hi Alex, i''ve made a list of all commands i executed for this test. You can find it here: http://pastebin.com/y8PBgmMZ> Hi Robert, > do you think you can make the "root_snap_send" file of yours available > anywhere (not sure how big it is)?I''m afraid i''ve already delete it :/ sry. But in the pastebin there should be all the commands you need to execute to reproduce my setup.> > Also, I am not sure I understand how you btrfs tree looks like WRT to > where all subvolumes are mounted (but all others seem to understand > well). > > You mentioned: >> /dev/loop0 on /mnt/TEST_ROOT type btrfs (rw,relatime,compress=lzo,space_cache) # default-subvolume >> /dev/loop0 on /mnt/TEST_ROOT/root_volid0 type btrfs (rw,relatime,compress=lzo,space_cache) # subvolid= 0 >> /dev/loop1 on /mnt/TEST_ROOT/backup_volid0 type btrfs (rw,relatime,compress=lzo,space_cache) >> btrfs subvolume snapshot -r /mnt/TEST_ROOT/root_volid0/root/ /mnt/TEST_ROOT/root_volid0/root_snap > Are you trying to snapshot a directory here? I.e., what is "root" > within "root_volid0"?root is a subvolume inside the /dev/loop0 fs. It is set as the default subvolume. I mounted /dev/loop0 at /mnt/TEST_ROOT and inside that i mounted /dev/loop0 again, but this time with subvolid=0. So "/mnt/TEST_ROOT/root_volid0/root" is actually a subvolume which is also mounted at "/mnt/TEST_ROOT".> Can you pls list all subvolumes you have on your source filesystem > (the one you are trying to backup), and where each one is mounted? > Again, looks like I''m the only one confused about this, so apologies. > > You can also possibly use the "tree" utility to better visualize your > fs tree, like: > tree -A --inodes --noreport /mnt/TEST_ROOT > > Jan, David, hope it''s ok with you if I''ll try to debug this. > > Thanks, > Alex. >I''m kinda in a hurry now because i''m leaving for Holidays soon and i still have to finish my bachelor thesis :P I hope with the the commands from the pastebin you have everything you need. I can answer emails until Friday morning. Regards, Robert> > > > > On Sat, Aug 25, 2012 at 11:24 AM, Robert Buhren <robert@robertbuhren.de> wrote: >> On 24.08.2012 15:33, David Sterba wrote: >>> On Thu, Aug 23, 2012 at 10:54:54AM +0200, Robert Buhren wrote: >>>> I''m on linux-3.6-rc2 and btrfs-progs from git. >>> Please try it with Chris'' for-linus branch, it contains a fair portion >>> of send-related fixes and from brief look they may be related to the >>> errors you see. >>> >>> david >> Hi David, >> >> i just tried it with a kernel from the "for-linus" branch. But i still get >> the same error. >> Just to be sure: >> You ment this branch: >> http://git.kernel.org/?p=linux/kernel/git/mason/linux-btrfs.git;a=shortlog;h=refs/heads/for-linus >> >> right? >> >> >> Regards, >> >> Robert >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Alex Lyakas
2012-Aug-28 08:27 UTC
Re: [PATCH] Btrfs-progs: replace find_mount_root from send code
Thank you, Robert for the detailed data. I will debug & get back to you before Friday. Alex. On Mon, Aug 27, 2012 at 9:37 PM, Robert Buhren <robert@robertbuhren.de> wrote:> Hi Alex, > > i''ve made a list of all commands i executed for this test. You can find it > here: > > http://pastebin.com/y8PBgmMZ > > > >> Hi Robert, >> do you think you can make the "root_snap_send" file of yours available >> anywhere (not sure how big it is)? > > I''m afraid i''ve already delete it :/ sry. But in the pastebin there should > be all the commands > you need to execute to reproduce my setup. > >> >> Also, I am not sure I understand how you btrfs tree looks like WRT to >> where all subvolumes are mounted (but all others seem to understand >> well). >> >> You mentioned: >>> >>> /dev/loop0 on /mnt/TEST_ROOT type btrfs >>> (rw,relatime,compress=lzo,space_cache) # default-subvolume >>> /dev/loop0 on /mnt/TEST_ROOT/root_volid0 type btrfs >>> (rw,relatime,compress=lzo,space_cache) # subvolid= 0 >>> /dev/loop1 on /mnt/TEST_ROOT/backup_volid0 type btrfs >>> (rw,relatime,compress=lzo,space_cache) >>> btrfs subvolume snapshot -r /mnt/TEST_ROOT/root_volid0/root/ >>> /mnt/TEST_ROOT/root_volid0/root_snap >> >> Are you trying to snapshot a directory here? I.e., what is "root" >> within "root_volid0"? > > root is a subvolume inside the /dev/loop0 fs. It is set as the default > subvolume. > I mounted /dev/loop0 at /mnt/TEST_ROOT and inside that i mounted /dev/loop0 > again, > but this time with subvolid=0. So "/mnt/TEST_ROOT/root_volid0/root" is > actually a subvolume > which is also mounted at "/mnt/TEST_ROOT". > >> Can you pls list all subvolumes you have on your source filesystem >> (the one you are trying to backup), and where each one is mounted? >> Again, looks like I''m the only one confused about this, so apologies. >> >> You can also possibly use the "tree" utility to better visualize your >> fs tree, like: >> tree -A --inodes --noreport /mnt/TEST_ROOT >> >> Jan, David, hope it''s ok with you if I''ll try to debug this. >> >> Thanks, >> Alex. >> > I''m kinda in a hurry now because i''m leaving for Holidays soon and i still > have to finish my bachelor thesis :P > > I hope with the the commands from the pastebin you have everything you need. > I can answer emails until Friday morning. > > Regards, > > Robert > > > >> >> >> >> >> On Sat, Aug 25, 2012 at 11:24 AM, Robert Buhren <robert@robertbuhren.de> >> wrote: >>> >>> On 24.08.2012 15:33, David Sterba wrote: >>>> >>>> On Thu, Aug 23, 2012 at 10:54:54AM +0200, Robert Buhren wrote: >>>>> >>>>> I''m on linux-3.6-rc2 and btrfs-progs from git. >>>> >>>> Please try it with Chris'' for-linus branch, it contains a fair portion >>>> of send-related fixes and from brief look they may be related to the >>>> errors you see. >>>> >>>> david >>> >>> Hi David, >>> >>> i just tried it with a kernel from the "for-linus" branch. But i still >>> get >>> the same error. >>> Just to be sure: >>> You ment this branch: >>> >>> http://git.kernel.org/?p=linux/kernel/git/mason/linux-btrfs.git;a=shortlog;h=refs/heads/for-linus >>> >>> right? >>> >>> >>> Regards, >>> >>> Robert >>> >>> -- >>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in >>> the body of a message to majordomo@vger.kernel.org >>> More majordomo info at http://vger.kernel.org/majordomo-info.html > >-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Alex Lyakas
2012-Aug-28 17:26 UTC
Re: [PATCH] Btrfs-progs: replace find_mount_root from send code
Hi Robert, can you pls apply this patch. It should solve the issue (your script now runs ok for me). Alex. diff --git a/cmds-receive.c b/cmds-receive.c index a8be6fa..3ee2ff8 100644 --- a/cmds-receive.c +++ b/cmds-receive.c @@ -792,11 +792,18 @@ int do_receive(struct btrfs_receive *r, const char *tomnt, int r_fd) int ret; int end = 0; - r->root_path = strdup(tomnt); - r->mnt_fd = open(tomnt, O_RDONLY | O_NOATIME); + r->root_path = realpath(tomnt, NULL); + if (!r->root_path) { + ret = -errno; + fprintf(stderr, "ERROR: realpath %s failed. " + "%s\n", tomnt, strerror(-ret)); + goto out; + } + + r->mnt_fd = open(r->root_path, O_RDONLY | O_NOATIME); if (r->mnt_fd < 0) { ret = -errno; - fprintf(stderr, "ERROR: failed to open %s. %s\n", tomnt, + fprintf(stderr, "ERROR: failed to open %s. %s\n", r->root_path, strerror(-ret)); goto out; } On Tue, Aug 28, 2012 at 11:27 AM, Alex Lyakas <alex.bolshoy.btrfs@gmail.com> wrote:> Thank you, Robert for the detailed data. I will debug & get back to > you before Friday. > > Alex. > > > On Mon, Aug 27, 2012 at 9:37 PM, Robert Buhren <robert@robertbuhren.de> wrote: >> Hi Alex, >> >> i''ve made a list of all commands i executed for this test. You can find it >> here: >> >> http://pastebin.com/y8PBgmMZ >> >> >> >>> Hi Robert, >>> do you think you can make the "root_snap_send" file of yours available >>> anywhere (not sure how big it is)? >> >> I''m afraid i''ve already delete it :/ sry. But in the pastebin there should >> be all the commands >> you need to execute to reproduce my setup. >> >>> >>> Also, I am not sure I understand how you btrfs tree looks like WRT to >>> where all subvolumes are mounted (but all others seem to understand >>> well). >>> >>> You mentioned: >>>> >>>> /dev/loop0 on /mnt/TEST_ROOT type btrfs >>>> (rw,relatime,compress=lzo,space_cache) # default-subvolume >>>> /dev/loop0 on /mnt/TEST_ROOT/root_volid0 type btrfs >>>> (rw,relatime,compress=lzo,space_cache) # subvolid= 0 >>>> /dev/loop1 on /mnt/TEST_ROOT/backup_volid0 type btrfs >>>> (rw,relatime,compress=lzo,space_cache) >>>> btrfs subvolume snapshot -r /mnt/TEST_ROOT/root_volid0/root/ >>>> /mnt/TEST_ROOT/root_volid0/root_snap >>> >>> Are you trying to snapshot a directory here? I.e., what is "root" >>> within "root_volid0"? >> >> root is a subvolume inside the /dev/loop0 fs. It is set as the default >> subvolume. >> I mounted /dev/loop0 at /mnt/TEST_ROOT and inside that i mounted /dev/loop0 >> again, >> but this time with subvolid=0. So "/mnt/TEST_ROOT/root_volid0/root" is >> actually a subvolume >> which is also mounted at "/mnt/TEST_ROOT". >> >>> Can you pls list all subvolumes you have on your source filesystem >>> (the one you are trying to backup), and where each one is mounted? >>> Again, looks like I''m the only one confused about this, so apologies. >>> >>> You can also possibly use the "tree" utility to better visualize your >>> fs tree, like: >>> tree -A --inodes --noreport /mnt/TEST_ROOT >>> >>> Jan, David, hope it''s ok with you if I''ll try to debug this. >>> >>> Thanks, >>> Alex. >>> >> I''m kinda in a hurry now because i''m leaving for Holidays soon and i still >> have to finish my bachelor thesis :P >> >> I hope with the the commands from the pastebin you have everything you need. >> I can answer emails until Friday morning. >> >> Regards, >> >> Robert >> >> >> >>> >>> >>> >>> >>> On Sat, Aug 25, 2012 at 11:24 AM, Robert Buhren <robert@robertbuhren.de> >>> wrote: >>>> >>>> On 24.08.2012 15:33, David Sterba wrote: >>>>> >>>>> On Thu, Aug 23, 2012 at 10:54:54AM +0200, Robert Buhren wrote: >>>>>> >>>>>> I''m on linux-3.6-rc2 and btrfs-progs from git. >>>>> >>>>> Please try it with Chris'' for-linus branch, it contains a fair portion >>>>> of send-related fixes and from brief look they may be related to the >>>>> errors you see. >>>>> >>>>> david >>>> >>>> Hi David, >>>> >>>> i just tried it with a kernel from the "for-linus" branch. But i still >>>> get >>>> the same error. >>>> Just to be sure: >>>> You ment this branch: >>>> >>>> http://git.kernel.org/?p=linux/kernel/git/mason/linux-btrfs.git;a=shortlog;h=refs/heads/for-linus >>>> >>>> right? >>>> >>>> >>>> Regards, >>>> >>>> Robert >>>> >>>> -- >>>> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in >>>> the body of a message to majordomo@vger.kernel.org >>>> More majordomo info at http://vger.kernel.org/majordomo-info.html >> >>-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
David Sterba
2012-Sep-24 17:18 UTC
Re: [PATCH] Btrfs-progs: replace find_mount_root from send code
Hi Alex, On Tue, Aug 28, 2012 at 08:26:22PM +0300, Alex Lyakas wrote:> can you pls apply this patch. It should solve the issue (your script > now runs ok for me).have you considered sending this patch separately? thanks, david -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Alex Lyakas
2012-Oct-03 13:01 UTC
Re: [PATCH] Btrfs-progs: replace find_mount_root from send code
Hi Jan,> + mnttab = fopen("/etc/mtab", "r");Isn''t it better to use "/proc/mounts" here? Otherwise, if the FS was mounted using "mount" syscall, then this code will fail to find the correct mount root.> + while ((ent = getmntent(mnttab))) { > + len = strlen(ent->mnt_dir); > + if (strncmp(ent->mnt_dir, path, len) == 0) { > + /* match found */ > + if (longest_matchlen < len) { > + free(longest_match); > + longest_matchlen = len; > + longest_match = strdup(ent->mnt_dir);Alex. -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html