Commit graph

6623 commits

Author SHA1 Message Date
David Sterba cac019e583 btrfs-progs: list-chunks: update column names
Make the column names more descriptive, PNumber is from times when there
was only physical sort. Make the type/profile more explicit, later it
can be filtered by that. The 'Age' reflects the current allocation
strategy to always pick a higher number but this could become confusing,
it's really the number when sorted by logical offset.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-27 14:45:29 +02:00
David Sterba 8d2843afca btrfs-progs: list-chunks: reflow help text of --sort
Now we can use newlines in option descriptions to make nicer lists for
options:

    --sort MODE               sort by a column ascending (default: pstart),
                              MODE can be one of:
                              pstart - physical offset, grouped by device
                              lstart - logical offset
                              usage - by chunk usage (implies --usage)
                              length_p - by chunk length, secondary by physical offset
                              length_l - by chunk length, secondary by logical offset

Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-27 14:45:29 +02:00
David Sterba c135550c28 btrfs-progs: help: indent option description newlines
A newline character in option description text will break line and then
indent the text properly, can be used for lists or paragraphs.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-27 14:45:29 +02:00
David Sterba 3d17609d66 btrfs-progs: list-chunks: add sorting by length
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-27 14:45:29 +02:00
David Sterba 73c5ad0d70 btrfs-progs: list-chunks: add sorting by usage
Add another sorting key 'usage' to sort chunks by usage, ascending. Also
implies --usage parameter so it's viewed. This ignores devid, so all
chunks are mixed.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-27 14:45:29 +02:00
David Sterba 316f221908 btrfs-progs: btrfstune: add injection points to btrfsune --csum
Add points after each commit when changing the checksum type.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-27 14:45:29 +02:00
David Sterba 6f05548661 btrfs-progs: add error injection helper script
Add a convenience script for adding new injection cookies and filter for
actual testing.

- ./inject-error new - return new unique cookie
- ./inject-error file tune/change-csum.c - show all cookies in the given
  file (takes regexp)

Example usage:

  for i in $(./inject-error file tune/change-csum.c | awk '{print $1}') ; do
	  echo "Inject $i"
	  export INJECT="$i"
	  rm img
	  cp --reflink img.filled img
	  ./btrfstune --csum blake2 img
	  btrfs check img
  done

Where 'img' is a filesystem with sample files and directories.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-27 14:45:29 +02:00
David Sterba 8922ab5d6a btrfs-progs: add simple error injection framework
To be able to test errors at specific locations, add a simple way to
check for a condition in code and controlled from user space environment
variable INJECT. For now a single value is accepted.

Use like:

	if (inject_error(0x1234)) {
		do_something();
		return -ERROR;
	}

This is enabled in debugging build by default (make D=1) and can be
enabled on demand too (make EXTRA_CFLAGS=-DINJECT).

Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-27 14:45:29 +02:00
David Sterba 4790665142 btrfs-progs: docs: update doc style and conventions
Issue: #638
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-27 14:45:29 +02:00
David Sterba bb0ca35245
Btrfs progs v6.3.3
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-27 14:33:30 +02:00
David Sterba 01418f28f1 btrfs-progs: update CHANGES for 6.3.3
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-27 14:32:00 +02:00
David Sterba c77f2f9f0d btrfs-progs: replace: properly enqueue if there's another replace running
Enqueuing allows to let some operations to wait until the current one
finishes. This usually means that it's waiting for another one, but in
case of replace there's a check that does not allow the enqueuing to
take place, as reported.

Move it before that check.

Issue: #645
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:48 +02:00
David Sterba fedd4cc596 btrfs-progs: ci: upload coverage workflow results to codecov.io
Needed to work:

- install github app Codecov, accept permissions
- copy token from codecov.io to repository secrets
- allow actions permissions to run either verified marketplace creators
  or list codecov/codecov-action@*
- set up repository as active on codecov.io, watch results eg.
  https://app.codecov.io/gh/kdave/btrfs-progs/tree/coverage-test/

Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:48 +02:00
David Sterba eceb335ab2 btrfs-progs: ci: link CI badges to the workflow pages
The plain badge links to the image, now it's pointing to the individual
workflows.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:48 +02:00
David Sterba 1b88e5166a btrfs-progs: ci: update CI badges
Add badges for the CI workflows.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:48 +02:00
David Sterba 57d9311b4d btrfs-progs: ci: add workflow for code coverage
Enable gcov build and run all tests, collect lcov results as artifacts.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:48 +02:00
David Sterba 5636dce4f6 btrfs-progs: ci: enable fuzz tests
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:48 +02:00
David Sterba f2b3170c3b btrfs-progs: build: add support for gcov
With 'make D=gcov' the files are built with gcov support. After running
the workload, the results can be viewed by 'gcov file.c' or by
lcov+genhtml.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:48 +02:00
David Sterba b3b041302e btrfs-progs: add btrfs-find-root to btrfs.box
There's a report that btrfs-find-root does not work as built-in tool in
btrfs.box, while it's advertised in the help:

  $ ./btrfs.box help --box
  Standalone tools built-in in the busybox style:
  - mkfs.btrfs
  - btrfs-image
  - btrfs-convert
  - btrfstune
  - btrfs-find-root

Add the support as it might be useful tool sometimes. In the future the
command should be moved to e.g. inspect-internal or rescue.

Issue: #648
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:48 +02:00
David Sterba 7446f2ce71 btrfs-progs: ci: build check all crypto backends
On relese tests also check all the backends, use Tumbleweed as it's
known to work there and provide all supported library versions.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:48 +02:00
Anand Jain 77f366c9da btrfs-progs: add noscan parameter to check_where_mounted
The function check_where_mounted() scans the system for all other btrfs
devices, which is necessary for its operation.  However, in certain
cases, devices remaining in the scanned state is undesirable.  Introduce
the 'noscan' argument to make devices unscanned before return.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:48 +02:00
Anand Jain e408cfb49b btrfs-progs: factor out btrfs_scan_argv_devices
To prepare for handling command line given devices factor out
btrfs_scan_argv_devices().

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:48 +02:00
Anand Jain 60771e72a4 btrfs-progs: drop argument devid from device_list_add
Drop the devid argument, it can be fetched from the disk_super argument.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:48 +02:00
Anand Jain dc9e80192b btrfs-progs: drop open_ctree_flags variable in cmd_inspect_dump_tree
Local variable open_ctree_flags carries the flags whose final update is
for the locally declared struct variable oca_flags. Just use oca.flags
directly.

Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:48 +02:00
Anand Jain d46a0ef6a0 btrfs-progs: rename struct open_ctree_flags to open_ctree_args
The struct open_ctree_flags currently holds arguments for
open_ctree_fs_info(), it can be confusing when mixed with a local variable
named open_ctree_flags as below in the function cmd_inspect_dump_tree().

  cmd_inspect_dump_tree()
  ::
  struct open_ctree_flags ocf = { 0 };
  ::
  unsigned open_ctree_flags;

So rename struct open_ctree_flags to struct open_ctree_args.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:47 +02:00
Anand Jain 626d53fc75 btrfs-progs: switch is_btrfs to bool in check_mounted_where
The variable 'is_btrfs' is declared as an integer but should be a boolean
instead.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:47 +02:00
David Sterba 177a2eeadb btrfs-progs: tests: don't show grep output when checking stream version
The test misc/058 does not properly filter out the output due to -s that
only ignores non-existent files and was there due to previous changes.
We need to use -q.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:47 +02:00
Anand Jain 82a9870d48 btrfs-progs: dump-super: fix read beyond device size
On aarch64 systems with glibc 2.28, several btrfs-progs test cases are
failing because the command 'btrfs inspect dump-super -a <dev>' reports
an error when it attempts to read beyond the disk/file-image size.

  $ btrfs inspect dump-super -a /dev/vdb12
  <snap>
  ERROR: Failed to read the superblock on /dev/vdb12 at 274877906944

And btrfs/184 also fails, as it uses -s 2 option to dump the last super
block.

	$ ./check btrfs/184
	FSTYP         -- btrfs
	PLATFORM      -- Linux/aarch64 a4k 6.4.0-rc7+ #7 SMP PREEMPT Sat Jun 24 02:47:24 EDT 2023
	MKFS_OPTIONS  -- /dev/vdb2
	MOUNT_OPTIONS -- /dev/vdb2 /mnt/scratch

	btrfs/184 1s ... [failed, exit status 1]- output mismatch (see /Volumes/ws/xfstests-dev/results//btrfs/184.out.bad)
	    --- tests/btrfs/184.out    2020-03-03 00:26:40.172081468 -0500
	    +++ /Volumes/ws/xfstests-dev/results//btrfs/184.out.bad    2023-06-24 05:54:40.868210737 -0400
	    @@ -1,2 +1,3 @@
	     QA output created by 184
	    -Silence is golden
	    +Deleted dev superblocks not scratched
	    +(see /Volumes/ws/xfstests-dev/results//btrfs/184.full for details)
	    ...
	    (Run 'diff -u /Volumes/ws/xfstests-dev/tests/btrfs/184.out /Volumes/ws/xfstests-dev/results//btrfs/184.out.bad'  to see the entire diff)
	Ran: btrfs/184
	Failures: btrfs/184
	Failed 1 of 1 tests

This is because `pread()` behaves differently on aarch64 and sets
`errno = 2` instead of the usual `errno = 0`.

To fix check if the sb offset is beyond the device size or regular file
size and skip the corresponding sbread().

Also, move putchar('\n') after a successful call to load_and_dump_sb() to
the load_and_dump_sb() itself.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:47 +02:00
Anand Jain 8da82cde9c btrfs-progs: dump-super: drop the label out and variable ret
In cmd_inspect_dump_super(), at the label 'out', nothing much happens
other than returning ret.

At the goto statement to the label, in the for loop, we perform close(fd).
However, moving the close(fd) to 'out' as well is not a good idea because
close(fd) doesn't make sense outside the for loop.

Instead, simply return 1 instead of ret=1 and then returning it. Drop both
the 'out' label and ret.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 15:00:41 +02:00
Anand Jain 4ab083175a btrfs-progs: dump-super: improve error message on failed read
Add more error information to help debugging:

  $ ./btrfs inspect-internal dump-super -Ffa /dev/vdb10

  Before:
  ERROR: failed to read the superblock on /dev/vdb10 at 274877906944

  After:
  ERROR: failed to read the superblock on /dev/vdb10 at 274877906944 read 0/4096 bytes

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 14:59:10 +02:00
Anand Jain b51117d68e btrfs-progs: tests: check for btrfs ACL support
Fix failures caused by the lack of ACL support in btrfs. For example:

  $ make test
    ::
    [TEST/misc]   057-btrfstune-free-space-tree
    failed: setfacl -m u:root:x /Volumes/ws/btrfs-progs/tests/mnt/acls/acls.1
    test failed for case 057-btrfstune-free-space-tree
    make: *** [Makefile:493: test-misc] Error 1

Similar failures occurred in the test cases convert/001-ext2-basic,
convert/003-ext4-basic, convert/005-delete-all-rollback, and
convert/006-large-hole-extent.

Resolve it by adding a check for ACL support using the
check_kernel_support_acl() helper function. It gracefully handles the case
when ACL support is not compiled by calling _not_run().

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 14:59:10 +02:00
Anand Jain 1fb1ae8ebb btrfs-progs: tests: add helper to check if ACLs are supported
Some test cases are failing when ACL is not compiled in the system.
Instead, they should be marked as 'not_run'.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 14:59:10 +02:00
Anand Jain d52686fc2a btrfs-progs: tests: move delete_subvol_children under HAVE_BTRFSUTIL_H fsstress.c
Bring the  'delete_subvol_children' function under the HAVE_BTRFSUTIL_H
define and fix the following warnings. This function is called only when
'HAVE_BTRFSUTILS_H' is defined.

tests/fsstress.c:1183:1: warning: ‘delete_subvol_children’ defined but not used [-Wunused-function]
 1183 | delete_subvol_children(int parid

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 14:59:10 +02:00
Anand Jain b31f1e6988 btrfs-progs: tests: move do_fallocate under HAVE_LINUX_FALLOC_H in fsstress.c
Move the entire 'do_fallocate' function under the 'HAVE_LINUX_FALLOC_H'
define and fix the following warnings. This function is called only when
'HAVE_LINUX_FALLOC_H' is defined.

tests/fsstress.c:3814:1: warning: ‘do_fallocate’ defined but not used [-Wunused-function]
 3814 | do_fallocate(opnum_t opno, long r, int mode)

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 14:59:10 +02:00
Anand Jain 282c05698a btrfs-progs: tests: move do_mmap under HAVE_SYS_MMAN_H in fsstress.c
Move the entire 'do_mmap' function under the 'HAVE_SYS_MMAN_H' define
and fix the following warnings. This function is called only when
'HAVE_SYS_MMAN_H' is defined.

tests/fsstress.c:4363:1: warning: ‘do_mmap’ defined but not used [-Wunused-function]
 4363 | do_mmap(opnum_t opno, long r, int prot)

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 14:59:10 +02:00
Anand Jain 3b8a552fd7 btrfs-progs: tests: fix missing prototype warnings in fssum.c
Annoying warnings when running 'make test' from the file tests/fssum.c.
gcc version 8.5.0. Fix the it by declaring the corresponding functions as static.

$ rm fssum
$ make TEST=001\* test-misc
::
tests/fssum.c:86:1: warning: no previous prototype for ‘getln’ [-Wmissing-prototypes]
   86 | getln(char *buf, int size, FILE *fp)
      | ^~~~~
tests/fssum.c:103:1: warning: no previous prototype for ‘parse_flag’ [-Wmissing-prototypes]
  103 | parse_flag(int c)
      | ^~~~~~~~~~
tests/fssum.c:123:1: warning: no previous prototype for ‘parse_flags’ [-Wmissing-prototypes]
  123 | parse_flags(char *p)
      | ^~~~~~~~~~~
tests/fssum.c:130:1: warning: no previous prototype for ‘usage’ [-Wmissing-prototypes]
  130 | usage(void)
      | ^~~~~
tests/fssum.c:163:1: warning: no previous prototype for ‘alloc’ [-Wmissing-prototypes]
  163 | alloc(size_t sz)
      | ^~~~~
tests/fssum.c:176:1: warning: no previous prototype for ‘sum_init’ [-Wmissing-prototypes]
  176 | sum_init(sum_t *cs)
      | ^~~~~~~~
tests/fssum.c:182:1: warning: no previous prototype for ‘sum_fini’ [-Wmissing-prototypes]
  182 | sum_fini(sum_t *cs)
      | ^~~~~~~~
tests/fssum.c:188:1: warning: no previous prototype for ‘sum_add’ [-Wmissing-prototypes]
  188 | sum_add(sum_t *cs, void *buf, int size)
      | ^~~~~~~
tests/fssum.c:194:1: warning: no previous prototype for ‘sum_add_sum’ [-Wmissing-prototypes]
  194 | sum_add_sum(sum_t *dst, sum_t *src)
      | ^~~~~~~~~~~
tests/fssum.c:200:1: warning: no previous prototype for ‘sum_add_u64’ [-Wmissing-prototypes]
  200 | sum_add_u64(sum_t *dst, uint64_t val)
      | ^~~~~~~~~~~
tests/fssum.c:207:1: warning: no previous prototype for ‘sum_add_time’ [-Wmissing-prototypes]
  207 | sum_add_time(sum_t *dst, time_t t)
      | ^~~~~~~~~~~~
tests/fssum.c:213:1: warning: no previous prototype for ‘sum_to_string’ [-Wmissing-prototypes]
  213 | sum_to_string(sum_t *dst)
      | ^~~~~~~~~~~~~
tests/fssum.c:225:1: warning: no previous prototype for ‘namecmp’ [-Wmissing-prototypes]
  225 | namecmp(const void *aa, const void *bb)
      | ^~~~~~~
tests/fssum.c:234:1: warning: no previous prototype for ‘sum_xattrs’ [-Wmissing-prototypes]
  234 | sum_xattrs(int fd, sum_t *dst)
      | ^~~~~~~~~~
tests/fssum.c:325:1: warning: no previous prototype for ‘sum_file_data_permissive’ [-Wmissing-prototypes]
  325 | sum_file_data_permissive(int fd, sum_t *dst)
      | ^~~~~~~~~~~~~~~~~~~~~~~~
tests/fssum.c:341:1: warning: no previous prototype for ‘sum_file_data_strict’ [-Wmissing-prototypes]
  341 | sum_file_data_strict(int fd, sum_t *dst)
      | ^~~~~~~~~~~~~~~~~~~~
tests/fssum.c:369:1: warning: no previous prototype for ‘escape’ [-Wmissing-prototypes]
  369 | escape(char *in)
      | ^~~~~~
tests/fssum.c:389:1: warning: no previous prototype for ‘excess_file’ [-Wmissing-prototypes]
  389 | excess_file(const char *fn)
      | ^~~~~~~~~~~
tests/fssum.c:395:1: warning: no previous prototype for ‘missing_file’ [-Wmissing-prototypes]
  395 | missing_file(const char *fn)
      | ^~~~~~~~~~~~
tests/fssum.c:401:1: warning: no previous prototype for ‘pathcmp’ [-Wmissing-prototypes]
  401 | pathcmp(const char *a, const char *b)
      | ^~~~~~~
tests/fssum.c:419:1: warning: no previous prototype for ‘check_match’ [-Wmissing-prototypes]
  419 | check_match(char *fn, char *local_m, char *remote_m,
      | ^~~~~~~~~~~
tests/fssum.c:438:1: warning: no previous prototype for ‘check_manifest’ [-Wmissing-prototypes]
  438 | check_manifest(char *fn, char *m, char *c, int last_call)
      | ^~~~~~~~~~~~~~
tests/fssum.c:509:1: warning: no previous prototype for ‘sum’ [-Wmissing-prototypes]
  509 | sum(int dirfd, int level, sum_t *dircs, char *path_prefix, char *path_in)
      | ^~~
    [LD]     fsstress
tests/fsstress.c:4363:1: warning: ‘do_mmap’ defined but not used [-Wunused-function]
 4363 | do_mmap(opnum_t opno, long r, int prot)
      | ^~~~~~~
tests/fsstress.c:3814:1: warning: ‘do_fallocate’ defined but not used [-Wunused-function]
 3814 | do_fallocate(opnum_t opno, long r, int mode)
      | ^~~~~~~~~~~~
tests/fsstress.c:1183:1: warning: ‘delete_subvol_children’ defined but not used [-Wunused-function]
 1183 | delete_subvol_children(int parid)

Signed-off-by: Anand Jain <anand.jain@oracle.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 14:59:10 +02:00
David Sterba a0137082de btrfs-progs: docs: formatting updates
- use :file: and :command:
- simplify manual page references
- add more web links
- typo fixes
- more cross-references

Signed-off-by: David Sterba <dsterba@suse.com>
2023-07-26 14:59:10 +02:00
David Sterba 22cf63d8ee btrfs-progs: kernel-shared: add helper write_extent_buffer_chunk_tree_uuid
Sync the helper write_extent_buffer_chunk_tree_uuid from kernel.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-06-27 23:40:56 +02:00
David Sterba 339de9b2d7 btrfs-progs: kernel-shared: use write_extent_buffer_fsid where possible
We already have the helper but don't use it everywhere.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-06-27 16:29:58 +02:00
David Sterba f094e35d63 btrfs-progs: kernel-shared: use copy_extent_buffer_full where possible
We already have the helper for full extent buffer copy but don't use it
everywhere.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-06-27 16:29:54 +02:00
David Sterba 53b64cc366 btrfs-progs: minor source sync with kernel 6.4
Sync a few more file on the source level with kernel 6.4, no functional
changes.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-06-27 16:15:35 +02:00
David Sterba 2bc4002583 btrfs-progs: docs: update 6.4 kernel development stats
Signed-off-by: David Sterba <dsterba@suse.com>
2023-06-26 23:09:47 +02:00
David Sterba 8a59d12c92 btrfs-progs: tests: support starting from a given test
Add make command line variable TEST_FROM that takes a glob from where to
start the test sequence. Update docs and fix some trivial typos.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-06-21 16:44:30 +02:00
David Sterba 316499ed79 btrfs-progs: fix 6.3.2 change description regarding big endian hosts
The build is fine on BE but endianness was broken which prevents mkfs
and anything else on existing images.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-06-15 13:58:43 +02:00
David Sterba 3139c26079 btrfs-progs: ci: run more workflows after pushing master branch
Run release tests after pushing master branch to verify that everything
is ok, also trigger the static build so there are binaries built with
the new version tag.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-06-15 13:41:52 +02:00
David Sterba d1d8fb4b59
Btrfs progs v6.3.2
Signed-off-by: David Sterba <dsterba@suse.com>
2023-06-15 13:37:06 +02:00
David Sterba 77988fef38 btrfs-progs: update CHANGES for 6.3.2
Signed-off-by: David Sterba <dsterba@suse.com>
2023-06-15 12:24:48 +02:00
Qu Wenruo c88ac0170b btrfs-progs: scrub: unify the output numbers for "Total to scrub"
[BUG]
Command `btrfs scrub start -B` and `btrfs scrub status` are reporting
very different results for "Total to scrub":

  $ sudo btrfs scrub start -B /mnt/btrfs/
  scrub done for c107ef62-0a5d-4fd7-a119-b88f38b8e084
  Scrub started:    Mon Jun  5 07:54:07 2023
  Status:           finished
  Duration:         0:00:00
  Total to scrub:   1.52GiB
  Rate:             0.00B/s
  Error summary:    no errors found

  $ sudo btrfs scrub status /mnt/btrfs/
  UUID:             c107ef62-0a5d-4fd7-a119-b88f38b8e084
  Scrub started:    Mon Jun  5 07:54:07 2023
  Status:           finished
  Duration:         0:00:00
  Total to scrub:   12.00MiB
  Rate:             0.00B/s
  Error summary:    no errors found

This can be very confusing for end users.

[CAUSE]
It's the function print_fs_stat() handling the "Total to scrub" output.

For `btrfs scrub start` command, we use the used bytes (aka, the total
used dev extents of a device) for output.

This is not really accurate, as the chunks may be mostly empty just like
the following:

  $ btrfs fi df /mnt/btrfs/
  Data, single: total=1.01GiB, used=9.06MiB
  System, DUP: total=40.00MiB, used=64.00KiB
  Metadata, DUP: total=256.00MiB, used=1.38MiB
  GlobalReserve, single: total=22.00MiB, used=0.00B

Thus we're reporting 1.5GiB to scrub (1.01GiB + 40MiB * 2 + 256MiB * 2).
But in reality, we only scrubbed 12MiB
(9.06MiB + 64KiB * 2 + 1.38MiB * 2).

[FIX]
Instead of using the used dev-extent bytes of a device, go with proper
scrubbed bytes for each device.

This involves print_fs_stat() and print_scrub_dev() called inside
scrub_start().

Now the output should match each other.

Issue: #636
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-06-15 12:24:48 +02:00
Qu Wenruo af6f301834 btrfs-progs: fix accessors for big endian systems
[BUG]
There is a bug report that on s390x big endian systems, mkfs.btrfs just
fails:

  $ mkfs.btrfs  -f ~/test.img
  btrfs-progs v6.3.1
  Invalid mapping for 1081344-1097728, got 17592186044416-17592190238720
  Couldn't map the block 1081344
  ERROR: cannot read chunk root
  ERROR: open ctree failed

[CAUSE]
The error is caused by wrong endian conversion. The s390x is a big
endian architecture:

  $ lscpu
  Byte Order:            Big Endian

While checking the offending @disk_key and @key inside
btrfs_read_sys_array(), we got:

  2301		while (cur_offset < array_size) {
  (gdb)
  2304			if (cur_offset + len > array_size)
  (gdb)
  2307			btrfs_disk_key_to_cpu(&key, disk_key);
  (gdb)
  2310			sb_array_offset += len;
  (gdb) print *disk_key
  $2 = {objectid = 281474976710656, type = 228 '\344', offset = 17592186044416}
  (gdb) print key
  $3 = {objectid = 281474976710656, type = 228 '\344', offset = 17592186044416}
  (gdb)

Now we can see, @disk_key is indeed in the little endian, but @key is
not converted to the CPU native endian.

Furthermore, if we step into the help btrfs_disk_key_to_cpu(), it shows
we're using little endian version:

  (gdb) step
  btrfs_disk_key_to_cpu (disk_key=0x109fcdb, cpu_key=0x3ffffff847f)
      at ./kernel-shared/accessors.h:592
  592		memcpy(cpu_key, disk_key, sizeof(struct btrfs_key));

[FIX]
The kernel accessors.h checks if __LITTLE_ENDIAN is defined or not, but
that only works inside kernel.

In user space, __LITTLE_ENDIAN and __BIG_ENDIAN are both provided by
kerncompat.h that should have been included already.

Instead we should check __BYTE_ORDER against __LITTLE_ENDIAN to
determine our endianness.

With this change, s390x build works as expected now.

Issue: #639
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-06-15 12:24:09 +02:00
Boris Burkov aa49b7cfbb btrfs-progs: docs: discourage seeding remount workflow
The remount workflow could cause some problems so make a note about it.
Recommend the umount/mount step by default. A seeding device used for
e.g. a root filesystem that gets updated and has snapshots is a real
world example where the space consumed by unreclaimed deleted snapshots
would hurt.

Pull-request: #462
Author: Boris Burkov <boris@bur.io>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-06-09 12:55:13 +02:00