Btrfs-progs: add shift_items to btrfs-corrupt-block

A user had a corrupted fs where his items where shifted oddly.  This adds the
functionality I needed to btrfs-corrupt-block in order to reproduce this
corruption in order to make fsck fix this sort of problem.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Btrfs-progs: make free space cache less noisy

Fsck only cares if the cache is really broken, so don't be noisy if the
generations don't match or other such errors.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Btrfs-progs: rebuild the crc tree with --init-csum-tree

We have --init-csum-tree, which just empties the csum tree.  I'm not sure why we
would ever need this, but we definitely need to be able to rebuild the csum tree
in some cases.  This patch adds the ability to completely rebuild the crc tree
by reading all of the data and adding csum entries for them.  This patch doesn't
pay attention to NODATASUM inodes, it'll happily add csums for everything.
Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Btrfs-progs: add the ability to fix shifted item offsets

A user had a corrupted fs where the items had been shifted improperly.  This
patch adds the ability to fix this sort of problem within fsck.  We will simply
shift the item over to the proper offset and update the offsets to make sure
they are correct.  I tested this with a hand crafted fs that was broken in the
same way as the user, and I've included the file as a new test.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Btrfs-progs: add the ability to delete items

Somtetimes you just need to delete an item, add that functionality to
btrfs-corrupt-block.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Btrfs-progs: repair missing dir index

If we have an inode backref entry then we know enough to add back a missing dir
index.  When messing with the inode backrefs we need to do all of that first
before we process the inode recs themselves as we may clear errors on the inode
recs as we fix the directory indexes.  This adds the framework for fixing
backref errors and fixes missing dir index issues.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Btrfs-progs: check blocks when checking fs roots

Usually if we find a bad block during the extent tree stuff we will error out,
but if the bad block is in an fs tree and doens't have extents in it then fsck
may still pass even though the block was complete garbage.  So add the check
block logic to the fs root checking so we actually error out of fsck if there is
a bad block.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Btrfs-progs: corrupt btrfs items in btrfs-corrup-block

For testing fsck against completely broken btrfs_items.

Signed-off-by: Josef Bacik <jbacik@fb.com>
Btrfs-progs: make fsck deal with bogus items

We can deal with corrupt items by deleting them in a few cases.  Fsck can easily
recover from a missing extent item or a dir index item.  So if we notice a item
is completely bogus and it is of a key that we know we can repair then just
delete it and carry on.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Btrfs-progs: skip extent rebuild test if no testdev

It is highly obnoxious to have to go put in a testdev when all you really want
is to run the quick image tests.  Make this part optional so if we don't have a
testdev specified we just don't run that particular test.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>