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.

Dependency Surface

Detected Declarations

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

Implementation Notes