diff options
author | Tony Luck <tony.luck@intel.com> | 2011-03-22 19:01:49 -0400 |
---|---|---|
committer | Tony Luck <tony.luck@intel.com> | 2011-03-22 19:01:49 -0400 |
commit | 9f6af27fb693c633cc46d36fc1d85efe6d6fbc17 (patch) | |
tree | d5474b26be0995dbe650dcd0be79a9f046335315 /fs/pstore/platform.c | |
parent | eddecbb601c9ea3fab7e67d7892010fc9426d1e6 (diff) |
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>
Diffstat (limited to 'fs/pstore/platform.c')
-rw-r--r-- | fs/pstore/platform.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c index ce9ad84d5dd9..f835a25625ff 100644 --- a/fs/pstore/platform.c +++ b/fs/pstore/platform.c | |||
@@ -48,6 +48,10 @@ void pstore_set_kmsg_bytes(int bytes) | |||
48 | /* Tag each group of saved records with a sequence number */ | 48 | /* Tag each group of saved records with a sequence number */ |
49 | static int oopscount; | 49 | static int oopscount; |
50 | 50 | ||
51 | static char *reason_str[] = { | ||
52 | "Oops", "Panic", "Kexec", "Restart", "Halt", "Poweroff", "Emergency" | ||
53 | }; | ||
54 | |||
51 | /* | 55 | /* |
52 | * callback from kmsg_dump. (s2,l2) has the most recently | 56 | * callback from kmsg_dump. (s2,l2) has the most recently |
53 | * written bytes, older bytes are in (s1,l1). Save as much | 57 | * written bytes, older bytes are in (s1,l1). Save as much |
@@ -61,15 +65,20 @@ static void pstore_dump(struct kmsg_dumper *dumper, | |||
61 | unsigned long s1_start, s2_start; | 65 | unsigned long s1_start, s2_start; |
62 | unsigned long l1_cpy, l2_cpy; | 66 | unsigned long l1_cpy, l2_cpy; |
63 | unsigned long size, total = 0; | 67 | unsigned long size, total = 0; |
64 | char *dst; | 68 | char *dst, *why; |
65 | u64 id; | 69 | u64 id; |
66 | int hsize, part = 1; | 70 | int hsize, part = 1; |
67 | 71 | ||
72 | if (reason < ARRAY_SIZE(reason_str)) | ||
73 | why = reason_str[reason]; | ||
74 | else | ||
75 | why = "Unknown"; | ||
76 | |||
68 | mutex_lock(&psinfo->buf_mutex); | 77 | mutex_lock(&psinfo->buf_mutex); |
69 | oopscount++; | 78 | oopscount++; |
70 | while (total < kmsg_bytes) { | 79 | while (total < kmsg_bytes) { |
71 | dst = psinfo->buf; | 80 | dst = psinfo->buf; |
72 | hsize = sprintf(dst, "Oops#%d Part%d\n", oopscount, part++); | 81 | hsize = sprintf(dst, "%s#%d Part%d\n", why, oopscount, part++); |
73 | size = psinfo->bufsize - hsize; | 82 | size = psinfo->bufsize - hsize; |
74 | dst += hsize; | 83 | dst += hsize; |
75 | 84 | ||
@@ -86,7 +95,7 @@ static void pstore_dump(struct kmsg_dumper *dumper, | |||
86 | memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy); | 95 | memcpy(dst + l1_cpy, s2 + s2_start, l2_cpy); |
87 | 96 | ||
88 | id = psinfo->write(PSTORE_TYPE_DMESG, hsize + l1_cpy + l2_cpy); | 97 | id = psinfo->write(PSTORE_TYPE_DMESG, hsize + l1_cpy + l2_cpy); |
89 | if (pstore_is_mounted()) | 98 | if (reason == KMSG_DUMP_OOPS && pstore_is_mounted()) |
90 | pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, | 99 | pstore_mkfile(PSTORE_TYPE_DMESG, psinfo->name, id, |
91 | psinfo->buf, hsize + l1_cpy + l2_cpy, | 100 | psinfo->buf, hsize + l1_cpy + l2_cpy, |
92 | CURRENT_TIME, psinfo->erase); | 101 | CURRENT_TIME, psinfo->erase); |