[2/2] f2fs: add iostat support for flush

Message ID 20221221192001.17290-1-frank.li@vivo.com
State New
Headers
Series [1/2] f2fs: support accounting iostat count and avg_bytes |

Commit Message

李扬韬 Dec. 21, 2022, 7:20 p.m. UTC
  In this patch, it adds to account flush count.

Signed-off-by: Yangtao Li <frank.li@vivo.com>
---
 fs/f2fs/f2fs.h    | 1 +
 fs/f2fs/iostat.c  | 4 ++++
 fs/f2fs/segment.c | 2 ++
 3 files changed, 7 insertions(+)
  

Patch

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index b116c778fce6..7d7b96d1e1d2 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1194,6 +1194,7 @@  enum iostat_type {
 
 	/* other */
 	FS_DISCARD,			/* discard */
+	FS_FLUSH,			/* flush */
 	NR_IO_TYPE,
 };
 
diff --git a/fs/f2fs/iostat.c b/fs/f2fs/iostat.c
index 3d4503fef183..721294c40399 100644
--- a/fs/f2fs/iostat.c
+++ b/fs/f2fs/iostat.c
@@ -150,6 +150,10 @@  int __maybe_unused iostat_info_seq_show(struct seq_file *seq, void *offset)
 				sbi->rw_iostat[FS_DISCARD],
 				sbi->iostat_count[FS_DISCARD],
 				iostat_get_avg_bytes(sbi, FS_DISCARD));
+	seq_printf(seq, "fs flush:		%-16llu %-16llu %-16llu\n",
+				sbi->rw_iostat[FS_FLUSH],
+				sbi->iostat_count[FS_FLUSH],
+				iostat_get_avg_bytes(sbi, FS_FLUSH));
 
 	return 0;
 }
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index af2d522b1a89..ec4ed7603d1f 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -505,6 +505,8 @@  static int __submit_flush_wait(struct f2fs_sb_info *sbi,
 				struct block_device *bdev)
 {
 	int ret = blkdev_issue_flush(bdev);
+	if (!ret)
+		f2fs_update_iostat(sbi, NULL, FS_FLUSH, 0);
 
 	trace_f2fs_issue_flush(bdev, test_opt(sbi, NOBARRIER),
 				test_opt(sbi, FLUSH_MERGE), ret);