Commit Graph

1977 Commits

Author SHA1 Message Date
David Sterba
e99303c381 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>
2015-06-08 18:37:16 +02:00
David Sterba
60447579c4 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>
2015-06-08 17:51:59 +02:00
David Sterba
b6179c8942 btrfs-progs: mkfs: drop mixed from summary
The mixed-bg incompat feature should be enough.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-08 17:50:47 +02:00
David Sterba
d209d6fc97 btrfs-progs: mkfs, drop UUID from device summary
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-08 17:50:47 +02:00
David Sterba
e8eb7c001d btrfs-progs: mkfs, move uuid to the end of device summary
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-08 17:50:47 +02:00
Goffredo Baroncelli
3afd86683b 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>
2015-06-08 17:50:47 +02:00
Goffredo Baroncelli
23bc56c0e8 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>
2015-06-08 17:50:46 +02:00
Goffredo Baroncelli
f8a0b85e38 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>
2015-06-08 17:50:46 +02:00
Goffredo Baroncelli
b96345c7ff 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>
2015-06-08 17:50:46 +02:00
David Sterba
1bcedaae79 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>
2015-06-08 17:50:46 +02:00
David Sterba
49ac5f50b5 btrfs-progs: mkfs: move info message out of btrfs_add_to_fsid
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-08 17:50:42 +02:00
David Sterba
42a8983143 btrfs-progs: mkfs: accept mixed case for profile names
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-06 01:03:48 +02:00
David Sterba
d34f9faf60 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>
2015-06-06 01:00:18 +02:00
Jeff Mahoney
1f93b9d4ce 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>
2015-06-05 23:41:25 +02:00
Jeff Mahoney
76c38116b3 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>
2015-06-05 23:39:54 +02:00
Jeff Mahoney
7fb975abc6 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>
2015-06-05 23:34:35 +02:00
Jeff Mahoney
626fee6b3b 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>
2015-06-05 23:29:59 +02:00
Jeff Mahoney
81e43b4b76 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>
2015-06-05 23:28:44 +02:00
Jeff Mahoney
9b288f868b 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>
2015-06-05 22:01:28 +02:00
Jeff Mahoney
90d3928987 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>
2015-06-05 22:00:35 +02:00
Jeff Mahoney
bb45612e87 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>
2015-06-05 21:59:17 +02:00
Dongsheng Yang
d91f5ef091 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>
2015-06-05 18:45:21 +02:00
Dongsheng Yang
d9fd7cc0f5 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>
2015-06-05 18:40:32 +02:00
Dongsheng Yang
ea496435d5 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>
2015-06-05 18:36:55 +02:00
Dongsheng Yang
216259e0e6 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>
2015-06-05 18:35:17 +02:00
David Sterba
281be9e7d5 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>
2015-06-05 18:29:58 +02:00
David Sterba
47de682c0e 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>
2015-06-05 18:02:08 +02:00
David Sterba
567d7569d8 btrfs-progs: tests: update convert tests to set fs features
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-04 19:19:08 +02:00
David Sterba
c9b73b702b 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>
2015-06-04 19:14:54 +02:00
David Sterba
11ddfeb261 btrfs-progs: add function to stringify filesystem features
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-04 19:10:55 +02:00
David Sterba
65cc6883c0 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>
2015-06-04 16:50:15 +02:00
David Sterba
4f43aaf4aa 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>
2015-06-04 15:56:23 +02:00
David Sterba
1d46539284 btrfs-progs: ioctl.h: add btrfs_ioctl_feature_flags struct
Copied from uapi/linux/btrfs.h.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-03 19:36:36 +02:00
David Sterba
5910645a0e btrfs-progs: ioctl.h: update btrfs_ioctl_fs_info_args
Copied from uapi/linux/btrfs.h.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-03 19:35:54 +02:00
David Sterba
3e35646453 btrfs-progs: ioctl.h: update type annotations
Add the __user annotations to pointers in structures.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-03 19:33:44 +02:00
David Sterba
b648021e06 btrfs-progs: ioctl.h: add send flag mask
Copied from uapi/linux/btrfs.h.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-03 19:33:44 +02:00
David Sterba
5adf707028 btrfs-progs: ioctl.h: add EXTENT_SAME ioctl and structures
Copied from uapi/linux/btrfs.h.

Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-03 19:33:43 +02:00
David Sterba
493f979c15 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>
2015-06-03 16:40:34 +02:00
David Sterba
ddd8003d94 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>
2015-06-03 16:38:43 +02:00
David Sterba
9a6eb1f5ea 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>
2015-06-03 16:35:51 +02:00
David Sterba
e106c695bf btrfs-progs: btrfstune: make uuid rewrite progress more verbose
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-03 15:55:15 +02:00
David Sterba
551c4bb064 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>
2015-06-03 14:04:02 +02:00
David Sterba
0721c08dff btrfs-progs: doc: update btrfstune manpage
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-03 12:52:56 +02:00
David Sterba
6a4a3acbc2 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>
2015-06-03 12:52:56 +02:00
David Sterba
c476696b82 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>
2015-06-03 12:52:56 +02:00
David Sterba
d020af5235 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>
2015-06-03 12:52:56 +02:00
David Sterba
67db275e90 btrfs-progs: subvol show: print received uuid
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-03 12:52:52 +02:00
Josef Bacik
420afa3edc 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>
2015-06-02 17:35:43 +02:00
David Sterba
fa7749fdf4 btrfs-progs: update .gitignore
Signed-off-by: David Sterba <dsterba@suse.cz>
2015-06-02 17:16:47 +02:00
Anand Jain
d2d22a4f7b 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>
2015-06-02 17:15:00 +02:00