fs/pstore/platform.c
Source file repositories/reference/linux-study-clean/fs/pstore/platform.c
File Facts
- System
- Linux kernel
- Corpus path
fs/pstore/platform.c- Extension
.c- Size
- 18931 bytes
- Lines
- 767
- 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/atomic.hlinux/types.hlinux/errno.hlinux/init.hlinux/kmsg_dump.hlinux/console.hlinux/mm.hlinux/module.hlinux/pstore.hlinux/string.hlinux/timer.hlinux/slab.hlinux/uaccess.hlinux/jiffies.hlinux/vmalloc.hlinux/workqueue.hlinux/zlib.hinternal.h
Detected Declarations
function pstore_set_kmsg_bytesfunction pstore_name_to_typefunction pstore_timer_kickfunction pstore_cannot_block_pathfunction pstore_compressfunction allocate_buf_for_compressionfunction free_buf_for_compressionfunction pstore_record_initfunction pstore_dumpfunction pstore_register_kmsgfunction pstore_unregister_kmsgfunction pstore_console_writefunction pstore_register_consolefunction pstore_unregister_consolefunction pstore_register_consolefunction pstore_registerfunction pstore_unregisterfunction decompress_recordfunction pstore_get_backend_recordsfunction pstore_doworkfunction pstore_timefuncfunction pstore_initfunction pstore_exitexport pstore_type_to_nameexport pstore_name_to_typeexport pstore_registerexport pstore_unregister
Annotated Snippet
if (!raw_spin_trylock_irqsave(&psinfo->buf_lock, flags)) {
pr_err("dump skipped in %s path because of concurrent dump\n",
in_nmi() ? "NMI" : why);
return;
}
} else {
raw_spin_lock_irqsave(&psinfo->buf_lock, flags);
}
kmsg_dump_rewind(&iter);
oopscount++;
while (total < remaining) {
char *dst;
size_t dst_size;
int header_size;
int zipped_len = -1;
size_t dump_size;
struct pstore_record record;
pstore_record_init(&record, psinfo);
record.type = PSTORE_TYPE_DMESG;
record.count = oopscount;
record.reason = detail->reason;
record.part = part;
record.buf = psinfo->buf;
dst = big_oops_buf ?: psinfo->buf;
dst_size = max_compressed_size ?: psinfo->bufsize;
/* Write dump header. */
header_size = snprintf(dst, dst_size, "%s#%d Part%u\n", why,
oopscount, part);
dst_size -= header_size;
/* Write dump contents. */
if (!kmsg_dump_get_buffer(&iter, true, dst + header_size,
dst_size, &dump_size))
break;
if (big_oops_buf) {
zipped_len = pstore_compress(dst, psinfo->buf,
header_size + dump_size,
psinfo->bufsize);
if (zipped_len > 0) {
record.compressed = true;
record.size = zipped_len;
} else {
/*
* Compression failed, so the buffer is most
* likely filled with binary data that does not
* compress as well as ASCII text. Copy as much
* of the uncompressed data as possible into
* the pstore record, and discard the rest.
*/
record.size = psinfo->bufsize;
memcpy(psinfo->buf, dst, psinfo->bufsize);
}
} else {
record.size = header_size + dump_size;
}
ret = psinfo->write(&record);
if (ret == 0 && detail->reason == KMSG_DUMP_OOPS) {
pstore_new_entry = 1;
pstore_timer_kick();
} else {
/* Preserve only the first non-zero returned value. */
if (!saved_ret)
saved_ret = ret;
}
total += record.size;
part++;
}
raw_spin_unlock_irqrestore(&psinfo->buf_lock, flags);
if (saved_ret) {
pr_err_once("backend (%s) writing error (%d)\n", psinfo->name,
saved_ret);
}
}
static struct kmsg_dumper pstore_dumper = {
.dump = pstore_dump,
};
/*
* Register with kmsg_dump to save last part of console log on panic.
Annotation
- Immediate include surface: `linux/atomic.h`, `linux/types.h`, `linux/errno.h`, `linux/init.h`, `linux/kmsg_dump.h`, `linux/console.h`, `linux/mm.h`, `linux/module.h`.
- Detected declarations: `function pstore_set_kmsg_bytes`, `function pstore_name_to_type`, `function pstore_timer_kick`, `function pstore_cannot_block_path`, `function pstore_compress`, `function allocate_buf_for_compression`, `function free_buf_for_compression`, `function pstore_record_init`, `function pstore_dump`, `function pstore_register_kmsg`.
- 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.