btrfs-progs: remove extra uuid-tree.o in objects

This fixes static compile target of btrfs-progs.

Signed-off-by: Emil Karlson <jekarlson@gmail.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
btrfs-progs: mkfs: extend -O syntax to disable features

A way of disabling features that are on by default in case it's not
wanted, eg. due to lack of support in the used kernel.

Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
btrfs-progs: man: add rescue super-recover bits

Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
btrfs-progs: mkfs: enable extended refs by default

The feature has been introduced in kernel 3.7 and enabling it by
default is desired.

All features enabled by default are marked as such in
'mkfs.btrfs -O list-all' output.

Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
btrfs-progs: for mixed group check opt before default raid profile is enforced

This fixes the regression introduced with the patch

    btrfs-progs: avoid write to the disk before sure to create fs

what happened with this patch is it missed the check to see if the
user has the option set before pushing the defaults.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
btrfs filesystem show: skip duplicate fsids

If a given filesystem is mounted more than once, btrfs fi show will
print dups.  This adds a quick and dirty hash table of fsids it
has already printed and makes sure we don't print any fsid more than
once.

Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Add -fno-strict-aliasing

Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Update the version

Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Btrfs-progs: fix btrfsck improper prompt on dropping snapshots

Exec btrfsck on btrfs with snapshots that are under a dropping
progress will cause prompt on "ref mismatch".
However we do not want this kind of prompt, since an remount
operation will continue the dropping progress.
Here the prompt is nonsense.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
btrfs-progs: remove cmds-chunk.c

Commit "btrfs-progs: separate command and implementation of
chunk-recover code" moved contents of this file to chunk-recover.c but
failed to remove the file cmds-chunk.c

Reported-by: Mitch Harder <mitch.harder@sabayonlinux.org>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
btrfs-progs: make filesystem show by label work

with design revamp around filesystem show the fsid filter
by label wasn't planned. but apparently that seemed to be
necessary. this patch will fix it.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Btrfs-progs: allow --init-extent-tree to work when extent tree is borked

Unfortunately you can't run --init-extent-tree if you can't actually read the
extent root.  Fix this by allowing partial starts with no extent root and then
have fsck only check to see if the extent root is uptodate _after_ the check to
see if we are init'ing the extent tree.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Btrfs-progs: don't output baffling message when checking a fresh fs

As we know,  a new fs doesn't have space cache, so we set the cache generation
of the super block to be -1ULL, it is not equal to the fs generation. But the
check program didn't consider this case, and output the following message

  cache and super generation don't match, space cache will be invalidated

directly, it would be baffling the users. So we should avoid outputing such
message. This patch fixes this problem.

Signed-off-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
btrfs-progs: fix loop device mount checks

When creating a fs on a loop device, mkfs checks whether the same file
is not already mounted, but a backing file of another loop dev does not
exist, mkfs fails. This fixes a bug during openSUSE installation.

Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
btrfs-progs: use /proc/self/mounts

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
btrfs-progs: make it static if function isn't called outside

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Btrfs-progs: try harder to make btrfs receive successfully

Steps to reproduce:
	# mkfs.btrfs -f <dev>
	# mount <dev> <mnt>
	# mkdir <mnt>/backup
	# btrfs sub create <mnt>/subv
	# btrfs sub snapshot -r <mnt>/subv <mnt>/snap1
	# btrfs sub snapshot -r <mnt>/subv <mnt>/snap2
	# btrfs send <mnt>/snap2 -p <mnt>/snap1 -f sent_file
	# btrfs receive -f sent_file <mnt>/backup

Above steps will make btrfs receive fails with "ERROR: can not find
parent subvolume", this is because we try to find parent subvolume by
RECEIVED_SUBVOL_KEY,and it will return ENOENT if parent snapshot has not
been sent or it has been deleted. Actually, we can try harder to find
whether parent subvolume exists by searching uuid key.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Reviewed-by: Stefan Behrens <sbehrens@giantdisaster.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Btrfs-progs: let get_label return the label instead of printing it

get_label prints the label at the moment. Change this so that
the label is returned and printing is done by the caller.

Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
btrfs-progs: define BTRFS_UUID_UNPARSE_SIZE for uuid unparse buf size

we use 37 as the allocation size to hold the uuid_unparse, here
it defines BTRFS_UUID_UNPARSE_SIZE for the same.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
btrfs-progs: Make btrfs_header_chunk_tree_uuid() return unsigned long

Internally, btrfs_header_chunk_tree_uuid() calculates an unsigned
long, but casts it to a pointer, while all callers cast it to unsigned
long again.

From btrfs commit b308bc2f05a86e728bd035e21a4974acd05f4d1e

Signed-off-by: Ross Kirk <ross.kirk@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>