@@ -37,6 +37,7 @@
#include <linux/user_namespace.h>
#include <linux/fs_context.h>
#include <uapi/linux/mount.h>
+#include <linux/fsverity.h>
#include "internal.h"
static int thaw_super_locked(struct super_block *sb, enum freeze_holder who);
@@ -637,6 +638,8 @@ void generic_shutdown_super(struct super_block *sb)
sb->s_dio_done_wq = NULL;
}
+ fsverity_destroy_wq(sb);
+
if (sop->put_super)
sop->put_super(sb);
@@ -339,6 +339,20 @@ void fsverity_verify_bio(struct bio *bio)
EXPORT_SYMBOL_GPL(fsverity_verify_bio);
#endif /* CONFIG_BLOCK */
+int fsverity_init_wq(struct super_block *sb, unsigned int wq_flags,
+ int max_active)
+{
+ WARN_ON_ONCE(sb->s_verity_wq != NULL);
+
+ sb->s_verity_wq = alloc_workqueue("fsverity/%s", wq_flags, max_active,
+ sb->s_id);
+ if (!sb->s_verity_wq)
+ return -ENOMEM;
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(fsverity_init_wq);
+
/**
* fsverity_enqueue_verify_work() - enqueue work on the fs-verity workqueue
* @work: the work to enqueue
@@ -1232,6 +1232,8 @@ struct super_block {
#endif
#ifdef CONFIG_FS_VERITY
const struct fsverity_operations *s_vop;
+ /* Completion queue for post read verification */
+ struct workqueue_struct *s_verity_wq;
#endif
#if IS_ENABLED(CONFIG_UNICODE)
struct unicode_map *s_encoding;
@@ -262,6 +262,17 @@ 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);
+int fsverity_init_wq(struct super_block *sb, unsigned int wq_flags,
+ int max_active);
+
+static inline void fsverity_destroy_wq(struct super_block *sb)
+{
+ if (sb->s_verity_wq) {
+ destroy_workqueue(sb->s_verity_wq);
+ sb->s_verity_wq = NULL;
+ }
+}
+
#else /* !CONFIG_FS_VERITY */
static inline struct fsverity_info *fsverity_get_info(const struct inode *inode)
@@ -339,6 +350,13 @@ static inline void fsverity_enqueue_verify_work(struct work_struct *work)
WARN_ON_ONCE(1);
}
+static inline int fsverity_init_wq(struct super_block *sb)
+{
+ return -EOPNOTSUPP;
+}
+
+static inline void fsverity_destroy_wq(struct super_block *sb) { }
+
#endif /* !CONFIG_FS_VERITY */
static inline bool fsverity_verify_folio(struct folio *folio)