Buffer cache mechanism

Pranay Kr. Srivastava pranjas at gmail.com
Sat Apr 26 08:48:09 EDT 2014



On April 26, 2014 5:50:16 PM GMT+05:30, Satheesaran <satheesaran at gmail.com> wrote:
>Hi All,
>
>I was reading through the text, "The Design of the Unix Operating
>System" -
>Maurice Bach
>
>While reading through the Buffer cache, I had the following query
>
>Buffer data structure, has Buffer header + pointer to data area +
>pointers
>for Buffer Management.
>Does this,"pointer to data area", corresponds to disk block or Logical
>Filesystem block ?
>
>I am confused about this.
>
>To add more, I am aware of the fact that disk block is of 512 bytes on
>the
>most of the hard disks and

This is the device block size and for Linux kernel it is 512. For filesystem don't be bothered about it.

>logical disk block size ( depending on filesystem ) is of 4k in size.
>what would be available in data area pointed in buffer ?
>
1 buffer_head in Linux kernel represents your file system block.

A file system block has to be multiple of 512 and must be less than or equal to PAGE_SIZE. With that said the buffer head would actually point to something within a page. 

So if your file system block size FS_BLOCKSIZE  you can have PAGE_SIZE/FS_BLOCKSIZE  buffer heads pointing at different locations but within the same page.

Functions that give you a buffer head like sb_bread take file system block number as argument. 

The translation of which device sector to read/write is done by kernel in 512 units. 

As far as the kernel is concerned device block size is always 512 bytes. So depending on which file system block you request the translation is done since when you mount your file system you will tell kernel about your file system block size. sb_setblocksize i think is the function.

The device driver may further translate it if the device block size isn't 512 bytes. But Thats not your concern. Its between kernel and device driver.

>Thanks,
>Satheesaran
>
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Kernelnewbies mailing list
>Kernelnewbies at kernelnewbies.org
>http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20140426/d6305012/attachment.html 


More information about the Kernelnewbies mailing list