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: Seiji Aguchi <seiji.aguchi@hds.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>

Tony Luck 9f6af27f eddecbb6

+12 -3
+12 -3
fs/pstore/platform.c
··· 48 /* Tag each group of saved records with a sequence number */ 49 static int oopscount; 50 51 /* 52 * callback from kmsg_dump. (s2,l2) has the most recently 53 * written bytes, older bytes are in (s1,l1). Save as much ··· 65 unsigned long s1_start, s2_start; 66 unsigned long l1_cpy, l2_cpy; 67 unsigned long size, total = 0; 68 - char *dst; 69 u64 id; 70 int hsize, part = 1; 71 72 mutex_lock(&psinfo->buf_mutex); 73 oopscount++; 74 while (total < kmsg_bytes) { 75 dst = psinfo->buf; 76 - hsize = sprintf(dst, "Oops#%d Part%d\n", oopscount, part++); 77 size = psinfo->bufsize - hsize; 78 dst += hsize; 79 ··· 95 memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy); 96 97 id = psinfo->write(PSTORE_TYPE_DMESG, hsize + l1_cpy + l2_cpy); 98 - if (pstore_is_mounted()) 99 pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, 100 psinfo->buf, hsize + l1_cpy + l2_cpy, 101 CURRENT_TIME, psinfo->erase);
··· 48 /* Tag each group of saved records with a sequence number */ 49 static int oopscount; 50 51 + static char *reason_str[] = { 52 + "Oops", "Panic", "Kexec", "Restart", "Halt", "Poweroff", "Emergency" 53 + }; 54 + 55 /* 56 * callback from kmsg_dump. (s2,l2) has the most recently 57 * written bytes, older bytes are in (s1,l1). Save as much ··· 61 unsigned long s1_start, s2_start; 62 unsigned long l1_cpy, l2_cpy; 63 unsigned long size, total = 0; 64 + char *dst, *why; 65 u64 id; 66 int hsize, part = 1; 67 + 68 + if (reason < ARRAY_SIZE(reason_str)) 69 + why = reason_str[reason]; 70 + else 71 + why = "Unknown"; 72 73 mutex_lock(&psinfo->buf_mutex); 74 oopscount++; 75 while (total < kmsg_bytes) { 76 dst = psinfo->buf; 77 + hsize = sprintf(dst, "%s#%d Part%d\n", why, oopscount, part++); 78 size = psinfo->bufsize - hsize; 79 dst += hsize; 80 ··· 86 memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy); 87 88 id = psinfo->write(PSTORE_TYPE_DMESG, hsize + l1_cpy + l2_cpy); 89 + if (reason == KMSG_DUMP_OOPS && pstore_is_mounted()) 90 pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, 91 psinfo->buf, hsize + l1_cpy + l2_cpy, 92 CURRENT_TIME, psinfo->erase);