Lines Matching +full:no +full:- +full:dump +full:- +full:oops
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Persistent Storage - platform driver interface parts.
5 * Copyright (C) 2007-2008 Google, Inc.
32 * We defer making "oops" entries appear in pstore - see
36 static int pstore_update_ms = -1;
39 "(default is -1, which means runtime updates are disabled; "
50 "powerpc-ofw",
51 "powerpc-common",
53 "powerpc-opal",
77 * pstore no longer implements compression via the crypto API, and only
102 * Compression is only used for dmesg output, which consists of low-entropy
103 * ASCII text, and so we can assume worst-case 60%.
186 return -EINVAL; in pstore_compress()
189 -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY); in pstore_compress()
191 return -EINVAL; in pstore_compress()
195 return -EINVAL; in pstore_compress()
209 /* Skip if not built-in or compression disabled. */ in allocate_buf_for_compression()
227 compressed_size = (psinfo->bufsize * 100) / DMESG_COMP_PERCENT; in allocate_buf_for_compression()
231 psinfo->bufsize, compress); in allocate_buf_for_compression()
243 /* A non-NULL big_oops_buf indicates compression is available. */ in allocate_buf_for_compression()
247 pr_info("Using crash dump compression: %s\n", compress); in allocate_buf_for_compression()
267 record->psi = psinfo; in pstore_record_init()
270 record->time = ns_to_timespec64(ktime_get_real_fast_ns()); in pstore_record_init()
288 why = kmsg_dump_reason_str(detail->reason); in pstore_dump()
290 if (pstore_cannot_block_path(detail->reason)) { in pstore_dump()
291 if (!raw_spin_trylock_irqsave(&psinfo->buf_lock, flags)) { in pstore_dump()
292 pr_err("dump skipped in %s path because of concurrent dump\n", in pstore_dump()
297 raw_spin_lock_irqsave(&psinfo->buf_lock, flags); in pstore_dump()
307 int zipped_len = -1; in pstore_dump()
314 record.reason = detail->reason; in pstore_dump()
316 record.buf = psinfo->buf; in pstore_dump()
318 dst = big_oops_buf ?: psinfo->buf; in pstore_dump()
319 dst_size = max_compressed_size ?: psinfo->bufsize; in pstore_dump()
321 /* Write dump header. */ in pstore_dump()
324 dst_size -= header_size; in pstore_dump()
326 /* Write dump contents. */ in pstore_dump()
332 zipped_len = pstore_compress(dst, psinfo->buf, in pstore_dump()
334 psinfo->bufsize); in pstore_dump()
347 record.size = psinfo->bufsize; in pstore_dump()
348 memcpy(psinfo->buf, dst, psinfo->bufsize); in pstore_dump()
354 ret = psinfo->write(&record); in pstore_dump()
355 if (ret == 0 && detail->reason == KMSG_DUMP_OOPS) { in pstore_dump()
359 /* Preserve only the first non-zero returned value. */ in pstore_dump()
367 raw_spin_unlock_irqrestore(&psinfo->buf_lock, flags); in pstore_dump()
370 pr_err_once("backend (%s) writing error (%d)\n", psinfo->name, in pstore_dump()
376 .dump = pstore_dump,
405 psinfo->write(&record); in pstore_console_write()
410 .index = -1,
416 strscpy(pstore_console.name, psinfo->name, in pstore_register_console()
440 if (record->buf) in pstore_write_user_compat()
441 return -EINVAL; in pstore_write_user_compat()
443 record->buf = vmemdup_user(buf, record->size); in pstore_write_user_compat()
444 if (IS_ERR(record->buf)) { in pstore_write_user_compat()
445 ret = PTR_ERR(record->buf); in pstore_write_user_compat()
449 ret = record->psi->write(record); in pstore_write_user_compat()
451 kvfree(record->buf); in pstore_write_user_compat()
453 record->buf = NULL; in pstore_write_user_compat()
455 return unlikely(ret < 0) ? ret : record->size; in pstore_write_user_compat()
469 if (backend && strcmp(backend, psi->name)) { in pstore_register()
471 backend, psi->name); in pstore_register()
472 return -EBUSY; in pstore_register()
476 if (!psi->flags) { in pstore_register()
478 psi->name); in pstore_register()
479 return -EINVAL; in pstore_register()
483 if (!psi->read || !psi->write) { in pstore_register()
485 psi->name); in pstore_register()
486 return -EINVAL; in pstore_register()
489 new_backend = kstrdup(psi->name, GFP_KERNEL); in pstore_register()
491 return -ENOMEM; in pstore_register()
496 psinfo->name, psi->name); in pstore_register()
499 return -EBUSY; in pstore_register()
502 if (!psi->write_user) in pstore_register()
503 psi->write_user = pstore_write_user_compat; in pstore_register()
505 mutex_init(&psinfo->read_mutex); in pstore_register()
506 raw_spin_lock_init(&psinfo->buf_lock); in pstore_register()
508 if (psi->flags & PSTORE_FLAGS_DMESG) in pstore_register()
513 if (psi->flags & PSTORE_FLAGS_DMESG) { in pstore_register()
514 pstore_dumper.max_reason = psinfo->max_reason; in pstore_register()
517 if (psi->flags & PSTORE_FLAGS_CONSOLE) in pstore_register()
519 if (psi->flags & PSTORE_FLAGS_FTRACE) in pstore_register()
521 if (psi->flags & PSTORE_FLAGS_PMSG) in pstore_register()
533 pr_info("Registered %s as persistent store backend\n", psi->name); in pstore_register()
555 if (psi->flags & PSTORE_FLAGS_PMSG) in pstore_unregister()
557 if (psi->flags & PSTORE_FLAGS_FTRACE) in pstore_unregister()
559 if (psi->flags & PSTORE_FLAGS_CONSOLE) in pstore_unregister()
561 if (psi->flags & PSTORE_FLAGS_DMESG) in pstore_unregister()
577 pr_info("Unregistered %s as persistent store backend\n", psi->name); in pstore_unregister()
590 if (!IS_ENABLED(CONFIG_PSTORE_COMPRESS) || !record->compressed) in decompress_record()
594 if (record->type != PSTORE_TYPE_DMESG) { in decompress_record()
595 pr_warn("ignored compressed record type %d\n", record->type); in decompress_record()
600 if (!zstream->workspace) { in decompress_record()
601 pr_warn("no decompression method initialized!\n"); in decompress_record()
612 max_uncompressed_size = 3 * psinfo->bufsize; in decompress_record()
613 workspace = kvzalloc(max_uncompressed_size + record->ecc_notice_size, in decompress_record()
618 zstream->next_in = record->buf; in decompress_record()
619 zstream->avail_in = record->size; in decompress_record()
620 zstream->next_out = workspace; in decompress_record()
621 zstream->avail_out = max_uncompressed_size; in decompress_record()
630 unzipped_len = zstream->total_out; in decompress_record()
633 memcpy(workspace + unzipped_len, record->buf + record->size, in decompress_record()
634 record->ecc_notice_size); in decompress_record()
636 /* Copy decompressed contents into an minimum-sized allocation. */ in decompress_record()
637 unzipped = kvmemdup(workspace, unzipped_len + record->ecc_notice_size, in decompress_record()
644 kvfree(record->buf); in decompress_record()
645 record->buf = unzipped; in decompress_record()
646 record->size = unzipped_len; in decompress_record()
647 record->compressed = false; in decompress_record()
652 * files in our filesystem. Don't warn about -EEXIST errors
653 * when we are re-scanning the backing store looking to add new
669 zlib_inflateInit2(&zstream, -DEF_WBITS); in pstore_get_backend_records()
672 mutex_lock(&psi->read_mutex); in pstore_get_backend_records()
673 if (psi->open && psi->open(psi)) in pstore_get_backend_records()
681 for (; stop_loop; stop_loop--) { in pstore_get_backend_records()
692 record->size = psi->read(record); in pstore_get_backend_records()
694 /* No more records left in backend? */ in pstore_get_backend_records()
695 if (record->size <= 0) { in pstore_get_backend_records()
704 kvfree(record->buf); in pstore_get_backend_records()
705 kfree(record->priv); in pstore_get_backend_records()
707 if (rc != -EEXIST || !quiet) in pstore_get_backend_records()
711 if (psi->close) in pstore_get_backend_records()
712 psi->close(psi); in pstore_get_backend_records()
714 mutex_unlock(&psi->read_mutex); in pstore_get_backend_records()
724 failed, psi->name); in pstore_get_backend_records()
727 psi->name); in pstore_get_backend_records()
764 MODULE_DESCRIPTION("Persistent Storage - platform driver interface");