大网数据广告活动
服务器运维问答

How does Linux tell an LSI Megaraid card to flush its cache before shutdown?

· 52CE 我爱测

The LSI Megaraid controller has a Battery back up for its write cache, which allows, in the event of an unanticipated power outage, to retain the cached, not yet written data, so it can write it out to disk next time the server i…

问题原文

原帖链接 · bk. · CC BY-SA 3.0

The LSI Megaraid controller has a Battery back up for its write cache, which allows, in the event of an unanticipated power outage, to retain the cached, not yet written data, so it can write it out to disk next time the server is booted up. In the event of a clean shutdown, this back up is presumably not necessary, as part of the clean shutdown will involve the controller writing out the cached data to disk.

How does the raid controller get informed that the shutdown is about to happen? Presumably this flush must be the last thing to occur after other OS shutdown code, which might involve writing out data or logs to the raid.

Is there some PCIe level signalling that informs peripherals of a pending power down? Does the Megaraid_sas kernel module inform the card of the pending shutdown? Or does a MegaCli command to flush the cache need to be run from an init script for the shutdown?

I've manually added a Megaraid card and additional set of drives to a Linux system which was installed without one, and want to be sure that I don't need to manually add something in to guarantee the cache is consistent on shutdown.

已采纳解答

原帖链接 · Mircea Vutcovici · CC BY-SA 3.0

During shutdown the system will unmount most of the filesystems. Those that can not be unmounted are remounted read-only. Umount syscall will flush the disk caches via VFS, and disk buffers using the driver behind the block device. The block device driver in your case is the generic SCSI driver sg. This will send the data to the SCSI device using the specific driver for your device and a SCSI flush command so that the data is written from internal disk cache to the disk storage medium. All of this is synchronous and the umount will not return until the data is on the disk. For remounted read-only FS the shutdown scripts will just run the sync syscall.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-10-20)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。