Commit 9f6af27f authored by Tony Luck's avatar Tony Luck

pstore: cleanups to pstore_dump()

pstore_dump() can be called with many different "reason" codes. Save
the name of the code in the persistent store record.

Also - only worthwhile calling pstore_mkfile for KMSG_DUMP_OOPS - that
is the only one where the kernel will continue running.
Reviewed-by: default avatarSeiji Aguchi <seiji.aguchi@hds.com>
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
parent eddecbb6
...@@ -48,6 +48,10 @@ void pstore_set_kmsg_bytes(int bytes) ...@@ -48,6 +48,10 @@ void pstore_set_kmsg_bytes(int bytes)
/* Tag each group of saved records with a sequence number */ /* Tag each group of saved records with a sequence number */
static int oopscount; static int oopscount;
static char *reason_str[] = {
"Oops", "Panic", "Kexec", "Restart", "Halt", "Poweroff", "Emergency"
};
/* /*
* callback from kmsg_dump. (s2,l2) has the most recently * callback from kmsg_dump. (s2,l2) has the most recently
* written bytes, older bytes are in (s1,l1). Save as much * written bytes, older bytes are in (s1,l1). Save as much
...@@ -61,15 +65,20 @@ static void pstore_dump(struct kmsg_dumper *dumper, ...@@ -61,15 +65,20 @@ static void pstore_dump(struct kmsg_dumper *dumper,
unsigned long s1_start, s2_start; unsigned long s1_start, s2_start;
unsigned long l1_cpy, l2_cpy; unsigned long l1_cpy, l2_cpy;
unsigned long size, total = 0; unsigned long size, total = 0;
char *dst; char *dst, *why;
u64 id; u64 id;
int hsize, part = 1; int hsize, part = 1;
if (reason < ARRAY_SIZE(reason_str))
why = reason_str[reason];
else
why = "Unknown";
mutex_lock(&psinfo->buf_mutex); mutex_lock(&psinfo->buf_mutex);
oopscount++; oopscount++;
while (total < kmsg_bytes) { while (total < kmsg_bytes) {
dst = psinfo->buf; dst = psinfo->buf;
hsize = sprintf(dst, "Oops#%d Part%d\n", oopscount, part++); hsize = sprintf(dst, "%s#%d Part%d\n", why, oopscount, part++);
size = psinfo->bufsize - hsize; size = psinfo->bufsize - hsize;
dst += hsize; dst += hsize;
...@@ -86,7 +95,7 @@ static void pstore_dump(struct kmsg_dumper *dumper, ...@@ -86,7 +95,7 @@ static void pstore_dump(struct kmsg_dumper *dumper,
memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy); memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy);
id = psinfo->write(PSTORE_TYPE_DMESG, hsize + l1_cpy + l2_cpy); id = psinfo->write(PSTORE_TYPE_DMESG, hsize + l1_cpy + l2_cpy);
if (pstore_is_mounted()) if (reason == KMSG_DUMP_OOPS && pstore_is_mounted())
pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id,
psinfo->buf, hsize + l1_cpy + l2_cpy, psinfo->buf, hsize + l1_cpy + l2_cpy,
CURRENT_TIME, psinfo->erase); CURRENT_TIME, psinfo->erase);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment