[PATCH 4/4] f2fs: rename rw_iostat to iostat_bytes

From: Yangtao Li
Date: Wed Jan 04 2023 - 06:22:42 EST


The contents stored in the rw_iostat and prev_rw_iostat arrays do not
quite match the meaning of the names. In fact, array storage is not
only read, write io, but also discard and flush. In addition, in order
to better distinguish it from the iostat_count array, it is more accurate
to say that io bytes are stored in it. Also, the FS_DISCARD and FS_FLUSH_IO
names are less harmonious than others. Let's change to new names.

Signed-off-by: Yangtao Li <frank.li@xxxxxxxx>
---
fs/f2fs/f2fs.h | 8 ++++----
fs/f2fs/iostat.c | 20 ++++++++++----------
fs/f2fs/segment.c | 4 ++--
include/trace/events/f2fs.h | 2 +-
4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 0a24447472db..331c330ea31d 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1191,8 +1191,8 @@ enum iostat_type {
FS_META_READ_IO, /* meta read IOs */

/* other */
- FS_DISCARD, /* discard */
- FS_FLUSH, /* flush */
+ FS_DISCARD_IO, /* discard */
+ FS_FLUSH_IO, /* flush */
NR_IO_TYPE,
};

@@ -1856,8 +1856,8 @@ struct f2fs_sb_info {
/* For app/fs IO statistics */
spinlock_t iostat_lock;
unsigned long long iostat_count[NR_IO_TYPE];
- unsigned long long rw_iostat[NR_IO_TYPE];
- unsigned long long prev_rw_iostat[NR_IO_TYPE];
+ unsigned long long iostat_bytes[NR_IO_TYPE];
+ unsigned long long prev_iostat_bytes[NR_IO_TYPE];
bool iostat_enable;
unsigned long iostat_next_period;
unsigned int iostat_period_ms;
diff --git a/fs/f2fs/iostat.c b/fs/f2fs/iostat.c
index 991605fcfe0b..59c72f92191a 100644
--- a/fs/f2fs/iostat.c
+++ b/fs/f2fs/iostat.c
@@ -21,13 +21,13 @@ static mempool_t *bio_iostat_ctx_pool;
static inline unsigned long long iostat_get_avg_bytes(struct f2fs_sb_info *sbi,
enum iostat_type type)
{
- return sbi->iostat_count[type] ? div64_u64(sbi->rw_iostat[type],
+ return sbi->iostat_count[type] ? div64_u64(sbi->iostat_bytes[type],
sbi->iostat_count[type]) : 0;
}

#define IOSTAT_INFO_SHOW(name, type) \
seq_printf(seq, "%-23s %-16llu %-16llu %-16llu\n", \
- name":", sbi->rw_iostat[type], \
+ name":", sbi->iostat_bytes[type], \
sbi->iostat_count[type], \
iostat_get_avg_bytes(sbi, type)) \

@@ -79,8 +79,8 @@ int __maybe_unused iostat_info_seq_show(struct seq_file *seq, void *offset)

/* print other IOs */
seq_puts(seq, "[OTHER]\n");
- IOSTAT_INFO_SHOW("fs discard", FS_DISCARD);
- IOSTAT_INFO_SHOW("fs flush", FS_FLUSH);
+ IOSTAT_INFO_SHOW("fs discard", FS_DISCARD_IO);
+ IOSTAT_INFO_SHOW("fs flush", FS_FLUSH_IO);

return 0;
}
@@ -129,9 +129,9 @@ static inline void f2fs_record_iostat(struct f2fs_sb_info *sbi)
msecs_to_jiffies(sbi->iostat_period_ms);

for (i = 0; i < NR_IO_TYPE; i++) {
- iostat_diff[i] = sbi->rw_iostat[i] -
- sbi->prev_rw_iostat[i];
- sbi->prev_rw_iostat[i] = sbi->rw_iostat[i];
+ iostat_diff[i] = sbi->iostat_bytes[i] -
+ sbi->prev_iostat_bytes[i];
+ sbi->prev_iostat_bytes[i] = sbi->iostat_bytes[i];
}
spin_unlock_irqrestore(&sbi->iostat_lock, flags);

@@ -148,8 +148,8 @@ void f2fs_reset_iostat(struct f2fs_sb_info *sbi)
spin_lock_irq(&sbi->iostat_lock);
for (i = 0; i < NR_IO_TYPE; i++) {
sbi->iostat_count[i] = 0;
- sbi->rw_iostat[i] = 0;
- sbi->prev_rw_iostat[i] = 0;
+ sbi->iostat_bytes[i] = 0;
+ sbi->prev_iostat_bytes[i] = 0;
}
spin_unlock_irq(&sbi->iostat_lock);

@@ -161,7 +161,7 @@ void f2fs_reset_iostat(struct f2fs_sb_info *sbi)
static inline void __f2fs_update_iostat(struct f2fs_sb_info *sbi,
enum iostat_type type, unsigned long long io_bytes)
{
- sbi->rw_iostat[type] += io_bytes;
+ sbi->iostat_bytes[type] += io_bytes;
sbi->iostat_count[type]++;
}

diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index 34e9dc4df5bb..38bae9107a3b 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -504,7 +504,7 @@ static int __submit_flush_wait(struct f2fs_sb_info *sbi,
{
int ret = blkdev_issue_flush(bdev);
if (!ret)
- f2fs_update_iostat(sbi, NULL, FS_FLUSH, 0);
+ f2fs_update_iostat(sbi, NULL, FS_FLUSH_IO, 0);

trace_f2fs_issue_flush(bdev, test_opt(sbi, NOBARRIER),
test_opt(sbi, FLUSH_MERGE), ret);
@@ -1184,7 +1184,7 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,

atomic_inc(&dcc->issued_discard);

- f2fs_update_iostat(sbi, NULL, FS_DISCARD, len * F2FS_BLKSIZE);
+ f2fs_update_iostat(sbi, NULL, FS_DISCARD_IO, len * F2FS_BLKSIZE);

lstart += len;
start += len;
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 9183a0a11e26..3852085198fb 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -1972,7 +1972,7 @@ TRACE_EVENT(f2fs_iostat,
__entry->fs_cdrio = iostat[FS_CDATA_READ_IO];
__entry->fs_nrio = iostat[FS_NODE_READ_IO];
__entry->fs_mrio = iostat[FS_META_READ_IO];
- __entry->fs_discard = iostat[FS_DISCARD];
+ __entry->fs_discard = iostat[FS_DISCARD_IO];
),

TP_printk("dev = (%d,%d), "
--
2.25.1