On Sat, Mar 15, 2025 at 08:01:37PM -0700, Eric Biggers wrote: > From: Eric Biggers <[email protected]> > > These functions are never called, so remove them.
I've had requests for enabling encryption on an existing filesystem, and I think that is something we should allow - I wrote the code and didn't hook it up at the time because I wanted to think about safety issues more. So I'd rather just #if 0 it out, if the issue was that it was going to need to be updated for your other cleanups. bch2_disable_encryption seems to be duplicating code that also exists in userspace, I don't see any reason for the userspace version to exist, this one looks cleaner, so let's also not delete that. I'm applying this instead: >From a5331b44ab612f1609ee980389a8ea677e194d46 Mon Sep 17 00:00:00 2001 From: Kent Overstreet <[email protected]> Date: Sun, 16 Mar 2025 13:39:14 -0400 Subject: [PATCH] bcachefs: #if 0 out (enable|disable)_encryption() These weren't hooked up, but they probably should be - add some comments for context. Signed-off-by: Kent Overstreet <[email protected]> diff --git a/fs/bcachefs/checksum.c b/fs/bcachefs/checksum.c index 23a383577d4c..15de9d794337 100644 --- a/fs/bcachefs/checksum.c +++ b/fs/bcachefs/checksum.c @@ -693,6 +693,14 @@ static int bch2_alloc_ciphers(struct bch_fs *c) return 0; } +#if 0 + +/* + * This seems to be duplicating code in cmd_remove_passphrase() in + * bcachefs-tools, but we might want to switch userspace to use this - and + * perhaps add an ioctl for calling this at runtime, so we can take the + * passphrase off of a mounted filesystem (which has come up). + */ int bch2_disable_encryption(struct bch_fs *c) { struct bch_sb_field_crypt *crypt; @@ -725,6 +733,10 @@ int bch2_disable_encryption(struct bch_fs *c) return ret; } +/* + * For enabling encryption on an existing filesystem: not hooked up yet, but it + * should be + */ int bch2_enable_encryption(struct bch_fs *c, bool keyed) { struct bch_encrypted_key key; @@ -781,6 +793,7 @@ int bch2_enable_encryption(struct bch_fs *c, bool keyed) memzero_explicit(&key, sizeof(key)); return ret; } +#endif void bch2_fs_encryption_exit(struct bch_fs *c) { diff --git a/fs/bcachefs/checksum.h b/fs/bcachefs/checksum.h index 43b9d71f2f2b..4ac251c8fcd8 100644 --- a/fs/bcachefs/checksum.h +++ b/fs/bcachefs/checksum.h @@ -103,8 +103,10 @@ extern const struct bch_sb_field_ops bch_sb_field_ops_crypt; int bch2_decrypt_sb_key(struct bch_fs *, struct bch_sb_field_crypt *, struct bch_key *); +#if 0 int bch2_disable_encryption(struct bch_fs *); int bch2_enable_encryption(struct bch_fs *, bool); +#endif void bch2_fs_encryption_exit(struct bch_fs *); int bch2_fs_encryption_init(struct bch_fs *);
