Commit 1815a7a3 authored by James Bottomley's avatar James Bottomley

Merge mulgrave.(none):/home/jejb/BK/scsi-sd-cache-2.5

into mulgrave.(none):/home/jejb/BK/scsi-for-linus-2.5
parents 5b29b6c5 f6d999f9
...@@ -580,10 +580,6 @@ static int sd_release(struct inode *inode, struct file *filp) ...@@ -580,10 +580,6 @@ static int sd_release(struct inode *inode, struct file *filp)
if (sd_template.module) if (sd_template.module)
__MOD_DEC_USE_COUNT(sd_template.module); __MOD_DEC_USE_COUNT(sd_template.module);
/* check that we actually have a write back cache to synchronize */
if(sdkp->WCE)
sd_synchronize_cache(dsk_nr, 1);
return 0; return 0;
} }
...@@ -1474,9 +1470,6 @@ static void sd_detach(Scsi_Device * sdp) ...@@ -1474,9 +1470,6 @@ static void sd_detach(Scsi_Device * sdp)
for (dsk_nr = 0; dsk_nr < sd_template.dev_max; dsk_nr++) { for (dsk_nr = 0; dsk_nr < sd_template.dev_max; dsk_nr++) {
sdkp = sd_dsk_arr[dsk_nr]; sdkp = sd_dsk_arr[dsk_nr];
if (sdkp->device == sdp) { if (sdkp->device == sdp) {
sdkp->device = NULL;
sdkp->capacity = 0;
/* sdkp->detaching = 1; */
break; break;
} }
} }
...@@ -1484,6 +1477,16 @@ static void sd_detach(Scsi_Device * sdp) ...@@ -1484,6 +1477,16 @@ static void sd_detach(Scsi_Device * sdp)
if (dsk_nr >= sd_template.dev_max) if (dsk_nr >= sd_template.dev_max)
return; return;
/* check that we actually have a write back cache to synchronize */
if(sdkp->WCE) {
printk(KERN_NOTICE "Synchronizing SCSI cache: ");
sd_synchronize_cache(dsk_nr, 1);
printk("\n");
}
sdkp->device = NULL;
sdkp->capacity = 0;
/* sdkp->detaching = 1; */
if (sdkp->has_been_registered) { if (sdkp->has_been_registered) {
sdkp->has_been_registered = 0; sdkp->has_been_registered = 0;
dev = MKDEV_SD(dsk_nr); dev = MKDEV_SD(dsk_nr);
...@@ -1548,6 +1551,7 @@ static void __exit exit_sd(void) ...@@ -1548,6 +1551,7 @@ static void __exit exit_sd(void)
static int sd_notifier(struct notifier_block *nbt, unsigned long event, void *buf) static int sd_notifier(struct notifier_block *nbt, unsigned long event, void *buf)
{ {
int i; int i;
char *msg = "Synchronizing SCSI caches: ";
if (!(event == SYS_RESTART || event == SYS_HALT if (!(event == SYS_RESTART || event == SYS_HALT
|| event == SYS_POWER_OFF)) || event == SYS_POWER_OFF))
...@@ -1557,9 +1561,16 @@ static int sd_notifier(struct notifier_block *nbt, unsigned long event, void *bu ...@@ -1557,9 +1561,16 @@ static int sd_notifier(struct notifier_block *nbt, unsigned long event, void *bu
if (!sdkp || !sdkp->device) if (!sdkp || !sdkp->device)
continue; continue;
if (sdkp->WCE) if (sdkp->WCE) {
if(msg) {
printk(KERN_NOTICE "%s", msg);
msg = NULL;
}
sd_synchronize_cache(i, 1); sd_synchronize_cache(i, 1);
} }
}
if(!msg)
printk("\n");
return NOTIFY_OK; return NOTIFY_OK;
} }
...@@ -1579,7 +1590,7 @@ static int sd_synchronize_cache(int index, int verbose) ...@@ -1579,7 +1590,7 @@ static int sd_synchronize_cache(int index, int verbose)
sd_dskname(index, buf); sd_dskname(index, buf);
printk("%s: synchronizing cache...", buf); printk("%s ", buf);
} }
SRpnt = scsi_allocate_request(SDpnt); SRpnt = scsi_allocate_request(SDpnt);
...@@ -1607,9 +1618,7 @@ static int sd_synchronize_cache(int index, int verbose) ...@@ -1607,9 +1618,7 @@ static int sd_synchronize_cache(int index, int verbose)
the_result = SRpnt->sr_result; the_result = SRpnt->sr_result;
scsi_release_request(SRpnt); scsi_release_request(SRpnt);
if(verbose) { if(verbose) {
if(the_result == 0) { if(the_result != 0) {
printk("OK\n");
} else {
printk("FAILED\n status = %x, message = %02x, host = %d, driver = %02x\n ", printk("FAILED\n status = %x, message = %02x, host = %d, driver = %02x\n ",
status_byte(the_result), status_byte(the_result),
msg_byte(the_result), msg_byte(the_result),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment