[PATCH RFC 10/29] btrfs: use a per-superblock fsverity workqueue

Andrey Albershteyn
2025-07-28T20:31:34Z

From: "Darrick J. Wong" <djwong@kernel.org>

Switch btrfs to use a per-sb fsverity workqueue instead of a systemwide
workqueue.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
fs/btrfs/super.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)

diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index a0c65adce1ab..cf82c260da9c 100644
--- a/fs/btrfs/super.c
+++ b/fs/btrfs/super.c
@@ -28,6 +28,7 @@
#include <linux/btrfs.h>
#include <linux/security.h>
#include <linux/fs_parser.h>
+#include <linux/fsverity.h>
#include "messages.h"
#include "delayed-inode.h"
#include "ctree.h"
@@ -954,6 +955,19 @@ static int btrfs_fill_super(struct super_block *sb,
sb->s_export_op = &btrfs_export_ops;
#ifdef CONFIG_FS_VERITY
sb->s_vop = &btrfs_verityops;
+ /*
+ * Use a high-priority workqueue to prioritize verification work, which
+ * blocks reads from completing, over regular application tasks.
+ *
+ * For performance reasons, don't use an unbound workqueue. Using an
+ * unbound workqueue for crypto operations causes excessive scheduler
+ * latency on ARM64.
+ */
+ err = fsverity_init_wq(sb, WQ_HIGHPRI, num_online_cpus());
+ if (err) {
+ btrfs_err(fs_info, "fsverity_init_wq failed");
+ return err;
+ }
#endif
sb->s_xattr = btrfs_xattr_handlers;
sb->s_time_gran = 1;

--
2.50.0