[PATCH 2/2] f2fs: set f2fs verify work io priority

From: Yi Sun
Date: Fri Jun 21 2024 - 02:27:44 EST


The io priority of reading the original data of the verity-file
and reading hash blocks during verification should be consistent.
If the io priority is not set, when a high-task-priority process
reads the verity-file, the kworker's io priority may be too low,
resulting in delayed reading of hash blocks, which eventually
causes the high-task-priority process to response slowly.

Signed-off-by: Yi Sun <yi.sun@xxxxxxxxxx>
---
fs/f2fs/data.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index b9b0debc6b3d..705a2bdf0848 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -172,6 +172,8 @@ static void f2fs_verify_bio(struct work_struct *work)
struct bio *bio = ctx->bio;
bool may_have_compressed_pages = (ctx->enabled_steps & STEP_DECOMPRESS);

+ may_adjust_work_task_ioprio(work);
+
/*
* fsverity_verify_bio() may call readahead() again, and while verity
* will be disabled for this, decryption and/or decompression may still
@@ -204,6 +206,8 @@ static void f2fs_verify_bio(struct work_struct *work)
}

f2fs_finish_read_bio(bio, true);
+
+ restore_work_task_ioprio(work);
}

/*
@@ -221,6 +225,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);
+ set_work_ioprio(&ctx->work, bio->bi_ioprio);
fsverity_enqueue_verify_work(&ctx->work);
} else {
f2fs_finish_read_bio(bio, in_task);
--
2.25.1