Unofficial Hacker News client - receive Push Notifications on replies.

"This message has been on the screen for almost two hours now." (opens external site)

333 points by firloop 2 days ago | unsung.aresluna.org | 218 comments on HN | Vote on HN (opens Hacker News)

View full thread · View on Hacker News

Comment thread (2)

  1. Aren't you mixing up two different scenarios here? If the "eject" / "safe remove" action tells you that the drive isn't ready then it DOES signal that back to the OS, otherwise the OS would tell you "it's safe to remove now" while being unsafe to remove. The same information that blocks within the UI might be used to block fsync() as well -- if it doesn't then that is a choice made by the kernel/driver, not the hardware.
    Replies (1)
    1. The SYNCHRONIZE CACHE command (0x35 / 0x91) instructs the drive to write the volatile cached data to non-volatile cache and/or the recording medium itself. Which one the drive chooses is anyone's guess, but can be influenced by the host beforehand (if the drive supports FUA and the host instructs the drive to WRITE data directly to the medium). This is the mechanism invoked by fsync() after the WRITEs from the host page cache have been issued and is where the drive can lie to the host.

      The START STOP UNIT command (0x1B) is used to instruct the drive to (among other things) unload or eject the medium and/or power down. This is what the Eject / Safely Remove Drive functions invoke. If the drive isn't ready to do so, for example because there is still data sitting in the volatile cache for it to write or a drive self-test is still in progress, it will tell you so.

      These are SCSI commands, which are also used in drives that aren't electrically or physically SCSI. These include SATA, SAS, and USB Mass Storage (both MSC and UAS). That's why they all show up as sdx devices in Linux; sd stands for SCSI Disk (see drivers/scsi/sd.c), and you can't use any of these types of drives without SCSI support enabled in the kernel configuration (CONFIG_SCSI=y).