diff options
author | Madper Xie <cxie@redhat.com> | 2013-11-29 02:58:57 -0500 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2013-11-29 05:11:06 -0500 |
commit | fdeadb43fdf1e7d5698c027b555c389174548e5a (patch) | |
tree | c71e65562836636719d6b7b5ef706120b91dc734 /drivers/firmware/efi/efi-pstore.c | |
parent | 1f3a8bae21a22808f242ccfb22aca37a635e261e (diff) |
efi-pstore: Make efi-pstore return a unique id
Pstore fs expects that backends provide a unique id which could avoid
pstore making entries as duplication or denominating entries the same
name. So I combine the timestamp, part and count into id.
Signed-off-by: Madper Xie <cxie@redhat.com>
Cc: Seiji Aguchi <seiji.aguchi@hds.com>
Cc: stable@vger.kernel.org
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
Diffstat (limited to 'drivers/firmware/efi/efi-pstore.c')
-rw-r--r-- | drivers/firmware/efi/efi-pstore.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c index 6ce31e93da55..743fd426f21b 100644 --- a/drivers/firmware/efi/efi-pstore.c +++ b/drivers/firmware/efi/efi-pstore.c | |||
@@ -37,6 +37,12 @@ struct pstore_read_data { | |||
37 | char **buf; | 37 | char **buf; |
38 | }; | 38 | }; |
39 | 39 | ||
40 | static inline u64 generic_id(unsigned long timestamp, | ||
41 | unsigned int part, int count) | ||
42 | { | ||
43 | return (timestamp * 100 + part) * 1000 + count; | ||
44 | } | ||
45 | |||
40 | static int efi_pstore_read_func(struct efivar_entry *entry, void *data) | 46 | static int efi_pstore_read_func(struct efivar_entry *entry, void *data) |
41 | { | 47 | { |
42 | efi_guid_t vendor = LINUX_EFI_CRASH_GUID; | 48 | efi_guid_t vendor = LINUX_EFI_CRASH_GUID; |
@@ -55,7 +61,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data) | |||
55 | 61 | ||
56 | if (sscanf(name, "dump-type%u-%u-%d-%lu-%c", | 62 | if (sscanf(name, "dump-type%u-%u-%d-%lu-%c", |
57 | cb_data->type, &part, &cnt, &time, &data_type) == 5) { | 63 | cb_data->type, &part, &cnt, &time, &data_type) == 5) { |
58 | *cb_data->id = part; | 64 | *cb_data->id = generic_id(time, part, cnt); |
59 | *cb_data->count = cnt; | 65 | *cb_data->count = cnt; |
60 | cb_data->timespec->tv_sec = time; | 66 | cb_data->timespec->tv_sec = time; |
61 | cb_data->timespec->tv_nsec = 0; | 67 | cb_data->timespec->tv_nsec = 0; |
@@ -65,7 +71,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data) | |||
65 | *cb_data->compressed = false; | 71 | *cb_data->compressed = false; |
66 | } else if (sscanf(name, "dump-type%u-%u-%d-%lu", | 72 | } else if (sscanf(name, "dump-type%u-%u-%d-%lu", |
67 | cb_data->type, &part, &cnt, &time) == 4) { | 73 | cb_data->type, &part, &cnt, &time) == 4) { |
68 | *cb_data->id = part; | 74 | *cb_data->id = generic_id(time, part, cnt); |
69 | *cb_data->count = cnt; | 75 | *cb_data->count = cnt; |
70 | cb_data->timespec->tv_sec = time; | 76 | cb_data->timespec->tv_sec = time; |
71 | cb_data->timespec->tv_nsec = 0; | 77 | cb_data->timespec->tv_nsec = 0; |
@@ -77,7 +83,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data) | |||
77 | * which doesn't support holding | 83 | * which doesn't support holding |
78 | * multiple logs, remains. | 84 | * multiple logs, remains. |
79 | */ | 85 | */ |
80 | *cb_data->id = part; | 86 | *cb_data->id = generic_id(time, part, 0); |
81 | *cb_data->count = 0; | 87 | *cb_data->count = 0; |
82 | cb_data->timespec->tv_sec = time; | 88 | cb_data->timespec->tv_sec = time; |
83 | cb_data->timespec->tv_nsec = 0; | 89 | cb_data->timespec->tv_nsec = 0; |
@@ -320,14 +326,16 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count, | |||
320 | char name[DUMP_NAME_LEN]; | 326 | char name[DUMP_NAME_LEN]; |
321 | efi_char16_t efi_name[DUMP_NAME_LEN]; | 327 | efi_char16_t efi_name[DUMP_NAME_LEN]; |
322 | int found, i; | 328 | int found, i; |
329 | unsigned int part; | ||
323 | 330 | ||
324 | sprintf(name, "dump-type%u-%u-%d-%lu", type, (unsigned int)id, count, | 331 | do_div(id, 1000); |
325 | time.tv_sec); | 332 | part = do_div(id, 100); |
333 | sprintf(name, "dump-type%u-%u-%d-%lu", type, part, count, time.tv_sec); | ||
326 | 334 | ||
327 | for (i = 0; i < DUMP_NAME_LEN; i++) | 335 | for (i = 0; i < DUMP_NAME_LEN; i++) |
328 | efi_name[i] = name[i]; | 336 | efi_name[i] = name[i]; |
329 | 337 | ||
330 | edata.id = id; | 338 | edata.id = part; |
331 | edata.type = type; | 339 | edata.type = type; |
332 | edata.count = count; | 340 | edata.count = count; |
333 | edata.time = time; | 341 | edata.time = time; |