Hi All,

I noticed that the sysfs file cache_type is not is sync with the information in 
the mode page. If we change the WCE attribute in the mode page (sdparm 
--set=WCE /dev/sda  and sdparm --clear=WCE /dev/sda) it does not reflect this 
in the sysfs file.

$ cat /sys/block/sda/device/scsi_disk/6\:0\:0\:0/cache_type 
write back

$ sdparm --clear=WCE /dev/sda
    /dev/sda: TOSHIBA   AL13SEB600        0101

$ cat /sys/block/sda/device/scsi_disk/6\:0\:0\:0/cache_type 
write back

Ideally cache_type should have changed to 'write through' or 'none'. I have a 
small one line change that can fix this one. This patch applies against the 
latest branch "linux-3.15-rc8". 

Few things to note:
1. revalidate_disk() also reads a whole bunch of other things from the mode 
page and I don't know if this will have any side effects. This call is made on 
store_cache_type as well, so I think it should be OK.
2. This is extra work which is not needed in most cases (mode pages hardly 
change). Is there an event that we can subscribe to when the modpages change?

Please review.

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index efcbcd1..5b65ccc 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -256,6 +256,7 @@ static ssize_t
 cache_type_show(struct device *dev, struct device_attribute *attr, char *buf)
 {
        struct scsi_disk *sdkp = to_scsi_disk(dev);
+       revalidate_disk(sdkp->disk);
        int ct = sdkp->RCD + 2*sdkp->WCE;
 
        return snprintf(buf, 40, "%s\n", sd_cache_types[ct]);

Thanks,
Vishwanath


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to