pstore: Split pstore fragile flags
authorNamhyung Kim <namhyung@kernel.org>
Wed, 27 Jul 2016 15:08:25 +0000 (00:08 +0900)
committerKees Cook <keescook@chromium.org>
Thu, 8 Sep 2016 22:01:08 +0000 (15:01 -0700)
This patch adds new PSTORE_FLAGS for each pstore type so that they can
be enabled separately.  This is a preparation for ongoing virtio-pstore
work to support those types flexibly.

The PSTORE_FLAGS_FRAGILE is changed to PSTORE_FLAGS_DMESG to preserve the
original behavior.

Cc: Anton Vorontsov <anton@enomsg.org>
Cc: Colin Cross <ccross@android.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Tony Luck <tony.luck@intel.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Len Brown <lenb@kernel.org>
Cc: Matt Fleming <matt@codeblueprint.co.uk>
Cc: linux-acpi@vger.kernel.org
Cc: linux-efi@vger.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
[kees: retained "FRAGILE" for now to make merges easier]
Signed-off-by: Kees Cook <keescook@chromium.org>
drivers/acpi/apei/erst.c
drivers/firmware/efi/efi-pstore.c
fs/pstore/platform.c
fs/pstore/ram.c
include/linux/pstore.h

index f096ab3cb54d6f8b67fa1c7dee4cf0d4cc5179e2..ec4f507b524fa81343c44d0da039a19e468da5c4 100644 (file)
@@ -938,7 +938,7 @@ static int erst_clearer(enum pstore_type_id type, u64 id, int count,
 static struct pstore_info erst_info = {
        .owner          = THIS_MODULE,
        .name           = "erst",
-       .flags          = PSTORE_FLAGS_FRAGILE,
+       .flags          = PSTORE_FLAGS_DMESG,
        .open           = erst_open_pstore,
        .close          = erst_close_pstore,
        .read           = erst_reader,
index 30a24d09ea6cf712da643aee9adaac010b0e9473..4daa5acd9117b12ae245ee0f1eb1831ef95a2600 100644 (file)
@@ -362,7 +362,7 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count,
 static struct pstore_info efi_pstore_info = {
        .owner          = THIS_MODULE,
        .name           = "efi",
-       .flags          = PSTORE_FLAGS_FRAGILE,
+       .flags          = PSTORE_FLAGS_DMESG,
        .open           = efi_pstore_open,
        .close          = efi_pstore_close,
        .read           = efi_pstore_read,
index 16ecca5b72d815d92163def3f03bd9f26c4cc8b1..76dd604a0f2cc9ec3b19670357250ad21f95d40b 100644 (file)
@@ -659,13 +659,14 @@ int pstore_register(struct pstore_info *psi)
        if (pstore_is_mounted())
                pstore_get_records(0);
 
-       pstore_register_kmsg();
-
-       if ((psi->flags & PSTORE_FLAGS_FRAGILE) == 0) {
+       if (psi->flags & PSTORE_FLAGS_DMESG)
+               pstore_register_kmsg();
+       if (psi->flags & PSTORE_FLAGS_CONSOLE)
                pstore_register_console();
+       if (psi->flags & PSTORE_FLAGS_FTRACE)
                pstore_register_ftrace();
+       if (psi->flags & PSTORE_FLAGS_PMSG)
                pstore_register_pmsg();
-       }
 
        if (pstore_update_ms >= 0) {
                pstore_timer.expires = jiffies +
@@ -689,12 +690,14 @@ EXPORT_SYMBOL_GPL(pstore_register);
 
 void pstore_unregister(struct pstore_info *psi)
 {
-       if ((psi->flags & PSTORE_FLAGS_FRAGILE) == 0) {
+       if (psi->flags & PSTORE_FLAGS_PMSG)
                pstore_unregister_pmsg();
+       if (psi->flags & PSTORE_FLAGS_FTRACE)
                pstore_unregister_ftrace();
+       if (psi->flags & PSTORE_FLAGS_CONSOLE)
                pstore_unregister_console();
-       }
-       pstore_unregister_kmsg();
+       if (psi->flags & PSTORE_FLAGS_DMESG)
+               pstore_unregister_kmsg();
 
        free_buf_for_compression();
 
index 2340262a7e974ee759c86bb6df88f018ac0f970b..c2ebf5084977bafaa2566e4e010040d8ed2b7f47 100644 (file)
@@ -623,6 +623,8 @@ static int ramoops_probe(struct platform_device *pdev)
                goto fail_clear;
        }
 
+       cxt->pstore.flags = PSTORE_FLAGS_ALL;
+
        err = pstore_register(&cxt->pstore);
        if (err) {
                pr_err("registering with pstore failed\n");
index 899e95e844006d9b2eb7ff1ecc41b9e40cc076a6..f5806b2a6f7a440870c913111d305d0788e5c192 100644 (file)
@@ -74,7 +74,13 @@ struct pstore_info {
        void            *data;
 };
 
-#define        PSTORE_FLAGS_FRAGILE    1
+#define PSTORE_FLAGS_DMESG     (1 << 0)
+#define PSTORE_FLAGS_FRAGILE   PSTORE_FLAGS_DMESG
+#define PSTORE_FLAGS_CONSOLE   (1 << 1)
+#define PSTORE_FLAGS_FTRACE    (1 << 2)
+#define PSTORE_FLAGS_PMSG      (1 << 3)
+
+#define PSTORE_FLAGS_ALL       ((1 << 4) - 1)
 
 extern int pstore_register(struct pstore_info *);
 extern void pstore_unregister(struct pstore_info *);