Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'please-pull-pstore' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux

Pull pstore updates from Tony Luck:
"Half dozen small cleanups plus change to allow pstore backend drivers
to be unloaded"

* tag 'please-pull-pstore' of git://git.kernel.org/pub/scm/linux/kernel/git/aegl/linux:
pstore: fix code comment to match code
efi-pstore: fix kernel-doc argument name
pstore: Fix return type of pstore_is_mounted()
pstore: add pstore unregister
pstore: add a helper function pstore_register_kmsg
pstore: add vmalloc error check

+102 -40
+1 -1
drivers/firmware/efi/efi-pstore.c
··· 103 103 104 104 /** 105 105 * efi_pstore_scan_sysfs_enter 106 - * @entry: scanning entry 106 + * @pos: scanning entry 107 107 * @next: next entry 108 108 * @head: list head 109 109 */
+1 -1
fs/pstore/Kconfig
··· 1 1 config PSTORE 2 - bool "Persistent store support" 2 + tristate "Persistent store support" 3 3 default n 4 4 select ZLIB_DEFLATE 5 5 select ZLIB_INFLATE
+3 -3
fs/pstore/Makefile
··· 2 2 # Makefile for the linux pstorefs routines. 3 3 # 4 4 5 - obj-y += pstore.o 5 + obj-$(CONFIG_PSTORE) += pstore.o 6 6 7 7 pstore-objs += inode.o platform.o 8 - obj-$(CONFIG_PSTORE_FTRACE) += ftrace.o 8 + pstore-$(CONFIG_PSTORE_FTRACE) += ftrace.o 9 9 10 - obj-$(CONFIG_PSTORE_PMSG) += pmsg.o 10 + pstore-$(CONFIG_PSTORE_PMSG) += pmsg.o 11 11 12 12 ramoops-objs += ram.o ram_core.o 13 13 obj-$(CONFIG_PSTORE_RAM) += ramoops.o
+19 -6
fs/pstore/ftrace.c
··· 104 104 .write = pstore_ftrace_knob_write, 105 105 }; 106 106 107 + static struct dentry *pstore_ftrace_dir; 108 + 107 109 void pstore_register_ftrace(void) 108 110 { 109 - struct dentry *dir; 110 111 struct dentry *file; 111 112 112 113 if (!psinfo->write_buf) 113 114 return; 114 115 115 - dir = debugfs_create_dir("pstore", NULL); 116 - if (!dir) { 116 + pstore_ftrace_dir = debugfs_create_dir("pstore", NULL); 117 + if (!pstore_ftrace_dir) { 117 118 pr_err("%s: unable to create pstore directory\n", __func__); 118 119 return; 119 120 } 120 121 121 - file = debugfs_create_file("record_ftrace", 0600, dir, NULL, 122 - &pstore_knob_fops); 122 + file = debugfs_create_file("record_ftrace", 0600, pstore_ftrace_dir, 123 + NULL, &pstore_knob_fops); 123 124 if (!file) { 124 125 pr_err("%s: unable to create record_ftrace file\n", __func__); 125 126 goto err_file; ··· 128 127 129 128 return; 130 129 err_file: 131 - debugfs_remove(dir); 130 + debugfs_remove(pstore_ftrace_dir); 131 + } 132 + 133 + void pstore_unregister_ftrace(void) 134 + { 135 + mutex_lock(&pstore_ftrace_lock); 136 + if (pstore_ftrace_enabled) { 137 + unregister_ftrace_function(&pstore_ftrace_ops); 138 + pstore_ftrace_enabled = 0; 139 + } 140 + mutex_unlock(&pstore_ftrace_lock); 141 + 142 + debugfs_remove_recursive(pstore_ftrace_dir); 132 143 }
+10 -1
fs/pstore/inode.c
··· 178 178 } 179 179 180 180 static const struct file_operations pstore_file_operations = { 181 + .owner = THIS_MODULE, 181 182 .open = pstore_file_open, 182 183 .read = pstore_file_read, 183 184 .llseek = pstore_file_llseek, ··· 288 287 289 288 static struct super_block *pstore_sb; 290 289 291 - int pstore_is_mounted(void) 290 + bool pstore_is_mounted(void) 292 291 { 293 292 return pstore_sb != NULL; 294 293 } ··· 457 456 } 458 457 459 458 static struct file_system_type pstore_fs_type = { 459 + .owner = THIS_MODULE, 460 460 .name = "pstore", 461 461 .mount = pstore_mount, 462 462 .kill_sb = pstore_kill_sb, ··· 480 478 return err; 481 479 } 482 480 module_init(init_pstore_fs) 481 + 482 + static void __exit exit_pstore_fs(void) 483 + { 484 + unregister_filesystem(&pstore_fs_type); 485 + sysfs_remove_mount_point(fs_kobj, "pstore"); 486 + } 487 + module_exit(exit_pstore_fs) 483 488 484 489 MODULE_AUTHOR("Tony Luck <tony.luck@intel.com>"); 485 490 MODULE_LICENSE("GPL");
+5 -1
fs/pstore/internal.h
··· 41 41 42 42 #ifdef CONFIG_PSTORE_FTRACE 43 43 extern void pstore_register_ftrace(void); 44 + extern void pstore_unregister_ftrace(void); 44 45 #else 45 46 static inline void pstore_register_ftrace(void) {} 47 + static inline void pstore_unregister_ftrace(void) {} 46 48 #endif 47 49 48 50 #ifdef CONFIG_PSTORE_PMSG 49 51 extern void pstore_register_pmsg(void); 52 + extern void pstore_unregister_pmsg(void); 50 53 #else 51 54 static inline void pstore_register_pmsg(void) {} 55 + static inline void pstore_unregister_pmsg(void) {} 52 56 #endif 53 57 54 58 extern struct pstore_info *psinfo; ··· 63 59 int count, char *data, bool compressed, 64 60 size_t size, struct timespec time, 65 61 struct pstore_info *psi); 66 - extern int pstore_is_mounted(void); 62 + extern bool pstore_is_mounted(void); 67 63 68 64 #endif
+44 -3
fs/pstore/platform.c
··· 237 237 238 238 } 239 239 240 + static void free_buf_for_compression(void) 241 + { 242 + kfree(stream.workspace); 243 + stream.workspace = NULL; 244 + kfree(big_oops_buf); 245 + big_oops_buf = NULL; 246 + } 247 + 240 248 /* 241 249 * Called when compression fails, since the printk buffer 242 250 * would be fetched for compression calling it again when ··· 361 353 .dump = pstore_dump, 362 354 }; 363 355 356 + /* 357 + * Register with kmsg_dump to save last part of console log on panic. 358 + */ 359 + static void pstore_register_kmsg(void) 360 + { 361 + kmsg_dump_register(&pstore_dumper); 362 + } 363 + 364 + static void pstore_unregister_kmsg(void) 365 + { 366 + kmsg_dump_unregister(&pstore_dumper); 367 + } 368 + 364 369 #ifdef CONFIG_PSTORE_CONSOLE 365 370 static void pstore_console_write(struct console *con, const char *s, unsigned c) 366 371 { ··· 411 390 { 412 391 register_console(&pstore_console); 413 392 } 393 + 394 + static void pstore_unregister_console(void) 395 + { 396 + unregister_console(&pstore_console); 397 + } 414 398 #else 415 399 static void pstore_register_console(void) {} 400 + static void pstore_unregister_console(void) {} 416 401 #endif 417 402 418 403 static int pstore_write_compat(enum pstore_type_id type, ··· 437 410 * read function right away to populate the file system. If not 438 411 * then the pstore mount code will call us later to fill out 439 412 * the file system. 440 - * 441 - * Register with kmsg_dump to save last part of console log on panic. 442 413 */ 443 414 int pstore_register(struct pstore_info *psi) 444 415 { ··· 467 442 if (pstore_is_mounted()) 468 443 pstore_get_records(0); 469 444 470 - kmsg_dump_register(&pstore_dumper); 445 + pstore_register_kmsg(); 471 446 472 447 if ((psi->flags & PSTORE_FLAGS_FRAGILE) == 0) { 473 448 pstore_register_console(); ··· 487 462 */ 488 463 backend = psi->name; 489 464 465 + module_put(owner); 466 + 490 467 pr_info("Registered %s as persistent store backend\n", psi->name); 491 468 492 469 return 0; 493 470 } 494 471 EXPORT_SYMBOL_GPL(pstore_register); 472 + 473 + void pstore_unregister(struct pstore_info *psi) 474 + { 475 + pstore_unregister_pmsg(); 476 + pstore_unregister_ftrace(); 477 + pstore_unregister_console(); 478 + pstore_unregister_kmsg(); 479 + 480 + free_buf_for_compression(); 481 + 482 + psinfo = NULL; 483 + backend = NULL; 484 + } 485 + EXPORT_SYMBOL_GPL(pstore_unregister); 495 486 496 487 /* 497 488 * Read all the records from the persistent store. Create
+9
fs/pstore/pmsg.c
··· 37 37 if (buffer_size > PMSG_MAX_BOUNCE_BUFFER_SIZE) 38 38 buffer_size = PMSG_MAX_BOUNCE_BUFFER_SIZE; 39 39 buffer = vmalloc(buffer_size); 40 + if (!buffer) 41 + return -ENOMEM; 40 42 41 43 mutex_lock(&pmsg_lock); 42 44 for (i = 0; i < count; ) { ··· 113 111 unregister_chrdev(pmsg_major, PMSG_NAME); 114 112 err: 115 113 return; 114 + } 115 + 116 + void pstore_unregister_pmsg(void) 117 + { 118 + device_destroy(pmsg_class, MKDEV(pmsg_major, 0)); 119 + class_destroy(pmsg_class); 120 + unregister_chrdev(pmsg_major, PMSG_NAME); 116 121 }
+8 -11
fs/pstore/ram.c
··· 578 578 return err; 579 579 } 580 580 581 - static int __exit ramoops_remove(struct platform_device *pdev) 581 + static int ramoops_remove(struct platform_device *pdev) 582 582 { 583 - #if 0 584 - /* TODO(kees): We cannot unload ramoops since pstore doesn't support 585 - * unregistering yet. 586 - */ 587 583 struct ramoops_context *cxt = &oops_cxt; 588 584 589 - iounmap(cxt->virt_addr); 590 - release_mem_region(cxt->phys_addr, cxt->size); 585 + pstore_unregister(&cxt->pstore); 591 586 cxt->max_dump_cnt = 0; 592 587 593 - /* TODO(kees): When pstore supports unregistering, call it here. */ 594 588 kfree(cxt->pstore.buf); 595 589 cxt->pstore.bufsize = 0; 596 590 591 + persistent_ram_free(cxt->mprz); 592 + persistent_ram_free(cxt->fprz); 593 + persistent_ram_free(cxt->cprz); 594 + ramoops_free_przs(cxt); 595 + 597 596 return 0; 598 - #endif 599 - return -EBUSY; 600 597 } 601 598 602 599 static struct platform_driver ramoops_driver = { 603 600 .probe = ramoops_probe, 604 - .remove = __exit_p(ramoops_remove), 601 + .remove = ramoops_remove, 605 602 .driver = { 606 603 .name = "ramoops", 607 604 },
+1 -13
include/linux/pstore.h
··· 75 75 76 76 #define PSTORE_FLAGS_FRAGILE 1 77 77 78 - #ifdef CONFIG_PSTORE 79 78 extern int pstore_register(struct pstore_info *); 79 + extern void pstore_unregister(struct pstore_info *); 80 80 extern bool pstore_cannot_block_path(enum kmsg_dump_reason reason); 81 - #else 82 - static inline int 83 - pstore_register(struct pstore_info *psi) 84 - { 85 - return -ENODEV; 86 - } 87 - static inline bool 88 - pstore_cannot_block_path(enum kmsg_dump_reason reason) 89 - { 90 - return false; 91 - } 92 - #endif 93 81 94 82 #endif /*_LINUX_PSTORE_H*/
+1
kernel/printk/printk.c
··· 517 517 ok: 518 518 return security_syslog(type); 519 519 } 520 + EXPORT_SYMBOL_GPL(check_syslog_permissions); 520 521 521 522 static void append_char(char **pp, char *e, char c) 522 523 {