[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20200509234103.46544-19-keescook@chromium.org>
Date: Sat, 9 May 2020 16:41:03 -0700
From: Kees Cook <keescook@...omium.org>
To: WeiXiong Liao <liaoweixiong@...winnertech.com>
Cc: Kees Cook <keescook@...omium.org>,
Anton Vorontsov <anton@...msg.org>,
Colin Cross <ccross@...roid.com>,
Tony Luck <tony.luck@...el.com>,
Jonathan Corbet <corbet@....net>,
Miquel Raynal <miquel.raynal@...tlin.com>,
Richard Weinberger <richard@....at>,
Vignesh Raghavendra <vigneshr@...com>,
Petr Mladek <pmladek@...e.com>,
Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
Steven Rostedt <rostedt@...dmis.org>,
Rob Herring <robh@...nel.org>,
Pavel Tatashin <pasha.tatashin@...een.com>,
linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-mtd@...ts.infradead.org
Subject: [PATCH v6 18/18] pstore/blk: Introduce "best_effort" mode
In order to use arbitrary block devices as a pstore backend, provide a
new module param named "best_effort", which will allow using any block
device, even if it has not provided a panic_write callback.
Signed-off-by: Kees Cook <keescook@...omium.org>
---
fs/pstore/blk.c | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/fs/pstore/blk.c b/fs/pstore/blk.c
index 3e67bd4557ea..b7c33ef4c646 100644
--- a/fs/pstore/blk.c
+++ b/fs/pstore/blk.c
@@ -51,6 +51,10 @@ static long ftrace_size = -1;
module_param(ftrace_size, long, 0400);
MODULE_PARM_DESC(ftrace_size, "ftrace size in kbytes");
+static bool best_effort;
+module_param(best_effort, bool, 0400);
+MODULE_PARM_DESC(best_effort, "use best effort to write (i.e. do not require storage driver pstore support, default: off)");
+
/*
* blkdev - the block device to use for pstore storage
*
@@ -388,7 +392,7 @@ static int __register_pstore_blk(unsigned int major, unsigned int flags,
return PTR_ERR(binfo);
/* only allow driver matching the @blkdev */
- if (!binfo->devt || MAJOR(binfo->devt) != major) {
+ if (!binfo->devt || (!best_effort && MAJOR(binfo->devt) != major)) {
pr_debug("invalid major %u (expect %u)\n",
major, MAJOR(binfo->devt));
return -ENODEV;
@@ -532,6 +536,19 @@ int pstore_blk_usr_info(struct pstore_blk_info *info)
}
EXPORT_SYMBOL_GPL(pstore_blk_usr_info);
+static int __init pstore_blk_init(void)
+{
+ int ret = 0;
+
+ mutex_lock(&pstore_blk_lock);
+ if (!pstore_zone_info && best_effort && blkdev[0])
+ ret = __register_pstore_blk(0, 0, NULL);
+ mutex_unlock(&pstore_blk_lock);
+
+ return ret;
+}
+late_initcall(pstore_blk_init);
+
static void __exit pstore_blk_exit(void)
{
mutex_lock(&pstore_blk_lock);
--
2.20.1
Powered by blists - more mailing lists