Go to file
Brian Foster f76c449ec0 bcachefs-tools: fix endian problems between bit spinlocks and futexes
bcachefs format on a big-endian (s390x) machine crashes down in the
rhashtable code imported from the kernel. The reason this occurs
lies within the rht_lock() -> bit_spin_lock() code, the latter of
which casts bitmaps down to 32-bits to satisfy the requirements of
the futex interface.

The specific problem here is that a 64 -> 32 bit cast doesn't refer
to the lower 8 bytes on a big endian machine, which means setting
bit number 0 in the 32-bit map actually corresponds to bit 32 in the
64-bit map. The rhashtable code specifically uses bit zero of the
bucket pointer for exclusion and uses native bitops elsewhere (i.e.
__rht_ptr()) to identify NULL pointers. If bit 32 of the pointer is
set by the locking code instead of bit 0, an otherwise NULL pointer
looks like a non-NULL value and results in a segfault.

The bit spinlock code imported by the kernel is originally intended
to work with unsigned long. The kernel code is able to throttle the
cpu directly when under lock contention, while the userspace
implementation relies on the futex primitives to emulate reliable
blocking. Since the futex interface introduces the 32-bit
requirement, isolate the associated userspace hack to that
particular code.

Restore the native bitmap behavior of the bit spinlock code to
address the rhashtable problem described above. Since this is not
compatible with the futex interface, create a futex wrapper
specifically to convert the native bitmap type to a 32-bit virtual
address and mask value for the purposes of waiting/waking when under
lock contention.

Signed-off-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-09-19 17:26:45 -04:00
.github ci: set and verify MSRV 2023-08-04 20:13:38 +02:00
ccan Update bcachefs sources to f638850417 bcachefs: bch2_trans_log_msg() 2022-03-30 17:40:37 -04:00
debian Add rust toolchain to debian build-deps 2023-03-05 05:37:08 -05:00
doc Add additional information about encryption 2023-07-10 16:03:30 -04:00
include bcachefs-tools: fix endian problems between bit spinlocks and futexes 2023-09-19 17:26:45 -04:00
initramfs Replaced mkdir -p with install -D in make install 2019-01-13 19:31:04 -08:00
libbcachefs cmd_set_passphrase: revoke the invalidated key 2023-09-08 04:05:36 -04:00
linux Fix one second delay when exiting 2023-09-01 17:51:31 +02:00
packaging fuse: Set fsname correctly 2023-08-11 18:32:23 -04:00
raid snapraid 2018-11-23 02:10:44 -05:00
rust-src cmd_mount: request passphrase if the existing key is revoked 2023-09-08 04:05:39 -04:00
tests Add valgrind suppressions: 2022-03-24 11:41:10 -06:00
.bcachefs_revision Update bcachefs sources to e7f6215768 bcachefs: Fix snapshot_skiplist_good() 2023-08-28 15:20:58 -04:00
.editorconfig nix: overhaul build system. 2023-01-03 16:58:55 +13:00
.gitignore .gitignore: replace travis with github-ci config 2023-07-20 22:27:56 +02:00
bcachefs.8 Add manpage for mount command 2023-03-08 21:00:51 +01:00
bcachefs.c cmd_mount: don't return 0 on mount failure 2023-08-10 11:01:24 -04:00
build.nix build.nix: add instruction to keep cargoDeps hashes up-to-date 2023-06-16 14:02:17 +02:00
cmd_assemble.c Update bcachefs sources to 0906b1fb49 bcachefs: fixes for 32 bit/big endian machines 2018-05-17 02:36:19 -04:00
cmd_attr.c Update email address 2022-05-26 15:40:08 -04:00
cmd_data.c Update email address 2022-05-26 15:40:08 -04:00
cmd_device.c Update bcachefs sources to 717b356d1d bcachefs: Convert journal validation to bkey_invalid_flags 2023-08-06 13:08:36 -04:00
cmd_dump.c cmd_dump: Also set read_only 2023-08-11 18:32:23 -04:00
cmd_format.c Get current metadata version from sysfs 2022-12-21 21:41:34 -05:00
cmd_fs.c cmd_fs_usage: Implement --help 2023-06-10 20:59:22 -04:00
cmd_fsck.c Fix 'bcachefs fsck -y' 2023-07-20 18:11:51 -04:00
cmd_fusemount.c fuse: Set fsname correctly 2023-08-11 18:32:23 -04:00
cmd_key.c cmd_set_passphrase: revoke the invalidated key 2023-09-08 04:05:36 -04:00
cmd_kill_btree_node.c Update bcachefs sources to 717b356d1d bcachefs: Convert journal validation to bkey_invalid_flags 2023-08-06 13:08:36 -04:00
cmd_list_journal.c cmd_list_journal: Tweak extent matching 2023-08-01 16:57:52 -04:00
cmd_migrate.c Update bcachefs sources to da7d42a9a2 bcachefs: Add new assertions for shutdown path 2023-07-09 15:25:40 -04:00
cmd_option.c Use bch2_err_str() instead of strerror() 2022-12-19 16:05:54 -05:00
cmd_run.c Update bcachefs sources to 0906b1fb49 bcachefs: fixes for 32 bit/big endian machines 2018-05-17 02:36:19 -04:00
cmd_subvolume.c Add more specific subcommand usage messages 2021-11-01 08:12:35 -06:00
cmd_version.c Added 'version' command to print when the bcachefs tool was built 2018-05-26 14:32:30 -07:00
cmds.h cmd_mount: don't return 0 on mount failure 2023-08-10 11:01:24 -04:00
config.h Redo lots of stuff 2016-03-11 21:18:42 -09:00
COPYING bcache-tools are GPL 2013-07-17 13:13:31 -07:00
crypto.c cmd_unlock: Add -k argument to specify keyring 2022-05-19 16:01:51 -04:00
crypto.h cmd_unlock: Add -k argument to specify keyring 2022-05-19 16:01:51 -04:00
default.nix nix: overhaul build system. 2023-01-03 16:58:55 +13:00
flake.lock flake.lock: Update 2023-06-16 13:56:53 +02:00
flake.nix nix fix up! Rust now integrated into bcachefs binary 2023-02-27 16:39:46 +13:00
fsck.bcachefs fsck.bcachefs: convert to POSIX sh 2018-02-09 16:52:44 +01:00
INSTALL.md ci: set and verify MSRV 2023-08-04 20:13:38 +02:00
libbcachefs.c libbcachefs: convert sb features mask to little endian 2023-09-19 16:15:56 -04:00
libbcachefs.h Update bcachefs sources to 84f132d569 bcachefs: fsck: Break walk_inode() up into multiple functions 2023-06-27 19:38:18 -04:00
Makefile Update bcachefs sources to a8115093df bcachefs: Fix divide by zero in rebalance_work() 2023-08-17 17:11:27 -04:00
Makefile.compiler Update bcachefs sources to 6a20aede29 bcachefs: Fix quotas + snapshots 2023-05-02 00:41:47 -04:00
mkfs.bcachefs mkfs.bcachefs: convert to POSIX sh 2018-02-09 16:54:03 +01:00
mount.bcachefs Rust now integrated into bcachefs binary 2023-02-21 01:03:08 -05:00
mount.bcachefs.sh Add a shell script version of mount.bcachefs 2020-08-24 23:17:17 -04:00
mount.fuse.bcachefs fuse: Set fsname correctly 2023-08-11 18:32:23 -04:00
qcow2.c Update bcachefs sources to f638850417 bcachefs: bch2_trans_log_msg() 2022-03-30 17:40:37 -04:00
qcow2.h cmd_migrate 2017-03-09 09:14:11 -09:00
README.md Update docs 2023-03-07 12:46:53 -05:00
tools-util.c Fix null ptr deref in bbpos_parse() 2023-08-22 15:45:35 -04:00
tools-util.h Update bcachefs sources to 33a60d9b05 bcachefs: Assorted fixes for clang 2023-08-01 22:13:03 -04:00

bcachefs-tools

Userspace tools and docs for bcachefs

Bcachefs is an advanced new filesystem for Linux, with an emphasis on reliability and robustness and the complete set of features one would expect from a modern filesystem.

This repo primarily consists of the following:

  • bcachefs tool, the reason this repo exists.
  • {mkfs,mount,fsck}.bcachefs utils, which is just wrappers calling the corresponding subcommands in the main tool
  • docs in the form of man-pages and a user manual

Please refer to the main site for getting started An in-depth user manual is (also) found on the official website

Build and install

Refer to INSTALL.md

Bug reports and contributions