aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sd.c
diff options
context:
space:
mode:
authorVaughan Cao <vaughan.cao@oracle.com>2014-06-03 05:37:30 -0400
committerChristoph Hellwig <hch@lst.de>2014-07-17 16:07:31 -0400
commitcb2fb68d064c16a559483651132815cc378fd1f9 (patch)
treebe186c470b27cfa9af56d464423cb3655bdacf1a /drivers/scsi/sd.c
parent6bb5e6e772f5f71413e290eb9c6a475e9a6d39e2 (diff)
sd: notify block layer when using temporary change to cache_type
This is a fix for commit 39c60a0948cc06139e2fbfe084f83cb7e7deae3b "sd: fix array cache flushing bug causing performance problems" We must notify the block layer via q->flush_flags after a temporary change of the cache_type to write through. Without this, a SYNCHRONIZE CACHE command will still be generated. This patch factors out a helper that can be called from sd_revalidate_disk and cache_type_store. Signed-off-by: Vaughan Cao <vaughan.cao@oracle.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r--drivers/scsi/sd.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 14ec8f521ae8..4056004102ae 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -134,6 +134,19 @@ static const char *sd_cache_types[] = {
134 "write back, no read (daft)" 134 "write back, no read (daft)"
135}; 135};
136 136
137static void sd_set_flush_flag(struct scsi_disk *sdkp)
138{
139 unsigned flush = 0;
140
141 if (sdkp->WCE) {
142 flush |= REQ_FLUSH;
143 if (sdkp->DPOFUA)
144 flush |= REQ_FUA;
145 }
146
147 blk_queue_flush(sdkp->disk->queue, flush);
148}
149
137static ssize_t 150static ssize_t
138cache_type_store(struct device *dev, struct device_attribute *attr, 151cache_type_store(struct device *dev, struct device_attribute *attr,
139 const char *buf, size_t count) 152 const char *buf, size_t count)
@@ -177,6 +190,7 @@ cache_type_store(struct device *dev, struct device_attribute *attr,
177 if (sdkp->cache_override) { 190 if (sdkp->cache_override) {
178 sdkp->WCE = wce; 191 sdkp->WCE = wce;
179 sdkp->RCD = rcd; 192 sdkp->RCD = rcd;
193 sd_set_flush_flag(sdkp);
180 return count; 194 return count;
181 } 195 }
182 196
@@ -2698,7 +2712,6 @@ static int sd_revalidate_disk(struct gendisk *disk)
2698 struct scsi_disk *sdkp = scsi_disk(disk); 2712 struct scsi_disk *sdkp = scsi_disk(disk);
2699 struct scsi_device *sdp = sdkp->device; 2713 struct scsi_device *sdp = sdkp->device;
2700 unsigned char *buffer; 2714 unsigned char *buffer;
2701 unsigned flush = 0;
2702 2715
2703 SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp, 2716 SCSI_LOG_HLQUEUE(3, sd_printk(KERN_INFO, sdkp,
2704 "sd_revalidate_disk\n")); 2717 "sd_revalidate_disk\n"));
@@ -2744,13 +2757,7 @@ static int sd_revalidate_disk(struct gendisk *disk)
2744 * We now have all cache related info, determine how we deal 2757 * We now have all cache related info, determine how we deal
2745 * with flush requests. 2758 * with flush requests.
2746 */ 2759 */
2747 if (sdkp->WCE) { 2760 sd_set_flush_flag(sdkp);
2748 flush |= REQ_FLUSH;
2749 if (sdkp->DPOFUA)
2750 flush |= REQ_FUA;
2751 }
2752
2753 blk_queue_flush(sdkp->disk->queue, flush);
2754 2761
2755 set_capacity(disk, sdkp->capacity); 2762 set_capacity(disk, sdkp->capacity);
2756 sd_config_write_same(sdkp); 2763 sd_config_write_same(sdkp);