• Filipe Manana's avatar
    Btrfs: fix send issuing outdated paths for utimes, chown and chmod · bf0d1f44
    Filipe Manana authored
    When doing an incremental send, if we had a directory pending a move/rename
    operation and none of its parents, except for the immediate parent, were
    pending a move/rename, after processing the directory's references, we would
    be issuing utimes, chown and chmod intructions against am outdated path - a
    path which matched the one in the parent root.
    
    This change also simplifies a bit the code that deals with building a path
    for a directory which has a move/rename operation delayed.
    
    Steps to reproduce:
    
        $ mkfs.btrfs -f /dev/sdb3
        $ mount /dev/sdb3 /mnt/btrfs
        $ mkdir -p /mnt/btrfs/a/b/c/d/e
        $ mkdir /mnt/btrfs/a/b/c/f
        $ chmod 0777 /mnt/btrfs/a/b/c/d/e
        $ btrfs subvolume snapshot -r /mnt/btrfs /mnt/btrfs/snap1
        $ btrfs send /mnt/btrfs/snap1 -f /tmp/base.send
        $ mv /mnt/btrfs/a/b/c/f /mnt/btrfs/a/b/f2
        $ mv /mnt/btrfs/a/b/c/d/e /mnt/btrfs/a/b/f2/e2
        $ mv /mnt/btrfs/a/b/c /mnt/btrfs/a/b/c2
        $ mv /mnt/btrfs/a/b/c2/d /mnt/btrfs/a/b/c2/d2
        $ chmod 0700 /mnt/btrfs/a/b/f2/e2
        $ btrfs subvolume snapshot -r /mnt/btrfs /mnt/btrfs/snap2
        $ btrfs send -p /mnt/btrfs/snap1 /mnt/btrfs/snap2 -f /tmp/incremental.send
    
        $ umount /mnt/btrfs
        $ mkfs.btrfs -f /dev/sdb3
        $ mount /dev/sdb3 /mnt/btrfs
        $ btrfs receive /mnt/btrfs -f /tmp/base.send
        $ btrfs receive /mnt/btrfs -f /tmp/incremental.send
    
    The second btrfs receive command failed with:
    
        ERROR: chmod a/b/c/d/e failed. No such file or directory
    
    A test case for xfstests follows.
    Signed-off-by: default avatarFilipe David Borba Manana <fdmanana@gmail.com>
    Signed-off-by: default avatarJosef Bacik <jbacik@fb.com>
    bf0d1f44
send.c 131 KB