From: Tim Hockin <thockin@sun.com>
To: andre@linux-ide.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
alan@redhat.com, torvalds@transmeta.com
Subject: [PATCH] IDE flush on reboot notify
Date: Tue, 16 Oct 2001 10:40:39 -0700 [thread overview]
Message-ID: <3BCC7117.49CAF9F8@sun.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 384 bytes --]
Andre, Alan, Linus,
This patch registers a reboot notifier for IDE devices, forcing a cache
flush before reboot/poweroff. Without it, we've experienced disk
corruption (verified by Seagate, I believe).
Please apply for the next 2.4.x, or let me know of any problems.
thanks!
Tim
--
Tim Hockin
Systems Software Engineer
Sun Microsystems, Cobalt Server Appliances
thockin@sun.com
[-- Attachment #2: ide-reboot.diff --]
[-- Type: text/plain, Size: 2526 bytes --]
diff -ruN dist-2.4.12+patches/drivers/ide/ide.c cvs-2.4.12+patches/drivers/ide/ide.c
--- dist-2.4.12+patches/drivers/ide/ide.c Mon Oct 15 10:21:50 2001
+++ cvs-2.4.12+patches/drivers/ide/ide.c Mon Oct 15 10:21:50 2001
@@ -149,6 +149,7 @@
#include <linux/ide.h>
#include <linux/devfs_fs_kernel.h>
#include <linux/completion.h>
+#include <linux/reboot.h>
#include <asm/byteorder.h>
#include <asm/irq.h>
@@ -3716,6 +3720,58 @@
EXPORT_SYMBOL(system_bus_clock);
+static int ide_notify_reboot(struct notifier_block *this,
+ unsigned long event, void *x)
+{
+ unsigned long flags;
+ ide_hwif_t *hwif;
+ ide_drive_t *drive;
+ int i, unit;
+
+ switch (event) {
+ case SYS_HALT:
+ case SYS_POWER_OFF:
+ case SYS_RESTART:
+ break;
+ default:
+ return NOTIFY_DONE;
+ }
+
+ printk("flushing ide devices: ");
+
+ spin_lock_irqsave(&io_request_lock, flags);
+ for (i = 0; i < MAX_HWIFS; i++) {
+ hwif = &ide_hwifs[i];
+ if (!hwif->present)
+ continue;
+ for (unit = 0; unit < MAX_DRIVES; ++unit) {
+ drive = &hwif->drives[unit];
+ if (!drive->present)
+ continue;
+
+ /* set the drive to standby */
+ printk("%s ", drive->name);
+ SELECT_DRIVE(hwif,drive);
+ udelay (20);
+ OUT_BYTE (event == SYS_RESTART ?
+ WIN_FLUSH_CACHE : WIN_STANDBYNOW1,
+ IDE_COMMAND_REG);
+ if (drive->driver != NULL &&
+ DRIVER(drive)->cleanup(drive))
+ continue;
+ }
+ }
+ printk("\n");
+ spin_unlock_irqrestore(&io_request_lock, flags);
+ return NOTIFY_DONE;
+}
+
+static struct notifier_block ide_notifier = {
+ ide_notify_reboot,
+ NULL,
+ 5
+};
+
/*
* This is gets invoked once during initialization, to set *everything* up
*/
@@ -3743,6 +3799,7 @@
ide_geninit(hwif);
}
+ register_reboot_notifier(&ide_notifier);
return 0;
}
@@ -3774,6 +3831,7 @@
{
int index;
+ unregister_reboot_notifier(&ide_notifier);
for (index = 0; index < MAX_HWIFS; ++index) {
ide_unregister(index);
#if defined(CONFIG_BLK_DEV_IDEDMA) && !defined(CONFIG_DMA_NONPCI)
diff -ruN dist-2.4.12+patches/include/linux/hdreg.h cvs-2.4.12+patches/include/linux/hdreg.h
--- dist-2.4.12+patches/include/linux/hdreg.h Mon Oct 15 10:23:41 2001
+++ cvs-2.4.12+patches/include/linux/hdreg.h Mon Oct 15 10:23:42 2001
@@ -59,6 +59,7 @@
#define WIN_SLEEPNOW2 0x99
#define WIN_CHECKPOWERMODE1 0xE5
#define WIN_CHECKPOWERMODE2 0x98
+#define WIN_FLUSH_CACHE 0xE7
#define WIN_DOORLOCK 0xDE /* lock door on removable drives */
#define WIN_DOORUNLOCK 0xDF /* unlock door on removable drives */
reply other threads:[~2001-10-16 17:44 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3BCC7117.49CAF9F8@sun.com \
--to=thockin@sun.com \
--cc=alan@redhat.com \
--cc=andre@linux-ide.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.