Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ee1d2674 authored by Geliang Tang's avatar Geliang Tang Committed by Tony Luck
Browse files

pstore: add pstore unregister



pstore doesn't support unregistering yet. It was marked as TODO.
This patch adds some code to fix it:
 1) Add functions to unregister kmsg/console/ftrace/pmsg.
 2) Add a function to free compression buffer.
 3) Unmap the memory and free it.
 4) Add a function to unregister pstore filesystem.

Signed-off-by: default avatarGeliang Tang <geliangtang@163.com>
Acked-by: default avatarKees Cook <keescook@chromium.org>
[Removed __exit annotation from ramoops_remove(). Reported by Arnd Bergmann]
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
parent 18730411
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
config PSTORE
	bool "Persistent store support"
	tristate "Persistent store support"
	default n
	select ZLIB_DEFLATE
	select ZLIB_INFLATE
+3 −3
Original line number Diff line number Diff line
@@ -2,12 +2,12 @@
# Makefile for the linux pstorefs routines.
#

obj-y += pstore.o
obj-$(CONFIG_PSTORE) += pstore.o

pstore-objs += inode.o platform.o
obj-$(CONFIG_PSTORE_FTRACE)	+= ftrace.o
pstore-$(CONFIG_PSTORE_FTRACE)	+= ftrace.o

obj-$(CONFIG_PSTORE_PMSG)	+= pmsg.o
pstore-$(CONFIG_PSTORE_PMSG)	+= pmsg.o

ramoops-objs += ram.o ram_core.o
obj-$(CONFIG_PSTORE_RAM)	+= ramoops.o
+19 −6
Original line number Diff line number Diff line
@@ -104,22 +104,23 @@ static const struct file_operations pstore_knob_fops = {
	.write	= pstore_ftrace_knob_write,
};

static struct dentry *pstore_ftrace_dir;

void pstore_register_ftrace(void)
{
	struct dentry *dir;
	struct dentry *file;

	if (!psinfo->write_buf)
		return;

	dir = debugfs_create_dir("pstore", NULL);
	if (!dir) {
	pstore_ftrace_dir = debugfs_create_dir("pstore", NULL);
	if (!pstore_ftrace_dir) {
		pr_err("%s: unable to create pstore directory\n", __func__);
		return;
	}

	file = debugfs_create_file("record_ftrace", 0600, dir, NULL,
				   &pstore_knob_fops);
	file = debugfs_create_file("record_ftrace", 0600, pstore_ftrace_dir,
				   NULL, &pstore_knob_fops);
	if (!file) {
		pr_err("%s: unable to create record_ftrace file\n", __func__);
		goto err_file;
@@ -127,5 +128,17 @@ void pstore_register_ftrace(void)

	return;
err_file:
	debugfs_remove(dir);
	debugfs_remove(pstore_ftrace_dir);
}

void pstore_unregister_ftrace(void)
{
	mutex_lock(&pstore_ftrace_lock);
	if (pstore_ftrace_enabled) {
		unregister_ftrace_function(&pstore_ftrace_ops);
		pstore_ftrace_enabled = 0;
	}
	mutex_unlock(&pstore_ftrace_lock);

	debugfs_remove_recursive(pstore_ftrace_dir);
}
+9 −0
Original line number Diff line number Diff line
@@ -178,6 +178,7 @@ static loff_t pstore_file_llseek(struct file *file, loff_t off, int whence)
}

static const struct file_operations pstore_file_operations = {
	.owner		= THIS_MODULE,
	.open		= pstore_file_open,
	.read		= pstore_file_read,
	.llseek		= pstore_file_llseek,
@@ -456,6 +457,7 @@ static void pstore_kill_sb(struct super_block *sb)
}

static struct file_system_type pstore_fs_type = {
	.owner          = THIS_MODULE,
	.name		= "pstore",
	.mount		= pstore_mount,
	.kill_sb	= pstore_kill_sb,
@@ -479,5 +481,12 @@ static int __init init_pstore_fs(void)
}
module_init(init_pstore_fs)

static void __exit exit_pstore_fs(void)
{
	unregister_filesystem(&pstore_fs_type);
	sysfs_remove_mount_point(fs_kobj, "pstore");
}
module_exit(exit_pstore_fs)

MODULE_AUTHOR("Tony Luck <tony.luck@intel.com>");
MODULE_LICENSE("GPL");
+4 −0
Original line number Diff line number Diff line
@@ -41,14 +41,18 @@ pstore_ftrace_decode_cpu(struct pstore_ftrace_record *rec)

#ifdef CONFIG_PSTORE_FTRACE
extern void pstore_register_ftrace(void);
extern void pstore_unregister_ftrace(void);
#else
static inline void pstore_register_ftrace(void) {}
static inline void pstore_unregister_ftrace(void) {}
#endif

#ifdef CONFIG_PSTORE_PMSG
extern void pstore_register_pmsg(void);
extern void pstore_unregister_pmsg(void);
#else
static inline void pstore_register_pmsg(void) {}
static inline void pstore_unregister_pmsg(void) {}
#endif

extern struct pstore_info *psinfo;
Loading