Ramdisk & BLKGETSIZE ioctl()

Stuart Stakoff (stuart@estateINFO.COM)
Thu, 5 Nov 1998 15:10:09 -0500 (EST)


RE: Kernel 2.0.34

I'm new to this list, but I couldn't find appropriate answer
in the archives.

In trying to understand the "dynamic" portion of the ramdisk
code, I notice that no matter what you do to a ramdisk, the
BLKGETSIZE ioctl() always returns the default ramdisk size.

For example, doing

%mke2fs -m 0 /dev/ram

will create a 4MB ramdisk (4MB is default size).
The ioctl() will return 8192 (512 byte) blocks as the size.
I assume that mke2fs will request the device size via BLKGETSIZE
and hence the 4MB ramdisk.

If I dynamically extend the ramdisk by doing:

%mke2fs -m 0 /dev/ram 16000

The ioctl() still return 8192, yet the filesystem created is ~16MB!

I am new to the kernel, but here is my understanding of what's going on:

- When you request to read at a particular block on the ramdisk device,
the buffering layer will allocate a buffer head if one isn't already
present and pass this to rd_request() with a READ command. This function
has no physical device to read from, so it simply zeros the buffer page
and returns. This means (again, I'm new) that I could request any
conceivable block, hence the dynamic behavior. But, the ioctl() still
tells me I'm looking at a 4MB device. Is this the intended behavior.

Also, what happens to the buffers that were allocated to the ramdisk
when I issue a BLKFLSBUF ioctl(). I see that the buffers are invalidated,
but does this mean that the kernel no longer holds them in any way? For
example, if I needed a temporary ramdisk of 100MB and I "free" it when I'm
done with BLKFLSBUF, does this affect my overall free memory? Will that
memory be returned to the pool of memory available for user programs?

Thanks in advance...

Stuart

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/