2002-02-05 16:21:11

by lord latex

[permalink] [raw]
Subject: confused about block device behaviour

hi

i've got written a block device driver for the 2.4.x
kernel and it seems to work. but something looks
strange to me. i've go a very simple application that
does nothing more then open the block device, read
1024 byte and close the device. when i run this app.
serveral times my do_request function gets called
every time. why? i expect this block beeing buffered
in the buffer cache. what do i don't see, or what is
possibly wrong with my block device?

thanks


2002-02-05 19:26:53

by Andrew Morton

[permalink] [raw]
Subject: Re: confused about block device behaviour

lord latex wrote:
>
> hi
>
> i've got written a block device driver for the 2.4.x
> kernel and it seems to work. but something looks
> strange to me. i've go a very simple application that
> does nothing more then open the block device, read
> 1024 byte and close the device. when i run this app.
> serveral times my do_request function gets called
> every time. why? i expect this block beeing buffered
> in the buffer cache. what do i don't see, or what is
> possibly wrong with my block device?
>

The kernel invalidates the device's cache on the final close.
If you hold the device open in a different process:

sleep 1000 < /dev/foo

while you run the test, you'll see that the underlying device's
contents are indeed cached.

-