linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Vaughan Cao <vaughan.cao@oracle.com>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] notify block layer when using temporary change to cache_type
Date: Tue, 27 May 2014 20:18:16 +0400	[thread overview]
Message-ID: <1401207496.14454.90.camel@dabdike> (raw)
In-Reply-To: <1401190754-6822-1-git-send-email-vaughan.cao@oracle.com>

On Tue, 2014-05-27 at 19:39 +0800, Vaughan Cao wrote:
> 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,

This is a weird function name.  The name in the vanilla kernel is
cache_type_store().

>  	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);
> +

Is there a reason you cut and paste from sd_revalidate_disk() instead of
just calling it directly?

James




  reply	other threads:[~2014-05-27 16:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2014-05-28  4:58   ` Vaughan Cao
2014-05-28 11:23     ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1401207496.14454.90.camel@dabdike \
    --to=james.bottomley@hansenpartnership.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=vaughan.cao@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).