]> git.sesse.net Git - bcachefs-tools-debian/log
bcachefs-tools-debian
4 months agonix: fix build
Will Fancher [Sun, 21 Jan 2024 22:16:51 +0000 (17:16 -0500)]
nix: fix build

4 months agoMerge pull request #219 from xhebox/master
koverstreet [Sun, 21 Jan 2024 12:08:23 +0000 (07:08 -0500)]
Merge pull request #219 from xhebox/master

bch_bindgen: add liburcu paths by pkgconfig

4 months agobch_bindgen: add liburcu paths by pkgconfig
xhe [Sun, 21 Jan 2024 11:04:31 +0000 (19:04 +0800)]
bch_bindgen: add liburcu paths by pkgconfig

Signed-off-by: xhe <xw897002528@gmail.com>
4 months agoRemove gag usage
Kent Overstreet [Sun, 21 Jan 2024 01:29:48 +0000 (20:29 -0500)]
Remove gag usage

Possibly-fixes: https://github.com/koverstreet/bcachefs-tools/issues/217
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agoMove c_src dirs back to toplevel
Kent Overstreet [Tue, 16 Jan 2024 22:00:02 +0000 (17:00 -0500)]
Move c_src dirs back to toplevel

We just wanted c sourcefiles out of the top level, not c source
directories.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agorust: bump rpassword to v7.x
Faidon Liambotis [Tue, 9 Jan 2024 10:53:00 +0000 (12:53 +0200)]
rust: bump rpassword to v7.x

Including a tiny API change.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agomove Rust sources to top level, C sources into c_src
Thomas Bertschinger [Tue, 16 Jan 2024 06:41:02 +0000 (23:41 -0700)]
move Rust sources to top level, C sources into c_src

This moves the Rust sources out of rust_src/ and into the top level.
Running the bcachefs executable out of the development tree is now:

$ ./target/release/bcachefs command
or
$ cargo run --profile release -- command

instead of "./bcachefs command".

Building and installing is still:

$ make && make install

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agoremove library from bcachefs-tools Rust package
Thomas Bertschinger [Tue, 16 Jan 2024 06:41:01 +0000 (23:41 -0700)]
remove library from bcachefs-tools Rust package

When bcachefs was a C program that had some functions implemented in
Rust, it was necessary to make a static library containing the Rust
functions available for the C program to link.

Now that bcachefs is a Rust program, that library is no longer needed.
Instead, the Rust executable links in libbachefs.a.

This patch updates the crate structure to reflect that. The command
functions are moved into their own module.

There could be a need to create a "libbachefs-tools" library in the
future that exposes an API for bcachefs functionality to other
userspace programs. That will be a different, external API as opposed to
the previous library functions which were an internal API for the
bcachefs tool itself.

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agoconvert main() from C to Rust
Thomas Bertschinger [Tue, 16 Jan 2024 06:41:00 +0000 (23:41 -0700)]
convert main() from C to Rust

This moves the main() function from C to Rust. It also updates the name
of the Rust package from "bcachefs-rust" to "bcachefs-tools".

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agocmd_dump: Use buffered IO
Kent Overstreet [Tue, 16 Jan 2024 03:14:52 +0000 (22:14 -0500)]
cmd_dump: Use buffered IO

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agoPrune rust dependencies
Kent Overstreet [Mon, 15 Jan 2024 19:37:07 +0000 (14:37 -0500)]
Prune rust dependencies

pruned via 'cargo machete --fix'

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agocmd_attr: check for errors from fdopendir()
Kent Overstreet [Mon, 15 Jan 2024 19:34:54 +0000 (14:34 -0500)]
cmd_attr: check for errors from fdopendir()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agocmd_mount: Use noxcl for opening block devices
Kent Overstreet [Sat, 13 Jan 2024 06:47:33 +0000 (01:47 -0500)]
cmd_mount: Use noxcl for opening block devices

We're only reading the superblocks, no need for O_EXCL - and this fixes
mounts failing because we're still holding the devices open.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agorust: remove dependency on itertools
Faidon Liambotis [Tue, 9 Jan 2024 10:52:51 +0000 (12:52 +0200)]
rust: remove dependency on itertools

The only use for itertools is in parse_mount_options() where we take a
vector, convert it to iterator and then join it. Instead, we can join
the vector directly.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agofix invalid write in pop_cmd()
Thomas Bertschinger [Fri, 12 Jan 2024 06:57:29 +0000 (23:57 -0700)]
fix invalid write in pop_cmd()

The memmove() in pop_cmd() reads and writes beyond the end of argv.

This is basically harmless in the current C program; the environment
variable list immediately follows argv so all this does is unnecessarily
copy the beginning of that list.

However, this will become problematic once we start calling C functions
like fs_cmds() from Rust code. Then argv will be a Vec<String> (as
*mut *mut i8) and the memory layout will be different--in particular,
I don't think we can assume that a Vec<String> will be NULL-terminated
like argv always is--, meaning the invalid write could lead to heap
corruption.

Also, it doesn't look like full_cmd ever gets used after calling
pop_cmd() so I'm removing it here since it looks unneeded to me.

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agocmd_migrate: Fix fsck invocation
Kent Overstreet [Fri, 12 Jan 2024 18:10:54 +0000 (13:10 -0500)]
cmd_migrate: Fix fsck invocation

It's now an error to ask for a read_write filesystem with nochanges.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agoinit_layout(): fix rounding
Steinar H. Gunderson [Fri, 12 Jan 2024 17:56:49 +0000 (18:56 +0100)]
init_layout(): fix rounding

block_size is in bytes, not sectors, so when calling round_up(),
we could start rounding up by a way too large size and then overflow
outside the area that migrate allocated for us.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agoMerge pull request #206 from kode54/fix-fsck-service
koverstreet [Fri, 12 Jan 2024 17:25:48 +0000 (12:25 -0500)]
Merge pull request #206 from kode54/fix-fsck-service

fix fsck service location

4 months agofix fsck service location
Christopher Snowhill [Fri, 12 Jan 2024 07:55:39 +0000 (23:55 -0800)]
fix fsck service location

Correctly generate libexecdir based path for the bcachefsck_all
service, like the bcachefsck_all_fail service already does.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
4 months agokill bd_buffered_fd
Kent Overstreet [Sat, 6 Jan 2024 22:54:06 +0000 (17:54 -0500)]
kill bd_buffered_fd

this gets us back down to a single fd for opening block devices, which
means we can use O_EXCL.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agokill bd_sync_fd
Kent Overstreet [Sat, 6 Jan 2024 22:45:54 +0000 (17:45 -0500)]
kill bd_sync_fd

not needed with pwritev2(.., RWF_SYNC), and perhaps we can get down to
one fd and then use O_EXCL for block devices.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agoFix bch2_super_write() alignment
Kent Overstreet [Thu, 11 Jan 2024 03:26:49 +0000 (22:26 -0500)]
Fix bch2_super_write() alignment

We're about to switch to O_DIRECT only, which means we need to write
with proper alignment.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agocreate common entry point for Rust commands
Thomas Bertschinger [Mon, 8 Jan 2024 01:36:33 +0000 (18:36 -0700)]
create common entry point for Rust commands

The bcachefs sub-commands that are implemented in Rust (completions,
list, and mount) had separate entrypoints and thus had some differences
in behavior.

This introduces a common entry point for the Rust sub-commands. This
reduces duplicate boilerplate code like parsing argv and setting up
logging, and will facilitate converting more sub-commands to Rust in
the future.

An immediate benefit is that this fixes an issue with `bcachefs list`
not reporting errors:

before:

$ bcachefs list /dev/typo
$ echo $?
0

after:

$ bcachefs list /dev/typo
ERROR - bcachefs_rust::cmd_list: Fatal error: "No such file or directory"
$ echo $?
1

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agoUpdate bcachefs sources to cbb2e45634dd bcachefs: fix simulateously upgrading & downg...
Kent Overstreet [Fri, 5 Jan 2024 19:18:29 +0000 (14:18 -0500)]
Update bcachefs sources to cbb2e45634dd bcachefs: fix simulateously upgrading & downgrading

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agoatomic64_read_acquire() should be inline
Kent Overstreet [Fri, 5 Jan 2024 20:11:42 +0000 (15:11 -0500)]
atomic64_read_acquire() should be inline

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agocmd_show_super: --field-only
Kent Overstreet [Fri, 5 Jan 2024 17:39:05 +0000 (12:39 -0500)]
cmd_show_super: --field-only

4 months agoUpdate bcachefs sources to d267e10a43b2 bcachefs: __bch2_sb_field_to_text()
Kent Overstreet [Fri, 5 Jan 2024 17:38:14 +0000 (12:38 -0500)]
Update bcachefs sources to d267e10a43b2 bcachefs: __bch2_sb_field_to_text()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agolinux header updates
Kent Overstreet [Fri, 5 Jan 2024 17:39:40 +0000 (12:39 -0500)]
linux header updates

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agofix show_super default fields
Kent Overstreet [Fri, 5 Jan 2024 17:07:57 +0000 (12:07 -0500)]
fix show_super default fields

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agocmd_reset_counters
Kent Overstreet [Fri, 5 Jan 2024 00:45:54 +0000 (19:45 -0500)]
cmd_reset_counters

Add a subcommand for resetting superblock counters - for automated tests

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agofix list_journal for nochanges
Kent Overstreet [Thu, 4 Jan 2024 04:14:28 +0000 (23:14 -0500)]
fix list_journal for nochanges

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agoUpdate bcachefs sources to 2a6125decb43 bcachefs: bch_sb_field_downgrade
Kent Overstreet [Sun, 31 Dec 2023 03:54:04 +0000 (22:54 -0500)]
Update bcachefs sources to 2a6125decb43 bcachefs: bch_sb_field_downgrade

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agoimprove do_splice()
Kent Overstreet [Thu, 4 Jan 2024 01:30:35 +0000 (20:30 -0500)]
improve do_splice()

4 months agoUpdate bcachefs sources to 5264e9f4d0c0 bcachefs: fix setting version_upgrade_complete
Kent Overstreet [Sat, 30 Dec 2023 21:04:21 +0000 (16:04 -0500)]
Update bcachefs sources to 5264e9f4d0c0 bcachefs: fix setting version_upgrade_complete

4 months agofix missing atomic64_read_acquire on 32 bit
Kent Overstreet [Sat, 30 Dec 2023 01:16:37 +0000 (20:16 -0500)]
fix missing atomic64_read_acquire on 32 bit

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agofix cmd_list for new nochanges semantics
Kent Overstreet [Thu, 28 Dec 2023 02:50:46 +0000 (21:50 -0500)]
fix cmd_list for new nochanges semantics

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
4 months agoMerge pull request #196 from Conan-Kudo/spec-libexecdir
koverstreet [Sun, 24 Dec 2023 14:11:48 +0000 (09:11 -0500)]
Merge pull request #196 from Conan-Kudo/spec-libexecdir

packaging: Update RPM spec to use %_libexecdir for libexec files

4 months agopackaging: Update RPM spec to use %_libexecdir for libexec files
Neal Gompa [Sun, 24 Dec 2023 14:09:56 +0000 (09:09 -0500)]
packaging: Update RPM spec to use %_libexecdir for libexec files

5 months agoUpdate bcachefs sources to 44ac32df8e0c bcachefs: Split brain detection
Kent Overstreet [Sun, 24 Dec 2023 00:55:43 +0000 (19:55 -0500)]
Update bcachefs sources to 44ac32df8e0c bcachefs: Split brain detection

5 months agoMerge pull request #195 from Conan-Kudo/use-libexec
koverstreet [Sun, 24 Dec 2023 13:47:55 +0000 (08:47 -0500)]
Merge pull request #195 from Conan-Kudo/use-libexec

Makefile, fsck: Use libexec instead of lib

5 months agoMakefile, fsck: Use libexec instead of lib
Neal Gompa [Sun, 24 Dec 2023 13:34:16 +0000 (08:34 -0500)]
Makefile, fsck: Use libexec instead of lib

These are executables that need to be installed in a non-path location.
Most distributions now install these into /usr/libexec, and the
path variable for this is LIBEXECDIR, so use that instead.

5 months agofixup for old gcc
Kent Overstreet [Sun, 24 Dec 2023 00:47:08 +0000 (19:47 -0500)]
fixup for old gcc

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agov1.4.0: Split brain detection
Kent Overstreet [Sat, 23 Dec 2023 04:33:16 +0000 (23:33 -0500)]
v1.4.0: Split brain detection

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agocmd_fsck: -k, run fsck in kernel
Kent Overstreet [Sun, 24 Dec 2023 00:37:04 +0000 (19:37 -0500)]
cmd_fsck: -k, run fsck in kernel

This adds a new option to cmd_fsck for using the kernel implementation
of fsck instead of userspace, via the BCH_IOCTL_FSCK_OFFLINE ioctl.

This isn't intended for normal usage - mainly for testing and debugging
purposes, and for when the kernel version of bcachefs better matches the
on disk format version.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agoUpdate bcachefs sources to 72740a707b64 bcachefs: Split brain detection
Kent Overstreet [Sat, 23 Dec 2023 02:39:45 +0000 (21:39 -0500)]
Update bcachefs sources to 72740a707b64 bcachefs: Split brain detection

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agocmd_fsck can now take colon separated devices
Kent Overstreet [Sat, 23 Dec 2023 02:29:36 +0000 (21:29 -0500)]
cmd_fsck can now take colon separated devices

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agoUpdate bcachefs sources to c6d45169c6 bcachefs: Convert split_devs() to darray
Kent Overstreet [Sat, 23 Dec 2023 02:21:14 +0000 (21:21 -0500)]
Update bcachefs sources to c6d45169c6 bcachefs: Convert split_devs() to darray

5 months agoMerge pull request #194 from intelfx/work/makefile-nonrecursive
koverstreet [Fri, 22 Dec 2023 09:49:58 +0000 (04:49 -0500)]
Merge pull request #194 from intelfx/work/makefile-nonrecursive

Makefile: do not recursively expand flags (speed up parallel builds considerably)

5 months agoMakefile: avoid recursively expanding expensive variables
Ivan Shapovalov [Fri, 22 Dec 2023 06:51:17 +0000 (09:51 +0300)]
Makefile: avoid recursively expanding expensive variables

Specifically, do not recursively expand $(CFLAGS) because this leads to
repeatedly performing compile tests (e. g. cc-disable-warning) on every
recipe execution.

Without (nproc=32):
```
$ time env -i PATH=/usr/bin BCACHEFS_FUSE=1 NO_RUST=1 make -j$(nproc)
<...>
    [LD]     bcachefs
  72,48s user 11,29s system 190% cpu 44,036 total
```

With:
```
$ time env -i PATH=/usr/bin BCACHEFS_FUSE=1 NO_RUST=1 make -j$(nproc)
<...>
    [LD]     bcachefs
  66,79s user 5,17s system 1955% cpu 3,679 total
```

5 months agoSilence a few rust build warnings
Kent Overstreet [Fri, 22 Dec 2023 00:49:55 +0000 (19:49 -0500)]
Silence a few rust build warnings

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agoUpdate bcachefs sources to df6415fefb27 bcachefs: Fixes for rust bindgen
Kent Overstreet [Fri, 22 Dec 2023 00:49:00 +0000 (19:49 -0500)]
Update bcachefs sources to df6415fefb27 bcachefs: Fixes for rust bindgen

5 months agoUpdate bcachefs sources to 5d0a6c2b32f1 bcachefs: check_directory_structure() can...
Kent Overstreet [Fri, 22 Dec 2023 00:10:40 +0000 (19:10 -0500)]
Update bcachefs sources to 5d0a6c2b32f1 bcachefs: check_directory_structure() can now be run online

5 months agoremove Rust artifacts during `make clean`
Thomas Bertschinger [Wed, 20 Dec 2023 22:02:28 +0000 (15:02 -0700)]
remove Rust artifacts during `make clean`

This should use `cargo clean` instead of `rm -rf ...`. Also,
due to a typo, the `rm` did not actually remove the Rust artifacts.

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agocmd_list_journal: fix check to print entry header
Kent Overstreet [Wed, 20 Dec 2023 02:28:43 +0000 (21:28 -0500)]
cmd_list_journal: fix check to print entry header

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agocmd_migrate: don't link data above i_size
Kent Overstreet [Wed, 20 Dec 2023 01:35:20 +0000 (20:35 -0500)]
cmd_migrate: don't link data above i_size

The new filesystem might have a smaller blocksize than the old
blocksize, which trips this.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agodocs: add llvm-config dependency for arch, fedora
Thomas Bertschinger [Tue, 19 Dec 2023 23:38:47 +0000 (16:38 -0700)]
docs: add llvm-config dependency for arch, fedora

This adds on to 446ec6b092cc ("docs: mention that libclang is
required"). That commit updated the dependency list for Debian. This
adds the packages needed to get llvm-config for arch and fedora.

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agocmd_migrate: fix memory leaks
Kent Overstreet [Wed, 20 Dec 2023 00:43:30 +0000 (19:43 -0500)]
cmd_migrate: fix memory leaks

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agomake allocator helpers inlines
Kent Overstreet [Wed, 20 Dec 2023 00:30:13 +0000 (19:30 -0500)]
make allocator helpers inlines

this gets us better log messages when using -fsanitize=address

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agocmd_migrate: check for write errors
Kent Overstreet [Wed, 20 Dec 2023 00:30:00 +0000 (19:30 -0500)]
cmd_migrate: check for write errors

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agofix shrinker_free()
Kent Overstreet [Wed, 20 Dec 2023 00:29:25 +0000 (19:29 -0500)]
fix shrinker_free()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agocmd_migrate: fix write_data()
Kent Overstreet [Wed, 20 Dec 2023 00:17:19 +0000 (19:17 -0500)]
cmd_migrate: fix write_data()

passing a parent closure is totally unnecessary when using
BCH_WRITE_SYNC - and pops an assert in debug mode, because the write
path no longer supports delivering completions that way.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agov1.3.6
Kent Overstreet [Tue, 19 Dec 2023 04:29:06 +0000 (23:29 -0500)]
v1.3.6

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agoDrop mlockall()
Kent Overstreet [Tue, 19 Dec 2023 04:21:43 +0000 (23:21 -0500)]
Drop mlockall()

now that we have
 - shrinkers running in the background via a thread
 - run_shrinkers() considering swap usage

this can probably be safely dropped - and it causes problems when
running as non root, so let's do so.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agoUpdate bcachefs sources to 1a739db0b256 bcachefs; guard against overflow in btree...
Kent Overstreet [Sun, 17 Dec 2023 20:42:17 +0000 (15:42 -0500)]
Update bcachefs sources to 1a739db0b256 bcachefs; guard against overflow in btree node split

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agocmd_dump: fix error message
Kent Overstreet [Sun, 17 Dec 2023 20:42:38 +0000 (15:42 -0500)]
cmd_dump: fix error message

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agoFix makefile when building without systemd
Kent Overstreet [Sat, 16 Dec 2023 23:42:22 +0000 (18:42 -0500)]
Fix makefile when building without systemd

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agoUpdate bcachefs sources to 841a95c29f4c bcachefs: fix userspace build errors
Kent Overstreet [Sat, 16 Dec 2023 02:57:44 +0000 (21:57 -0500)]
Update bcachefs sources to 841a95c29f4c bcachefs: fix userspace build errors

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agofix packaging
Alexander Fougner [Sat, 9 Dec 2023 11:20:04 +0000 (12:20 +0100)]
fix packaging

- make deb fails with dh: error: Unknown sequence --with
  (options should not come before the sequence)

- fix deb build deps

- add missing rpm files

Signed-off-by: Alexander Fougner <fougner89@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agobcachefs-tools: Fix typo in 872cd43
Chris Webb [Sun, 10 Dec 2023 07:28:31 +0000 (07:28 +0000)]
bcachefs-tools: Fix typo in 872cd43

6% of physical RAM is info.totalram >> 4 not info.totalram << 4.

Signed-off-by: Chris Webb <chris@arachsys.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agobcachefs-tools: Disable -Wgnu-variable-sized-type-not-at-end for clang
Chris Webb [Sat, 9 Dec 2023 14:31:40 +0000 (14:31 +0000)]
bcachefs-tools: Disable -Wgnu-variable-sized-type-not-at-end for clang

clang's default warnings include -Wgnu-variable-sized-type-not-at-end,
producing a lot of false alarms about the GNU extension for libbcachefs.
Disable these using cc-disable-warning when building with clang.

Signed-off-by: Chris Webb <chris@arachsys.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agobcachefs-tools: Guard the __struct_group() #define in kernel.h
Chris Webb [Sat, 9 Dec 2023 14:15:08 +0000 (14:15 +0000)]
bcachefs-tools: Guard the __struct_group() #define in kernel.h

Our include/linux/byteorder.h uses the system <asm/byteorder.h>
because we don't provide our own in include/asm. This then pulls in
system <linux/stddef.h> which defines __struct_group. That definition
collides with the unconditional #define __struct_group in our local
include/linux/kernel.h, provoking preprocessor warnings.

Signed-off-by: Chris Webb <chris@arachsys.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agobcachefs-tools: Avoid glibc-specific mallinfo() in shrinker
Chris Webb [Sat, 9 Dec 2023 12:50:31 +0000 (12:50 +0000)]
bcachefs-tools: Avoid glibc-specific mallinfo() in shrinker

Before 326d7c1, the shrinker used freeram and totalram from a struct
sysinfo (constructed from /proc/meminfo) to target 25% free physical
memory. As well as the slowness of repeatedly reading /proc/meminfo,
this was a problem as freeram rises when the system starts to swap.
We don't want swapping to reduce our estimate of memory pressure.

To work around this, in 326d7c1 the shrinker started to use the total
allocated heap from a glibc-specific interface mallinfo2(), aiming to
shrink such that our heap is less than 80% of physical memory, unless
overall free memory is less than 6% so that becomes the determining factor.

Unfortunately, a sign error in the calculation means this heuristic
never worked. It would shrink aggressively when the process was small,
and not at all when the process grew beyond 80% of physical RAM. Only the
fallback test ensuring the free physical RAM doesn't fall below 6% would
actually kick in under memory pressure. It also breaks portability to
anything other than recent glibc.

Later, in 2440469 the mallinfo2() was replaced with the older mallinfo()
to improve compatibility with older glibc. This is even more problematic:
it's still not portable but also struct mallinfo has (signed) int fields
which overflow for large processes on 32-bit machines with a 3G/1G split.

Rather than trying to use libc-specific debug interfaces and our own heap
to inform the shrinker, use the information about free and total swap
we already have from sysinfo(2) to explicitly compensate for swapping
in our estimate of free physical memory. Target free memory of 6% of
physical RAM adjusted for zero swap use when calculating the pressure
on the shrinker, based on the effective behaviour of 326d7c1 in practice
given the sign error.

As well as fixing portability to non-glibc systems, this loosens the
assumption that we are the only process using significant memory when
setting the shrinker target. It wouldn't be unreasonable to run two
fsck jobs against independent devices on a large RAM machine and want to
balance physical RAM between them.

Signed-off-by: Chris Webb <chris@arachsys.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agobcachefs-tools: Use sysinfo(2) directly to implement si_meminfo()
Chris Webb [Sat, 9 Dec 2023 12:49:12 +0000 (12:49 +0000)]
bcachefs-tools: Use sysinfo(2) directly to implement si_meminfo()

Use a single sysinfo(2) call to fill out struct sysinfo instead of
multiple libc sysconf(3) requests, which will only make sysinfo(2) calls
internally anyway. This also enables us to access other struct sysinfo
fields, not just the three filled-out previously.

As we provide our own definition of struct sysinfo in include/linux/mm.h
to match the kernel, which is not guaranteed to align with the definition
libc provides in <sys/sysinfo.h>, use syscall(SYS_sysinfo, ...) directly
instead of the libc wrapper.

Signed-off-by: Chris Webb <chris@arachsys.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agobcachefs-tools: Use basename(3) from <libgen.h>
Chris Webb [Sat, 9 Dec 2023 12:58:46 +0000 (12:58 +0000)]
bcachefs-tools: Use basename(3) from <libgen.h>

Although glibc also provides basename(3) from <string.h>, this is
non-standard whereas it is available from <libgen.h> portably.

Signed-off-by: Chris Webb <chris@arachsys.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agobcachefs-tools: make 'all' the default Makefile goal
Tero Roponen [Fri, 8 Dec 2023 08:10:52 +0000 (10:10 +0200)]
bcachefs-tools: make 'all' the default Makefile goal

"fsck/bcachefsck_all:" coming before "all:" in the Makefile
causes the bcachefs binary not being built by default. Fix
this by explicitly setting the .DEFAULT_GOAL=all.

Signed-off-by: Tero Roponen <tero.roponen@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agoMerge remote-tracking branch 'amoz/devel'
Kent Overstreet [Fri, 8 Dec 2023 01:19:06 +0000 (20:19 -0500)]
Merge remote-tracking branch 'amoz/devel'

5 months agoMerge pull request #190 from Dikay900/fs_free_space
koverstreet [Fri, 8 Dec 2023 01:10:15 +0000 (20:10 -0500)]
Merge pull request #190 from Dikay900/fs_free_space

cmd_fs: calculate free space

5 months agofix build for glibc prior to 2.33
Alexander Fougner [Thu, 7 Dec 2023 20:27:16 +0000 (21:27 +0100)]
fix build for glibc prior to 2.33

Signed-off-by: Alexander Fougner <fougner89@gmail.com>
5 months agofix fallback flex array
Alexander Fougner [Thu, 7 Dec 2023 20:04:27 +0000 (21:04 +0100)]
fix fallback flex array

Signed-off-by: Alexander Fougner <fougner89@gmail.com>
5 months agocmd_fs: calculate size based on bucket count for data types BCH_DATA_free, BCH_DATA_n...
Philip Laube [Wed, 6 Dec 2023 18:29:26 +0000 (19:29 +0100)]
cmd_fs: calculate size based on bucket count for data types BCH_DATA_free, BCH_DATA_need_discard and BCH_DATA_need_inc_gens

Signed-off-by: Philip Laube <philip.laube.dev@xyz.de>
5 months agoOnline fsck
Kent Overstreet [Tue, 5 Dec 2023 00:49:21 +0000 (19:49 -0500)]
Online fsck

This hooks up cmd_fsck to the new BCH_IOCTL_FSCK_ONLINE: if a filesystem
is mounted, we now use that instead of bailing out with an error.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agoUpdate bcachefs sources to 6d44812757dd bcachefs: BCH_IOCTL_FSCK_ONLINE
Kent Overstreet [Mon, 4 Dec 2023 21:03:52 +0000 (16:03 -0500)]
Update bcachefs sources to 6d44812757dd bcachefs: BCH_IOCTL_FSCK_ONLINE

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agoUpdate .gitignore for new service files
Kent Overstreet [Wed, 6 Dec 2023 04:52:43 +0000 (23:52 -0500)]
Update .gitignore for new service files

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agofsck: add a service to schedule and run bcachefsck@ services
Darrick J. Wong [Tue, 5 Dec 2023 02:43:31 +0000 (18:43 -0800)]
fsck: add a service to schedule and run bcachefsck@ services

Create a script that looks for mounted bcachefs filesystems and tries to
run as many of them in parallel as possible without two different
scrubbers hitting the same low level block device.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
5 months agofsck: add systemd service definitions for automatic online service
Darrick J. Wong [Tue, 5 Dec 2023 02:43:31 +0000 (18:43 -0800)]
fsck: add systemd service definitions for automatic online service

Add some systemd service files so that bcachefs can automatically fsck
mounted filesystems in the background.  Hopefully with minimal
disruption to frontend operations.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
5 months agoMerge pull request #191 from cepelinas9000/fuse-fixes-1
koverstreet [Thu, 7 Dec 2023 16:57:04 +0000 (11:57 -0500)]
Merge pull request #191 from cepelinas9000/fuse-fixes-1

Multiple small fuse fixes for write, api, and hardlink

5 months agoMultiple small fuse fixes for write, api, and hardlink
Tautvydas Nesvarbu [Thu, 7 Dec 2023 13:17:34 +0000 (15:17 +0200)]
Multiple small fuse fixes for write, api, and hardlink

* changed in Makefile to use recomended fuse api 35;
* force foreground mode, because fuse_daemonize is forking after initalization other bcachefs threads;
* fix fuse_link, there where mistype in fuse_log (the paremeter need to be inum.inum);
* The write_aligned is fixed, by  wrapping struct bch_write_op into container with single closure and using end_io callback to release
      that closure.

5 months agofix udev rules path
Alexander Fougner [Wed, 6 Dec 2023 17:20:11 +0000 (18:20 +0100)]
fix udev rules path

- include rules file in rpmspec
- update install docs with udev build requirement

Signed-off-by: Alexander Fougner <fougner89@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agoMerge pull request #189 from Dikay900/fs_human_readable
koverstreet [Wed, 6 Dec 2023 18:58:01 +0000 (13:58 -0500)]
Merge pull request #189 from Dikay900/fs_human_readable

cmd_fs: add long parameter --human-readable to usage command

5 months agocmd_fs: add long parameter --human-readable to usage command
Philip Laube [Wed, 6 Dec 2023 18:29:05 +0000 (19:29 +0100)]
cmd_fs: add long parameter --human-readable to usage command

Signed-off-by: Philip Laube <philip.laube.dev@xyz.de>
5 months agoDisable shrinker thread shutdown
Kent Overstreet [Tue, 5 Dec 2023 23:28:14 +0000 (18:28 -0500)]
Disable shrinker thread shutdown

We seem to be hitting a rare crash in the exit path of fsck - when
shutting down the shrinker thread. Disable exiting the shrinker thread
as a workaround.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agomisc: don't allow udisks to automount bcachefs filesystems with no prompt
Darrick J. Wong [Tue, 5 Dec 2023 00:44:29 +0000 (19:44 -0500)]
misc: don't allow udisks to automount bcachefs filesystems with no prompt

The unending stream of syzbot bug reports and overwrought filing of CVEs
for corner case handling (i.e. things that distract from actual user
complaints) in XFS has generated all sorts of of overheated rhetoric
about how every bug is a Serious Security Issue(tm) because anyone can
craft a malicious filesystem on a USB stick, insert the stick into a
victim machine, and mount will trigger a bug in the kernel driver that
leads to some compromise or DoS or something.

I thought that nobody would be foolish enough to automount an XFS
filesystem.  What a fool I was!  It turns out that udisks can be told
that it's okay to automount things, and then GNOME will do exactly that.
Including mounting mangled XFS filesystems!  Same with bcachefs!

<delete angry rant about poor decisionmaking and armchair fs developers
blasting us on X while not actually doing any of the work>

Turn off /this/ idiocy by adding a udev rule to tell udisks not to
automount bcachefs filesystems.

This will not stop a logged in user from unwittingly inserting a
malicious storage device and pressing [mount] and getting breached.
This is not a substitute for a thorough audit.  This is not a substitute
for lklfuse.  This does not solve the general problem of in-kernel fs
drivers being a huge attack surface.  I just want to give Kent a break
from some of the oceans of bu******.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agoUpdate bcachefs sources to 71a5b27e017d bcachefs: Make backpointer fsck wb flush...
Kent Overstreet [Thu, 30 Nov 2023 07:20:42 +0000 (02:20 -0500)]
Update bcachefs sources to 71a5b27e017d bcachefs: Make backpointer fsck wb flush check more rigorous

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agoUpdate bcachefs sources to 676dd269f0f8 mean and variance: Promote to lib/math
Kent Overstreet [Thu, 30 Nov 2023 03:42:52 +0000 (22:42 -0500)]
Update bcachefs sources to 676dd269f0f8 mean and variance: Promote to lib/math

5 months agoUpdate bcachefs sources to eb83f1f842bb mean and variance: Promote to lib/math
Kent Overstreet [Thu, 30 Nov 2023 03:00:41 +0000 (22:00 -0500)]
Update bcachefs sources to eb83f1f842bb mean and variance: Promote to lib/math

5 months agoadd a fallback __DECLARE_FLEX_ARRAY
Kent Overstreet [Wed, 29 Nov 2023 22:41:06 +0000 (17:41 -0500)]
add a fallback __DECLARE_FLEX_ARRAY

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agoUpdate bcachefs sources to c3e4d892b77b mean and variance: Promote to lib/math
Kent Overstreet [Wed, 29 Nov 2023 22:00:30 +0000 (17:00 -0500)]
Update bcachefs sources to c3e4d892b77b mean and variance: Promote to lib/math

5 months agoman: Fix cmd-option format
Brett Holman [Mon, 27 Nov 2023 20:22:59 +0000 (13:22 -0700)]
man: Fix cmd-option format

Options prgquote and degraded only had a single leading hyphen.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agobcachefs-tools: don't skip stale superblock wipe in force mode
Brian Foster [Mon, 27 Nov 2023 18:31:10 +0000 (13:31 -0500)]
bcachefs-tools: don't skip stale superblock wipe in force mode

Even though the blkid wipe has been fixed to detect and wipe old
superblocks, we still incorrectly skip the wipe when in force mode.
Update the force logic in open_for_format() to bypass the user
request and otherwise proceed with the wipe.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
5 months agocmd_list_journal: Apply star_start_of_lines() correctly
Kent Overstreet [Mon, 27 Nov 2023 18:35:08 +0000 (13:35 -0500)]
cmd_list_journal: Apply star_start_of_lines() correctly

In list_journal, we note which journal entries are being ignored - this
was forgetting to mark entries newer than the newest flush.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>