Block device driver question

neha naik nehanaik27 at gmail.com
Fri Nov 1 13:26:44 EDT 2013


Hi,
  I am writing a block device driver and i am using the
'blq_queue_make_request' call while registering my block device
driver.
  Now as far as i understand this will bypass the linux kernel queue
for each block device driver (bypassing the elevator algorithm etc).
However, i am still not very clear about exactly how i get a request.

 1.  Consider i am doing a dd on the block device directly :
  Will it bypass the buffer cache(/page cache) or will it use it.
Example if i register my block device with set_blocksize() as 512. And
i do a dd of 512 bytes will i get a read because it passes through the
buffer cache and since the minimum page size is 4096 it has to read
the page first and then pass it to me.
    I am still unclear about the 'page' in the bvec. What does that
refer to? Is it a page from the page cache or a user buffer (DMA).


2. Another thing i am not clear about is a queue. When i register my
driver, the 'make_request' function gets called whenever there is an
io. Now in my device driver, i have some more logic about  writing
this io i.e some time may be spent in the device driver for each io.
In such a case, if i get two ios on the same block one after the other
(say one is writing 'a' and the other is writing 'b') then isn't it
possible that i may end up passing 'b' followed by 'a' to the layer
below me (changing the order because thread 'a' took more time than
thread 'b'). Then in that case should i be using a queue in my layer -
put the ios in the queue whenever i get a call to 'make_request'.
Another thread keeps pulling the ios from the queue and processing
them and passing it to the layer below.


Regards,
Neha



More information about the Kernelnewbies mailing list