Commit Graph

22 Commits (0fc8e78088216c76c262b1ea723d7136ec191869)

Author SHA1 Message Date
Uli Heller c5b6e3fad8 btrfs-progs: Removed missing header file, fixes compilation error
(From pull request #61.)

Author: Uli Heller <uli.heller@daemons-point.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:16:52 +02:00
David Sterba 74a95ec84c btrfs-progs: deprecate standalone btrfs-calc-size
The functionality is now provided by 'inspect tree-stats'.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-11-24 13:06:36 +01:00
Alexander Fougner d4abd0bfb0 btrfs-progs: copy btrfs-calc-size to inspect-internal tree-stats
Signed-off-by: Alexander Fougner <fougner89@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2016-05-02 14:39:53 +02:00
David Sterba 358807cc33 btrfs-progs: unify argc min/max checking
We don't want to modify argc.

Signed-off-by: David Sterba <dsterba@suse.com>
2016-03-14 13:42:47 +01:00
David Sterba d551d05bbc btrfs-progs: calc-size: kill fs_roots structure and its user
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-13 18:24:34 +01:00
David Sterba b023281d3b btrfs-progs: calc-size: use on-stack buffer for a helper structure
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-13 18:24:34 +01:00
Zhao Lei ba4476bc62 btrfs-progs: Fix negative eb's ref_cnt in btrfs-calc-size
btrfs-calc-size show following warning:
 # btrfs-calc-size /dev/sda6
 Calculating size of root tree
 ...
 extent_io.c:582: free_extent_buffer: Assertion `eb->refs < 0` failed.
 ./btrfs-calc-size[0x41d642]
 ./btrfs-calc-size(free_extent_buffer+0x70)[0x41e1c1]
 ./btrfs-calc-size(btrfs_free_fs_root+0x11)[0x40e1e8]
 ./btrfs-calc-size[0x40e215]
 ./btrfs-calc-size(rb_free_nodes+0x1d)[0x4326fe]
 ./btrfs-calc-size(close_ctree+0x3f3)[0x40f9ea]
 ./btrfs-calc-size(main+0x200)[0x431b4e]
 /lib64/libc.so.6(__libc_start_main+0xf5)[0x3858621d65]
 ./btrfs-calc-size[0x407009]

Reason:
 path in calc_root_size() is only used to save node data,
 it don't hold ref_cnt for each eb in.
 Using btrfs_free_path() to free path will reduce these eb
 again, and cause many problems, as negative ref_cnt or
 invalid memory access.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 15:10:14 +01:00
Zhao Lei 0b69dfa410 btrfs-progs: fix floating point exception for btrfs-calc-size
Current code exit with floating point exception on a blank fs:
 # btrfs-calc-size -b /dev/sda6
 Calculating size of root tree
         Total size: 16384
                 Inline data: 0
         Total seeks: 0
                 Forward seeks: 0
                 Backward seeks: 0
 Floating point exception

This patch add a condition check for above case.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 15:10:14 +01:00
Zhao Lei e72cb5de12 btrfs-progs: Add all missing btrfs_close_all_devices to standalone tools
This patch add all missing btrfs_close_all_devices() to standalone
tools in btrfs progs, to avoid memory leak.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:08 +01:00
David Sterba c985a2b104 btrfs-progs: cleanup, update function definitions to be ANSI conformant
Sparse reports:

 warning: non-ANSI function declaration of function

and we're using func(void) elsewhere.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-09-14 23:46:19 +02:00
Anand Jain 672076d4b7 Btrfs-progs: fix compile warnings
simple compile time warning fixes.

btrfs-calc-size.c: In function ‘print_seek_histogram’:
btrfs-calc-size.c:221: warning: ‘group_start’ may be used uninitialized in this function
btrfs-calc-size.c:223: warning: ‘group_end’ may be used uninitialized in this function

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-04-14 15:11:24 +02:00
Qu Wenruo ccdd0a067f btrfs-progs: read_tree_block() and read_node_slot() cleanup.
Allow read_tree_block() and read_node_slot() to return error pointer.
This should help caller to get more specified error number.

For existing callers, change (!eb) judgmentt to
(!extent_buffer_uptodate(eb)) to keep the compatibility, and for caller
missing the check, use PTR_ERR(eb) if possible.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-02-02 19:21:24 +01:00
Karel Zak 33f2d6b84d btrfs-progs: autoconf: use standard PACKAGE_* macros
- use standard PACKAGE_{NAME,VERSION,STRING,URL,...} autoconf macros
  rather than homemade BTRFS_BUILD_VERSION

- don't #include version.h, now the file is necessary for library API only

Note that "btrfs version" returns "btrfs-progs <version>" instead of
the original confusing "btrfs <version>".

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-28 18:00:58 +01:00
Dimitri John Ledkov e69e015634 btrfs-progs: drop feature defines from C files, in favour of CFLAGS defines
glibc 2.10+ (5+ years old) enables all the desired features:
_XOPEN_SOURCE 700, __XOPEN2K8, POSIX_C_SOURCE, DEFAULT_SOURCE; with a
single _GNU_SOURCE define in the makefile alone. For portability to
other libc implementations (e.g. dietlibc) _XOPEN_SOURCE=700 is also
defined.

This also resolves Debian bug report filed by Michael Tautschnig -
"Inconsistent use of _XOPEN_SOURCE results in conflicting
declarations". Whilst I was not able to reproduce the results, the
reported fact is that _XOPEN_SOURCE set to 500 in one set of files
(e.g. cmds-filesystem.c) generates/defines different struct stat from
other files (cmds-replace.c).

This patch thus cleans up all feature defines, and sets them at a
consistent level.

Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=747969
Signed-off-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-01-27 14:45:59 +01:00
Gui Hecheng f1672e50c7 btrfs-progs: use check_argc_* to check arg number for all tools
Since this patch:
	btrfs-progs: move the check_argc_* functions into utils.c

All tools including the independent tools(e.g. btrfs-image, btrfs-convert)
can share the convenience of the check_argc_* functions, so this patch
adopt the argc check functions globally.

Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 15:07:02 +02:00
Wang Shilong a764785990 Btrfs-progs: fsck: fix wrong check for btrfs_read_fs_root()
When encountering a corrupted fs root node, fsck hit following message:

Check tree block failed, want=29360128, have=0
Check tree block failed, want=29360128, have=0
Check tree block failed, want=29360128, have=0
Check tree block failed, want=29360128, have=0
Check tree block failed, want=29360128, have=0
read block failed check_tree_block
Checking filesystem on /dev/sda9
UUID: 0d295d80-bae2-45f2-a106-120dbfd0e173
checking extents
Segmentation fault (core dumped)

This is because in btrfs_setup_all_roots(), we check
btrfs_read_fs_root() return value by verifing whether it is
NULL pointer, this is wrong since btrfs_read_fs_root() return
PTR_ERR(ret), fix it.

Signed-off-by: Wang Shilong <wangsl.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
2014-08-22 14:39:33 +02:00
Zach Brown f539dbb3e5 btrfs-progs: free leaked roots in calc-size
This was found by static analysis.

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>
2013-10-16 08:23:13 -04:00
Josef Bacik 1b10eaa8e1 Btrfs-progs: fix the min ticks check in print_seek_histogram
Before I had been dividing by 5 but that gave me too much output so I changed it
to 20 without changing the min seeks test.  Fix this to avoid a divide by 0
problem.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-10-16 08:23:11 -04:00
Josef Bacik b5efa4c3c9 Btrfs-progs: add a bunch of new statistics to btrfs-calc-size
I've been wanting to get back to the allocator and make some changes to try and
fix our fragmenation woes with lots of metadata.  But in order to make these
changes I need to have something to tell me if my changes are making a real
measurable difference.  So this patch adds a bunch of new statistics to
btrfs-calc-size.  It will tell me how long it took to read in the trees, how
many seeks it had (both forward and backward).  It will tell me how far spread
out the tree is and spit out a nice histogram of the seeks.  Here is some sample
output

Calculating size of extent tree
        Total size: 60.74MB
                Inline data: 0.00
        Total seeks: 5020
                Forward seeks: 3691
                Backward seeks: 1329
                Avg seek len: 929.53MB
        Seek histogram
                      4096 -       4096:       1043 ####
                      8192 -      73728:        760 ###
                     81920 -   52527104:        753 ###
                  53518336 -  168009728:        753 ###
                 168591360 -  696045568:        753 ###
                 696238080 - 7560364032:        753 ###
                7560437760 - 8409739264:        178 |
        Total clusters: 1874
                Avg cluster size: 25.17KB
                Min cluster size: 8.00KB
                Max cluster size: 472.00KB
        Total disk spread: 7.90GB
        Total read time: 0 s 341670 us
        Levels: 4

This way we can have good numbers to back up any changes we make to the
allocator.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-10-16 08:23:11 -04:00
Ross Kirk af86684e9b btrfs-progs: drop unused parameter from btrfs_item_nr
Remove unused eb parameter from btrfs_item_nr, unused since introduced
in 7777e63b42

Signed-off-by: Ross Kirk <ross.kirk@gmail.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
2013-10-16 08:23:10 -04:00
Zach Brown 876e3f9380 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>
2013-08-09 14:32:33 +02:00
Eric Sandeen b1031dfae1 btrfs-progs: standardize tool source filenames
For any btrfs-$FOO executable, rename the main source file from
$FOO.c to to btrfs-$FOO.c

This makes it slightly more obvious what's building what,
and allows us to write a default rule in the Makefile for
these tools.

(also add btrfs-calc-size to the list of objects to remove
on make clean)

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
2013-04-24 14:05:33 +02:00