Commit Graph

1225 Commits

Author SHA1 Message Date
Kent Overstreet
8c9dddb00a getattr skeleton 2023-12-23 18:16:15 -05:00
Kent Overstreet
8b2a893c6b v1.4.0: Split brain detection
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-23 17:10:13 -05:00
Kent Overstreet
f0334bbc10 Update bcachefs sources to 72740a707b64 bcachefs: Split brain detection
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-23 17:10:03 -05:00
Kent Overstreet
ca4892af17 cmd_fsck can now take colon separated devices
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-22 23:30:55 -05:00
Kent Overstreet
5134a64ceb Update bcachefs sources to c6d45169c6 bcachefs: Convert split_devs() to darray 2023-12-22 21:21:14 -05:00
koverstreet
e962ffb769
Merge pull request #194 from intelfx/work/makefile-nonrecursive
Makefile: do not recursively expand flags (speed up parallel builds considerably)
2023-12-22 04:49:58 -05:00
Ivan Shapovalov
ae818d9579 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
```
2023-12-22 11:41:54 +03:00
Kent Overstreet
eaca023d53 Silence a few rust build warnings
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-21 19:49:55 -05:00
Kent Overstreet
596ec1050d Update bcachefs sources to df6415fefb27 bcachefs: Fixes for rust bindgen 2023-12-21 19:49:00 -05:00
Kent Overstreet
93241a1c9a Update bcachefs sources to 5d0a6c2b32f1 bcachefs: check_directory_structure() can now be run online 2023-12-21 19:10:40 -05:00
Thomas Bertschinger
2b97686ffa 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>
2023-12-20 18:45:43 -05:00
Kent Overstreet
0bacefdf5f cmd_list_journal: fix check to print entry header
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-19 21:28:43 -05:00
Kent Overstreet
4158833a51 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>
2023-12-19 20:35:24 -05:00
Thomas Bertschinger
f06fd08067 docs: add llvm-config dependency for arch, fedora
This adds on to 446ec6b092 ("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>
2023-12-19 19:52:37 -05:00
Kent Overstreet
411eb2575e cmd_migrate: fix memory leaks
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-19 19:43:30 -05:00
Kent Overstreet
2b28e8f7d2 make allocator helpers inlines
this gets us better log messages when using -fsanitize=address

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-19 19:30:15 -05:00
Kent Overstreet
5fa4e3da62 cmd_migrate: check for write errors
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-19 19:30:00 -05:00
Kent Overstreet
fe37b584d3 fix shrinker_free()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-19 19:29:25 -05:00
Kent Overstreet
3233d8a0c4 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>
2023-12-19 19:17:21 -05:00
Kent Overstreet
f2cb831b99 v1.3.6
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-18 23:29:06 -05:00
Kent Overstreet
e9df26f9c9 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>
2023-12-18 23:21:43 -05:00
Kent Overstreet
f76d246fff Update bcachefs sources to 1a739db0b256 bcachefs; guard against overflow in btree node split
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-18 23:21:21 -05:00
Kent Overstreet
b7453196fe cmd_dump: fix error message
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-17 15:42:51 -05:00
Kent Overstreet
d8e7f3671d Fix makefile when building without systemd
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-16 18:42:22 -05:00
Kent Overstreet
b6740e5392 Update bcachefs sources to 841a95c29f4c bcachefs: fix userspace build errors
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-15 22:20:39 -05:00
Alexander Fougner
4c5dcb018d 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>
2023-12-10 12:16:00 -05:00
Chris Webb
b44629a3db 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>
2023-12-10 12:14:23 -05:00
Chris Webb
cc98a16776 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>
2023-12-09 23:29:04 -05:00
Chris Webb
0d401928b8 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>
2023-12-09 23:28:58 -05:00
Chris Webb
872cd437e7 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>
2023-12-09 23:28:01 -05:00
Chris Webb
ddc7161531 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>
2023-12-09 23:26:29 -05:00
Chris Webb
2d5118e01f 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>
2023-12-09 23:25:00 -05:00
Tero Roponen
6b674b8817 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>
2023-12-08 15:07:32 -05:00
Kent Overstreet
e3e7f67b3e Merge remote-tracking branch 'amoz/devel' 2023-12-07 20:19:06 -05:00
koverstreet
36898f574b
Merge pull request #190 from Dikay900/fs_free_space
cmd_fs: calculate free space
2023-12-07 20:10:15 -05:00
Alexander Fougner
244046945a fix build for glibc prior to 2.33
Signed-off-by: Alexander Fougner <fougner89@gmail.com>
2023-12-07 21:36:47 +01:00
Alexander Fougner
262e548a84 fix fallback flex array
Signed-off-by: Alexander Fougner <fougner89@gmail.com>
2023-12-07 21:36:45 +01:00
Philip Laube
5bc5fc621a 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>
2023-12-07 20:47:09 +01:00
Kent Overstreet
ea5264fdf4 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>
2023-12-07 12:04:24 -05:00
Kent Overstreet
8d8a9f3e9b Update bcachefs sources to 6d44812757dd bcachefs: BCH_IOCTL_FSCK_ONLINE
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-07 11:57:36 -05:00
Kent Overstreet
db9ae9a79d Update .gitignore for new service files
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2023-12-07 11:57:36 -05:00
Darrick J. Wong
74753de989 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>
2023-12-07 11:57:36 -05:00
Darrick J. Wong
fbfdd05ac5 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>
2023-12-07 11:57:36 -05:00
koverstreet
5fa7db9806
Merge pull request #191 from cepelinas9000/fuse-fixes-1
Multiple small fuse fixes for write, api, and hardlink
2023-12-07 11:57:04 -05:00
Tautvydas Nesvarbu
bb50e50173 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.
2023-12-07 15:17:34 +02:00
Alexander Fougner
1c2cb80376 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>
2023-12-06 15:41:05 -05:00
koverstreet
5d892680cf
Merge pull request #189 from Dikay900/fs_human_readable
cmd_fs: add long parameter --human-readable to usage command
2023-12-06 13:58:01 -05:00
Philip Laube
ec028b4913 cmd_fs: add long parameter --human-readable to usage command
Signed-off-by: Philip Laube <philip.laube.dev@xyz.de>
2023-12-06 19:29:05 +01:00
Kent Overstreet
cf78a3f65c 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>
2023-12-05 23:53:29 -05:00
Darrick J. Wong
f407121d18 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>
2023-12-04 19:49:26 -05:00