167 Commits

Author SHA1 Message Date
Kent Overstreet
b02c3e9682 posix_to_bcachefs: cleanup
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-12 19:49:41 -04:00
Kent Overstreet
c074341f16 posix_to_bcachefs: sync file data, not just copy
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-12 19:49:41 -04:00
Kent Overstreet
3830cc296a posix_to_bcachefs: create_or_update_file()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-12 19:49:41 -04:00
Kent Overstreet
6795cb6d0c posix_to_bcachefs: delete_non_matching_dirents()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-12 19:49:41 -04:00
Kent Overstreet
f9d8d2c51d cmd_image: hook up c->loglevel
Quieter output.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-12 19:49:41 -04:00
Kent Overstreet
a0f12e09b6 cmd_image: Flush journal before moving btree
We need the key cache to be flushed before moving btree nodes - key
cache flushing won't obey the target we're moving btree nodes to.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-07 19:54:48 -04:00
Kent Overstreet
03d7318c31 cmd_data: scrub is bcachefs data scrub, not bcachefs data job scrub
Some checks failed
build / bcachefs-tools-deb (ubuntu-22.04) (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-24.04) (push) Has been cancelled
build / bcachefs-tools-rpm (push) Has been cancelled
build / bcachefs-tools-msrv (push) Has been cancelled
Nix Flake actions / nix-matrix (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-07 16:22:38 -04:00
Kent Overstreet
39c00050d2 bpos_parse(): parse symbolic constants
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-07 16:14:18 -04:00
Kent Overstreet
60ec05df84 bcachefs recovery-passes
New subcommand for scheduling or descheduling recovery passes on an
unmounted filesystem.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-06 12:29:26 -04:00
Kent Overstreet
cdde2f1160 Add missing newline to bcachefs --help
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-06 11:26:15 -04:00
Kent Overstreet
b392d55d4a cmd_migrate: Fix small UAF
Some checks failed
build / bcachefs-tools-deb (ubuntu-22.04) (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-24.04) (push) Has been cancelled
build / bcachefs-tools-rpm (push) Has been cancelled
build / bcachefs-tools-msrv (push) Has been cancelled
Nix Flake actions / nix-matrix (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-05 11:33:49 -04:00
Kent Overstreet
7c0c6c812b cmd_device_evacuate: --force
Some checks failed
build / bcachefs-tools-deb (ubuntu-22.04) (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-24.04) (push) Has been cancelled
build / bcachefs-tools-rpm (push) Has been cancelled
build / bcachefs-tools-msrv (push) Has been cancelled
Nix Flake actions / nix-matrix (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled
We now take the --force option, like set-state, if the array will become
degraded.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-04 13:02:12 -04:00
Kent Overstreet
e7cc6bb9cf getopt() -> getopt_long()
Kill all remaining getopt() uses - all options can now be passed as
longopts.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-04 12:47:30 -04:00
Kent Overstreet
7d69a303d1 kill_btree_node: We can now kill nodes on a specific device
For improved btree node scan tests.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-03 21:12:00 -04:00
Kent Overstreet
78b1ccf5f1 cmd_list_journal: By default, print all contiguous entries
Some checks failed
Nix Flake actions / nix-matrix (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-22.04) (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-24.04) (push) Has been cancelled
build / bcachefs-tools-rpm (push) Has been cancelled
build / bcachefs-tools-msrv (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled
Previously, we defaulted to only printing dirty journal entries (which
means nothing would be printed after a clean shutdown) - this is usually
not what we want.

Now, we default to printing the biggest range that has no gaps or
missing entries.

-a, --all
  now means print all entries, not just contiguous entries

And we now have

-d, --dirty-only
  for the the previous default behaviour.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-02 15:33:07 -04:00
Kent Overstreet
4145de1746 cmd_list_journal: new options
Some checks failed
build / bcachefs-tools-deb (ubuntu-22.04) (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-24.04) (push) Has been cancelled
build / bcachefs-tools-rpm (push) Has been cancelled
build / bcachefs-tools-msrv (push) Has been cancelled
Nix Flake actions / nix-matrix (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled
-D, --datetime
  Print out one line per journal entry, with datetime it was written

-L, --log-only
  Only print entries containing log messages

-F, --flush-only
  Only print flush commits

Additionally, we now print a line for missing journal entry ranges.

These make it easier to get an overall picture of what happened in the
journal - in particular, seeing how far back we can rewind before we
have gaps.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-06-30 22:39:52 -04:00
Kent Overstreet
84f7b2fdc3 cmd_fsck: Online fsck can now specify a mountpoint
If the specified path is a directory, we'll try to run online fsck on
the filesystem mounted at that path.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-06-25 13:20:59 -04:00
Kent Overstreet
45f6fe0a14 cmd_image_create
Some checks failed
build / bcachefs-tools-deb (ubuntu-22.04) (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-24.04) (push) Has been cancelled
build / bcachefs-tools-rpm (push) Has been cancelled
build / bcachefs-tools-msrv (push) Has been cancelled
Nix Flake actions / nix-matrix (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled
Add a tool for creating small image files.

Data is written out in a reproducible order, sequentially from the
start of the device.

Metadata is initially written to a temporary device, then after writing
out data, the metadata we want to keep (alloc info is left out by
default) is migrated to the real device.

Then, the image file is trimmed to minimum size and the temporary
metadata device dropped.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-06-20 17:16:33 -04:00
Kent Overstreet
f2d9a55b1b cmd_strip_alloc
Add a command for stripping allocation info for a filesystem.

This is primarily to test codepaths used by the new image creation tool.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-06-20 17:16:33 -04:00
Kent Overstreet
3f66d905c0 bch2_format_for_device_add()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-06-20 17:16:33 -04:00
Kent Overstreet
792222046d cmd_list_journal: More filtering tweaks
New options:

-B: show blacklisted entries: previously show by default, but
    highlighted
-l: Show log-only entries, i.e. recovery, snapshot deletion messages
-o: Print entry offset for each subentry

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-06-13 19:58:02 -04:00
Kent Overstreet
529d14db49 cmd_list_journal: Fix assertion pop
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-06-07 19:17:53 -04:00
Kent Overstreet
f4aa18bea1 cmd_device: Device add now updates blkid cache
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-06-07 19:04:03 -04:00
Kent Overstreet
8868e1c2b4 cmd_fsck: -p is also a noop
Some checks failed
build / bcachefs-tools-deb (ubuntu-22.04) (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-24.04) (push) Has been cancelled
build / bcachefs-tools-rpm (push) Has been cancelled
build / bcachefs-tools-msrv (push) Has been cancelled
Nix Flake actions / nix-matrix (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-06-05 20:26:10 -04:00
Kent Overstreet
0a7bbc6aeb cmd_fsck: make sure to modprobe if we might need kernel fsck
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-06-05 20:25:50 -04:00
Kent Overstreet
315508358d cmd_list_journal: Improved matching
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-06-02 17:24:50 -04:00
Kent Overstreet
f6ed4c26d7 cmd_list_journal: Improved matching
Some checks failed
Nix Flake actions / nix-matrix (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-22.04) (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-24.04) (push) Has been cancelled
build / bcachefs-tools-rpm (push) Has been cancelled
build / bcachefs-tools-msrv (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-06-01 19:37:00 -04:00
Kent Overstreet
72f550f2da cmd_fs_top(): skip non firing counters, add column for total
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-28 19:49:16 -04:00
Kent Overstreet
6cb4160e0c cmd_list_journal: handle jset_entries with bad lengths
Some checks failed
build / bcachefs-tools-deb (ubuntu-22.04) (push) Has been cancelled
Nix Flake actions / nix-matrix (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-24.04) (push) Has been cancelled
build / bcachefs-tools-rpm (push) Has been cancelled
build / bcachefs-tools-msrv (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-25 17:59:45 -04:00
Kent Overstreet
241bcd0183 Fix infinite loop in cmd_list_journal
list_journal can print the entire contents of the journal, and non-dirty
entries don't get validated, so we have to account for that.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-25 17:05:55 -04:00
Kent Overstreet
fa0a54c45c cmd_dump: Don't use noexcl by default
Some checks failed
build / bcachefs-tools-deb (ubuntu-22.04) (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-24.04) (push) Has been cancelled
build / bcachefs-tools-rpm (push) Has been cancelled
build / bcachefs-tools-msrv (push) Has been cancelled
Nix Flake actions / nix-matrix (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled
This has been leading to too many people taking metadata dumps of rw
mounted filesystems.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-21 21:41:04 -04:00
Kent Overstreet
3139850c75 suppress warn_unused_result
Some checks failed
Nix Flake actions / nix-matrix (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-22.04) (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-24.04) (push) Has been cancelled
build / bcachefs-tools-rpm (push) Has been cancelled
build / bcachefs-tools-msrv (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-15 17:58:36 -04:00
Mark Bryars
cea4d4dea3 Fix human readable units for compressed data
It was forcing human readable units even without the -h flag,
so use the functions that respect that configuration.
2025-05-15 22:55:50 +02:00
Kent Overstreet
968369e0da Update bcachefs sources to db6b78d0e5ef bcachefs: Extend bucket_size to 32 bits
Some checks failed
Nix Flake actions / nix-matrix (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-22.04) (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-24.04) (push) Has been cancelled
build / bcachefs-tools-rpm (push) Has been cancelled
build / bcachefs-tools-msrv (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-08 14:37:46 -04:00
Kent Overstreet
723b9092ac cmd_recover_super: Add a mode for recovering from another member device
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-08 12:26:19 -04:00
Kent Overstreet
79ec3dd3e3 cmd_super.c
Move some things out of cmd_format.c

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-08 11:21:53 -04:00
Kent Overstreet
6e4bda5ad5 Set BCH_FEATURE_incompat_version_field if supported
Some checks are pending
build / bcachefs-tools-deb (ubuntu-22.04) (push) Waiting to run
build / bcachefs-tools-deb (ubuntu-24.04) (push) Waiting to run
build / bcachefs-tools-rpm (push) Waiting to run
build / bcachefs-tools-msrv (push) Waiting to run
Nix Flake actions / nix-matrix (push) Waiting to run
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Blocked by required conditions
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-03 16:27:03 -04:00
Kent Overstreet
a4babd1d64 fix fsck return code for in-kernel fsck
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-02 14:33:52 -04:00
Kent Overstreet
5f46c4b522 Don't use xclose() in splice_fd_to_stdinout()
Some checks failed
build / bcachefs-tools-deb (ubuntu-22.04) (push) Waiting to run
build / bcachefs-tools-deb (ubuntu-24.04) (push) Waiting to run
build / bcachefs-tools-rpm (push) Waiting to run
build / bcachefs-tools-msrv (push) Waiting to run
Nix Flake actions / nix-matrix (push) Waiting to run
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Blocked by required conditions
update-flake-lock / lockfile (push) Has been cancelled
The splice fd might have been closed, and a double-close here shouldn't
be a concern because we're not doing any interesting multithreaded
things and it's local to this function.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-04-29 13:33:29 -04:00
Kent Overstreet
6d7b47685b Update bcachefs sources to f0ebca18293c bcachefs: bch2_fs_open() now takes a darray
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-04-28 15:31:43 -04:00
Kent Overstreet
e00e83b84d copy_data should be static
Some checks are pending
build / bcachefs-tools-deb (ubuntu-22.04) (push) Waiting to run
build / bcachefs-tools-deb (ubuntu-24.04) (push) Waiting to run
build / bcachefs-tools-rpm (push) Waiting to run
build / bcachefs-tools-msrv (push) Waiting to run
Nix Flake actions / nix-matrix (push) Waiting to run
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Blocked by required conditions
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-04-26 21:20:08 -04:00
Kent Overstreet
3304c90bec format_opts.no_sb_at_end
Add an option for controlling whether we create a third redundant
superblock at the end of the device.

For image files that are going to immediately be resized, we want to
skip this.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-04-21 18:46:30 -04:00
Kent Overstreet
fee67d807b linux shim: implement BLK_OPEN_CREAT
this allows O_CREAT to be passed through, for the new image creation
tool.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-04-21 18:46:30 -04:00
Kent Overstreet
8fae948d60 fixup! posix_to_bcachefs: Process dirents in sorted order 2025-04-21 18:46:30 -04:00
Kent Overstreet
6a83d70ef5 Update bcachefs sources to c9d875f9be1f bcachefs: Casefold is now a regular opts.h option
Some checks are pending
build / bcachefs-tools-deb (ubuntu-22.04) (push) Waiting to run
build / bcachefs-tools-deb (ubuntu-24.04) (push) Waiting to run
build / bcachefs-tools-rpm (push) Waiting to run
build / bcachefs-tools-msrv (push) Waiting to run
Nix Flake actions / nix-matrix (push) Waiting to run
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Blocked by required conditions
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-04-21 15:47:15 -04:00
Kent Overstreet
98f2c06d41 fd fixes
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-04-21 14:32:50 -04:00
Kent Overstreet
dd2c7b9b89 format: Ensure we pick power of two bucket size
Non power of two bucket sizes are allowed - but not preferred.

We were accidentally picking bucket sizes that weren't blocksize
aligned - ouch.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-04-18 17:24:19 -04:00
Kent Overstreet
0f59cc6a9e Update bcachefs sources to 65456ba56b93 bcachefs: Fix struct with flex member ABI warning 2025-04-17 12:51:03 -04:00
Kent Overstreet
642bc34abc fixup! Add support for FS_IOC_GETFSSYSFSPATH
Some checks failed
Nix Flake actions / nix-matrix (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-22.04) (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-24.04) (push) Has been cancelled
build / bcachefs-tools-rpm (push) Has been cancelled
build / bcachefs-tools-msrv (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-04-15 12:01:13 -04:00
Kent Overstreet
0335994507 Fix bchu_fs_open_by_dev()
- we can now correctly open by parsing sysfs, instead of falling back to
  reading the superblock and grabbing the UUID

- non-UUID filesystem names now work

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-04-15 11:28:47 -04:00