Commit graph

6301 commits

Author SHA1 Message Date
David Sterba 076891943a btrfs-progs: crypto: test all implementations
Now that there are more implementations for the hashes test them all on
the vectors if the CPU supports that.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 19:49:30 +01:00
David Sterba e772621053 btrfs-progs: crypto: add more test vectors
Add test vectors that are longer that the internal block length.
Accelerated implementations may not be used on the short or unpaded
blocks but we need to test them as well.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 19:49:30 +01:00
David Sterba 6a7a0d8af8 btrfs-progs: crypto: add accelerated SHA256 implementation
Copy sha256-x86.c from https://github.com/noloader/SHA-Intrinsics, that
uses the compiler intrinsics to implement the update step with the
native x86_64 instructions.

To avoid dependencies of the reference code and the x86 version, check
runtime support only if the compiler also supports -msha.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 19:49:30 +01:00
David Sterba 7d1353fa01 btrfs-progs: hash-speedtest: add accelerated BLAKE2 implementations
Benchmark all accelerated implementations if the CPU supports them. Set
the level before each test, expecting that the implementation switches
the implementation dynamically.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 19:49:30 +01:00
David Sterba 23cb9771bc btrfs-progs: crypto: add AVX2 implementation of BLAKE2
Copy AVX2 implementation from https://github.com/sneves/blake2-avx2 .
Though this is marked experimental, libsodium uses this version.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 19:49:29 +01:00
David Sterba d61739003d btrfs-progs: crypto: add SSE4.1 implementation of BLAKE2
Copy SSE4.1 implementation from https://github.com/BLAKE2/BLAKE2 .

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 19:49:06 +01:00
David Sterba 1f2117eae8 btrfs-progs: crypto: add SSE2 implementation of BLAKE2
Copy implementation from https://github.com/BLAKE2/BLAKE2, add runtime
detection of SSE2 and add the switch function.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-28 19:48:24 +01:00
David Sterba 3157c572e1 btrfs-progs: add run-time CPU feature detection
Add support for run-time detection of CPU features on x86_64 to allow
selection of accelerated implementations of hash algorithms.

When possible use the compiler builtin (works on gcc and clang).
The SHA extensions can't be detected by __builtin_cpu_supports and the
__cpuid/__cpuidex macros are not consistently provided in all supported
gcc and clang versions. Copy the __cpuidex and call it manually for the
SHA extensions. Complete list https://en.wikipedia.org/wiki/CPUID .

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:44:03 +01:00
Qu Wenruo f914949b1a btrfs-progs: fix set but not used variables
[WARNING]
Clang 15.0.7 warns about several unused variables:

  kernel-shared/zoned.c:829:6: warning: variable 'num_sequential' set but not used [-Wunused-but-set-variable]
          u32 num_sequential = 0, num_conventional = 0;
              ^
  cmds/scrub.c:1174:6: warning: variable 'n_skip' set but not used [-Wunused-but-set-variable]
          int n_skip = 0;
              ^
  mkfs/main.c:493:6: warning: variable 'total_block_count' set but not used [-Wunused-but-set-variable]
          u64 total_block_count = 0;
              ^
  image/main.c:2246:6: warning: variable 'bytenr' set but not used [-Wunused-but-set-variable]
          u64 bytenr = 0;
              ^

[CAUSE]
Most of them are just straightforward set but not used variables.

The only exception is total_block_count, which has commented out code
relying on it.

[FIX]
Just remove those variables, and for @total_block_count, also remove the
comments.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:44:03 +01:00
Qu Wenruo c3a41e5d4c btrfs-progs: move a union with variable sized type to the end
[WARNING]
Clang 15.0.7 gives the following warning:

  image/main.c:95:2: warning: field '' with variable sized type 'union metadump_struct::(anonymous at image/main.c:95:2)' not at the end of a struct or class is a GNU extension [-Wgnu-variable-sized-type-not-at-end]
          union {
          ^

[CAUSE]
The union contains meta_cluster, which variable sized:

  struct meta_cluster {
  	struct meta_cluster_header header;
  	struct meta_cluster_item items[];
  } __attribute__ ((__packed__));

Thus clang gives above warning since it's a GNU extension.

[FIX]
Just move the union to the end of the structure.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:44:02 +01:00
Qu Wenruo 3a1d4aa089 btrfs-progs: fix fallthrough cases with proper attributes
[FALSE ALERT]
Unlike gcc, clang doesn't really understand the comments, thus it's
reportings tons of fall through related errors:

  cmds/reflink.c:124:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough]
                  case 'r':
                  ^
  cmds/reflink.c:124:3: note: insert '__attribute__((fallthrough));' to silence this warning
                  case 'r':
                  ^
                  __attribute__((fallthrough));
  cmds/reflink.c:124:3: note: insert 'break;' to avoid fall-through
                  case 'r':
                  ^
                  break;

[CAUSE]
Although gcc is fine with /* fallthrough */ comments, clang is not.

[FIX]
So just introduce a fallthrough macro to handle the situation properly,
and use that macro instead.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:44:02 +01:00
Qu Wenruo 66dad3a8f5 btrfs-progs: fix a false alert on an uninitialized variable when BUG_ON() is involved
[FALSE ALERT]
Clang 15.0.7 gives the following false alert in get_dev_extent_len():

  kernel-shared/extent-tree.c:3328:2: warning: variable 'div' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
          default:
          ^~~~~~~
  kernel-shared/extent-tree.c:3332:24: note: uninitialized use occurs here
          return map->ce.size / div;
                                ^~~
  kernel-shared/extent-tree.c:3311:9: note: initialize the variable 'div' to silence this warning
          int div;
                 ^
                  = 0

And one in btrfs_stripe_length() too:

  kernel-shared/volumes.c:2781:2: warning: variable 'stripe_len' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
          default:
          ^~~~~~~
  kernel-shared/volumes.c:2785:9: note: uninitialized use occurs here
          return stripe_len;
                 ^~~~~~~~~~
  kernel-shared/volumes.c:2754:16: note: initialize the variable 'stripe_len' to silence this warning
          u64 stripe_len;
                        ^
                         = 0

[CAUSE]
Clang doesn't really understand what BUG_ON() means, thus in that
default case, we won't get uninitialized value but crash directly.

[FIX]
Silent the errors by assigning the default value properly using the
value of SINGLE profile.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:44:02 +01:00
Qu Wenruo e2806fd624 btrfs-progs: remove an unnecessary branch to silent the clang warning
[FALSE ALERT]
With clang 15.0.7, there is a false alert on uninitialized value in
ctree.c:

  kernel-shared/ctree.c:3418:13: warning: variable 'offset' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
          } else if (ret < 0) {
                     ^~~~~~~
  kernel-shared/ctree.c:3428:41: note: uninitialized use occurs here
          write_extent_buffer(eb, &subvol_id_le, offset, sizeof(subvol_id_le));
                                                 ^~~~~~
  kernel-shared/ctree.c:3418:9: note: remove the 'if' if its condition is always true
          } else if (ret < 0) {
                 ^~~~~~~~~~~~~
  kernel-shared/ctree.c:3380:22: note: initialize the variable 'offset' to silence this warning
          unsigned long offset;
                              ^
                               = 0
  kernel-shared/ctree.c:3418:13: warning: variable 'eb' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
          } else if (ret < 0) {
                     ^~~~~~~
  kernel-shared/ctree.c:3429:26: note: uninitialized use occurs here
          btrfs_mark_buffer_dirty(eb);
                                  ^~
  kernel-shared/ctree.c:3418:9: note: remove the 'if' if its condition is always true
          } else if (ret < 0) {
                 ^~~~~~~~~~~~~
  kernel-shared/ctree.c:3378:26: note: initialize the variable 'eb' to silence this warning
          struct extent_buffer *eb;
                                  ^
                                   = NULL

[CAUSE]
The original code is handling the return value from
btrfs_insert_empty_item() like this:

	ret = btrfs_insert_empty_item();
	if (ret >= 0) {
		/* Do something for it. */
	} else if (ret == -EEXIST) {
		/* Do something else. */
	} else if (ret < 0) {
		/* Error handling. */
	}

But the problem is, the last one check is always true if we can reach
there.

Thus clang is providing the hint to remove the if () check.

[FIX]
Normally we prefer to do error handling first, so move the error
handling first so we don't need the if () else if () chain.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:44:02 +01:00
Filipe Manana e3209f8792 btrfs-progs: receive: fix a corruption when decompressing zstd extents
Before decompressing, we zero out the content of the entire output buffer,
so that we don't get any garbage after the last byte of data. We do this
for all compression algorithms. However zstd, at least with libzstd 1.5.2
on Debian (version 1.5.2+dfsg-1), the decompression routine can end up
touching the content of the output buffer beyond the last valid byte of
decompressed data, resulting in a corruption.

Example reproducer:

   $ cat test.sh
   #!/bin/bash

   DEV=/dev/sdj
   MNT=/mnt/sdj

   rm -f /tmp/send.stream

   umount $DEV &> /dev/null
   mkfs.btrfs -f $DEV &> /dev/null || echo "MKFS failed!"
   mount -o compress=zstd $DEV $MNT

   # File foo is not sector size aligned, 127K.
   xfs_io -f -c "pwrite -S 0xab 0 3" \
             -c "pwrite -S 0xcd 3 130042" \
             -c "pwrite -S 0xef 130045 3" $MNT/foo

   # Now do an fallocate that increases the size of foo from 127K to 128K.
   xfs_io -c "falloc 0 128K " $MNT/foo

   btrfs subvolume snapshot -r $MNT $MNT/snap

   btrfs send --compressed-data -f /tmp/send.stream $MNT/snap

   echo -e "\nFile data in the original filesystem:\n"
   od -A d -t x1 $MNT/snap/foo

   umount $MNT
   mkfs.btrfs -f $DEV &> /dev/null || echo "MKFS failed!"
   mount $DEV $MNT

   btrfs receive --force-decompress -f /tmp/send.stream $MNT

   echo -e "\nFile data in the new filesystem:\n"
   od -A d -t x1 $MNT/snap/foo

   umount $MNT

Running the reproducer gives:

   $ ./test.sh
   (...)
   File data in the original filesystem:

   0000000 ab ab ab cd cd cd cd cd cd cd cd cd cd cd cd cd
   0000016 cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd
   *
   0130032 cd cd cd cd cd cd cd cd cd cd cd cd cd ef ef ef
   0130048 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   *
   0131072
   At subvol snap

   File data in the new filesystem:

   0000000 ab ab ab cd cd cd cd cd cd cd cd cd cd cd cd cd
   0000016 cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd cd
   *
   0130032 cd cd cd cd cd cd cd cd cd cd cd cd cd ef ef ef
   0130048 cd cd cd cd 00 00 00 00 00 00 00 00 00 00 00 00
   0130064 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
   *
   0131072

The are 4 bytes with a value of 0xcd instead of 0x00, at file offset
127K (130048).

Fix this by explicitly zeroing out the part of the output buffer that was
not used after decompressing with zstd.

The decompression of compressed extents, sent when using the send v2
stream, happens in the following cases:

1) By explicitly passing --force-decompress to the receive command, as in
   the reproducer above;

2) Calling the BTRFS_IOC_ENCODED_WRITE ioctl failed with -ENOTTY, meaning
   the kernel on the receiving side is old and does not implement that
   ioctl;

3) Calling the BTRFS_IOC_ENCODED_WRITE ioctl failed with -ENOSPC;

4) Calling the BTRFS_IOC_ENCODED_WRITE ioctl failed with -EINVAL.

Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:44:02 +01:00
David Sterba 8affa4e116 btrfs-progs: image: use help and cmd_struct for printing help text
Unify the image help text so it uses the help framework. The cmd struct
is set up only partially.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:44:02 +01:00
David Sterba 512467c17e btrfs-progs: tune: use help and cmd_struct for printing help text
Unify the btrfstune help text so it uses the help framework. The cmd
struct is set up only partially.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:44:02 +01:00
David Sterba 4de40f3a5e btrfs-progs: tune: remove unused includes
Remove includes reported by include-what-you-use after the refactoring.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-02-18 17:44:02 +01:00
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
David Sterba 7305c69cf9 btrfs-progs: subvol sync: print count and progress
By default print how many subvolumes are considered for checks, either
found or specified on the command line. Once a subvolume is removed from
the list print the progress from the total count.

  $ btrfs subvolume sync /path
  Waiting for 130 subvolumes
  Subvolume id 256 is gone (1/130)
  Subvolume id 257 is gone (2/130)
  ...
  Subvolume id 384 is gone (129/130)
  Subvolume id 385 is gone (130/130)

Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 19:55:47 +01:00
David Sterba 347c8209e8 btrfs-progs: mkfs: convert help text to option formatter
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 19:55:47 +01:00
David Sterba dfd58c294b btrfs-progs: mkfs: use help and cmd_struct for printing help text
Unify the mkfs help text so it uses the help framework. The cmd struct
is set up only partially.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 19:55:47 +01:00
David Sterba c719f20b74 btrfs-progs: help: change how padding is printed
Use the configured widths and print padding directly instead of the
embedded printf format and fixed width strings.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 19:55:47 +01:00
David Sterba fede0c5057 btrfs-progs: help: add option text formatting infrastructure
To make option formatting a bit easier so the spacing is unified add
macros and formatting helpers.

Usage in the help text:

	OPTLINE("-o value", "description")

Internally the option and description are delimiters by chars that are
not part of normal text, the formatter separates that and uses fixed
with for output. The description text can be of any length, multi-line
text should still end up as one token (i.e. newline without ',' between).

Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 19:55:47 +01:00
David Sterba 908b4b4450
Btrfs progs v6.1.3
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 19:39:27 +01:00
David Sterba 46a3665671 btrfs-progs: update CHANGES for 6.1.3
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 16:55:54 +01:00
Christopher Yeleighton 29017208b8 btrfs-progs: docs: describe formatting of sizes
Input must be prepared and output must be interpreted under the C
locale, which requires special precautions on the client’s side.

Pull-request: #561
Author: Christopher Yeleighton <ne01026@shark.2a.pl>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 16:20:36 +01:00
pinysuse 7f10503bcd btrfs-progs: docs: add heading to ch-mount-options.rst
The header of the main section seems to be missing --> added.

Pull-request: #565
Author: pinysuse
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 16:20:33 +01:00
Christopher Head cf7b55a980 btrfs-progs: docs: document some subvolume related ioctls
Author: Christopher Head <chead@chead.ca>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 16:20:31 +01:00
Christopher Head c5e3671121 btrfs-progs: docs: add missing ioctl names to the list
Author: Christopher Head <chead@chead.ca>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 16:20:28 +01:00
Christopher Head 23b2f8a1e7 btrfs-progs: docs: add struct btrfs_ioctl_get_subvol_info_args
Author: Christopher Head <chead@chead.ca>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 16:20:27 +01:00
Christopher Head 3387667966 btrfs-progs: docs: add up-to-date definition of btrfs_ioctl_vol_args_v2
Author: Christopher Head <chead@chead.ca>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 16:20:24 +01:00
Naohiro Aota 2b4bebeacc btrfs-progs: docs: add sysfs chunk_size description
Add description for /sys/fs/btrfs/<uuid>/allocation/<type>/chunk_size.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 16:20:18 +01:00
Naohiro Aota 2a20dc237c btrfs-progs: docs: fix sysfs nodesize typo
Fix the typo.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 16:20:16 +01:00
Naohiro Aota cdcdcf17af btrfs-progs: docs: add sysfs per-space_info bg_reclaim_threshold entry
There are two "bg_reclaim_threshold" under the sysfs directory. One is at
/sys/fs/btrfs/<UUID>/ and sets the threshold to start the auto reclaim
thread. The other one is
at/sys/fs/btrfs/<UUID>/allocations/{data,metadata,system} and sets the
threshold to reclaim a block group.

These two options have the same name but they are calculated against
different metrics. The former is a percentage of allocated (for a device
extent) space on total device space, and the latter is a percentage of
reclaimable space on a block group's zone capacity.

Add description for per-space_info bg_reclaim_threshold to distinguish
these two same name configurations.

Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 16:20:14 +01:00
Qu Wenruo 04930385fd btrfs-progs: check: enhance the error output for backref mismatch
[PROBLEM]
Btrfs check original mode output is not that reader friendly already, it
even includes pointer output:

  backref 15353727729664 parent 1140559929556992 not referenced back 0xc9133d70
  tree backref 15353727729664 parent 14660022714368 not found in extent tree
  incorrect global backref count on 15353727729664 found 3 wanted 2
  backpointer mismatch on [15353727729664 16384]

In above case, the "0xc9133d70" is completely useless, as it's a pointer
for the tree_backref structure.

And the term "backref" is quite abused in above case.

[ENHANCEMENT]
To enhance the situation, let's use some output format from lowmem mode
instead.

Now above example will be changed to:

  tree extent[15353727729664, 16384] parent 1140559929556992 has no tree block found
  tree extent[15353727729664, 16384] parent 14660022714368 has no backref item in extent tree
  incorrect global backref count on 15353727729664 found 3 wanted 2
  backpointer mismatch on [15353727729664 16384]

And some example for data backrefs:

  data extent[12845056, 1048576] bytenr mimsmatch, extent item bytenr 12845056 file item bytenr 0
  data extent[12845056, 1048576] referencer count mismatch (root 5 owner 257 offset 0) wanted 1 have 0

  data extent[14233600, 12288] referencer count mismatch (parent 42139648) wanted 0 have 1
  data extent[14233600, 12288] referencer count mismatch (root 5 owner 307 offset 0) wanted 0 have 1
  data extent[14233600, 12288] referencer count mismatch (parent 30507008) wanted 0 have 1

Furthermore, the original function print_tree_backref_error() is a mess
already, here we clean it up by exacting all the error output into a
dedicated helper, print_backref_error(), so the function itself only
need to find out errors.

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 16:19:59 +01:00
Naohiro Aota d8c6021727 btrfs-progs: mkfs: check blkid version on zoned filesystems
Prior to version 2.38, libblkid fails to detect zoned mode's superblock
location resulting in blkid failing to detect btrfs on zoned block
devices. This patch suggest to the user to upgrade libblkid if it
detects a version lower then 2.38.

Reviewed-by: Johannes Thumshirn <johannes.thumshirn@wdc.com>
Signed-off-by: Naohiro Aota <naohiro.aota@wdc.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 16:19:55 +01:00
David Sterba f5884fc8ca btrfs-progs: docs: drop copyright year from manual pages
The copyright config variable can be used for a real copyright but we
don't have that for the manual pages and it was a stub. The date of page
generation time is added to the page anyway.

Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 16:19:51 +01:00
Qu Wenruo 0d901db20a btrfs-progs: docs: add sysfs doc
This patch will add a dedicated section for btrfs sysfs interfaces.

It will include:

- Directory layout explanation
  Including:
  * Description
  * Introduced in which kernel version

- Files explanation
  Including:
  * RW/RO type
  * Description
  * Introduced in which kernel version

Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 16:19:43 +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 54b90cb6e5 btrfs-progs: fi mkswapfile: fix page count in header
Per user report on https://old.reddit.com/r/btrfs/comments/107fnw1/btrfs_filesystem_mkswapfile_results_in_an/
the swapfile header does not contain the correct number of pages that
matches the file size and the activated swapfile is only 1GiB:

  # btrfs filesystem mkswapfile -s 10g swapfile
  # swapon swapfile
  # cat /proc/swaps
  Filename          Type    Size       Used    Priority
  /swap/swapfile    file    1048572    0       -2

A workaround is to run 'mkswap swapfile' before activation. Proper fix
is to calculate the number of (fixed size) 4K pages available for the
swap.

Issue: #568
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-25 16:19:36 +01:00
David Sterba 660d10d3fb
Btrfs progs v6.1.2
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-05 19:07:04 +01:00
David Sterba f1a910ba60 btrfs-progs: update CHANGES for 6.1.2
Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-05 19:06:48 +01:00
David Sterba 6fd4241e87 btrfs-progs: inspect: add build conditionals around list-chunk
In default build there's a warning (reported by CI) that the
experimental list-chunk command and related functions are not used, so
add the condition there as well.

  In file included from cmds/inspect.c:45:
  ./cmds/commands.h:67:26: warning: 'cmd_struct_inspect_list_chunks' defined but not used [-Wunused-const-variable=]
   #define __CMD_NAME(name) cmd_struct_ ##name
			    ^~~~~~~~~~~
  ./cmds/commands.h:73:26: note: in expansion of macro '__CMD_NAME'
    const struct cmd_struct __CMD_NAME(name) =   \
			    ^~~~~~~~~~
  ./cmds/commands.h:88:2: note: in expansion of macro 'DEFINE_COMMAND'
    DEFINE_COMMAND(name, token, cmd_ ##name,   \
    ^~~~~~~~~~~~~~
  cmds/inspect.c:1115:8: note: in expansion of macro 'DEFINE_SIMPLE_COMMAND'
   static DEFINE_SIMPLE_COMMAND(inspect_list_chunks, "list-chunks");
	  ^~~~~~~~~~~~~~~~~~~~~

Signed-off-by: David Sterba <dsterba@suse.com>
2023-01-05 14:59:12 +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