]> git.sesse.net Git - bcachefs-tools-debian/log
bcachefs-tools-debian
2 months agoDisable pristine-tar option in gbp.conf, since there is no pristine-tar branch. master
Steinar H. Gunderson [Tue, 13 Feb 2024 21:39:43 +0000 (22:39 +0100)]
Disable pristine-tar option in gbp.conf, since there is no pristine-tar branch.

2 months agoDepend on python3:any due to bcachefsck_all being a Python script (Lintian warning).
Steinar H. Gunderson [Tue, 13 Feb 2024 21:23:14 +0000 (22:23 +0100)]
Depend on python3:any due to bcachefsck_all being a Python script (Lintian warning).

2 months agoAdd debhelper tokens to postinst and postrm scripts (Lintian warning).
Steinar H. Gunderson [Tue, 13 Feb 2024 21:09:27 +0000 (22:09 +0100)]
Add debhelper tokens to postinst and postrm scripts (Lintian warning).

2 months agoBuild-Depend on pkgconf instead of pkg-config (Lintian warning).
Steinar H. Gunderson [Tue, 13 Feb 2024 21:08:40 +0000 (22:08 +0100)]
Build-Depend on pkgconf instead of pkg-config (Lintian warning).

2 months agoEnable Rust parts, including mount.bcachefs.
Steinar H. Gunderson [Tue, 13 Feb 2024 21:01:33 +0000 (22:01 +0100)]
Enable Rust parts, including mount.bcachefs.

2 months agoRevert upstream patch f6b619da.
Steinar H. Gunderson [Tue, 13 Feb 2024 20:57:00 +0000 (21:57 +0100)]
Revert upstream patch f6b619da.

With this revert (and a loosening of the version dependency in
Cargo.toml), we compile and run with bindgen 0.66, which is in Debian.
It can safely be removed when Debian upgrades to at least 0.69.4.

2 months agoBuild-depend on systemd-dev, since udev.pc has moved there.
Steinar H. Gunderson [Tue, 13 Feb 2024 20:45:47 +0000 (21:45 +0100)]
Build-depend on systemd-dev, since udev.pc has moved there.

2 months agoStart working on NMU for new upstream version.
Steinar H. Gunderson [Tue, 13 Feb 2024 20:44:56 +0000 (21:44 +0100)]
Start working on NMU for new upstream version.

 - Bump the version (including epoch).
 - Remove the (now obsolete) do-not-install-mount-symlink patch.

2 months agoUpdate upstream source from tag 'v1.6.3'
Steinar H. Gunderson [Wed, 21 Feb 2024 18:28:22 +0000 (19:28 +0100)]
Update upstream source from tag 'v1.6.3'

Update to upstream version '1.6.3'
with Debian dir b1e0464fd09031260f5ed4e3222d0d49f72ce7f5

2 months agov1.6.3
Kent Overstreet [Tue, 20 Feb 2024 23:42:07 +0000 (18:42 -0500)]
v1.6.3

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2 months agoUpdate bcachefs sources to c887148ebf99 thread_with_file: add f_ops.flush
Kent Overstreet [Tue, 20 Feb 2024 21:28:18 +0000 (16:28 -0500)]
Update bcachefs sources to c887148ebf99 thread_with_file: add f_ops.flush

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2 months agocmd_fsck: Collect return code of kernel fsck with close()
Kent Overstreet [Sun, 18 Feb 2024 01:57:07 +0000 (20:57 -0500)]
cmd_fsck: Collect return code of kernel fsck with close()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2 months agobch_bindgen: fix packed and aligned structs on i686, ppc64
Thomas Bertschinger [Sat, 17 Feb 2024 18:20:25 +0000 (11:20 -0700)]
bch_bindgen: fix packed and aligned structs on i686, ppc64

This patch addresses build issues with bch_bindgen on architectures
where the natural alignment of u64 is 4 instead of 8, such as i686 and
ppc64. The issue arises from rustc's refusing to compile structs with a
"packed" attribute that have members with an explicit "align(N)"
attribute.

rust-bindgen generally does not place "align(N)" attributes on types
when it is redundant with the type's natural alignment. There are a few
types in bcachefs with "__aligned(8)" in C where the type's natural
alignment is 8 except on architectures like those mentioned above where
it is 4. rust-bindgen places the "align(8)" attribute on these types,
for those architectures. The affected types include:

- bch_csum
- bch_sb_layout
- bch_ioctl_data_progress

bch_ioctl_data_progress, and all types that depend on it, are not used
on the Rust side currently and bindings are only generated for them
because they are covered by `.allowlist_type("bch_.*")` in
bch_bindgen/build.rs. This patch resolves the build failure for this
type by excluding it from bch_bindgen. If/when accessing this type in
Rust is needed, a decision can be made then about how to represent its
layout in Rust.

bch_csum and bch_sb_layout, and types that depend on them, are currently
used in Rust so they can't be excluded. This patch addresses these types
by stripping off the "packed" attribute in Rust on types that embed
these types, since that attribute happens to not be necessary for proper
layout.

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2 months agoMerge remote-tracking branch 'github/master'
Kent Overstreet [Fri, 16 Feb 2024 06:53:51 +0000 (01:53 -0500)]
Merge remote-tracking branch 'github/master'

2 months agoMerge pull request #211 from oz123/master
koverstreet [Fri, 16 Feb 2024 06:53:37 +0000 (01:53 -0500)]
Merge pull request #211 from oz123/master

Add option to read passphrase from a keyfile

2 months agoUpdate bcachefs sources to 9a555a741e80 bcachefs: omit alignment attribute on big...
Kent Overstreet [Fri, 16 Feb 2024 04:45:29 +0000 (23:45 -0500)]
Update bcachefs sources to 9a555a741e80 bcachefs: omit alignment attribute on big endian struct bkey

2 months agofix build on old gcc
Kent Overstreet [Wed, 14 Feb 2024 04:27:04 +0000 (23:27 -0500)]
fix build on old gcc

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2 months agofsck: Fall back to userland fsck when probed for kernel fsck
Kent Overstreet [Wed, 14 Feb 2024 03:05:09 +0000 (22:05 -0500)]
fsck: Fall back to userland fsck when probed for kernel fsck

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2 months agofsck: Automatically use kernel fsck when better version match
Kent Overstreet [Mon, 12 Feb 2024 02:42:14 +0000 (21:42 -0500)]
fsck: Automatically use kernel fsck when better version match

To avoid expensive version upgrades and downgrades - use the kernel
version of fsck when it's availale and a better match.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2 months agokill_btree_node: fix return code
Kent Overstreet [Sun, 11 Feb 2024 02:16:03 +0000 (21:16 -0500)]
kill_btree_node: fix return code

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2 months agoUpdate bcachefs sources to 39a84c99af2d bcachefs: Clamp replicas_required to replicas
Kent Overstreet [Sun, 11 Feb 2024 02:06:20 +0000 (21:06 -0500)]
Update bcachefs sources to 39a84c99af2d bcachefs: Clamp replicas_required to replicas

2 months agoUpdate bcachefs sources to bee7b5a4fa21 bcachefs: Pin btree cache in ram for random...
Kent Overstreet [Sat, 10 Feb 2024 02:30:46 +0000 (21:30 -0500)]
Update bcachefs sources to bee7b5a4fa21 bcachefs: Pin btree cache in ram for random access in fsck

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2 months agoMerge pull request #236 from ErrorNoInternet/subcommand-aliases
koverstreet [Fri, 9 Feb 2024 19:20:29 +0000 (14:20 -0500)]
Merge pull request #236 from ErrorNoInternet/subcommand-aliases

Add a few subcommand aliases

2 months agofeat: add aliases for a few subcommands
ErrorNoInternet [Fri, 9 Feb 2024 09:37:00 +0000 (17:37 +0800)]
feat: add aliases for a few subcommands

2 months agorefactor: clean up arguments
ErrorNoInternet [Fri, 9 Feb 2024 09:36:49 +0000 (17:36 +0800)]
refactor: clean up arguments

2 months agoReplace atty with stdlib
Alexander Fougner [Wed, 7 Feb 2024 20:12:09 +0000 (21:12 +0100)]
Replace atty with stdlib

is_terminal() is part of rust 1.70 std, no need for isatty

Signed-off-by: Alexander Fougner <fougner89@gmail.com>
2 months agokill dependency on char signedness
Kent Overstreet [Wed, 7 Feb 2024 04:13:02 +0000 (23:13 -0500)]
kill dependency on char signedness

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2 months agofix snapshotting when dst is single component path
Kent Overstreet [Tue, 6 Feb 2024 06:32:37 +0000 (01:32 -0500)]
fix snapshotting when dst is single component path

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2 months agoUpdate bcachefs sources to 50847e296b34 bcachefs: Check subvol <-> inode pointers...
Kent Overstreet [Tue, 6 Feb 2024 04:09:25 +0000 (23:09 -0500)]
Update bcachefs sources to 50847e296b34 bcachefs: Check subvol <-> inode pointers in check_inode()

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2 months agocmd_subvolume: Fix snapshot creation with implicit source
Kent Overstreet [Tue, 6 Feb 2024 01:33:10 +0000 (20:33 -0500)]
cmd_subvolume: Fix snapshot creation with implicit source

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2 months agocosmetic refactoring of Makefile
Frederik Schwan [Sat, 3 Feb 2024 18:21:19 +0000 (19:21 +0100)]
cosmetic refactoring of Makefile

Make clear that LIBEXECDIR is an option.

2 months agorust: update bindgen to 0.69.4; remove custom type modifications
Thomas Bertschinger [Sun, 4 Feb 2024 20:49:23 +0000 (13:49 -0700)]
rust: update bindgen to 0.69.4; remove custom type modifications

This updates rust-bindgen to version 0.69.4 which includes the patch
199bee441ad0: "try to avoid #[repr(packed)] when align is needed". With
this patch, bindgen generates code that is both ABI-correct and can be
compiled by rustc, for 3 bcachefs types:

- bkey
- bch_extent_crc32
- bch_extent_ptr

This allows us to remove the custom treatment for these three types.

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2 months agoMerge pull request #231 from sesse/install-mount
koverstreet [Sun, 4 Feb 2024 13:46:14 +0000 (08:46 -0500)]
Merge pull request #231 from sesse/install-mount

Make initramfs hook install mount.btrfs

2 months agoMake initramfs hook install mount.bcachefs
Steinar H. Gunderson [Sat, 3 Feb 2024 09:45:00 +0000 (10:45 +0100)]
Make initramfs hook install mount.bcachefs

Now that the bcachefs tool unconditionally includes the mount parts
(or more correctly, you cannot build it at all if you don't have Rust),
we can call copy_exec on mount.bcachefs, to get the symlink installed.
In particular, this helps with mounting UUID mounts as /.

See also https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1060411
for the remaining parts needed in initramfs-tools itself.

2 months agoMerge pull request #229 from g2p/cli-symlink
koverstreet [Mon, 29 Jan 2024 17:20:04 +0000 (12:20 -0500)]
Merge pull request #229 from g2p/cli-symlink

Add bcachefs command compatibility symlink

2 months agoMerge pull request #228 from g2p/non-utf8-printbuf-display
koverstreet [Mon, 29 Jan 2024 17:19:16 +0000 (12:19 -0500)]
Merge pull request #228 from g2p/non-utf8-printbuf-display

printbuf_to_formatter: Lossy display of non-UTF-8 printbufs

2 months agoprintbuf_to_formatter: Lossy display of non-UTF-8 printbufs
Gabriel [Mon, 29 Jan 2024 13:33:15 +0000 (14:33 +0100)]
printbuf_to_formatter: Lossy display of non-UTF-8 printbufs

Use to_string_lossy in printbuf_to_formatter, which tolerates
non-UTF-8 strings (by using replacement characters).

This is used in various Display impls, and allows something like:
bcachefs list --btree dirents
with non-UTF-8 paths.

2 months agoAdd bcachefs command compatibility symlink
Gabriel [Mon, 29 Jan 2024 13:03:07 +0000 (14:03 +0100)]
Add bcachefs command compatibility symlink

The CLI is now built by Cargo, add a symlink so it can be found at the
place it was before so people don't try to run an old binary.

2 months agocmd_list_journal: --transaction-filter now takes range
Kent Overstreet [Sat, 27 Jan 2024 15:56:34 +0000 (10:56 -0500)]
cmd_list_journal: --transaction-filter now takes range

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
3 months agofeat(c_src): drop entirely subvolume subcommands
Ryan Lahfa [Sat, 27 Jan 2024 04:46:24 +0000 (05:46 +0100)]
feat(c_src): drop entirely subvolume subcommands

We get rid of it as we have now a pure Rust version.

Signed-off-by: Ryan Lahfa <bcachefs@lahfa.xyz>
3 months agofix(build): clean should delete top-level libbcachefs.a
Ryan Lahfa [Sat, 27 Jan 2024 03:30:00 +0000 (04:30 +0100)]
fix(build): clean should delete top-level libbcachefs.a

I spent some minutes pestering Kent about weird counters issues, when, actually, `make clean`
was keeping this artifact on my filesystem.

Signed-off-by: Ryan Lahfa <bcachefs@lahfa.xyz>
3 months agofeat(rust/commands): introduce Rust-driven `subvolume` sub-CLI
Ryan Lahfa [Sat, 27 Jan 2024 03:23:53 +0000 (04:23 +0100)]
feat(rust/commands): introduce Rust-driven `subvolume` sub-CLI

This makes use of `BcachefsHandle` to introduce an elegant Rust driven CLI for subvolumes.

Signed-off-by: Ryan Lahfa <bcachefs@lahfa.xyz>
3 months agofeat(rust/wrappers): init `BcachefsHandle`
Ryan Lahfa [Sat, 27 Jan 2024 03:23:20 +0000 (04:23 +0100)]
feat(rust/wrappers): init `BcachefsHandle`

We propose a simple low-level wrapper which can perform various subvolume-related operations
as an example for the API surface.

This will be used in an upcoming commit to migrate the subvolume CLI fully to Rust.

The API design is the following:

- `BcachefsHandle` is meant as a low level handle to carry around whenever you need a filesystem handle
  to send ioctl to.
- it possess type-safe operations

Type safe operations are handled by having type safe wrappers for ioctl commands
*and* their payloads.

We assume that all ioctl payloads only use *one* argument, this can easily be changed if needed.

When the handle goes out of scope, we automatically close it à la C++ RAII.

Signed-off-by: Ryan Lahfa <bcachefs@lahfa.xyz>
3 months agofeat(bindgen): expose `bcache_fs_(open|close)` to Rust side
Ryan Lahfa [Sat, 27 Jan 2024 02:19:28 +0000 (03:19 +0100)]
feat(bindgen): expose `bcache_fs_(open|close)` to Rust side

This function allows to obtain a handle to send various `ioctl`s to the underlying bcachefs filesystem.
We need also its counterpart to clean up.

Signed-off-by: Ryan Lahfa <bcachefs@lahfa.xyz>
3 months agodoc(versioning): document version semantics of this project
Raito Bezarius [Sat, 27 Jan 2024 01:51:11 +0000 (02:51 +0100)]
doc(versioning): document version semantics of this project

It's semantic versioning applied to bcachefs kernel data structures.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
3 months agofeat(bindgen): expose `BCH_IOCTL_SUBVOLUME_*` on Rust side
Raito Bezarius [Sat, 27 Jan 2024 01:35:19 +0000 (02:35 +0100)]
feat(bindgen): expose `BCH_IOCTL_SUBVOLUME_*` on Rust side

As they are functional macro, they need help from our side.

3 months agofix(bindgen): expand the Fix753 workaround for any type and document it
Raito Bezarius [Sat, 27 Jan 2024 01:34:50 +0000 (02:34 +0100)]
fix(bindgen): expand the Fix753 workaround for any type and document it

Offer documentation to the poor people who stumble on this and look for a macro generation mechanism
on the Rust side.

3 months agofix(libbcachefs/ioctl): `dirfd` should be a signed 32 bits integer
Raito Bezarius [Sat, 27 Jan 2024 01:29:31 +0000 (02:29 +0100)]
fix(libbcachefs/ioctl): `dirfd` should be a signed 32 bits integer

`AT_FDCWD` is defined as a macro constant: -100, it works in C… because C.

But in Rust, this will be exposed as a u32 instead of a i32, which is the correct variable type for it.

3 months agoUpdate bcachefs sources to 481b5f343248 bcachefs: Better error messages for missing...
Kent Overstreet [Wed, 17 Jan 2024 03:45:53 +0000 (22:45 -0500)]
Update bcachefs sources to 481b5f343248 bcachefs: Better error messages for missing inodes in fsck

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
3 months agouse upstream bindgen; fix packed and aligned types
Thomas Bertschinger [Tue, 23 Jan 2024 14:36:02 +0000 (07:36 -0700)]
use upstream bindgen; fix packed and aligned types

bcachefs-tools has been using a patched bindgen to work around a
limitation of rustc that prevents compiling structs with
both #[repr(packed(N)] and #[repr(align(N)] attributes. The patch:
e8168ceda507 "codegen: Don't generate conflicting packed() and align()
representation hints." discards the "align" attribute in cases where
bindgen produces a type with both.

This may be correct for some types, but it turns out that for each
bcachefs type with this problem, keeping the "align" attribute and
discarding the "packed" attribute generates a type with the same ABI as
the original C type.

This can be tested automatically by running:
$ cargo test --manifest-path bch_bindgen/Cargo.toml
in the bcachefs-tools tree.

There has been pressure recently to start using upstream bindgen; both
externally, from distribution maintainers who want to build
bcachefs-tools with standard dependencies, and internally, in order to
enable using Rust for bcachefs in-kernel.

This patch updates bcachefs-tools to use upstream bindgen. It works
around the rustc limitation with a post-processing step in the bindgen
build that adjusts the attributes to include "#[repr(C, align(N))]" and
exclude #[repr(packed(N)] only for the 4 types that need it. It also
updates bch_bindgen to format the code with prettyplease so that this
will work even in environments with rustfmt installed.

Some types that had been manually implemented in
bch_bindgen/src/bcachefs.rs are now automatically generated by bindgen,
so that they will be covered by the ABI compatibility testing mentioned
above.

I intentionally targeted the post-processing to the exact 4 types with
the issue currently, so that any changes to bcachefs that result in this
issue appearing for a new type will require manual intervention. I
figured any such changes should require careful consideration.

Ideally, bindgen can be updated to handle situations where "align(N)"
is needed and "packed(N)" can be safely discarded. If a patch for this
is accepted into bindgen, the post-processing hack can be removed.

I update the minimum Rust version to 1.70 as this is needed to build
recent versions of some dependencies.

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
3 months agoremove bch_bindgen/Cargo.lock from version control
Thomas Bertschinger [Mon, 22 Jan 2024 04:38:37 +0000 (21:38 -0700)]
remove bch_bindgen/Cargo.lock from version control

This is redundant with the root level Cargo.lock. Any changes made to
the bch_bindgen dependencies will be duplicated in both Cargo.lock
files. Removing this from version control will reduce the noise in the
git diffs for such changes.

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
3 months agoMerge pull request #220 from ElvishJerricco/fix-nix-and-docs
koverstreet [Tue, 23 Jan 2024 07:53:21 +0000 (02:53 -0500)]
Merge pull request #220 from ElvishJerricco/fix-nix-and-docs

Fix nix and docs

3 months agorust: fix docs
Will Fancher [Sun, 21 Jan 2024 22:16:58 +0000 (17:16 -0500)]
rust: fix docs

3 months agonix: fix build
Will Fancher [Sun, 21 Jan 2024 22:16:51 +0000 (17:16 -0500)]
nix: fix build

3 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

3 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>
3 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>
3 months agoAdd option to read passphrase from a keyfile
Oz Tiram [Mon, 15 Jan 2024 14:40:02 +0000 (15:40 +0100)]
Add option to read passphrase from a keyfile

Similar to the same option with luks. Ofcourse,
one can simply wrap bcachefs tool with a script and expect,
but this is a nicer way of doing things.

Signed-off-by: Oz Tiram <oz.tiram@gmail.com>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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

3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 months agocmd_show_super: --field-only
Kent Overstreet [Fri, 5 Jan 2024 17:39:05 +0000 (12:39 -0500)]
cmd_show_super: --field-only

3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 months agoimprove do_splice()
Kent Overstreet [Thu, 4 Jan 2024 01:30:35 +0000 (20:30 -0500)]
improve do_splice()

3 months agoUpload to unstable
Jonathan Carter [Wed, 3 Jan 2024 15:06:47 +0000 (17:06 +0200)]
Upload to unstable

3 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

3 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>
3 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 agoUpload to experimental
Jonathan Carter [Wed, 27 Dec 2023 17:51:21 +0000 (19:51 +0200)]
Upload to experimental

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

4 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

4 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

4 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.

4 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>
4 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>
4 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>