Due to ambiguity of error values in the public API subvol_uuid_search,
there was second version added. There's a separate copy in libbtrfs and
we don't have to distinguish in the internal code. All callers check for
IS_ERR and NULL, so we can safely merge the helpers into one.
Signed-off-by: David Sterba <dsterba@suse.com>
After removing uuid search fallback code the structure has become
trivial and copies the fd that all callers have in their context.
Signed-off-by: David Sterba <dsterba@suse.com>
After the uuid search fallback code has been removed, the finit helper
has become empty and can be removed.
Signed-off-by: David Sterba <dsterba@suse.com>
There's a lot of code under BTRFS_COMPAT_SEND_NO_UUID_TREE to support
kernels < 3.12 that don't have uuid tree and the subvolume uuids are
searched in a slow way, building the uuid tree on the userspace side.
As the uuid tree is always created, the fallback code was not exercised
anyway due to 'uuid_tree_existed' check in subvol_uuid_search2.
Delete the code from the internal copy of send-utils. The support still
stays for libbtrfs and will be removed in the future.
Signed-off-by: David Sterba <dsterba@suse.com>
All the comparators switch the result based on is_descending, but that
can be factored to the caller to simplify the comparators.
Signed-off-by: David Sterba <dsterba@suse.com>
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>
There's only one caller of btrfs_list_alloc_filter_set so move it there.
Also move the definitions of BTRFS_LIST_* to the header so they can be
used by both btrfs-list and subvolume.c.
Signed-off-by: David Sterba <dsterba@suse.com>
There's only one caller of btrfs_list_alloc_comparer_set so move it
there. Also move the definitions of BTRFS_LIST_* to the header so they
can be used by both btrfs-list and subvolume.c.
Signed-off-by: David Sterba <dsterba@suse.com>
The actual implementation of find-new functionality is outside of
subvolume.c, copy it where it's supposed to be. No reformatting or style
changes.
Signed-off-by: David Sterba <dsterba@suse.com>
It has been replaced by libbtrfsutil function in 9e73a416f0
("btrfs-progs: use libbtrfsutil for get-default").
Signed-off-by: David Sterba <dsterba@suse.com>
All users have been converted to use btrfs_subvolid_resolve, we can now
remove btrfs_list_path_for_root.
Signed-off-by: David Sterba <dsterba@suse.com>
Replaced by libbtrfsutil functions in 9005b603d7 ("btrfs-progs: use
libbtrfsutil for subvol show"). Also remove strdup_or_null as it's now
unused too.
Signed-off-by: David Sterba <dsterba@suse.com>
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>
The btrfs_list_* functions come with some overhead and for simple path
resolution we can use btrfs_subvolid_resolve.
Signed-off-by: David Sterba <dsterba@suse.com>
We don't need to include this besides btrfs-list.c itself and
subvolume.c that does use the btrfs_list_* API.
Signed-off-by: David Sterba <dsterba@suse.com>
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>
Changing several defaults at once is desirable for easier reference,
rather than a number of scattered releases enabling each. The changes
are documented but printing a notice won't hurt as not everybody reads
the documentation or release notes.
Undesired features can be unselected by prepending ^ to the option name,
like:
$ mkfs.btrfs -O ^no-holes
Signed-off-by: David Sterba <dsterba@suse.com>
The original idea of not doing DUP on SSD was that the duplicate blocks
get deduplicated again by the driver firmware. This was in 2013, years
ago. Then it was speculative and even nowadays we don't have much
reliable information from vendors what optimizations are done on the
drive level.
After the year there's enough information gathered by user community and
there's no simple answer. Expensive drives are more reliable but less
common, for cheap consumer drive it's vice versa. The characteristics
are described in more detail in manual page btrfs(5) in section "SOLID
STATE DRIVES (SSD)".
The reasoning is based on numerous reports on IRC and technical
difficulty on mkfs side to do the right decision. The default is chosen
to be the safe option and up to user to change that based on informed
decision.
Issue: #319
Signed-off-by: David Sterba <dsterba@suse.com>
The free space tree is a better way to track the free space and has been
tested in the wild for a long time. The backward compatibility is
sufficient, several long term kernels. On-line conversion from v1 to v2
can be done by mount, switching from v2 to v1 can be done by 'btrfs
check'.
Issue: #295
Signed-off-by: David Sterba <dsterba@suse.com>
The no-holes feature reduces consumption of metadata by not representing
file holes. Reducing metadata is a good thing in general, this is the
main goal to enable this by default.
There's a drawback, related to the missing information about holes. The
'check' tool cannot use it to cross-reference extent information and in
some cases may not be able to detect a problem.
The no-hole feature can be also enabled by 'btrfstune -n' on an
unmounted filesystem.
Issue: #405
Signed-off-by: David Sterba <dsterba@suse.com>
device_get_partition_size_fd() fails if we pass a regular file. This can
happen when trying to create an emulated zoned filesystem on a regular file.
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
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>
Make the helpers using crc32c not inline so the crc32c.h can be removed
from the public headers exported by libbtrfs.
Signed-off-by: David Sterba <dsterba@suse.com>
There's an ancient macro btrfs_crc32c which is just wrapping crc32c and
not doing anything else, so we can use the crc helper directly.
Signed-off-by: David Sterba <dsterba@suse.com>
To drop sizes.h from exported headers, replace the few SZ_ constants
from the existing exported headers (ctree.h, send.h). It would be nice
to use them in the long run but right now it would prevent unexporting
the sizes.h file.
Signed-off-by: David Sterba <dsterba@suse.com>
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>
Copy the lookup helper and switch the API functions using it. We can
drop dependency on kernel-shared/uuid-tree.c after that.
Signed-off-by: David Sterba <dsterba@suse.com>
There are two functions for resolving subvolume id path, but one is less
convenient and pulls a lot of dependencies. This is
btrfs_list_path_for_root, where the idea is to have the whole tree of
subvolumes and query it as needed.
For simple path resolution we already have btrfs_subvolid_resolve and
it's also in the public API, so we can use it and drop the other one.
This in turn allows to drop btrfs-list.o from build dependencies.
Signed-off-by: David Sterba <dsterba@suse.com>
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>
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>
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>