Skip to contentSkip to conversation

f2fs: add iostat latency statistics support for discard

PATCH Superseded Yangtao Li 1 participant 1 message Feb 16, 2023

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Yangtao Li

author
#0 lore raw

PATCH 1/1 f2fs: add iostat latency statistics support for discard

In this patch, it adds to account discard latency.

---
 fs/f2fs/data.c              |  2 +-
 fs/f2fs/f2fs.h              |  1 +
 fs/f2fs/iostat.c            | 83 +++++++++++++++++++++----------------
 fs/f2fs/iostat.h            | 49 +++++++++++-----------
 fs/f2fs/segment.c           |  8 +++-
 include/trace/events/f2fs.h | 68 ++++++++++++++++--------------
 6 files changed, 118 insertions(+), 93 deletions(-)
fs/f2fs/data.c +1 -1
index 28e09682b056..b67c0b41ee13 100644
@@ -2312,7 +2312,7 @@ int f2fs_read_multi_pages(struct compress_ctx *cc, struct bio **bio_ret,
 		if (bio_add_page(bio, page, blocksize, 0) < blocksize)
 			goto submit_and_realloc;
 
-		ctx = get_post_read_ctx(bio);
+		ctx = get_bio_iostat_private(bio);
 		ctx->enabled_steps |= STEP_DECOMPRESS;
 		refcount_inc(&dic->refcnt);
 
fs/f2fs/f2fs.h +1 -0
index 21596e0266ba..29e973f67c3c 100644
@@ -1131,6 +1131,7 @@ enum page_type {
 	META_FLUSH,
 	IPU,		/* the below types are used by tracepoints only. */
 	OPU,
+	DISCARD,	/* used by iostat */
 };
 
 enum temp_type {
fs/f2fs/iostat.c +47 -36

132 lines not on this page · raw message

fs/f2fs/iostat.h +24 -25

89 lines not on this page · raw message

fs/f2fs/segment.c +7 -1
index 227e25836173..9a6c45a62e8b 100644
@@ -1012,9 +1012,12 @@ static void __remove_discard_cmd(struct f2fs_sb_info *sbi,
 
 static void f2fs_submit_discard_endio(struct bio *bio)
 {
-	struct discard_cmd *dc = (struct discard_cmd *)bio->bi_private;
+	struct discard_cmd *dc;
 	unsigned long flags;
 
+	iostat_update_and_unbind_ctx(bio);
+	dc = bio->bi_private;
+
 	spin_lock_irqsave(&dc->lock, flags);
 	if (!dc->error)
 		dc->error = blk_status_to_errno(bio->bi_status);
@@ -1188,6 +1191,9 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
 		bio->bi_private = dc;
 		bio->bi_end_io = f2fs_submit_discard_endio;
 		bio->bi_opf |= flag;
+
+		iostat_alloc_and_bind_ctx(sbi, bio, dc);
+		iostat_update_submit_ctx(bio, DISCARD);
 		submit_bio(bio);
 
 		atomic_inc(&dcc->issued_discard);
include/trace/events/f2fs.h +38 -30

96 lines not on this page · raw message

Signature · 1 line
2.25.1