* [PATCH 1/6] fs: Update outdated comment for SB_INLINECRYPT
2026-07-18 21:46 [PATCH 0/6] More fscrypt and blk-crypto doc updates and code removals Eric Biggers
@ 2026-07-18 21:46 ` Eric Biggers
2026-07-18 21:46 ` [PATCH 2/6] f2fs: Update outdated comment in f2fs_write_begin() Eric Biggers
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Eric Biggers @ 2026-07-18 21:46 UTC (permalink / raw)
To: linux-fscrypt
Cc: linux-block, linux-fsdevel, linux-ext4, linux-f2fs-devel,
linux-doc, Eric Biggers
Update the comment for SB_INLINECRYPT to match the latest code, where
SB_INLINECRYPT now controls whether blk-crypto uses inline encryption
hardware rather than whether blk-crypto is used.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
include/linux/fs/super_types.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/fs/super_types.h b/include/linux/fs/super_types.h
index ef7941e9dc79..3bdd7f7fb9e5 100644
--- a/include/linux/fs/super_types.h
+++ b/include/linux/fs/super_types.h
@@ -300,7 +300,7 @@ struct super_block {
#define SB_NODIRATIME BIT(11) /* Do not update directory access times */
#define SB_SILENT BIT(15)
#define SB_POSIXACL BIT(16) /* Supports POSIX ACLs */
-#define SB_INLINECRYPT BIT(17) /* Use blk-crypto for encrypted files */
+#define SB_INLINECRYPT BIT(17) /* Use inline crypto hardware if available */
#define SB_KERNMOUNT BIT(22) /* this is a kern_mount call */
#define SB_I_VERSION BIT(23) /* Update inode I_version field */
#define SB_LAZYTIME BIT(25) /* Update the on-disk [acm]times lazily */
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 2/6] f2fs: Update outdated comment in f2fs_write_begin()
2026-07-18 21:46 [PATCH 0/6] More fscrypt and blk-crypto doc updates and code removals Eric Biggers
2026-07-18 21:46 ` [PATCH 1/6] fs: Update outdated comment for SB_INLINECRYPT Eric Biggers
@ 2026-07-18 21:46 ` Eric Biggers
2026-07-18 21:46 ` [PATCH 3/6] fscrypt: Remove unused function fscrypt_finalize_bounce_page() Eric Biggers
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Eric Biggers @ 2026-07-18 21:46 UTC (permalink / raw)
To: linux-fscrypt
Cc: linux-block, linux-fsdevel, linux-ext4, linux-f2fs-devel,
linux-doc, Eric Biggers
Refer to f2fs_set_bio_crypt_ctx() instead of the removed function
f2fs_encrypt_one_page().
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
fs/f2fs/data.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index 65117dd2e123..a88ed125d266 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -3956,7 +3956,7 @@ static int f2fs_write_begin(const struct kiocb *iocb,
/*
* Although the block may be stored in the COW inode, the folio
* belongs to @inode and its data was encrypted (or not) using
- * @inode's context (see f2fs_encrypt_one_page()). Read with
+ * @inode's context (see f2fs_set_bio_crypt_ctx()). Read with
* @inode so the post-read decryption decision matches the
* folio's owner; otherwise an unencrypted @inode whose COW inode
* is encrypted hits a NULL ->i_crypt_info on decryption.
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 3/6] fscrypt: Remove unused function fscrypt_finalize_bounce_page()
2026-07-18 21:46 [PATCH 0/6] More fscrypt and blk-crypto doc updates and code removals Eric Biggers
2026-07-18 21:46 ` [PATCH 1/6] fs: Update outdated comment for SB_INLINECRYPT Eric Biggers
2026-07-18 21:46 ` [PATCH 2/6] f2fs: Update outdated comment in f2fs_write_begin() Eric Biggers
@ 2026-07-18 21:46 ` Eric Biggers
2026-07-18 21:46 ` [PATCH 4/6] fscrypt: Update docs for data path Eric Biggers
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Eric Biggers @ 2026-07-18 21:46 UTC (permalink / raw)
To: linux-fscrypt
Cc: linux-block, linux-fsdevel, linux-ext4, linux-f2fs-devel,
linux-doc, Eric Biggers
fscrypt_finalize_bounce_page() is no longer called, so remove it.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
include/linux/fscrypt.h | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/include/linux/fscrypt.h b/include/linux/fscrypt.h
index 52ff014aeae6..42ffd66a2491 100644
--- a/include/linux/fscrypt.h
+++ b/include/linux/fscrypt.h
@@ -1057,15 +1057,4 @@ static inline int fscrypt_encrypt_symlink(struct inode *inode,
return 0;
}
-/* If *pagep is a bounce page, free it and set *pagep to the pagecache page */
-static inline void fscrypt_finalize_bounce_page(struct page **pagep)
-{
- struct page *page = *pagep;
-
- if (fscrypt_is_bounce_page(page)) {
- *pagep = fscrypt_pagecache_page(page);
- fscrypt_free_bounce_page(page);
- }
-}
-
#endif /* _LINUX_FSCRYPT_H */
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 4/6] fscrypt: Update docs for data path
2026-07-18 21:46 [PATCH 0/6] More fscrypt and blk-crypto doc updates and code removals Eric Biggers
` (2 preceding siblings ...)
2026-07-18 21:46 ` [PATCH 3/6] fscrypt: Remove unused function fscrypt_finalize_bounce_page() Eric Biggers
@ 2026-07-18 21:46 ` Eric Biggers
2026-07-18 21:46 ` [PATCH 5/6] blk-crypto: Remove unused function blk_crypto_config_supported() Eric Biggers
2026-07-18 21:46 ` [PATCH 6/6] blk-crypto: Update docs for blk-crypto-fallback motivation Eric Biggers
5 siblings, 0 replies; 7+ messages in thread
From: Eric Biggers @ 2026-07-18 21:46 UTC (permalink / raw)
To: linux-fscrypt
Cc: linux-block, linux-fsdevel, linux-ext4, linux-f2fs-devel,
linux-doc, Eric Biggers
Update the "Data path changes" section to accurately document and
elaborate on the current implementation of file contents en/decryption.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
Documentation/filesystems/fscrypt.rst | 56 ++++++++++++++++++---------
1 file changed, 37 insertions(+), 19 deletions(-)
diff --git a/Documentation/filesystems/fscrypt.rst b/Documentation/filesystems/fscrypt.rst
index 5f1b5b53aa16..ef0925f78fa1 100644
--- a/Documentation/filesystems/fscrypt.rst
+++ b/Documentation/filesystems/fscrypt.rst
@@ -1475,25 +1475,43 @@ keys`_ and `DIRECT_KEY policies`_.
Data path changes
-----------------
-When inline encryption is used, filesystems just need to associate
-encryption contexts with bios to specify how the block layer or the
-inline encryption hardware will encrypt/decrypt the file contents.
-
-When inline encryption isn't used, filesystems must encrypt/decrypt
-the file contents themselves, as described below:
-
-For the read path (->read_folio()) of regular files, filesystems can
-read the ciphertext into the page cache and decrypt it in-place. The
-folio lock must be held until decryption has finished, to prevent the
-folio from becoming visible to userspace prematurely.
-
-For the write path (->writepages()) of regular files, filesystems
-cannot encrypt data in-place in the page cache, since the cached
-plaintext must be preserved. Instead, filesystems must encrypt into a
-temporary buffer or "bounce page", then write out the temporary
-buffer. Some filesystems, such as UBIFS, already use temporary
-buffers regardless of encryption. Other filesystems, such as ext4 and
-F2FS, have to allocate bounce pages specially for encryption.
+The block-based filesystems that support fscrypt, such as ext4 and
+f2fs, use blk-crypto (:ref:`inline_encryption`) to implement file
+contents encryption and decryption. With blk-crypto, the filesystem
+assigns an encryption context to each I/O request it issues to the
+contents of an encrypted file. The encryption (for writes) or
+decryption (for reads) is handled by the block layer transparently to
+the filesystem, using either the CPU or inline encryption hardware.
+
+Non-block-based filesystems can't use blk-crypto, so they make the
+calls to the cryptographic algorithms at the filesystem layer instead.
+
+Regardless of the layer in which they occur (blk-crypto-fallback or the
+filesystem), for CPU-based encryption and decryption of file contents:
+
+- For reads, the ciphertext data is read from the storage backend
+ (block device, network, UBI device, etc.) into the destination
+ buffers, then decrypted in-place. The destination buffers are
+ pagecache folios for buffered reads, or application-provided buffers
+ for direct reads. In either case, the filesystem reports success
+ only after decryption has successfully completed.
+
+- For writes, the plaintext data is encrypted from the source buffers
+ (which cannot be modified) into bounce buffers. Then, the
+ ciphertext in the bounce buffers is written to the storage backend.
+
+ The source buffers are usually pagecache folios for buffered writes,
+ or application-provided buffers for direct writes. There are also
+ some cases (all files on UBIFS, and compressed files on f2fs) where
+ the filesystem already uses bounce buffers for writes for other
+ reasons; in these cases the source plaintext data is already in
+ bounce buffers. UBIFS optimizes this case by encrypting the data
+ in-place in its existing bounce buffers.
+
+When inline encryption hardware is used instead of the CPU, reads from
+the storage backend logically return plaintext data, and writes accept
+plaintext data. In that case the flow is simplified: there's no
+scheduling of decryption work, and no bounce buffers are used.
Filename hashing and encoding
-----------------------------
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 5/6] blk-crypto: Remove unused function blk_crypto_config_supported()
2026-07-18 21:46 [PATCH 0/6] More fscrypt and blk-crypto doc updates and code removals Eric Biggers
` (3 preceding siblings ...)
2026-07-18 21:46 ` [PATCH 4/6] fscrypt: Update docs for data path Eric Biggers
@ 2026-07-18 21:46 ` Eric Biggers
2026-07-18 21:46 ` [PATCH 6/6] blk-crypto: Update docs for blk-crypto-fallback motivation Eric Biggers
5 siblings, 0 replies; 7+ messages in thread
From: Eric Biggers @ 2026-07-18 21:46 UTC (permalink / raw)
To: linux-fscrypt
Cc: linux-block, linux-fsdevel, linux-ext4, linux-f2fs-devel,
linux-doc, Eric Biggers
blk_crypto_config_supported() is no longer called, so remove it.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
Documentation/block/inline-encryption.rst | 29 ++++++++---------------
block/blk-crypto.c | 14 -----------
include/linux/blk-crypto.h | 2 --
3 files changed, 10 insertions(+), 35 deletions(-)
diff --git a/Documentation/block/inline-encryption.rst b/Documentation/block/inline-encryption.rst
index cae23949a626..0052c7011b48 100644
--- a/Documentation/block/inline-encryption.rst
+++ b/Documentation/block/inline-encryption.rst
@@ -185,20 +185,12 @@ blk-crypto-fallback is optional and is controlled by the
API presented to users of the block layer
=========================================
-``blk_crypto_config_supported()`` allows users to check ahead of time whether
-inline encryption with particular crypto settings will work on a particular
-block_device -- either via hardware or via blk-crypto-fallback. This function
-takes in a ``struct blk_crypto_config`` which is like blk_crypto_key, but omits
-the actual bytes of the key and instead just contains the algorithm, data unit
-size, etc. This function can be useful if blk-crypto-fallback is disabled.
-
``blk_crypto_init_key()`` allows users to initialize a blk_crypto_key.
Users must call ``blk_crypto_start_using_key()`` before actually starting to use
-a blk_crypto_key on a block_device (even if ``blk_crypto_config_supported()``
-was called earlier). This is needed to initialize blk-crypto-fallback if it
-will be needed. This must not be called from the data path, as this may have to
-allocate resources, which may deadlock in that case.
+a blk_crypto_key on a block_device. This is needed to initialize
+blk-crypto-fallback if it will be needed. This must not be called from the data
+path, as this may have to allocate resources, which may deadlock in that case.
Next, to attach an encryption context to a bio, users should call
``bio_crypt_set_ctx()``. This function allocates a bio_crypt_ctx and attaches
@@ -220,16 +212,15 @@ any kernel data structures it may be linked into.
In summary, for users of the block layer, the lifecycle of a blk_crypto_key is
as follows:
-1. ``blk_crypto_config_supported()`` (optional)
-2. ``blk_crypto_init_key()``
-3. ``blk_crypto_start_using_key()``
-4. ``bio_crypt_set_ctx()`` (potentially many times)
-5. ``blk_crypto_evict_key()`` (after all I/O has completed)
-6. Zeroize the blk_crypto_key (this has no dedicated function)
+1. ``blk_crypto_init_key()``
+2. ``blk_crypto_start_using_key()``
+3. ``bio_crypt_set_ctx()`` (potentially many times)
+4. ``blk_crypto_evict_key()`` (after all I/O has completed)
+5. Zeroize the blk_crypto_key (this has no dedicated function)
If a blk_crypto_key is being used on multiple block_devices, then
-``blk_crypto_config_supported()`` (if used), ``blk_crypto_start_using_key()``,
-and ``blk_crypto_evict_key()`` must be called on each block_device.
+``blk_crypto_start_using_key()`` and ``blk_crypto_evict_key()`` must be called
+on each block_device.
API presented to device drivers
===============================
diff --git a/block/blk-crypto.c b/block/blk-crypto.c
index 0fe6ef0eea1d..bc3a9f59574b 100644
--- a/block/blk-crypto.c
+++ b/block/blk-crypto.c
@@ -386,20 +386,6 @@ bool blk_crypto_config_supported_natively(struct block_device *bdev,
return true;
}
-/*
- * Check if bios with @cfg can be en/decrypted by blk-crypto (i.e. either the
- * block_device it's submitted to supports inline crypto, or the
- * blk-crypto-fallback is enabled and supports the cfg).
- */
-bool blk_crypto_config_supported(struct block_device *bdev,
- const struct blk_crypto_config *cfg)
-{
- if (IS_ENABLED(CONFIG_BLK_INLINE_ENCRYPTION_FALLBACK) &&
- cfg->key_type == BLK_CRYPTO_KEY_TYPE_RAW)
- return true;
- return blk_crypto_config_supported_natively(bdev, cfg);
-}
-
/**
* blk_crypto_start_using_key() - Start using a blk_crypto_key on a device
* @bdev: block device to operate on
diff --git a/include/linux/blk-crypto.h b/include/linux/blk-crypto.h
index 5f40821f99cd..938ff536838c 100644
--- a/include/linux/blk-crypto.h
+++ b/include/linux/blk-crypto.h
@@ -171,8 +171,6 @@ void blk_crypto_evict_key(struct block_device *bdev,
bool blk_crypto_config_supported_natively(struct block_device *bdev,
const struct blk_crypto_config *cfg);
-bool blk_crypto_config_supported(struct block_device *bdev,
- const struct blk_crypto_config *cfg);
int blk_crypto_derive_sw_secret(struct block_device *bdev,
const u8 *eph_key, size_t eph_key_size,
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH 6/6] blk-crypto: Update docs for blk-crypto-fallback motivation
2026-07-18 21:46 [PATCH 0/6] More fscrypt and blk-crypto doc updates and code removals Eric Biggers
` (4 preceding siblings ...)
2026-07-18 21:46 ` [PATCH 5/6] blk-crypto: Remove unused function blk_crypto_config_supported() Eric Biggers
@ 2026-07-18 21:46 ` Eric Biggers
5 siblings, 0 replies; 7+ messages in thread
From: Eric Biggers @ 2026-07-18 21:46 UTC (permalink / raw)
To: linux-fscrypt
Cc: linux-block, linux-fsdevel, linux-ext4, linux-f2fs-devel,
linux-doc, Eric Biggers
The "Objective" section of inline-encryption.rst suggests that
blk-crypto-fallback is just for testing. That's no longer accurate, so
update it accordingly. Also fix a typo later in the document.
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
---
Documentation/block/inline-encryption.rst | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/Documentation/block/inline-encryption.rst b/Documentation/block/inline-encryption.rst
index 0052c7011b48..0df964507f76 100644
--- a/Documentation/block/inline-encryption.rst
+++ b/Documentation/block/inline-encryption.rst
@@ -37,12 +37,12 @@ initialization vector for each sector, and can be tested for correctness.
Objective
=========
-We want to support inline encryption in the kernel. To make testing easier, we
-also want support for falling back to the kernel crypto API when actual inline
-encryption hardware is absent. We also want inline encryption to work with
-layered devices like device-mapper and loopback (i.e. we want to be able to use
-the inline encryption hardware of the underlying devices if present, or else
-fall back to crypto API en/decryption).
+We want to support inline encryption hardware in the kernel. The API for using
+such hardware should also support a fallback to the CPU, so that users only need
+to use a single API and more of the code can be tested without actual hardware.
+We also want inline encryption to work with layered devices like device-mapper
+and loopback (i.e. we want to be able to use the inline encryption hardware of
+the underlying devices if present, or else fall back to the CPU).
Constraints and notes
=====================
@@ -295,7 +295,7 @@ hardware implementations might not implement both features together correctly,
and disallow the combination for now. Whenever a device supports integrity, the
kernel will pretend that the device does not support hardware inline encryption
(by setting the blk_crypto_profile in the request_queue of the device to NULL).
-When the crypto API fallback is enabled, this means that all bios with and
+When the crypto API fallback is enabled, this means that all bios with an
encryption context will use the fallback, and IO will complete as usual. When
the fallback is disabled, a bio with an encryption context will be failed.
--
2.55.0
^ permalink raw reply related [flat|nested] 7+ messages in thread