Commit Graph

6578 Commits

Author SHA1 Message Date
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
Tobias Kaiser 3edfc2b29a btrfs-progs: docs: fix typo in subvolume intro
Author: Tobias Kaiser <mail@tb-kaiser.de>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-07 20:52:35 +01:00
David Sterba 306ee04ffd btrfs-progs: tests: add more build tests for old microarchitectures
As reported in #588, build fails on some microarchitectures when the
blake2 macros do not coverall combinations. Extend the build tests and
add some uarchs to test.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-07 20:50:16 +01:00
Tino Mai 0da635fd1b btrfs-progs: crypto: fix SSE2/SSE4.1 detection of BLAKE2
On recent x86-64 system with march=native|<cpu>|<microarchitecture
level> gcc/clang will automatically define all the available vector
extensions macros. crypto/blake2-config.h then correctly set all the
HAVE_<EXTENSION> macros.

crypto/blake2-round.h then checks the HAVE_<EXTENSION> macros for
including further headers:

    #if defined(HAVE_SSE41)
    #include "blake2b-load-sse41.h"
    #else
    #include "blake2b-load-sse2.h"
    #endif

which is wrong. On recent systems it always results in including
blake2b-load-sse41.h. crypto/blake2-round.h itself is included by
crypto/blake2b-sse2.c and now we have a SSE2/SSE4.1 code mixing
resulting in the incompatible type for argument build errors described
in #589.

The idea is to remove the lines above from crypto/blake2-round.h and put
the includes directly into crypto/blake2b-sse2.c and
crypto/blake2b-sse41.c respectively.

Note this slightly diverges from the upstream BLAKE2 sources.

Pull-request: #591
Author: Tino Mai <mai.tino@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-07 20:50:06 +01:00
David Sterba 366cd079bc
Btrfs progs v6.2.1
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-03 17:10:44 +01:00
David Sterba 53d2375d22 btrfs-progs: update CHANGES for 6.2.1
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-03 16:54:17 +01:00
Alexander Kanavin 2aa6854bb0 btrfs-progs: crypto: add missing ssse3 header for blake2-sse2 implementation
Otherwise, the following error occurs:

| In file included from crypto/blake2b-sse2.c:30:
| crypto/blake2b-sse2.c: In function 'blake2b_compress_sse2':
| crypto/blake2b-round.h:32:22: warning: implicit declaration of function '_mm_shuffle_epi8'; did you mean '_mm_shuffle_epi32'? [-Wimplicit-function-declaration]
|    32 |     : (-(c) == 24) ? _mm_shuffle_epi8((x), r24) \
|       |                      ^~~~~~~~~~~~~~~~

Note: it's not yet clear what affects this build failure as it otherwise
builds in the tested configurations (gcc/clang, arch, distro), but it
apparently fixes the build in some environments.

Pull-request: #588
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
[ add note ]
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-03 16:54:17 +01:00
David Sterba f09e9c9543 btrfs-progs: tests: add more targets to build test
Add config for crypto backends (they could fail for the static targets
due to missing static libraries). Reiserfs is not tested and it slowly
disappears from distros.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-01 18:53:46 +01:00
David Sterba 6984ee86b1 btrfs-progs: INSTALL: add minimal version of crypto libraries
Configure verifies the minimum version, make them explicit in the
installation docs.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-01 17:02:26 +01:00
David Sterba b79b330f62 btrfs-progs: ci: enable crypto backends on alpine/musl image
Add the libaries and update script so additional configure parameters
can be passed. Also enable backtrace so it's closer to the defaults.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-01 16:58:29 +01:00
David Sterba 9981a6767d btrfs-progs: ci: enable crypto backends on Centos images
Add the libaries and update script so additional configure parameters
can be passed. Also enable backtrace so it's closer to the defaults.

Only the libsodium is enabled and verified to build, libgcrypt has
sufficient version on 8 but configure does not detect it for some
reason. Libkca is old on both.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-01 16:51:27 +01:00
David Sterba 223fa4ca01 btrfs-progs: ci: enable crypto backends on Leap image
Add the libaries and update script so additional configure parameters
can be passed. Also enable backtrace and libudev so it's closer to the
defaults.

Leap 15.3 properly builds only with libsodium, 15.4 with libgcrypt and
libsodium. Libkcapi is old on both.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-01 16:33:12 +01:00
David Sterba d8b66fe2e2 btrfs-progs: ci: enable crypto backends on Tumbleweed image
Add the libaries and update script so additional configure parameters
can be passed. Also enable backtrace and libudev so it's closer to the
defaults.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-01 16:10:53 +01:00
David Sterba 02d3723993 btrfs-progs: hash-vectest: verify vectors against configured implementation
Add entries for all crypto backends and test the ones that match what
was configured with --with-crypto.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-01 15:53:26 +01:00
David Sterba bbcd599062 btrfs-progs: hash-speedtest: benchmark the configured backend
Change what hash-speedtest benchmarks according to the
--with-crypto=backend option. Until now it would run the same version
under different names inherited from the builting.

At configure time detect availability of all backends and define all
macros.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-01 15:53:26 +01:00
David Sterba 4fc291a465 btrfs-progs: fix detection of accelerated implementation.
The build fails with crypto backends other than builtin, the
initializers cannot be reached as they're ifdef-ed out.  Move
hash_init_accel under the right condition and delete the
algorithm-specific initializers as they're used only by the hash test
and that can simply call hash_init_accel to set the implementation.

All the -m flags need to be detected at configure time and the flag used
for ifdef (HAVE_CFLAG_m*), not the actual feature defined by compiler as
the dispatcher function is not built with the -m flags.

The uname check for x86_64 must be dropped so on i386/i586 we can still
build accelerated version.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-01 15:10:21 +01:00
David Sterba 6439e92cba
Btrfs progs v6.2
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:21:38 +01:00
David Sterba 208e52382f btrfs-progs: update CHANGES for 6.2
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba f8a9c985fe btrfs-progs: help: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba 304bdfa0a5 btrfs-progs: select-super: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba 7eefb7bab1 btrfs-progs: map-logical: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba 7ed23eca5c btrfs-progs: find-root: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba 72463c23d2 btrfs-progs: corrupt-block: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba b1c159b804 btrfs-progs: docs: add 6.2 development statistics
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +01:00
David Sterba 4996e4375c btrfs-progs: convert common options to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:24 +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 4b8d51ded9 btrfs-progs: check: 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
David Sterba dde2f15010 btrfs-progs: docs: remove mentions of btrfs-debug-tree, btrfs-show-super, btrfs-zero-log
The standalone tools have been deprecated and removed in 2018 and nobody
should miss them.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:23 +01:00
David Sterba 5edf4950b4 btrfs-progs: reformat global options and update docs
With the growing list of global option we need to print them somewhere
in the help text and document them.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:23 +01:00
David Sterba 67964cbcda btrfs-progs: add global option --log=level
Add an option to set the log level exactly instead of -vv and similar.
The combined option may not be known to all users as reported and one
option for the level is for convenience.

Issue: #570
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:23 +01:00
David Sterba c811ccc6c9 btrfs-progs: convert: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:23 +01:00
David Sterba a7fa81f296 btrfs-progs: open code print_usage where applicable
After previous change to usage() that now has the return code, there's
no purpose of the print_usage() wrapper so it can be removed.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:23 +01:00
Qu Wenruo e3a24cf11a btrfs-progs: tests: fix cli/017 test case failure
[BUG]
Test case cli/017 fails with the following errors:

    [TEST]   cli-tests.sh
    [TEST/cli]   017-fi-show-missing
  didn't find exact missing device
  test failed for case 017-fi-show-missing

[CAUSE]
After kernel commit cb3e217bdb39 ("btrfs: use btrfs_dev_name() helper to
handle missing devices better"), all dev info ioctl call on missing
device would only return "<missing disk>" for its path.

Thus "btrfs filesystem show" would never report detailed device path for
missing disks.

[FIX]
Instead of relying on the device path, change the check to rely on devid
instead.

Now cli/017 can properly pass.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:23 +01:00
Qu Wenruo f61b90aff9 btrfs-progs: make usage call properly return an exit value
[BUG]
Currently cli/009 test case failed with different exit number:

  ====== RUN CHECK /home/adam/btrfs-progs/btrfstune --help
  usage: btrfstune [options] device
  [...]
  failed: /home/adam/btrfs-progs/btrfstune --help
  test failed for case 009-btrfstune

[CAUSE]
In tune/main.c, we have the following call on usage():

  static void print_usage(int ret)
  {
	usage(&tune_cmd);
	exit(ret);
  }

However usage() itself would always call exit(1):

  void usage(const struct cmd_struct *cmd)
  {
	usage_command_usagestr(cmd->usagestr, NULL, 0, true, true);
	exit(1);
  }

This makes prevents any caller of usage() to modify its exit number.

[FIX]
Add a new argument @error for print_usage(), so we can properly return 0
for -h/--help usage.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:23 +01:00
Anand Jain 32c2e57c65 btrfs-progs: read fsid from the sysfs in device_is_seed
The kernel commit a26d60dedf9a ("btrfs: sysfs: add devinfo/fsid to
retrieve actual fsid from the device") introduced a sysfs interface
to access the device's fsid from the userspace. This is a more
reliable method to obtain the fsid compared to reading the
superblock, and it even works if the device is not present.
Additionally, this sysfs interface can be read by non-root users.

Therefore, it is recommended to utilize this new sysfs interface to
retrieve the fsid.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:23 +01:00
Anand Jain bdd0ca8a9a btrfs-progs: prepare helper device_is_seed
load_device_info() checks if the device is a seed device by reading
superblock::fsid and comparing it with the mount fsid, and it fails
to work if the device is missing (a RAID1 seed fs). Move this part
of the code into a new helper function device_is_seed() in
preparation to make device_is_seed() work with the new sysfs
devinfo/<devid>/fsid interface.

Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:23 +01:00