mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 12:52:29 -04:00
fscrypt: Remove unused functions and workqueue
Remove functions that are no longer used: - fscrypt_decrypt_bio() - fscrypt_decrypt_pagecache_blocks() - fscrypt_inode_uses_fs_layer_crypto() - fscrypt_inode_uses_inline_crypto() - fscrypt_enqueue_decrypt_work() This makes the decryption workqueue unused, so remove it too. Reviewed-by: Christoph Hellwig <hch@lst.de> Link: https://patch.msgid.link/20260713023708.9245-16-ebiggers@kernel.org Signed-off-by: Eric Biggers <ebiggers@kernel.org>
This commit is contained in:
@@ -15,38 +15,6 @@
|
||||
|
||||
#include "fscrypt_private.h"
|
||||
|
||||
/**
|
||||
* fscrypt_decrypt_bio() - decrypt the contents of a bio
|
||||
* @bio: the bio to decrypt
|
||||
*
|
||||
* Decrypt the contents of a "read" bio following successful completion of the
|
||||
* underlying disk read. The bio must be reading a whole number of blocks of an
|
||||
* encrypted file directly into the page cache. If the bio is reading the
|
||||
* ciphertext into bounce pages instead of the page cache (for example, because
|
||||
* the file is also compressed, so decompression is required after decryption),
|
||||
* then this function isn't applicable. This function may sleep, so it must be
|
||||
* called from a workqueue rather than from the bio's bi_end_io callback.
|
||||
*
|
||||
* Return: %true on success; %false on failure. On failure, bio->bi_status is
|
||||
* also set to an error status.
|
||||
*/
|
||||
bool fscrypt_decrypt_bio(struct bio *bio)
|
||||
{
|
||||
struct folio_iter fi;
|
||||
|
||||
bio_for_each_folio_all(fi, bio) {
|
||||
int err = fscrypt_decrypt_pagecache_blocks(fi.folio, fi.length,
|
||||
fi.offset);
|
||||
|
||||
if (err) {
|
||||
bio->bi_status = errno_to_blk_status(err);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
EXPORT_SYMBOL(fscrypt_decrypt_bio);
|
||||
|
||||
struct fscrypt_zero_done {
|
||||
atomic_t pending;
|
||||
blk_status_t status;
|
||||
|
||||
@@ -38,17 +38,10 @@ MODULE_PARM_DESC(num_prealloc_crypto_pages,
|
||||
|
||||
static mempool_t *fscrypt_bounce_page_pool = NULL;
|
||||
|
||||
static struct workqueue_struct *fscrypt_read_workqueue;
|
||||
static DEFINE_MUTEX(fscrypt_init_mutex);
|
||||
|
||||
struct kmem_cache *fscrypt_inode_info_cachep;
|
||||
|
||||
void fscrypt_enqueue_decrypt_work(struct work_struct *work)
|
||||
{
|
||||
queue_work(fscrypt_read_workqueue, work);
|
||||
}
|
||||
EXPORT_SYMBOL(fscrypt_enqueue_decrypt_work);
|
||||
|
||||
static struct page *fscrypt_alloc_bounce_page(gfp_t gfp_flags)
|
||||
{
|
||||
if (WARN_ON_ONCE(!fscrypt_bounce_page_pool)) {
|
||||
@@ -238,50 +231,6 @@ int fscrypt_encrypt_block_inplace(const struct inode *inode, struct page *page,
|
||||
}
|
||||
EXPORT_SYMBOL(fscrypt_encrypt_block_inplace);
|
||||
|
||||
/**
|
||||
* fscrypt_decrypt_pagecache_blocks() - Decrypt data from a pagecache folio
|
||||
* @folio: the pagecache folio containing the data to decrypt
|
||||
* @len: size of the data to decrypt, in bytes
|
||||
* @offs: offset within @folio of the data to decrypt, in bytes
|
||||
*
|
||||
* Decrypt data that has just been read from an encrypted file. The data must
|
||||
* be located in a pagecache folio that is still locked and not yet uptodate.
|
||||
* The length and offset of the data must be aligned to the file's crypto data
|
||||
* unit size. Alignment to the filesystem block size fulfills this requirement,
|
||||
* as the filesystem block size is always a multiple of the data unit size.
|
||||
*
|
||||
* Return: 0 on success; -errno on failure
|
||||
*/
|
||||
int fscrypt_decrypt_pagecache_blocks(struct folio *folio, size_t len,
|
||||
size_t offs)
|
||||
{
|
||||
const struct inode *inode = folio->mapping->host;
|
||||
const struct fscrypt_inode_info *ci = fscrypt_get_inode_info_raw(inode);
|
||||
const unsigned int du_bits = ci->ci_data_unit_bits;
|
||||
const unsigned int du_size = 1U << du_bits;
|
||||
u64 index = ((u64)folio->index << (PAGE_SHIFT - du_bits)) +
|
||||
(offs >> du_bits);
|
||||
size_t i;
|
||||
int err;
|
||||
|
||||
if (WARN_ON_ONCE(!folio_test_locked(folio)))
|
||||
return -EINVAL;
|
||||
|
||||
if (WARN_ON_ONCE(len <= 0 || !IS_ALIGNED(len | offs, du_size)))
|
||||
return -EINVAL;
|
||||
|
||||
for (i = offs; i < offs + len; i += du_size, index++) {
|
||||
struct page *page = folio_page(folio, i >> PAGE_SHIFT);
|
||||
|
||||
err = fscrypt_crypt_data_unit(ci, FS_DECRYPT, index, page,
|
||||
page, du_size, i & ~PAGE_MASK);
|
||||
if (err)
|
||||
return err;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(fscrypt_decrypt_pagecache_blocks);
|
||||
|
||||
/**
|
||||
* fscrypt_decrypt_block_inplace() - Decrypt a filesystem block in-place
|
||||
* @inode: The inode to which this block belongs
|
||||
@@ -371,20 +320,6 @@ void fscrypt_msg(const struct inode *inode, const char *level,
|
||||
|
||||
static int __init fscrypt_init(void)
|
||||
{
|
||||
/*
|
||||
* Use an unbound workqueue to allow bios to be decrypted in parallel
|
||||
* even when they happen to complete on the same CPU. This sacrifices
|
||||
* locality, but it's worthwhile since decryption is CPU-intensive.
|
||||
*
|
||||
* Also use a high-priority workqueue to prioritize decryption work,
|
||||
* which blocks reads from completing, over regular application tasks.
|
||||
*/
|
||||
fscrypt_read_workqueue = alloc_workqueue("fscrypt_read_queue",
|
||||
WQ_UNBOUND | WQ_HIGHPRI,
|
||||
num_online_cpus());
|
||||
if (!fscrypt_read_workqueue)
|
||||
panic("failed to allocate fscrypt_read_queue");
|
||||
|
||||
fscrypt_inode_info_cachep = KMEM_CACHE(fscrypt_inode_info,
|
||||
SLAB_RECLAIM_ACCOUNT |
|
||||
SLAB_PANIC);
|
||||
|
||||
@@ -345,7 +345,6 @@ static inline void fscrypt_prepare_dentry(struct dentry *dentry,
|
||||
}
|
||||
|
||||
/* crypto.c */
|
||||
void fscrypt_enqueue_decrypt_work(struct work_struct *);
|
||||
|
||||
struct page *fscrypt_encrypt_pagecache_blocks(struct folio *folio,
|
||||
size_t len, size_t offs, gfp_t gfp_flags);
|
||||
@@ -353,8 +352,6 @@ int fscrypt_encrypt_block_inplace(const struct inode *inode, struct page *page,
|
||||
unsigned int len, unsigned int offs,
|
||||
u64 lblk_num);
|
||||
|
||||
int fscrypt_decrypt_pagecache_blocks(struct folio *folio, size_t len,
|
||||
size_t offs);
|
||||
int fscrypt_decrypt_block_inplace(const struct inode *inode, struct page *page,
|
||||
unsigned int len, unsigned int offs,
|
||||
u64 lblk_num);
|
||||
@@ -452,7 +449,6 @@ bool fscrypt_match_name(const struct fscrypt_name *fname,
|
||||
u64 fscrypt_fname_siphash(const struct inode *dir, const struct qstr *name);
|
||||
|
||||
/* bio.c */
|
||||
bool fscrypt_decrypt_bio(struct bio *bio);
|
||||
int fscrypt_zeroout_range(const struct inode *inode, loff_t pos,
|
||||
sector_t sector, u64 len);
|
||||
|
||||
@@ -512,9 +508,6 @@ static inline void fscrypt_prepare_dentry(struct dentry *dentry,
|
||||
}
|
||||
|
||||
/* crypto.c */
|
||||
static inline void fscrypt_enqueue_decrypt_work(struct work_struct *work)
|
||||
{
|
||||
}
|
||||
|
||||
static inline struct page *fscrypt_encrypt_pagecache_blocks(struct folio *folio,
|
||||
size_t len, size_t offs, gfp_t gfp_flags)
|
||||
@@ -530,12 +523,6 @@ static inline int fscrypt_encrypt_block_inplace(const struct inode *inode,
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static inline int fscrypt_decrypt_pagecache_blocks(struct folio *folio,
|
||||
size_t len, size_t offs)
|
||||
{
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
||||
static inline int fscrypt_decrypt_block_inplace(const struct inode *inode,
|
||||
struct page *page,
|
||||
unsigned int len,
|
||||
@@ -753,10 +740,6 @@ static inline int fscrypt_d_revalidate(struct inode *dir, const struct qstr *nam
|
||||
}
|
||||
|
||||
/* bio.c */
|
||||
static inline bool fscrypt_decrypt_bio(struct bio *bio)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
static inline int fscrypt_zeroout_range(const struct inode *inode, loff_t pos,
|
||||
sector_t sector, u64 len)
|
||||
@@ -894,36 +877,6 @@ static inline u64 fscrypt_limit_io_blocks(const struct inode *inode, u64 lblk,
|
||||
}
|
||||
#endif /* !CONFIG_FS_ENCRYPTION_INLINE_CRYPT */
|
||||
|
||||
/**
|
||||
* fscrypt_inode_uses_inline_crypto() - test whether an inode uses inline
|
||||
* encryption
|
||||
* @inode: an inode. If encrypted, its key must be set up.
|
||||
*
|
||||
* Return: true if the inode requires file contents encryption and if the
|
||||
* encryption should be done in the block layer via blk-crypto rather
|
||||
* than in the filesystem layer.
|
||||
*/
|
||||
static inline bool fscrypt_inode_uses_inline_crypto(const struct inode *inode)
|
||||
{
|
||||
return fscrypt_needs_contents_encryption(inode) &&
|
||||
inode->i_sb->s_cop->is_block_based;
|
||||
}
|
||||
|
||||
/**
|
||||
* fscrypt_inode_uses_fs_layer_crypto() - test whether an inode uses fs-layer
|
||||
* encryption
|
||||
* @inode: an inode. If encrypted, its key must be set up.
|
||||
*
|
||||
* Return: true if the inode requires file contents encryption and if the
|
||||
* encryption should be done in the filesystem layer rather than in the
|
||||
* block layer via blk-crypto.
|
||||
*/
|
||||
static inline bool fscrypt_inode_uses_fs_layer_crypto(const struct inode *inode)
|
||||
{
|
||||
return fscrypt_needs_contents_encryption(inode) &&
|
||||
!inode->i_sb->s_cop->is_block_based;
|
||||
}
|
||||
|
||||
/**
|
||||
* fscrypt_has_encryption_key() - check whether an inode has had its key set up
|
||||
* @inode: the inode to check
|
||||
|
||||
Reference in New Issue
Block a user