summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartlomiej Zolnierkiewicz <b.zolnierkiewicz@elka.pw.edu.pl>2004-05-05 17:38:16 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-05-05 17:38:16 -0700
commitf0d61324cd799ceca96c805e1ddf5714cf1b9799 (patch)
tree58055f9c42c41993b091aafa1d62402238d38393
parentfe61f793e676bc2b7d27ab10f126d4e7529c6159 (diff)
[PATCH] ide-disk.c: write cache handling fixes
From: Alan Cox <alan@redhat.com>, Arjan van de Ven <arjanv@redhat.com> - calculate drive->wcache for non-removable disks too - flush the cache before unlocking the door on removable media, otherwise you have a small race with the human
-rw-r--r--drivers/ide/ide-disk.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/ide/ide-disk.c b/drivers/ide/ide-disk.c
index b3d7a002afba..51d7465cba1e 100644
--- a/drivers/ide/ide-disk.c
+++ b/drivers/ide/ide-disk.c
@@ -1729,11 +1729,11 @@ static ide_driver_t idedisk_driver = {
static int idedisk_open(struct inode *inode, struct file *filp)
{
+ u8 cf;
ide_drive_t *drive = inode->i_bdev->bd_disk->private_data;
drive->usage++;
if (drive->removable && drive->usage == 1) {
ide_task_t args;
- u8 cf;
memset(&args, 0, sizeof(ide_task_t));
args.tfRegister[IDE_COMMAND_OFFSET] = WIN_DOORLOCK;
args.command_type = IDE_DRIVE_TASK_NO_DATA;
@@ -1746,18 +1746,18 @@ static int idedisk_open(struct inode *inode, struct file *filp)
*/
if (drive->doorlocking && ide_raw_taskfile(drive, &args, NULL))
drive->doorlocking = 0;
- drive->wcache = 0;
- /* Cache enabled ? */
- if (drive->id->csfo & 1)
- drive->wcache = 1;
- /* Cache command set available ? */
- if (drive->id->cfs_enable_1 & (1<<5))
- drive->wcache = 1;
- /* ATA6 cache extended commands */
- cf = drive->id->command_set_2 >> 24;
- if((cf & 0xC0) == 0x40 && (cf & 0x30) != 0)
- drive->wcache = 1;
}
+ drive->wcache = 0;
+ /* Cache enabled? */
+ if (drive->id->csfo & 1)
+ drive->wcache = 1;
+ /* Cache command set available? */
+ if (drive->id->cfs_enable_1 & (1 << 5))
+ drive->wcache = 1;
+ /* ATA6 cache extended commands */
+ cf = drive->id->command_set_2 >> 24;
+ if ((cf & 0xC0) == 0x40 && (cf & 0x30) != 0)
+ drive->wcache = 1;
return 0;
}
@@ -1779,6 +1779,7 @@ static int ide_cacheflush_p(ide_drive_t *drive)
static int idedisk_release(struct inode *inode, struct file *filp)
{
ide_drive_t *drive = inode->i_bdev->bd_disk->private_data;
+ ide_cacheflush_p(drive);
if (drive->removable && drive->usage == 1) {
ide_task_t args;
memset(&args, 0, sizeof(ide_task_t));
@@ -1788,7 +1789,6 @@ static int idedisk_release(struct inode *inode, struct file *filp)
if (drive->doorlocking && ide_raw_taskfile(drive, &args, NULL))
drive->doorlocking = 0;
}
- ide_cacheflush_p(drive);
drive->usage--;
return 0;
}