Skip to content

Commit 78c0824

Browse files
WeiXiong Liaokees
authored andcommitted
mtd: Support kmsg dumper based on pstore/blk
This introduces mtdpstore, which is similar to mtdoops but more powerful. It uses pstore/blk, and aims to store panic and oops logs to a flash partition, where pstore can later read back and present as files in the mounted pstore filesystem. To make mtdpstore work, the "blkdev" of pstore/blk should be set as MTD device name or MTD device number. For more details, see Documentation/admin-guide/pstore-blk.rst This solves a number of issues: - Work duplication: both of pstore and mtdoops do the same job storing panic/oops log. They have very similar logic, registering to kmsg dumper and storing logs to several chunks one by one. - Layer violations: drivers should provides methods instead of polices. MTD should provide read/write/erase operations, and allow a higher level drivers to provide the chunk management, kmsg dump configuration, etc. - Missing features: pstore provides many additional features, including presenting the logs as files, logging dump time and count, and supporting other frontends like pmsg, console, etc. Signed-off-by: WeiXiong Liao <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
1 parent f8feafe commit 78c0824

File tree

4 files changed

+596
-2
lines changed

4 files changed

+596
-2
lines changed

Documentation/admin-guide/pstore-blk.rst

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ blkdev
4343
~~~~~~
4444

4545
The block device to use. Most of the time, it is a partition of block device.
46-
It's required for pstore/blk.
46+
It's required for pstore/blk. It is also used for MTD device.
4747

48-
It accepts the following variants:
48+
It accepts the following variants for block device:
4949

5050
1. <hex_major><hex_minor> device number in hexadecimal represents itself; no
5151
leading 0x, for example b302.
@@ -64,6 +64,11 @@ It accepts the following variants:
6464
partition with a known unique id.
6565
#. <major>:<minor> major and minor number of the device separated by a colon.
6666

67+
It accepts the following variants for MTD device:
68+
69+
1. <device name> MTD device name. "pstore" is recommended.
70+
#. <device number> MTD device number.
71+
6772
kmsg_size
6873
~~~~~~~~~
6974

drivers/mtd/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,16 @@ config MTD_OOPS
170170
buffer in a flash partition where it can be read back at some
171171
later point.
172172

173+
config MTD_PSTORE
174+
tristate "Log panic/oops to an MTD buffer based on pstore"
175+
depends on PSTORE_BLK
176+
help
177+
This enables panic and oops messages to be logged to a circular
178+
buffer in a flash partition where it can be read back as files after
179+
mounting pstore filesystem.
180+
181+
If unsure, say N.
182+
173183
config MTD_SWAP
174184
tristate "Swap on MTD device support"
175185
depends on MTD && SWAP

drivers/mtd/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ obj-$(CONFIG_RFD_FTL) += rfd_ftl.o
2020
obj-$(CONFIG_SSFDC) += ssfdc.o
2121
obj-$(CONFIG_SM_FTL) += sm_ftl.o
2222
obj-$(CONFIG_MTD_OOPS) += mtdoops.o
23+
obj-$(CONFIG_MTD_PSTORE) += mtdpstore.o
2324
obj-$(CONFIG_MTD_SWAP) += mtdswap.o
2425

2526
nftl-objs := nftlcore.o nftlmount.o

0 commit comments

Comments
 (0)