Skip to content

Commit a9efd39

Browse files
Seiji Aguchiaegl
authored andcommitted
efi_pstore: Add ctime to argument of erase callback
[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:12345678, 23456789 [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>
1 parent 96480d9 commit a9efd39

5 files changed

Lines changed: 14 additions & 14 deletions

File tree

‎drivers/acpi/apei/erst.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
938938
u64 *id, unsigned int part,
939939
size_t size, struct pstore_info *psi);
940940
static int erst_clearer(enum pstore_type_id type, u64 id,
941-
struct pstore_info *psi);
941+
struct timespec time, struct pstore_info *psi);
942942

943943
static struct pstore_info erst_info = {
944944
.owner = THIS_MODULE,
@@ -1102,7 +1102,7 @@ static int erst_writer(enum pstore_type_id type, enum kmsg_dump_reason reason,
11021102
}
11031103

11041104
static int erst_clearer(enum pstore_type_id type, u64 id,
1105-
struct pstore_info *psi)
1105+
struct timespec time, struct pstore_info *psi)
11061106
{
11071107
return erst_clear(id);
11081108
}

‎drivers/firmware/efivars.c‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -747,24 +747,25 @@ static int efi_pstore_write(enum pstore_type_id type,
747747
};
748748

749749
static int efi_pstore_erase(enum pstore_type_id type, u64 id,
750-
struct pstore_info *psi)
750+
struct timespec time, struct pstore_info *psi)
751751
{
752-
char stub_name[DUMP_NAME_LEN];
752+
char name[DUMP_NAME_LEN];
753753
efi_char16_t efi_name[DUMP_NAME_LEN];
754754
efi_guid_t vendor = LINUX_EFI_CRASH_GUID;
755755
struct efivars *efivars = psi->data;
756756
struct efivar_entry *entry, *found = NULL;
757757
int i;
758758

759-
sprintf(stub_name, "dump-type%u-%u-", type, (unsigned int)id);
759+
sprintf(name, "dump-type%u-%u-%lu", type, (unsigned int)id,
760+
time.tv_sec);
760761

761762
spin_lock(&efivars->lock);
762763

763764
for (i = 0; i < DUMP_NAME_LEN; i++)
764-
efi_name[i] = stub_name[i];
765+
efi_name[i] = name[i];
765766

766767
/*
767-
* Clean up any entries with the same name
768+
* Clean up an entry with the same name
768769
*/
769770

770771
list_for_each_entry(entry, &efivars->list, list) {
@@ -775,16 +776,14 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id,
775776
if (utf16_strncmp(entry->var.VariableName, efi_name,
776777
utf16_strlen(efi_name)))
777778
continue;
778-
/* Needs to be a prefix */
779-
if (entry->var.VariableName[utf16_strlen(efi_name)] == 0)
780-
continue;
781779

782780
/* found */
783781
found = entry;
784782
efivars->ops->set_variable(entry->var.VariableName,
785783
&entry->var.VendorGuid,
786784
PSTORE_EFI_ATTRIBUTES,
787785
0, NULL);
786+
break;
788787
}
789788

790789
if (found)
@@ -823,7 +822,7 @@ static int efi_pstore_write(enum pstore_type_id type,
823822
}
824823

825824
static int efi_pstore_erase(enum pstore_type_id type, u64 id,
826-
struct pstore_info *psi)
825+
struct timespec time, struct pstore_info *psi)
827826
{
828827
return 0;
829828
}

‎fs/pstore/inode.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ static int pstore_unlink(struct inode *dir, struct dentry *dentry)
175175
struct pstore_private *p = dentry->d_inode->i_private;
176176

177177
if (p->psi->erase)
178-
p->psi->erase(p->type, p->id, p->psi);
178+
p->psi->erase(p->type, p->id, dentry->d_inode->i_ctime,
179+
p->psi);
179180

180181
return simple_unlink(dir, dentry);
181182
}

‎fs/pstore/ram.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ static int notrace ramoops_pstore_write_buf(enum pstore_type_id type,
237237
}
238238

239239
static int ramoops_pstore_erase(enum pstore_type_id type, u64 id,
240-
struct pstore_info *psi)
240+
struct timespec time, struct pstore_info *psi)
241241
{
242242
struct ramoops_context *cxt = psi->data;
243243
struct persistent_ram_zone *prz;

‎include/linux/pstore.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ struct pstore_info {
6060
unsigned int part, const char *buf, size_t size,
6161
struct pstore_info *psi);
6262
int (*erase)(enum pstore_type_id type, u64 id,
63-
struct pstore_info *psi);
63+
struct timespec time, struct pstore_info *psi);
6464
void *data;
6565
};
6666

0 commit comments

Comments
 (0)