@@ -171,7 +171,8 @@ int fscrypt_prepare_inline_crypt_key(struct fscrypt_prepared_key *prep_key,
err = blk_crypto_init_key(blk_key, raw_key, crypto_mode,
fscrypt_get_dun_bytes(ci),
- 1U << ci->ci_data_unit_bits, NULL);
+ 1U << ci->ci_data_unit_bits,
+ sb->s_cop->process_bio);
if (err) {
fscrypt_err(inode, "error %d initializing blk-crypto key", err);
goto fail;
@@ -16,6 +16,7 @@
#include <linux/fs.h>
#include <linux/mm.h>
#include <linux/slab.h>
+#include <linux/blk-crypto.h>
#include <uapi/linux/fscrypt.h>
/*
@@ -199,6 +200,19 @@ struct fscrypt_operations {
*/
struct block_device **(*get_devices)(struct super_block *sb,
unsigned int *num_devs);
+
+ /*
+ * A callback if the file system requires the ability to process the
+ * encrypted bio, used only with inline encryption.
+ *
+ * @orig_bio: the original bio submitted.
+ * @enc_bio: the encrypted bio.
+ *
+ * For writes the enc_bio will be different from the orig_bio, for reads
+ * they will be the same. For reads we get the bio before it is
+ * decrypted, for writes we get the bio before it is submitted.
+ */
+ blk_crypto_process_bio_t process_bio;
};
static inline struct fscrypt_inode_info *
This will allow file systems to set a process_bio hook for inline encryption. This will be utilized by btrfs in order to make sure the checksumming work is done on the encrypted bio's. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/crypto/inline_crypt.c | 3 ++- include/linux/fscrypt.h | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-)