platform/upstream/btrfs-progs.git
8 years agobtrfs-progs: reduce size of btrfs_path::reada
David Sterba [Thu, 3 Nov 2016 15:55:35 +0000 (16:55 +0100)]
btrfs-progs: reduce size of btrfs_path::reada

We use only a few values, reada accessed not in performance critical
contexts.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: reduce size of btrfs_path, locks are not used
David Sterba [Thu, 3 Nov 2016 15:49:30 +0000 (16:49 +0100)]
btrfs-progs: reduce size of btrfs_path, locks are not used

Size of btrfs_path can be reduced by 32 bytes as we don't use the locks
array, down to 112 from 144 bytes.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: mkfs: constify some char parameters
David Sterba [Wed, 2 Nov 2016 23:02:29 +0000 (00:02 +0100)]
btrfs-progs: mkfs: constify some char parameters

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: mkfs: use const char for unmodified members of directory_name_entry
David Sterba [Wed, 2 Nov 2016 23:01:51 +0000 (00:01 +0100)]
btrfs-progs: mkfs: use const char for unmodified members of directory_name_entry

We never modify the members, just point them to other strings.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: check: reorder fields in inode_backref for better packing
David Sterba [Wed, 2 Nov 2016 15:50:47 +0000 (16:50 +0100)]
btrfs-progs: check: reorder fields in inode_backref for better packing

The structure size went from 56 bytes to 48, which could save some bytes
in larger scale.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: check: unify type for inode_backref::itemtype
David Sterba [Wed, 2 Nov 2016 15:37:09 +0000 (16:37 +0100)]
btrfs-progs: check: unify type for inode_backref::itemtype

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: check: unify type for inode_backref::filetype
David Sterba [Wed, 2 Nov 2016 15:37:09 +0000 (16:37 +0100)]
btrfs-progs: check: unify type for inode_backref::filetype

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: send: cleanup use of ctransid delta temporary variable in find_good_parent
David Sterba [Wed, 2 Nov 2016 13:59:07 +0000 (14:59 +0100)]
btrfs-progs: send: cleanup use of ctransid delta temporary variable in find_good_parent

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: send: cleanup, rename send context variables
David Sterba [Wed, 2 Nov 2016 13:14:56 +0000 (14:14 +0100)]
btrfs-progs: send: cleanup, rename send context variables

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: send: cleanup, rename some variables in dump_thread
David Sterba [Wed, 2 Nov 2016 13:07:53 +0000 (14:07 +0100)]
btrfs-progs: send: cleanup, rename some variables in dump_thread

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: send: clean types in write_buf
David Sterba [Wed, 2 Nov 2016 13:04:06 +0000 (14:04 +0100)]
btrfs-progs: send: clean types in write_buf

Use matching types for buffer, return value and buffer sizes.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: send: use proper type for read result, and rename the variable
David Sterba [Wed, 2 Nov 2016 13:00:07 +0000 (14:00 +0100)]
btrfs-progs: send: use proper type for read result, and rename the variable

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: send: increase size of transfer buffer
David Sterba [Wed, 2 Nov 2016 12:27:45 +0000 (13:27 +0100)]
btrfs-progs: send: increase size of transfer buffer

4K is quite small, increase it to 64K. This reduces number of
context switches and calls to read. Kernel sends us about 50K of data
per read, so increasing the buffer further does not make any
improvement.

Example run on tests/cli-tests/004-send-parent-multi-subvol:
4K:
  - ~800 context switches
  - ~5000 calls to read

64K:
  - ~450 context switches
  - ~500 calls to read

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: send: constify some arugments
David Sterba [Wed, 2 Nov 2016 12:17:31 +0000 (13:17 +0100)]
btrfs-progs: send: constify some arugments

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: tests: add test for multi-subvolume send from parent
David Sterba [Wed, 2 Nov 2016 12:07:15 +0000 (13:07 +0100)]
btrfs-progs: tests: add test for multi-subvolume send from parent

Fixed by "btrfs-progs: send: fix handling of multiple snapshots (-p
option)".

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: convert dir-item-to-string to table
David Sterba [Wed, 2 Nov 2016 10:16:12 +0000 (11:16 +0100)]
btrfs-progs: dump-tree: convert dir-item-to-string to table

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: convert key-to-string to table
David Sterba [Wed, 2 Nov 2016 10:16:12 +0000 (11:16 +0100)]
btrfs-progs: dump-tree: convert key-to-string to table

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: cleanup types for item number iteration
David Sterba [Wed, 2 Nov 2016 09:52:25 +0000 (10:52 +0100)]
btrfs-progs: dump-tree: cleanup types for item number iteration

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: move remaining item variables to the scope of use
David Sterba [Wed, 2 Nov 2016 09:50:40 +0000 (10:50 +0100)]
btrfs-progs: dump-tree: move remaining item variables to the scope of use

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: move variable declarations closer to their use
David Sterba [Wed, 2 Nov 2016 09:48:08 +0000 (10:48 +0100)]
btrfs-progs: dump-tree: move variable declarations closer to their use

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: rename extent buffer variable in btrfs_print_leaf
David Sterba [Wed, 2 Nov 2016 09:42:19 +0000 (10:42 +0100)]
btrfs-progs: dump-tree: rename extent buffer variable in btrfs_print_leaf

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: add untyped item ptr helper and use it
David Sterba [Wed, 2 Nov 2016 09:06:16 +0000 (10:06 +0100)]
btrfs-progs: dump-tree: add untyped item ptr helper and use it

There's lots of code that passes btrfs_item_ptr. Add a helper to extract
the ptr at the beginning, ignoring the type. The print functions take
the correct type, but we ignore it in the conversion macros as it does
not provide the type checking anyway.

If the typed variable is used more than once, it's kept in place.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: constify char argument in print_root_ref
David Sterba [Wed, 2 Nov 2016 09:26:33 +0000 (10:26 +0100)]
btrfs-progs: dump-tree: constify char argument in print_root_ref

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: simplify and fix check for empty uuid
David Sterba [Wed, 2 Nov 2016 09:22:10 +0000 (10:22 +0100)]
btrfs-progs: dump-tree: simplify and fix check for empty uuid

Counting non-zero bytes is wasteful, besides that it would not recognize
uuids containing a 00 value.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: return void from print_* functions
David Sterba [Wed, 2 Nov 2016 09:19:16 +0000 (10:19 +0100)]
btrfs-progs: dump-tree: return void from print_* functions

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: pass item size instead of item
David Sterba [Wed, 2 Nov 2016 09:15:32 +0000 (10:15 +0100)]
btrfs-progs: dump-tree: pass item size instead of item

Several functions take item but use just the size, we can factor the
item size and use that.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: remove unused parameter from print_inode_item
David Sterba [Wed, 2 Nov 2016 09:08:55 +0000 (10:08 +0100)]
btrfs-progs: remove unused parameter from print_inode_item

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: consolidate data key names
David Sterba [Wed, 2 Nov 2016 08:54:31 +0000 (09:54 +0100)]
btrfs-progs: dump-tree: consolidate data key names

Rename to the structure members, add underscore so it's a single word.
Compression is also printed as raw value.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: print dev stats
David Sterba [Wed, 2 Nov 2016 01:06:13 +0000 (02:06 +0100)]
btrfs-progs: dump-tree: print dev stats

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: add dev stats on-disk structure
David Sterba [Wed, 2 Nov 2016 01:10:52 +0000 (02:10 +0100)]
btrfs-progs: add dev stats on-disk structure

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: print balance status item
David Sterba [Tue, 1 Nov 2016 12:47:14 +0000 (13:47 +0100)]
btrfs-progs: dump-tree: print balance status item

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: add balance status structures
David Sterba [Tue, 1 Nov 2016 23:53:54 +0000 (00:53 +0100)]
btrfs-progs: add balance status structures

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: teach print_leaf about temporary item subtypes
David Sterba [Tue, 1 Nov 2016 12:39:44 +0000 (13:39 +0100)]
btrfs-progs: teach print_leaf about temporary item subtypes

[ kernel patch 9f07e1d76eaeeddedcf9651395b4a8f870df31f0 ]
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: teach print_leaf about permanent item subtypes
David Sterba [Tue, 1 Nov 2016 12:36:58 +0000 (13:36 +0100)]
btrfs-progs: teach print_leaf about permanent item subtypes

[ kernel patch 585a3d0d238dfe42909cb58b0d05f644365fed14 ]
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: switch dev stats item to the permanent item key
David Sterba [Tue, 1 Nov 2016 12:34:13 +0000 (13:34 +0100)]
btrfs-progs: switch dev stats item to the permanent item key

[ kernel patch 242e2956e4afde7727fffe21adc0a7b198b77f96 ]
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: introduce key type for persistent permanent items
David Sterba [Tue, 1 Nov 2016 12:32:26 +0000 (13:32 +0100)]
btrfs-progs: introduce key type for persistent permanent items

The number of distinct key types is not that big that we could waste one
for something new we want to store in the tree.

Similar to the temporary items, we'll introduce a new name for an
existing key value and use the objectid for further extension.  The
victim is the BTRFS_DEV_STATS_KEY (248).

The device stats are an example of a permanent item.

[ kernel patch 50c2d5abe64c1726b48d292a2ab04f60e8238933 ]
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: print-tree: extract offset from the item key
David Sterba [Tue, 1 Nov 2016 12:40:19 +0000 (13:40 +0100)]
btrfs-progs: print-tree: extract offset from the item key

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: introduce key type for persistent temporary items
David Sterba [Tue, 1 Nov 2016 12:29:25 +0000 (13:29 +0100)]
btrfs-progs: introduce key type for persistent temporary items

The number of distinct key types is not that big that we could waste one
for something new we want to store in the tree. We'll introduce a new
name for an existing key value and use the objectid for further
extension.  The victim is the BTRFS_BALANCE_ITEM_KEY (248).

The nature of the balance status item is a good example of the temporary
item. It exists from beginning of the balance, keeps the status until it
finishes.

[ kernel patch 0bbbccb17fea86818e1a058faf5903aefd20b31a ]
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: mkfs: store creation time of the toplevel subvolume
David Sterba [Mon, 31 Oct 2016 16:06:15 +0000 (17:06 +0100)]
btrfs-progs: mkfs: store creation time of the toplevel subvolume

For unkonwn reasons, the creation time of the toplevel subvolume inode
item hasn't been set.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: print missing data for file extent item
David Sterba [Mon, 31 Oct 2016 15:31:15 +0000 (16:31 +0100)]
btrfs-progs: dump-tree: print missing data for file extent item

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: print more root_item data
David Sterba [Mon, 31 Oct 2016 15:22:17 +0000 (16:22 +0100)]
btrfs-progs: dump-tree: print more root_item data

Print a few more missing items of root_item (there are still some
remaining). Drop key is printend unconditionally.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: print missing dir_item data
David Sterba [Mon, 31 Oct 2016 13:25:03 +0000 (14:25 +0100)]
btrfs-progs: dump-tree: print missing dir_item data

Add items from dir_item that are not printed, plus other adjustments.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: print missing inode_item data
David Sterba [Mon, 31 Oct 2016 13:25:03 +0000 (14:25 +0100)]
btrfs-progs: dump-tree: print missing inode_item data

Add items from inode_item that are not printed.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: add helper to print timespec
David Sterba [Mon, 31 Oct 2016 15:00:53 +0000 (16:00 +0100)]
btrfs-progs: dump-tree: add helper to print timespec

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: factor inode_item dump to function
David Sterba [Mon, 31 Oct 2016 14:20:20 +0000 (15:20 +0100)]
btrfs-progs: dump-tree: factor inode_item dump to function

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: print missing dev_extent data
David Sterba [Mon, 31 Oct 2016 13:25:03 +0000 (14:25 +0100)]
btrfs-progs: dump-tree: print missing dev_extent data

Add items from chunk that are not printed, unify names according to
the member names and reorder a bit.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: print missing chunk data
David Sterba [Mon, 31 Oct 2016 13:25:03 +0000 (14:25 +0100)]
btrfs-progs: dump-tree: print missing chunk data

Add items from chunk that are not printed, unify names according to
the member names and reorder a bit.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: print missing dev_item data
David Sterba [Mon, 31 Oct 2016 13:25:03 +0000 (14:25 +0100)]
btrfs-progs: dump-tree: print missing dev_item data

Add items from dev_item that are not printed, unify names according to
the member names.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: subvol show: print more details about toplevel subvolume
David Sterba [Mon, 31 Oct 2016 12:56:28 +0000 (13:56 +0100)]
btrfs-progs: subvol show: print more details about toplevel subvolume

The toplevel subvolume is special and the other listing code leaves it
out so we have to add several special cases to handle it. There's no
backreference so the path is built artificially. New helper
btrfs_get_toplevel_subvol is a reduced version of btrfs_get_subvol.

There's some information usually missing for the toplevel subvolume, eg.
the uuid or creation info. This has to be fixed on the mkfs side, the
other subvolumes are created by kernel.

Example:
/mnt
        Name:                   <FS_TREE>
        UUID:                   -
        Parent UUID:            -
        Received UUID:          -
        Creation time:          -
        Subvolume ID:           5
        Generation:             233
        Gen at creation:        0
        Parent ID:              0
        Top level ID:           0
        Flags:                  -
        Snapshot(s):
                                subv1

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: subvol list: better error message if subvol insertion fails
David Sterba [Mon, 31 Oct 2016 11:53:35 +0000 (12:53 +0100)]
btrfs-progs: subvol list: better error message if subvol insertion fails

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: subvol list: remove ugly goto construct
David Sterba [Mon, 31 Oct 2016 11:46:52 +0000 (12:46 +0100)]
btrfs-progs: subvol list: remove ugly goto construct

Jumping into an if is not considered nice.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: remove trivial helper root_lookup_init
David Sterba [Mon, 31 Oct 2016 11:44:29 +0000 (12:44 +0100)]
btrfs-progs: remove trivial helper root_lookup_init

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: subvol list: consolidate uuid types accross functions
David Sterba [Mon, 31 Oct 2016 11:33:28 +0000 (12:33 +0100)]
btrfs-progs: subvol list: consolidate uuid types accross functions

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: subvol list: add simplified helper for adding root backrefs
David Sterba [Mon, 31 Oct 2016 11:27:08 +0000 (12:27 +0100)]
btrfs-progs: subvol list: add simplified helper for adding root backrefs

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: subvol list: consilidate naming of otime varaibles
David Sterba [Mon, 31 Oct 2016 11:19:50 +0000 (12:19 +0100)]
btrfs-progs: subvol list: consilidate naming of otime varaibles

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: subvol list: simplify value assignments
David Sterba [Mon, 31 Oct 2016 11:15:18 +0000 (12:15 +0100)]
btrfs-progs: subvol list: simplify value assignments

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: subvol list: remove useless comments
David Sterba [Mon, 31 Oct 2016 11:04:55 +0000 (12:04 +0100)]
btrfs-progs: subvol list: remove useless comments

The search ioctl follows a well known usage pattern.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: subvol list: cleanup layout argument setup
David Sterba [Mon, 31 Oct 2016 11:00:15 +0000 (12:00 +0100)]
btrfs-progs: subvol list: cleanup layout argument setup

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: return void from btrfs_list_setup_filter
David Sterba [Mon, 31 Oct 2016 10:51:54 +0000 (11:51 +0100)]
btrfs-progs: return void from btrfs_list_setup_filter

As an early setup function, failure uisng exit is ok.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: subvol list: setup list filters later
David Sterba [Mon, 31 Oct 2016 10:40:23 +0000 (11:40 +0100)]
btrfs-progs: subvol list: setup list filters later

First check for arguments and whether we can open the filesystem.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: list: switch to common message helpers
David Sterba [Mon, 31 Oct 2016 10:32:12 +0000 (11:32 +0100)]
btrfs-progs: list: switch to common message helpers

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: list: rename some helpers
David Sterba [Mon, 31 Oct 2016 10:17:02 +0000 (11:17 +0100)]
btrfs-progs: list: rename some helpers

Using _volume_ is confusing, it's for subvolumes.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: use enum for list layout type
David Sterba [Mon, 31 Oct 2016 10:11:50 +0000 (11:11 +0100)]
btrfs-progs: use enum for list layout type

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: list: constify prefix arugment
David Sterba [Mon, 31 Oct 2016 10:08:06 +0000 (11:08 +0100)]
btrfs-progs: list: constify prefix arugment

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: use symbolic tree name when searching
David Sterba [Mon, 31 Oct 2016 09:59:08 +0000 (10:59 +0100)]
btrfs-progs: use symbolic tree name when searching

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: remove leading underscores from several helper
David Sterba [Mon, 31 Oct 2016 09:52:26 +0000 (10:52 +0100)]
btrfs-progs: remove leading underscores from several helper

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: opencode trivial helper __free_all_subvolumn
David Sterba [Mon, 31 Oct 2016 09:51:52 +0000 (10:51 +0100)]
btrfs-progs: opencode trivial helper __free_all_subvolumn

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: use existing rootid resolving helper in btrfs_list_get_path_rootid
David Sterba [Mon, 31 Oct 2016 09:38:31 +0000 (10:38 +0100)]
btrfs-progs: use existing rootid resolving helper in btrfs_list_get_path_rootid

The utils helper is not verbose in case of an error, for now the helper
used for subvolume listing will print the error message but not
duplicate the ioctl anymore.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: rename lookup_ino_rootid
David Sterba [Mon, 31 Oct 2016 09:34:37 +0000 (10:34 +0100)]
btrfs-progs: rename lookup_ino_rootid

It does not resolve the inode number but path where fd has been opened.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: remove unused function btrfs_get_path_rootid
David Sterba [Mon, 31 Oct 2016 09:29:12 +0000 (10:29 +0100)]
btrfs-progs: remove unused function btrfs_get_path_rootid

Last user replaced with a more appropriate helper.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: qgroups show: handle errors when resolving root id
David Sterba [Mon, 31 Oct 2016 09:27:25 +0000 (10:27 +0100)]
btrfs-progs: qgroups show: handle errors when resolving root id

If btrfs_get_path_rootid fails, prints an error message but continues.
Replace with a helper that returns an error.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: remove send-test tool
Qu Wenruo [Tue, 1 Nov 2016 08:01:46 +0000 (16:01 +0800)]
btrfs-progs: remove send-test tool

Since new "receive --dump" has better output and structure, it's time
to remove old and function-weak send-test tool.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: Add travis CI build support
Roman Lebedev [Mon, 31 Oct 2016 09:08:46 +0000 (10:08 +0100)]
btrfs-progs: Add travis CI build support

Automated build checks for the devel branch and integration to coverity,
using travis.org. Roman's initial .yml version has been adjusted for
btrfs-progs needs.

Author: Roman Lebedev <lebedev.ri@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: convert: switch more messages to common helpers
David Sterba [Fri, 28 Oct 2016 16:34:03 +0000 (18:34 +0200)]
btrfs-progs: convert: switch more messages to common helpers

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: send: fix handling of multiple snapshots (-p option)
Tsutomu Itoh [Wed, 19 Oct 2016 02:35:03 +0000 (11:35 +0900)]
btrfs-progs: send: fix handling of multiple snapshots (-p option)

We cannot send multiple snapshots at once by -p option.

[before]
# btrfs send -f /tmp/data0 -p Snap0 Snap[12]
At subvol Snap1
At subvol Snap2
ERROR: parent determination failed for 0
#

[after]
# btrfs send -f /tmp/data0 -p Snap0 Snap[12]
At subvol Snap1
At subvol Snap2
#

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: Ignore clang complete file
Qu Wenruo [Thu, 27 Oct 2016 02:32:48 +0000 (10:32 +0800)]
btrfs-progs: Ignore clang complete file

While most guys are using ctags and cscope with vim, new completion tool
like vim-clang_completion is gaining its popularity, due to its compiler
level accuracy simpleness to use.

Since ctags and cscope are already in .gitignore, I see no reason to
reject .clang_complete.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: tests: switch to dump- commands from inspect
David Sterba [Wed, 26 Oct 2016 14:41:32 +0000 (16:41 +0200)]
btrfs-progs: tests: switch to dump- commands from inspect

The dump-super and debug-tree commands are replacements for the
standalone tools.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: fsck-tests: Check if clear space cache works
Qu Wenruo [Thu, 13 Oct 2016 09:22:27 +0000 (17:22 +0800)]
btrfs-progs: fsck-tests: Check if clear space cache works

Add test case to check the basic function of --clear-space-cache.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: check: add support to clear v1 free space cache
Qu Wenruo [Thu, 13 Oct 2016 09:22:26 +0000 (17:22 +0800)]
btrfs-progs: check: add support to clear v1 free space cache

Kernel clear_cache mount option will only rebuild free space cache if
the used space of that chunk has changed.

So it won't ensure any corrupted free space cache get cleared.

So add a new option "--clear-space-cache v1|v2" to btrfsck, to
completely wipe out free space cache.
So kernel won't complain again.

Reported-by: Ivan P <chrnosphered@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ adjusted error messages, doc wording changes ]
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agoBtrfs progs v4.8.2
David Sterba [Wed, 26 Oct 2016 17:43:34 +0000 (19:43 +0200)]
Btrfs progs v4.8.2

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: update CHANGES for v4.8.2
David Sterba [Mon, 24 Oct 2016 13:40:37 +0000 (15:40 +0200)]
btrfs-progs: update CHANGES for v4.8.2

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: check: release path after usage
Goldwyn Rodrigues [Mon, 24 Oct 2016 15:18:14 +0000 (10:18 -0500)]
btrfs-progs: check: release path after usage

While performing an fsck, an assertion failure occurs because of reusing path in a loop.
ctree.c:1112: btrfs_search_slot: Warning: assertion `p->nodes[0] != NULL` failed, value 0

Signed-off-by: Goldwyn Rodrigues <rgoldwyn@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: Fix wrong tree block alignment for unalianged block group
Qu Wenruo [Mon, 24 Oct 2016 07:22:33 +0000 (15:22 +0800)]
btrfs-progs: Fix wrong tree block alignment for unalianged block group

Commit 854437ca(btrfs-progs: extent-tree: avoid allocating tree block
that crosses stripe boundary) introduces check for logical bytenr not
crossing stripe boundary.

However that check is not completely correct.
It only checks if the logical bytenr and length agaist absolute logical
offset.
That's to say, it only check if a tree block lies in 64K logical stripe.

But in fact, it's possible a block group starts at bytenr unaligned with
64K, just like the following case.

Then btrfsck will give false alert.

0       32K       64K       96K        128K         160K ...
        |--------------- Block group A ---------------------
|<-----TB 32K------>|
        |/Scrub stripe unit/|
|    WRONG UNIT   |

In that case, TB(tree block) at bytenr 32K in fact fits into the kernel
scrub stripe unit.
But doesn't fit into the pure logical 64K stripe.

Fix check_crossing_stripes() to compare bytenr to block group start, not
to absolute logical bytenr.

Reported-by: Jussi Kansanen <jussi.kansanen@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: ioctl: fix build failure if BUILD_ASSERT is not defined
David Sterba [Mon, 24 Oct 2016 12:46:26 +0000 (14:46 +0200)]
btrfs-progs: ioctl: fix build failure if BUILD_ASSERT is not defined

The build fails if ioctl.h is included without kerncompat.h which
defines BUILD_ASSERT, as reported. The proposed patches add kerncompat.h
but I don't want to pull that header via ioctl.h, so the fix will
provide an empty macro instead.

Reported-by: Eric Sandeen <sandeen@redhat.com>
Reported-by: Sergei Trofimovich <slyfox@gentoo.org>
Reported-by: Mikhail Pukhlikov <cynede@gentoo.org>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: move btrfs_extref_hash() to hash.h
Lu Fengqi [Fri, 15 Jul 2016 03:00:28 +0000 (11:00 +0800)]
btrfs-progs: move btrfs_extref_hash() to hash.h

Move btrfs_extref_hash() from inode-item.c to hash.h,
so that the function can be called elsewhere.

Signed-off-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
8 years agobtrfs-progs: send: remove unnecessary code
Tsutomu Itoh [Wed, 19 Oct 2016 03:45:57 +0000 (12:45 +0900)]
btrfs-progs: send: remove unnecessary code

Some unnecessary codes are deleted.

 - the setting of subvol is duplicated
 - read only check was already done by the previous loop

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: dump-tree: fix crash on unrecognized tree id
David Sterba [Wed, 19 Oct 2016 10:38:10 +0000 (12:38 +0200)]
btrfs-progs: dump-tree: fix crash on unrecognized tree id

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: rename btrfs_scan_lblkid() to btrfs_scan_devices()
Karel Zak [Tue, 11 Nov 2014 11:35:58 +0000 (12:35 +0100)]
btrfs-progs: rename btrfs_scan_lblkid() to btrfs_scan_devices()

It seems like bad idea to use a library name (lblkid) within generic
function name. The currently used scanning library is implementation
detail and this detail should be hidden for rest of the code.

Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
8 years agobtrfs-progs: build: detect fiemap shared flag but don't fail build
David Sterba [Fri, 14 Oct 2016 16:39:40 +0000 (18:39 +0200)]
btrfs-progs: build: detect fiemap shared flag but don't fail build

The FIEMAP_EXTENT_SHARED fiemap flag was introduced in 2.6.33. If the
headers do not provide the definition, the build will fail. The support
of the fiemap sharing depends on the running kernel. There are still
systems with 2.6.32 kernel headers but running newer versions.

To support such environment, don't fail build, provide own defintion of
the structure and detect if there's an old kernel in use in the relevant
command (btrfs fi du).

Reported-by: Abhay Sachan <lkp.abhay@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: mkfs: detect version of running kernel
David Sterba [Tue, 9 Feb 2016 23:23:29 +0000 (00:23 +0100)]
btrfs-progs: mkfs: detect version of running kernel

Use the uname syscall and parse the string.

Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: volumes: Remove BUG_ON in raid56 write routine
Qu Wenruo [Tue, 25 Oct 2016 02:11:04 +0000 (10:11 +0800)]
btrfs-progs: volumes: Remove BUG_ON in raid56 write routine

Remove various BUG_ON in raid56 write routine, including:
1) Memory allocation error
   Old codes allocates memory when code needs new memory in a loop, and
   catch the error using BUG_ON().
   New codes allocates memory in a allocation loop first, if any failure
   is caught, freeing already allocated memories then throw -ENOMEM.

2) Write error
   Change BUG_ON() to correct return value.

3) Validation check
   Same as write error.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: rename raid6.c to raid56.c
Qu Wenruo [Fri, 30 Sep 2016 05:04:54 +0000 (13:04 +0800)]
btrfs-progs: rename raid6.c to raid56.c

This allows us to put raid5 codes into that file other than creating a
new raid5.c.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: test: Add image for quota verify stack overflow
Qu Wenruo [Fri, 7 Oct 2016 07:23:00 +0000 (15:23 +0800)]
btrfs-progs: test: Add image for quota verify stack overflow

For image with tree reloc tree, if its height is over level 2, the root
node's backref will point to itself.  It's valid for kernel, but quota
verify code can't handle it and cause a infinite call, overflowing the
stack.

Add minimal image to reproduce the bug, as regression test.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ minor cleanups in test.sh ]
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: test: Add test image for btrfsck qgroup rescan detection
Qu Wenruo [Fri, 7 Oct 2016 07:22:59 +0000 (15:22 +0800)]
btrfs-progs: test: Add test image for btrfsck qgroup rescan detection

Fixed by commit 7c646c538e74 btrfs-progs: qgroup: Fix regression leads
to corrupted qgroup status.

Add minimal test image for that fix.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ minor cleanups in test.sh ]
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: Fix stack overflow for checking qgroup on tree reloc tree
Qu Wenruo [Thu, 6 Oct 2016 09:13:32 +0000 (17:13 +0800)]
btrfs-progs: Fix stack overflow for checking qgroup on tree reloc tree

For tree reloc tree whose level is >= 2, the root node's parent will
point to itself.
In this case it will make btrfsck overflow its stack and cause segfault.

While for tree reloc tree, it doesn't affect qgroup and kernel can
handle it well.

So add tree reloc tree check for qgroup-verify.c and fix the bug.

Test case will follow soon after I make a minimal image for it.
Current xz ziped image is still over 10M for a 512M fs.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: image: fix compiler warning
Tsutomu Itoh [Wed, 5 Oct 2016 08:07:48 +0000 (17:07 +0900)]
btrfs-progs: image: fix compiler warning

In v4.8-rc1, gcc 5.3.1 gives following warning. Fixed it.

    [CC]     btrfs-image.o
btrfs-image.c: In function 'flush_pending':
btrfs-image.c:708:17: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]
  header->bytenr = cpu_to_le64(start);
                 ^
btrfs-image.c:927:6: note: 'start' was declared here
  u64 start;
      ^

Signed-off-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: convert-test: Add test case for common inode flags
Qu Wenruo [Mon, 10 Oct 2016 03:00:13 +0000 (11:00 +0800)]
btrfs-progs: convert-test: Add test case for common inode flags

Add a new test case to check if btrfs-convert copies common inode flags
like append(a), immutable(i).

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ minor fixes ]
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: convert: Convert ext inode flags to btrfs inode flags
Qu Wenruo [Mon, 10 Oct 2016 02:30:34 +0000 (10:30 +0800)]
btrfs-progs: convert: Convert ext inode flags to btrfs inode flags

Before this patch, btrfs-convert never copy ext* inode flags to
corresponding btrfs inode flags.

This makes common flags like APPEND/SYNC/SYNCDIR/IMMUTABLE not copied to
btrfs inode.

This patch introduces ext2_convert_inode_flags() function to handle the
convert, so btrfs-convert can copy as many inode flags as possible.

Reported-by: Lakshmipathi.G <lakshmipathi.g@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: Make btrfs-debug-tree print all readable strings for inode flags
Qu Wenruo [Mon, 10 Oct 2016 02:12:22 +0000 (10:12 +0800)]
btrfs-progs: Make btrfs-debug-tree print all readable strings for inode flags

Before this patch, only 3 inode flags have readable string: NODATACOW,
NODATASUM, READONLY.

This patch will output all readable strings for remaining inode flags,
making debug-tree tool more handy.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ minor adjustments ]
Signed-off-by: David Sterba <dsterba@suse.com>
8 years agobtrfs-progs: Copy btrfs inode flags from kernel header
Qu Wenruo [Mon, 10 Oct 2016 01:47:39 +0000 (09:47 +0800)]
btrfs-progs: Copy btrfs inode flags from kernel header

Btrfs-progs header lacks quite a lot inode flags.
Copy them from kernel for later use.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>