What’s the difference between ‘no caching page mode present’ and ‘assuming drive cache. write through.’

bootdevicesdmesg

Post-POST, post-BIOS screen, post-GRUB; when I boot Debian with a SD card or USB stick plugged in, one of the first things to pop up on the screen (so quickly that usually I don't even notice) looks a little something like:

[sdX] no caching page mode present

text, text, X starts about halfway through that long list of stuff, the text gets noticeably smaller, and just before the window manager starts, I see the very familiar device message (isn't that what dmesg stands for, anyhow?)

[sdX] assuming drive cache. write through

So, technically speaking, what's the difference between those two states? What's being cached? What's the page? What's 'writing through'? And what precludes the assumption of drive cache so that the writing through can happen, directly following boot?

Best Answer

"sd" stands for SCSI disk. When a disk device is first detected, the kernel (among other things) requests the device's caching mode page, which will indicate if the device has an onboard memory buffer that sits in front of the media (disk, flash memory, whatever). In your case the device doesn't have a caching mode page, so the kernel assumes there is no caching of reads or buffering of writes, and that therefore writes to the device will be "write through," i.e. will go directly to the media.

The kernel cares about write buffering because filesystem consistency checking and recovery depends in part on the order in which data is written to storage. If there were a device onboard cache, a filesystem module might want to send the SCSI command to disable the caching of writes so that fsck continues to work properly.

Related Question