Commit Graph

1244 Commits (c17d0a73c11d7cdbdf1582408ec6d168876160ea)
 

Author SHA1 Message Date
Gui Hecheng d9d9704510 btrfs-progs: fix improper error prompt for defragment
The error msg:
	"ERROR: defrag range ioctl not supported in this kernel,
	 please try without any options."
should only show up when failing to do a range defraging,
not upon non-range defraging.

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>
2014-01-31 08:22:13 -08:00
David Sterba d47b4e4dd2 btrfs-progs: convert remaining uuid buffer declarations to BTRFS_UUID_UNPARSED_SIZE
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:13 -08:00
David Sterba b085b145b6 btrfs-progs: add fsck.btrfs stub and manpage
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:13 -08:00
Gui Hecheng f1d08d2253 btrfs-progs: fix a manpage item for btrfstune
btrfstune operates on umounted devices <device>,
not mount points <mnt>. fix it.

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>
2014-01-31 08:22:13 -08:00
David Sterba 2b3b68a2f0 btrfs-progs: send: check if parent or clone sources are read-only
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:13 -08:00
Wang Shilong 8d68cb2bad Btrfs-progs: avoid using btrfs internal subvolume path to send
Steps to reproduce:
	# mkfs.btrfs -f /dev/sda
	# mount /dev/sda /mnt
	# btrfs subvolume create /mnt/foo
	# umount /mnt
	# mount -o subvol=foo /dev/sda /mnt
	# btrfs sub snapshot -r /mnt /mnt/snap
	# btrfs send /mnt/snap > /dev/null

We will fail to send '/mnt/snap',this is because btrfs send try to
open '/mnt/snap' by btrfs internal subvolume path 'foo/snap' rather
than relative path based on mounted point, this will return us 'no
such file or directory',this is not right, fix it.

Reported-by: Thomas Scheiblauer <tom@sharkbay.at>
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:12 -08:00
Anand Jain f053be8082 btrfs-progs: qgroup destroy says create failed
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>
2014-01-31 08:22:12 -08:00
Wang Shilong 1878717b75 Btrfs-progs: fix segfault when getting scrub status
I sometimes get segfault in cmd_scrub_status(), this is because
free_history() forgot to check whether pointer address is valid,fix it.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:12 -08:00
Wang Shilong f8675eb30f Btrfs-progs: add option to skip whether a scrub has started/resumed in userspace
I hit a problem that i can not start scrub when i am trying to track
superblock generation mismatch problems.

The fact is that we are trying to check whether we have started a scrub operation
in userspace, this will make us can't start scrub if that record file is damaged
itself. By adding a option to skip that check, everything will be fine.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:11 -08:00
Anand Jain b94a3003ae btrfs-progs: fix backref after init-csum-tree
btrfsck reports backref error after running init-csum-tree

btrfsck --init-csum-tree /dev/sdc
btrfsck /dev/sdc
::
ref mismatch on [29474816 16384] extent item 1, found 0
Backref 29474816 root 7 not referenced back 0x1101d30
Incorrect global backref count on 29474816 found 1 wanted 0
backpointer mismatch on [29474816 16384]
owner ref check failed [29474816 16384]
Errors found in extent allocation tree or chunk allocation
::

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>
2014-01-31 08:22:10 -08:00
Anand Jain 4956a16711 btrfs-progs: Turning ON incompat isn't an error
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>
2014-01-31 08:22:10 -08:00
Gui Hecheng 9df48a7d01 btrfs-progs: scan devices in parallel for chunk-recover
Originally, multi devices are scanned one by one;
Now, one thread is used per device to scan.

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>
2014-01-31 08:22:09 -08:00
Gui Hecheng 4989dc82d1 btrfs-progs: add chunk-recover raid0/5/6 data stripes rebuild routine
Decide the raid0/5/6 data stripes' order using checksums.
For one chunk, fetch each 64k logical stripe
	1. search its checksum in the csum tree
	2. read the physical stripe data on each device
	3. calc the data checksums
	4. if one checksum matches the value from the csum tree,
	   then the logical stripe resides in that device,
	   the stripe order index can be calculated.
	5. if more than one checksums match,
	   then use the successive csum in the tree to compare again.
	6. if equal stripes are encountered, just fetch next stripe.
	7. if some devices' order are still not decided, then they
	   can not be recovered.

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>
2014-01-31 08:22:09 -08:00
Gui Hecheng 7af8e4ee2a btrfs-progs: skip chunk recover works when check chunks successfully
If no chunks need to be recovered, skip the recover works,
meanwhile the user won't be annoyed by the "ask_user".

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>
2014-01-31 08:22:08 -08:00
Wang Shilong 52ddfa74fe Btrfs-progs: chunk-recover: add new flag to prepare recovering for ordered data chunk
When reading block groups we will searching it's corresponding chunk, however, at this
time, some chunks has not been built(data chunks raid0/raid10/raid56), don't bug_on here,
we will try to rebuild these chunks later.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:07 -08:00
David Sterba 387d5f3234 btrfs-progs: use mntent functions in find_mount_root
getmntent should be used in context of *mntent functions, though
fopen/fclose works.

Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:07 -08:00
David Sterba 37cd29521a btrfs-progs: call endmntent in btrfs_scan_kernel
btrfs_scan_kernel() does a getmntent() but never releases the
filedescriptor it gets back from that.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=64711

Reported-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:07 -08:00
Liu Bo 53ee1bccf9 Btrfs-progs: fix the mismatch of extent buffer's space
Now we set @refs to 2 on creating a new extent buffer, meanwhile we
allocate the needed free space, but we don't give enough free_extent_buffer()
to reduce the eb's references to zero so that the eb can finally be freed,
so the problem is we has decrease the referene count of backrefs to zero, which
ends up releasing the space occupied by the eb, and this space can be allocated
again for something else(another eb or disk), usually a crash(core dump) will
occur, I've hit a crash in rb_insert() because another eb re-use the space while
the original one is floating around.

We should do the same thing as the kernel code does, it's necessary to initialize
@refs to 1 instead of 2, this helps us get rid of the above problem.

Signed-off-by: Liu Bo <bo.li.liu@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:06 -08:00
Wang Shilong e5f72de944 Btrfs-progs: chunk-recover: use right size when allocating chunk root node
When allocating chunk root node, we should use nodesize rather than sectorsize,
this will casue regression when making other nodesize choice.(for example 16k size now)

Reported-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
2014-01-31 08:22:06 -08:00
Ross Kirk 7ff512ce38 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>
2014-01-31 08:22:04 -08:00
Anand Jain 1ecefced86 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>
2014-01-31 08:22:03 -08:00
Filipe David Borba Manana 457b1286dd 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>
2014-01-31 08:22:02 -08:00
Wang Shilong 67d3c3c0d3 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>
2014-01-31 08:22:02 -08:00
Anand Jain 72f1835ae4 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>
2014-01-31 08:22:01 -08:00
Anand Jain 90cad5f9e6 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>
2014-01-31 08:22:01 -08:00
David Sterba d06b30feb9 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>
2014-01-31 08:22:00 -08:00
Miao Xie b4f4473e8a 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>
2014-01-31 08:21:59 -08:00
Josef Bacik 1f5e3b2825 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>
2014-01-31 08:21:58 -08:00
Anand Jain a156b967ed 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>
2014-01-31 08:21:58 -08:00
David Sterba f1332a2ebc 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>
2014-01-31 08:21:57 -08:00
Gui Hecheng 1cf9af2294 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>
2014-01-31 08:21:56 -08:00
Chris Mason 8cae1840af Update the version
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-25 15:48:57 -05:00
Chris Mason 8116550e16 Add -fno-strict-aliasing
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-22 08:41:50 -05:00
Chris Mason 5aff090a39 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>
2013-11-18 14:27:21 -05:00
Anand Jain e9ac73b441 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>
2013-11-15 12:30:13 -05:00
David Sterba 9f0c53f574 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>
2013-11-14 12:21:17 -05:00
David Sterba e89c31e5ec 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>
2013-11-14 12:21:17 -05:00
David Sterba 492fc44828 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>
2013-11-14 12:21:17 -05:00
Emil Karlson e11a9ae9bd 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>
2013-11-11 16:05:06 -05:00
Chris Mason c652e4efb8 mkfs: change default metadata blocksize to 16KB
16KB is faster and leads to less metadata fragmentation in almost all
workloads.  It does slightly increase lock contention on the root nodes
in some workloads, but that is best dealt with by adding more subvolumes
(for now).

This uses 16KB or the page size, whichever is bigger.  If you're doing a
mixed block group mkfs, it uses the sectorsize instead.

Since the kernel refuses to mount a mixed block group FS where the
metadata leaf size doesn't match the data sectorsize, this also adds a
similar check during mkfs.

Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-08 13:51:52 -05:00
Eric Sandeen 06ceeb209e btrfs-progs: annotate fallthroughs in parse_limit
We intentionally fall through these case statements;
just annotate it to be clear.

Resolves-Coverity-CID: 1054884
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-07 16:10:41 -05:00
Eric Sandeen 7bee7b2f2a btrfs-progs: annotate fallthroughs in parse_size
We intentionally fall through these case statements;
just annotate it to be clear.

Resolves-Coverity-CID: 1054887
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-07 16:10:41 -05:00
Eric Sandeen b68477aee1 btrfs-progs: check for fstat failure in cmd_defrag
Resolves-Coverity-CID: 1125924
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-07 16:10:41 -05:00
Eric Sandeen e11712a146 btrfs-progs: check btrfs_scan_one_device in btrfs_scan_lblkid()
Even if it's "definitely" btrfs at this point,
btrfs_scan_one_device could fail for other reasons.

Check the return value, warn if it fails, and skip
the device register.

Resolves-Coverity-CID: 1125925
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-07 16:10:41 -05:00
Eric Sandeen 18800f4a31 btrfs-progs: remove more dead code from check_extent_refs
e0a04278 removed a bunch of dead code but left one little
bit; reinit is always 0, so btrfs_read_block_groups is
never called from here.

Resolves-Coverity-CID: 1125926
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-07 16:10:41 -05:00
Eric Sandeen 7e29db9e49 btrfs-progs: pass positive errno to strerror in cmd_df()
get_df returns a negative error number, but then
we pass it to strerror, which wants a positive value...

Resolves-Coverity-CID: 1125929
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-07 16:10:41 -05:00
Eric Sandeen 53e56831b0 btrfs-progs: Check for open failure in btrfs_scan_lblkid()
open can fail, of course.

Resolves-Coverity-CID: 1125925
Resolves-Coverity-CID: 1125930
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-07 16:10:41 -05:00
Eric Sandeen 09aa5d3601 btrfs-progs: btrfs_scan_kernel(): fd==0 is not an error
The error return from open is -1, so test that, not 0,
for success/failure.

Resolves-Coverity-CID: 1125931
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-07 16:10:41 -05:00
Eric Sandeen 249b93b5ef btrfs-progs: don't leak buffer on add_file_items() error
add_file_items() leaked "buffer" on this error return.
Free it first.

Resolves-Coverity-CID: 1125937
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-07 16:10:41 -05:00
Eric Sandeen 0650c12576 btrfs-progs: fix leak of "buf" in make_btrfs() error paths
If any pwrite failed we leaked the allocated "buf" on
return from the function.  "goto out" takes care of
those paths.

Resolves-Coverity-CID: 1125938
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-11-07 16:10:41 -05:00