lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 12 Dec 2022 13:47:06 +0800
From:   Yangtao Li <frank.li@...o.com>
To:     jaegeuk@...nel.org, chao@...nel.org
Cc:     linux-f2fs-devel@...ts.sourceforge.net,
        linux-kernel@...r.kernel.org, Yangtao Li <frank.li@...o.com>
Subject: [PATCH] f2fs: add iostat support for FS_DISCARD_IO

Just like other data we count uses the number of bytes as the basic
unit, but discard uses the number of cmds as the statistical unit. In
fact, the discard command contains the number of blocks. In order to
avoid breaking its usage of application, let's keeping FS_DISCARD
as it is, and add FS_DISCARD_IO to account discard bytes.

Suggested-by: Chao Yu <chao@...nel.org>
Signed-off-by: Yangtao Li <frank.li@...o.com>
---
 fs/f2fs/f2fs.h    | 1 +
 fs/f2fs/iostat.c  | 5 +++++
 fs/f2fs/segment.c | 2 +-
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index e8953c3dc81a..ef0043003bf8 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1193,6 +1193,7 @@ enum iostat_type {
 	FS_META_READ_IO,		/* meta read IOs */
 
 	/* other */
+	FS_DISCARD_IO,		/* discard IOs */
 	FS_DISCARD,			/* discard */
 	NR_IO_TYPE,
 };
diff --git a/fs/f2fs/iostat.c b/fs/f2fs/iostat.c
index 3166a8939ed4..3d2f0b69cdda 100644
--- a/fs/f2fs/iostat.c
+++ b/fs/f2fs/iostat.c
@@ -89,6 +89,8 @@ int __maybe_unused iostat_info_seq_show(struct seq_file *seq, void *offset)
 
 	/* print other IOs */
 	seq_puts(seq, "[OTHER]\n");
+	seq_printf(seq, "fs discard bytes:	%-16llu\n",
+				sbi->rw_iostat[FS_DISCARD_IO]);
 	seq_printf(seq, "fs discard:		%-16llu\n",
 				sbi->rw_iostat[FS_DISCARD]);
 
@@ -180,6 +182,9 @@ void f2fs_update_iostat(struct f2fs_sb_info *sbi, struct inode *inode,
 	spin_lock_irqsave(&sbi->iostat_lock, flags);
 	sbi->rw_iostat[type] += io_bytes;
 
+	if (type == FS_DISCARD_IO)
+		sbi->rw_iostat[FS_DISCARD]++;
+
 	if (type == APP_BUFFERED_IO || type == APP_DIRECT_IO)
 		sbi->rw_iostat[APP_WRITE_IO] += io_bytes;
 
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index dee712f7225f..bd02631f9681 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1187,7 +1187,7 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
 
 		atomic_inc(&dcc->issued_discard);
 
-		f2fs_update_iostat(sbi, NULL, FS_DISCARD, 1);
+		f2fs_update_iostat(sbi, NULL, FS_DISCARD_IO, len * F2FS_BLKSIZE);
 
 		lstart += len;
 		start += len;
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ