0

In this book, the following is mentioned about filesystem addressing:

A file system does not need to concern itself with where on the physical media a block should be put, that is the job of the device's driver

I have some questions related to this:

  1. Do the pointers that are part of the inodes comprise of logical block indices or actual physical addresses?
  2. If it is the former, then where is the mapping of block index to actual physical location stored?
  3. Is there an example of how the physical addressing might look like, e.g. for an SSD device?

1 Answer 1

2

Do the pointers that are part of the inodes comprise of logical block indices or actual physical addresses?

Logical, relative to beginning of the block device that contains the filesystem.

then where is the mapping of block index to actual physical location stored?

That mapping can happen in several layers:

  • If LVM is used, it provides a mapping table that maps range(s) of blocks of a logical volume device to some physical volume block device + offset.

  • Software RAID also maps the blocks of the RAID device in some (simple, systematic) way to the blocks of underlying block device(s), if used.

  • A partition block device applies a simple offset to the logical block numbers, equal to the distance of the beginning of partition from the beginning of the disk.

  • Modern SATA, SAS and NVMe all use addressing based on logical blocks numbered starting from the beginning of the device, so only the disk itself knows the actual physical location. For HDDs, the classic Cylinder/Head/Sector physical addressing become obsolete long ago: modern HDDs are likely to have more physical sectors on outer cylinders than on inner ones, and there may be other complications too. For SSDs, the logical block number is mapped through a wear-levelling table to find the actual physical block number.

When you're viewing each layer in isolation, it is common to call the higher-level block number "logical" and the lower-level one "physical", but when multiple layers are stacked on top of each other, they are effectively all "logical" of some degree or other, until you get within the actual storage device itself.

Is there an example of how the physical addressing might look like, e.g. for an SSD device?

Unless you are developing/debugging/hacking the firmware of an actual SSD, or forensically examining loose flash memory chips desoldered from an SSD, you are not likely to ever have any access to the actual physical addressing. Proprietary, vendor-specific solutions might be involved (translation: each manufacturer can do it however they think best, and the exact implementations are likely considered trade secrets). The situation is similar with modern HDDs.

From the viewpoint of a kernel, all modern storage devices are just long lines of logical blocks of some fixed size, numbered with simple increasing block numbers, starting from block #0 at the beginning of the device. The real physical addressing is of no practical concern outside the actual storage device.

1
  • The quote says "it's the device driver's job to figure out the physical location of the block", and to me, that really sounded like they were thinking CHS addressing. It's partly a terminology thing in that I'm not sure I'd call LVM or software RAID "device" drivers, and of course as you mention, on more modern drives, the device just presents a linearly addressed data area, and deals with the actual physical details itself. Commented Feb 11, 2024 at 12:05

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.