On Mon, Aug 17, 2009 at 2:08 AM, Manish Katiyar<mkatiyar@xxxxxxxxx> wrote: > On Mon, Aug 17, 2009 at 11:06 AM, ajit mote<mail2blackmen@xxxxxxxxx> wrote: >> >> Hello, >> >> I would like to know how file system structures are mapped to hard disk >> sector. > > Each filesystem deals in the granularity of "block size" which is > generally configurable (typically 4K) during fs creation time. So each > block maps to 8 sectors (which are generally 512 bytes). Now given a > block number you can multiply it by 8 to get your hard disk sector. One slight clarification. The above provides the sector relative to the start of the partition (/dev/sda3 as an example). Lower level code maps that to the actual LBA that is sent to the hardware. And in a classroom scenario you should at least mention that 512 byte physical sectors are no longer the only option at the actual platter level. Instead 2K and 4K sectors are being seen in use. The Linux kernel just got (2.6.31 I think) the topo feature patchset to allow the block stack as well as userspace the ability to see how these underlying physical sectors are aligned. So for these new drives, they still present a 512 byte logical sector interface on the ATA interface, but for writes that don't completely overwrite the true physical sector the following inefficient process is followed in the drive itself: Read physical sector (including header/footer/crc/etc), modify data, update crc, write physical sector. Obviously you have to allow the harddrive to do a full rotation between the read and write, so the above is very inefficient. Thus the reason for the linux kernel growing topo support is that filesystems and other users need to make a strong effort to align their pages with these new drives physical sector layout. I'm sure you can find a lwn article on the topo patchset that will clarify this more than the above. Greg -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ