RE: SCSI cache flush will be lack under some circumstances??

From: Ju, Seokmann
Date: Wed Oct 06 2004 - 10:17:04 EST


Hi,

There are two different cache involved in your concern.
One is cache in each HDD to enhance write performance of it. The other one
is cache in RAID controller.
When you set cache to 'write back' using utility for RAID controller, it
towards to cache in RAID controller.
So, even though kernel doesn't flush SCSI cache, MegaRAID driver will make
sure data consistency including data on both cache through driver's shutdown
entry-point and F/W that controls each physical disk as well.

I hope this helps you.

Regards,


Seokmann


-----Original Message-----
From: OHKUBO Katsuhiko [mailto:ohkubo-k@xxxxxxxxxx]
Sent: Friday, October 01, 2004 5:38 AM
To: linux-kernel@xxxxxxxxxxxxxxx
Subject: SCSI cache flush will be lack under some circumstances??

Dear developers,

I am using Linux 2.6.8.1 with megaraid card.
At boot time, I saw drive cache type was assumed to be 'write through'.

------
megaraid cmm: 2.20.2.0 (Release Date: Thu Aug 19 09:58:33 EDT 2004)
megaraid: 2.20.3.1 (Release Date: Tue Aug 24 09:43:35 EDT 2004)
megaraid: probe new device 0x1000:0x1960:0x1028:0x0520: bus 1:slot 2:func 0
megaraid: fw version:[3.41] bios version:[1.06]
scsi0 : LSI Logic MegaRAID driver
scsi[0]: scanning scsi channel 0 [Phy 0] for non-raid devices
Vendor: SDR Model: GEM318P Rev: 1
Type: Processor ANSI SCSI revision: 02
scsi[0]: scanning scsi channel 1 [virtual] for logical drives
Vendor: MegaRAID Model: LD0 RAID5 79796R Rev: 3.41
Type: Direct-Access ANSI SCSI revision: 02
Vendor: MegaRAID Model: LD1 RAID5 4R Rev: 3.41
Type: Direct-Access ANSI SCSI revision: 02
SCSI device sda: 573022208 512-byte hdwr sectors (293387 MB)
sda: asking for cache data failed
sda: assuming drive cache: write through
...
------

If kernel cannot get cache type, write cache type (sdkp->WCE) is set
to 'write through' mode (=0) in sd_read_cache_type() at drivers/scsi/sd.c.
sdkp->WCE is only reffered in sd_shutdown() to decide
whether SCSI cache flush is necessary or not.
SCSI cache is flushed only at 'write back' mode (sdkp->WCE is 1).

On such behavior, even if I configure my RAID card to 'write back' mode,
Linux kernel assumes it is 'write through' mode because kernel cannot get
write type, so kernel doesn't flush SCSI cache in sd_shutdown().
I think it will be a disk consistency problem.

To avoid such problem, I think write cache type must be assumed to be
'write back' if kernel cannot get write cache type.

--- drivers/scsi/sd.c.old 2004-10-01 17:32:06.000000000 +0900
+++ drivers/scsi/sd.c 2004-10-01 17:32:31.000000000 +0900
@@ -1251,9 +1251,9 @@
}

defaults:
- printk(KERN_ERR "%s: assuming drive cache: write through\n",
+ printk(KERN_ERR "%s: assuming drive cache: write back\n",
diskname);
- sdkp->WCE = 0;
+ sdkp->WCE = 1;
sdkp->RCD = 0;
}


If RAID card is configured to 'write through' mode, and if kernel assumes
it is 'write back' mode, unnecessary cache flush request (no data to flush)
will be done.


Thanks in advance for any help, OHKUBO Katsuhiko.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/