
From: Vasile-Laurentiu Stanimir <vasile-laurentiu.stanimir@windriver.com> mainline inclusion from mainline-5.10 category: feature commit:26fecbf7602dd69b649914e61526bd67c557fece issue: #I4919J -------------------------------- While kmsg_bytes can be set for pstore via mount, if a crash occurs before the mount only partial console log will be stored as kmsg_bytes defaults to a potentially different hardcoded value in the kernel (PSTORE_DEFAULT_KMSG_BYTES). This makes it impossible to analyze valuable post-mortem data especially on the embedded development or in the process of bringing up new boards. Change this value to be a Kconfig option with the default of old PSTORE_DEFAULT_KMSG_BYTES Signed-off-by: Vasile-Laurentiu Stanimir <vasile-laurentiu.stanimir@windriver.com> Signed-off-by: Kees Cook <keescook@chromium.org> (cherry picked from commit 26fecbf7602dd69b649914e61526bd67c557fece) Signed-off-by: roger <kongzhengrong@huawei.com> --- fs/pstore/Kconfig | 8 ++++++++ fs/pstore/inode.c | 2 +- fs/pstore/internal.h | 1 - fs/pstore/platform.c | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/fs/pstore/Kconfig b/fs/pstore/Kconfig index 0f5a4bdb3b34..e0ac6601a928 100644 --- a/fs/pstore/Kconfig +++ b/fs/pstore/Kconfig @@ -13,6 +13,14 @@ config PSTORE If you don't have a platform persistent store driver, say N. +config PSTORE_DEFAULT_KMSG_BYTES + int "Default kernel log storage space" if EXPERT + depends on PSTORE + default "10240" + help + Defines default size of pstore kernel log storage. + Can be enlarged if needed, not recommended to shrink it. + config PSTORE_DEFLATE_COMPRESS tristate "DEFLATE (ZLIB) compression" default y diff --git a/fs/pstore/inode.c b/fs/pstore/inode.c index c29e4d4a3359..b4836705d220 100644 --- a/fs/pstore/inode.c +++ b/fs/pstore/inode.c @@ -276,7 +276,7 @@ static void parse_options(char *options) */ static int pstore_show_options(struct seq_file *m, struct dentry *root) { - if (kmsg_bytes != PSTORE_DEFAULT_KMSG_BYTES) + if (kmsg_bytes != CONFIG_PSTORE_DEFAULT_KMSG_BYTES) seq_printf(m, ",kmsg_bytes=%lu", kmsg_bytes); return 0; } diff --git a/fs/pstore/internal.h b/fs/pstore/internal.h index 7783db28ce4a..b82e074853ec 100644 --- a/fs/pstore/internal.h +++ b/fs/pstore/internal.h @@ -6,7 +6,6 @@ #include <linux/time.h> #include <linux/pstore.h> -#define PSTORE_DEFAULT_KMSG_BYTES 10240 extern unsigned long kmsg_bytes; #ifdef CONFIG_PSTORE_FTRACE diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index 216c3247a2c6..b0703d0278b4 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c @@ -112,7 +112,7 @@ static char *big_oops_buf; static size_t big_oops_buf_sz; /* How much of the console log to snapshot */ -unsigned long kmsg_bytes = PSTORE_DEFAULT_KMSG_BYTES; +unsigned long kmsg_bytes = CONFIG_PSTORE_DEFAULT_KMSG_BYTES; void pstore_set_kmsg_bytes(int bytes) { -- 2.17.1