<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Nov 1, 2013 at 12:17 PM, neha naik <span dir="ltr"><<a href="mailto:nehanaik27@gmail.com" target="_blank">nehanaik27@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Rajat,<br>
Thanks for the information. One more question :<br>
Say my block device driver doesn't support reads and the<br>
application always does aligned io in 512 chunks (but it is not direct<br>
io). In that case, will i get a read because the page size is 4096 and<br>
yet we are writing 512. Because i am not getting any read which is why<br>
i am confused.I have been doing the io after syncing the page cache so<br>
it is not like i get a pagecache hit every time.<br></blockquote><div><br></div><div>sync does not evict page cache. And is your block device sector size declared as 512 ?<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I am doing a normal dd without any special flags, just 'bs=512'.<br>
<br>
Regards,<br>
Neha<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Fri, Nov 1, 2013 at 12:16 PM, Rajat Sharma <<a href="mailto:fs.rajat@gmail.com">fs.rajat@gmail.com</a>> wrote:<br>
> Hi Neha,<br>
><br>
><br>
> On Fri, Nov 1, 2013 at 10:26 AM, neha naik <<a href="mailto:nehanaik27@gmail.com">nehanaik27@gmail.com</a>> wrote:<br>
>><br>
>> Hi,<br>
>> I am writing a block device driver and i am using the<br>
>> 'blq_queue_make_request' call while registering my block device<br>
>> driver.<br>
>> Now as far as i understand this will bypass the linux kernel queue<br>
>> for each block device driver (bypassing the elevator algorithm etc).<br>
>> However, i am still not very clear about exactly how i get a request.<br>
>><br>
>> 1. Consider i am doing a dd on the block device directly :<br>
>> Will it bypass the buffer cache(/page cache) or will it use it.<br>
>> Example if i register my block device with set_blocksize() as 512. And<br>
>> i do a dd of 512 bytes will i get a read because it passes through the<br>
>> buffer cache and since the minimum page size is 4096 it has to read<br>
>> the page first and then pass it to me.<br>
>> I am still unclear about the 'page' in the bvec. What does that<br>
>> refer to? Is it a page from the page cache or a user buffer (DMA).<br>
>><br>
><br>
> If you are not using oflag=direct with dd, then you are getting 'page' in<br>
> bvec that belongs to buffer cache (in 2.6 it is implemented as page-cache of<br>
> block_device->bd_inode->i_mapping). You get user buffer only with direct IO,<br>
> but then you need to take care to issue aligned IO requests yourself (if<br>
> your block device wants only aligned buffers its your implementation<br>
> though).<br>
><br>
>><br>
>> 2. Another thing i am not clear about is a queue. When i register my<br>
>> driver, the 'make_request' function gets called whenever there is an<br>
>> io. Now in my device driver, i have some more logic about writing<br>
>> this io i.e some time may be spent in the device driver for each io.<br>
>> In such a case, if i get two ios on the same block one after the other<br>
>> (say one is writing 'a' and the other is writing 'b') then isn't it<br>
>> possible that i may end up passing 'b' followed by 'a' to the layer<br>
>> below me (changing the order because thread 'a' took more time than<br>
>> thread 'b'). Then in that case should i be using a queue in my layer -<br>
>> put the ios in the queue whenever i get a call to 'make_request'.<br>
>> Another thread keeps pulling the ios from the queue and processing<br>
>> them and passing it to the layer below.<br>
>><br>
><br>
> If your application does not quarantee the ordering of writes, then you<br>
> don't have to worry either. Most likely block layer will do the merges in<br>
> page-cache if it is not a direct IO. As a driver developer, you don't need<br>
> to worry about out of order writes from application.<br>
><br>
>><br>
>><br>
>> Regards,<br>
>> Neha<br>
>><br>
>> _______________________________________________<br>
>> Kernelnewbies mailing list<br>
>> <a href="mailto:Kernelnewbies@kernelnewbies.org">Kernelnewbies@kernelnewbies.org</a><br>
>> <a href="http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies" target="_blank">http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies</a><br>
><br>
><br>
</div></div></blockquote></div><br></div></div>