Commit graph

6399 commits

Author SHA1 Message Date
Qu Wenruo f3353a5e85 btrfs-progs: convert: handle ext4 orphan file feature properly
[BUG]
Since e2fsprog 1.47, even with a newly created empty ext4 filesystem,
btrfs-convert would result an fs that btrfs-check would complain:

  # mkfs.ext4 -F test.img
  # btrfs-convert test.img
  # btrfs-check test.img
  Opening filesystem to check...
  Checking filesystem on test.img
  UUID: e45da158-8967-4e4d-9c9f-66b0d127dbce
  [1/7] checking root items
  [2/7] checking extents
  [3/7] checking free space cache
  [4/7] checking fs roots
  root 5 inode 266 errors 2000, link count wrong
  ERROR: errors found in fs roots
  found 26333184 bytes used, error(s) found <<<
  total csum bytes: 25540
  total tree bytes: 180224
  total fs tree bytes: 49152
  total extent tree bytes: 16384
  btree space waste bytes: 145423
  file data blocks allocated: 33947648
   referenced 26284032

[CAUSE]
Ext4 has a new compat feature, COMPAT_ORPHAN_FILE, as a better way to
track all the orphan inodes.

This new feature would create a new special inode for this purpose, and
such orphan file inode would not be reachable from any other inode, but
only from super block.

Unfortunately btrfs-convert only skip ext2 known special inodes, not the
newer one.

[FIX]
According to the kernel document, we can locate the orphan file inode
using ext2 super block s_orphan_file_inum, and skip it for
btrfs-convert.

And such skip would only happen if we have the definition of
EXT4_FEATURE_COMPAT_ORPHAN_FILE, to be compatible with older e2fsprogs.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-23 19:48:26 +01:00
David Sterba 2f8fc64d50 btrfs-progs: docs: convert btrfs-ioctl to more compact format
Use tabular format instead of the defintion list as it's more compact.
Enable syntax hilighting to code examples.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-22 20:07:50 +01:00
David Sterba eec7613e61 btrfs-progs: ci: build workflow Github actions for devel
Add basic build tests and runtime tests devel, triggered by branch push.
For workflow testing there's a stub triggered by push of devel-ci.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-22 15:21:37 +01:00
David Sterba 183eece927 btrfs-progs: tests: fix mkfs/025 detection of zoned support
When 'nullb setup' fails to detect something, e.g. the null_blk module,
the whole test fails though the failure is supposed to be caught and
test not run. Use the correct helper that handles potential failures.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-22 14:34:21 +01:00
David Sterba 403ba6e6ee btrfs-progs: docs: add some design-related documents
Copied from wiki.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-22 14:39:17 +01:00
David Sterba 5e4a18b4b5 btrfs-progs: docs: add kernel version changes
Copy from wiki.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-22 14:39:15 +01:00
David Sterba 2c5f8de36b btrfs-progs: docs: add Status page from wiki
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-22 14:39:13 +01:00
Qu Wenruo 6c7a6dba95 btrfs-progs: use alloc_dummy_extent_buffer() for temporary super block
[FALSE ALERT]
There is a false alert when compiling btrfs-progs using gcc 12.2.1:

  $ make D=1
  kernel-shared/print-tree.c: In function 'print_sys_chunk_array':
  kernel-shared/print-tree.c:1797:9: warning: 'buf' may be used uninitialized [-Wmaybe-uninitialized]
   1797 |         write_extent_buffer(buf, sb, 0, sizeof(*sb));
        |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from ./kernel-shared/ctree.h:27,
                   from kernel-shared/print-tree.c:24:
  ./kernel-shared/extent_io.h:148:6: note: by argument 1 of type 'const struct extent_buffer *' to 'write_extent_buffer' declared here
    148 | void write_extent_buffer(const struct extent_buffer *eb, const void *src,
        |      ^~~~~~~~~~~~~~~~~~~

[CAUSE]
This is a false alert, the uninitialized part of buf will not be
utilized at all during write_extent_buffer().

[FIX]
Instead of allocating such ad-hoc buffer, go a more formal way by
calling alloc_dummy_extent_buffer(), which would properly set all
the members.

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-03-21 03:10:42 +01:00
Qu Wenruo 788e30f7ea btrfs-progs: tests: fix failure of misc/034
[BUG]
Test case misc/034 can fail like this:

  ====== RUN CHECK mount /dev/loop16 /home/adam/btrfs-progs/tests/mnt
  mount: /home/adam/btrfs-progs/tests/mnt: wrong fs type, bad option, bad superblock on /dev/loop16, missing codepage or helper program, or other error.
         dmesg(1) may have more information after failed mount system call.
  failed: mount /dev/loop16 /home/adam/btrfs-progs/tests/mnt

And the dmesg looks like this:

  loop16: detected capacity change from 0 to 1024000
  loop17: detected capacity change from 0 to 1024000
  BTRFS: device fsid 593e23af-a7e6-4360-b16a-229f415de697 devid 1 transid 6 /dev/loop16 scanned by mount (79348)
  BTRFS info (device loop16): using crc32c (crc32c-intel) checksum algorithm
  BTRFS info (device loop16): found metadata UUID change in progress flag, clearing
  BTRFS info (device loop16): disk space caching is enabled
  BTRFS error (device loop16): devid 2 uuid cde07de6-db7e-4b34-909e-d3db6e7c0b06 is missing
  BTRFS error (device loop16): failed to read the system array: -2
  BTRFS error (device loop16): open_ctree failed

[CAUSE]
From the dmesg, it shows that although both loopback devices are
properly registered, only one is properly scanned by mount.

Thus the other device is missing, and without "-o degraded" the
filesystem failed to be mounted.

[FIX]
Before we mount the filesystem, also scan them in their passed order
to properly assemble the device list for mount.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-21 02:59:06 +01:00
Qu Wenruo dad89b7aca btrfs-progs: sync DEV_INFO ioctl from kernel
Add fsid to DEV_INFO structure introduced in kernel 6.3 by 2943868a909f
("btrfs: ioctl: return device fsid from DEV_INFO ioctl").

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-03-21 02:55:56 +01: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
Alexander Barton d82c2ca63c btrfs-progs: docs: fix name of "mountinfo" file in subvolume intro
The name of a mounted sub volume can not be found in /proc/self/mounts
but in /proc/self/mountinfo.

Pull-request: #596
Signed-off-by: Alexander Barton <alex@barton.de>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-17 18:14:18 +01:00
David Sterba 474c980386 btrfs-progs: crypto: remove unused declarations of blake2 variants
We use only the 2b variant, we can remove the rest.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-17 01:16:02 +01:00
softwarecreations 36fcaa1a7b btrfs-progs: docs: update swapfile Added size to mkswapfile example
Let's show users how to set the size of their new swapfile.

Pull-request: #601
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-16 23:15:15 +01:00
David Sterba 02ffc977be btrfs-progs: docs: don't use wiki links in manual pages and package
The wiki has been archived so remove the links from manual page
footers. Also replace the wiki link by RTD site in configure and
libbtrfsutil.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-16 22:38:21 +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
Anand Jain 4a37203c8a btrfs-progs: docs: discard tunables and metrics in sysfs
Since kernel v6.1, we have had discard tunables and metrics under sysfs.
Add documentation for them.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-03-16 15:48:48 +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
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