aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-06-24 23:42:21 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-06-24 23:42:21 -0400
commit266da6f14232638b9caafb7facf2a7333895dd05 (patch)
tree1005013ee85dd897518354de4ff02b50e315bc99
parentcfcc0ad47f4cbc19ddd057cfb39b144a3518c59e (diff)
parent078550569eafc6631d333488045159badbeb911a (diff)
Merge tag 'please-pull-pstore' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux
Pull pstore updates from Tony Luck: "Miscellaneous pstore improvements" * tag 'please-pull-pstore' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux: ramoops: make it possible to change mem_type param. pstore/ram: verify ramoops header before saving record fs/pstore: Optimization function ramoops_init_przs fs/pstore: update the backend parameter in pstore module pstore: do not use message compression without lock
-rw-r--r--fs/pstore/platform.c8
-rw-r--r--fs/pstore/ram.c50
2 files changed, 39 insertions, 19 deletions
diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c
index c4c9a10c5760..791743deedf1 100644
--- a/fs/pstore/platform.c
+++ b/fs/pstore/platform.c
@@ -299,7 +299,7 @@ static void pstore_dump(struct kmsg_dumper *dumper,
299 bool compressed; 299 bool compressed;
300 size_t total_len; 300 size_t total_len;
301 301
302 if (big_oops_buf) { 302 if (big_oops_buf && is_locked) {
303 dst = big_oops_buf; 303 dst = big_oops_buf;
304 hsize = sprintf(dst, "%s#%d Part%u\n", why, 304 hsize = sprintf(dst, "%s#%d Part%u\n", why,
305 oopscount, part); 305 oopscount, part);
@@ -456,6 +456,12 @@ int pstore_register(struct pstore_info *psi)
456 add_timer(&pstore_timer); 456 add_timer(&pstore_timer);
457 } 457 }
458 458
459 /*
460 * Update the module parameter backend, so it is visible
461 * through /sys/module/pstore/parameters/backend
462 */
463 backend = psi->name;
464
459 pr_info("Registered %s as persistent store backend\n", psi->name); 465 pr_info("Registered %s as persistent store backend\n", psi->name);
460 466
461 return 0; 467 return 0;
diff --git a/fs/pstore/ram.c b/fs/pstore/ram.c
index 44a549beeafa..6c26c4daaec9 100644
--- a/fs/pstore/ram.c
+++ b/fs/pstore/ram.c
@@ -186,12 +186,34 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
186 ssize_t size; 186 ssize_t size;
187 ssize_t ecc_notice_size; 187 ssize_t ecc_notice_size;
188 struct ramoops_context *cxt = psi->data; 188 struct ramoops_context *cxt = psi->data;
189 struct persistent_ram_zone *prz; 189 struct persistent_ram_zone *prz = NULL;
190 int header_length; 190 int header_length = 0;
191
192 /* Ramoops headers provide time stamps for PSTORE_TYPE_DMESG, but
193 * PSTORE_TYPE_CONSOLE and PSTORE_TYPE_FTRACE don't currently have
194 * valid time stamps, so it is initialized to zero.
195 */
196 time->tv_sec = 0;
197 time->tv_nsec = 0;
198 *compressed = false;
199
200 /* Find the next valid persistent_ram_zone for DMESG */
201 while (cxt->dump_read_cnt < cxt->max_dump_cnt && !prz) {
202 prz = ramoops_get_next_prz(cxt->przs, &cxt->dump_read_cnt,
203 cxt->max_dump_cnt, id, type,
204 PSTORE_TYPE_DMESG, 1);
205 if (!prz_ok(prz))
206 continue;
207 header_length = ramoops_read_kmsg_hdr(persistent_ram_old(prz),
208 time, compressed);
209 /* Clear and skip this DMESG record if it has no valid header */
210 if (!header_length) {
211 persistent_ram_free_old(prz);
212 persistent_ram_zap(prz);
213 prz = NULL;
214 }
215 }
191 216
192 prz = ramoops_get_next_prz(cxt->przs, &cxt->dump_read_cnt,
193 cxt->max_dump_cnt, id, type,
194 PSTORE_TYPE_DMESG, 1);
195 if (!prz_ok(prz)) 217 if (!prz_ok(prz))
196 prz = ramoops_get_next_prz(&cxt->cprz, &cxt->console_read_cnt, 218 prz = ramoops_get_next_prz(&cxt->cprz, &cxt->console_read_cnt,
197 1, id, type, PSTORE_TYPE_CONSOLE, 0); 219 1, id, type, PSTORE_TYPE_CONSOLE, 0);
@@ -204,13 +226,7 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type,
204 if (!prz_ok(prz)) 226 if (!prz_ok(prz))
205 return 0; 227 return 0;
206 228
207 if (!persistent_ram_old(prz)) 229 size = persistent_ram_old_size(prz) - header_length;
208 return 0;
209
210 size = persistent_ram_old_size(prz);
211 header_length = ramoops_read_kmsg_hdr(persistent_ram_old(prz), time,
212 compressed);
213 size -= header_length;
214 230
215 /* ECC correction notice */ 231 /* ECC correction notice */
216 ecc_notice_size = persistent_ram_ecc_string(prz, NULL, 0); 232 ecc_notice_size = persistent_ram_ecc_string(prz, NULL, 0);
@@ -394,18 +410,16 @@ static int ramoops_init_przs(struct device *dev, struct ramoops_context *cxt,
394 } 410 }
395 411
396 for (i = 0; i < cxt->max_dump_cnt; i++) { 412 for (i = 0; i < cxt->max_dump_cnt; i++) {
397 size_t sz = cxt->record_size; 413 cxt->przs[i] = persistent_ram_new(*paddr, cxt->record_size, 0,
398
399 cxt->przs[i] = persistent_ram_new(*paddr, sz, 0,
400 &cxt->ecc_info, 414 &cxt->ecc_info,
401 cxt->memtype); 415 cxt->memtype);
402 if (IS_ERR(cxt->przs[i])) { 416 if (IS_ERR(cxt->przs[i])) {
403 err = PTR_ERR(cxt->przs[i]); 417 err = PTR_ERR(cxt->przs[i]);
404 dev_err(dev, "failed to request mem region (0x%zx@0x%llx): %d\n", 418 dev_err(dev, "failed to request mem region (0x%zx@0x%llx): %d\n",
405 sz, (unsigned long long)*paddr, err); 419 cxt->record_size, (unsigned long long)*paddr, err);
406 goto fail_prz; 420 goto fail_prz;
407 } 421 }
408 *paddr += sz; 422 *paddr += cxt->record_size;
409 } 423 }
410 424
411 return 0; 425 return 0;
@@ -608,7 +622,7 @@ static void ramoops_register_dummy(void)
608 622
609 dummy_data->mem_size = mem_size; 623 dummy_data->mem_size = mem_size;
610 dummy_data->mem_address = mem_address; 624 dummy_data->mem_address = mem_address;
611 dummy_data->mem_type = 0; 625 dummy_data->mem_type = mem_type;
612 dummy_data->record_size = record_size; 626 dummy_data->record_size = record_size;
613 dummy_data->console_size = ramoops_console_size; 627 dummy_data->console_size = ramoops_console_size;
614 dummy_data->ftrace_size = ramoops_ftrace_size; 628 dummy_data->ftrace_size = ramoops_ftrace_size;