platform/upstream/btrfs-progs.git
9 years agobtrfs-progs: add helper for copying paths
David Sterba [Fri, 12 Jun 2015 14:09:33 +0000 (16:09 +0200)]
btrfs-progs: add helper for copying paths

Check the source path length and do the copy.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: receive: use static buffer for cur_subvol
David Sterba [Fri, 12 Jun 2015 13:40:07 +0000 (15:40 +0200)]
btrfs-progs: receive: use static buffer for cur_subvol

Get rid of the allocation. The logic is changed so that a NULL
cur_subvol::path means that no subvolume/snapshot has been found so far.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: properly set up ioctl arguments
David Sterba [Fri, 12 Jun 2015 12:36:51 +0000 (14:36 +0200)]
btrfs-progs: properly set up ioctl arguments

At some places we do not clear the whole ioctl structure and could
pass garbage to kernel. Zero the ioctl vol_args and use a helper for
copying the path.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: use PATH_MAX instead of BTRFS_PATH_NAME_MAX
David Sterba [Fri, 12 Jun 2015 11:18:44 +0000 (13:18 +0200)]
btrfs-progs: use PATH_MAX instead of BTRFS_PATH_NAME_MAX

The path bufferes should be PATH_MAX but BTRFS_PATH_NAME_MAX is shorter
due to embedding in 4k aligned structures.

The only reason to use BTRFS_PATH_NAME_MAX is for the respective
structures btrfs_ioctl_vol_args::name.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: send: add option to for the no-data mode
David Sterba [Fri, 12 Jun 2015 11:15:41 +0000 (13:15 +0200)]
btrfs-progs: send: add option to for the no-data mode

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: receive: implement the update_extent callback
David Sterba [Thu, 11 Jun 2015 17:31:01 +0000 (19:31 +0200)]
btrfs-progs: receive: implement the update_extent callback

The callback for the NO_FILE_DATA send flag is missing and would crash
if such stream is received.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: make receive work inside of subvolumes
Josef Bacik [Wed, 10 Jun 2015 19:05:51 +0000 (15:05 -0400)]
btrfs-progs: make receive work inside of subvolumes

Kind of a big feature of btrfs is being able to have a default subvol.  However
the receive code generates the paths to the subvols from the root of the fs,
even in the case of a default subvol.  So instead figure out if we're inside of
a subvol, either because we have a different default or we've chroot'ed and are
using -m.  Then strip this extra path off of the subvol we find so we can look
up our parent properly.  Thanks

Reported-by: Neil Horman <nhorman@redhat.com>
Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: use less memory for pretty_size_mode buffers
David Sterba [Fri, 27 Feb 2015 18:37:24 +0000 (19:37 +0100)]
btrfs-progs: use less memory for pretty_size_mode buffers

Anand reports that the static buffers used for pertty size strings cause
a stack overflow on SPARC. Zach proposed to change the printf format to
wrap the number and the suffix into a macro. This would require to
change all callsites of pretty_size* and is not very convienient to
write.

This patch replaces the per-call-site static buffers with a limited
number for slots that would be used on each invokation of pretty_size
and wrap around. The number of array slots shall be 10 for now, in
current codebase there are no more than 2 calls to pretty_size in a
single argument list.

Reported-by: Anand Jain <Anand.Jain@oracle.com>
CC: Zach Brown <zab@zabbo.net>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: print error within test_num_disk_vs_raid
David Sterba [Wed, 10 Jun 2015 22:51:15 +0000 (00:51 +0200)]
btrfs-progs: print error within test_num_disk_vs_raid

The error string buffer passed as an argument is of a fixed size, though
we could print up to PATH_MAX + something bytes. Print the error message
directly.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: print error within test_dev_for_mkfs
David Sterba [Wed, 10 Jun 2015 22:46:30 +0000 (00:46 +0200)]
btrfs-progs: print error within test_dev_for_mkfs

The error string buffer passed as an argument is of a fixed size, though
we could print up to PATH_MAX + something bytes. Print the error message
directly.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: accept --help as option in the standalone utilities
David Sterba [Wed, 10 Jun 2015 22:04:19 +0000 (00:04 +0200)]
btrfs-progs: accept --help as option in the standalone utilities

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: add missing includes to header files
David Sterba [Wed, 10 Jun 2015 00:21:42 +0000 (02:21 +0200)]
btrfs-progs: add missing includes to header files

Add includes that let the header files compile or add explicit include
of kerncompat if the uXX types are used.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: add helper to wait for subvolume cleaning
David Sterba [Wed, 8 Apr 2015 16:15:57 +0000 (18:15 +0200)]
btrfs-progs: add helper to wait for subvolume cleaning

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: subvol: let sync check only current deletions
David Sterba [Tue, 7 Apr 2015 22:28:48 +0000 (00:28 +0200)]
btrfs-progs: subvol: let sync check only current deletions

So far the subvol sync command takes a shortcut and looks if there are
any deleted subvols at all. It does not print the deleted subvolumes as
they get cleaned. Arguably this is what the user would like to see and
has to do

 $ btrfs subvol sync /path $(btrfs subvol list -d /path | "extract the ids")

to see the progress.

Make it look for all currently deleted subvolumes automatically and
print the progress as if the ids were listed manually.

This is a slight change in the semantics of the command. Previously, any
new subvol deletion would prevent subvol sync to return. To simulate the
old behaviour, run 'subvol sync' in a loop until it returns 0.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: cleanup after errors in open_file_or_dir3
David Sterba [Tue, 9 Jun 2015 13:24:51 +0000 (15:24 +0200)]
btrfs-progs: cleanup after errors in open_file_or_dir3

We should zero the dirstream in case we close it ourselves, so the
caller does not do it again. Most current callers do not do that and
exit immediatelly.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: receive: fix minor resource leak
David Sterba [Tue, 9 Jun 2015 12:58:43 +0000 (14:58 +0200)]
btrfs-progs: receive: fix minor resource leak

Resolves-coverity-id: 1302985
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: print compact help for btrfs
David Sterba [Mon, 8 Jun 2015 16:54:04 +0000 (18:54 +0200)]
btrfs-progs: print compact help for btrfs

Running 'btrfs' without arguments will print complete help that spans
a lot of lines and is really helpful. Print only subcommand group
names with short descriptions, similar to what 'git' does.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: add command group info strings
David Sterba [Tue, 9 Jun 2015 12:22:05 +0000 (14:22 +0200)]
btrfs-progs: add command group info strings

They're printed in the 'btrfs' command group summary.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: fix argv0_buf handling
David Sterba [Mon, 8 Jun 2015 21:30:21 +0000 (23:30 +0200)]
btrfs-progs: fix argv0_buf handling

The variable argv0_buf was duplicated and the changes done in utils.c
were not propagated to help.c. So if an unknown commandline token was
found, the error message did not contain the known part:

 $ btrfs scrub test
 : unknown token 'test'

instead of

 $ btrfs scrub test
 btrfs scrub: uknown token 'test'

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: remove stray deprecation notice
David Sterba [Mon, 8 Jun 2015 16:36:58 +0000 (18:36 +0200)]
btrfs-progs: remove stray deprecation notice

The 1st level balance subcommand is the right one but it accidentally
inherited the notice about 'filesystem balance' deprecation.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: mkfs: make the summary more compact
David Sterba [Mon, 8 Jun 2015 14:26:54 +0000 (16:26 +0200)]
btrfs-progs: mkfs: make the summary more compact

Single device example:

btrfs-progs v4.0.1-39
See http://btrfs.wiki.kernel.org for more information.

Label:              (null)
UUID:               a88bfc85-b454-4a32-8de7-276c01f04d58
Node size:          16384
Sector size:        4096
Filesystem size:    2.00GiB
Block group profiles:
  Data:             single            8.00MiB
  Metadata:         single            8.00MiB
  System:           single            4.00MiB
SSD detected:       no
Incompat features:  extref, skinny-metadata
Number of devices:  1
Devices:
   ID        SIZE  PATH
    1     2.00GiB  /dev/sda

Multiple devices:

btrfs-progs v4.0.1-39
See http://btrfs.wiki.kernel.org for more information.

Label:              (null)
UUID:               9db282ef-55f3-4070-a59f-012a654614b2
Node size:          16384
Sector size:        4096
Filesystem size:    8.00GiB
Block group profiles:
  Data:             RAID6           417.50MiB
  Metadata:         RAID6           417.50MiB
  System:           RAID6            20.00MiB
SSD detected:       no
Incompat features:  extref, raid56, skinny-metadata
Number of devices:  4
Devices:
   ID        SIZE  PATH
    1     2.00GiB  /dev/sda
    2     2.00GiB  /dev/sdb
    3     2.00GiB  /dev/sdc
    4     2.00GiB  /dev/sdd

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: mkfs: drop mixed from summary
David Sterba [Mon, 8 Jun 2015 13:06:17 +0000 (15:06 +0200)]
btrfs-progs: mkfs: drop mixed from summary

The mixed-bg incompat feature should be enough.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: mkfs, drop UUID from device summary
David Sterba [Mon, 2 Feb 2015 15:11:23 +0000 (16:11 +0100)]
btrfs-progs: mkfs, drop UUID from device summary

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: mkfs, move uuid to the end of device summary
David Sterba [Mon, 2 Feb 2015 15:10:10 +0000 (16:10 +0100)]
btrfs-progs: mkfs, move uuid to the end of device summary

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: mkfs: print the summary
Goffredo Baroncelli [Mon, 8 Jun 2015 11:00:50 +0000 (13:00 +0200)]
btrfs-progs: mkfs: print the summary

This patch prints the summary of the filesystem after the creation.
The main fileds printed are:
- devices list with their uuid, devid, path and size
- raid profile (dup,single,raid0...)
- leafsize/nodesize/sectorsize
- filesystem features (raid56, extref, mixed-bg)
- chunk size and type

If the '-v' switched is passed, the output is more verbose; if the '-q'
switched is passed, only the errors are printed.

Below an example:

BTRFS filesystem summary:
  Label:                btrfs-test
  UUID:                 14ae8a88-98ac-4f22-8441-79f76ec622f7

  Node size:            4096
  Leaf size:            4096
  Sector size:          4096
  Initial chunks:
    Data+Metadata:      9.01GiB
    System:             18.06MiB
  Metadata profile:     RAID5
  Data profile:         RAID5
  Mixed mode:           YES
  SSD detected:         NO
  Incompat features:    mixed-bg, extref, raid56
  Number of devices:    10
    UUID                                  ID    SIZE    PATH
    ------------------------------------  --  --------- -----------
    df1c7f50-1980-4da2-8bc9-7ee6ffb0b554   1   50.00GiB /dev/vdb
    32c808a0-cd7b-4497-a2c0-1d77a9854af9   2   50.00GiB /dev/vdc
    3159782e-d108-40bc-9e15-090ecac160b4   3   50.00GiB /dev/vdd
    db7eaf0c-beb8-4093-a9d0-b9c25c146305   4   50.00GiB /dev/vde
    c367ca04-1f71-49c0-a331-11fc0b87e9fc   5   50.00GiB /dev/vdf
    e9b73c86-4058-4b3a-90ac-18741a276e70   6   50.00GiB /dev/vdg
    c4298b7a-ad41-4690-bf10-bf748b319413   7   50.00GiB /dev/vdh
    1cf048c8-af8a-4225-b09a-5d12e9b217fa   8    2.00GiB /dev/vdi
    7e157869-768a-4725-bad5-82e6bd05fd17   9    2.00GiB /dev/vdj
    2c9431ac-c7f0-45a5-8529-cef8cf6e4033  10    2.00GiB /dev/vdk

  Total devices size:                         356.01GiB

Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: mkfs: track sizes of created block groups
Goffredo Baroncelli [Mon, 8 Jun 2015 10:54:54 +0000 (12:54 +0200)]
btrfs-progs: mkfs: track sizes of created block groups

Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: return the fsid from make_btrfs()
Goffredo Baroncelli [Wed, 17 Dec 2014 20:14:09 +0000 (21:14 +0100)]
btrfs-progs: return the fsid from make_btrfs()

The function make_btrfs() has as argument the fsid of the filesystem.
If this fsid is empty or null make_btrfs() generates a new fsid. However
If the buffer is valid (but the string is empty) the generated fsid is
copied back to the caller.

Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: add strdup in btrfs_add_to_fsid() to track the device path
Goffredo Baroncelli [Wed, 17 Dec 2014 20:14:08 +0000 (21:14 +0100)]
btrfs-progs: add strdup in btrfs_add_to_fsid() to track the device path

When creating a new btrfs_device, copy the path to track it.  This path
is then used by mkfs.btrfs to list all devices.

Signed-off-by: Goffredo Baroncelli <kreijack@inwind.it>
Reviewed-by: Satoru Takeuchi <takeuchi_satoru@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: mkfs: do not try to register non-block-devices
David Sterba [Sat, 6 Jun 2015 00:17:13 +0000 (02:17 +0200)]
btrfs-progs: mkfs: do not try to register non-block-devices

A mkfs on a regular file will try to call the DEV_SCAN ioctl that will
take the loop through the kernel and fail:

 ERROR: device scan failed './test.img' - Block device required

If a user without permission to open the control device tries to mkfs a
regular file, an error message is printed:

 failed to open /dev/btrfs-control skipping device registration: Permission denied

So we should not try to pass a non-block-device besides that this makes
the --quiet option more quiet.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: mkfs: move info message out of btrfs_add_to_fsid
David Sterba [Fri, 5 Jun 2015 23:39:26 +0000 (01:39 +0200)]
btrfs-progs: mkfs: move info message out of btrfs_add_to_fsid

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: mkfs: accept mixed case for profile names
David Sterba [Fri, 5 Jun 2015 23:03:48 +0000 (01:03 +0200)]
btrfs-progs: mkfs: accept mixed case for profile names

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: mkfs: add option to make it quiet
David Sterba [Wed, 17 Dec 2014 20:14:05 +0000 (21:14 +0100)]
btrfs-progs: mkfs: add option to make it quiet

Add option to silecne mkfs and print only errors, warnings or info on
user request like features or help.

Based on patch from Goffredo Baroncelli <kreijack@inwind.it>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: convert: factor out block iteration callback
Jeff Mahoney [Fri, 5 Jun 2015 21:41:09 +0000 (23:41 +0200)]
btrfs-progs: convert: factor out block iteration callback

block_iterate_proc uses the libext2fs error return codes when it doesn't
need them to return the error. We can push this out to __block_iterate_proc
and allow the reiserfs converter to share the code.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: convert: factor out adding dirent into convert_insert_dirent
Jeff Mahoney [Fri, 5 Jun 2015 21:37:11 +0000 (23:37 +0200)]
btrfs-progs: convert: factor out adding dirent into convert_insert_dirent

Adding a dirent consists of multiple steps that will need to be taken by
any converter.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: convert: fix typo in btrfs_insert_dir_item call
Jeff Mahoney [Fri, 5 Jun 2015 21:34:29 +0000 (23:34 +0200)]
btrfs-progs: convert: fix typo in btrfs_insert_dir_item call

EXT2_FT_REG_FILE and BTRFS_FT_REG_FILE happen to share the same value, but
btrfs_insert_dir_item expects the btrfs version.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: compat: define DIV_ROUND_UP if not already defined
Jeff Mahoney [Wed, 14 Aug 2013 18:21:54 +0000 (14:21 -0400)]
btrfs-progs: compat: define DIV_ROUND_UP if not already defined

DIV_ROUND_UP may not be defined, so define it if it's not already.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: convert: rename ext2_root to image_root
Jeff Mahoney [Wed, 14 Aug 2013 17:44:21 +0000 (13:44 -0400)]
btrfs-progs: convert: rename ext2_root to image_root

In preparation to extend to other file systems, rename ext2_root to
image_root.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: convert: remove unused inode_key in copy_single_inode
Jeff Mahoney [Fri, 16 Aug 2013 14:39:27 +0000 (10:39 -0400)]
btrfs-progs: convert: remove unused inode_key in copy_single_inode

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: convert: remove unused fs argument from block_iterate_proc
Jeff Mahoney [Fri, 16 Aug 2013 01:30:05 +0000 (21:30 -0400)]
btrfs-progs: convert: remove unused fs argument from block_iterate_proc

The fs argument is unused, so let's not pass it.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: convert: clean up blk_iterate_data handling wrt record_file_blocks
Jeff Mahoney [Wed, 14 Aug 2013 04:25:59 +0000 (00:25 -0400)]
btrfs-progs: convert: clean up blk_iterate_data handling wrt record_file_blocks

Hand off initialization of blk_iterate_data to init_blk_iterate_data and
pass the structure when the elements are the only values passed anyway.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: qgroup limit: add a check for invalid input of 'T/G/M/K'
Dongsheng Yang [Wed, 3 Jun 2015 09:27:04 +0000 (17:27 +0800)]
btrfs-progs: qgroup limit: add a check for invalid input of 'T/G/M/K'

Add a check to error out in the following case:

 # ./btrfs qgroup limit  T /mnt/
Invalid size argument given

Without this patch, btrfs-progs would parse the input as 0
and continue.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: qgroup limit: error out if input value is negative
Dongsheng Yang [Wed, 3 Jun 2015 09:27:03 +0000 (17:27 +0800)]
btrfs-progs: qgroup limit: error out if input value is negative

If we pass a negative value to command qgroup limit, btrfs-progs
would convert it to unsigned long long silently. That's a little
confusing to user, why I can limit my quota to a negative value.

This patch add a check in parse_limit, if the input value is negative,
error out to user.

Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: qgroup: allow user to clear some limitation on qgroup.
Dongsheng Yang [Wed, 3 Jun 2015 06:57:33 +0000 (14:57 +0800)]
btrfs-progs: qgroup: allow user to clear some limitation on qgroup.

Currently, we can not clear a limitation on a qgroup. Although
there is a 'none' choice provided to user to do it, it does not
work well.

It does not set the flag which user want to clear, then kernel
will never know what the user want to do at all.

*Without this commit*
 # ./btrfs qgroup show -re /mnt
qgroupid         rfer         excl     max_rfer     max_excl
--------         ----         ----     --------     --------
0/5           2.19GiB      2.19GiB      5.00GiB         none
0/257       100.02MiB    100.02MiB         none         none
 # ./btrfs qgroup limit none /mnt
 # ./btrfs qgroup show -re /mnt
qgroupid         rfer         excl     max_rfer     max_excl
--------         ----         ----     --------     --------
0/5           2.19GiB      2.19GiB      5.00GiB         none
0/257       100.02MiB    100.02MiB         none         none

This patch will set the flag user want to clear and pass a
size=-1 to kernel. Then kernel will clear it correctly.

*With this commit*
 # ./btrfs qgroup show -re /mnt
qgroupid         rfer         excl     max_rfer     max_excl
--------         ----         ----     --------     --------
0/5           2.19GiB      2.19GiB      5.00GiB         none
0/257       100.02MiB    100.02MiB         none         none
 # ./btrfs qgroup limit none /mnt
 # ./btrfs qgroup show -re /mnt
qgroupid         rfer         excl     max_rfer     max_excl
--------         ----         ----     --------     --------
0/5           2.19GiB      2.19GiB         none         none
0/257       100.02MiB    100.02MiB         none         none

Reported-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Tested-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: qgroup: show 'none' when we did not limit it on this qgroup
Dongsheng Yang [Wed, 3 Jun 2015 06:57:31 +0000 (14:57 +0800)]
btrfs-progs: qgroup: show 'none' when we did not limit it on this qgroup

There are two understanding of the '0' value in btrfs qgroup show.
(1) is no-limitation on this qgroup. (2) is the max-limitation is 0.

This patch make it showing in different way.

(1) max-limitation for 0 is still showing '0'.
(2) no-limitation will show 'none'.

qgroupid         rfer         excl     max_rfer     max_excl parent
--------         ----         ----     --------     -------- ------
0/5           2.19GiB      2.19GiB         none         none ---
0/257       100.02MiB    100.02MiB         none         none ---

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Tested-by: Tsutomu Itoh <t-itoh@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: tests: add test for zero-log
David Sterba [Fri, 5 Jun 2015 16:26:32 +0000 (18:26 +0200)]
btrfs-progs: tests: add test for zero-log

Simple test to verify that the log_root is reset after the command, but
we yet need to provide a testing image with log_root set to something
sensible or crafted images with borked log_root pointer.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: cleanup and deprecate btrfs-zero-log
David Sterba [Fri, 5 Jun 2015 16:02:08 +0000 (18:02 +0200)]
btrfs-progs: cleanup and deprecate btrfs-zero-log

Sync with the 'rescue zero-log' code, add a warning about deprecation.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: tests: update convert tests to set fs features
David Sterba [Thu, 4 Jun 2015 17:09:52 +0000 (19:09 +0200)]
btrfs-progs: tests: update convert tests to set fs features

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: convert: allow to set filesystem features
David Sterba [Mon, 23 Mar 2015 18:31:31 +0000 (19:31 +0100)]
btrfs-progs: convert: allow to set filesystem features

Curretnly there are no features set for the converted filesystem and
it's not possible to request it like in mkfs.

Add new option -O|--features, use -O list-all to show all that are
supported for convert.

Note: from now on, convert without any -O option will use the same
defaults as mkfs. The original behaviour was rather confusing.

Convert is now more verbose about the parameters of the btrfs filesytem.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: add function to stringify filesystem features
David Sterba [Thu, 4 Jun 2015 17:08:15 +0000 (19:08 +0200)]
btrfs-progs: add function to stringify filesystem features

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: scrub: more friendly duration format in status
David Sterba [Thu, 4 Jun 2015 14:49:00 +0000 (16:49 +0200)]
btrfs-progs: scrub: more friendly duration format in status

scrub status for d4dc0da9-e8cc-4bfe-9b6f-2dcf8e0754f5
scrub started at Sat Jan  1 00:00:01 UTC 2000 and finished after 00:43:05
total bytes scrubbed: 111.17GiB with 0 errors

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: doc: update btrfs-rescue page and drop btrfs-zero-log
David Sterba [Thu, 4 Jun 2015 13:54:22 +0000 (15:54 +0200)]
btrfs-progs: doc: update btrfs-rescue page and drop btrfs-zero-log

- fix page title
- update zero-log text
- delete btrfs-zero-log.asciidoc as page is not shipped anymore

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: ioctl.h: add btrfs_ioctl_feature_flags struct
David Sterba [Wed, 3 Jun 2015 17:36:36 +0000 (19:36 +0200)]
btrfs-progs: ioctl.h: add btrfs_ioctl_feature_flags struct

Copied from uapi/linux/btrfs.h.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: ioctl.h: update btrfs_ioctl_fs_info_args
David Sterba [Wed, 3 Jun 2015 17:35:54 +0000 (19:35 +0200)]
btrfs-progs: ioctl.h: update btrfs_ioctl_fs_info_args

Copied from uapi/linux/btrfs.h.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: ioctl.h: update type annotations
David Sterba [Wed, 3 Jun 2015 14:52:05 +0000 (16:52 +0200)]
btrfs-progs: ioctl.h: update type annotations

Add the __user annotations to pointers in structures.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: ioctl.h: add send flag mask
David Sterba [Wed, 3 Jun 2015 14:51:34 +0000 (16:51 +0200)]
btrfs-progs: ioctl.h: add send flag mask

Copied from uapi/linux/btrfs.h.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: ioctl.h: add EXTENT_SAME ioctl and structures
David Sterba [Wed, 3 Jun 2015 14:42:51 +0000 (16:42 +0200)]
btrfs-progs: ioctl.h: add EXTENT_SAME ioctl and structures

Copied from uapi/linux/btrfs.h.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: ioctl.h: copy commented version of balance structures
David Sterba [Wed, 3 Jun 2015 14:40:34 +0000 (16:40 +0200)]
btrfs-progs: ioctl.h: copy commented version of balance structures

Copied from uapi/linux/btrfs.h, no-op change.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: ioctl.h: copy commented version of scrub_progress structure
David Sterba [Wed, 3 Jun 2015 14:37:50 +0000 (16:37 +0200)]
btrfs-progs: ioctl.h: copy commented version of scrub_progress structure

Copied from uapi/linux/btrfs.h, no-op change.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: ioctl.h: reorder to match kernel uapi header
David Sterba [Wed, 3 Jun 2015 14:35:51 +0000 (16:35 +0200)]
btrfs-progs: ioctl.h: reorder to match kernel uapi header

This is a no-op change, move the code that also exists in the
uapi/linux/btrfs.h header.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: btrfstune: make uuid rewrite progress more verbose
David Sterba [Wed, 3 Jun 2015 13:24:56 +0000 (15:24 +0200)]
btrfs-progs: btrfstune: make uuid rewrite progress more verbose

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: tests: add misc tests for uuid rewrite
David Sterba [Wed, 3 Jun 2015 11:59:55 +0000 (13:59 +0200)]
btrfs-progs: tests: add misc tests for uuid rewrite

Simple tests of the -u/-U options of btrfstune.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: doc: update btrfstune manpage
David Sterba [Tue, 2 Jun 2015 17:34:40 +0000 (19:34 +0200)]
btrfs-progs: doc: update btrfstune manpage

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: btrfstune: add option to enable NO_HOLES
David Sterba [Tue, 2 Jun 2015 16:41:01 +0000 (18:41 +0200)]
btrfs-progs: btrfstune: add option to enable NO_HOLES

New option -n to enable the NO_HOLES feature.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: btrfstune: rework option handling
David Sterba [Tue, 2 Jun 2015 16:24:33 +0000 (18:24 +0200)]
btrfs-progs: btrfstune: rework option handling

Simplify the code, gather the incompat flag bits and set them at once.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: subvol show: tweak output
David Sterba [Tue, 2 Jun 2015 15:57:56 +0000 (17:57 +0200)]
btrfs-progs: subvol show: tweak output

- capitalize UUID
- print otime with timezone
- rename 'Object ID' to 'Subvolume ID'
- add ID to Parent and Top level

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: subvol show: print received uuid
David Sterba [Tue, 2 Jun 2015 15:48:32 +0000 (17:48 +0200)]
btrfs-progs: subvol show: print received uuid

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: specify mountpoint for recieve
Josef Bacik [Wed, 27 May 2015 17:51:29 +0000 (13:51 -0400)]
btrfs-progs: specify mountpoint for recieve

In a chroot environment we may not have /proc mounted, which makes btrfs receive
freak out since it wants to know the base directory where are are mounted for
things like clone and such.  Give an option to specify where the mountpoint is
in these cases so you can still do a btrfs receive in a chroot.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
[added manpage documentation]
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: update .gitignore
David Sterba [Tue, 2 Jun 2015 15:16:47 +0000 (17:16 +0200)]
btrfs-progs: update .gitignore

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: use function is_block_device() instead
Anand Jain [Mon, 1 Jun 2015 06:25:18 +0000 (14:25 +0800)]
btrfs-progs: use function is_block_device() instead

Here the delete code as below, is trying to check if the provided device
is a block device, there is a function for it. Use it.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: mkfs: check metadata redundancy
Sam Tygier [Sat, 30 May 2015 14:54:48 +0000 (15:54 +0100)]
btrfs-progs: mkfs: check metadata redundancy

Currently BTRFS allows you to make bad choices of data and
metadata levels. For example -d raid1 -m raid0 means you can
only use half your total disk space, but will lose everything
if 1 disk fails. It should give a warning in these cases.

When making a filesystem, check that metadata mode is at least
as redundant as the data mode. For example give warning when:

-d raid1 -m raid0

Signed-off-by: Sam Tygier <samtygier@yahoo.co.uk>
[make the check more visible in mkfs output]
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: tests: add misc test for fs features
David Sterba [Tue, 2 Jun 2015 14:37:20 +0000 (16:37 +0200)]
btrfs-progs: tests: add misc test for fs features

A sample test for the misc-test category. Verify that btrfstune sets the
requested fs features. Now implemented extrefs, skinny-metadata and
seeding.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: tests: common: add helper run_check_stdout
David Sterba [Tue, 2 Jun 2015 13:57:51 +0000 (15:57 +0200)]
btrfs-progs: tests: common: add helper run_check_stdout

Sometimes we need to process the output of the command, but run_check
captures all the output into results file.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: tests: add driver script for misc tests
David Sterba [Tue, 2 Jun 2015 13:00:32 +0000 (15:00 +0200)]
btrfs-progs: tests: add driver script for misc tests

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: add info about list-all to the help
Anand Jain [Mon, 1 Jun 2015 06:20:24 +0000 (14:20 +0800)]
btrfs-progs: add info about list-all to the help

mkfs.btrfs -O list-all is a good options to list features,
publish it in the help.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: receive: restore capabilities after chown
David Sterba [Wed, 27 May 2015 16:29:57 +0000 (18:29 +0200)]
btrfs-progs: receive: restore capabilities after chown

Capabilities are cleared after chown, and the btrfs-stream encodes the
CHOWN command after any SET_XATTR command. So the capabilites are not
always preserved.

This could be fixed in kernel to emit the instructions in the right
order, but fix in userspace will make it work for older kernels.

If we see the capabilities among xattrs, cache the value and apply it
again in case it's followed by chown on that file.

Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=68891
Reported-by: Juan Orti Alcaine <j.orti.alcaine@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: btrfstune: fix a bug which makes unfinished fsid change unrecoverable
Qu Wenruo [Fri, 15 May 2015 06:36:35 +0000 (14:36 +0800)]
btrfs-progs: btrfstune: fix a bug which makes unfinished fsid change unrecoverable

This bug is found by making break point after change_fsid_prepare() and
then kill the unfinished change, then try to restore the unfinished fsid
change.

If fsid change is canceled, open_ctree will still fail even with
IGNORE_FSID_MIMATCH open ctree flag, since it can't find device with
mismatched fsid, making it unable to restoring.

Now add ignore_fsid_mismatch judgment in btrfs_find_device() to fix the
bug and allow later restore to work as expected.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Documentation: uuid change
Qu Wenruo [Fri, 15 May 2015 06:28:26 +0000 (14:28 +0800)]
btrfs-progs: Documentation: uuid change

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[updated wodring]
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: btrfstune: add '-U' and '-u' option to change fsid
Qu Wenruo [Fri, 15 May 2015 06:28:25 +0000 (14:28 +0800)]
btrfs-progs: btrfstune: add '-U' and '-u' option to change fsid

Add two options, '-U' and '-u' for btrfstune.

For '-u', it is used to change fsid to a random new UUID.
For '-U', it is used to change fsid to a specified UUID.

Both will also change the internal use only chunk_tree_uuid to a random
new UUID.

Although there is a GNU getopt extension "::" to get optional
option-argument, but is forbidden by POSIX.1-2008, so use split options
here.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: btrfstune: add ability to restore unfinished fsid change
Qu Wenruo [Fri, 15 May 2015 06:28:24 +0000 (14:28 +0800)]
btrfs-progs: btrfstune: add ability to restore unfinished fsid change

Now change_uuid() can auto detected unfinished fsid change and restore
it.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: btrfstune: rework change_uuid
Qu Wenruo [Fri, 15 May 2015 06:28:23 +0000 (14:28 +0800)]
btrfs-progs: btrfstune: rework change_uuid

Change the change_uuid():
1) Remove new_chunk_tree_uuid parameter
   As chunk_tree_uuid is only internal used, no need to manual specify it.
   Use random generated UUID instead.

2) Don't use heap allocated memory for fs_info->new_fsid/chunk_tree_id.
   It's easy to forgot free or double free heap memory.
   Use stack memory instead.
   (In fact, I forgot to free them in previous patchset)

3) Print destination fsid.
   As now it's possible to change fsid to random uuid, it's better to print
   it out.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agoBtrfs-progs: corrupt-block: add the ability to remove csums
Josef Bacik [Tue, 19 May 2015 14:21:04 +0000 (10:21 -0400)]
Btrfs-progs: corrupt-block: add the ability to remove csums

Sometimes we need to test what happens when we're missing a csum for a range, so
add an option to btrfs-corrupt-block to be able to remove a csum range.  Thanks,

Signed-off-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: use openat for process_clone in receive
Emil Karlson [Thu, 21 May 2015 15:42:29 +0000 (18:42 +0300)]
btrfs-progs: use openat for process_clone in receive

This will fix breakage, when doing chrooted receive with cloned paths
outside main subvolume.

Steps to reproduce:
 $ create subvolume
 $ create file
 $ snapshot to snap1
 $ delete file
 $ snapshot to snap2
 $ reflink file from snap1
 $ snapsthot to snap3

 $ send full snap1 | receive --chroot
 $ send incremental snap2 | receive --chroot
 $ send incremental snap3 | receive --chroot

The last step would fail with:

 Chroot to /mnt/recvdir
 At snapshot snap3
 ERROR: failed to open /recvdir/snap1/file. No such file or directory

Signed-off-by: Emil Karlson <jekarlson@gmail.com>
[added reproducer]
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: tests: add script to clean intermediate images
David Sterba [Mon, 25 May 2015 14:08:46 +0000 (16:08 +0200)]
btrfs-progs: tests: add script to clean intermediate images

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: test: 015-check-bad-memory-access
David Sterba [Mon, 25 May 2015 13:39:29 +0000 (15:39 +0200)]
btrfs-progs: test: 015-check-bad-memory-access

Crafted images may trigger out-of-bounds access during check, fixed by
"btrfs-progs: Enhance read_tree_block to avoid memory corruption"

Now adding image for the first one, the other need enhancements in the
testing framework.

Reference: https://bugzilla.kernel.org/show_bug.cgi?id=97171
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=97191
Reference: https://bugzilla.kernel.org/show_bug.cgi?id=97271
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: tests: sort image files
David Sterba [Mon, 25 May 2015 13:35:58 +0000 (15:35 +0200)]
btrfs-progs: tests: sort image files

If a test has several images let filenames enforce a particular order of
checks if desired.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Enhance read_tree_block to avoid memory corruption
Qu Wenruo [Fri, 22 May 2015 01:01:23 +0000 (09:01 +0800)]
btrfs-progs: Enhance read_tree_block to avoid memory corruption

Add the following tree block check to avoid memory corruption on hostile
image:
1) Check level.
Level >= BTRFS_MAX_LEVEL won't be read out.

2) Nritems.
For nr_items > max_nritems, the tree_block won't be read out.
Max nritems is calculated in a easy method.
For node, it's straightforward, just (nodesize - header size) /
(btrfs_key_ptr)
For leaf, (nodesize - header size) / (btrfs_item), as btrfs support zero
item size

This fixes 3 kernel bugs: BZ#97171, BZ#97191, BZ#97271.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: tests: use readlink -f to resolve path
David Sterba [Thu, 21 May 2015 16:48:55 +0000 (18:48 +0200)]
btrfs-progs: tests: use readlink -f to resolve path

The utility 'realpath' from coreutils is new enough to be missing on my
"old" reference build host.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: fsck.btrfs: Fix bashism and bad getopts processing
Dimitri John Ledkov [Thu, 21 May 2015 12:50:55 +0000 (13:50 +0100)]
btrfs-progs: fsck.btrfs: Fix bashism and bad getopts processing

First fix == bashism, as that is not accepted by e.g. Debian/Ubuntu
dash.

Secondly shift OPTIND, such that last parameter is checked to exist.

Signed-off-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: tests: support more formats of test images
David Sterba [Thu, 21 May 2015 14:33:16 +0000 (16:33 +0200)]
btrfs-progs: tests: support more formats of test images

We're using he meta-dump images, now we support compressed meta-dump,
raw and compressed raw images.

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: tests: log the test name in results file
David Sterba [Thu, 21 May 2015 13:04:29 +0000 (15:04 +0200)]
btrfs-progs: tests: log the test name in results file

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agoBtrfs progs v4.0.1
David Sterba [Wed, 20 May 2015 13:12:44 +0000 (15:12 +0200)]
Btrfs progs v4.0.1

Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Fix a bug in chunk item extra check and allow degraded chunk.
Qu Wenruo [Fri, 15 May 2015 05:11:14 +0000 (13:11 +0800)]
btrfs-progs: Fix a bug in chunk item extra check and allow degraded chunk.

For DUP profile, the num_stripes should be 2 not 1.
This causes btrfs offline tool fails on valid image.

Also, num_stripes check is too restrict for btrfsck self test,
as there is some image in degraded mode, so modify it to allow degraded
chunk.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Add extra chunk item check to avoid btrfs-progs crash.
Qu Wenruo [Wed, 13 May 2015 09:15:36 +0000 (17:15 +0800)]
btrfs-progs: Add extra chunk item check to avoid btrfs-progs crash.

Adds extra check when reading a chunk item:
1) Check chunk type.
Don't allow any unsupported type/profile bit.

2) Check num_stripes
Any chunk item should contain at least one stripe.
For system chunk, the chunk item size(calculated by btrfs_stripe size *
(num_stripes - 1) + btrfs_chunk size) should not exceed
BTRFS_SYSTEM_CHUNK_SIZE(2048).
For normal chunk, the chunk item size(calculated) should match the chunk
item size.

3) Check num_stripes/sub_stripes against chunk profile.
Num_stripes/sub_stripes must meet its lower limit for its chunk profile.

Reported-by: Lukas Lueg <lukas.lueg@gmail.com>
Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Remove non-exist csum size.
Qu Wenruo [Wed, 13 May 2015 09:15:33 +0000 (17:15 +0800)]
btrfs-progs: Remove non-exist csum size.

Current btrfs only support CRC32 as checksum algorithm.
But in btrfs_csum_sizes array, we have an extra 0 at tail, causing
csum_type 1 can still be considered as supported csum type.

Fix it by removing the tailing 0.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Introduce change_uuid function
Qu Wenruo [Wed, 13 May 2015 14:42:21 +0000 (16:42 +0200)]
btrfs-progs: Introduce change_uuid function

This function does all the needed things for changing filesystem uuid.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Introduce change_fsid_prepare and change_fsid_done functions
Qu Wenruo [Wed, 13 May 2015 14:41:51 +0000 (16:41 +0200)]
btrfs-progs: Introduce change_fsid_prepare and change_fsid_done functions

These two functions will write flags to all supers before and after
fsid/chunk tree id change, informing kernel not to mount a inconsistent
fs.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[removed chunk tree super flag]
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Introduce change_devices_uuid function.
Qu Wenruo [Mon, 11 May 2015 08:08:50 +0000 (16:08 +0800)]
btrfs-progs: Introduce change_devices_uuid function.

This function will change all device items' fsid.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Introduce change_device_uuid function
Qu Wenruo [Mon, 11 May 2015 08:08:49 +0000 (16:08 +0800)]
btrfs-progs: Introduce change_device_uuid function

This function changes a device items uuid.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Introduce change_extents_uuid function
Qu Wenruo [Mon, 11 May 2015 08:08:48 +0000 (16:08 +0800)]
btrfs-progs: Introduce change_extents_uuid function

This is the function which iterates all metadata extents and changes
their fsid.

This function also does it without transaction.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.cz>
9 years agobtrfs-progs: Introduce change_header_uuid function
Qu Wenruo [Mon, 11 May 2015 08:08:47 +0000 (16:08 +0800)]
btrfs-progs: Introduce change_header_uuid function

This function is used to change fsid and chunk_tree_uuid of a node/leaf.
The function does it without transaction protection.

This is the basis of offline uuid change.

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