0

Let's use example of a modern Linux system with modern HDDs of typical SATA3 drives. When the OS decides to write a file to a HDD:

Who breaks up the file into blocks? The "Virtual File System" in kernel?

And who translate those software constructs into cylinders/heads address so the HDD knows how to point the head and spin the plates? The "Virtual File System" to the HDD driver? Or the HDD exposed itself only as abstract "blocks" to "Virtual File System" already and the controller in the physical HDD does the translation?

1
  • 1
    Cylinders and heads are reference that are not used today. Now we just use LBA sector numbers. The drive hardware may still have to do conversions, but the OS doesn't.
    – cybernard
    Jul 7, 2017 at 0:09

1 Answer 1

1

Beware that "block" has many uses and meanings in computer technology.

When the OS decides to write a file to a HDD:

Who breaks up the file into blocks? The "Virtual File System" in kernel?

You need to back up a bit.
Previously the filesystem was mounted, and before that the filesystem was created on a block device (i.e. a device that performs I/O in fixed-sized units of data).
So this file being written is associated with a filesystem of known attributes and a block device of known attributes.

The filesystem will have its concept of a logical block. The size of this logical block may be a multiple of the I/O block size.
The filesystem will buffer user data in its logical block sizes, and perform I/O in the block device's size.

And who translate those software constructs into cylinders/heads address so the HDD knows how to point the head and spin the plates?

Cylinder/head/sector addressing was deprecated in favor of logical block addressing (aka LBA) a few revisions ago of ATAPI.
Regardless, filesystems typically use logical block or sector addresses for ease of calculations.

The filesystem is responsible for mapping its logical blocks to "physical" blocks of the block device. Note that the block device is typically an abstraction, i.e. a volume or partition on a physical device. That means that the physical block addresses that the filesystem is aware of are actually only relative to the volume, and the volume manager layer must translate these relative block addresses to device block addresses, i.e. the LBAs of the drive.

Or the HDD exposed itself only as abstract "blocks" to "Virtual File System" already and the controller in the physical HDD does the translation?

The modern ATA drive is essentially a collection of blocks addressed by LBA (logical block addressing). Legacy drives use a 512-byte block (sector), and Advanced Format (aka 512E) hard disk drives have 4KB sectors but emulate the 512-byte sector size. Modern, large capacity drives will use a 4KB sector for storage and for I/O.

The integrated controller of the modern drive performs the mapping of LBA to physical sector. The actual cylinder, head, and sector that maps to a particular LBA is known only to the drive so that any type of zone bit recording and relocation for bad sectors can be implemented by the disk drive.


ADDENDUM

Typically the filesystem's logical block size is also the unit of allocation. See Downsides of a small allocation unit size.
Regarding disk sectors, see What are disk sectors for?

2
  • Thank you very much, it is very clear now. Allow me to summarize just to confirm: [Application Layer creates] File --> [FileSystem] OS specific Logical Blocks --> [VolumeManager] universal standard LBA block --> [Hard Drive Controller] Cylinders Heads and Sectors.
    – eliu
    Jul 7, 2017 at 19:31
  • I'm not sure I understand what you're trying to summarize is such few words. The filesystem has its (not the OS) definition of a logical block. There's no such thing as "universal standard LBA". The LBA can be relative (e.g. to a file or fs/volume) or absolute (i.e. drive specific). In between VolumeManager and Hard Drive Controller is the disk driver (which is the host's software interface to the drive).
    – sawdust
    Jul 8, 2017 at 1:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .