This is a note to let you know that I've just added the patch titled Btrfs: send, account for orphan directories when building path strings to the 3.15-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: btrfs-send-account-for-orphan-directories-when-building-path-strings.patch and it can be found in the queue-3.15 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From c992ec94f24c3e7135d6c23860615f269f0b1d87 Mon Sep 17 00:00:00 2001 From: Filipe Manana <fdmanana@xxxxxxxxx> Date: Sat, 22 Mar 2014 17:15:24 +0000 Subject: Btrfs: send, account for orphan directories when building path strings From: Filipe Manana <fdmanana@xxxxxxxxx> commit c992ec94f24c3e7135d6c23860615f269f0b1d87 upstream. If we have directories with a pending move/rename operation, we must take into account any orphan directories that got created before executing the pending move/rename. Those orphan directories are directories with an inode number higher then the current send progress and that don't exist in the parent snapshot, they are created before current progress reaches their inode number, with a generated name of the form oN-M-I and at the root of the filesystem tree, and later when progress matches their inode number, moved/renamed to their final location. Reproducer: $ mkfs.btrfs -f /dev/sdd $ mount /dev/sdd /mnt $ mkdir -p /mnt/a/b/c/d $ mkdir /mnt/a/b/e $ mv /mnt/a/b/c /mnt/a/b/e/CC $ mkdir /mnt/a/b/e/CC/d/f $ mkdir /mnt/a/g $ btrfs subvolume snapshot -r /mnt /mnt/snap1 $ btrfs send /mnt/snap1 -f /tmp/base.send $ mkdir /mnt/a/g/h $ mv /mnt/a/b/e /mnt/a/g/h/EE $ mv /mnt/a/g/h/EE/CC/d /mnt/a/g/h/EE/DD $ btrfs subvolume snapshot -r /mnt /mnt/snap2 $ btrfs send -p /mnt/snap1 /mnt/snap2 -f /tmp/incremental.send The second receive command failed with the following error: ERROR: rename a/b/e/CC/d -> o264-7-0/EE/DD failed. No such file or directory A test case for xfstests follows soon. Signed-off-by: Filipe David Borba Manana <fdmanana@xxxxxxxxx> Signed-off-by: Chris Mason <clm@xxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- fs/btrfs/send.c | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -3054,33 +3054,18 @@ static int apply_dir_move(struct send_ct if (ret < 0) goto out; - if (parent_ino == sctx->cur_ino) { - /* child only renamed, not moved */ - ASSERT(parent_gen == sctx->cur_inode_gen); - ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, - from_path); - if (ret < 0) - goto out; - ret = fs_path_add_path(from_path, name); - if (ret < 0) - goto out; - } else { - /* child moved and maybe renamed too */ - sctx->send_progress = pm->ino; - ret = get_cur_path(sctx, pm->ino, pm->gen, from_path); - if (ret < 0) - goto out; - } + ret = get_cur_path(sctx, parent_ino, parent_gen, + from_path); + if (ret < 0) + goto out; + ret = fs_path_add_path(from_path, name); + if (ret < 0) + goto out; - fs_path_free(name); + fs_path_reset(name); + to_path = name; name = NULL; - to_path = fs_path_alloc(); - if (!to_path) { - ret = -ENOMEM; - goto out; - } - sctx->send_progress = sctx->cur_ino + 1; ret = get_cur_path(sctx, pm->ino, pm->gen, to_path); if (ret < 0) Patches currently in stable-queue which might be from fdmanana@xxxxxxxxx are queue-3.15/btrfs-send-use-the-right-limits-for-xattr-names-and-values.patch queue-3.15/btrfs-read-inode-size-after-acquiring-the-mutex-when-punching-a-hole.patch queue-3.15/btrfs-send-account-for-orphan-directories-when-building-path-strings.patch queue-3.15/btrfs-fix-leaf-corruption-caused-by-enospc-while-hole-punching.patch queue-3.15/btrfs-send-don-t-error-in-the-presence-of-subvols-snapshots.patch -- To unsubscribe from this list: send the line "unsubscribe stable" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html