linux/fs/pstore/zone.c

// SPDX-License-Identifier: GPL-2.0
/*
 * Provide a pstore intermediate backend, organized into kernel memory
 * allocated zones that are then mapped and flushed into a single
 * contiguous region on a storage backend of some kind (block, mtd, etc).
 */

#define pr_fmt(fmt)

#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/mount.h>
#include <linux/printk.h>
#include <linux/fs.h>
#include <linux/pstore_zone.h>
#include <linux/kdev_t.h>
#include <linux/device.h>
#include <linux/namei.h>
#include <linux/fcntl.h>
#include <linux/uio.h>
#include <linux/writeback.h>
#include "internal.h"

/**
 * struct psz_buffer - header of zone to flush to storage
 *
 * @sig: signature to indicate header (PSZ_SIG xor PSZONE-type value)
 * @datalen: length of data in @data
 * @start: offset into @data where the beginning of the stored bytes begin
 * @data: zone data.
 */
struct psz_buffer {};

/**
 * 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 conpressed
 * @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 {};

/**
 * 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 {};

/**
 * 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 {};
static struct psz_context pstore_zone_cxt;

static void psz_flush_all_dirty_zones(struct work_struct *);
static DECLARE_DELAYED_WORK(psz_cleaner, psz_flush_all_dirty_zones);

/**
 * enum psz_flush_mode - flush mode for psz_zone_write()
 *
 * @FLUSH_NONE: do not flush to storage but update data on memory
 * @FLUSH_PART: just flush part of data including meta data to storage
 * @FLUSH_META: just flush meta data of zone to storage
 * @FLUSH_ALL: flush all of zone
 */
enum psz_flush_mode {};

static inline int buffer_datalen(struct pstore_zone *zone)
{}

static inline int buffer_start(struct pstore_zone *zone)
{}

static inline bool is_on_panic(void)
{}

static ssize_t psz_zone_read_buffer(struct pstore_zone *zone, char *buf,
		size_t len, unsigned long off)
{}

static int psz_zone_read_oldbuf(struct pstore_zone *zone, char *buf,
		size_t len, unsigned long off)
{}

static int psz_zone_write(struct pstore_zone *zone,
		enum psz_flush_mode flush_mode, const char *buf,
		size_t len, unsigned long off)
{}

static int psz_flush_dirty_zone(struct pstore_zone *zone)
{}

static int psz_flush_dirty_zones(struct pstore_zone **zones, unsigned int cnt)
{}

static int psz_move_zone(struct pstore_zone *old, struct pstore_zone *new)
{}

static void psz_flush_all_dirty_zones(struct work_struct *work)
{}

static int psz_kmsg_recover_data(struct psz_context *cxt)
{}

static int psz_kmsg_recover_meta(struct psz_context *cxt)
{}

static int psz_kmsg_recover(struct psz_context *cxt)
{}

static int psz_recover_zone(struct psz_context *cxt, struct pstore_zone *zone)
{}

static int psz_recover_zones(struct psz_context *cxt,
		struct pstore_zone **zones, unsigned int cnt)
{}

/**
 * psz_recovery() - recover data from storage
 * @cxt: the context of pstore/zone
 *
 * recovery means reading data back from storage after rebooting
 *
 * Return: 0 on success, others on failure.
 */
static inline int psz_recovery(struct psz_context *cxt)
{}

static int psz_pstore_open(struct pstore_info *psi)
{}

static inline bool psz_old_ok(struct pstore_zone *zone)
{}

static inline bool psz_ok(struct pstore_zone *zone)
{}

static inline int psz_kmsg_erase(struct psz_context *cxt,
		struct pstore_zone *zone, struct pstore_record *record)
{}

static inline int psz_record_erase(struct psz_context *cxt,
		struct pstore_zone *zone)
{}

static int psz_pstore_erase(struct pstore_record *record)
{}

static void psz_write_kmsg_hdr(struct pstore_zone *zone,
		struct pstore_record *record)
{}

/*
 * In case zone is broken, which may occur to MTD device, we try each zones,
 * start at cxt->kmsg_write_cnt.
 */
static inline int notrace psz_kmsg_write_record(struct psz_context *cxt,
		struct pstore_record *record)
{}

static int notrace psz_kmsg_write(struct psz_context *cxt,
		struct pstore_record *record)
{}

static int notrace psz_record_write(struct pstore_zone *zone,
		struct pstore_record *record)
{}

static int notrace psz_pstore_write(struct pstore_record *record)
{}

static struct pstore_zone *psz_read_next_zone(struct psz_context *cxt)
{}

static int psz_kmsg_read_hdr(struct pstore_zone *zone,
		struct pstore_record *record)
{}

static ssize_t psz_kmsg_read(struct pstore_zone *zone,
		struct pstore_record *record)
{}

/* try to combine all ftrace zones */
static ssize_t psz_ftrace_read(struct pstore_zone *zone,
		struct pstore_record *record)
{}

static ssize_t psz_record_read(struct pstore_zone *zone,
		struct pstore_record *record)
{}

static ssize_t psz_pstore_read(struct pstore_record *record)
{}

static struct psz_context pstore_zone_cxt =;

static void psz_free_zone(struct pstore_zone **pszone)
{}

static void psz_free_zones(struct pstore_zone ***pszones, unsigned int *cnt)
{}

static void psz_free_all_zones(struct psz_context *cxt)
{}

static struct pstore_zone *psz_init_zone(enum pstore_type_id type,
		loff_t *off, size_t size)
{}

static struct pstore_zone **psz_init_zones(enum pstore_type_id type,
	loff_t *off, size_t total_size, ssize_t record_size,
	unsigned int *cnt)
{}

static int psz_alloc_zones(struct psz_context *cxt)
{}

/**
 * register_pstore_zone() - register to pstore/zone
 *
 * @info: back-end driver information. See &struct pstore_zone_info.
 *
 * Only one back-end at one time.
 *
 * Return: 0 on success, others on failure.
 */
int register_pstore_zone(struct pstore_zone_info *info)
{}
EXPORT_SYMBOL_GPL();

/**
 * unregister_pstore_zone() - unregister to pstore/zone
 *
 * @info: back-end driver information. See struct pstore_zone_info.
 */
void unregister_pstore_zone(struct pstore_zone_info *info)
{}
EXPORT_SYMBOL_GPL();

MODULE_LICENSE();
MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_DESCRIPTION();