Skip to contentSkip to conversation

ramdisk size bug in 2.4.17-pre2

DISCUSSION Erik Mouw 2 participants 2 messages Dec 7, 2001 – Dec 10, 2001 VFS

lore
Share & tools
lore

Erik Mouw

author
#0 lore raw

Hi,

It looks like the ramdisk driver in 2.4.17-pre2 doesn't honor the rd_size parameter:

root@arthur:/tmp #uname -a
Linux arthur 2.4.17-pre2 #1 Sat Dec 1 00:47:24 CET 2001 i686 unknown root@arthur:/tmp #cat /proc/sys/kernel/tainted
0
root@arthur:/tmp #modinfo rd
filename: /lib/modules/2.4.17-pre2/kernel/drivers/block/rd.o
description: <none>

  author:      <none>
  license:     "GPL"
  parm:        rd_size int, description "Size of each RAM disk in kbytes."
  parm:        rd_blocksize int, description "Blocksize of each RAM disk in bytes."

root@arthur:/tmp #modprobe rd rd_size=8192
RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize

So I would expect that each ramdisk is 8192kB. But:

root@arthur:/tmp #dd if=/dev/zero of=/dev/ram1 bs=1k count=16384 16384+0 records in
16384+0 records out

IOW: writing 16MB to a 8MB ramdisk happily succeeds.

The last time I tried this was with 2.4.10-ac10, which didn't have this bug.

Erik
[who will investigate further but is currently -ENOTIME]

Signature · 5 lines
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Faculty
of Information Technology and Systems, Delft University of Technology,
PO BOX 5031, 2600 GA Delft, The Netherlands  Phone: +31-15-2783635
Fax: +31-15-2781843  Email: [email protected]
WWW: http://www-ict.its.tudelft.nl/~erik/
#1 lore raw

Hello,

I think following one-line patch fixes the bug.

fs/block_dev.c +1 -0
diff -Nur linux-2.4.17-pre7.org/fs/block_dev.c linux-2.4.17-pre7/fs/block_dev.c
@@ -329,6 +329,7 @@
 			inode->i_bdev = new_bdev;
 			inode->i_data.a_ops = &def_blk_aops;
 			inode->i_data.gfp_mask = GFP_USER;
+			inode->i_mode = S_IFBLK;
 			spin_lock(&bdev_lock);
 			bdev = bdfind(dev, head);
 			if (!bdev) {

generic_file_write() checks whether i_mapping->host is a block device and if it is a block device, i_size is used as a size of block device. but it does not work because bdget() does not set inode->i_mode to S_IFBLK.

At Fri, 7 Dec 2001 16:07:02 +0100,

Quoted 46 lines · Erik Mouw

Hi,

It looks like the ramdisk driver in 2.4.17-pre2 doesn't honor the rd_size parameter:

root@arthur:/tmp #uname -a
Linux arthur 2.4.17-pre2 #1 Sat Dec 1 00:47:24 CET 2001 i686 unknown root@arthur:/tmp #cat /proc/sys/kernel/tainted
0
root@arthur:/tmp #modinfo rd
filename: /lib/modules/2.4.17-pre2/kernel/drivers/block/rd.o
description: <none>

  author:      <none>
  license:     "GPL"
  parm:        rd_size int, description "Size of each RAM disk in kbytes."
  parm:        rd_blocksize int, description "Blocksize of each RAM disk in bytes."

root@arthur:/tmp #modprobe rd rd_size=8192
RAMDISK driver initialized: 16 RAM disks of 8192K size 1024 blocksize

So I would expect that each ramdisk is 8192kB. But:

root@arthur:/tmp #dd if=/dev/zero of=/dev/ram1 bs=1k count=16384 16384+0 records in
16384+0 records out

IOW: writing 16MB to a 8MB ramdisk happily succeeds.

The last time I tried this was with 2.4.10-ac10, which didn't have this bug.

Erik
[who will investigate further but is currently -ENOTIME]

Signature · 10 lines
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Faculty
of Information Technology and Systems, Delft University of Technology,
PO BOX 5031, 2600 GA Delft, The Netherlands  Phone: +31-15-2783635
Fax: +31-15-2781843  Email: [email protected]
WWW: http://www-ict.its.tudelft.nl/~erik/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/