forked from Linaro/linux-kernel-uadk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge tag 'pstore-v4.20-rc1' of git://git.kernel.org/pub/scm/linux/ke…
…rnel/git/kees/linux Pull pstore updates from Kees Cook: "pstore improvements: - refactor init to happen as early as possible again (Joel Fernandes) - improve resource reservation names" * tag 'pstore-v4.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: pstore/ram: Clarify resource reservation labels pstore: Refactor compression initialization pstore: Allocate compression during late_initcall() pstore: Centralize init/exit routines
- Loading branch information
Showing
6 changed files
with
90 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -482,12 +482,10 @@ static struct file_system_type pstore_fs_type = { | |
.kill_sb = pstore_kill_sb, | ||
}; | ||
|
||
static int __init init_pstore_fs(void) | ||
int __init pstore_init_fs(void) | ||
{ | ||
int err; | ||
|
||
pstore_choose_compression(); | ||
|
||
/* Create a convenient mount point for people to access pstore */ | ||
err = sysfs_create_mount_point(fs_kobj, "pstore"); | ||
if (err) | ||
|
@@ -500,14 +498,9 @@ static int __init init_pstore_fs(void) | |
out: | ||
return err; | ||
} | ||
module_init(init_pstore_fs) | ||
|
||
static void __exit exit_pstore_fs(void) | ||
void __exit pstore_exit_fs(void) | ||
{ | ||
unregister_filesystem(&pstore_fs_type); | ||
sysfs_remove_mount_point(fs_kobj, "pstore"); | ||
} | ||
module_exit(exit_pstore_fs) | ||
|
||
MODULE_AUTHOR("Tony Luck <[email protected]>"); | ||
MODULE_LICENSE("GPL"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -274,36 +274,56 @@ static int pstore_decompress(void *in, void *out, | |
|
||
static void allocate_buf_for_compression(void) | ||
{ | ||
struct crypto_comp *ctx; | ||
int size; | ||
char *buf; | ||
|
||
/* Skip if not built-in or compression backend not selected yet. */ | ||
if (!IS_ENABLED(CONFIG_PSTORE_COMPRESS) || !zbackend) | ||
return; | ||
|
||
/* Skip if no pstore backend yet or compression init already done. */ | ||
if (!psinfo || tfm) | ||
return; | ||
|
||
if (!crypto_has_comp(zbackend->name, 0, 0)) { | ||
pr_err("No %s compression\n", zbackend->name); | ||
pr_err("Unknown compression: %s\n", zbackend->name); | ||
return; | ||
} | ||
|
||
big_oops_buf_sz = zbackend->zbufsize(psinfo->bufsize); | ||
if (big_oops_buf_sz <= 0) | ||
size = zbackend->zbufsize(psinfo->bufsize); | ||
if (size <= 0) { | ||
pr_err("Invalid compression size for %s: %d\n", | ||
zbackend->name, size); | ||
return; | ||
} | ||
|
||
big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL); | ||
if (!big_oops_buf) { | ||
pr_err("allocate compression buffer error!\n"); | ||
buf = kmalloc(size, GFP_KERNEL); | ||
if (!buf) { | ||
pr_err("Failed %d byte compression buffer allocation for: %s\n", | ||
size, zbackend->name); | ||
return; | ||
} | ||
|
||
tfm = crypto_alloc_comp(zbackend->name, 0, 0); | ||
if (IS_ERR_OR_NULL(tfm)) { | ||
kfree(big_oops_buf); | ||
big_oops_buf = NULL; | ||
pr_err("crypto_alloc_comp() failed!\n"); | ||
ctx = crypto_alloc_comp(zbackend->name, 0, 0); | ||
if (IS_ERR_OR_NULL(ctx)) { | ||
kfree(buf); | ||
pr_err("crypto_alloc_comp('%s') failed: %ld\n", zbackend->name, | ||
PTR_ERR(ctx)); | ||
return; | ||
} | ||
|
||
/* A non-NULL big_oops_buf indicates compression is available. */ | ||
tfm = ctx; | ||
big_oops_buf_sz = size; | ||
big_oops_buf = buf; | ||
|
||
pr_info("Using compression: %s\n", zbackend->name); | ||
} | ||
|
||
static void free_buf_for_compression(void) | ||
{ | ||
if (IS_ENABLED(CONFIG_PSTORE_COMPRESS) && !IS_ERR_OR_NULL(tfm)) | ||
if (IS_ENABLED(CONFIG_PSTORE_COMPRESS) && tfm) | ||
crypto_free_comp(tfm); | ||
kfree(big_oops_buf); | ||
big_oops_buf = NULL; | ||
|
@@ -774,14 +794,43 @@ void __init pstore_choose_compression(void) | |
for (step = zbackends; step->name; step++) { | ||
if (!strcmp(compress, step->name)) { | ||
zbackend = step; | ||
pr_info("using %s compression\n", zbackend->name); | ||
return; | ||
} | ||
} | ||
} | ||
|
||
static int __init pstore_init(void) | ||
{ | ||
int ret; | ||
|
||
pstore_choose_compression(); | ||
|
||
/* | ||
* Check if any pstore backends registered earlier but did not | ||
* initialize compression because crypto was not ready. If so, | ||
* initialize compression now. | ||
*/ | ||
allocate_buf_for_compression(); | ||
|
||
ret = pstore_init_fs(); | ||
if (ret) | ||
return ret; | ||
|
||
return 0; | ||
} | ||
late_initcall(pstore_init); | ||
|
||
static void __exit pstore_exit(void) | ||
{ | ||
pstore_exit_fs(); | ||
} | ||
module_exit(pstore_exit) | ||
|
||
module_param(compress, charp, 0444); | ||
MODULE_PARM_DESC(compress, "Pstore compression to use"); | ||
|
||
module_param(backend, charp, 0444); | ||
MODULE_PARM_DESC(backend, "Pstore backend to use"); | ||
|
||
MODULE_AUTHOR("Tony Luck <[email protected]>"); | ||
MODULE_LICENSE("GPL"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters