fs/f2fs/iostat.c
Source file repositories/reference/linux-study-clean/fs/f2fs/iostat.c
File Facts
- System
- Linux kernel
- Corpus path
fs/f2fs/iostat.c- Extension
.c- Size
- 10128 bytes
- Lines
- 352
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fs.hlinux/f2fs_fs.hlinux/seq_file.hf2fs.hiostat.htrace/events/f2fs.h
Detected Declarations
function iostat_get_avg_bytesfunction iostat_get_avg_bytesfunction __record_iostat_latencyfunction f2fs_record_iostatfunction f2fs_reset_iostatfunction __f2fs_update_iostatfunction f2fs_update_read_folio_countfunction f2fs_update_iostatfunction __update_iostat_latencyfunction iostat_update_and_unbind_ctxfunction iostat_alloc_and_bind_ctxfunction f2fs_init_iostat_processingfunction f2fs_destroy_iostat_processingfunction f2fs_init_iostatfunction f2fs_destroy_iostat
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
/*
* f2fs iostat support
*
* Copyright 2021 Google LLC
* Author: Daeho Jeong <daehojeong@google.com>
*/
#include <linux/fs.h>
#include <linux/f2fs_fs.h>
#include <linux/seq_file.h>
#include "f2fs.h"
#include "iostat.h"
#include <trace/events/f2fs.h>
static struct kmem_cache *bio_iostat_ctx_cache;
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->iostat_bytes[type],
sbi->iostat_count[type]) : 0;
}
#define IOSTAT_INFO_SHOW(name, type) \
seq_printf(seq, "%-23s %-16llu %-16llu %-16llu\n", \
name":", sbi->iostat_bytes[type], \
sbi->iostat_count[type], \
iostat_get_avg_bytes(sbi, type))
int __maybe_unused iostat_info_seq_show(struct seq_file *seq, void *offset)
{
struct super_block *sb = seq->private;
struct f2fs_sb_info *sbi = F2FS_SB(sb);
int i;
if (!sbi->iostat_enable)
return 0;
seq_printf(seq, "time: %-16llu\n", ktime_get_real_seconds());
seq_printf(seq, "\t\t\t%-16s %-16s %-16s\n",
"io_bytes", "count", "avg_bytes");
/* print app write IOs */
seq_puts(seq, "[WRITE]\n");
IOSTAT_INFO_SHOW("app buffered data", APP_BUFFERED_IO);
IOSTAT_INFO_SHOW("app direct data", APP_DIRECT_IO);
IOSTAT_INFO_SHOW("app mapped data", APP_MAPPED_IO);
IOSTAT_INFO_SHOW("app buffered cdata", APP_BUFFERED_CDATA_IO);
IOSTAT_INFO_SHOW("app mapped cdata", APP_MAPPED_CDATA_IO);
/* print fs write IOs */
IOSTAT_INFO_SHOW("fs data", FS_DATA_IO);
IOSTAT_INFO_SHOW("fs cdata", FS_CDATA_IO);
IOSTAT_INFO_SHOW("fs node", FS_NODE_IO);
IOSTAT_INFO_SHOW("fs meta", FS_META_IO);
IOSTAT_INFO_SHOW("fs gc data", FS_GC_DATA_IO);
IOSTAT_INFO_SHOW("fs gc node", FS_GC_NODE_IO);
IOSTAT_INFO_SHOW("fs cp data", FS_CP_DATA_IO);
IOSTAT_INFO_SHOW("fs cp node", FS_CP_NODE_IO);
IOSTAT_INFO_SHOW("fs cp meta", FS_CP_META_IO);
/* print app read IOs */
seq_puts(seq, "[READ]\n");
IOSTAT_INFO_SHOW("app buffered data", APP_BUFFERED_READ_IO);
IOSTAT_INFO_SHOW("app direct data", APP_DIRECT_READ_IO);
IOSTAT_INFO_SHOW("app mapped data", APP_MAPPED_READ_IO);
IOSTAT_INFO_SHOW("app buffered cdata", APP_BUFFERED_CDATA_READ_IO);
IOSTAT_INFO_SHOW("app mapped cdata", APP_MAPPED_CDATA_READ_IO);
/* print fs read IOs */
IOSTAT_INFO_SHOW("fs data", FS_DATA_READ_IO);
IOSTAT_INFO_SHOW("fs gc data", FS_GDATA_READ_IO);
IOSTAT_INFO_SHOW("fs cdata", FS_CDATA_READ_IO);
IOSTAT_INFO_SHOW("fs node", FS_NODE_READ_IO);
IOSTAT_INFO_SHOW("fs meta", FS_META_READ_IO);
/* print read folio order stats */
seq_printf(seq, "%-23s", "fs read folio order:");
for (i = 0; i < NR_PAGE_ORDERS; i++)
seq_printf(seq, " %llu", sbi->iostat_read_folio_count[i]);
seq_putc(seq, '\n');
/* print other IOs */
seq_puts(seq, "[OTHER]\n");
IOSTAT_INFO_SHOW("fs discard", FS_DISCARD_IO);
IOSTAT_INFO_SHOW("fs flush", FS_FLUSH_IO);
IOSTAT_INFO_SHOW("fs zone reset", FS_ZONE_RESET_IO);
Annotation
- Immediate include surface: `linux/fs.h`, `linux/f2fs_fs.h`, `linux/seq_file.h`, `f2fs.h`, `iostat.h`, `trace/events/f2fs.h`.
- Detected declarations: `function iostat_get_avg_bytes`, `function iostat_get_avg_bytes`, `function __record_iostat_latency`, `function f2fs_record_iostat`, `function f2fs_reset_iostat`, `function __f2fs_update_iostat`, `function f2fs_update_read_folio_count`, `function f2fs_update_iostat`, `function __update_iostat_latency`, `function iostat_update_and_unbind_ctx`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.