]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
efi_pstore: Add ctime to argument of erase callback
authorSeiji Aguchi <seiji.aguchi@hds.com>
Wed, 14 Nov 2012 20:27:28 +0000 (20:27 +0000)
committerTony Luck <tony.luck@intel.com>
Tue, 27 Nov 2012 00:02:12 +0000 (16:02 -0800)
[Issue]

Currently, a variable name, which is used to identify each log entry, consists of type,
id and ctime. But an erase callback does not use ctime.

If efi_pstore supported just one log, type and id were enough.
However, in case of supporting multiple logs, it doesn't work because
it can't distinguish each entry without ctime at erasing time.

 <Example>

 As you can see below, efi_pstore can't differentiate first event from second one without ctime.

 a variable name of first event: dump-type0-1-12345678
 a variable name of second event: dump-type0-1-23456789

  type:0
  id:1
  ctime:1234567823456789

[Solution]

This patch adds ctime to an argument of an erase callback.

It works across reboots because ctime of pstore means the date that the record was originally stored.
To do this, efi_pstore saves the ctime to variable name at writing time and passes it to pstore
at reading time.

Signed-off-by: Seiji Aguchi <seiji.aguchi@hds.com>
Acked-by: Mike Waychison <mikew@google.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
drivers/acpi/apei/erst.c
drivers/firmware/efivars.c
fs/pstore/inode.c
fs/pstore/ram.c
include/linux/pstore.h

index e4d9d24eb73dda047655ac018ed45b6259effedb..0bd6ae4a899fbdf1aa21b6ca7165ce4a76e19b7e 100644 (file)
@@ -938,7 +938,7 @@ static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
                       u64 *id, unsigned int part,
                       size_t size, struct pstore_info *psi);
 static int erst_clearer(enum pstore_type_id type, u64 id,
-                       struct pstore_info *psi);
+                       struct timespec time, struct pstore_info *psi);
 
 static struct pstore_info erst_info = {
        .owner          = THIS_MODULE,
@@ -1102,7 +1102,7 @@ static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
 }
 
 static int erst_clearer(enum pstore_type_id type, u64 id,
-                       struct pstore_info *psi)
+                       struct timespec time, struct pstore_info *psi)
 {
        return erst_clear(id);
 }
index fbe9202c267866ee8301382b95f3ae566674ec6c..3803621c0d45f6235897ed860870d14f47217247 100644 (file)
@@ -747,24 +747,25 @@ static int efi_pstore_write(enum pstore_type_id type,
 };
 
 static int efi_pstore_erase(enum pstore_type_id type, u64 id,
-                           struct pstore_info *psi)
+                           struct timespec time, struct pstore_info *psi)
 {
-       char stub_name[DUMP_NAME_LEN];
+       char name[DUMP_NAME_LEN];
        efi_char16_t efi_name[DUMP_NAME_LEN];
        efi_guid_t vendor = LINUX_EFI_CRASH_GUID;
        struct efivars *efivars = psi->data;
        struct efivar_entry *entry, *found = NULL;
        int i;
 
-       sprintf(stub_name, "dump-type%u-%u-", type, (unsigned int)id);
+       sprintf(name, "dump-type%u-%u-%lu", type, (unsigned int)id,
+               time.tv_sec);
 
        spin_lock(&efivars->lock);
 
        for (i = 0; i < DUMP_NAME_LEN; i++)
-               efi_name[i] = stub_name[i];
+               efi_name[i] = name[i];
 
        /*
-        * Clean up any entries with the same name
+        * Clean up an entry with the same name
         */
 
        list_for_each_entry(entry, &efivars->list, list) {
@@ -775,9 +776,6 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id,
                if (utf16_strncmp(entry->var.VariableName, efi_name,
                                  utf16_strlen(efi_name)))
                        continue;
-               /* Needs to be a prefix */
-               if (entry->var.VariableName[utf16_strlen(efi_name)] == 0)
-                       continue;
 
                /* found */
                found = entry;
@@ -785,6 +783,7 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id,
                                           &entry->var.VendorGuid,
                                           PSTORE_EFI_ATTRIBUTES,
                                           0, NULL);
+               break;
        }
 
        if (found)
@@ -823,7 +822,7 @@ static int efi_pstore_write(enum pstore_type_id type,
 }
 
 static int efi_pstore_erase(enum pstore_type_id type, u64 id,
-                           struct pstore_info *psi)
+                           struct timespec time, struct pstore_info *psi)
 {
        return 0;
 }
index 4ab572e6d27782ad40efcdaff5e279b5e4c15daa..4300af6547108ec93ea61cf1942a1bcf747b291c 100644 (file)
@@ -175,7 +175,8 @@ static int pstore_unlink(struct inode *dir, struct dentry *dentry)
        struct pstore_private *p = dentry->d_inode->i_private;
 
        if (p->psi->erase)
-               p->psi->erase(p->type, p->id, p->psi);
+               p->psi->erase(p->type, p->id, dentry->d_inode->i_ctime,
+                             p->psi);
 
        return simple_unlink(dir, dentry);
 }
index 1a4f6da58eab4018878aab4275e1d3b6f3309b37..749693fcb75a6cad7f63dd007b42a3d6e6a9d3d2 100644 (file)
@@ -237,7 +237,7 @@ static int notrace ramoops_pstore_write_buf(enum pstore_type_id type,
 }
 
 static int ramoops_pstore_erase(enum pstore_type_id type, u64 id,
-                               struct pstore_info *psi)
+                               struct timespec time, struct pstore_info *psi)
 {
        struct ramoops_context *cxt = psi->data;
        struct persistent_ram_zone *prz;
index ee3034a408847153c664b20051874066d2150b05..f6e93362d25932b7467f121cefd9274fdd830182 100644 (file)
@@ -60,7 +60,7 @@ struct pstore_info {
                        unsigned int part, const char *buf, size_t size,
                        struct pstore_info *psi);
        int             (*erase)(enum pstore_type_id type, u64 id,
-                       struct pstore_info *psi);
+                       struct timespec time, struct pstore_info *psi);
        void            *data;
 };