Commit Graph

82 Commits

Author SHA1 Message Date
Kent Overstreet
db3121cbf9 Fix cmd_fs_usage for disk accounting key sort change
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-Tests / nix-flake-check (push) Has been cancelled
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-01-05 20:08:37 -05:00
Kent Overstreet
43a1380575 Scrub
Implement 'bcachefs data scrub', frontend for
BCH_IOCTL_DATA.BCH_DATA_OP_scrub.

Takes a path to a device, mountpoint, or filesystem uuid. Can be run on
a specific device by passing a device, or if run on a filesystem scrubs
all devices in parallel.

Metadata only scrubbing is supported via -m.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-12-30 21:56:48 -05:00
Kent Overstreet
ef25411bdc fixup! bcachefs: cmd_set_option() can now set device options on multi device filesystems 2024-12-09 03:55:16 -05:00
Kent Overstreet
2aeeac7785 bcachefs: cmd_set_option() can now set device options on multi device filesystems
Currently, 'bcachefs set-fs-option' requires all devices to be specified
when setting options on an offline multidevice filesystem - it can't yet
scan for the rest of the filesystem members.

We do need to fix this, but the scan code is written in Rust, so that
either means a lot of ugly FFI code or rewriting cmd_set_option() in
Rust - neither of which are happening today.

So as an interim hack, add a --dev-idx option: this can be specified
(multiple times if desired) for indicating which devices the device
specific options should be applied to.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-12-06 16:30:19 -05:00
Kent Overstreet
83cc57700f fixup! cmd_format: fix --version
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-12-04 21:22:03 -05:00
koverstreet
077677e61c
Merge pull request #329 from ticpu/set-passphrase
Fix set-passphrase on --no_passphrase FS
2024-12-03 22:41:13 -05:00
Kent Overstreet
c560ff06f4 cmd_format: fix --version
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-12-03 21:51:26 -05:00
Kent Overstreet
6829fb2010 fix online fsck options
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-11-28 23:43:06 -05:00
Integral
d4932bf0e3 bcachefs-tools: Fix TODO "Show bcachefs version"
Fix TODO "Show bcachefs version" in fusemount.

Signed-off-by: Integral <integral@archlinuxcn.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-11-06 16:21:02 -05:00
Gabriel de Perthuis
8d5f44d3b1 Check for a sufficiently recent libblkid before formatting
This can prevent data loss as libblkid < 2.40.1 can fail
to recognize existing bcachefs filesystems.

Reported on #bcache.

Signed-off-by: Gabriel de Perthuis <g2p.code@gmail.com>
2024-10-27 14:48:05 +00:00
Integral
5350fd2b7b bcachefs-tools: fix build failure when BCACHEFS_FUSE=1
Currently, when BCACHEFS_FUSE=1 is set, bcachefs-tools failed to build.
Replace "bch2_trans_do()" macro with "bch2_trans_commit_do()" in
cmd_fusemount.c to fix build failure.

Signed-off-by: Integral <integral@archlinuxcn.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-10-26 01:48:17 -04:00
Kent Overstreet
2541755981 cmd_fsck: Add -K flag (don't run kernel fsck)
This was added previously, but not added to the getopt string.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-10-20 19:23:21 -04:00
Kent Overstreet
553d6f107a Update bcachefs sources to 1dbc147a6eb0 bcachefs: Add version check for bch_btree_ptr_v2.sectors_written validate
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-10-20 19:07:51 -04:00
Kent Overstreet
4f9293b045 cmd_fsck: Create loopback device for kernel fsck when necessary
fstests generic/648 now passes

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-10-12 17:20:56 -04:00
Alyssa Ross
6153c37e38 Avoid static linking conflicts with libblkid
When static linking, it's not possible to have two functions with the
same name in different libraries:

	= note: /nix/store/s2cjhni3s6shh0n35ay1hpj8d85k44qk-x86_64-unknown-linux-musl-binutils-2.43.1/bin/x86_64-unknown-linux-musl-ld: /nix/store/zwid05lzfy46k32xljb2alh0gq7ys58a-util-linux-minimal-static-x86_64-unknown-linux-musl-2.39.4-lib/lib/libblkid.a(libcommon_la-crc32c.o): in function `crc32c':
	        (.text+0x0): multiple definition of `crc32c'; ./libbcachefs.a(tools-util.o):/build/source/c_src/tools-util.c:484: first defined here
	        collect2: error: ld returned 1 exit status

Work around this by avoiding a known name collision with a function in
libblkid.

Closes: https://github.com/koverstreet/bcachefs-tools/issues/311
Signed-off-by: Alyssa Ross <hi@alyssa.is>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-10-12 17:20:56 -04:00
Kent Overstreet
1dba682527 cmd_kill_btree_node: Can now kill multiple nodes simultaneously
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-10-12 17:20:56 -04:00
Kent Overstreet
571ca8b8ce cmd_list_journal: Add filtering on log msg
This allows us to filter out e.g. all btree_node_write_work transacitons

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-10-09 21:58:15 -04:00
Thomas Bertschinger
3829e49167 fuse: graceful shutdown when startup fails
When FUSE startup encounters an error after opening the filesystem--for
example because of a bad mountpoint--it exited uncleanly, which is a
bit unfriendly.

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-10-04 22:48:21 -04:00
Kent Overstreet
9f20109509 Update bcachefs sources to 438696e03da7 bcachefs: rename version -> bversion for big endian builds 2024-09-29 22:18:18 -04:00
Mae Kasza
45468a9a6f
Fix set-passphrase on --no_passphrase FS
This also fixes a bug where the set-passphrase
command failed to derive the key for disks initially
formatted with --encrypted and --no_passphrase, due to
bch_sb_crypt_init not configuring the KDF params if
the passphrase wasn't specified during formatting.

Signed-off-by: Mae Kasza <git@badat.dev>
Tested-by: Jérôme Poulin <jeromepoulin@gmail.com>
2024-09-07 21:46:32 -04:00
Kent Overstreet
1e058db4b6 cmd_dump: Open in noexcl mode
no need to make it harder to dump than it needs to be

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-08-31 21:34:15 -04:00
Reed Riley
6c32c8d9c9 change setattr to set-file-option in docs/usage 2024-08-22 16:23:51 -05:00
Antti Savolainen
ef47274485 Change lingering set-option texts to set-fs-option 2024-08-21 15:24:00 +03:00
Kent Overstreet
31039815a7 posix_to_bcachefs: fix missing copy_xattrs() error checking
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-08-20 19:47:56 -04:00
Kent Overstreet
8b93af8747 kill_btree_node fixup
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-08-10 17:30:27 -04:00
Kent Overstreet
6687752a1d Update bcachefs sources to 070f7d6a382a bcachefs: bch2_sb_nr_devices()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-08-10 11:52:25 -04:00
Kent Overstreet
3f885423df fsck: modprobe before doing version check
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-08-09 04:01:23 -04:00
Kent Overstreet
8d75a97e1a cmd_fs_usage: fix null ptr deref
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-08-09 03:44:27 -04:00
Kent Overstreet
da1d5571f5 fixup! cmd_set_option: Can now set device options
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-08-06 20:34:20 -04:00
Kent Overstreet
52b9e813bd Rename option commands
set-option	-> set-fs-option
setattr 	-> set-file-option

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-07-20 16:45:08 -04:00
Kent Overstreet
8594891772 cmd_set_option: Can now set device options
This allows data_allowed (and others) to be set on an offline
filesystem.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-07-15 20:17:37 -04:00
Kent Overstreet
32fbdff2a9 Update bcachefs sources to 4a7a003763f5 bcachefs: Opt_durability can now be set via bch2_opt_set_sb() 2024-07-15 20:17:37 -04:00
Kent Overstreet
755788e2d6 Be explicit about which fsck implementation we're running
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-29 11:55:03 -04:00
Kent Overstreet
fc06a0ea5e Update bcachefs sources to c56e1ec97dfd bcachefs: Fix bch2_sb_downgrade_update()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-17 12:38:43 -04:00
Ariel Miculas
ab83e348fb Preserve directory {a,m,c} times by calling copy_times() after the recursion
Otherwise the directory {a,m,c} times will be modified by the recursive
copy of the directory tree.

Signed-off-by: Ariel Miculas <ariel.miculas@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-16 14:09:18 -04:00
Ariel Miculas
3a4a096cd2 Fix incomplete file copy due to copy_data misuse
The copy_data function takes a start and an end parameter as the range
of bytes to copy, but it was called with a start and a length parameter.
This resulted in incomplete file copies. Fix it by passing the end of
the range instead of the length.

Signed-off-by: Ariel Miculas <ariel.miculas@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-16 14:09:13 -04:00
Ariel Miculas
ed675b8d64 Fix performance regression of update_inode
This kernel commit: 65bd442397274347e721a89c2c4882a392bae982 removes
BTREE_ITER_cached from bch2_btree_insert_trans, which causes the
update_inode function to take a long time (~20s). Add this flag back in
the update_inode function.

Signed-off-by: Ariel Miculas <ariel.miculas@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-16 14:08:59 -04:00
Ariel Miculas
d750b2b98b bcachefs: allow initializing a bcachefs filesystem from a source directory
Add a new source command line argument which specifies the directory
tree that will be copied onto the newly formatted bcachefs filesystem.

This commit also fixes an issue in copy_link where uninitialized data is
copied into the symlink because of a round_up of the buffer size.

Signed-off-by: Ariel Miculas <ariel.miculas@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-16 14:08:52 -04:00
Kent Overstreet
e1fa076a86 Fix target option parsing for format, migrate
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-07 16:12:55 -04:00
Kent Overstreet
0916d38664 cmd_fs_usage: Use now BCH_IOCTL_QUERY_ACCOUNTING
We can now report on compression type/ratio, btree usage, and pending
rebalance work.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-03 20:08:06 -04:00
Kent Overstreet
da5435b0cc cmd_fs_usage: split out devs_usage_to_text()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-03 20:08:06 -04:00
Kent Overstreet
7d79fba1af Update bcachefs sources to f81dc88f0c80 bcachefs: bch2_btree_insert() - add btree iter flags
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-03 20:08:06 -04:00
Kent Overstreet
587f7f5a47 cmd_list_journal: open with noexcl, so we can work on mounted filesystems
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-02 21:06:47 -04:00
Thomas Mühlbacher
25bce91b4b refactor: rename function again
`bch2_sb_is_encrypted_and_locked()` simply does not check if the fs is
locked. The name is misleading.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-05-30 22:26:06 +02:00
koverstreet
de6e8ac230
Merge pull request #280 from JohnRTitor/cleanup
treewide: fix typos in docs and comments
2024-05-29 23:56:27 -04:00
Kent Overstreet
3016a7dbbd cmd_fsck: Fix check for running online fsck
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-05-29 18:01:59 -04:00
Andrea Gelmini
18f9526c45
treewide, docs: fix typos
Signed-off-by: Andrea Gelmini <andrea.gelmini@gelma.net>
[remove changes to libbcachefs/, linux/, include/, and raid/]
Co-authored-by: Masum Reza <masumrezarock100@gmail.com>
Signed-off-by: Masum Reza <masumrezarock100@gmail.com>
2024-05-29 09:22:09 +05:30
Kent Overstreet
80167bf0a8 cmd_dump: Dump full btree nodes
We're still having issues with corrupted dumps when we try to dump only
the live part of btree nodes.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-05-26 12:51:26 -04:00
Kent Overstreet
1e35104d31 Revert dump blocksize change
It appears qemu-img chokes on qcow2 images with too many l1 entries

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-05-25 12:51:31 -04:00
Thomas Bertschinger
7bf821f3f9 check errno to determine fsck ioctl error
The error code is in errno, not the return value.

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-05-25 00:02:27 -04:00