@@ -327,13 +327,15 @@ static void decrypt_bh(struct work_struct *work)
err = fscrypt_decrypt_pagecache_blocks(bh->b_folio, bh->b_size,
bh_offset(bh));
if (err == 0 && need_fsverity(bh)) {
+ struct super_block *sb = bh->b_folio->mapping->host->i_sb;
+
/*
* We use different work queues for decryption and for verity
* because verity may require reading metadata pages that need
* decryption, and we shouldn't recurse to the same workqueue.
*/
INIT_WORK(&ctx->work, verify_bh);
- fsverity_enqueue_verify_work(&ctx->work);
+ fsverity_enqueue_verify_work(sb, &ctx->work);
return;
}
end_buffer_async_read(bh, err == 0);
@@ -362,7 +364,8 @@ static void end_buffer_async_read_io(struct buffer_head *bh, int uptodate)
fscrypt_enqueue_decrypt_work(&ctx->work);
} else {
INIT_WORK(&ctx->work, verify_bh);
- fsverity_enqueue_verify_work(&ctx->work);
+ fsverity_enqueue_verify_work(inode->i_sb,
+ &ctx->work);
}
return;
}
@@ -61,6 +61,7 @@ enum bio_post_read_step {
struct bio_post_read_ctx {
struct bio *bio;
+ struct super_block *sb;
struct work_struct work;
unsigned int cur_step;
unsigned int enabled_steps;
@@ -132,7 +133,7 @@ static void bio_post_read_processing(struct bio_post_read_ctx *ctx)
case STEP_VERITY:
if (ctx->enabled_steps & (1 << STEP_VERITY)) {
INIT_WORK(&ctx->work, verity_work);
- fsverity_enqueue_verify_work(&ctx->work);
+ fsverity_enqueue_verify_work(ctx->sb, &ctx->work);
return;
}
ctx->cur_step++;
@@ -195,6 +196,7 @@ static void ext4_set_bio_post_read_ctx(struct bio *bio,
mempool_alloc(bio_post_read_ctx_pool, GFP_NOFS);
ctx->bio = bio;
+ ctx->sb = inode->i_sb;
ctx->enabled_steps = post_read_steps;
bio->bi_private = ctx;
}
@@ -1775,7 +1775,8 @@ void f2fs_decompress_end_io(struct decompress_io_ctx *dic, bool failed,
* file, and these metadata pages may be compressed.
*/
INIT_WORK(&dic->verity_work, f2fs_verify_cluster);
- fsverity_enqueue_verify_work(&dic->verity_work);
+ fsverity_enqueue_verify_work(dic->inode->i_sb,
+ &dic->verity_work);
return;
}
@@ -221,7 +221,7 @@ static void f2fs_verify_and_finish_bio(struct bio *bio, bool in_task)
if (ctx && (ctx->enabled_steps & STEP_VERITY)) {
INIT_WORK(&ctx->work, f2fs_verify_bio);
- fsverity_enqueue_verify_work(&ctx->work);
+ fsverity_enqueue_verify_work(ctx->sbi->sb, &ctx->work);
} else {
f2fs_finish_read_bio(bio, in_task);
}
@@ -367,13 +367,15 @@ EXPORT_SYMBOL_GPL(fsverity_init_wq);
/**
* fsverity_enqueue_verify_work() - enqueue work on the fs-verity workqueue
+ * @sb: superblock for this filesystem
* @work: the work to enqueue
*
* Enqueue verification work for asynchronous processing.
*/
-void fsverity_enqueue_verify_work(struct work_struct *work)
+void fsverity_enqueue_verify_work(struct super_block *sb,
+ struct work_struct *work)
{
- queue_work(fsverity_read_workqueue, work);
+ queue_work(sb->s_verity_wq ?: fsverity_read_workqueue, work);
}
EXPORT_SYMBOL_GPL(fsverity_enqueue_verify_work);
@@ -297,7 +297,8 @@ int fsverity_ioctl_read_metadata(struct file *filp, const void __user *uarg);
bool fsverity_verify_blocks(struct folio *folio, size_t len, size_t offset);
void fsverity_verify_bio(struct bio *bio);
-void fsverity_enqueue_verify_work(struct work_struct *work);
+void fsverity_enqueue_verify_work(struct super_block *sb,
+ struct work_struct *work);
int fsverity_init_wq(struct super_block *sb, unsigned int wq_flags,
int max_active);
@@ -389,7 +390,8 @@ static inline void fsverity_verify_bio(struct bio *bio)
WARN_ON_ONCE(1);
}
-static inline void fsverity_enqueue_verify_work(struct work_struct *work)
+static inline void fsverity_enqueue_verify_work(struct super_block *sb,
+ struct work_struct *work)
{
WARN_ON_ONCE(1);
}