Commit graph

408 commits

Author SHA1 Message Date
Anand Jain e408cfb49b btrfs-progs: factor out btrfs_scan_argv_devices
To prepare for handling command line given devices factor out
btrfs_scan_argv_devices().

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:48 +02:00
Anand Jain dc9e80192b btrfs-progs: drop open_ctree_flags variable in cmd_inspect_dump_tree
Local variable open_ctree_flags carries the flags whose final update is
for the locally declared struct variable oca_flags. Just use oca.flags
directly.

Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:48 +02:00
Anand Jain d46a0ef6a0 btrfs-progs: rename struct open_ctree_flags to open_ctree_args
The struct open_ctree_flags currently holds arguments for
open_ctree_fs_info(), it can be confusing when mixed with a local variable
named open_ctree_flags as below in the function cmd_inspect_dump_tree().

  cmd_inspect_dump_tree()
  ::
  struct open_ctree_flags ocf = { 0 };
  ::
  unsigned open_ctree_flags;

So rename struct open_ctree_flags to struct open_ctree_args.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:47 +02:00
Anand Jain 82a9870d48 btrfs-progs: dump-super: fix read beyond device size
On aarch64 systems with glibc 2.28, several btrfs-progs test cases are
failing because the command 'btrfs inspect dump-super -a <dev>' reports
an error when it attempts to read beyond the disk/file-image size.

  $ btrfs inspect dump-super -a /dev/vdb12
  <snap>
  ERROR: Failed to read the superblock on /dev/vdb12 at 274877906944

And btrfs/184 also fails, as it uses -s 2 option to dump the last super
block.

	$ ./check btrfs/184
	FSTYP         -- btrfs
	PLATFORM      -- Linux/aarch64 a4k 6.4.0-rc7+ #7 SMP PREEMPT Sat Jun 24 02:47:24 EDT 2023
	MKFS_OPTIONS  -- /dev/vdb2
	MOUNT_OPTIONS -- /dev/vdb2 /mnt/scratch

	btrfs/184 1s ... [failed, exit status 1]- output mismatch (see /Volumes/ws/xfstests-dev/results//btrfs/184.out.bad)
	    --- tests/btrfs/184.out    2020-03-03 00:26:40.172081468 -0500
	    +++ /Volumes/ws/xfstests-dev/results//btrfs/184.out.bad    2023-06-24 05:54:40.868210737 -0400
	    @@ -1,2 +1,3 @@
	     QA output created by 184
	    -Silence is golden
	    +Deleted dev superblocks not scratched
	    +(see /Volumes/ws/xfstests-dev/results//btrfs/184.full for details)
	    ...
	    (Run 'diff -u /Volumes/ws/xfstests-dev/tests/btrfs/184.out /Volumes/ws/xfstests-dev/results//btrfs/184.out.bad'  to see the entire diff)
	Ran: btrfs/184
	Failures: btrfs/184
	Failed 1 of 1 tests

This is because `pread()` behaves differently on aarch64 and sets
`errno = 2` instead of the usual `errno = 0`.

To fix check if the sb offset is beyond the device size or regular file
size and skip the corresponding sbread().

Also, move putchar('\n') after a successful call to load_and_dump_sb() to
the load_and_dump_sb() itself.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:47 +02:00
Anand Jain 8da82cde9c btrfs-progs: dump-super: drop the label out and variable ret
In cmd_inspect_dump_super(), at the label 'out', nothing much happens
other than returning ret.

At the goto statement to the label, in the for loop, we perform close(fd).
However, moving the close(fd) to 'out' as well is not a good idea because
close(fd) doesn't make sense outside the for loop.

Instead, simply return 1 instead of ret=1 and then returning it. Drop both
the 'out' label and ret.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:41 +02:00
Anand Jain 4ab083175a btrfs-progs: dump-super: improve error message on failed read
Add more error information to help debugging:

  $ ./btrfs inspect-internal dump-super -Ffa /dev/vdb10

  Before:
  ERROR: failed to read the superblock on /dev/vdb10 at 274877906944

  After:
  ERROR: failed to read the superblock on /dev/vdb10 at 274877906944 read 0/4096 bytes

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 14:59:10 +02:00
Qu Wenruo c88ac0170b btrfs-progs: scrub: unify the output numbers for "Total to scrub"
[BUG]
Command `btrfs scrub start -B` and `btrfs scrub status` are reporting
very different results for "Total to scrub":

  $ sudo btrfs scrub start -B /mnt/btrfs/
  scrub done for c107ef62-0a5d-4fd7-a119-b88f38b8e084
  Scrub started:    Mon Jun  5 07:54:07 2023
  Status:           finished
  Duration:         0:00:00
  Total to scrub:   1.52GiB
  Rate:             0.00B/s
  Error summary:    no errors found

  $ sudo btrfs scrub status /mnt/btrfs/
  UUID:             c107ef62-0a5d-4fd7-a119-b88f38b8e084
  Scrub started:    Mon Jun  5 07:54:07 2023
  Status:           finished
  Duration:         0:00:00
  Total to scrub:   12.00MiB
  Rate:             0.00B/s
  Error summary:    no errors found

This can be very confusing for end users.

[CAUSE]
It's the function print_fs_stat() handling the "Total to scrub" output.

For `btrfs scrub start` command, we use the used bytes (aka, the total
used dev extents of a device) for output.

This is not really accurate, as the chunks may be mostly empty just like
the following:

  $ btrfs fi df /mnt/btrfs/
  Data, single: total=1.01GiB, used=9.06MiB
  System, DUP: total=40.00MiB, used=64.00KiB
  Metadata, DUP: total=256.00MiB, used=1.38MiB
  GlobalReserve, single: total=22.00MiB, used=0.00B

Thus we're reporting 1.5GiB to scrub (1.01GiB + 40MiB * 2 + 256MiB * 2).
But in reality, we only scrubbed 12MiB
(9.06MiB + 64KiB * 2 + 1.38MiB * 2).

[FIX]
Instead of using the used dev-extent bytes of a device, go with proper
scrubbed bytes for each device.

This involves print_fs_stat() and print_scrub_dev() called inside
scrub_start().

Now the output should match each other.

Issue: #636
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-06-15 12:24:48 +02:00
David Sterba ab32c4445d btrfs-progs: qgroup show: fix formatting of limit values in json output
There are reports that json output of 'qgroup show' crashes due to
internal error when printing the limit values:

  INTERNAL ERROR: unknown unit base, mode 2304
  btrfs(internal_error+0x10a)[0x5605c37ce48a]
  btrfs(pretty_size_snprintf+0x5c)[0x5605c37d105c]
  btrfs(fmt_print+0x44e)[0x5605c37d178e]
  btrfs(+0x7ed1d)[0x5605c3800d1d]
  btrfs(main+0x8f)[0x5605c379beff]
  /lib64/libc.so.6(+0x27bb0)[0x7f83924ddbb0]
  /lib64/libc.so.6(__libc_start_main+0x8b)[0x7f83924ddc79]
  btrfs(_start+0x25)[0x5605c379d405]
  common/units.c:82: pretty_size_snprintf: Assertion `0` failed, value 0
  btrfs(+0x1d4b1)[0x5605c379f4b1]
  btrfs(pretty_size_snprintf+0x7b)[0x5605c37d107b]
  btrfs(fmt_print+0x44e)[0x5605c37d178e]
  btrfs(+0x7ed1d)[0x5605c3800d1d]
  btrfs(main+0x8f)[0x5605c379beff]
  /lib64/libc.so.6(+0x27bb0)[0x7f83924ddbb0]
  /lib64/libc.so.6(__libc_start_main+0x8b)[0x7f83924ddc79]
  btrfs(_start+0x25)[0x5605c379d405]

This is caused by "size" format that requires the unit mode, but it was not
specified and some stack value used. As json prints the raw values, use
the plain %llu format.

Link: https://bugzilla.opensuse.org/show_bug.cgi?id=1206960
Link: https://bugzilla.opensuse.org/show_bug.cgi?id=1209136#c15
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:33 +02:00
Qu Wenruo 1f66936c83 btrfs-progs: dump-tree: skip tree-checker when dumpping tree blocks
Since commit c8593f65cbf3 ("btrfs-progs: sync tree-checker.[ch] from
kernel"), btrfs-progs can do the kernel level tree block checks, which
is not really sutiable for dump-tree.

Under a lot of cases, we're using dump-tree tool to debug to collect the
details from end users.
If it's a bitflip causing a rejection, we would be unable to determine
the cause.

So this patch would add OPEN_CTREE_SKIP_LEAF_ITEM_CHECKS for dump-tree.

Reviewed-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:32 +02:00
Qu Wenruo 0c94a7d005 btrfs-progs: receive: output the parent subvolume uuid if it cannot be found
It's a known problem that a received subvolume would lose its UUID after
switching to RW.  Thus it can lead to later receive problems for
snapshotting and cloning.

In that case, we just output a simple error message like:

  ERROR: cannot find parent subvolume

Or

  ERROR: clone: did not find source subvol

Normally we need to use "btrfs receive --dump" to know what the missing
subvolume UUID is, which would take extra work.

This patch would:

- Add extra subvolume UUID to the output
- Unify the error messages to the same format

Now the error messages would look like:

  ERROR: snapshot: cannot find parent subvolume 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb
  ERROR: clone: cannot find source subvolume 1b4e28ba-2fa1-11d2-883f-b9a761bde3fb

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:31 +02:00
Anand Jain 96de5b014f btrfs-progs: inspect: fix warnings reported by -Wmissing-prototypes
When compiling on a system with gcc 12.2.1, the following warning is
generated. It can be fixed by adding a static storage class specifier.

cmds/inspect.c:733:5: warning: no previous prototype for ‘cmp_cse_devid_start’ [-Wmissing-prototypes]
  733 | int cmp_cse_devid_start(const void *va, const void *vb)
      |     ^~~~~~~~~~~~~~~~~~~
cmds/inspect.c:754:5: warning: no previous prototype for ‘cmp_cse_devid_lstart’ [-Wmissing-prototypes]
  754 | int cmp_cse_devid_lstart(const void *va, const void *vb)
      |     ^~~~~~~~~~~~~~~~~~~~
cmds/inspect.c:775:5: warning: no previous prototype for ‘print_list_chunks’ [-Wmissing-prototypes]
  775 | int print_list_chunks(struct list_chunks_ctx *ctx, unsigned sort_mode,
      |     ^~~~~~~~~~~~~~~~~

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:31 +02:00
Qu Wenruo b3327119ec btrfs-progs: fix -Wmissing-prototypes warnings
The fixes involve the following changes:

- Unexport functions which are not utilized out of the file
  * print_path_column()
  * parse_reflink_range()
  * btrfs_list_setup_print_column()
  * device_get_partition_size_sysfs()
  * max_zone_append_size()

- Include related headers before implementing the function
  * change-uuid.c
  * convert-bgt.c
  * seed.h

- Add missing headers caused by the above header changes
  * include <uuid/uuid.h> for tune/tune.h.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:31 +02:00
Josef Bacik 75262a2a0f btrfs-progs: make reada_for_search static
We were using this in cmds/restore.c, however it only does anything if
path->reada is set, and we don't set that in cmds/restore.c.  Remove
this usage of reada_for_search and make the function static.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:30 +02:00
Josef Bacik b3477244f9 btrfs-progs: update read_tree_block to match the kernel definition
The in-kernel version of read_tree_block adds some extra sanity checks
to make sure we don't return blocks that don't match what we expect.
This includes the owning root, the level, and the expected first key.
We don't actually do these checks in btrfs-progs, however kernel code
we're going to sync will expect this calling convention, so update it to
match the in-kernel code and then update all the callers.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:30 +02:00
Josef Bacik 6da52f41c7 btrfs-progs: pass root_id for btrfs_free_tree_block
In the kernel we pass in the root_id for btrfs_free_tree_block instead
of the root itself.  Update the btrfs-progs version of the helper to
match what we do in the kernel.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:30 +02:00
Josef Bacik 656938b665 btrfs-progs: rename clear_extent_buffer_dirty to btrfs_clear_buffer_dirty
This is a mirror of the change I've done in the kernel, but in progs
it's even more simply because clean_tree_block was just a wrapper around
clear_extent_buffer_dirty.  Change this to btrfs_clear_buffer_dirty, and
then update all the callers to use this helper instead of
clean_tree_block and clear_extent_buffer_dirty.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:29 +02:00
Josef Bacik 5780714b58 btrfs-progs: add btrfs_locking_nest to btrfs_alloc_tree_block
This is how btrfs_alloc_tree_block is defined in the kernel, so when we
go to sync this code in it'll be easier if we're already setup to accept
this argument.  Since we're in progs we don't care about nesting so just
use BTRFS_NORMAL_NESTING everywhere, as we sync in the kernel code it'll
get updated to whatever is appropriate.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:29 +02:00
Josef Bacik 006baaecdd btrfs-progs: rename btrfs_alloc_free_block to btrfs_alloc_tree_block
This is in keeping with what the function actually does, and is named
this way in the kernel.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:29 +02:00
Josef Bacik 4a9a8f2a8a btrfs-progs: sync extent-io-tree.[ch] and misc.h from the kernel
This is a bit larger than the previous syncs, because we use
extent_io_tree's everywhere.  There's a lot of stuff added to
kerncompat.h, and then I went through and cleaned up all the API
changes, which were

- extent_io_tree_init takes an fs_info and an owner now.
- extent_io_tree_cleanup is now extent_io_tree_release.
- set_extent_dirty takes a gfpmask.
- clear_extent_dirty takes a cached_state.
- find_first_extent_bit takes a cached_state.

The diffstat looks insane for this, but keep in mind extent-io-tree.c
and extent-io-tree.h are ~2000 loc just by themselves.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:29 +02:00
Josef Bacik f8efe9f724 btrfs-progs: sync file-item.h into progs
This patch syncs file-item.h into btrfs-progs.  This carries with it an
API change for btrfs_del_csums, which takes a root argument in the
kernel, so all callsites have been updated accordingly.

I didn't sync file-item.c because it carries with it a bunch of bio
related helpers which are difficult to adapt to the kernel.
Additionally there's a few helpers in the local copy of file-item.c that
aren't in the kernel that are required for different tools.

This requires more cleanups in both the kernel and progs in order to
sync file-item.c, so for now just do file-item.h in order to pull things
out of ctree.h.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:29 +02:00
Josef Bacik c979ffd787 btrfs-progs: sync accessors.[ch] from the kernel
This syncs accessors.[ch] from the kernel.  For the most part
accessors.h will remain the same, there's just some helpers that need to
be adjusted for eb->data instead of eb->pages.  Additionally accessors.c
needed to be completely updated to deal with this as well.

This is a set of files where we will likely only sync the header going
forward, and leave the C file in place as it needs to be specific to
btrfs-progs.

This forced a few "unrelated" changes

- Using btrfs_dir_item_ftype() instead of btrfs_dir_item_type().  This
  is due to the encryption changes, and was simpler to just do in this
  patch.
- Adjusting some of the print tree code to use the actual helpers and
  not the btrfs-progs ones.

A local definition of static_assert is used to avoid compilation
failures on older gcc (< 9) where the 2nd parameter is mandatory.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:28 +02:00
Josef Bacik a754fe29d9 btrfs-progs: sync uapi/btrfs.h into btrfs-progs
We want to keep this file locally as we want to be uptodate with
upstream, so we can build btrfs-progs regardless of which kernel is
currently installed.  Sync this with the upstream version and put it in
kernel-shared/uapi to maintain some semblance of where this file comes
from.

There are some changes that need to be synced back to kernel. A local
definition of static_assert is used to avoid compilation problems on gcc
(< 9) due to mandatory 2nd parameter.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:28 +02:00
Josef Bacik bee10e7fc9 btrfs-progs: rename the qgroup structs to match the kernel
Now that the libbtrfs stuff has it's own local copy of ctree.h and
ioctl.h, let's rename these qgroup struct members to match the kernel
names, this way it'll make it easier to sync the kernel code into
btrfs-progs.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:28 +02:00
Josef Bacik bf0f3db765 btrfs-progs: introduce UASSERT() for purely userspace code
While syncing messages.[ch] I had to back out the ASSERT() code in
kerncompat.h, which means we now rely on the kernel code for ASSERT().
In order to maintain some semblance of separation introduce UASSERT()
and use that in all the purely userspace code.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-05-26 18:02:28 +02:00
David Sterba 1046beb7a4 btrfs-progs: inspect tree-stats: rephrase warning when run on a mounted filesystem
Running 'btrfs inspect tree-stats' on a mounted filesystem works though
it reads directly from block devices. This can lead to inconsistent
data, warnings, errors or or a crash. More checks could be added but at
least explain things in more detail.

Issue: #520
Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-25 16:59:42 +02:00
David Sterba 938c6a19a9 btrfs-progs: subvol snapshot: adjust error message when there's an active swapfile
Attempting to create a snapshot of subvolume with an active swapfile
prints the errno message corresponding to ETXTBSY but this is confusing
so change it to be more descriptove to:

  ERROR: cannot snapshot '/hibernate': source subvolume contains an active swapfile (Text file busy)

Issue: #607
Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-25 16:59:42 +02:00
psykose c9abbf6264 btrfs-progs: stop using legacy *64 interfaces
The *64 interfaces, such as fstat64, off64_t, etc, are legacy interfaces
created at a time when 64-bit file support was still new. They are
generally exposed when defining a macro named _LARGEFILE64_SOURCE, as
e.g. the glibc docs[0] say.

The modern way to utilise largefile support, is to continue to use the
regular interfaces (off_t, fstat, ..), and define _FILE_OFFSET_BITS=64.

We already use the autoconf macro AC_SYS_LARGEFILE[1] which arranges this
and sets this macro for us. Therefore, we can utilise the non-64 names
without fear of breaking on 32-bit systems.

This fixes the build against musl libc, ever since musl dropped the
*64 compat from interfaces by default[2] just for _GNU_SOURCE, unless
_LARGEFILE64_SOURCE is defined. However, there are plans for a future
removal of the whole *64 header API, and that workaround (adding another
define) might cease to exist.

So, rename all *64 API use to the regular non-suffixed names. For
consistency, rename the internal functions that were *64 named
(lstat64_path, ..) too.

This should have no regressions on any platform.

[0]: https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html#index-_005fLARGEFILE64_005fSOURCE
[1]: https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/System-Services.html
[2]: 25e6fee27f

Pull-request: #615
Signed-off-by: psykose <alice@ayaya.dev>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-25 16:59:42 +02:00
David Sterba 9cb34031d7 btrfs-progs: balance: fix condition for recognizing old syntax
The commit 6f7151f499 extended the set of recognized valid subcommands
for the old path syntax but wrongly checks for more than 2 parameters.
That way a shortened and valid new syntax is not recognized (here 'can'
is short for 'cancel' and the short form is not in the list):

  btrfs-progs-6.1.3

  btrfs bal can /
  ERROR: balance cancel on '/' failed: Not in progress

  btrfs-progs-6.2.2

  btrfs bal can /
  WARNING: deprecated syntax, please use 'btrfs balance start'
  ERROR: cannot access 'can': No such file or directory

Issue: #612
Fixes: 6f7151f499 ("btrfs-progs: balance: fix some cases wrongly parsed as old syntax")
Signed-off-by: David Sterba <dsterba@suse.com>
2023-04-03 19:28:16 +02:00
Oliver Freyermuth 8e11c07269 btrfs-progs: handle case if fsid not in sysfs in device_is_seed
For older kernels, the sysfs interface providing the fsid may not be present yet.
Since 32c2e57c65 ("btrfs-progs: read fsid from the sysfs in
device_is_seed"), the fallback to the previous approach to determine
the fsid was not used anymore.

Ensure negative return values of sysfs_open_fsid_file are handled by
falling back to the dev_to_fsid in this case.

Pull-request: #599
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-17 18:15:39 +01:00
Wang Yugui 7ff278ba3d btrfs-progs: balance: warn when deprecated syntax is used
Deprecate old 'btrfs balance' syntax since new syntax has been
introduced in 2012.  We will remove the old syntax completely in a few
releases.

Signed-off-by: Wang Yugui <wangyugui@e16-tech.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-16 16:46:38 +01:00
Wang Yugui 6f7151f499 btrfs-progs: balance: fix some cases wrongly parsed as old syntax
Some cases of 'btrfs balance' are wrongly parsed as old syntax.
  $ btrfs balance status
  ERROR: cannot access 'status': No such file or directory

Currently, only 'start' is successfully excluded in the check of old
syntax.  Fix it by adding others in the check of old syntax.

Signed-off-by: Wang Yugui <wangyugui@e16-tech.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-16 16:40:31 +01:00
Holger Jakob 7647192c23 btrfs-progs: restore: don't modify metadata in dry-run mode
In Dry run the following error appeared and aborted execution:

  ERROR: failed to access 'XYZ' to restore metadata/xattrs: No such file or directory

Skip the metadata and xattrs handling when dry run is enabled.

Signed-off-by: Holger Jakob <jakob@dsi.uni-stuttgart.de>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-16 16:31:27 +01:00
Holger Jakob 5c1fb686aa btrfs-progs: restore: fix restoring xattrs on directories
Restore was only setting xattrs on files but ignored directories.

Signed-off-by: Holger Jakob <jakob@dsi.uni-stuttgart.de>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-16 16:30:25 +01:00
David Sterba 600f374058 btrfs-progs: qgroup show: fix formatting of qgroupid on json output
On a 32bit host the split qgroupid is wrong due to the way the numbers
are passed to the formatter as variable length arguments. The level is
u16, promoted to int and then parsed as u64. This means that the values
are shifted and some stack data are printed instead.

Example error messages from yast2-bootloader:

  SystemCmd.cc(addLine):569 Adding Line 7 "      "qgroupid": "21474836480/23885859321282560","

The value 21474836480 = 0x5000000 is 0x5 shifted by 32 bits,
23885859321282560 is 0x54dc1000000000 and shifting by 32 does not
lead to a valid value which should be 0 in this case.

Bugzilla: https://bugzilla.suse.com/show_bug.cgi?id=1209136
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-16 15:48:41 +01:00
David Sterba cba1ef1a42 btrfs-progs: dev stats: fix printing wrong values in tabular output
The tabular output prints the same value for all columns:

  # btrfs device stats /srv/btrfs-data
  [/dev/sdc1].write_io_errs    0
  [/dev/sdc1].read_io_errs     0
  [/dev/sdc1].flush_io_errs    0
  [/dev/sdc1].corruption_errs  0
  [/dev/sdc1].generation_errs  0
  [/dev/sdb1].write_io_errs    7489899
  [/dev/sdb1].read_io_errs     3751023
  [/dev/sdb1].flush_io_errs    117
  [/dev/sdb1].corruption_errs  68
  [/dev/sdb1].generation_errs  25

  # btrfs device stats -T /srv/btrfs-data
  Id Path      Write errors Read errors Flush errors Corruption errors Generation errors
  -- --------- ------------ ----------- ------------ ----------------- -----------------
   1 /dev/sdc1            0           0            0                 0                 0
   2 /dev/sdb1           25          25           25                25                25

The table_printf has a fixed list of columns and should not iterate over
them. Only check if some of the value is set and return error.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=217045
Issue: #585
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-07 21:09:03 +01:00
David Sterba f7b5e6924a btrfs-progs: subvolume: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba 56666f95c5 btrfs-progs: send: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba c75cc187a8 btrfs-progs: scrub: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba 808fdcee3b btrfs-progs: restore: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba dc6a4265bf btrfs-progs: rescue: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba 7b1e2e3b88 btrfs-progs: replace: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba e9614be78e btrfs-progs: reflink: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba 0a09370313 btrfs-progs: receive: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba a958ad85ec btrfs-progs: quota: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba e8569299c4 btrfs-progs: qgroup: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba 8c0d870ac7 btrfs-progs: property: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba 251d397870 btrfs-progs: inspect-internal: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba 5dd9506409 btrfs-progs: filesystem: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:23 +01:00
David Sterba fd112d04fc btrfs-progs: device: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:23 +01:00
David Sterba 38f90c6ad6 btrfs-progs: balance: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:23 +01:00