linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] notify block layer when using temporary change to cache_type
@ 2014-05-27 11:39 Vaughan Cao
  2014-05-27 16:18 ` James Bottomley
  0 siblings, 1 reply; 4+ messages in thread
From: Vaughan Cao @ 2014-05-27 11:39 UTC (permalink / raw)
  To: JBottomley; +Cc: linux-scsi, linux-kernel, vaughan.cao

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 temporary change the cache_type to write through.
If not, SYNCHRONIZE CACHE command will still be generated.

Signed-off-by: Vaughan Cao <vaughan.cao@oracle.com>
---
 drivers/scsi/sd.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 6146b9d..366e48b 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -144,6 +144,7 @@ sd_store_cache_type(struct device *dev, struct device_attribute *attr,
 	struct scsi_sense_hdr sshdr;
 	static const char temp[] = "temporary ";
 	int len;
+	unsigned flush;
 
 	if (sdp->type != TYPE_DISK)
 		/* no cache control on RBC devices; theoretically they
@@ -174,6 +175,17 @@ sd_store_cache_type(struct device *dev, struct device_attribute *attr,
 	if (sdkp->cache_override) {
 		sdkp->WCE = wce;
 		sdkp->RCD = rcd;
+
+		/* set flush_flags to notify the block layer */
+		flush = 0;
+		if (sdkp->WCE) {
+			flush |= REQ_FLUSH;
+			if (sdkp->DPOFUA)
+				flush |= REQ_FUA;
+		}
+
+		blk_queue_flush(sdkp->disk->queue, flush);
+
 		return count;
 	}
 
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-05-28 11:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-27 11:39 [PATCH] notify block layer when using temporary change to cache_type Vaughan Cao
2014-05-27 16:18 ` James Bottomley
2014-05-28  4:58   ` Vaughan Cao
2014-05-28 11:23     ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).