linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] efi-pstore: Make efi-pstore return a unique id
@ 2013-11-23 11:55 Madper Xie
  2013-11-27 11:44 ` Matt Fleming
  0 siblings, 1 reply; 4+ messages in thread
From: Madper Xie @ 2013-11-23 11:55 UTC (permalink / raw)
  To: 'linux-kernel@vger.kernel.org', linux-efi@vger.kernel.org
  Cc: matt.fleming@intel.com, Seiji Aguchi, richard@nod.at, Tony Luck


Pstore fs expects that backends provide a uniqued 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>
---
 drivers/firmware/efi/efi-pstore.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/drivers/firmware/efi/efi-pstore.c b/drivers/firmware/efi/efi-pstore.c
index 5002d50..c6075f8 100644
--- a/drivers/firmware/efi/efi-pstore.c
+++ b/drivers/firmware/efi/efi-pstore.c
@@ -39,6 +39,12 @@ struct pstore_read_data {
 	char **buf;
 };
 
+static inline u64 generic_id(unsigned long timestamp,
+			     unsigned int part, int count)
+{
+	return (timestamp * 100 + part) * 1000 + count;
+}
+
 static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
 {
 	efi_guid_t vendor = LINUX_EFI_CRASH_GUID;
@@ -57,7 +63,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
 
 	if (sscanf(name, "dump-type%u-%u-%d-%lu-%c",
 		   cb_data->type, &part, &cnt, &time, &data_type) == 5) {
-		*cb_data->id = part;
+		*cb_data->id = generic_id(time, part, cnt);
 		*cb_data->count = cnt;
 		cb_data->timespec->tv_sec = time;
 		cb_data->timespec->tv_nsec = 0;
@@ -67,7 +73,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
 			*cb_data->compressed = false;
 	} else if (sscanf(name, "dump-type%u-%u-%d-%lu",
 		   cb_data->type, &part, &cnt, &time) == 4) {
-		*cb_data->id = part;
+		*cb_data->id = generic_id(time, part, cnt);
 		*cb_data->count = cnt;
 		cb_data->timespec->tv_sec = time;
 		cb_data->timespec->tv_nsec = 0;
@@ -79,7 +85,7 @@ static int efi_pstore_read_func(struct efivar_entry *entry, void *data)
 		 * which doesn't support holding
 		 * multiple logs, remains.
 		 */
-		*cb_data->id = part;
+		*cb_data->id = generic_id(time, part, 0);
 		*cb_data->count = 0;
 		cb_data->timespec->tv_sec = time;
 		cb_data->timespec->tv_nsec = 0;
@@ -199,14 +205,15 @@ static int efi_pstore_erase(enum pstore_type_id type, u64 id, int count,
 	char name[DUMP_NAME_LEN];
 	efi_char16_t efi_name[DUMP_NAME_LEN];
 	int found, i;
+	unsigned int part;
 
-	sprintf(name, "dump-type%u-%u-%d-%lu", type, (unsigned int)id, count,
-		time.tv_sec);
+	part = (id / 1000) % 100;
+	sprintf(name, "dump-type%u-%u-%d-%lu", type, part, count, time.tv_sec);
 
 	for (i = 0; i < DUMP_NAME_LEN; i++)
 		efi_name[i] = name[i];
 
-	edata.id = id;
+	edata.id = part;
 	edata.type = type;
 	edata.count = count;
 	edata.time = time;
-- 
1.8.4.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] efi-pstore: Make efi-pstore return a unique id
  2013-11-23 11:55 [PATCH v2] efi-pstore: Make efi-pstore return a unique id Madper Xie
@ 2013-11-27 11:44 ` Matt Fleming
  2013-11-27 14:51   ` Seiji Aguchi
  2013-11-28  2:15   ` Madper Xie
  0 siblings, 2 replies; 4+ messages in thread
From: Matt Fleming @ 2013-11-27 11:44 UTC (permalink / raw)
  To: Madper Xie
  Cc: 'linux-kernel@vger.kernel.org', linux-efi@vger.kernel.org,
	matt.fleming@intel.com, Seiji Aguchi, richard@nod.at, Tony Luck

On Sat, 23 Nov, at 07:55:37PM, Madper Xie wrote:
> 
> Pstore fs expects that backends provide a uniqued 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>
> ---
>  drivers/firmware/efi/efi-pstore.c | 19 +++++++++++++------
>  1 file changed, 13 insertions(+), 6 deletions(-)

Thanks unless anyone complains, I'm going to apply this.

Does this need to be tagged for stable?

-- 
Matt Fleming, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH v2] efi-pstore: Make efi-pstore return a unique id
  2013-11-27 11:44 ` Matt Fleming
@ 2013-11-27 14:51   ` Seiji Aguchi
  2013-11-28  2:15   ` Madper Xie
  1 sibling, 0 replies; 4+ messages in thread
From: Seiji Aguchi @ 2013-11-27 14:51 UTC (permalink / raw)
  To: Matt Fleming, Madper Xie
  Cc: 'linux-kernel@vger.kernel.org', linux-efi@vger.kernel.org,
	matt.fleming@intel.com, richard@nod.at, Tony Luck



> -----Original Message-----
> From: Matt Fleming [mailto:matt@console-pimps.org]
> Sent: Wednesday, November 27, 2013 6:45 AM
> To: Madper Xie
> Cc: 'linux-kernel@vger.kernel.org'; linux-efi@vger.kernel.org; matt.fleming@intel.com; Seiji Aguchi; richard@nod.at; Tony Luck
> Subject: Re: [PATCH v2] efi-pstore: Make efi-pstore return a unique id
> 
> On Sat, 23 Nov, at 07:55:37PM, Madper Xie wrote:
> >
> > Pstore fs expects that backends provide a uniqued 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>
> > ---
> >  drivers/firmware/efi/efi-pstore.c | 19 +++++++++++++------
> >  1 file changed, 13 insertions(+), 6 deletions(-)
> 
> Thanks unless anyone complains, I'm going to apply this.
> 

I'm OK with this patch based on Madper's comment below.

<snip>
So i'd like to using fixed length. My dell xps has 128kb nvram
space. and it at most store 126 pstore entries. So I think 1000 will be
a safe value for count. For part, 100 should be okay. I don't think
there will be a large kmsg and we must split it into more than 100 parts.
<snip>

> Does this need to be tagged for stable?
> 

I think so.

Seiji

> --
> Matt Fleming, Intel Open Source Technology Center

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] efi-pstore: Make efi-pstore return a unique id
  2013-11-27 11:44 ` Matt Fleming
  2013-11-27 14:51   ` Seiji Aguchi
@ 2013-11-28  2:15   ` Madper Xie
  1 sibling, 0 replies; 4+ messages in thread
From: Madper Xie @ 2013-11-28  2:15 UTC (permalink / raw)
  To: Matt Fleming
  Cc: Madper Xie, 'linux-kernel@vger.kernel.org',
	linux-efi@vger.kernel.org, matt.fleming@intel.com, Seiji Aguchi,
	richard@nod.at, Tony Luck


matt@console-pimps.org writes:

> On Sat, 23 Nov, at 07:55:37PM, Madper Xie wrote:
>> 
>> Pstore fs expects that backends provide a uniqued 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>
>> ---
>>  drivers/firmware/efi/efi-pstore.c | 19 +++++++++++++------
>>  1 file changed, 13 insertions(+), 6 deletions(-)
>
> Thanks unless anyone complains, I'm going to apply this.
>
> Does this need to be tagged for stable?
Since it fix a real issue, my answer is "Yes".

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-11-28  2:15 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-23 11:55 [PATCH v2] efi-pstore: Make efi-pstore return a unique id Madper Xie
2013-11-27 11:44 ` Matt Fleming
2013-11-27 14:51   ` Seiji Aguchi
2013-11-28  2:15   ` Madper Xie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).