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
2023-08-04 20:13:38 +02:00
2023-09-01 17:51:31 +02:00
2023-08-11 18:32:23 -04:00
2018-11-23 02:10:44 -05:00
2022-03-24 11:41:10 -06:00
2023-01-03 16:58:55 +13:00
2023-03-08 21:00:51 +01:00
2022-05-26 15:40:08 -04:00
2022-05-26 15:40:08 -04:00
2023-08-11 18:32:23 -04:00
2023-06-10 20:59:22 -04:00
2023-07-20 18:11:51 -04:00
2023-08-11 18:32:23 -04:00
2016-03-11 21:18:42 -09:00
2013-07-17 13:13:31 -07:00
2023-01-03 16:58:55 +13:00
2023-06-16 13:56:53 +02:00
2023-08-04 20:13:38 +02:00
2023-08-11 18:32:23 -04:00
2017-03-09 09:14:11 -09:00
2023-03-07 12:46:53 -05: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

Description
Languages
C 95.6%
C++ 2%
Rust 1.4%
Roff 0.4%
Nix 0.2%
Other 0.4%