kernel-hacking-2024-linux-s.../fs/btrfs
Josef Bacik ba5e8f2e2d Btrfs: fix send issues related to inode number reuse
If you are sending a snapshot and specifying a parent snapshot we will walk the
trees and figure out where they differ and send the differences only.  The way
we check for differences are if the leaves aren't the same and if the keys are
not the same within the leaves.  So if neither leaf is the same (ie the leaf has
been cow'ed from the parent snapshot) we walk each item in the send root and
check it against the parent root.  If the items match exactly then we don't do
anything.  This doesn't quite work for inode refs, since they will just have the
name and the parent objectid.  If you move the file from a directory and then
remove that directory and re-create a directory with the same inode number as
the old directory and then move that file back into that directory we will
assume that nothing changed and you will get errors when you try to receive.

In order to fix this we need to do extra checking to see if the inode ref really
is the same or not.  So do this by passing down BTRFS_COMPARE_TREE_SAME if the
items match.  Then if the key type is an inode ref we can do some extra
checking, otherwise we just keep processing.  The extra checking is to look up
the generation of the directory in the parent volume and compare it to the
generation of the send volume.  If they match then they are the same directory
and we are good to go.  If they don't we have to add them to the changed refs
list.

This means we have to track the generation of the ref we're trying to lookup
when we iterate all the refs for a particular inode.  So in the case of looking
for new refs we have to get the generation from the parent volume, and in the
case of looking for deleted refs we have to get the generation from the send
volume to compare with.

There was also the issue of using a ulist to keep track of the directories we
needed to check.  Because we can get a deleted ref and a new ref for the same
inode number the ulist won't work since it indexes based on the value.  So
instead just dup any directory ref we find and add it to a local list, and then
process that list as normal and do away with using a ulist for this altogether.

Before we would fail all of the tests in the far-progs that related to moving
directories (test group 32).  With this patch we now pass these tests, and all
of the tests in the far-progs send testing suite.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-09-01 08:15:44 -04:00
..
tests Btrfs: separate out tests into their own directory 2013-09-01 08:15:38 -04:00
acl.c
async-thread.c
async-thread.h
backref.c Btrfs: fix possible memory leak in find_parent_nodes() 2013-09-01 08:04:56 -04:00
backref.h Btrfs: cleanup backref search commit root flag stuff 2013-07-01 08:52:29 -04:00
btrfs_inode.h Btrfs: don't cache the csum value into the extent state tree 2013-09-01 08:04:33 -04:00
check-integrity.c btrfs: Cleanup for using BTRFS_SETGET_STACK instead of raw convert 2013-09-01 07:57:37 -04:00
check-integrity.h
compat.h
compression.c btrfs: Introduce extent_read_full_page_nolock() 2013-09-01 08:04:59 -04:00
compression.h
ctree.c Btrfs: fix send issues related to inode number reuse 2013-09-01 08:15:44 -04:00
ctree.h Btrfs: fix send issues related to inode number reuse 2013-09-01 08:15:44 -04:00
delayed-inode.c btrfs: Cleanup for using BTRFS_SETGET_STACK instead of raw convert 2013-09-01 07:57:37 -04:00
delayed-inode.h [readdir] convert btrfs 2013-06-29 12:57:00 +04:00
delayed-ref.c Btrfs/tracepoint: update delayed ref tracepoints 2013-09-01 07:57:39 -04:00
delayed-ref.h
dev-replace.c Btrfs: introduce per-subvolume ordered extent list 2013-06-14 11:29:41 -04:00
dev-replace.h
dir-item.c
disk-io.c Btrfs: fix heavy delalloc related deadlock 2013-09-01 08:05:04 -04:00
disk-io.h Btrfs: introduce grab/put functions for the root of the fs/file tree 2013-06-14 11:29:38 -04:00
export.c Btrfs: cleanup: don't check the same thing twice 2013-06-14 11:29:30 -04:00
export.h
extent-tree.c Btrfs: avoid starting a transaction in the write path 2013-09-01 08:05:05 -04:00
extent_io.c btrfs: Introduce extent_read_full_page_nolock() 2013-09-01 08:04:59 -04:00
extent_io.h btrfs: Introduce extent_read_full_page_nolock() 2013-09-01 08:04:59 -04:00
extent_map.c
extent_map.h
file-item.c Btrfs: don't cache the csum value into the extent state tree 2013-09-01 08:04:33 -04:00
file.c Btrfs: avoid starting a transaction in the write path 2013-09-01 08:05:05 -04:00
free-space-cache.c Btrfs: separate out tests into their own directory 2013-09-01 08:15:38 -04:00
free-space-cache.h Btrfs: separate out tests into their own directory 2013-09-01 08:15:38 -04:00
hash.h
inode-item.c
inode-map.c
inode-map.h
inode.c Btrfs: avoid starting a transaction in the write path 2013-09-01 08:05:05 -04:00
ioctl.c Btrfs: don't allow a subvol to be deleted if it is the default subovl 2013-09-01 08:05:02 -04:00
Kconfig
locking.c
locking.h
lzo.c Btrfs: return -1 when lzo compression makes data bigger 2013-09-01 07:57:19 -04:00
Makefile Btrfs: separate out tests into their own directory 2013-09-01 08:15:38 -04:00
math.h
ordered-data.c Btrfs: fix heavy delalloc related deadlock 2013-09-01 08:05:04 -04:00
ordered-data.h Btrfs: remove btrfs_sector_sum structure 2013-07-02 11:50:47 -04:00
orphan.c
print-tree.c Btrfs: Print key type in decimal everywhere 2013-09-01 07:57:40 -04:00
print-tree.h
qgroup.c Btrfs: set qgroup_ulist to be null after calling ulist_free() 2013-09-01 07:57:36 -04:00
raid56.c Btrfs, raid56: fix memory leak when allocating pages for p/q stripes failed 2013-09-01 08:04:27 -04:00
raid56.h
rcu-string.h
reada.c
relocation.c Btrfs: change how we queue blocks for backref checking 2013-09-01 08:04:41 -04:00
root-tree.c btrfs: Cleanup for using BTRFS_SETGET_STACK instead of raw convert 2013-09-01 07:57:37 -04:00
scrub.c btrfs: Cleanup for using BTRFS_SETGET_STACK instead of raw convert 2013-09-01 07:57:37 -04:00
send.c Btrfs: fix send issues related to inode number reuse 2013-09-01 08:15:44 -04:00
send.h
struct-funcs.c
super.c Btrfs: separate out tests into their own directory 2013-09-01 08:15:38 -04:00
sysfs.c
transaction.c Btrfs: don't bug_on when we fail when cleaning up transactions 2013-09-01 08:04:42 -04:00
transaction.h Btrfs: check to see if root_list is empty before adding it to dead roots 2013-08-09 19:30:23 -04:00
tree-defrag.c
tree-log.c Btrfs: don't ignore errors from btrfs_run_delayed_items 2013-09-01 08:04:54 -04:00
tree-log.h
ulist.c Btrfs: fix crash regarding to ulist_add_merge 2013-07-02 11:50:59 -04:00
ulist.h
volumes.c Fix leak in __btrfs_map_block error path 2013-09-01 08:04:45 -04:00
volumes.h Btrfs: don't cache the csum value into the extent state tree 2013-09-01 08:04:33 -04:00
xattr.c
xattr.h
zlib.c