Commit Graph

394 Commits

Author SHA1 Message Date
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
David Sterba 38356d456b btrfs-progs: libbtrfs: drop radix-tree.h from exported headers
The header is only included from ctree.h but not actually used, we can
drop it from the exported files.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-10-08 20:46:35 +02:00
David Sterba aaf13469c0 btrfs-progs: libbtrfs: drop all unneeded build objects
Drop basically all build objects that were entangled due to various
interdependencies and accumulated over the time to libbtrfs.

The commit of shame from 2013 is e5cb128a95 ("btrfs-progs: libify some
parts of btrfs-progs") and let that be a warning how not to do a
library.

The send stream is not yet available in libbtrfsutil, once it will be we
can drop libbtrfs for good.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-10-08 20:46:35 +02:00
David Sterba 46fa64417c btrfs-progs: libbtrfs: drop btrfs-list.o from build
Nothing from that is needed anymore.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-10-08 20:46:35 +02:00
David Sterba 6b5c089469 btrfs-progs: libbtrfs: make own copy of files implementing the API
The two files send-stream and send-utils contain the implementations of
the exported API, which was just for send stream. This was the original
idea. That libbtrfs contains another 40 files was a result of
unclean/missing library design and had to be done that way to resolve
the symbols due to dependencies.

That the same files have been used for both internal and public library
has prevented refactoring and cleanups and was always a risk of breaking
something.

Make separate copy for libbtrfs utils and allow any cleanups and
reduction of number of build objects. The API hasn't changed since the
beginning so there's low risk of missing some fixes from the internal
code.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-10-08 20:46:34 +02:00
David Sterba d4dc4793fa btrfs-progs: build: merge object variables
Now libbtrfs.a has own list and we can merge $objects and
$shared_objects again. Reformat it now that it's changed.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-10-08 20:46:34 +02:00
David Sterba e0f7a9a902 btrfs-progs: build: enumerate libbtrfs.a build objects
Enumerate all the objects required for libbtrfs.a, removing unnecessary
ones on the way

- kernel-lib/radix-tree.o
- kernel-shared/inode-item.o
- libbtrfsutil/stubs.o

There are only a handful of files exported in libbtrfs.sym so the file
is excessively long and most of the code is not necessary. This will be
reduced eventually.

static_libbtrfs_objects need to use the linked shared_objects to avoid
duplication of symbols.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-10-08 20:46:34 +02:00
David Sterba 9a136b39df btrfs-progs: build: replace libbtrfs.a by object list
Avoid using libbtrfs.a as build object so replace it with the same list
of objects.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-10-08 20:46:34 +02:00
David Sterba 1eb3470681 btrfs-progs: build: simplify library variables
As preparation to make libbtrfs build standalone and separate, start
with variables simplifications and inlining.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-10-08 20:46:34 +02:00
Nikolay Borisov f74ebeee5c btrfs-progs: build: add optional dependency on libudev
This is needed for future code which will make btrfs-progs' device
scanning logic a little smarter by filtering out path device in
multipath setups. libudev is added as an optional dependency since the
library doesn't have a static version so making it a hard dependency
means forfeiting static build support. To alleviate this a fallback code
will be added for the static build case which doesn't rely on libudev.

Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2021-10-06 16:50:32 +02:00
David Sterba 53c9618ce0 btrfs-progs: libbtrfs: drop btrfs-list.h, raid56.h and btrfsck.h
libbtrfs isn't a proper library and exports internal headers that aren't
included from other headers and their use in public API does not make
sense. There are no known applications using them so don't install them.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-09-08 18:17:29 +02:00