Skip to content

Commit 17639f6

Browse files
WeiXiong Liaokees
authored andcommitted
pstore/blk: Introduce backend for block devices
pstore/blk is similar to pstore/ram, but uses a block device as the storage rather than persistent ram. The pstore/blk backend solves two common use-cases that used to preclude using pstore/ram: - not all devices have a battery that could be used to persist regular RAM across power failures. - most embedded intelligent equipment have no persistent ram, which increases costs, instead preferring cheaper solutions, like block devices. pstore/blk provides separate configurations for the end user and for the block drivers. User configuration determines how pstore/blk operates, such as record sizes, max kmsg dump reasons, etc. These can be set by Kconfig and/or module parameters, but module parameter have priority over Kconfig. Driver configuration covers all the details about the target block device, such as total size of the device and how to perform read/write operations. These are provided by block drivers, calling pstore_register_blkdev(), including an optional panic_write callback used to bypass regular IO APIs in an effort to avoid potentially destabilized kernel code during a panic. Signed-off-by: WeiXiong Liao <[email protected]> Link: https://lore.kernel.org/lkml/[email protected]/ Co-developed-by: Kees Cook <[email protected]> Signed-off-by: Kees Cook <[email protected]>
1 parent d26c332 commit 17639f6

File tree

4 files changed

+552
-0
lines changed

4 files changed

+552
-0
lines changed

fs/pstore/Kconfig

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,3 +160,67 @@ config PSTORE_ZONE
160160
help
161161
The common layer for pstore/blk (and pstore/ram in the future)
162162
to manage storage in zones.
163+
164+
config PSTORE_BLK
165+
tristate "Log panic/oops to a block device"
166+
depends on PSTORE
167+
depends on BLOCK
168+
select PSTORE_ZONE
169+
default n
170+
help
171+
This enables panic and oops message to be logged to a block dev
172+
where it can be read back at some later point.
173+
174+
If unsure, say N.
175+
176+
config PSTORE_BLK_BLKDEV
177+
string "block device identifier"
178+
depends on PSTORE_BLK
179+
default ""
180+
help
181+
Which block device should be used for pstore/blk.
182+
183+
It accept the following variants:
184+
1) <hex_major><hex_minor> device number in hexadecimal representation,
185+
with no leading 0x, for example b302.
186+
2) /dev/<disk_name> represents the device number of disk
187+
3) /dev/<disk_name><decimal> represents the device number
188+
of partition - device number of disk plus the partition number
189+
4) /dev/<disk_name>p<decimal> - same as the above, this form is
190+
used when disk name of partitioned disk ends with a digit.
191+
5) PARTUUID=00112233-4455-6677-8899-AABBCCDDEEFF representing the
192+
unique id of a partition if the partition table provides it.
193+
The UUID may be either an EFI/GPT UUID, or refer to an MSDOS
194+
partition using the format SSSSSSSS-PP, where SSSSSSSS is a zero-
195+
filled hex representation of the 32-bit "NT disk signature", and PP
196+
is a zero-filled hex representation of the 1-based partition number.
197+
6) PARTUUID=<UUID>/PARTNROFF=<int> to select a partition in relation
198+
to a partition with a known unique id.
199+
7) <major>:<minor> major and minor number of the device separated by
200+
a colon.
201+
202+
NOTE that, both Kconfig and module parameters can configure
203+
pstore/blk, but module parameters have priority over Kconfig.
204+
205+
config PSTORE_BLK_KMSG_SIZE
206+
int "Size in Kbytes of kmsg dump log to store"
207+
depends on PSTORE_BLK
208+
default 64
209+
help
210+
This just sets size of kmsg dump (oops, panic, etc) log for
211+
pstore/blk. The size is in KB and must be a multiple of 4.
212+
213+
NOTE that, both Kconfig and module parameters can configure
214+
pstore/blk, but module parameters have priority over Kconfig.
215+
216+
config PSTORE_BLK_MAX_REASON
217+
int "Maximum kmsg dump reason to store"
218+
depends on PSTORE_BLK
219+
default 2
220+
help
221+
The maximum reason for kmsg dumps to store. The default is
222+
2 (KMSG_DUMP_OOPS), see include/linux/kmsg_dump.h's
223+
enum kmsg_dump_reason for more details.
224+
225+
NOTE that, both Kconfig and module parameters can configure
226+
pstore/blk, but module parameters have priority over Kconfig.

fs/pstore/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ obj-$(CONFIG_PSTORE_RAM) += ramoops.o
1515

1616
pstore_zone-objs += zone.o
1717
obj-$(CONFIG_PSTORE_ZONE) += pstore_zone.o
18+
19+
pstore_blk-objs += blk.o
20+
obj-$(CONFIG_PSTORE_BLK) += pstore_blk.o

0 commit comments

Comments
 (0)