[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <174553065528.1161238.4178228996070898927.stgit@frogsfrogsfrogs>
Date: Thu, 24 Apr 2025 14:45:43 -0700
From: "Darrick J. Wong" <djwong@...nel.org>
To: tytso@....edu
Cc: linux-ext4@...r.kernel.org
Subject: [PATCH 1/5] fuse2fs: report cache hits and misses at unmount time
From: Darrick J. Wong <djwong@...nel.org>
Log the IO cache's hit and miss quantities at unmount time.
Signed-off-by: "Darrick J. Wong" <djwong@...nel.org>
---
lib/ext2fs/ext2_io.h | 2 ++
lib/ext2fs/unix_io.c | 4 +++-
misc/fuse2fs.c | 13 +++++++++++++
3 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/lib/ext2fs/ext2_io.h b/lib/ext2fs/ext2_io.h
index 27eaaf1be35442..39a4e8fcf6b515 100644
--- a/lib/ext2fs/ext2_io.h
+++ b/lib/ext2fs/ext2_io.h
@@ -71,6 +71,8 @@ struct struct_io_stats {
int reserved;
unsigned long long bytes_read;
unsigned long long bytes_written;
+ unsigned long long cache_hits;
+ unsigned long long cache_misses;
};
struct struct_io_manager {
diff --git a/lib/ext2fs/unix_io.c b/lib/ext2fs/unix_io.c
index 4b4f25a494f8c6..207a8e63b77fd4 100644
--- a/lib/ext2fs/unix_io.c
+++ b/lib/ext2fs/unix_io.c
@@ -536,6 +536,7 @@ static struct unix_cache *find_cached_block(struct unix_private_data *data,
}
if (cache->block == block) {
cache->access_time = ++data->access_time;
+ data->io_stats.cache_hits++;
return cache;
}
if (!oldest_cache ||
@@ -544,6 +545,7 @@ static struct unix_cache *find_cached_block(struct unix_private_data *data,
}
if (eldest)
*eldest = (unused_cache) ? unused_cache : oldest_cache;
+ data->io_stats.cache_misses++;
return 0;
}
@@ -737,7 +739,7 @@ static errcode_t unix_open_channel(const char *name, int fd,
memset(data, 0, sizeof(struct unix_private_data));
data->magic = EXT2_ET_MAGIC_UNIX_IO_CHANNEL;
- data->io_stats.num_fields = 2;
+ data->io_stats.num_fields = 4;
data->flags = flags;
data->dev = fd;
diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 8451cabfb19110..7f1e7556b9204e 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -604,6 +604,19 @@ static void op_destroy(void *p EXT2FS_ATTR((unused)))
translate_error(fs, 0, err);
}
+ if (ff->debug && fs->io->manager->get_stats) {
+ io_stats stats = NULL;
+
+ fs->io->manager->get_stats(fs->io, &stats);
+ dbg_printf(ff, "read: %lluk\n", stats->bytes_read >> 10);
+ dbg_printf(ff, "write: %lluk\n", stats->bytes_written >> 10);
+ dbg_printf(ff, "hits: %llu\n", stats->cache_hits);
+ dbg_printf(ff, "misses: %llu\n", stats->cache_misses);
+ dbg_printf(ff, "hit_ratio: %.1f%%\n",
+ (100.0 * stats->cache_hits) /
+ (stats->cache_hits + stats->cache_misses));
+ }
+
if (ff->kernel) {
char uuid[UUID_STR_SIZE];
Powered by blists - more mailing lists