Skip to contentSkip to conversation

pramdisk: new block disk driver to perform persistent storage

PATCH In review Lin Yongting 3 participants 5 messages Sep 18, 2015 – Sep 21, 2015 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pramdisk: new block disk driver to perform persistent storage

In embed devices, user space applications will use reserved memory (i.e. persistent memory) to store business data, the data is kept in this memory region after system rebooting or panic.

pramdisk is a block disk driver based on Persistent memory, it provide file system interface for application to read/write data in persistent memory. Application can use pramdisk to store log file or business data in persistent memory in the way of file system operation, avoid operating or managing memory directly.

pramdisk support multiple Persistent menory regions and each one is a block device named as /dev/pram<N>.

Usage:
modprobe pramdisk.ko pmem=<size1>@<addr2> [ pmem=<size2>@<addr2> ... ]

For example:
modprobe pramdisk.ko pmem=20M@2050M pmem=20M@2150M mkfs.ext3 /dev/pram1
mkdir /tmp/test1
mount -t ext3 /dev/pram1 /tmp/test1

---
 drivers/block/Kconfig    |   18 +++
 drivers/block/Makefile   |    1 +
 drivers/block/pramdisk.c |  305 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 324 insertions(+)
 create mode 100644 drivers/block/pramdisk.c
drivers/block/Kconfig +18 -0
index 1b8094d..9bd68a5 100644
@@ -404,6 +404,24 @@ config BLK_DEV_RAM_DAX
 	  and will prevent RAM block device backing store memory from being
 	  allocated from highmem (only a problem for highmem systems).
 
+config BLK_DEV_PRAM_DISK
+	tristate "Persistent RAM Disk device support"
+	---help---
+	  Saying Y here will allow you to use some portion of your Persistent
+	  RAM memory as disk(i.e. block device), so that you can make file
+	  systems on it, read and write to it. The RAM memory region is
+	  persistent and the data will be kept after system rebooting, panic
+	  or NMI.
+
+	  This functionality is very useful in embed device, can be used to
+	  access log data or business data in the way of file systems.
+
+	  Saying M here will compile this driver as a Module.
+	  Saying N here if don't need this Persistent RAM Block Device
+	  functionality.
+
+	  Use devices /dev/pram$N.
+
 config CDROM_PKTCDVD
 	tristate "Packet writing on CD/DVD media"
 	depends on !UML
drivers/block/Makefile +1 -0
index 02b688d..3cab7e5 100644
@@ -38,6 +38,7 @@ obj-$(CONFIG_XEN_BLKDEV_FRONTEND)	+= xen-blkfront.o
 obj-$(CONFIG_XEN_BLKDEV_BACKEND)	+= xen-blkback/
 obj-$(CONFIG_BLK_DEV_DRBD)     += drbd/
 obj-$(CONFIG_BLK_DEV_RBD)     += rbd.o
+obj-$(CONFIG_BLK_DEV_PRAM_DISK)		+= pramdisk.o
 obj-$(CONFIG_BLK_DEV_PCIESSD_MTIP32XX)	+= mtip32xx/
 
 obj-$(CONFIG_BLK_DEV_RSXX) += rsxx/
drivers/block/pramdisk.c new file +305 -0

305 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 16 lines · Lin Yongting

In embed devices, user space applications will use reserved memory (i.e. persistent memory) to store business data, the data is kept in this memory region after system rebooting or panic.

pramdisk is a block disk driver based on Persistent memory, it provide file system interface for application to read/write data in persistent memory. Application can use pramdisk to store log file or business data in persistent memory in the way of file system operation, avoid operating or managing memory directly.

pramdisk support multiple Persistent menory regions and each one is a block device named as /dev/pram<N>.

Usage:
modprobe pramdisk.ko pmem=<size1>@<addr2> [ pmem=<size2>@<addr2> ... ]

Quoted 8 lines

For example:
modprobe pramdisk.ko pmem=20M@2050M pmem=20M@2150M mkfs.ext3 /dev/pram1
mkdir /tmp/test1
mount -t ext3 /dev/pram1 /tmp/test1

I think you already have this functionality with the PMEM driver and the memmap=nn[KMG]!ss[KMG] command line parameter? What are you trying to accomplish with this driver that you can't do with PMEM?

#2 lore raw
Quoted 23 lines · Ross Zwisler
Quoted 22 lines · Lin Yongting

In embed devices, user space applications will use reserved memory (i.e. persistent memory) to store business data, the data is kept in this memory region after system rebooting or panic.

pramdisk is a block disk driver based on Persistent memory, it provide file system interface for application to read/write data in persistent memory. Application can use pramdisk to store log file or business data in persistent memory in the way of file system operation, avoid operating or managing memory directly.

pramdisk support multiple Persistent menory regions and each one is a block device named as /dev/pram<N>.

Usage:
modprobe pramdisk.ko pmem=<size1>@<addr2> [ pmem=<size2>@<addr2> ... ]

For example:
modprobe pramdisk.ko pmem=20M@2050M pmem=20M@2150M mkfs.ext3 /dev/pram1
mkdir /tmp/test1
mount -t ext3 /dev/pram1 /tmp/test1

Quoted 6 lines
Quoted 2 lines

I think you already have this functionality with the PMEM driver and the memmap=nn[KMG]!ss[KMG] command line parameter? What are you trying to accomplish with this driver that you can't do with PMEM?

Moreover, if your embedded firmware publishes persistent memory ranges you can reuse the drivers/nvdimm/e820.c driver. As long as your platform code in the kernel names those iomem_resource(s) as ""Persistent Memory (legacy)" they will be auto discovered and surfaced by the libnvidmm sub-system.

#3 lore raw
Quoted 32 lines · Dan Williams
Quoted 23 lines · Ross Zwisler
Quoted 22 lines · Lin Yongting

In embed devices, user space applications will use reserved memory (i.e. persistent memory) to store business data, the data is kept in this memory region after system rebooting or panic.

pramdisk is a block disk driver based on Persistent memory, it provide file system interface for application to read/write data in persistent memory. Application can use pramdisk to store log file or business data in persistent memory in the way of file system operation, avoid operating or managing memory directly.

pramdisk support multiple Persistent menory regions and each one is a block device named as /dev/pram<N>.

Usage:
modprobe pramdisk.ko pmem=<size1>@<addr2> [ pmem=<size2>@<addr2> ... ]

For example:
modprobe pramdisk.ko pmem=20M@2050M pmem=20M@2150M mkfs.ext3 /dev/pram1
mkdir /tmp/test1
mount -t ext3 /dev/pram1 /tmp/test1

Quoted 6 lines
Quoted 2 lines

I think you already have this functionality with the PMEM driver and the memmap=nn[KMG]!ss[KMG] command line parameter? What are you trying to accomplish with this driver that you can't do with PMEM?

Quoted 6 lines

Moreover, if your embedded firmware publishes persistent memory ranges you can reuse the drivers/nvdimm/e820.c driver. As long as your platform code in the kernel names those iomem_resource(s) as ""Persistent Memory (legacy)" they will be auto discovered and surfaced by the libnvidmm sub-system.

Thanks Dan!

Seems nvdimm sub-system can figure out my requirement.

Actually, my system is ARM arch, there is no any firmware but just a DDR memory. We reserved a memory region which is out of OS-memory to store data Persistently, this memory region will not clear in rebooting or panic as long as the power is not cut off.

#4 lore raw
In reply to Ross Zwisler
Quoted 23 lines · Ross Zwisler
Quoted 22 lines · Lin Yongting

In embed devices, user space applications will use reserved memory (i.e. persistent memory) to store business data, the data is kept in this memory region after system rebooting or panic.

pramdisk is a block disk driver based on Persistent memory, it provide file system interface for application to read/write data in persistent memory. Application can use pramdisk to store log file or business data in persistent memory in the way of file system operation, avoid operating or managing memory directly.

pramdisk support multiple Persistent menory regions and each one is a block device named as /dev/pram<N>.

Usage:
modprobe pramdisk.ko pmem=<size1>@<addr2> [ pmem=<size2>@<addr2> ... ]

For example:
modprobe pramdisk.ko pmem=20M@2050M pmem=20M@2150M mkfs.ext3 /dev/pram1
mkdir /tmp/test1
mount -t ext3 /dev/pram1 /tmp/test1

Quoted 6 lines
Quoted 2 lines

I think you already have this functionality with the PMEM driver and the memmap=nn[KMG]!ss[KMG] command line parameter? What are you trying to accomplish with this driver that you can't do with PMEM?

Hi Ross, thanks!

I dig into nvdimm sub-system these two day and found that PMEM can make Reserved Memory as block disk to mount file system on it.

But I am curious about two things:
1. seems memmap command line parameter is not available at ARM arch. Can we use module parameter rather than kernel command parameter?
2. If I specified two memmap regions(which they are Adjacent to each other), Can we get tow block device?

Thanks Again.

Best Regards!

-- Lin Yongting