Btrfs: more send support for parent/child dir relationship inversion
authorFilipe David Borba Manana <fdmanana@gmail.com>
Sat, 1 Feb 2014 02:02:16 +0000 (02:02 +0000)
committerJosef Bacik <jbacik@fb.com>
Mon, 10 Mar 2014 19:15:43 +0000 (15:15 -0400)
The commit titled "Btrfs: fix infinite path build loops in incremental send"
didn't cover a particular case where the parent-child relationship inversion
of directories doesn't imply a rename of the new parent directory. This was
due to a simple logic mistake, a logical and instead of a logical or.

Steps to reproduce:

  $ mkfs.btrfs -f /dev/sdb3
  $ mount /dev/sdb3 /mnt/btrfs
  $ mkdir -p /mnt/btrfs/a/b/bar1/bar2/bar3/bar4
  $ btrfs subvol snapshot -r /mnt/btrfs /mnt/btrfs/snap1
  $ mv /mnt/btrfs/a/b/bar1/bar2/bar3/bar4 /mnt/btrfs/a/b/k44
  $ mv /mnt/btrfs/a/b/bar1/bar2/bar3 /mnt/btrfs/a/b/k44
  $ mv /mnt/btrfs/a/b/bar1/bar2 /mnt/btrfs/a/b/k44/bar3
  $ mv /mnt/btrfs/a/b/bar1 /mnt/btrfs/a/b/k44/bar3/bar2/k11
  $ btrfs subvol snapshot -r /mnt/btrfs /mnt/btrfs/snap2
  $ btrfs send -p /mnt/btrfs/snap1 /mnt/btrfs/snap2 > /tmp/incremental.send

A patch to update the test btrfs/030 from xfstests, so that it covers
this case, will be submitted soon.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
fs/btrfs/send.c

index 8bd0505ee2f9a9c316b2b5c9a6bf09ed1be65cda..154a717d2a3cbc719b6436b169171f84b6d1fdbb 100644 (file)
@@ -3053,8 +3053,8 @@ static int wait_for_parent_move(struct send_ctx *sctx,
 
        len1 = fs_path_len(path_before);
        len2 = fs_path_len(path_after);
-       if ((parent_ino_before != parent_ino_after) && (len1 != len2 ||
-            memcmp(path_before->start, path_after->start, len1))) {
+       if (parent_ino_before != parent_ino_after || len1 != len2 ||
+            memcmp(path_before->start, path_after->start, len1)) {
                ret = 1;
                goto out;
        }