fs/pstore/zone.c
Source file repositories/reference/linux-study-clean/fs/pstore/zone.c
File Facts
- System
- Linux kernel
- Corpus path
fs/pstore/zone.c- Extension
.c- Size
- 36312 bytes
- Lines
- 1476
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/kernel.hlinux/module.hlinux/slab.hlinux/mount.hlinux/printk.hlinux/fs.hlinux/pstore_zone.hlinux/kdev_t.hlinux/device.hlinux/namei.hlinux/fcntl.hlinux/uio.hlinux/writeback.hinternal.h
Detected Declarations
struct psz_bufferstruct psz_kmsg_headerstruct pstore_zonestruct psz_contextenum psz_flush_modefunction buffer_datalenfunction buffer_startfunction is_on_panicfunction psz_zone_read_bufferfunction psz_zone_read_oldbuffunction psz_zone_writefunction psz_flush_dirty_zonefunction psz_flush_dirty_zonesfunction psz_move_zonefunction psz_flush_all_dirty_zonesfunction psz_kmsg_recover_datafunction psz_kmsg_recover_metafunction psz_kmsg_recoverfunction psz_recover_zonefunction psz_recover_zonesfunction psz_recoveryfunction psz_pstore_openfunction psz_old_okfunction psz_okfunction psz_kmsg_erasefunction psz_record_erasefunction psz_pstore_erasefunction psz_write_kmsg_hdrfunction psz_kmsg_write_recordfunction psz_kmsg_writefunction psz_record_writefunction psz_pstore_writefunction psz_kmsg_read_hdrfunction psz_kmsg_readfunction psz_ftrace_readfunction psz_record_readfunction psz_pstore_readfunction psz_free_zonefunction psz_free_zonesfunction psz_free_all_zonesfunction psz_alloc_zonesfunction register_pstore_zonefunction unregister_pstore_zoneexport register_pstore_zoneexport unregister_pstore_zone
Annotated Snippet
struct psz_buffer {
#define PSZ_SIG (0x43474244) /* DBGC */
uint32_t sig;
atomic_t datalen;
atomic_t start;
uint8_t data[];
};
/**
* struct psz_kmsg_header - kmsg dump-specific header to flush to storage
*
* @magic: magic num for kmsg dump header
* @time: kmsg dump trigger time
* @compressed: whether compressed
* @counter: kmsg dump counter
* @reason: the kmsg dump reason (e.g. oops, panic, etc)
* @data: pointer to log data
*
* This is a sub-header for a kmsg dump, trailing after &psz_buffer.
*/
struct psz_kmsg_header {
#define PSTORE_KMSG_HEADER_MAGIC 0x4dfc3ae5 /* Just a random number */
uint32_t magic;
struct timespec64 time;
bool compressed;
uint32_t counter;
enum kmsg_dump_reason reason;
uint8_t data[];
};
/**
* struct pstore_zone - single stored buffer
*
* @off: zone offset of storage
* @type: front-end type for this zone
* @name: front-end name for this zone
* @buffer: pointer to data buffer managed by this zone
* @oldbuf: pointer to old data buffer
* @buffer_size: bytes in @buffer->data
* @should_recover: whether this zone should recover from storage
* @dirty: whether the data in @buffer dirty
*
* zone structure in memory.
*/
struct pstore_zone {
loff_t off;
const char *name;
enum pstore_type_id type;
struct psz_buffer *buffer;
struct psz_buffer *oldbuf;
size_t buffer_size;
bool should_recover;
atomic_t dirty;
};
/**
* struct psz_context - all about running state of pstore/zone
*
* @kpszs: kmsg dump storage zones
* @ppsz: pmsg storage zone
* @cpsz: console storage zone
* @fpszs: ftrace storage zones
* @kmsg_max_cnt: max count of @kpszs
* @kmsg_read_cnt: counter of total read kmsg dumps
* @kmsg_write_cnt: counter of total kmsg dump writes
* @pmsg_read_cnt: counter of total read pmsg zone
* @console_read_cnt: counter of total read console zone
* @ftrace_max_cnt: max count of @fpszs
* @ftrace_read_cnt: counter of max read ftrace zone
* @oops_counter: counter of oops dumps
* @panic_counter: counter of panic dumps
* @recovered: whether finished recovering data from storage
* @on_panic: whether panic is happening
* @pstore_zone_info_lock: lock to @pstore_zone_info
* @pstore_zone_info: information from backend
* @pstore: structure for pstore
*/
struct psz_context {
struct pstore_zone **kpszs;
struct pstore_zone *ppsz;
struct pstore_zone *cpsz;
struct pstore_zone **fpszs;
unsigned int kmsg_max_cnt;
unsigned int kmsg_read_cnt;
unsigned int kmsg_write_cnt;
unsigned int pmsg_read_cnt;
unsigned int console_read_cnt;
unsigned int ftrace_max_cnt;
unsigned int ftrace_read_cnt;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/slab.h`, `linux/mount.h`, `linux/printk.h`, `linux/fs.h`, `linux/pstore_zone.h`, `linux/kdev_t.h`.
- Detected declarations: `struct psz_buffer`, `struct psz_kmsg_header`, `struct pstore_zone`, `struct psz_context`, `enum psz_flush_mode`, `function buffer_datalen`, `function buffer_start`, `function is_on_panic`, `function psz_zone_read_buffer`, `function psz_zone_read_oldbuf`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration 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.