Skip to content

Commit 9db5579

Browse files
Nick PigginLinus Torvalds
authored andcommitted
rewrite rd
This is a rewrite of the ramdisk block device driver. The old one is really difficult because it effectively implements a block device which serves data out of its own buffer cache. It relies on the dirty bit being set, to pin its backing store in cache, however there are non trivial paths which can clear the dirty bit (eg. try_to_free_buffers()), which had recently lead to data corruption. And in general it is completely wrong for a block device driver to do this. The new one is more like a regular block device driver. It has no idea about vm/vfs stuff. It's backing store is similar to the buffer cache (a simple radix-tree of pages), but it doesn't know anything about page cache (the pages in the radix tree are not pagecache pages). There is one slight downside -- direct block device access and filesystem metadata access goes through an extra copy and gets stored in RAM twice. However, this downside is only slight, because the real buffercache of the device is now reclaimable (because we're not playing crazy games with it), so under memory intensive situations, footprint should effectively be the same -- maybe even a slight advantage to the new driver because it can also reclaim buffer heads. The fact that it now goes through all the regular vm/fs paths makes it much more useful for testing, too. text data bss dec hex filename 2837 849 384 4070 fe6 drivers/block/rd.o 3528 371 12 3911 f47 drivers/block/brd.o Text is larger, but data and bss are smaller, making total size smaller. A few other nice things about it: - Similar structure and layout to the new loop device handlinag. - Dynamic ramdisk creation. - Runtime flexible buffer head size (because it is no longer part of the ramdisk code). - Boot / load time flexible ramdisk size, which could easily be extended to a per-ramdisk runtime changeable size (eg. with an ioctl). - Can use highmem for the backing store. [akpm@linux-foundation.org: fix build] [byron.bbradley@gmail.com: make rd_size non-static] Signed-off-by: Nick Piggin <npiggin@suse.de> Signed-off-by: Byron Bradley <byron.bbradley@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent daeb51e commit 9db5579

6 files changed

Lines changed: 556 additions & 549 deletions

File tree

‎MAINTAINERS‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3254,6 +3254,11 @@ W: http://rt2x00.serialmonkey.com/
32543254
S: Maintained
32553255
F: drivers/net/wireless/rt2x00/
32563256

3257+
RAMDISK RAM BLOCK DEVICE DRIVER
3258+
P: Nick Piggin
3259+
M: npiggin@suse.de
3260+
S: Maintained
3261+
32573262
RANDOM NUMBER DRIVER
32583263
P: Matt Mackall
32593264
M: mpm@selenic.com

‎drivers/block/Kconfig‎

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ config BLK_DEV_UB
322322
If unsure, say N.
323323

324324
config BLK_DEV_RAM
325-
tristate "RAM disk support"
325+
tristate "RAM block device support"
326326
---help---
327327
Saying Y here will allow you to use a portion of your RAM memory as
328328
a block device, so that you can make file systems on it, read and
@@ -357,16 +357,6 @@ config BLK_DEV_RAM_SIZE
357357
The default value is 4096 kilobytes. Only change this if you know
358358
what you are doing.
359359

360-
config BLK_DEV_RAM_BLOCKSIZE
361-
int "Default RAM disk block size (bytes)"
362-
depends on BLK_DEV_RAM
363-
default "1024"
364-
help
365-
The default value is 1024 bytes. PAGE_SIZE is a much more
366-
efficient choice however. The default is kept to ensure initrd
367-
setups function - apparently needed by the rd_load_image routine
368-
that supposes the filesystem in the image uses a 1024 blocksize.
369-
370360
config CDROM_PKTCDVD
371361
tristate "Packet writing on CD/DVD media"
372362
depends on !UML

‎drivers/block/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ obj-$(CONFIG_AMIGA_FLOPPY) += amiflop.o
1111
obj-$(CONFIG_PS3_DISK) += ps3disk.o
1212
obj-$(CONFIG_ATARI_FLOPPY) += ataflop.o
1313
obj-$(CONFIG_AMIGA_Z2RAM) += z2ram.o
14-
obj-$(CONFIG_BLK_DEV_RAM) += rd.o
14+
obj-$(CONFIG_BLK_DEV_RAM) += brd.o
1515
obj-$(CONFIG_BLK_DEV_LOOP) += loop.o
1616
obj-$(CONFIG_BLK_DEV_PS2) += ps2esdi.o
1717
obj-$(CONFIG_BLK_DEV_XD) += xd.o

0 commit comments

Comments
 (0)