From: Yi Sun <yi.sun@unisoc.com>
To: <sunyibuaa@gmail.com>, <tj@kernel.org>, <jiangshanlai@gmail.com>,
<jaegeuk@kernel.org>, <chao@kernel.org>
Cc: <ebiggers@google.com>, <linux-f2fs-devel@lists.sourceforge.net>,
<linux-kernel@vger.kernel.org>, <kent.overstreet@linux.dev>,
<niuzhiguo84@gmail.com>, <Hao_hao.Wang@unisoc.com>,
<yunlongxing23@gmail.com>, <yi.sun@unisoc.com>
Subject: [PATCH v2 2/2] f2fs: set io priority for fsverity work
Date: Mon, 1 Jul 2024 15:51:38 +0800 [thread overview]
Message-ID: <20240701075138.1144575-3-yi.sun@unisoc.com> (raw)
In-Reply-To: <20240701075138.1144575-1-yi.sun@unisoc.com>
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@unisoc.com>
---
fs/f2fs/data.c | 17 ++++++++++-------
fs/f2fs/f2fs.h | 1 +
fs/f2fs/verity.c | 5 +++++
3 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c
index b9b0debc6b3d..7e8c56a3098b 100644
--- a/fs/f2fs/data.c
+++ b/fs/f2fs/data.c
@@ -110,7 +110,7 @@ enum bio_post_read_step {
struct bio_post_read_ctx {
struct bio *bio;
struct f2fs_sb_info *sbi;
- struct work_struct work;
+ struct io_work iowork;
unsigned int enabled_steps;
/*
* decompression_attempted keeps track of whether
@@ -168,10 +168,12 @@ static void f2fs_finish_read_bio(struct bio *bio, bool in_task)
static void f2fs_verify_bio(struct work_struct *work)
{
struct bio_post_read_ctx *ctx =
- container_of(work, struct bio_post_read_ctx, work);
+ container_of(to_io_work(work), struct bio_post_read_ctx, iowork);
struct bio *bio = ctx->bio;
bool may_have_compressed_pages = (ctx->enabled_steps & STEP_DECOMPRESS);
+ may_adjust_io_work_task_ioprio(to_io_work(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,7 @@ static void f2fs_verify_bio(struct work_struct *work)
}
f2fs_finish_read_bio(bio, true);
+ restore_io_work_task_ioprio(to_io_work(work));
}
/*
@@ -220,8 +223,8 @@ static void f2fs_verify_and_finish_bio(struct bio *bio, bool in_task)
struct bio_post_read_ctx *ctx = bio->bi_private;
if (ctx && (ctx->enabled_steps & STEP_VERITY)) {
- INIT_WORK(&ctx->work, f2fs_verify_bio);
- fsverity_enqueue_verify_work(&ctx->work);
+ INIT_IO_WORK(&ctx->iowork, f2fs_verify_bio);
+ f2fs_enqueue_verify_io_work(&ctx->iowork);
} else {
f2fs_finish_read_bio(bio, in_task);
}
@@ -270,7 +273,7 @@ static void f2fs_handle_step_decompress(struct bio_post_read_ctx *ctx,
static void f2fs_post_read_work(struct work_struct *work)
{
struct bio_post_read_ctx *ctx =
- container_of(work, struct bio_post_read_ctx, work);
+ container_of(to_io_work(work), struct bio_post_read_ctx, iowork);
struct bio *bio = ctx->bio;
if ((ctx->enabled_steps & STEP_DECRYPT) && !fscrypt_decrypt_bio(bio)) {
@@ -313,8 +316,8 @@ static void f2fs_read_end_io(struct bio *bio)
!f2fs_low_mem_mode(sbi)) {
f2fs_handle_step_decompress(ctx, intask);
} else if (enabled_steps) {
- INIT_WORK(&ctx->work, f2fs_post_read_work);
- queue_work(ctx->sbi->post_read_wq, &ctx->work);
+ INIT_IO_WORK(&ctx->iowork, f2fs_post_read_work);
+ queue_io_work(ctx->sbi->post_read_wq, &ctx->iowork);
return;
}
}
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 1974b6aff397..dc228c50ed30 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -4234,6 +4234,7 @@ void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi);
/* verity.c */
extern const struct fsverity_operations f2fs_verityops;
+void f2fs_enqueue_verify_io_work(struct io_work *iowork);
/*
* crypto support
diff --git a/fs/f2fs/verity.c b/fs/f2fs/verity.c
index f7bb0c54502c..fba6aecba9b6 100644
--- a/fs/f2fs/verity.c
+++ b/fs/f2fs/verity.c
@@ -292,3 +292,8 @@ const struct fsverity_operations f2fs_verityops = {
.read_merkle_tree_page = f2fs_read_merkle_tree_page,
.write_merkle_tree_block = f2fs_write_merkle_tree_block,
};
+
+void f2fs_enqueue_verify_io_work(struct io_work *iowork)
+{
+ fsverity_enqueue_verify_work(&(iowork->work));
+}
--
2.25.1
prev parent reply other threads:[~2024-07-01 7:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-01 7:51 [PATCH v2 0/2] new struct io_work and use it in f2fs " Yi Sun
2024-07-01 7:51 ` [PATCH v2 1/2] workqueue: new struct io_work Yi Sun
2024-07-01 17:32 ` Tejun Heo
2024-07-02 3:53 ` Kent Overstreet
2024-07-02 9:27 ` yi sun
2024-07-02 16:40 ` Tejun Heo
2024-07-02 16:45 ` Kent Overstreet
2024-07-02 3:40 ` kernel test robot
2024-07-02 21:51 ` kernel test robot
2024-07-01 7:51 ` Yi Sun [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240701075138.1144575-3-yi.sun@unisoc.com \
--to=yi.sun@unisoc.com \
--cc=Hao_hao.Wang@unisoc.com \
--cc=chao@kernel.org \
--cc=ebiggers@google.com \
--cc=jaegeuk@kernel.org \
--cc=jiangshanlai@gmail.com \
--cc=kent.overstreet@linux.dev \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=niuzhiguo84@gmail.com \
--cc=sunyibuaa@gmail.com \
--cc=tj@kernel.org \
--cc=yunlongxing23@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®