233 Commits

Author SHA1 Message Date
Kent Overstreet
c00f25b3cc cmd_dump: split out dump_fs()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-20 12:21:03 -04:00
Kent Overstreet
191d5b4b09 ranges_sort()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-20 11:56:42 -04:00
Kent Overstreet
fdf2819481 cmd_dump improvements
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-20 11:56:42 -04:00
Kent Overstreet
54be622b28 qcow2: Refactor to prep for sanitizing
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-20 11:56:42 -04:00
Kent Overstreet
2f28824c2b qcow2: qcow2_write_(buf|ranges)
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-20 11:56:42 -04:00
Kent Overstreet
ffe083c31d Fix clang build errors
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-17 17:38:44 -04:00
Kent Overstreet
ac9ca56637 posix_to_bcachefs: plumb verbosity
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-15 18:39:45 -04:00
Kent Overstreet
97b8348d28 posix_to_bcachefs: fix inode.bi_sectors updates
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-15 18:39:45 -04:00
Kent Overstreet
5f92627783 cmd_image_update: Fix truncate call at the start of update
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 don't want to make the image smaller until we've finished updating.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-15 16:54:11 -04:00
Kent Overstreet
36a3634c5e fix fuse build
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-13 10:02:53 -04:00
koverstreet
73740b9cf2
Merge pull request #391 from prey169/master
Format filesystem with encryption using a passphase file
2025-07-13 08:05:00 -05:00
Jérôme Poulin
5dd10a17e9 cmd_attr: Add --options=- and --remove-all to unset options
Signed-off-by: Jérôme Poulin <jeromepoulin@gmail.com>
2025-07-12 22:20:17 -04:00
Kent Overstreet
3321afc8b6 cmd_image_update
New tool: 'bcachefs image update', for updating images produced by
'bcachefs image create': this tool will update images while making the
minimal changes to the on disk image, to make tools like casync more
efficient.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-12 19:49:55 -04:00
Kent Overstreet
c1a25673e9 cmd_image: finish_image()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-12 19:49:41 -04:00
Kent Overstreet
d0e71900a3 posix_to_bcachefs: create_or_update_link()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-07-12 19:49:41 -04:00
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
prey169
7362ed1223 Added the ability to format a filesystem with encryption, using a passphrase key located within a file 2025-07-03 23:54:12 -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