Commit Graph

2285 Commits (b13197d68f659e9f52fff0506a0fd5b1e557f7d7)
 

Author SHA1 Message Date
David Sterba b13197d68f btrfs-progs: use on-stack buffer for dev_to_fsid
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-13 18:24:17 +01:00
David Sterba ee07dc99d1 btrfs-progs: remove unused parameter from print_one_fs
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-06 17:05:36 +01:00
David Sterba e29ec82e4e btrfs-progs: don't print version info from embedded subcommands
The version is provided by 'btrfs --version'.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-06 17:00:36 +01:00
David Sterba 4e01c34b8b btrfs-progs: simplify empty stirngs check
We can do a strlen(str) == 0 in a simpler way.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-06 16:53:55 +01:00
David Sterba 49e0f3e646 btrfs-progs: utils: rename helpinfo unit vairables
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-06 16:39:49 +01:00
David Sterba d64a9ff88e
Btrfs progs v4.3
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-06 12:07:54 +01:00
David Sterba f2c844f65f btrfs-progs: mkfs: do not truncate the image when --rootdir is set
With the rootdir option we try to guess the final size of the image and
fill it with zeros, preceded by truncation. After patch

"Btrfs-progs: Do not force mixed block group creation unless '-M' option
 is specified"

the misc test 002 will fail, because of the non-mixed mode. I think we
should not touch the image size (no change for block devices) and try to
fit into whatever is provided by user.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-05 14:49:02 +01:00
Qu Wenruo e8a5f57b69 btrfs-progs: Allow btrfs_leaf_free_space to accept NULL root
Btrfs_leaf_free_space() function is used to determine the leaf/node
size.
It's OK to use root->nodesize to determine nodesize, but in fact,
extent_buffer->len can also be used to determine the nodesize if caller
can ensure it's a tree block.

So this patch will add support for NULL root for btrfs_leaf_free_space()
function, to allow btrfs_print_leaf() functions to be called in gdb or
to debug temporary btrfs in make_btrfs() without a valid root.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-05 13:40:44 +01:00
Zhao Lei fa2dcf1406 btrfs-progs: mkfs: Round device size down to sectorsize
When do following command in a vm, whose disks are created by
qemu-img create -f raw 11 2.6G:
 # mkfs.btrfs -f /dev/vdd /dev/vde /dev/vdf
 # btrfs-show-super /dev/vdd /dev/vde /dev/vdf | grep dev_item.total_bytes
 dev_item.total_bytes    2791727104
 dev_item.total_bytes    2791729152
 dev_item.total_bytes    2791729152
We can see that the first device's size is little smaller.

And it fails xfstests btrfs/011.

Reason:
 First device's size is rounded down to sectorsize in make_btrfs(),
 but other devices are not.

Fix:
 Round down remain devices' size in btrfs_add_to_fsid().

Reported-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03 13:16:05 +01:00
Zhao Lei a40b0ff048 btrfs-progs: Rename variables in btrfs_add_to_fsid
There are two total_bytes in btrfs_add_to_fsid(), local variable
of total_bytes means fs_total_bytes, and device->total_bytes means
device's total_bytes.
And device's total_bytes in argument is named block_count in current
code.

This patch rename:
 total_bytes -> fs_total_bytes
 block_count -> device_total_bytes

To make code more readable.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03 13:16:02 +01:00
Qu Wenruo 518fdbabd7 btrfs-progs: print-tree: Output stripe dev uuid
Add output for dev uuid for print_chunk().

Quite useful to debug temporary btrfs in btrfs-convert.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03 13:11:14 +01:00
Zhao Lei b160d29345 btrfs-progs: mkfs: remove unused code of format uuid string
Variant named dev_uuid and uuid_unparse() for set its value are
not used, remove it.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03 13:00:55 +01:00
Zhao Lei 568a3743f5 btrfs-progs: mkfs: output device list in sorted order
list_for_each_entry_reverse() in current code can not output
devices in sorted order, because the sequence are broken in
btrfs_alloc_chunk().

We can use list_sort() instead.

Before patch:
 # mkfs.btrfs -f /dev/vdd /dev/vde /dev/vdf
 ...
 Number of devices:  3
 Devices:
    ID        SIZE  PATH
     3     2.60GiB  /dev/vdf
     1     2.60GiB  /dev/vdd
     2     2.60GiB  /dev/vde

After patch:
 # mkfs.btrfs -f /dev/vdd /dev/vde /dev/vdf
 ...
 Number of devices:  3
 Devices:
    ID        SIZE  PATH
     1     2.60GiB  /dev/vdd
     2     2.60GiB  /dev/vde
     3     2.60GiB  /dev/vdf

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03 12:56:52 +01:00
David Sterba c5cb2432bf btrfs-progs: fi usage: print header and footer separation line
Print the full row width and change to '-' as we're not using '='
anywhere.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03 01:09:50 +01:00
David Sterba 1de2da5ddd btrfs-progs: string table: add specifier for fillup char
Currently it's one by a single "=", but we might want to use
a different filler, let's make it explicit by "*".

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03 01:00:23 +01:00
David Sterba 850ad2ce35 btrfs-progs: string table: cleanup, rename single letter variables
Exception for indexing variables.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03 00:56:32 +01:00
David Sterba 7a91592775 btrfs-progs: string table: fix whitespace damage
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03 00:55:20 +01:00
David Sterba 952251481e btrfs-progs: fi usage: print device id column in the tabular output<F2>
Example output:

             Data     Metadata System
Id Path      single   RAID1    RAID1    Unallocated

 1 /dev/sdc2 44.94GiB  7.93GiB 32.00MiB     1.00GiB
 2 /dev/sde1 44.94GiB  7.93GiB 32.00MiB     1.00GiB
             ======== ======== ======== ===========
   Total     89.88GiB  7.93GiB 32.00MiB     2.00GiB
   Used      74.28GiB  4.44GiB 20.00KiB

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03 00:19:41 +01:00
David Sterba 258a0e8812 btrfs-progs: fi usage: cleanup, replace space info starting column constant
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03 00:14:38 +01:00
David Sterba ffa899f296 btrfs-progs: fi usage: cleanup, replace header constant
The size of the header is not obvious, let's make it more visible by
replacing it with a varaible.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03 00:14:08 +01:00
David Sterba f3d5694578 btrfs-progs: fi usage: properly count real space infos
We did not account the column for path but abused the skipped global
block reserve colum instead. Properly count the real infos and manually
added headers.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-03 00:14:06 +01:00
David Sterba 7691c2c52b btrfs-progs: fi usage: print path header in the tabular mode
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 18:40:57 +01:00
David Sterba 5205097bac btrfs-progs: fi usage: cleanup, print header in one go
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 18:39:41 +01:00
David Sterba a0c78dca8f btrfs-progs: fi usage: do not print global block reserve
Global block reserve is inherently part of metadata and should not be
listed separately in the output of 'fi usage' in the tabular output.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 18:30:32 +01:00
David Sterba c1cbf59ef6
Btrfs progs v4.3-rc1
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 15:46:50 +01:00
Qu Wenruo c328e0db4a btrfs-progs: show-super: Add option to print superblock at given bytenr
Add '-s <sb_bytenr>' option to show superblock at given bytenr.

This is very useful to debug non-standard btrfs, like debuging the
1st stage btrfs of btrfs-convert.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ minor updates in docs ]
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 15:45:52 +01:00
David Sterba b1c222321e btrfs-progs: docs: enhance manual page for inspect-internal
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 15:10:16 +01:00
David Sterba 26d6392f70 btrfs-progs: docs: enhance the manual page for convert
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 15:10:15 +01:00
David Sterba bfb2659d12 btrfs-progs: docs: enhance manual page for balance
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 15:10:15 +01:00
David Sterba b44e84a650 btrfs-progs: docs: enhance manual page for btrfstune
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 15:10:15 +01:00
David Sterba a2d66e0962 btrfs-progs: docs: enhance manual page for mkfs
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 15:10:15 +01:00
David Sterba ce059fc9d7 btrfs-progs: mkfs: print version info first
The version info should not be preceded by any messages.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 15:10:15 +01:00
David Sterba 4f42e465cb btrfs-progs: image: fix bogus check after cpu on-line detection
Comparing unsigned type for <= 0 does not make much sense, we should
really check the signed value returned by sysconf.

Resolves-coverity-id: 1324536
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 15:10:14 +01:00
Zhao Lei c9bddcacbc btrfs-progs: Avoid use pointer in handle_options
We use pointer of argc and argv in handle_options() because they
are necessary in very old code which are not exist now.

This patch move to use argc and argv directly in handle_options(),
alone with following update:
1: rename handle_options() to check_options()
   to fit its function.
2: cleanup for condition in handle_options() to make line short.

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 eccf7aa62e btrfs-progs: Fix uninitialized key.type for btrfs_find_free_objectid
To avoid using uninitialized value in btrfs_search_slot().

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 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
David Sterba 835821f36a btrfs-progs: add initial tests/README
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 15:10:14 +01:00
David Sterba fea963541a btrfs-progs: add an initial README
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 15:10:13 +01:00
David Sterba e4706adbe0 btrfs-progs: mkfs: remove stray message about forced mixed-bg
We no longer force mixed-bg mode since "Btrfs-progs: Do not force mixed
block group creation unless '-M' option is specified", the message is
not relevant anymore.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:09 +01:00
David Sterba cb10f56cb6 btrfs-progs: tests: add 003-mixed-with-wrong-nodesize
Mixed mode needs equal sectorsize and nodesize. This was fixed by

 "Btrfs-progs: Prevent creation of filesystem with 'mixed bgs' and
  having differing sectorsize and nodesize"

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:08 +01:00
David Sterba 425274ed8f btrfs-progs: tests: do not log output of run_mayfail to terminal
No need to log expected failures to the terminal, the results file is
fine; pass the return value of the command.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:08 +01:00
Chandan Rajendra a73eb8b993 Btrfs-progs: Prevent creation of filesystem with 'mixed bgs' and having differing sectorsize and nodesize.
mkfs.btrfs allows creation of Btrfs filesystem instances with mixed block
group feature enabled and having a sectorsize different from nodesize.
For e.g:

[root@localhost btrfs-progs]# mkfs.btrfs -f -M -s 4096 -n 16384  /dev/loop0
Forcing mixed metadata/data groups
btrfs-progs v3.19-rc2-404-gbbbd18e-dirty
See http://btrfs.wiki.kernel.org for more information.

Performing full device TRIM (4.00GiB) ...
Label:              (null)
UUID:               c82b5720-6d88-4fa1-ac05-d0d4cb797fd5
Node size:          16384
Sector size:        4096
Filesystem size:    4.00GiB
Block group profiles:
  Data+Metadata:    single            8.00MiB
  System:           single            4.00MiB
SSD detected:       no
Incompat features:  mixed-bg, extref, skinny-metadata
Number of devices:  1
Devices:
  ID        SIZE  PATH
   1     4.00GiB  /dev/loop6

This commit fixes the issue by setting BTRFS_FEATURE_INCOMPAT_MIXED_GROUPS
feature bit before checking the validity of nodesize that was specified on the
command line.

Signed-off-by: Chandan Rajendra <chandan@linux.vnet.ibm.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:08 +01:00
Zhao Lei ca582727e8 btrfs-progs: use system's default path for math.h
Line of
 #include "math.h"
in extent-tree.c using quotas is historical reason, (we had custom
math.h before).

Use "<>" instead of quotes in this header file.

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
Zhao Lei 2b4000c551 btrfs-progs: Add missing close_ctree to btrfs-select-super.c
Add missing close_ctree() to btrfs-select-super.c 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
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
Zhao Lei da34dbd149 btrfs-progs: Remove all btrfs_close_all_devices in sub-command
Since we have btrfs_close_all_devices() in btrfs's main entrance,
it is not necessary to call btrfs_close_all_devices() separately
in each sub-command.

Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:07 +01:00
Zhao Lei 30fd6f2e92 btrfs-progs: btrfs: Add missing btrfs_close_all_devices for btrfs command
Adding a btrfs_close_all_devices() after command callback in btrfs.c
can force-close all opened device before program exit, to avoid memory leak
in all btrfs sub-command.

Suggested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:07 +01:00
David Sterba 1c4aefc2b8 btrfs-progs: tests: add support for command instrumentation
Add a way to wrap commands executed by the tests. This means the
common wrappers: run_check, run_check_stdout and run_mayfail , with the
exception of the use root_helper.

The contents of the shell variable INSTRUMENT are prepended to the
command, without quotes. Use with care.

Example: this has been tested with valgrind, the output goes to the
RESULTS file.

 $ INSTRUMENT=valgrind make test-misc

Any use of root_helper/SUDO_HELPER will skip the instrumentation.

Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:07 +01:00
David Sterba dfed5799db btrfs-progs: tests: 001-simple-unmounted: iterate over fuzzed images and run check
Signed-off-by: David Sterba <dsterba@suse.com>
2015-11-02 09:35:07 +01:00