Gui Hecheng [Thu, 5 Sep 2013 02:38:54 +0000 (10:38 +0800)]
btrfs-progs: free local variable buf upon unsuccessful returns
The variable "buf" passed into find_collision() as parameter "name"
should be freed on unsuccessful returns.
Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:37 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in cmds-scrub.c
There will be four kinds of return value for command "scrub start":
0: scrub dosen't find errors and return success.
1: usage or syntax errors.
3: scrub finds errors and correct all of them.
4: scrub finds errors and some of them are not correctable.
Three kinds of return values for scrub cancel/resume:
0: cancel successfully.
1: usage or syntax errors.
2: cancel a not started or finished scrub.
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:36 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in cmds-replace.c
There are 3 kinds of return values in replace cancel:
0: cancel successfully.
1: usage or syntal errors
2: cancel a not started or finished replacing operations.
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:34 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in random-test.c
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:33 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in dir-test.c
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:32 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in send-test.c
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:31 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in btrfs-zero-log.c
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:30 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in btrfs-imgae.c
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:29 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in cmds-send.c
If btrfs send return failure, we return 1,otherwise 0 will be returned.
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:28 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in cmds-restore.c
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:27 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in cmds-receive.c
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:26 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in cmds-quota.c
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:25 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in cmds-qgroup.c
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:24 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in cmds-inspect.c
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:23 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in cmds-filesystem.c
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:22 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in cmds-device.c
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:20 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in cmds-chunk.c
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:19 +0000 (23:22 +0800)]
Btrfs-progs: fix magic return value in cmds-subvolume.c
The patch also fixes some coding styles problems.
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 15:22:18 +0000 (23:22 +0800)]
Btrfs-progs: return 1 rather than 129 in usage()
if usage or syntax error happens, we return 1.
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 4 Sep 2013 11:43:20 +0000 (19:43 +0800)]
Btrfs-progs: fix compile warning in is_ssd()
mkfs.c: In function ‘is_ssd’:
mkfs.c:1168:26: warning: ignoring return value of ‘blkid_devno_to_wholedisk’,
declared with attribute warn_unused_result [-Wunused-result]
blkid_devno_to_wholedisk(devno, wholedisk, sizeof(wholedisk), NULL);
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Anand Jain [Fri, 30 Aug 2013 08:50:37 +0000 (16:50 +0800)]
btrfs-progs: mkfs should check for small vol well before
This fix the regression introduced by 830427d
that it no more creates the FS if disk is small
and if no mixed option is provided.
This patch will bring it to the original design
which will force mixed profile when disk is small
and go ahead to create the FS.
Which also means that before we open the device
for the write we should also check if disk is small.
v2: fixes the checkpatch.pl warnings
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Anand Jain [Wed, 7 Aug 2013 12:11:25 +0000 (20:11 +0800)]
btrfs-progs: avoid write to the disk before sure to create fs
This patch provides fix for the following bug,
When mkfs.btrfs fails the disks shouldn't be written.
------------
btrfs fi show /dev/sdb
Label: none uuid:
60fb76f4-3b4d-4632-a7da-
6a44dea5573d
Total devices 1 FS bytes used 24.00KiB
devid 1 size 2.00GiB used 20.00MiB path /dev/sdb
mkfs.btrfs -dsingle -mraid1 /dev/sdb -f
::
unable to create FS with metadata profile 16 (have 1 devices)
btrfs fi show /dev/sdb
Label: none uuid:
2da2179d-ecb1-4a4e-a44d-
e7613a08c18d
Total devices 1 FS bytes used 24.00KiB
devid 1 size 2.00GiB used 20.00MiB path /dev/sdb
-------------
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Filipe David Borba Manana [Tue, 3 Sep 2013 11:19:58 +0000 (12:19 +0100)]
Btrfs-progs: fix restore command leaving corrupted files
When there are files that have parts shared with snapshots, the
restore command was incorrectly restoring them, as it was not
taking into account the offset and number of bytes fields from
the file extent item. Besides leaving the recovered file corrupt,
it was also inneficient as it read and wrote more data than needed
(with each extent copy overwriting portions of the one previously
written).
The following steps show how to reproduce this corruption issue:
$ mkfs.btrfs -f /dev/sdb3
$ mount /dev/sdb3 /mnt/btrfs
$ perl -e '$d = "\x41" . ("\x00" x (1024*1024+349)); open($f,">","/mnt/btrfs/foobar"); print $f $d; close($f);'
$ du -b /mnt/btrfs/foobar
1048926 /mnt/btrfs/foobar
$ md5sum /mnt/btrfs/foobar
f9f778f3a7410c40e4ed104a3a63c3c4 /mnt/btrfs/foobar
$ btrfs subvolume snapshot /mnt/btrfs /mnt/btrfs/my_snap
$ perl -e 'open($f, "+<", "/mnt/btrfs/foobar"); seek($f, 4096, 0); print $f "\xff"; close($f);'
$ md5sum /mnt/btrfs/foobar
b983fcefd4622a03a78936484c40272b /mnt/btrfs/foobar
$ umount /mnt/btrfs
$ btrfs restore /dev/sdb3 /tmp/copy
$ du -b /tmp/copy/foobar
1048926 /tmp/copy/foobar
$ md5sum /tmp/copy/foobar
88db338cbc1c44dfabae083f1ce642d5 /tmp/copy/foobar
$ od -t x1 -j 8192 -N 4 /tmp/copy/foobar
0020000 41 00 00 00
0020004
$ mount /dev/sdb3 /mnt/btrfs
$ od -t x1 -j 8192 -N 4 /mnt/btrfs/foobar
0020000 00 00 00 00
0020004
$ md5sum /mnt/btrfs/foobar
b983fcefd4622a03a78936484c40272b /mnt/btrfs/foobar
Tested this change with zlib, lzo compression and file sizes larger
than 1GiB, and found no regression or other corruption issues (so far
at least).
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Eric Sandeen [Tue, 11 Jun 2013 23:15:17 +0000 (18:15 -0500)]
Btrfs-progs: Add Makefile infrastructure for subdirs
Preparatory patch to move cmd & test files into their
own subdirs.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Filipe David Borba Manana [Sat, 17 Aug 2013 13:48:29 +0000 (14:48 +0100)]
Btrfs-progs: mkfs can now create fs with skinny extents
Before this change, passing -O skinny-metadata to mkfs.btrfs would
only set the skinny metadata incompat flag in the super block after
the filesystem was created. This change makes mkfs.btrfs directly
create a filesystem with only skinny extents for metadata.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Filipe David Borba Manana [Sat, 17 Aug 2013 13:16:02 +0000 (14:16 +0100)]
Btrfs-progs: add restore command's -x flag to man page
This is a recent flag added to the restore command that allows
to restore xattrs. It was missing in the man page.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Wed, 14 Aug 2013 23:16:31 +0000 (16:16 -0700)]
btrfs-progs: get C=1 sparse checking working again
There were a few problems that were breaking sparse checking:
- We were defining CHECK_ENDIAN late in the environment, after
linux/fs.h has been included which defines __force and __bitwise in
confusing ways that conflict with ours. Define it up with __CHECKER__
so that linux/fs.h and our copy are acting on the same input.
- We had manually set a few of gcc's internal defines to give to sparse.
It's easier to just ask gcc for all the defines it sets and hand those
to sparse.
- We weren't passing the same *FLAGS to sparse as we were to CC.
- glibc has so many errors with FORTIFY turned on that sparse gives up
and doesn't show us any errors from our code. It's a questionable
hack to always turn on FORTIFY ourselves, so we'll just not do that
when building with sparse.
And add a nice '[SP]' quiet output line for sparse checks.
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Wed, 14 Aug 2013 23:16:45 +0000 (16:16 -0700)]
btrfs-progs: use NULL instead of 0
These were mostly in option structs but there were a few gross string
pointer arguments given as 0.
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Wed, 14 Aug 2013 23:16:44 +0000 (16:16 -0700)]
btrfs-progs: give raid6.c its exported prototypes
raid6.c is built without access to the prototypes of functions it
exports.
warning: symbol 'raid6_gen_syndrome' was not declared. Should it be static?
They could be changed and get out of sync of the exported prototypes
without errors. So we add disk-io.h, and its dependency ctree.h, so
that it has a chance to check that its exported prototypes are correct.
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Wed, 14 Aug 2013 23:16:43 +0000 (16:16 -0700)]
btrfs-progs: don't use <linux/fs.h>
sparse can freak out when <linux/fs.h> is included because it redefines
approximately a gazillion symbols already found in <sys/mount.h>:
/usr/include/linux/fs.h:203:9: warning: preprocessor token MS_RDONLY redefined
/usr/include/sys/mount.h:37:9: this was the original definition
Happily, we don't actually need to include the low-level <linux/fs.h>
for anything. One assumes it was just carried over from kernel space.
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Wed, 14 Aug 2013 23:16:42 +0000 (16:16 -0700)]
btrfs-progs: fix unaligned compat endian warnings
The _una_ struct's entire job is to pass an argument to le*_to_cpu. So
it's a little embarassing that it uses a native cpu types and generates
endian warnings.
ctree.h:1616:1: warning: incorrect type in assignment (different base types)
ctree.h:1616:1: expected unsigned long long [unsigned] [usertype] x
ctree.h:1616:1: got restricted __le64 [usertype] <noident>
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Wed, 14 Aug 2013 23:16:41 +0000 (16:16 -0700)]
btrfs-progs: make many private symbols static
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Wed, 14 Aug 2013 23:16:40 +0000 (16:16 -0700)]
btrfs-progs: fix qgroup realloc inheritance
qgroup.c:82:23: warning: memcpy with byte count of 0
qgroup.c:83:23: warning: memcpy with byte count of 0
The inheritance wasn't copying qgroups[] because a confused sizeof()
gave 0 byte memcpy()s. It's been like this for the year since it was
merged, so I guess this isn't a very important thing to do :).
Signed-off-by: Zach Brown <zab@redhat.com>
Reviewed-by: Arne Jansen <sensille@gmx.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Wed, 14 Aug 2013 23:16:39 +0000 (16:16 -0700)]
btrfs-progs: fix in-place byte swapping
Storing fixed-endian values in native cpu types defeats the purpose of
using sparse endian types to find endian conversion bugs.
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Wed, 14 Aug 2013 23:16:38 +0000 (16:16 -0700)]
btrfs-progs: fix extent key endian bug in repair
Extents rebuilt from backrefs can have their objectid mangled. The code
tried to build a disk_key by hand and got the swabbing backwards.
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Wed, 14 Aug 2013 23:16:37 +0000 (16:16 -0700)]
btrfs-progs: fix endian bugs in chunk rebuilding
A disk_key was set by hand instead of using the endian helpers.
I *think* the second one is just a typo. The chunk's num_stripes was
already initialized from the record, but it's le16. So we'll set the
item's size based on the record's native num_stripes.
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Wed, 14 Aug 2013 23:16:36 +0000 (16:16 -0700)]
btrfs-print: define void function args
This silences (reasonable) sparse warnings of the form:
warning: non-ANSI function declaration of ..
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Wed, 14 Aug 2013 23:16:35 +0000 (16:16 -0700)]
btrfs-progs: remove variable length stack arrays
sparse hates variable length array definitions on the stack:
btrfs-show-super.c:155:21: warning: Variable length array is used.
And it's right to. They're a fragile construct that doesn't handle bad
input well at all.
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Wed, 14 Aug 2013 23:16:34 +0000 (16:16 -0700)]
btrfs-progs: fix shadow symbols
This fixes all the instances of warnings that symbols declared in blocks
shadow symbols with the same name in surrounding scopes:
cmds-device.c:341:22: warning: symbol 'path' shadows an earlier one
cmds-device.c:285:14: originally declared here
I just renamed or removed the risky shadow symbols instead of pulling
their blocks out into functions.
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Wed, 14 Aug 2013 23:16:33 +0000 (16:16 -0700)]
btrfs-progs: add ULL to u64 constant
This silences a sparse warning:
warning: constant 0x4D5F53665248425F is so big it is long
from
commit
52162700bb59663add809a6465ce2769d80b3664
Author: Zach Brown <zab@redhat.com>
Date: Thu Jan 17 11:54:47 2013 -0800
btrfs-progs: treat super.magic as an le64
High fives, past me!
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Wed, 14 Aug 2013 23:16:32 +0000 (16:16 -0700)]
btrfs-progs: remove __CHECKER__ from main code
__CHECKER__ is only for the type juggling used to tell sparse which
types need conversion between address spaces. It is not OK to use to
change the code that gets checked to avoid bugs elsewhere in the build
infrastructure. We want to check the code that builds when the checker
isn't enabled.
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 14 Aug 2013 04:29:17 +0000 (12:29 +0800)]
Btrfs-progs: add missing man page for btrfs-map-logical
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 14 Aug 2013 04:29:16 +0000 (12:29 +0800)]
Btrfs-progs: add missing man page information for btrfs-zero-log
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 14 Aug 2013 04:29:15 +0000 (12:29 +0800)]
Btrfs-progs: add missing man page for btrfstune
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 14 Aug 2013 04:29:14 +0000 (12:29 +0800)]
Btrfs-progs: add man page information for btrfs-convert
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 14 Aug 2013 04:29:13 +0000 (12:29 +0800)]
Btrfs-progs: add man page information for btrfs-find-root
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 14 Aug 2013 04:29:12 +0000 (12:29 +0800)]
Btrfs-progs: add missing man page for btrfs-show-super
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 14 Aug 2013 04:29:11 +0000 (12:29 +0800)]
Btrfs-progs: add missing man information for btrfs-debug-tree
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 14 Aug 2013 04:29:10 +0000 (12:29 +0800)]
Btrfs-progs: add missing man page information for btrfsck
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Eric Sandeen [Fri, 9 Aug 2013 20:20:47 +0000 (15:20 -0500)]
btrfs-progs: mark static & remove unused from non-kernel code
Mark many functions as static, and remove any resulting dead code.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Stefan Behrens [Thu, 8 Aug 2013 10:51:39 +0000 (12:51 +0200)]
Btrfs-progs: fix a regression in mkfs.btrfs
Commit
55061a98 adds a cut & paste error that makes mkfs.btrfs fail
if leafsize != sectorsize.
Signed-off-by: Stefan Behrens <sbehrens@giantdisaster.de>
Reviewed-by: Filipe Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Eric Sandeen [Wed, 7 Aug 2013 01:03:33 +0000 (20:03 -0500)]
btrfs-progs: mark static & remove unused from shared kernel code
In files copied from the kernel, mark many functions as static,
and remove any resulting dead code.
Some functions are left unmarked if they aren't static in the
kernel tree.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Tue, 6 Aug 2013 18:49:04 +0000 (11:49 -0700)]
btrfs-progs: don't overrun "answer" array in cmds-chunk.c
Eric noticed the trivial stack overflow bug in ask_user(). I went to
see the context for that fix and found that ask_user() was a bit much.
This fixes the overflow bug that Eric found, endless spinning on scanf()
errors, removes dead code, and leaves us with a trivial helper.
Signed-off-by: Zach Brown <zab@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Anand Jain [Thu, 25 Jul 2013 17:35:27 +0000 (01:35 +0800)]
btrfs-progs: cmd_start_replace() to use test_dev_for_mkfs()
test_dev_for_mkfs() is a common place where
we check if a device is fit for the btrfs use.
cmd_start_replace() should make use of test_dev_for_mkfs(),
and here the test_dev_for_mkfs() is further enhanced
to fit the cmd_start_replace() needs.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Anand Jain [Thu, 25 Jul 2013 17:35:26 +0000 (01:35 +0800)]
btrfs-progs: let user know that devid can be used if path is missing
When the device disappear the path goes missing,
and that will be the one of the reason that user
will replace the device.
The devid of the missing btrfs device can be
obtained using the new cli option
btrfs fi show --kernel
And which can be used in the replace command.
---
btrfs replace start /dev/sdc /dev/sde /btrfs
Error: Unable to open device '/dev/sdc'
Try using the devid instead of the path
---
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Qu Wenruo [Thu, 1 Aug 2013 05:35:33 +0000 (13:35 +0800)]
btrfs-progs: Fix the return value of btrfs-map-logical
The ret variant in the main function is not changed so even problems
happen, return value is still 0.
The patch fixs the minor bug and return 1 if any problems happen.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Jan Schmidt [Mon, 6 May 2013 19:15:18 +0000 (21:15 +0200)]
Btrfs-progs: added "btrfs quota rescan" -w switch (wait)
With -w one can wait for a rescan operation to finish. It can be used when
starting a rescan operation or later to wait for the currently running
rescan operation to finish. Waiting is interruptible.
Signed-off-by: Jan Schmidt <list.btrfs@jan-o-sch.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Koen De Wit [Thu, 11 Jul 2013 20:56:17 +0000 (22:56 +0200)]
btrfs-progs: mkfs.btrfs documentation: clarify current restrictions of sectorsize, nodesize and leafsize
Commit
8d082fb727ac11930ea20bf1612e334ea7c2b697 (Btrfs: do not mount when
we have a sectorsize unequal to PAGE_SIZE) requires the sectorsize to be
equal to the pagesize for the filesystem to be mountable.
The nodesize and leafsize should be equal, and not larger than 65536.
Adding this information to the manpage and usage instructions of mkfs.btrfs.
Signed-off-by: Koen De Wit <koen.de.wit@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Eric Sandeen [Mon, 5 Aug 2013 21:49:33 +0000 (16:49 -0500)]
btrfs-progs: make set/get functions for the super compat_ro flags use compat_ro
Port of commit
12534832 to userspace:
commit
12534832cb7b0abc7369298246e8b7af03b863ca
Author: Josef Bacik <josef@redhat.com>
Date: Thu Dec 17 21:32:27 2009 +0000
Btrfs: make set/get functions for the super compat_ro flags use compat_ro
Our set/get functions for compat_ro_flags actually look at compat_flags. This
will mess any attempt to use compat flags up. The fix is obvious. Thanks,
Signed-off-by: Josef Bacik <josef@redhat.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Eric Sandeen [Mon, 5 Aug 2013 21:46:08 +0000 (16:46 -0500)]
btrfs-progs: fix definition of struct btrfs_extent_inline_ref
Port kernel commit
1bec1aed to userspace.
use __le64 instead of u64 in on-disk structure definition.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Eric Sandeen [Sat, 3 Aug 2013 01:24:55 +0000 (20:24 -0500)]
btrfs-progs: drop weird indirections & dead code from send/receive
cmds-recieve.c & cmds-send.c seem to have weird wrappers and
indirections, and "groups" of commands which have only
one member, which are never referenced in the code.
I think these can be removed.
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Reviewed-by: Stefan Behrens <sbehrens@giantdisaster.de>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Eric Sandeen [Sat, 3 Aug 2013 00:52:43 +0000 (19:52 -0500)]
btrfs-progs: drop unused parameter from btrfs_release_path
Port of commit b3b4aa7 to userspace.
parameter tree root it's not used since commit
5f39d397dfbe140a14edecd4e73c34ce23c4f9ee ("Btrfs: Create extent_buffer
interface for large blocksizes")
This gets userspace a tad closer to kernelspace by removing
this unused parameter that was all over the codebase...
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Josef Bacik [Wed, 31 Jul 2013 14:23:58 +0000 (10:23 -0400)]
Btrfs-progs: sanitize xattrs when we specify sanitization
Alexandre pointed out that his xattrs have sensitive information in them as
well, so fix btrfs-image to zero out the data part of xattrs that we find.
Thanks,
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Reviewed-by: Filipe Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Filipe David Borba Manana [Mon, 29 Jul 2013 18:36:36 +0000 (19:36 +0100)]
Btrfs-progs: return immediately on tree search failure
If the chunk tree search failed in volumes.c:btrfs_read_chunk_tree()
return immediately, rather than looping and use the invalid contents
of the path structure, causing weird errors/crash at run time.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Anand Jain [Thu, 25 Jul 2013 17:35:30 +0000 (01:35 +0800)]
btrfs-progs: don't have to report ENOMEDIUM error during open
when we scan /proc/partitions the cdrom is scanned
as well, and we don't have to report ENOMEDIUM errors
against it.
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Qu Wenruo [Tue, 23 Jul 2013 02:43:22 +0000 (10:43 +0800)]
btrfs-progs: Update the man page of btrfs
Update the man page of "btrfs" command to keep up with new commands.
Now the updated btrfs man page should have all the commands,
and better description sequence, which is the same with "btrfs --help".
Also the paragraph and italic style is unified to improve the readability.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Qu Wenruo [Tue, 23 Jul 2013 02:43:21 +0000 (10:43 +0800)]
btrfs-progs: Update the usage strings of some cmds
Update the usage strings of some cmds to keep the them consistent with
the source.
Also some minor changes are done to fit the man page syntax.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Filipe David Borba Manana [Tue, 30 Jul 2013 11:09:55 +0000 (12:09 +0100)]
Btrfs-progs: add missing path alloc return value check
Also remove unused path in extent-tree.c:finish_current_insert().
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Fri, 19 Jul 2013 06:31:34 +0000 (14:31 +0800)]
Btrfs-progs: make btrfs-map-logical handle error gracefully
If an overflow logical address is passed(for example),the original
code will cause segmentation, this is unfriendly to users,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 <chris.mason@fusionio.com>
Wang Shilong [Wed, 17 Jul 2013 16:03:40 +0000 (00:03 +0800)]
Btrfs-progs: fix wrong arg sb_bytenr for btrfs_scan_fs_devices()
For most time, In open_ctree_*(), we use the first superblock
(BTRFS_SUPER_INFO_OFFSET). However, for btrfs-convert, we don't,
we should pass the correct sb_bytenr to btrfs_scan_fs_devices() rather
than always use BTRFS_SUPER_INFO_OFFSET.This patch fix the following
regression:
mkfs.ext2 <dev>
btrfs-convert <dev>
warning, device 1 is missing
Check tree block failed, want=2670592, have=0
read block failed check_tree_block
Couldn't read chunk root
Segmentation fault (core dumped)
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Anand Jain [Mon, 15 Jul 2013 05:30:54 +0000 (13:30 +0800)]
btrfs-progs: get_label_mounted to return label instead of print
This would help to reuse the function
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Anand Jain [Mon, 15 Jul 2013 05:30:53 +0000 (13:30 +0800)]
btrfs-progs: device delete to get errors from the kernel
when user runs command btrfs dev del the raid requisite error if any
goes to the /var/log/messages, its not good idea to clutter messages
with these user (knowledge) errors, further user don't have to review
the system messages to know problem with the cli it should be dropped
to the user as part of the cli return.
to bring this feature created a set of the ERROR defined
BTRFS_ERROR_DEV* error codes and created their error string.
I expect this enum to be added with other error which we might
want to communicate to the user land
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Anand Jain [Mon, 15 Jul 2013 05:30:50 +0000 (13:30 +0800)]
btrfs-progs: congregate dev scan
the dev scan to find btrfs is performed at two locations
all most the same way one at filesystem show and another
at device scan. They both follow the same steps. This
patch does not alter anything except that it brings these
two same logic into the function scan_for_btrfs so that
we can play tweaking it.
the patch which recommends to use /dev/mapper
will also need it
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Anand Jain [Mon, 15 Jul 2013 05:30:49 +0000 (13:30 +0800)]
btrfs-progs: update device scan usage
the btrfs device scan usage didnt publish --all-devices
option so add it
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Anand Jain [Mon, 15 Jul 2013 05:30:48 +0000 (13:30 +0800)]
btrfs-progs: label option in btrfs filesystem show is not coded
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Anand Jain [Mon, 15 Jul 2013 05:30:47 +0000 (13:30 +0800)]
btrfs-progs: btrfs_scan_for_fsid doesn't need all the arguments
btrfs_scan_for_fsid uses only one argument run_ioctl out of 3
so remove the rest two of them
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Mon, 15 Jul 2013 11:36:50 +0000 (19:36 +0800)]
Btrfs-progs: fix closing of opendir()
valgrind complains open_file_or_dir() causes a memory leak.That is because
if we open a directoy by opendir(), and then we should call closedir()
to free memory.
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Qu Wenruo [Fri, 7 Jun 2013 02:25:59 +0000 (10:25 +0800)]
btrfs-progs: Add chunk corrupt funtion to btrfs-corrupt-block
Add chunk corrupt function to btrfs-corrupt-block.
This funtion can be used to delete or corrupt a given chunk or the whole
chunk tree.
This funtion is useful to test the coming chunk recover funtion.
BTW, since the chunk recover funtion is based on whole partion scanning,
so the COW should be disabled and edit leaf without changing generation.
Which makes btrfs_commit_transation giving some ignorable warning.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Sun, 14 Jul 2013 14:32:23 +0000 (22:32 +0800)]
Btrfs-progs: listing subvols and getting default subvol don't need a subv path
Listing subvolumes and getting default subvol in the filesystem don't need a
subv path,Any valid path related to Btrfs filesystem is ok to finish the work.
Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Filipe David Borba Manana [Sun, 4 Aug 2013 14:14:05 +0000 (15:14 +0100)]
Btrfs-progs: restore can now recover file xattrs
This change adds a new option to the restore command, named -x,
that makes it restore file extented attributes too. This is an
optional behaviour and it's disabled by default.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
David Sterba [Wed, 10 Jul 2013 17:30:51 +0000 (19:30 +0200)]
btrfs-progs: use IEC units for sizes
As implemented now, we use 1024 based units but reporting 1000 based,
let's finally fix that and add optional unit bases later.
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Filipe David Borba Manana [Wed, 10 Jul 2013 08:36:34 +0000 (09:36 +0100)]
Btrfs-progs: update usage message for cmds-restore
Mention that a target path argument is mandatory unless
the -l option is supplied. Also mention about the existence
of the -l option, which was previously not announced.
$ btrfs restore -v /dev/sdb3
usage: btrfs restore [options] <device>
Try to restore files from a damaged filesystem (unmounted)
-s get snapshots
-v verbose
-i ignore errors
-o overwrite
-t tree location
-f <offset> filesystem location
-u <block> super mirror
-d find dir
$ echo $?
129
After specifying a target path, the command works as expected:
$ btrfs restore -v /dev/sdb3 files2/
Restoring files2/file1
Done searching
$ echo $?
0
V2: Updated command synopsis by suggestion of Anand Jain.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
David Sterba [Tue, 9 Jul 2013 16:39:24 +0000 (18:39 +0200)]
btrfs-progs: use reentrant localtime
localtime may return NULL (when an error is detected eg. after setting
tzname), followed by a segfault when the values is about to be used.
localtime_r works, does not set tzname and does not return NULL.
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
David Sterba [Tue, 9 Jul 2013 16:38:55 +0000 (18:38 +0200)]
btrfs-progs: use accessor macro for otime
The root_item->otime value must be accessed via the macro otherwise the
value is incorrect on big endian machines.
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Michal Marek [Tue, 9 Jul 2013 16:38:46 +0000 (18:38 +0200)]
btrfs-progs: fix duplicate __[su]* typedefs on ppc64
The <ext2fs/ext2_types.h> header does attempt to avoid conflicts with
<linux/types.h>, but on ppc64, <asm-generic/int-ll64.h> gets somehow
included by other headers.
Include <linux/types.h> explicitly, so that <ext2fs/ext2_types.h>
notices it. The proper fix would be to fix <ext2fs/ext2_types.h> to not
use its own typedefs.
Originally observed in btrfs-convert, put the include into kerncompat.h
to avoid future problems.
Signed-off-by: Michal Marek <mmarek@suse.cz>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
David Sterba [Tue, 9 Jul 2013 16:38:29 +0000 (18:38 +0200)]
btrfs-progs: Fix getopt on arm/ppc platforms
(same as commit
bb0eabc383e9a3fde7cdb02591ca88243f3e31fb)
There, 'char' is unsigned, so once assigned '-1' from getopt, it gets
the value 255. Then, it compared to '-1' gives false.
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Filipe David Borba Manana [Tue, 9 Jul 2013 11:45:23 +0000 (12:45 +0100)]
Btrfs-progs: add missing path release
Before repeating the search in extent-tree.c:lookup_inline_extent_backref(),
release the current path.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Kusanagi Kouichi [Sat, 6 Jul 2013 08:22:31 +0000 (17:22 +0900)]
btrfs-progs: Fix automatic prerequisite generation
Some files don't compile because of insufficient prerequisite.
$ make btrfs
...
[CC] btrfs.o
btrfs.c:24:21: fatal error: version.h: No such file or directory
#include "version.h"
^
compilation terminated.
make: *** [btrfs.o] Error 1
Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Filipe David Borba Manana [Tue, 30 Jul 2013 11:08:17 +0000 (12:08 +0100)]
Btrfs-progs: optimize function btrfs_read_chunk_tree
After reading all device items from the chunk tree, don't
exit the loop and then navigate down the tree again to find
the chunk items. Instead just read all device items and
chunk items with a single tree search. This is possible
because all device items are found before any chunk item in
the chunks tree.
This is a port of the corresponding kernel patch to keep both
kernel and btrfs-progs identical:
https://patchwork.kernel.org/patch/2835529/
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Filipe David Borba Manana [Fri, 5 Jul 2013 13:35:07 +0000 (14:35 +0100)]
Btrfs-progs: remove incorrect slot decrement
In btrfs_set_block_flags() we want to check if the slot
in the leaf points to the first item in the leaf - if it
doesn't check if the previous item in the leaf is an extent
item. By removing this extra slot decrement we are indeed
checking the item right before the slot, and not the second
item before.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Filipe David Borba Manana [Thu, 4 Jul 2013 15:48:39 +0000 (16:48 +0100)]
Btrfs-progs: fix optimization in btrfs_lookup_extent_info
If we did a tree search with the goal to find a metadata item
but the search failed with return value 1, we attempt to see
if in the same leaf there's a corresponding extent item, and if
there's one, just use it instead of doing another tree search
for this extent item. The check in the leaf was wrong because
it was seeking for a metadata item instead of an extent item.
This optimization was also being triggered incorrectly, as it
was evaluating path->slots which always evaluates to true. The
goal was to see if the leaf level slot was greater than zero
(i.e. not the first item in the leaf).
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Filipe David Borba Manana [Mon, 8 Jul 2013 13:21:24 +0000 (14:21 +0100)]
Btrfs-progs: don't ignore errors in extent-tree.c
Several function return values were being completely
ignored.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Filipe David Borba Manana [Thu, 4 Jul 2013 09:48:39 +0000 (10:48 +0100)]
Btrfs-progs: return error on write failure in make_btrfs()
Instead of aborting with a BUG_ON() statement, return a
negated errno code. Also updated mkfs and convert tools
to print a nicer error message when make_btrfs() returns
an error.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Filipe David Borba Manana [Wed, 3 Jul 2013 17:30:41 +0000 (18:30 +0100)]
Btrfs-progs: add missing write check for mkfs
Assert that the writes of the device and chunk tree
roots succeed. This verification is currently done
for all other tree roots, however it was missing for
those 2 trees.
Would these tree root writes fail, but all others succeed,
it would lead to a corrupted/incomplete btrfs filesystem,
or, more likely some weird failure later on in mkfs.btrfs
inside open_ctree().
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Wang Shilong [Wed, 3 Jul 2013 16:07:38 +0000 (00:07 +0800)]
Btrfs-progs: fix possible memory leak related to subvolume/snapshot creation
The operation related qgroup inherit may fails, if it fails, we should
free memory allocated,otherwise, memory leak happens.
Signed-off-by: Wang Shilong <wangsl-fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Zach Brown [Tue, 9 Jul 2013 20:24:43 +0000 (13:24 -0700)]
btrfs-progs: per-thread, per-call pretty buffer
We don't need callers to manage string storage for each pretty_sizes()
call. We can use a macro to have per-thread and per-call static storage
so that pretty_sizes() can be used as many times as needed in printf()
arguments without requiring a bunch of supporting variables.
This lets us have a natural interface at the cost of requiring __thread
and TLS from gcc and a small amount of static storage. This seems
better than the current code or doing something with illegible format
specifier macros.
Signed-off-by: Zach Brown <zab@redhat.com>
Acked-by: Wang Shilong <wangs.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Filipe David Borba Manana [Wed, 3 Jul 2013 17:32:41 +0000 (18:32 +0100)]
Btrfs-progs: remove unused code
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Filipe David Borba Manana [Sun, 30 Jun 2013 11:51:45 +0000 (12:51 +0100)]
Btrfs-progs: add kstrdup() return value check
When allocating a btrfs_device structure, device_list_add()
in volumes.c was not checking if the call to duplicate the
label string succeeded or not.
Signed-off-by: Filipe David Borba Manana <fdmanana@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Qu Wenruo [Thu, 27 Jun 2013 06:25:18 +0000 (14:25 +0800)]
btrfs-progs: Cleanup unneeded extra variant in btrfs_read_sys_array
The btrfs_read_sys_array function uses 3 variants to read data from
super block.
But the three variants are related to each other, so the patch removes
unneeded extra variants and make code a little simpler.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Reviewed-by: Miao Xie <miaox@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Qu Wenruo [Wed, 26 Jun 2013 05:27:08 +0000 (13:27 +0800)]
btrfs-progs: Cleanup for using BTRFS_SETGET_STACK instead of raw convert
Some codes still use the cpu_to_lexx instead of the
BTRFS_SETGET_STACK_FUNCS declared in ctree.h.
Also added some BTRFS_SETGET_STACK_FUNCS for btrfs_header and
btrfs_super.
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>