Commit Graph

4414 Commits (2cd4a76ea9914c35b0fb614ad68aa9aefd7e5dd7)
 

Author SHA1 Message Date
Josh Soref 2cd4a76ea9 btrfs-progs: fix typos in user-visible strings
* error messages
* help strings

Generated by https://github.com/jsoref/spelling

Issue: #154
Author: Josh Soref <jsoref@users.noreply.github.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 18:24:49 +01:00
Josh Soref b1d39a42a4 btrfs-progs: fix typos in comments
Generated by https://github.com/jsoref/spelling

Issue: #154
Author: Josh Soref <jsoref@users.noreply.github.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 18:24:48 +01:00
Josh Soref 584749488a btrfs-progs: tests: fsck/025, fix typo in helpre name
Generated by https://github.com/jsoref/spelling

Issue: #154
Author: Josh Soref <jsoref@users.noreply.github.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 17:54:19 +01:00
Josh Soref 0509c05ae6 btrfs-progs: tests: fix typos in test comments
Generated by https://github.com/jsoref/spelling

Issue: #154
Author: Josh Soref <jsoref@users.noreply.github.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 17:53:43 +01:00
Josh Soref bc72922789 btrfs-progs: fix typos in Makefile
Besides the comments, there's a slight change as the file config.log
will be deleted by the 'clean-gen' rule.

Generated by https://github.com/jsoref/spelling

Issue: #154
Author: Josh Soref <jsoref@users.noreply.github.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 17:48:04 +01:00
Josh Soref 2e67bf0ed6 btrfs-progs: docs: fix typos in READMEs, INSTALL and CHANGES
Generated by https://github.com/jsoref/spelling

Issue: #154
Author: Josh Soref <jsoref@users.noreply.github.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 17:47:22 +01:00
Josh Soref f0cdb2c9fb btrfs-progs: docs: fix typos in Documentation
Generated by https://github.com/jsoref/spelling

Issue: #154
Author: Josh Soref <jsoref@users.noreply.github.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 17:32:10 +01:00
David Sterba fae4b632f5 btrfs-progs: tests: pull zstd version 1.3.7 to the travis CI
There's a newer version of zstd, without any obvious changes that would
affect our build testing coverage.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 17:26:51 +01:00
David Sterba b558bed40c btrfs-progs: link to libbtrfsutil/README from the main README
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 16:53:13 +01:00
Omar Sandoval f9dc5d5dfd libbtrfsutil: document API in README
btrfsutil.h and the Python docstrings are thorough, but I've gotten a
couple of requests for a high-level overview of the available interfaces
and example usages. Add them to README.md.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 16:49:09 +01:00
Omar Sandoval e2b1758937 libbtrfsutil: bump version to 1.1.0
With the previous few fixes and features, we should bump the minor
version.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 16:45:37 +01:00
Omar Sandoval 2a74c0e4ee libbtrfsutil: relax the privileges of subvolume iterator
We can use the new BTRFS_IOC_GET_SUBVOL_ROOTREF and
BTRFS_IOC_INO_LOOKUP_USER ioctls to allow non-root users to list
subvolumes.

This is based on a patch from Misono Tomohiro but takes a different
approach (mainly, this approach is more similar to the existing tree
search approach).

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 16:45:34 +01:00
Omar Sandoval bfe2dc3796 libbtrfsutil: relax the privileges of subvolume_info()
Attempt to use the BTRFS_IOC_GET_SUBVOL_INFO ioctl (added in kernel
4.18) for subvolume_info() if not root. Also, rename
get_subvolume_info_root() -> get_subvolume_info_privileged() for
consistency with further changes.

This is based on a patch from Misono Tomohiro.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 16:45:30 +01:00
Omar Sandoval 39ac43a2a4 libbtrfsutil: allow tests to create multiple Btrfs instances
Some upcoming tests will need to create a second Btrfs filesystem, so
add support for this to the test helpers.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 16:45:28 +01:00
Omar Sandoval fee45d5421 libbtrfsutil: add test helpers for dropping privileges
These will be used for testing some upcoming changes which allow
unprivileged operations.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 16:45:24 +01:00
Omar Sandoval 70126a1570 libbtrfsutil: use SubvolumeIterator as context manager in tests
We're leaking file descriptors, which makes it impossible to clean up
the temporary mount point created by the test.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 16:45:22 +01:00
Omar Sandoval c62625046a libbtrfsutil: document qgroup_inherit parameter in Python bindings
This has been supported since day one, but it wasn't documented.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 16:45:18 +01:00
Omar Sandoval 5776a70b30 libbtrfsutil: change async parameters to async_ in Python bindings
async became a keyword in Python 3.7, so, e.g., create_subvolume('foo',
async=True) is now a syntax error. Fix it with the Python convention of
adding a trailing underscore to the keyword (async -> async_). This is
what several other Python libraries did to handle this.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 16:45:14 +01:00
Omar Sandoval 563affcd42 libbtrfsutil: use top=0 as default for SubvolumeIterator()
Right now, we're defaulting to top=5 (i.e, all subvolumes). The
documented default is top=0 (i.e, only beneath the given path). This is
the expected behavior. Fix it and make the test cases cover it.

Reported-by: Jonathan Lemon <bsd@fb.com>
Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-26 16:45:11 +01:00
David Sterba 5d64c40240 btrfs-progs: docs: fix rendering of exponents in manual pages
Reported on IRC that the inode number limit appears to be 264, while the
actual value is 2^64. Fix that for the manual page backend by redefining
the format.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-20 11:16:02 +01:00
David Sterba e101cf8c31 btrfs-progs: README: add link to INSTALL
Make clickable and more visible in the formatted text.

Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-13 13:40:21 +01:00
David Sterba d96671ae54 btrfs-progs: kerncompat: rename swap to __swap
The 'swap' is too generic and clashes with some userspace tools that
compile against btrfs, eg. snapper when including
boost::smart_ptr::scoped_array after kerncompat.h:

  /usr/include/boost/smart_ptr/scoped_array.hpp:127:13: error: macro "swap" requires 2 arguments, but only 1 given
  a.swap(b);

Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-13 13:33:15 +01:00
Rosen Penev 01e35d9f53 btrfs-progs: treewide: Fix missing declarations
Found using -Wmissing-prototypes in GCC.  This should improve LTO
behavior.

Note that set_free_space_tree_thresholds is an unused function. Adding
inline seems to remove the unused function warning.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-13 13:32:41 +01:00
Rosen Penev 803c916907 btrfs-progs: task-utils: Fix comparison between pointer and integer
pthread_t is an opaque type, not an integer one. The > 0 makes no sense
and compiler throws a warning.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-13 13:22:19 +01:00
Rosen Penev ed570e2df3 btrfs-progs: kernel-lib: bitops: Fix big endian compilation
Replaced bswap with _ variants bswap_32 etc. While it's a glibc
extension, all of the popular libc implementations (glibc, uClibc, musl,
BIONIC) seem to support it.

Added static inline to two functions to match little endian variants. This
fixes a linking error experienced when compiling on gcc 7.3.0 with LTO,
possibly a bug that was fixed later.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-13 13:20:41 +01:00
David Sterba d72d913291
Btrfs progs v4.19
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-03 11:06:34 +01:00
David Sterba f9c7f68ed5 btrfs-progs: update CHANGES for v4.19
Signed-off-by: David Sterba <dsterba@suse.com>
2018-11-03 11:05:29 +01:00
Qu Wenruo 325256a232 btrfs-progs: doc: Update btrfs-qgroup regarding the rescan conditions
Add a new section, QUOTA RESCAN, to explain why and when we need a full
quota rescan when assigning/removing qgroup relationship.

Also, since 'remove' shares the same options of 'assign', add reference
to 'assign' options for 'remove' subcommand.

Signed-off-by: Qu Wenruo <wqu@suse.com>
[ update ]
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Qu Wenruo dda84b8a16 btrfs-progs: qgroup: make --rescan the default behavior after assign
Even though we have --rescan option, it still needs the user to manually
specify it or call quota rescan command.

This does not make much sense for the most common usecase and only
confuses users.  When the rescan is not desired, the --no-rescan option
can be used, eg.  when a mass qgruop assignment happens and the repeated
rescan would slow things down. This is considered a marginal usecase.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Qu Wenruo 922e555108 btrfs-progs: qgroup: Use bool to replace int for @rescan
Use more appropriate type.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Nikolay Borisov eac0574797 btrfs-progs: btrfstune: Rename change_header_uuid to change_buffer_header_uuid
Rename the function so its name falls in line with the rest of btrfs
nomenclature. So when we change the uuid of the header it's in fact of
the buffer header. Also remove the root argument since it's used solely
to take a reference to fs_info which can be done via the mandatory eb
argument. No functional changes.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Nikolay Borisov 9b521de429 btrfs-progs: btrfstune: Remove fs_info arg from change_device_uuid
This function already takes an extent buffer that contains a reference
to the fs_info. Use that and reduce argument count. No functional
changes.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Qu Wenruo 9f6d9ec10c btrfs-progs: print-tree: Use bool for @follow
Just a minor cleanup to make the parameter easier to read.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Qu Wenruo 0bbd407cbb btrfs-progs: print-tree: Introduce --bfs and --dfs options
Originally print-tree uses depth first search to print trees.
This works fine until we reach 3 level trees (root node level is 2).

For tall trees whose root level is 2 or higher, DFS will mix nodes and
leaves like the following example:

Level 2                       A
                             / \
Level 1                     B   C
                          / |   | \
Level 0                  D  E   F  G

DFS will cause the following output sequence:
A   B   D   E   C   F   G
Which in term of node/leave is:
N   N   L   L   N   L   L

Such mixed node/leave result is sometimes hard for human to read.

This patch will introduce 2 new options, --bfs and --dfs.

  --dfs: keeps the original output sequence, and to keep things
         compatible it's the default behavior.

  --bfs: uses breadth-first search, and will cause better output
         sequence like:

	 A   B   C   D   E   F   G
	 Which in term of node/leave is:
	 N   N   N   L   L   L   L

Much better sorted and may become default in the future.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Qu Wenruo 61c218756c btrfs-progs: print-tree: Introduce breadth-first search
Introduce a new function, bfs_print_children(), to do breadth-first
search to print a node.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Qu Wenruo cdd00958e4 btrfs-progs: Introduce function to find next sibling tree block
Introduce a new function, btrfs_next_sibling_tree_block(), which could
find any sibling tree blocks at path->lowest_level, unlike level 0
limited btrfs_next_leaf().

Since this function is more generic than btrfs_next_leaf(), also make
btrfs_next_leaf() a wrapper of btrfs_next_sibling_tree_block(), to keep
the interface the same as kernel.

This would provide the basis for later breadth-first search print-tree.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Qu Wenruo 65c3665811 btrfs-progs: Replace root parameter using fs_info for reada_for_search()
As the @root parameter is only used to get @fs_info, use fs_info
directly instead.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Misono Tomohiro 3e1d9cf022 libbtrfsutil: factor out btrfs_util_subvolume_info_fd
Factor out main logic of btrfs_util_subvolume_info_fd().  This is a
preparation work to relax the root privilege of this function.  No
functional changes.

Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Misono Tomohiro 001e1b2178 btrfs-progs: ioctl/libbtrfsutil: add 3 definitions of new unprivileged ioctl
Copy and add 3 definitions of new unprivileged ioctls:

* BTRFS_IOC_GET_SUBVOL_INFO
* BTRFS_IOC_GET_SUBVOL_ROOTREF
* BTRFS_IOC_INO_LOOKUP_USER

from kernel definitions. They will be used to implement the version
of "btrfs subvolume list/show" that will not require root privileges.

Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Misono Tomohiro 47abaaf6d0 btrfs-progs: doc: update manual page of btrfs subvolume
Some information is obsolete and updated as follows:

 - add missing explanations of some options
 - remove outdated explanation of "subvolrootid" mount option
 - reorder/group options of "subvolume list" so it matches the  help
   message
 - add explanation of different meanings of parent in "parent ID/UUID"
 - fix indentation/spelling
 - add missing comma

Signed-off-by: Misono Tomohiro <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
David Sterba e578b59bf6 btrfs-progs: convert strerror to implicit %m
Similar to the changes where strerror(errno) was converted, continue
with the remaining cases where the argument was stored in another
variable.

The savings in object size are about 4500 bytes:

 $ size btrfs.old btrfs.new
   text    data     bss     dec     hex filename
 805055   24248   19748  849051   cf49b btrfs.old
 804527   24248   19748  848523   cf28b btrfs.new

Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:14 +01:00
Qu Wenruo d59e19ca07 btrfs-progs: image: Warn about log tree generation mismatch when restoring
At restore time, btrfs-image will try to fixup dev extents, this will
trigger a transaction.

It's normally OK to start a new transaction, but for an image with log
tree, a new transaction will increment generation, and log tree generation
will not match super block generation + 1.

There is no good way to solve it yet. Just output a warning for now.

Signed-off-by: Qu Wenruo <wqu@suse.com>
[ update error message ]
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:13 +01:00
Nikolay Borisov bf60039cbe btrfs-progs: check: lowmem: Refactor extent type checks in check_file_extent
Make the checks in check_file_extent a bit more explicit. First we check
for unknown type and fail accordingly. Then we check for inline extent
and handle it in the newly introduced check_file_extent_inline. Finally
if none of the above checks triggered then we must have a regular or
prealloc extents.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:13 +01:00
Nikolay Borisov a9cddf632f btrfs-progs: check: lowmem: Refactor extent len test in check_file_extent_inline
Instead of having another top-level if which checks for
'extent_num_bytes != item_inline_len' only if we are !compressed, just
move the 'if' inside the 'else' branch of the first top-level if, since
it has already checked for !compressed or not. No functional changes.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:13 +01:00
Nikolay Borisov 2daecf07f3 btrfs-progs: check: lowmem: Factor out inline extent checking code in its own function
Since the inline extent code can be largely self-sufficient, factor
it out from check_file_extent. No functional changes.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Lu Fengqi <lufq.fnst@cn.fujitsu.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-31 18:24:13 +01:00
Su Yanjun 22e4767950 btrfs-progs: consitfy keys passed to serch functions
When using gcc8 to compile btrfs-progs, it complains as below:

ctree.c: In function 'btrfs_search_slot_for_read':
    ctree.c:1249:45: warning: passing argument 3 of 'btrfs_search_slot'
    discards 'const' qualifier from pointer target type
    [-Wdiscarded-qualifiers]
             ret = btrfs_search_slot(NULL, root, key, p, 0, 0);

Change btrfs_search_slot prototype with 'const' qualifier for argument 3.
Also fix similar problems as above change.

Signed-off-by: Su Yanjun <suyj.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-25 16:11:40 +02:00
Su Yanjun b4843d3669 btrfs-progs: tests: Add the testcase for subvolume name length limit test
Total of three conditions are tested. One for short name, one with
name length 255, the last one with more than 255.

This case should pass after commit
'btrfs-progs: change filename limit to 255 when creating subvolume'.

Signed-off-by: Su Yanjun <suyj.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-25 16:11:40 +02:00
Su Yanjun 3ea85fa886 btrfs-progs: change filename limit to 255 when creating subvolume
Modify the file name length limit to meet the Linux naming convention.
In addition, the file name length is always bigger than 0, no need to
compare with 0 again.

Issue: #145
Signed-off-by: Su Yanjun <suyj.fnst@cn.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-25 16:11:40 +02:00
Qu Wenruo 23eed7acfd btrfs-progs: convert: Output meaningful error messages for create_image
When convert failed, the error messsage would look like:

  create btrfs filesystem:
      blocksize: 4096
      nodesize:  16384
      features:  extref, skinny-metadata (default)
  creating ext2 image file
  ERROR: failed to create ext2_saved/image: -1
  WARNING: an error occurred during conversion, filesystem is partially
  created but not finalized and not mountable

We can only know something wrong happened during "ext2_saved/image" file
creation, but unable to know what exactly went wrong.

This patch will add the following error messages for create_image() and
its callee:

1) Sanity test error
2) Csum calculation error
3) Free ino number allocation error
4) Inode creation error
5) Inode mode change error
6) Inode link error

With all these error messages, we should be pretty easy to locate the
error without extra debugging.

Reported-by: Serhat Sevki Dincer <jfcgauss@gmail.com>
Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-25 16:11:40 +02:00
Qu Wenruo 6a659dbfde btrfs-progs: convert: Make read_disk_extent return more -EIO instead of -1
When pread64() returns value smaller than expected, it normally means
EIO, so just return -EIO to replace the intermediate number.  So when IO
fails, we should be able to get more meaningful error number of than
EPERM.

Reviewed-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2018-10-25 16:11:40 +02:00