Commit Graph

1545 Commits

Author SHA1 Message Date
Kent Overstreet
0f9b409aee add i686-linux to nix flake
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-07-12 14:14:55 -04:00
Tavian Barnes
53d7722563 raid/cpu: Use memcpy() instead of type punning
The vendor may not be suitably aligned for uint32_t *.

Signed-off-by: Tavian Barnes <tavianator@tavianator.com>
2024-07-12 14:02:14 -04:00
Kent Overstreet
8b06995115 Update bcachefs sources to 2be6fc9b111c bcachefs: bch2_gc_btree() should not use btree_root_lock
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-07-05 09:16:45 -04:00
koverstreet
d061c7ea11
Merge pull request #309 from tmuehlbacher/improve-logging-exiting
Improve logging and exiting
2024-06-29 14:16:14 -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
34b5654d9e Update bcachefs sources to 9404a01d3dc5 bcachefs: Make read_only a mount option again, but hidden
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-28 18:26:04 -04:00
Thomas Mühlbacher
5cce07e986 feat: use ExitCode over std::process:exit()
Should provide us with better outputs on process failure, also makes
unwinding better and is generally recommended over `exit()`.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-29 00:11:07 +02:00
Thomas Mühlbacher
176d76bceb feat: add --quiet cli argument
To silence log outputs on the CLI.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-28 21:29:47 +02:00
Thomas Mühlbacher
df09682869 feat: use env_logger
Instead of the custom logger impl, which limits the features we can
easily provide for users.

This introduces the `BCACHEFS_LOG` environment variable for setting the
log verbosity. Setting `BCACHEFS_LOG=trace`, e.g. in a test environment,
will yield all log messages.

Also I think it's reasonable to print INFO level logs by default.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-28 21:29:20 +02:00
koverstreet
b0eb3c2930
Merge pull request #305 from Artturin/use-ar-var
Use the AR variable in Makefile
2024-06-28 11:21:19 -04:00
Thomas Mühlbacher
7a17d429d5 feat(key): make UnlockPolicy::Fail more useful
We already can check if an fs is encrypted with `bcachefs unlock -c`.
With this option we can now instead check if we have a key but not
actually mount by not specifying a mount point. e.g.

```sh
if bcachefs mount -k fail "$blkdev"`; then
    echo "device is unlocked!"
fi
```

Not sure what the original intent for this was. For scenarios where
encryption is simply not supported on principle?

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-26 19:14:45 +02:00
Thomas Mühlbacher
ee5f3719d3 refactor(key): split up unlocking functions
This is more similar to the existing C code, which is already in nice
small chunks.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-26 19:14:45 +02:00
Thomas Mühlbacher
795585e289 refactor: simplify branches for parsing dev
Less repetition and no nested if/else.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-26 19:14:45 +02:00
Thomas Mühlbacher
9bd3ada1d1 feat(mount): make unlock policy optional/explict
This changes the semantics of some arguments related to unlocking and
slightly changes the unlocking logic. Also update help formatting/text.

Instead of defaulting to `UnlockPolicy::Ask`, the argument becomes
optional. That means if it is specified, the user really wants that
specific policy. Similar to how `passphrase_file` also works.

This also extends `UnlockPolicy` to override `isatty` detection.

Fixes: #292
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-26 19:14:45 +02:00
Thomas Mühlbacher
a411e7237f refactor(mount): rename opt => cli
The term option is already used for mount options and the `Option` type.
In other modules it's just called `cli`, so let's do that here as well.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-26 19:14:45 +02:00
Thomas Mühlbacher
cf180e8f34 refactor: rm function param only used for log msg
We lose that bit of info but it's weird to require a parameter simply
because we want to use it for a log message.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-26 19:14:45 +02:00
Artturin
91e67ab2bd Use the AR variable in Makefile
For cross-compiling
2024-06-24 21:00:08 +03:00
David Disseldorp
411df4e53f key: use c_long type for keyctl_search() helper fn
The keyctl_search() C function returns a long, which is already
reflected in the KeyHandle._id type. The search_keyring() helper
function currently returns a Result<i64>, which breaks 32-bit builds for
e.g. armv7l:
  error[E0308]: mismatched types
     --> src/key.rs:121:16
      |
  121 |             Ok(key_id)
      |             -- ^^^^^^ expected `i64`, found `i32`
      |             |
      |             arguments to this enum variant are incorrect
...
  error[E0308]: mismatched types
     --> src/key.rs:135:24
      |
  135 |                 _id:   id,
      |                        ^^ expected `i32`, found `i64`

Fix this by changing search_keyring() to return a Result<c_long>.

Fixes: f72ded6a ("fix(key): search for key in all relevant keyrings")
Signed-off-by: David Disseldorp <ddiss@suse.de>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-20 08:52:12 -04:00
Kent Overstreet
277ba6d4ac v1.9.1
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-19 14:48:31 -04:00
Kent Overstreet
02aa11829a Merge commit '41df701a089fbf19fe16d65fbb6df46854b1f3df' of https://github.com/tmuehlbacher/bcachefs-tools 2024-06-19 12:09:32 -04:00
Kent Overstreet
adb63be479 update Cargo.lock version
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-19 09:23:49 -04:00
Kent Overstreet
dd275b1c5f Update version to 1.9.0
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-19 09:05:50 -04:00
Thomas Mühlbacher
41df701a08 fix(logger): log to stderr
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-18 20:56:25 +02:00
Thomas Mühlbacher
f72ded6a4f fix(key): search for key in all relevant keyrings
Previously, using `bcachefs unlock -k session` would still cause mount
to ask for a passphrase.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-18 20:56:17 +02:00
Thomas Mühlbacher
e4271d7a3e fix(key): remove any newlines from passphrase
To match the behavior of the C code and because there may be newlines
under some conditions.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-18 20:56:15 +02:00
Thomas Mühlbacher
87ab1fd7ed chore(editorconfig): extend for sh scripts
To match with what's already in the repo.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-18 20:56:06 +02:00
koverstreet
c909480560
Merge pull request #302 from koverstreet/update_flake_lock_action
flake.lock: Update
2024-06-17 14:21:10 -04:00
github-actions[bot]
33ce7dd90c flake.lock: Update
Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/17d9e9dedd58dde2c562a4296934c6d6a0844534?narHash=sha256-hGLeRxSEeFz9WvmQ4s4AuMJ5InLSZvoczDdXkWSFi1A%3D' (2024-06-09)
  → 'github:ipetkov/crane/0095fd8ea00ae0a9e6014f39c375e40c2fbd3386?narHash=sha256-UKrfy/46YF2TRnxTtKCYzqf2f5ZPRRWwKCCJb7O5X8U%3D' (2024-06-15)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/051f920625ab5aabe37c920346e3e69d7d34400e?narHash=sha256-4q0s6m0GUcN7q%2BY2DqD27iLvbcd1G50T2lv08kKxkSI%3D' (2024-06-07)
  → 'github:nixos/nixpkgs/e9ee548d90ff586a6471b4ae80ae9cfcbceb3420?narHash=sha256-4Zu0RYRcAY/VWuu6awwq4opuiD//ahpc2aFHg2CWqFY%3D' (2024-06-13)
• Updated input 'treefmt-nix':
    'github:numtide/treefmt-nix/4fc1c45a5f50169f9f29f6a98a438fb910b834ed?narHash=sha256-npYqVg%2BWk4oxnWrnVG7416fpfrlRhp/lQ6wQ4DHI8YE%3D' (2024-06-08)
  → 'github:numtide/treefmt-nix/68eb1dc333ce82d0ab0c0357363ea17c31ea1f81?narHash=sha256-ULzoKzEaBOiLRtjeY3YoGFJMwWSKRYOic6VNw2UyTls%3D' (2024-06-16)
2024-06-17 18:20:02 +00:00
koverstreet
a87faa2e30
Merge pull request #301 from tmuehlbacher/fix-nix-install
fix(nix): install paths from pkg-config properly
2024-06-17 14:19:23 -04:00
Kent Overstreet
d915c62f17 Update bcachefs sources to 792ca5ba3c9a bcachefs: kill key cache arg to bch2_assert_pos_locked() 2024-06-17 14:08:42 -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
Thomas Mühlbacher
b46d3a2710 fix(nix): install paths from pkg-config properly
Because we were using `DESTDIR` instead of `PREFIX` for some reason, no
one noticed that this didn't work.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-17 18:31:40 +02: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
f3ab07db73 fix missing include
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-16 14:08:47 -04:00
koverstreet
8bc27da705
Merge pull request #297 from koverstreet/update_flake_lock_action
flake.lock: Update
2024-06-10 18:52:25 -04:00
github-actions[bot]
a2a0d53945 flake.lock: Update
Flake lock file updates:

• Updated input 'crane':
    'github:ipetkov/crane/480dff0be03dac0e51a8dfc26e882b0d123a450e?narHash=sha256-dIubLa56W9sNNz0e8jGxrX3CAkPXsq7snuFA/Ie6dn8%3D' (2024-05-29)
  → 'github:ipetkov/crane/17d9e9dedd58dde2c562a4296934c6d6a0844534?narHash=sha256-hGLeRxSEeFz9WvmQ4s4AuMJ5InLSZvoczDdXkWSFi1A%3D' (2024-06-09)
• Updated input 'fenix':
    'github:nix-community/fenix/14c3b99d4b7cb91343807eac77f005ed9218f742?narHash=sha256-BKFOT/eg0mCf99oTKa63yW%2Bd5Y3K6c5Gb%2BNetxacaHg%3D' (2024-05-31)
  → 'github:nix-community/fenix/ab655c627777ab5f9964652fe23bbb1dfbd687a8?narHash=sha256-ixopuTeTouxqTxfMuzs6IaRttbT8JqRW5C9Q/57WxQw%3D' (2024-06-08)
• Updated input 'fenix/rust-analyzer-src':
    'github:rust-lang/rust-analyzer/b32f181f477576bb203879f7539608f3327b6178?narHash=sha256-mUZtVS2S%2BleFcMpBgbqkMnZm4II1qBM21pW8UnivVSo%3D' (2024-05-27)
  → 'github:rust-lang/rust-analyzer/48bbdd6a74f3176987d5c809894ac33957000d19?narHash=sha256-%2BlRAmz92CNUxorqWusgJbL9VE1eKCnQQojglRemzwkw%3D' (2024-06-05)
• Updated input 'flake-parts':
    'github:hercules-ci/flake-parts/8dc45382d5206bd292f9c2768b8058a8fd8311d9?narHash=sha256-/GJvTdTpuDjNn84j82cU6bXztE0MSkdnTWClUCRub78%3D' (2024-05-16)
  → 'github:hercules-ci/flake-parts/2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8?narHash=sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw%3D' (2024-06-01)
• Updated input 'flake-parts/nixpkgs-lib':
    '50eb7ecf4c.tar.gz?narHash=sha256-QBx10%2Bk6JWz6u7VsohfSw8g8hjdBZEf8CFzXH1/1Z94%3D' (2024-05-02)
  → 'eb9ceca17d.tar.gz?narHash=sha256-lIbdfCsf8LMFloheeE6N31%2BBMIeixqyQWbSr2vk79EQ%3D' (2024-06-01)
• Updated input 'nixpkgs':
    'github:nixos/nixpkgs/ad57eef4ef0659193044870c731987a6df5cf56b?narHash=sha256-SzDKxseEcHR5KzPXLwsemyTR/kaM9whxeiJohbL04rs%3D' (2024-05-29)
  → 'github:nixos/nixpkgs/051f920625ab5aabe37c920346e3e69d7d34400e?narHash=sha256-4q0s6m0GUcN7q%2BY2DqD27iLvbcd1G50T2lv08kKxkSI%3D' (2024-06-07)
• Updated input 'treefmt-nix':
    'github:numtide/treefmt-nix/52b66cade760e93276146eb057122b8011ab9057?narHash=sha256-V68CsekhPCF6Oz84t2FHY5jin4smKrmsS208Xw057zs%3D' (2024-05-30)
  → 'github:numtide/treefmt-nix/4fc1c45a5f50169f9f29f6a98a438fb910b834ed?narHash=sha256-npYqVg%2BWk4oxnWrnVG7416fpfrlRhp/lQ6wQ4DHI8YE%3D' (2024-06-08)
2024-06-10 22:31:10 +00:00
koverstreet
786e507c2e
Merge pull request #295 from tmuehlbacher/flake-stuff
Make nix package builds have a unique version; dev shell addition
2024-06-10 18:30:30 -04:00
koverstreet
e743caf71c
Merge pull request #294 from tmuehlbacher/subvol-fix
fix(subvol): canonicalize requires path to exist
2024-06-10 18:30:00 -04:00
Thomas Mühlbacher
c20f323fdb fix(subvol): canonicalize requires path to exist
Which is probably not the case when you want to create a subvolume in
that path.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-10 23:07:27 +02:00
Thomas Mühlbacher
2a15fc0445 build(nix): use actual commit rev in version
This way we get an actually unique version for every version that can be
traced back to the source.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-10 00:04:13 +02:00
Thomas Mühlbacher
990437ad13 build(nix): add bear to dev shell
A useful addition to make sure is available, since we also make clangd
available through clang-tools. bear can generate the
`compile_commands.json` for clangd. For example with `make clean && bear
-- make -j$(nproc)`.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-10 00:04:13 +02:00
koverstreet
c2354f0326
Merge pull request #293 from tmuehlbacher/fix-subvolume-commands-with-relative-paths
fix(subvol): make cmds work with relative paths
2024-06-09 17:43:41 -04:00
Thomas Mühlbacher
b42b5b4065 fix(subvol): make cmds work with relative paths
`Path::parent()` returns `Some("")` for relative paths with a single
component. The simplest fix is to just canonicalize the paths first.

Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-09 22:13:11 +02: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
0d570e822b Update bcachefs sources to 4f69e2d39ad3 bcachefs: bch2_btree_insert() - add btree iter flags 2024-06-05 10:53:01 -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