Commit graph

5427 commits

Author SHA1 Message Date
Hugo Mills 373def57ce btrfs-progs: docs: minor fixes for spelling and idiom
Author: Hugo Mills <hugo@carfax.org.uk>
Signed-off-by: David Sterba <dsterba@suse.com>
2021-07-02 17:27:53 +02:00
David Sterba 9b027ac64e btrfs-progs: docs: add section about hardware considerations
Signed-off-by: David Sterba <dsterba@suse.com>
2021-07-02 17:27:53 +02:00
David Sterba cb11769cd3 btrfs-progs: docs: write section about storage model
Signed-off-by: David Sterba <dsterba@suse.com>
2021-07-02 17:27:52 +02:00
David Sterba 63794e7016 btrfs-progs: docs: update device related info
- recently added stripe count in device usage
- other minor updates

Signed-off-by: David Sterba <dsterba@suse.com>
2021-07-02 17:27:52 +02:00
David Sterba 6710641ad5 btrfs-progs: docs: add section about zoned devices
Signed-off-by: David Sterba <dsterba@suse.com>
2021-07-02 17:27:52 +02:00
Sidong Yang 4693e82261 btrfs-progs: device usage: print number of stripes in relevant profiles
Print number of stripes for striped profiles in device usage commands.
It helps to see profiles easily. The output is like below.

/dev/vdc, ID: 1
   Device size:             1.00GiB
   Device slack:              0.00B
   Data,RAID0/2:          912.62MiB
   Data,RAID0/3:          912.62MiB
   Metadata,RAID1:        102.38MiB
   System,RAID1:            8.00MiB
   Unallocated:             1.00MiB

Multiple lines can appear in case a balance conversion process was
interrupted or if there's been a new device added and new data written
to the full stripe.

Issue: #372
Signed-off-by: Sidong Yang <realwakka@gmail.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-23 13:47:35 +02:00
David Sterba c3acaee63a btrfs-progs: docs: add more results for checksums
Update the table with AVX2 accelerated versions provided by libgcrypt
and libsodium.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-23 13:47:35 +02:00
David Sterba ae59e39531 btrfs-progs: docs: add section about compression
Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-23 13:47:35 +02:00
David Sterba 1eb7b11303 btrfs-progs: remove stale user transaction ioctl definitions
The user transaction ioctls have been removed in kernel 4.17 by commit
7a5a07a81062 ("btrfs: Remove userspace transaction ioctls"), the
definitions are not relevant and can be removed.

The numbers could be reused in the future, eg. when there are no
maintained LTS kernels older than 4.19.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-19 22:07:50 +02:00
David Sterba d51075f05b btrfs-progs: restore: group help options
Group the options in the help text by the purpose for clarity.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-19 22:07:49 +02:00
David Sterba 9a83a0b5c0 btrfs-progs: restore: remove loop check during directory scan
There's another loop protection during scan of directory items. This can
fire under invalid conditions, ie. when there's no real endless loop.
The layout of b-tree items could trigger that and has been observed in
practice. This prevents automated restoration as it requires user
attention.

The number of loops is 1024, unjustified and without explanation. Errors
during traversing the leaves are checked so most errors would be caught.
A real loop in the directory items would require some crafting and would
not happen on a normal filesystem.

Issue: #59
Issue: #164
Issue: #237
Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-19 22:07:49 +02:00
David Sterba 4258b7161f btrfs-progs: restore: remove loop check during file copy
There's some kind of looping protection during copying file extents,
mostly likely to avoid endless loops on severely damaged filesystems.
This has been bothering users and makes restoring hard to automate as
it requires user attention to press 'y' or 'a'. This has not been well
documented either.

The number of loops is 1024 which looks arbitrary and hard to justify.
This eg. means that a file with many fragments hits the interactive
question more than once.

There are other checks when iterating the leaves that would catch
corruptions or other errors, so the looping would happen in some rare
and rather artificial case when some kind of loop exists inside the
extent items. This is not easily possible if possible at all as the
items do not directly reference other.

In case there's some genuine error found that would require a looping
protection, we'll add it or extend the checks to identify the loop.

Issue: #59
Issue: #164
Issue: #237
Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-19 22:07:49 +02:00
David Sterba afe055f438 btrfs-progs: restore: convert to error message helpers
- convert to error() helpers, remove trailing \n
- switch messages printing %d as errno to %m
- rewording

Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-19 22:07:49 +02:00
David Sterba b1f374dd1d btrfs-progs: switch %Lu to %llu format
The %Lu format is not standard and we use %llu everywhere else, so
switch the remaining cases.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-19 22:07:49 +02:00
Qu Wenruo ab0d369525 btrfs-progs: tests/fsck: add test case to make sure btrfs check can reset btrfs_dev_item::bytes_used
The test image is manually crafted with 1MiB offset in the device item
of devid 1.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-19 22:07:49 +02:00
Qu Wenruo 0ebd1f47c5 btrfs-progs: check: add the ability to reset btrfs_dev_item::bytes_used
There is a report from the mailing list that one user got its filesystem
with device item bytes_used mismatch.

This problem leaves the device item with some ghost bytes_used, meaning
even if we delete all device extents of that device, the bytes_used
still won't be 0.

This itself is not a big deal, but when the user used up all its
unallocated space, write time tree-checker can be triggered and make the
fs RO, as the new device::bytes_used can be larger than
device::total_bytes.

Thus we need to fix the problem in btrfs-check to avoid above write-time
tree check warning.

This patch will add the ability to reset a device's bytes_used to both
original mode and lowmem mode.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-19 22:07:49 +02:00
David Sterba 9f6c055e38 btrfs-progs: dump-tree: add options to dump checksums
Add new options to dumps checksums in node headers and in the checksum
items:

  $ btrfs inspect dump-tree --csum-headers image
  root tree
  leaf 471515136 items 19 free space 12186 generation 15 owner ROOT_TREE
  leaf 471515136 flags 0x1(WRITTEN) backref revision 1 csum 0x756b2d54
  fs uuid df0348df-5773-47dd-81e9-a18221461239

For nodes/leaves it's appended on the 2nd line of the header.

Checksum items are stored in leaves as EXTENT_CSUM key type, with offset
value as the logical offset starting. As the array would be hard to
parse or match, each offset value is printed with the checksum. For
crc32c it's 4 values on a line, for xxhash it's 2 and for the long
256bit checksums it's one checksum per line.

  $ btrfs inspect dump-tree --csum-items image
  leaf 5423104 items 1 free space 30 generation 6 owner CSUM_TREE
  leaf 5423104 flags 0x1(WRITTEN) backref revision 1
  fs uuid bd7c981e-16ff-4081-a734-3ef5d50cafc1
  chunk uuid 13f4c76c-7845-4984-88ed-f01b52e05cf8
	  item 0 key (EXTENT_CSUM EXTENT_CSUM 22020096) itemoff 55 itemsize 16228
		  range start 22020096 end 38637568 length 16617472
		  [22020096] 0x8941f998 [22024192] 0x8941f998 [22028288] 0x8941f998 [22032384] 0x8941f998
		  [22036480] 0x8941f998 [22040576] 0x8941f998 [22044672] 0x8941f998 [22048768] 0x8941f998
		  ...

  $ btrfs inspect dump-tree --csum-items image
  leaf 5718016 items 1 free space 7746 generation 6 owner CSUM_TREE
  leaf 5718016 flags 0x1(WRITTEN) backref revision 1
  fs uuid f453a5b4-8b4a-4fbf-90a2-2925e4fe2335
  chunk uuid eb1da63b-248b-44c2-82da-71b2564bf50e
	  item 0 key (EXTENT_CSUM EXTENT_CSUM 52387840) itemoff 7771 itemsize 8512
		  range start 52387840 end 53477376 length 1089536
		  [52387840] 0x686ede9288c391e7e05026e56f2f91bfd879987a040ea98445dabc76f55b8e5f
		  [52391936] 0x686ede9288c391e7e05026e56f2f91bfd879987a040ea98445dabc76f55b8e5f
		  ...

The options are not on by default, the header checksum is not important
for the structures. Data checksums can be quite big so that would make
the dump long and without any actual data to match against.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-19 22:07:49 +02:00
David Sterba 72d710637c btrfs-progs: print-tree: convert mode to bitmask
Replace follow and traverse by one parameter that takes bits to affect
the behaviour. This allows to extend btrfs_print_tree output with more
modes from one place.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-09 20:31:49 +02:00
David Sterba 6134973527 btrfs-progs: zoned: make it work without kernel support
There's a report that a system with 4.19 kernel fails boot because
device scan exits with error. This is because zoned support is compiled
in btrfs-progs but not in kernel.

To make new progs and old kernels work, do a fallback when the zoned
ioctl is not available, as if it were a non-zoned device. There is no
other option, but this is safe at least for the device scan that would
not error out. Any unaligned writes to a zoned device will fail as
expected.

Issue: #376
Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-07 17:38:46 +02:00
David Sterba 9527bc0649 btrfs-progs: crypto: add perf support to speed test
Use perf events to read the cycle count, this should work on all
architectures. Enabled by option --perf and the sysctl
kernel.perf_event_paranoid must be 0 or 1.

The results are roughly the same as for raw cycles on x86_64 but worse
because of the additional overhead (read, context switch):

Block size:     4096
Iterations:     100000
Implementation: builtin
Units:          CPU cycles

    NULL-NOP: cycles:     42719688, cycles/i      427
 NULL-MEMCPY: cycles:     72941208, cycles/i      729,    18670.314 MiB/s
      CRC32C: cycles:    183709926, cycles/i     1837,     7413.009 MiB/s
      XXHASH: cycles:    136727614, cycles/i     1367,     9960.264 MiB/s
      SHA256: cycles:  10711594532, cycles/i   107115,      127.137 MiB/s
      BLAKE2: cycles:   2256957529, cycles/i    22569,      603.398 MiB/s

Block size:     4096
Iterations:     100000
Implementation: builtin
Units:          perf event: CPU cycles

    NULL-NOP: perf_c:     29649530, perf_c/i      296
 NULL-MEMCPY: perf_c:     59954062, perf_c/i      599,    15137.464 MiB/s
      CRC32C: perf_c:    179009071, perf_c/i     1790,     6929.460 MiB/s
      XXHASH: perf_c:    136413509, perf_c/i     1364,     9982.950 MiB/s
      SHA256: perf_c:  10997356664, perf_c/i   109973,      127.046 MiB/s
      BLAKE2: perf_c:   2379077576, perf_c/i    23790,      588.780 MiB/s

Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-01 22:19:38 +02:00
David Sterba 1d4bab875a btrfs-progs: drop "2b" from blake2 in speed test
Internally it's blake2b but for the user facing output or other command
line interfaces let's call it just BLAKE2.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-06-01 21:17:50 +02:00
David Sterba 5734073b15 btrfs-progs: crypto: fix printf warnings in hash-speedtest
With explicit width the default alignment is to the right, using space
is a gnu extension. Fix the following warnings:

  crypto/hash-speedtest.c: In function ‘main’:
  crypto/hash-speedtest.c:152:15: warning: ' ' flag used with ‘%s’ gnu_printf format [-Wformat=]
    152 |   printf("% 12s: ", c->name);
	|               ^
  crypto/hash-speedtest.c:172:21: warning: ' ' flag used with ‘%u’ gnu_printf format [-Wformat=]
    172 |   printf("%s: % 12llu, %s/i % 8llu",
	|                     ^
  crypto/hash-speedtest.c:172:34: warning: ' ' flag used with ‘%u’ gnu_printf format [-Wformat=]
    172 |   printf("%s: % 12llu, %s/i % 8llu",
	|                                  ^

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-27 11:00:17 +02:00
David Sterba 133dd6c6c3 btrfs-progs: crypto: print throughput in hash-speedtest
Calculate the estimated throughput as a number that's comparable across
machines.

  $ ./hash-speedtest --cycles
  Block size:     4096
  Iterations:     100000
  Implementation: builtin
  Units:          cycles

      NULL-NOP: cycles:     42928902, cycles/i      429
   NULL-MEMCPY: cycles:     73014868, cycles/i      730,    18651.186 MiB/s
	CRC32C: cycles:    182293290, cycles/i     1822,     7470.579 MiB/s
	XXHASH: cycles:    138085981, cycles/i     1380,     9862.272 MiB/s
	SHA256: cycles:  10576270837, cycles/i   105762,      128.764 MiB/s
       BLAKE2b: cycles:   2263761293, cycles/i    22637,      601.585 MiB/s

  $ ./hash-speedtest --time
  Block size:     4096
  Iterations:     100000
  Implementation: builtin
  Units:          nsecs

      NULL-NOP: nsecs:     12164607, nsecs/i      121
   NULL-MEMCPY: nsecs:     20423641, nsecs/i      204,    19095.518 MiB/s
	CRC32C: nsecs:     51972794, nsecs/i      519,     7503.926 MiB/s
	XXHASH: nsecs:     38935164, nsecs/i      389,    10016.651 MiB/s
	SHA256: nsecs:   3030944497, nsecs/i    30309,      128.673 MiB/s
       BLAKE2b: nsecs:    648489262, nsecs/i     6484,      601.398 MiB/s

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-26 23:09:52 +02:00
David Sterba 55bf9b749d btrfs-progs: crypto: add time-based measurement to hash-speedtest
People are interested in measuring the hash performance on non-x86_64
architectures. Add option to do time-based measurements (in nanoseconds)
in case there's no support for clock-based measurements.

  $ ./hash-speedtest --cycles
  Block size:     4096
  Iterations:     100000
  Implementation: builtin
  Units:          cycles

      NULL-NOP: cycles:     43035633, cycles/i      430
   NULL-MEMCPY: cycles:     72478624, cycles/i      724
	CRC32C: cycles:    181712982, cycles/i     1817
	XXHASH: cycles:    136251305, cycles/i     1362
	SHA256: cycles:  10758567410, cycles/i   107585
       BLAKE2b: cycles:   2249704806, cycles/i    22497

  $ ./hash-speedtest --time
  Block size:     4096
  Iterations:     100000
  Implementation: builtin
  Units:          nsecs

      NULL-NOP:  nsecs:     12459033, nsecs/i      124
   NULL-MEMCPY:  nsecs:     20687845, nsecs/i      206
	CRC32C:  nsecs:     52648264, nsecs/i      526
	XXHASH:  nsecs:     39591766, nsecs/i      395
	SHA256:  nsecs:   3079668837, nsecs/i    30796
       BLAKE2b:  nsecs:    644766582, nsecs/i     6447

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-26 22:42:59 +02:00
David Sterba f123c28412 btrfs-progs: fi resize: add support for cancel
Recognize special resize amount 'cancel' for resize operation.  This
will request kernel to stop running any resize operation (most likely
shrinking resize). This needs support in kernel, otherwise this will
fail due to another exclusive operation running (though could be the
same one).

The command returns after kernel finishes any work that got interrupted,
but this should not take long in kernels 5.10+ that allow interruptible
relocation. The waiting inside kernel is interruptible so this command
(and the waiting stage) can be interrupted.

The resize operation could relocate block groups but the nominal
filesystem size will be restored when resize won't finish. It's
recommended to review the filesystem state.

Note: in kernels 5.10+ sending a fatal signal (TERM, KILL, Ctrl-C) to
the process running the resize will cancel it too.

Example:

  $ btrfs fi resize -10G /mnt
  ...
  $ btrfs fi resize cancel /mnt

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-20 22:43:29 +02:00
David Sterba 71d68ab8b2 btrfs-progs: device remove: add support for cancel
Recognize special name 'cancel' for device deletion, that will request
kernel to stop running device deletion. This needs support in kernel,
otherwise this will fail due to another exclusive operation running
(though could be the same one).

The command returns after kernel finishes any work that got interrupted,
but this should not take long in kernels 5.10+ that allow interruptible
relocation. The waiting inside kernel is interruptible so this command
(and the waiting stage) can be interrupted.

The device size is restored when deletion does not finish but it's
recommended to review the filesystem state.

Note: in kernels 5.10+ sending a fatal signal (TERM, KILL, Ctrl-C) to
the process running the device deletion will cancel it too.

Example:

    $ btrfs device delete /dev/sdx /mnt
    ...
    $ btrfs device delete cancel /mnt

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-20 22:14:18 +02:00
Anand Jain efe4844e01 btrfs-progs: fix inspect-internal --help incomplete sentence
btrfs inspect-internal --help shows incomplete sentence. As shown
below:

  btrfs inspect-internal --help
  <snip>
      btrfs inspect-internal min-dev-size [options] <path>
          Get the minimum size the device can be shrunk to. The
      btrfs inspect-internal dump-tree [options] <device> [<device> ..]
  <snip>

The short help string can be multi-line but must be in one string.  This
patch fixes it.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-17 14:26:32 +02:00
David Sterba 60541cf29e libbtrfsutil: add API summary
Add section with brief description of all API functions so it's clear
what's there and what's missing.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-14 17:14:34 +02:00
David Sterba 96d77fcefd
Btrfs progs v5.12.1
Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-13 15:42:51 +02:00
David Sterba a8a95e54e3 btrfs-progs: update CHANGES for 5.12.1
Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-13 15:42:18 +02:00
Su Yue 4c282411eb btrfs-progs: check: continue to check space cache if sb cache_generation is 0
User reported that test fsck-tests/037-freespacetree-repair fails:

 # TEST=037\* ./fsck-tests.sh
    [TEST/fsck]   037-freespacetree-repair
 btrfs check should have detected corruption
 test failed for case 037-freespacetree-repair

The test tries to corrupt FST, call btrfs check readonly then repair FST
using btrfs check. Above case failed at the second readonly check step.
Test log said "cache and super generation don't match, space cache will
be invalidated" which is printed by validate_free_space_cache().
If cache_generation of the superblock is not -1ULL,
validate_free_space_cache() requires that cache_generation must equal
to the superblock's generation. Otherwise, it skips the check of space
cache(v1, v2) like the above case where the sb cache_generation is 0.

Since kernel commit 948462294577 ("btrfs: keep sb cache_generation
consistent with space_cache"), sb cache_generation will be set to be 0
once space cache v1 is disabled (nospace_cache/space_cache=v2). But
progs check was forgotten to be added the 0 case support.

Fix it by adding the condition if sb cache_generation is 0 in
validate_free_space_cache() as the 0 case is valid now since the
kernel commit mentioned above.

Issue: #338
Signed-off-by: Su Yue <l@damenly.su>
Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-12 20:44:12 +02:00
Su Yue 80a86f1b47 btrfs-progs: do not BUG_ON if btrfs_add_to_fsid succeeded to write superblock
Commit 8ef9313cf2 ("btrfs-progs: zoned: implement log-structured
superblock") changed to write BTRFS_SUPER_INFO_SIZE bytes to device.
The before num of bytes to be written is sectorsize.
It causes mkfs.btrfs failed on my 16k pagesize kvm:

  $ /usr/bin/mkfs.btrfs -s 16k -f -mraid0 /dev/vdb2 /dev/vdb3
  btrfs-progs v5.12
  See http://btrfs.wiki.kernel.org for more information.

  ERROR: superblock magic doesn't match
  ERROR: superblock magic doesn't match
  common/device-scan.c:195: btrfs_add_to_fsid: BUG_ON `ret != sectorsize`
  triggered, value 1
  /usr/bin/mkfs.btrfs(btrfs_add_to_fsid+0x274)[0xaaab4fe8a5fc]
  /usr/bin/mkfs.btrfs(main+0x1188)[0xaaab4fe4dc8c]
  /usr/lib/libc.so.6(__libc_start_main+0xe8)[0xffff7223c538]
  /usr/bin/mkfs.btrfs(+0xc558)[0xaaab4fe4c558]

  [1]    225842 abort (core dumped)  /usr/bin/mkfs.btrfs -s 16k -f -mraid0
  /dev/vdb2 /dev/vdb3

btrfs_add_to_fsid() now always calls sbwrite() to write
BTRFS_SUPER_INFO_SIZE bytes to device, so change condition of
the BUG_ON().
Also add comments for sbread() and sbwrite().

Signed-off-by: Su Yue <l@damenly.su>
Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-12 16:00:14 +02:00
David Sterba d4b4baf312 btrfs-progs: build: note minimal version for zoned support
The configure phase can detect the following:

- no /usr/include/blkzoned.h - no zoned support possible
- usable /usr/include/blkzoned.h - on by default
- present /usr/include/blkzoned.h but unusable due to missing struct
  members or ioctl defintion

Case 3 could be confusing, so document the requirements.

Issue: #370
Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-12 13:12:13 +02:00
David Sterba a8bc071d9e btrfs-progs: ci: list hosted CI requirements
Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-12 13:03:55 +02:00
Johannes Thumshirn e1d9e1e1a3 btrfs-progs: mkfs: check for minimal needed number of zones
In order to create a usable zoned filesystem a minimum of 5 zones is
needed:

- 2 zones for the 1st superblock
- 1 zone for the system block group
- 1 zone for a metadata block group
- 1 zone for a data block group

Some tests in fstests create a sized filesystem and depending on the zone
size of the underlying device, it may happen, that this filesystem is too
small to be used. It's better to not create a filesystem at all than to
create an unusable filesystem.

Signed-off-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-12 12:38:44 +02:00
David Sterba 79bc8135c0 btrfs-progs: build: remove duplicate library from libbtrfs-test
In some cases the -lbtrfs is not resolved and the library is not found.
But the real libbtrfs.so is linked directly and we don't need to pass
the duplicate -lbtrfs.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-11 20:13:52 +02:00
David Sterba c674031cae btrfs-progs: fix libbtrfs build, missing symbols
There's a report that snapper does not build with v5.12 due to missing
symbols in libbtrfs (https://github.com/openSUSE/snapper/issues/650).

This is caused by misplaced common/device-utils.o that should be in
libbtrfs target.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-11 13:30:34 +02:00
David Sterba b16b0a766f
Btrfs progs v5.12
Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-10 16:12:47 +02:00
David Sterba 65736bec54 btrfs-progs: update CHANGES for 5.12
Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-10 16:11:54 +02:00
David Sterba 3dad6bd6e9 btrfs-progs: use proper array designator for exclop initialization
Compiling with clang produces warnings like:

  common/utils.c:1670:31: warning: use of GNU 'missing =' extension in designator [-Wgnu-designator]
	  [BTRFS_EXCLOP_SWAP_ACTIVATE]    "swap activate",
					  ^
					  =

Use the form with '=' to fix the warning.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-08 00:58:51 +02:00
David Sterba 6c53222add btrfs-progs: delete bogus zero checksum check
The check condition (csum_result == 0) does not make sense anymore as
it's not the buffer and not the crc32c result as it used to be. The
message does not bring any value and looks like it's some debugging aid
from the old times (added in 2008 as bb7055ec21 ("Add some extra
debugging around file data checksum failures")).

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-08 00:58:51 +02:00
David Sterba e034d2bbaa btrfs-prog: docs: add recent new mount options and features
Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-08 00:58:51 +02:00
David Sterba 1af37385e2 btrfs-progs: docs: move inode_cache to deprecated options
The inode_cache mount option does nothing since 5.11, update the docs.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-08 00:58:50 +02:00
David Sterba 780355d225 btrfs-progs: fi usage: print zone unusable in the overview
Print the total zone_unusable size in the summary for 'fi usage' for a
filesystem in zoned mode. It's a sum of all the zone_unusable values
from 'fi df'. Per-device stats are not implemented and would need more
complicated calculations from raw data, kernel does not export that (but
it could).

As of 5.12, the zone_unusable is stored only in memory so we'd have to
map raw block device zones to the block groups and the live extents in
the associated block groups to get the exact numbers.

Example:

  # btrfs fi usage /mnt
  Overall:
      Device size:                   2.00GiB
      Device allocated:            768.00MiB
      Device unallocated:            1.25GiB
      Device missing:                  0.00B
      Device zone unusable:        320.00KiB
      Used:                        128.00KiB
      Free (estimated):              1.50GiB      (min: 1.50GiB)
      Free (statfs, df):             1.50GiB
      Data ratio:                       1.00
      Metadata ratio:                   1.00
      Global reserve:                3.25MiB      (used: 32.00KiB)
      Multiple profiles:                  no

  Data,single: Size:256.00MiB, Used:0.00B (0.00%)
     /dev/nullb0   256.00MiB

  Metadata,single: Size:256.00MiB, Used:112.00KiB (0.04%)
     /dev/nullb0   256.00MiB

  System,single: Size:256.00MiB, Used:16.00KiB (0.01%)
     /dev/nullb0   256.00MiB

  Unallocated:
     /dev/nullb0     1.25GiB

  # btrfs fi df
  Data, single: total=256.00MiB, used=0.00B, zone_unusable=0.00B
  System, single: total=256.00MiB, used=16.00KiB, zone_unusable=160.00KiB
  Metadata, single: total=256.00MiB, used=112.00KiB, zone_unusable=160.00KiB
  GlobalReserve, single: total=3.25MiB, used=32.00KiB

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-08 00:58:50 +02:00
David Sterba a2495d1e6e btrfs-progs: export get_zone_unusable and move to utils.c
Getting the per bg type zone unusable space will be used in other size
reports like 'fi us', so export it to the device utils.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-08 00:58:50 +02:00
David Sterba 900d2ccfe4 btrfs-progs: ci: install static libs to Tumbleweed image
All the static versions of libraries are available on Tumbleweed, let's
add them to the image.

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-08 00:58:50 +02:00
David Sterba d92d7bcd70 btrfs-progs: ci: install clang on all images
Extend build coverage. The versions are different on all images and can
be run as:

  $ ./docker-run --env CC=clang

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-08 00:58:50 +02:00
David Sterba b02d151bd1 btrfs-progs: ci: fix docker-run argument parsing
The runner script allows to pass arguments to docker and the final
command, using the -- separator. This did not work as expected, the
arguments got concatenated to the first member, not all of them passed.
The following now works:

  $ ./docker-run --env CC=clang
  $ ./docker-run --env CC=clang --
  $ ./docker-run --env CC=clang -- /bin/bash

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-08 00:58:50 +02:00
David Sterba 21a33e673d btrfs-progs: mkfs: add fallback check for signature
The support to recognize a zoned btrfs in util-linux/blkid may take time
to get updated everywhere. Add a fallback check for the signature to
avoid accidental overwrites.

The following will not succeed on a zoned device:

  $ mkfs.btrfs /dev/zoned1
  $ mkfs.btrfs /dev/zoned1
  WARNING: /dev/zoned1 contains zoned btrfs signature but was not detected by blkid, please update
  ERROR: use the -f option to force overwrite of /dev/zoned1

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-08 00:58:50 +02:00
David Sterba 06ca2c87fd btrfs-progs: mkfs: indent zone size report in the summary
The zone size belongs to the zoned section so indent it accordingly:

  Label:              (null)
  UUID:               0d27fc11-8068-4f28-a1c5-5d97cbf2890a
  Node size:          16384
  Sector size:        4096
  Filesystem size:    2.00GiB
  Block group profiles:
    Data:             single          256.00MiB
    Metadata:         single          256.00MiB
    System:           single          256.00MiB
  SSD detected:       yes
  Zoned device:       yes
    Zone size:        256.00MiB
  Incompat features:  extref, skinny-metadata, zoned
  Runtime features:
  Checksum:           crc32c
  Number of devices:  1
  Devices:
     ID        SIZE  PATH
      1     2.00GiB  /dev/nullb0

Signed-off-by: David Sterba <dsterba@suse.com>
2021-05-08 00:58:50 +02:00