Commit Graph

1312 Commits

Author SHA1 Message Date
Kent Overstreet
de9c798382 v1.6.3
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-20 18:42:07 -05:00
Kent Overstreet
e5b2870d05 Update bcachefs sources to c887148ebf99 thread_with_file: add f_ops.flush
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-20 16:28:27 -05:00
Kent Overstreet
6ff5313cbe cmd_fsck: Collect return code of kernel fsck with close()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-17 23:31:47 -05:00
Thomas Bertschinger
b2824ebac1 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>
2024-02-17 13:38:09 -05:00
Kent Overstreet
46590fa310 Merge remote-tracking branch 'github/master' 2024-02-16 01:53:51 -05:00
koverstreet
d1900b637e
Merge pull request #211 from oz123/master
Add option to read passphrase from a keyfile
2024-02-16 01:53:37 -05:00
Kent Overstreet
e773e86495 Update bcachefs sources to 9a555a741e80 bcachefs: omit alignment attribute on big endian struct bkey 2024-02-15 23:45:29 -05:00
Kent Overstreet
f2ba586baf fix build on old gcc
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-13 23:27:04 -05:00
Kent Overstreet
da67fc2360 fsck: Fall back to userland fsck when probed for kernel fsck
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-13 22:05:09 -05:00
Kent Overstreet
cd4cbfc627 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>
2024-02-12 15:52:26 -05:00
Kent Overstreet
b03f7b606f kill_btree_node: fix return code
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-10 21:16:03 -05:00
Kent Overstreet
9866af841e Update bcachefs sources to 39a84c99af2d bcachefs: Clamp replicas_required to replicas 2024-02-10 21:06:20 -05:00
Kent Overstreet
7a716b76b5 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>
2024-02-09 21:32:46 -05:00
koverstreet
9e6d9560d0
Merge pull request #236 from ErrorNoInternet/subcommand-aliases
Add a few subcommand aliases
2024-02-09 14:20:29 -05:00
ErrorNoInternet
4327e0681b
feat: add aliases for a few subcommands 2024-02-09 17:37:01 +08:00
ErrorNoInternet
428948e120
refactor: clean up arguments 2024-02-09 17:36:49 +08:00
Alexander Fougner
a95a25dc1d 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>
2024-02-07 21:27:35 +01:00
Kent Overstreet
bc0a443850 kill dependency on char signedness
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-06 23:13:02 -05:00
Kent Overstreet
168126a41e fix snapshotting when dst is single component path
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-06 01:34:50 -05:00
Kent Overstreet
f3f005c76e Update bcachefs sources to 50847e296b34 bcachefs: Check subvol <-> inode pointers in check_inode()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-06 01:07:16 -05:00
Kent Overstreet
1ef396b684 cmd_subvolume: Fix snapshot creation with implicit source
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-05 21:31:08 -05:00
Frederik Schwan
1d39ee23af cosmetic refactoring of Makefile
Make clear that LIBEXECDIR is an option.
2024-02-05 20:47:54 -05:00
Thomas Bertschinger
f6b619daad 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>
2024-02-04 18:26:33 -05:00
koverstreet
f154e6ed41
Merge pull request #231 from sesse/install-mount
Make initramfs hook install mount.btrfs
2024-02-04 08:46:14 -05:00
Steinar H. Gunderson
e9fec00f86 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.
2024-02-04 14:44:54 +01:00
koverstreet
f15633cce1
Merge pull request #229 from g2p/cli-symlink
Add bcachefs command compatibility symlink
2024-01-29 12:20:04 -05:00
koverstreet
f2f1b5c3ec
Merge pull request #228 from g2p/non-utf8-printbuf-display
printbuf_to_formatter: Lossy display of non-UTF-8 printbufs
2024-01-29 12:19:16 -05:00
Gabriel
f8f10530f1 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.
2024-01-29 14:34:24 +01:00
Gabriel
ca06a063fa 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.
2024-01-29 14:29:35 +01:00
Kent Overstreet
da4bbf51d0 cmd_list_journal: --transaction-filter now takes range
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-01-27 10:58:14 -05:00
Ryan Lahfa
76538fa923 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>
2024-01-27 05:46:24 +01:00
Ryan Lahfa
ec277463e9 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>
2024-01-27 05:15:19 +01:00
Ryan Lahfa
e1d08fc1fc 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>
2024-01-27 05:15:19 +01:00
Ryan Lahfa
9282cb953c 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>
2024-01-27 05:15:19 +01:00
Ryan Lahfa
930646e8dd 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>
2024-01-27 04:20:47 +01:00
Raito Bezarius
11d2a45bc0 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>
2024-01-26 21:04:45 -05:00
Raito Bezarius
5787b1c234 feat(bindgen): expose BCH_IOCTL_SUBVOLUME_* on Rust side
As they are functional macro, they need help from our side.
2024-01-26 20:39:08 -05:00
Raito Bezarius
5a1975e528 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.
2024-01-26 20:39:08 -05:00
Raito Bezarius
234fe664b1 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.
2024-01-26 20:39:08 -05:00
Kent Overstreet
38b8d01c4c Update bcachefs sources to 481b5f343248 bcachefs: Better error messages for missing inodes in fsck
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-01-24 17:36:11 -05:00
Thomas Bertschinger
7717a439cf 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>
2024-01-23 13:08:12 -05:00
Thomas Bertschinger
505d5aaed2 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>
2024-01-23 02:53:45 -05:00
koverstreet
39e109e5f9
Merge pull request #220 from ElvishJerricco/fix-nix-and-docs
Fix nix and docs
2024-01-23 02:53:21 -05:00
Will Fancher
de191cd19c rust: fix docs 2024-01-23 02:38:24 -05:00
Will Fancher
8117fa732b nix: fix build 2024-01-23 02:38:20 -05:00
koverstreet
3da247cd20
Merge pull request #219 from xhebox/master
bch_bindgen: add liburcu paths by pkgconfig
2024-01-21 07:08:23 -05:00
xhe
03122a5888 bch_bindgen: add liburcu paths by pkgconfig
Signed-off-by: xhe <xw897002528@gmail.com>
2024-01-21 19:04:31 +08:00
Kent Overstreet
5e224596cf Remove gag usage
Possibly-fixes: https://github.com/koverstreet/bcachefs-tools/issues/217
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-01-20 22:32:00 -05:00
Oz Tiram
d0de5f03d2
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>
2024-01-18 11:53:12 +01:00
Kent Overstreet
b5fd066153 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>
2024-01-16 17:17:23 -05:00