Skip to contentSkip to conversation

SATA hotswap and write caches

DISCUSSION Michel Lespinasse 3 participants 4 messages Jun 3, 2007 – Jun 8, 2007 libata

lore
Share & tools
lore
#0 lore raw

Hi,

I have a few questions about disk cache synchronization. I'm running a setup with several SATA drives (seagate ST3500630AS), installed in hot-swap bays. The host controller is an Intel ICH8 running in AHCI mode, if that makes any difference. Also my kernel is from kernel.org, version 2.6.20.12.

When hot-removing a drive, I get messages such as:

Jun  1 23:48:50 server kernel: ata3.00: detaching (SCSI 2:0:0:0)
Jun  1 23:48:50 server kernel: Synchronizing SCSI cache for disk sdb: 
Jun  1 23:48:50 server kernel: FAILED
Jun  1 23:48:50 server kernel:   status = 0, message = 00, host = 4, driver = 00
Jun  1 23:50:22 server kernel:   <3>ata3: exception Emask 0x10 SAct 0x0 SErr 0x4050002 action 0x2 frozen

When the drive is plugged it mentions about caching:

Jun  1 23:50:32 server kernel: SCSI device sdb: write cache: enabled, read cache: enabled, doesn't support DPO or FUA.

I tried to google for more information about caching but could not come out with much. Mainly I found http://linux-ata.org/shutdown.html but this only talks about server poweron/down and suspend operations, not hotswap issues.

I'm a bit confused about this caching and have two questions:

* Is there anything one needs to know before hot-removing a drive ? Maybe a file under /sys that asks the drive to flush its cache ?

* Does the kernel issue such cache flushing commands when executing sync() or umount() operations ?

Please CC me in replies - I have subscribed to the list but did not get the majordomo confirmation message yet so who knows if that worked :)

Thanks,

Signature · 3 lines
Michel "Walken" Lespinasse
"Bill Gates is a monocle and a Persian cat away from being the villain
in a James Bond movie." -- Dennis Miller
#1 lore raw
Quoted 1 line · Michel Lespinasse

* Is there anything one needs to know before hot-removing a drive ?

Make sure all data is flushed to the drive before removing it.

Quoted 2 lines

* Does the kernel issue such cache flushing commands when executing sync() or umount() operations ?

No. (it should, IMO...)

Jeff

#2 lore raw
Quoted 4 lines · Jeff Garzik
Quoted 1 line · Michel Lespinasse

* Is there anything one needs to know before hot-removing a drive ?

Make sure all data is flushed to the drive before removing it.

Sure. Is there a way to do that, though, other than using /sbin/halt which seems to have, errr, undesirable side-effects :)

Ideally it'd be very nice if that was doable through /sys or /proc files. It'd also be nice if disk standby was user-controllable in this way too. (or maybe both as one step, i.e. a way to tell the kernel we'd like to take the disk out in the safest way possible).

Signature · 3 lines
Michel "Walken" Lespinasse
"Bill Gates is a monocle and a Persian cat away from being the villain
in a James Bond movie." -- Dennis Miller
#3 lore raw
Quoted 5 lines · Michel Lespinasse
Quoted 3 lines · Jeff Garzik
Quoted 1 line · Michel Lespinasse

* Is there anything one needs to know before hot-removing a drive ?

Make sure all data is flushed to the drive before removing it.

Quoted 7 lines

Sure. Is there a way to do that, though, other than using /sbin/halt which seems to have, errr, undesirable side-effects :)

Ideally it'd be very nice if that was doable through /sys or /proc files. It'd also be nice if disk standby was user-controllable in this way too. (or maybe both as one step, i.e. a way to tell the kernel we'd like to take the disk out in the safest way possible).

If you're using barrier, you should be in the clear, I think.

Signature · 1 line
tejun