Commit Graph

3791 Commits (3ae36b3b0f13326df8b38ff4a4df1ce47fccd417)
 

Author SHA1 Message Date
Jeff Mahoney 3ae36b3b0f btrfs-progs: backref: push state tracking into a helper structure
Eventually, we'll have several lists and trees, as well as some statistics.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:41:07 +02:00
Jeff Mahoney a5ce5d2198 btrfs-progs: extent-cache: actually cache extent buffers
We have the infrastructure to cache extent buffers but we don't actually
do the caching.  As soon as the last reference is dropped, the buffer
is dropped.  This patch keeps the extent buffers around until the max
cache size is reached (defaults to 25% of memory) and then it drops
the last 10% of the LRU to free up cache space for reallocation.  The
cache size is configurable (for use by e.g. lowmem) when the cache is
initialized.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
[ update codingstyle, switch total_memory to bytes ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:41:06 +02:00
Jeff Mahoney ad39e6252b btrfs-progs: check: switch to iterating over the backref_tree
We now have two data structures that can be used to iterate the same data
set, and there may be quite a few of them in memory.  Eliminating the
list_head member will reduce memory consumption while iterating over
the extent backrefs.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:41:05 +02:00
Jeff Mahoney 756105181e btrfs-progs: check: supplement extent backref list with rbtree
For the pathlogical case, like xfstests generic/297 that creates a
large file consisting of one, repeating reflinked extent, fsck can
take hours.  The root cause is that calling find_data_backref while
iterating the extent records is an O(n^2) algorithm.  For my
example test run, n was 2*2^20 and fsck was at 8 hours and counting.

This patch supplements the list with an rbtree and drops the runtime
of that testcase to about 20 seconds.

A previous version of this patch introduced a regression that would
have corrupted file systems during repair.  It was traced to the
compare algorithm honoring ->bytes regardless of whether the
reference had been found and a failure to reinsert nodes after
the target reference was found.

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:41:01 +02:00
David Sterba 530ca51307 btrfs-progs: mkfs: remove unused function
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:23:46 +02:00
David Sterba d07e349800 btrfs-progs: mkfs: use existing helper for path concatenation
Mkfs uses make_path that is duplicate of path_cat* functions, so we can
switch to them and add the error handling.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:23:44 +02:00
Yingyi Luo fe667f6e7d btrfs-progs: add a parameter to btrfs_mksubvol
A convert parameter is added as a flag to indicate if btrfs_mksubvol()
is used for btrfs-convert. The change cascades down to the callchain.

Signed-off-by: Yingyi Luo <yingyil@google.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:23:37 +02:00
Yingyi Luo 8a820b5765 btrfs-progs: convert: move link_subvol out of main
link_subvol() is moved to inode.c and renamed as btrfs_mksubvol().
The change cascades down to the callchain.

Signed-off-by: Yingyi Luo <yingyil@google.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:23:34 +02:00
Misono, Tomohiro 8d93d71f6a btrfs-progs: subvol: fix subvol del --commit-after
Fix 'subvolume delete --commit-after' to work properly:
- SYNC ioctl will be issued even when last delete fails
- SYNC ioctl will be issued on each file system only once in the end

To achieve this, get_fsid() and add_seen_fsid() are called after each
delete to keep only one fd for each fs.

In the end, seen_fsid_hash will be traversed and SYNC is issued on each
fs.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:23:31 +02:00
Misono, Tomohiro 26908f6146 btrfs-progs: change seen_fsid to hold fd and DIR
Change seen_fsid to hold fd and DIR in order to keep access to each fs.
This will be used for 'subvol delete --commit-after'.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:23:30 +02:00
Misono, Tomohiro 836aa5202a btrfs-progs: move seen_fsid to utils.c
Move is_seen_fsid()/add_seen_fsid()/free_seen_fsid() to common functions.
This will be used for 'subvol delete --commit-after'.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:23:28 +02:00
Misono, Tomohiro 448763c64a btrfs-progs: move get_fsid() to utils.c
Make get_fsid() to a common functions.
This will be used for 'subvol delete --commit-after'.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:23:27 +02:00
Misono, Tomohiro 75716f6a8f btrfs-progs: subvol: exchange subvol del --commit-after and --commit-each
Current code is reversed in --commit-after and --commit-each operation,
i.e. --commit-after means --commit-each actually. This patch fixes this
and also introduces enum type for more readable code.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Reviewed-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-10-06 13:23:26 +02:00
David Sterba 2a30baea9e
Btrfs progs v4.13.1
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 18:25:18 +02:00
David Sterba bef1270572 btrfs-progs: update CHANGES for v4.13.1
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:24:25 +02:00
David Sterba 5faec98439 btrfs-progs: tests: check there are no unprintable characters in btrfs-image -ss output
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:46 +02:00
David Sterba 15beadeaa2 btrfs-progs: build: add more sparse warning checks
- declarations after statements (style issue)
- bitfields without defined signedness

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:44 +02:00
David Sterba 5d57bdeb23 btrfs-progs: build: use -std=gnu89 for sparse
Sparse does not seem to support gnu90 that we'd like to keep for the
regular build. Use gnu89 for C=1 build.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:40 +02:00
David Sterba 4498f53707 btrfs-progs: build: add missing defines for the C=1 build
Sparse complains that BTRFSCONVERT_EXT2 and _RESIERFS are not defined.
The per-target options are missing from the default CFLAGS and only
added in the specific rule.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:37 +02:00
David Sterba 628307f5c4 btrfs-progs: updated and add missing function attributes to the definition
Reported by sparse. Make the prototype match the definition and put the
attributes before the function.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:32 +02:00
David Sterba b4b069dcb2 btrfs-progs: free-space-cache: fix endianity when reading from disk_key
Sparse reports:

free-space-cache.c:921:13: warning: incorrect type in assignment (different base types)
free-space-cache.c:921:13:    expected unsigned long long [unsigned] [usertype] ino
free-space-cache.c:921:13:    got restricted __le64 [addressable] [usertype] objectid

we need to use the helper to read objectid, as read_eb_member just
copies the data without disk->cpu transformation. This could lead to
bogus results on bigendian machines.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:27 +02:00
David Sterba 510a282f7f btrfs-progs: print-tree: use proper helper for reading offset
Sparse warns

print-tree.c:1261:49: warning: incorrect type in argument 4 (different base types)
print-tree.c:1261:49:    expected unsigned long long [unsigned] [usertype] start
print-tree.c:1261:49:    got restricted __le64 [addressable] [usertype] offset

which means we have to use the helper instead of directly accessing the offset
member. This could print bogus number on bigendian arch.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:19 +02:00
David Sterba 8eccfa86c0 btrfs-progs: fix debugging macro checks
Sparse warns that the DEBUG_*_ERROR macros are not defined when checked.
Use the ifdef check rather then relying on the implicit behaviour.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:17 +02:00
Nicholas D Steeves 5b2fbc6f4e btrfs-progs: tests: Remove misleading BCP 78 boilerplate from SHA implementation
BCP 78 applies to RFC 6234, but sha224-256.c is Simplified BSD.

This causes the following lintian error when building on Debian and
Debian derivatives:

    E: btrfs-progs source: license-problem-non-free-RFC-BCP78
       tests/sha224-256.c

Please consult the following email from debian-legal@lists.debian.org
for more information:

https://lists.debian.org/debian-legal/2017/08/msg00004.html
Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com>
[ I've copied too much from the RFC that's not related to the code,
  covered by the explicit copyright notice in the file ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:15 +02:00
Nicholas D Steeves ac71751828 btrfs-progs: tests: Add required IETF Trust copyright to SHA implementation
Signed-off-by: Nicholas D Steeves <nsteeves@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:12 +02:00
David Sterba bc2c60ad31 btrfs-progs: docs: start ioctl documentation manual page
Start documenting the ioctl interface to btrfs. The overall structure
should be settled, the formatting of the ioctl description may change in
the future, newly added ioctl descriptions should follow the examples of
BTRFS_IOC_SUBVOL_CREATE.

The document is not finished yet and will not be installed until most of
ioctls' details are filled in.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:09 +02:00
David Sterba 509af95c92 btrfs-progs: tests: make sure _is_file_or_command does not get confused
The test cli/007-check-force reports something like:

$ type -p '--string that starts with dashes'
bash: type: --: invalid option

Add the option/argument separator.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:18:05 +02:00
Qu Wenruo a7e555d706 btrfs-progs: Fix one-byte overlap bug in free_block_group_cache
free_block_group_cache() calls clear_extent_bits() with wrong end, which
is one byte larger than the correct range.

This will cause the next adjacent cache state to be split.  And due to
the split, private pointer (which points to block group cache) will be
reset to NULL.

This is very hard to detect as this function only gets called in
cleanup_temp_chunks() which is just before mkfs finishes.  This bug only
gets exposed when reworking --rootdir option.

Signed-off-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:52 +02:00
Qu Wenruo 02b58051e6 btrfs-progs: Refactor find_next_chunk to get rid of parameter root and objectid
Function find_next_chunk() is used to find next chunk start position,
which should only do search on chunk tree and objectid is set to
BTRFS_FIRST_CHUNK_TREE_OBJECTID.

So refactor the parameter list to get rid of @root, which should be
obtained from fs_info->chunk_root, and @objectid, which is set to
BTRFS_FIRST_CHUNK_TREE_OBJECTID.

Signed-off-by: Qu Wenruo <quwenruo.btrfs@gmx.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:48 +02:00
Naohiro Aota 3efd322db2 btrfs-progs: build: omit unnecessary -MD flag
According to gcc(1), "-MD is equivalent to -M -MF file, except that -E is not
implied." Since the rule in the Makefile is just generating dependency file
and not building object file, it is no use to have "-MD" here. Also, it's
overridden and conflicting with the following "-MM" flag. I guess we can drop
it.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:45 +02:00
Naohiro Aota fd8c78a47c btrfs-progs: build: generate all dependency files
We're missing several dependency files like:

$ diff -u <(find -name '*.o'|cut -d. -f2|sort) <(find -name '*.o.d'|cut -d. -f2|sort)
@@ -3,7 +3,6 @@
 /btrfs-corrupt-block
 /btrfs-debug-tree
 /btrfs-find-root
-/btrfs-list
 /btrfs-map-logical
 /btrfs-select-super
 /btrfstune
@@ -29,11 +28,6 @@
 /cmds-scrub
 /cmds-send
 /cmds-subvolume
-/convert/common
-/convert/main
-/convert/source-ext2
-/convert/source-fs
-/convert/source-reiserfs
 /ctree
 /dir-item
 /disk-io
<snip>

This is due to moving things out of objects and cmds_objects variables. Such
missing dependency files cause mis-building of some source files (try touch
utils.h; make mkfs/main.o).

This patch introduce a new variable "all_objects" to keep all the objects and
use the variable to generate proper dependency file building rules.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:42 +02:00
yingyil f7267bc85c btrfs-progs: mkfs: refactor create_data_reloc_tree
Add an objectid parameter to make the function a general one for
inserting root items and rename it to create_tree. The change cascades
down to the callchain.

Signed-off-by: yingyil <yingyil@google.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:39 +02:00
David Sterba bcaadc2e49 btrfs-progs: build: whitespace adjustment of [LD] fssum
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:35 +02:00
David Sterba 01bcf68cf5 btrfs-progs: tests: remove temporary images in mkfs/005 and mkfs/006
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:31 +02:00
David Sterba 03fb34b6b4 btrfs-progs: tests: remove temporary loopdev files
Remove files for testing loop devices when using the helper.

Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:28 +02:00
David Sterba 29faad6339 btrfs-progs: convert: use correct string printing for errcode_t
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:21 +02:00
Misono, Tomohiro 629688a2d2 btrfs-progs: cleanup whitespaces of btrfs-completion
Clean up spaces and use only tabs. No functional change.

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:19 +02:00
Nick Terrell 0766330f85 btrfs-progs: tests: add testing image for zstd for btrfs-restore
Adds tests for the new features based on a prebuilt btrfs image with a
zstd compressed file.

Split from the previous patch.

Signed-off-by: Nick Terrell <terrelln@fb.com>
[ with some cleanups ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:15 +02:00
Nick Terrell 717a8b1e5d btrfs-progs: Add zstd support
Adds zstd support to the btrfs program. An optional dependency on libzstd
>= 1.0.0 is added. Autoconf accepts `--enable-zstd' or `--disable-zstd' and
defaults to detecting if libzstd is present using `pkg-config'.

The patch is also available in my fork of btrfs-progs [1], which passes
Travis-CI with the new tests. The prebuilt binary is available there.

I haven't updated Android.mk.

[1] https://github.com/terrelln/btrfs-progs/tree/devel

Signed-off-by: Nick Terrell <terrelln@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:13 +02:00
Misono, Tomohiro 86529862e1 btrfs-progs: update btrfs-completion
This patch updates btrfs-completion:
 - add "filesystem du" and "rescure zero-log"
 - restrict _btrfs_mnts to show btrfs type only
 - add more completion in last case statements

(This file contains both spaces/tabs and may need cleanup.)

Signed-off-by: Tomohiro Misono <misono.tomohiro@jp.fujitsu.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:11 +02:00
David Sterba 5768fc03a4 btrfs-progs: build: sync Makefile to Android.mk
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:09 +02:00
David Sterba 67b7b4bc40 btrfs-progs: tests: fix run_mustfail in cli-tests/007-check-force
The sanity check in run_mustfail does not work as expected and allowed
the command to continue without the missing parameter

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=196893
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:06 +02:00
David Sterba fb48edcffb btrfs-progs: README: update links, enhance contribution section
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:04 +02:00
Piotr Pawlow 0e88d6d1d3 btrfs-progs: image: use CRC32C reversing instead of brute force to find collisions
Author: Piotr Pawlow <pp@siedziba.pl>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:01 +02:00
Piotr Pawlow 334d83053a btrfs-progs: image: add a function to check if generated filename suffix is valid
Author: Piotr Pawlow <pp@siedziba.pl>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:17:00 +02:00
Piotr Pawlow c859336f47 btrfs-progs: image: add a function to calculate CRC32C collisions
The function uses the reverse CRC32C table to quickly calculate a
4-byte suffix, that when added to the original data will make it
match desired checksum.

Author: Piotr Pawlow <pp@siedziba.pl>
[ minor adjustments ]
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:16:59 +02:00
Piotr Pawlow a172244163 btrfs-progs: image: add reverse CRC32C table
The table will be used to speed up calculations of CRC32C collisions.

Author: Piotr Pawlow <pp@siedziba.pl>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:16:58 +02:00
Piotr Pawlow bc98731f4c btrfs-progs: image: move core find_collision code to a separate function
Author: Piotr Pawlow <pp@siedziba.pl>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:16:56 +02:00
Piotr Pawlow 658e7b897b btrfs-progs: image: fix non-printable characters in generated file names
Function find_collision sometimes generated file names with non-printable
DEL characters (code 127), for example file name "|5gp!" would be changed
to "U'2<DEL>y" when using "crc-collisions" sanitize mode.

Author: Piotr Pawlow <pp@siedziba.pl>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:16:54 +02:00
Uli Heller c5b6e3fad8 btrfs-progs: Removed missing header file, fixes compilation error
(From pull request #61.)

Author: Uli Heller <uli.heller@daemons-point.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2017-09-25 15:16:52 +02:00