Commit graph

404 commits

Author SHA1 Message Date
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 140234dc0d btrfs-progs: move include from toplevel directory to include/
In order to reduce number of files in the toplevel directory,

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:23 +01:00
David Sterba 979fe686d2 btrfs-progs: libbtrfs: own copy of crc32c
The crc32c.c is going to be updated with CPU feature detection from
common/ which is not suitable for libbtrfs, so make own copy of the
file.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 20:11:22 +01:00
David Sterba 18e12e95ab btrfs-progs: build: fix detection of std=gnu11 build
Commit 0d5767e664 ("btrfs-progs: build: use -std=gnu11") was supposed
to set C level to gnu11 to match kernel but it was done only in the C=1
(checker) branch. The std used was still gnu90 that can be verified by
running with V=1.

Set the std option to gnu11 unconditionally and delete the m4 macros
that were detecting support on older gcc (4.5). The reference build on
lowest supported distro (Centos 7) compiles fine.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 19:49:30 +01:00
David Sterba 01faa47136 btrfs-progs: build: adjust spacing for ioctl-test output
The messages of ioctl-test related build is not aligned with other
commands:

    [LD]     hash-speedtest
    [LD]     hash-vectest
    [CC]   ioctl-test.o
    [LD]   ioctl-test

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 19:49:30 +01:00
David Sterba 6a7a0d8af8 btrfs-progs: crypto: add accelerated SHA256 implementation
Copy sha256-x86.c from https://github.com/noloader/SHA-Intrinsics, that
uses the compiler intrinsics to implement the update step with the
native x86_64 instructions.

To avoid dependencies of the reference code and the x86 version, check
runtime support only if the compiler also supports -msha.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 19:49:30 +01:00
David Sterba 23cb9771bc btrfs-progs: crypto: add AVX2 implementation of BLAKE2
Copy AVX2 implementation from https://github.com/sneves/blake2-avx2 .
Though this is marked experimental, libsodium uses this version.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 19:49:29 +01:00
David Sterba d61739003d btrfs-progs: crypto: add SSE4.1 implementation of BLAKE2
Copy SSE4.1 implementation from https://github.com/BLAKE2/BLAKE2 .

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 19:49:06 +01:00
David Sterba 1f2117eae8 btrfs-progs: crypto: add SSE2 implementation of BLAKE2
Copy implementation from https://github.com/BLAKE2/BLAKE2, add runtime
detection of SSE2 and add the switch function.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 19:48:24 +01:00
David Sterba 3157c572e1 btrfs-progs: add run-time CPU feature detection
Add support for run-time detection of CPU features on x86_64 to allow
selection of accelerated implementations of hash algorithms.

When possible use the compiler builtin (works on gcc and clang).
The SHA extensions can't be detected by __builtin_cpu_supports and the
__cpuid/__cpuidex macros are not consistently provided in all supported
gcc and clang versions. Copy the __cpuidex and call it manually for the
SHA extensions. Complete list https://en.wikipedia.org/wiki/CPUID .

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:44:03 +01:00
David Sterba 3cf00a0a38 btrfs-progs: tune: factor out checksum change to own file
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:44:01 +01:00
David Sterba 44fecc5fd2 btrfs-progs: tune: factor out conversion to block group tree to own file
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:43:47 +01:00
David Sterba 8962705987 btrfs-progs: tune: factor out metadata UUID change to own file
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:43:32 +01:00
David Sterba b2616464d3 btrfs-progs: tune: factor out UUID change to own file
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:43:19 +01:00
David Sterba b380d972e2 btrfs-progs: tune: factor out seeding to own file
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:43:04 +01:00
David Sterba f66478b961 btrfs-progs: move btrfstune to own directory
Move the source file to own directory so it can be further split and
refactored. File needs to be renamed to main.c so the build magic works.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:42:04 +01:00
Alexey 3e023b19f8 btrfs-progs: build: static should pick up EXTRA_LDFLAGS and SUBST_LDFLAGS
Concrete use-case:

- I want a static build to run in a small test VM.
- RedHat regrettably does not provide util-linux static libraries
- like libuuid.a and libblkid.a.
- So, one has to build them from source.
- Installing these to /usr is lame.
- This change lets me do make btrfs.static EXTRA_LDFLAGS=-L/path/to/util-linux-2.38/.libs

Pull-request: #563
Author: Alexey <snarkmaster@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 16:19:39 +01:00
David Sterba d6fc49d1dd btrfs-progs: libbtrfs: move libbtrfs.sym to the directory
The symbol definition is part of the library, move it away from the
toplevel directory.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-05 14:23:46 +01:00
David Sterba d4c7f01e37 btrfs-progs: libbtrfs: move version.h to the directory
The header is part of the public API and not used by any other code so
move it to the other files.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-05 14:18:07 +01:00
David Sterba e8d8949d38 btrfs-progs: libbtrfs: use own copy of kerncompat.h
Add a copy from v6.0.2 of kerncompat.h for libbtrfs to avoid accidental
build breakage as it's a public header and until now also shared with
the rest of btrfs-progs code.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-04 16:52:57 +01:00
David Sterba 900d56f1b9 btrfs-progs: add new group reflink and command
Add initial reflink group with example command 'clone' to test the
interface. Work in progress, experimental build needed.

Issue: #396
Signed-off-by: David Sterba <dsterba@suse.com>
2022-12-07 01:43:30 +01:00
David Sterba 9793474e22 btrfs-progs: tests: add string-table test framework
Signed-off-by: David Sterba <dsterba@suse.com>
2022-12-05 20:32:02 +01:00
Josef Bacik 5fc1d0cd64 btrfs-progs: copy ioctl.h into libbtrfs
We're going to sync btrfs.h into btrfs-progs from the kernel, however
libbtrfs still needs ioctl.h.  To deal with this copy ioctl.h into
libbtrfs, and update that code to use the local copy and update the
libbtrfs headers list to use this copy.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-11-28 18:57:43 +01:00
Josef Bacik 0d5767e664 btrfs-progs: build: use -std=gnu11
The kernel switched to this recently, switch btrfs-progs to this as well
to avoid issues with syncing the kernel code.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-11-24 22:36:56 +01:00
Josef Bacik a8531bfa39 btrfs-progs: fix make clean to clean convert properly
We were not clearing the .o files for btrfs-convert as we had the wrong
directory, which meant I missed a compile error that happened when I was
messing with kernel-shared.  Fix this by making sure we clear the .o
files for convert properly.

Fixes: 753baf2443 ("btrfs-progs: build: redirect dependency files files to .deps")
Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-11-24 22:35:47 +01:00
Josef Bacik 66d6d56f04 btrfs-progs: build: turn on more compiler warnings and use -Wall
In converting some of our helpers to take new args I would miss some
locations because we don't stop on any warning, and I would miss the
warning in the scrollback.

Note: the Centos7 build is not yet warning-free so we can't enable
-Werror by default. It can be used as:

  make EXTRA_CFLAGS=-Werror

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
[ add note ]
Signed-off-by: David Sterba <dsterba@suse.com>
2022-11-24 22:35:16 +01:00
David Sterba 753baf2443 btrfs-progs: build: redirect dependency files files to .deps
The dependency files clutter the source directories. Generate them in
the .deps directory, similar what automake uses.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:08:11 +02:00
David Sterba 2267708bfe btrfs-progs: move repair.c from common/ to check/
Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:08:09 +02:00
David Sterba e012d1fedb btrfs-progs: check: factor out code for clearing caches
Move helpers related to clearing space and inode cache from main.co to a
separate file.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:08:09 +02:00
David Sterba feef6aaaf6 btrfs-progs: kernel-lib: remove radix-tree
The radix-tree is not used in userspace code. In kernel it's for
tracking unpersisted and in-memory structures and has been replaced by
the xarray.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:08:07 +02:00
David Sterba d04a1fa10e btrfs-progs: factor filesystem helpers out of utils.c
Group helpers that retrieve information from the filesystem out of
utils.c.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:06:13 +02:00
David Sterba 6edd4b2121 btrfs-progs: factor string helpers out of utils.c
Utils is the catch-all file, we can now separate some string utility
functions.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:06:13 +02:00
David Sterba b121ac4404 btrfs-progs: fix path to internal libbtrfsutil includes
All files include the <btrfsutil.h> which could be confused with the
system-wide installation. Drop the -I path from build and use full path
for any libbtrfsutil headers.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:06:12 +02:00
David Sterba aa8040ef8c btrfs-progs: build: add rule for cleaning build dependencies
The header dependency rules generated as .o.d files are sometimes stale
and fail the build. Add a rule to clean them if needed, otherwise
they're also cleaned by 'make clean'.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-10-11 09:06:10 +02:00
David Sterba 92b57e4fd8 btrfs-progs: build: rename compression support variables
Now that LZO and ZSTD are optional for not just restore, rename the
build variables to a more generic name and update configure summary.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-08-16 15:18:11 +02:00
David Sterba 345731fff3 btrfs-progs: receive: optional build for lzo, zstd
There are build-time options for LZO and ZSTD support, the stream v2+
supports compression. The help text lists what has been compiled in,
similar to what 'restore' does, with a similar limitation that a stream
with compressed data cannot be processed if any of the extents is
compressed.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-08-16 15:18:11 +02:00
David Sterba 355844f86b btrfs-progs: libbtrfs: move extent-cache.h to ctree.h
Move the remaining structure definitions and prototypes to ctree.h that
is now the only user.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-06-06 15:49:22 +02:00
David Sterba 6b539bbbc4 btrfs-progs: libbtrfs: move extent_io.h to ctree.h
Move the remaining structure definitions and prototypes to ctree.h that
is now the only user.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-06-06 15:49:13 +02:00
David Sterba bb7db09e46 btrfs-progs: libbtrfs: use own copy of ctree.h, extent_io.h, send.h and extent-cache.h
Let libbtrfs use own copy of the exported header files to avoid
potential breakage when syncing with kernel headers and also to remove
declarations that are not used by userspace.  The send.h is frozen to
support protocol v1.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-06-06 15:48:46 +02:00
David Sterba c6dbd1d337 btrfs-progs: libbtrfs: add clean targets
Signed-off-by: David Sterba <dsterba@suse.com>
2022-06-06 15:48:33 +02:00
Ross Burton 73545c1fe6 btrfs-progs: build: add option to disable LZO support for restore
LZO as a compression format is pretty archaic these days, there are
better algorithms in all metrics for compression and decompression, and
lzo hasn't had a new release since 2017.

Add an option to disable LZO (defaulting to enabled), and respect it in
cmds/restore.c.

NOTE: disabling support for LZO will make make it impossible to restore
data from filesystems where the compression has ever been used. It's not
recommended to build without the support in general.

Signed-off-by: Ross Burton <ross.burton@arm.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-05-24 19:21:10 +02:00
David Sterba c1b24d742f btrfs-progs: kernel-lib: add rbtree_types.h from linux
In order to use rb_root_cached we need to sync with kernel sources. Copy
the file from linux.git/include/linux/rbtree_types.h and update so it's
C++ protected for inclusion to libbtrfs and remove duplicate
definitions.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-05-12 12:32:18 +02:00
David Sterba 2341d7fb9b btrfs-progs: tests: copy fsstress.c from fstests
The fsstress tool is a useful file generator, pull it from fstests as
it's not packaged as a standalone tool anywhere and the LTP version is
out of date.

The file has been modified to build, some xfs-specific ioctls are not
supported.

Signed-off-by: David Sterba <dsterba@suse.com>
2022-03-08 18:11:40 +01:00
Johannes Thumshirn 1aa806a66c btrfs-progs: add udev rule to use mq-deadline on zoned btrfs
As zoned btrfs uses regular writes for metadata, it needs zone write
locking in the IO scheduler. Add a udev rule that configures an IO
scheduler doing zone write locking.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2022-02-01 18:41:43 +01:00
David Sterba d96d143ef2 btrfs-progs: tests: unify mktemp file name pattern
The file names are build from roughly these components:

- btrfs-progs as prefix
- category (mkfs, convert) or what's the type of the file like 'image'
- the substitution template, XXXXXX

Signed-off-by: David Sterba <dsterba@suse.com>
2021-10-20 18:59:24 +02:00
David Sterba 7e0a8f3401 btrfs-progs: subvol list: merge the rest of btrfs-list.c
The remaining functions are too entangled to be moved separately without
too much churn making them exported and not, so move all the code at
once. No refactoring or coding style fixups.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-10-08 20:47:03 +02:00
David Sterba 03650851c5 btrfs-progs: split subvolume list to its own file
The main functionality of subvolume listing is now in btrfs-list.c but
there are no other commands using the API so this will be merged. It's a
lot of code so split it to another file.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-10-08 20:47:03 +02:00
David Sterba a3efed2adb btrfs-progs: libbtrfs: merge utils-lib.c back to utils.c
The separate file was needed for libbtrfs in the past to avoid pulling
utils.c in, but this is not needed after recent cleanups.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-10-08 20:47:03 +02:00
David Sterba 7ce3ae3966 btrfs-progs: libbtrfs: drop crc32c.h from exported headers
The usage of the crc32 helpers in ctree.h has been removed and there's
no other reason to keep crc32c.h exported.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-10-08 20:46:35 +02:00
David Sterba 2e2c7c0fc6 btrfs-progs: libbtrfs: drop sizes.h from exported headers
The SZ_ macros have been removed from the other exported headers, we can
now safely drop seizes.h too.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-10-08 20:46:35 +02:00