lkml.org 
[lkml]   [2004]   [May]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: Force IDE cache flush on shutdown

On Thu, May 06, 2004 at 08:55:49AM +0100, Christoph Hellwig wrote:
> On Thu, May 06, 2004 at 09:50:44AM +0200, Arjan van de Ven wrote:
> > > Please don't use reboot notifiers in new driver code. The driver
> > > model has a ->shutdown method for that.
> >
> > there is somewhat of a problem with that; the reboot command potentially
> > runs from the disk in question, so that might never get called since that
> > will keep things busy.
>
> shutdown != remove. Shutdown is called for all devices on shutdown, remove
> isn't called at all at reboot.

Ok the following does the trick for me. Better?

diff -purN linux-2.6.5/drivers/ide/ide-disk.c linux/drivers/ide/ide-disk.c
--- linux-2.6.5/drivers/ide/ide-disk.c 2004-05-06 10:56:55.672139712 +0200
+++ linux/drivers/ide/ide-disk.c 2004-05-06 11:09:19.470065240 +0200
@@ -1820,6 +1820,23 @@ static int idedisk_revalidate_disk(struc
return 0;
}

+static int ide_drive_shutdown(struct device * dev)
+{
+ ide_drive_t * drive = container_of(dev,ide_drive_t,gendev);
+
+ /* safety checks */
+ if (!drive->present)
+ return 0;
+ if (drive->media != ide_disk)
+ return 0;
+ printk("Flushing cache: %s \n", drive->name);
+ ide_cacheflush_p(drive);
+ /* give the hardware time to finish; it may return prematurely to cheat */
+ mdelay(300);
+ return 0;
+}
+
+
static struct block_device_operations idedisk_ops = {
.owner = THIS_MODULE,
.open = idedisk_open,
@@ -1881,6 +1898,7 @@ static void __exit idedisk_exit (void)

static int idedisk_init (void)
{
+ idedisk_driver.gen_driver.shutdown = ide_drive_shutdown;
return ide_register_driver(&idedisk_driver);
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-03-22 14:02    [W:3.529 / U:0.020 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site