linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] scsi: associate bio write hint with WRITE CDB
       [not found] ` <20190103075133.GA5141@infradead.org>
@ 2019-01-03  9:47   ` Randall Huang
  2019-01-03 21:00     ` Douglas Gilbert
  0 siblings, 1 reply; 10+ messages in thread
From: Randall Huang @ 2019-01-03  9:47 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: huangrandall, jejb, martin.petersen, linux-scsi, linux-kernel

On Wed, Jan 02, 2019 at 11:51:33PM -0800, Christoph Hellwig wrote:
> On Wed, Dec 26, 2018 at 12:15:04PM +0800, Randall Huang wrote:
> > In SPC-3, WRITE(10)/(16) support grouping function.
> > Let's associate bio write hint with group number for
> > enabling StreamID or Turbo Write feature.
> > 
> > Signed-off-by: Randall Huang <huangrandall@google.com>
> > ---
> >  drivers/scsi/sd.c | 14 ++++++++++++--
> >  1 file changed, 12 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> > index 4b49cb67617e..28bfa9ed2b54 100644
> > --- a/drivers/scsi/sd.c
> > +++ b/drivers/scsi/sd.c
> > @@ -1201,7 +1201,12 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
> >  		SCpnt->cmnd[11] = (unsigned char) (this_count >> 16) & 0xff;
> >  		SCpnt->cmnd[12] = (unsigned char) (this_count >> 8) & 0xff;
> >  		SCpnt->cmnd[13] = (unsigned char) this_count & 0xff;
> > -		SCpnt->cmnd[14] = SCpnt->cmnd[15] = 0;
> > +		if (rq_data_dir(rq) == WRITE) {
> > +			SCpnt->cmnd[14] = rq->bio->bi_write_hint & 0x3f;
> > +		} else {
> > +			SCpnt->cmnd[14] = 0;
> > +		}
> 
> No need for braces here.
Already send a new version
> 
> But what I'm more worried about is devices not recognizing the feature
> throwing up on the field.  Can you check what SBC version first
> references these or come up with some other decently smart conditional?
My reference is SCSI Block Commands – 3 (SBC-3) Revision 25.
Section 5.32 WRITE (10) and 5.34 WRITE (16)

> Maybe Martin has a good idea, too.

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

* Re: [PATCH] scsi: associate bio write hint with WRITE CDB
  2019-01-03  9:47   ` [PATCH] scsi: associate bio write hint with WRITE CDB Randall Huang
@ 2019-01-03 21:00     ` Douglas Gilbert
  2019-01-03 21:40       ` Ewan D. Milne
  0 siblings, 1 reply; 10+ messages in thread
From: Douglas Gilbert @ 2019-01-03 21:00 UTC (permalink / raw)
  To: Randall Huang, Christoph Hellwig
  Cc: huangrandall, jejb, martin.petersen, linux-scsi, linux-kernel

On 2019-01-03 4:47 a.m., Randall Huang wrote:
> On Wed, Jan 02, 2019 at 11:51:33PM -0800, Christoph Hellwig wrote:
>> On Wed, Dec 26, 2018 at 12:15:04PM +0800, Randall Huang wrote:
>>> In SPC-3, WRITE(10)/(16) support grouping function.
>>> Let's associate bio write hint with group number for
>>> enabling StreamID or Turbo Write feature.
>>>
>>> Signed-off-by: Randall Huang <huangrandall@google.com>
>>> ---
>>>   drivers/scsi/sd.c | 14 ++++++++++++--
>>>   1 file changed, 12 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
>>> index 4b49cb67617e..28bfa9ed2b54 100644
>>> --- a/drivers/scsi/sd.c
>>> +++ b/drivers/scsi/sd.c
>>> @@ -1201,7 +1201,12 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
>>>   		SCpnt->cmnd[11] = (unsigned char) (this_count >> 16) & 0xff;
>>>   		SCpnt->cmnd[12] = (unsigned char) (this_count >> 8) & 0xff;
>>>   		SCpnt->cmnd[13] = (unsigned char) this_count & 0xff;
>>> -		SCpnt->cmnd[14] = SCpnt->cmnd[15] = 0;
>>> +		if (rq_data_dir(rq) == WRITE) {
>>> +			SCpnt->cmnd[14] = rq->bio->bi_write_hint & 0x3f;
>>> +		} else {
>>> +			SCpnt->cmnd[14] = 0;
>>> +		}
>>
>> No need for braces here.
> Already send a new version
>>
>> But what I'm more worried about is devices not recognizing the feature
>> throwing up on the field.  Can you check what SBC version first
>> references these or come up with some other decently smart conditional?
> My reference is SCSI Block Commands – 3 (SBC-3) Revision 25.
> Section 5.32 WRITE (10) and 5.34 WRITE (16)
> 
>> Maybe Martin has a good idea, too.
> 

That is the GROUP NUMBER field. Also found in READ(16) at the same
location within its cdb. The proposed code deserves at least an
explanatory comment.

Since it is relatively recent, perhaps the above should only be done iff:
    - the REPORT SUPPORTED OPERATION CODES (RSOC) command is supported, and
    - in the RSOC entry for WRITE(16), the CDB USAGE DATA field (a bit mask)
      indicates the GROUP NUMBER field is supported

That check can be done once, at disk attachment time where there is already
code to fetch RSOC.


Is there a bi_read_hint ? If not then the bi_write_hint should also be applied
to READ(16). Makes that variable naming look pretty silly though.

Doug Gilbert


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

* Re: [PATCH] scsi: associate bio write hint with WRITE CDB
  2019-01-03 21:00     ` Douglas Gilbert
@ 2019-01-03 21:40       ` Ewan D. Milne
  2019-01-04  4:57         ` Martin K. Petersen
  0 siblings, 1 reply; 10+ messages in thread
From: Ewan D. Milne @ 2019-01-03 21:40 UTC (permalink / raw)
  To: dgilbert, Randall Huang, Christoph Hellwig
  Cc: huangrandall, jejb, martin.petersen, linux-scsi, linux-kernel

On Thu, 2019-01-03 at 16:00 -0500, Douglas Gilbert wrote:
> On 2019-01-03 4:47 a.m., Randall Huang wrote:
> > On Wed, Jan 02, 2019 at 11:51:33PM -0800, Christoph Hellwig wrote:
> > > On Wed, Dec 26, 2018 at 12:15:04PM +0800, Randall Huang wrote:
> > > > In SPC-3, WRITE(10)/(16) support grouping function.
> > > > Let's associate bio write hint with group number for
> > > > enabling StreamID or Turbo Write feature.
> > > > 
> > > > Signed-off-by: Randall Huang <huangrandall@google.com>
> > > > ---
> > > >   drivers/scsi/sd.c | 14 ++++++++++++--
> > > >   1 file changed, 12 insertions(+), 2 deletions(-)
> > > > 
> > > > diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
> > > > index 4b49cb67617e..28bfa9ed2b54 100644
> > > > --- a/drivers/scsi/sd.c
> > > > +++ b/drivers/scsi/sd.c
> > > > @@ -1201,7 +1201,12 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
> > > >   		SCpnt->cmnd[11] = (unsigned char) (this_count >> 16) & 0xff;
> > > >   		SCpnt->cmnd[12] = (unsigned char) (this_count >> 8) & 0xff;
> > > >   		SCpnt->cmnd[13] = (unsigned char) this_count & 0xff;
> > > > -		SCpnt->cmnd[14] = SCpnt->cmnd[15] = 0;
> > > > +		if (rq_data_dir(rq) == WRITE) {
> > > > +			SCpnt->cmnd[14] = rq->bio->bi_write_hint & 0x3f;
> > > > +		} else {
> > > > +			SCpnt->cmnd[14] = 0;
> > > > +		}
> > > 
> > > No need for braces here.
> > 
> > Already send a new version
> > > 
> > > But what I'm more worried about is devices not recognizing the feature
> > > throwing up on the field.  Can you check what SBC version first
> > > references these or come up with some other decently smart conditional?
> > 
> > My reference is SCSI Block Commands – 3 (SBC-3) Revision 25.
> > Section 5.32 WRITE (10) and 5.34 WRITE (16)
> > 
> > > Maybe Martin has a good idea, too.
> 
> That is the GROUP NUMBER field. Also found in READ(16) at the same
> location within its cdb. The proposed code deserves at least an
> explanatory comment.
> 
> Since it is relatively recent, perhaps the above should only be done iff:
>     - the REPORT SUPPORTED OPERATION CODES (RSOC) command is supported, and
>     - in the RSOC entry for WRITE(16), the CDB USAGE DATA field (a bit mask)
>       indicates the GROUP NUMBER field is supported
> 
> That check can be done once, at disk attachment time where there is already
> code to fetch RSOC.
> 
> 
> Is there a bi_read_hint ? If not then the bi_write_hint should also be applied
> to READ(16). Makes that variable naming look pretty silly though.
> 
> Doug Gilbert
> 

SBC-5 says that support for the grouping function is indicated by the
GROUP_SUP bit in the Extended Inquiry VPD page (86h).  I'm not sure how
many devices actually support that page though.  Probably most don't.

What devices actually DO support the grouping and do something with it?

We'd probably need a blacklist flag to turn this off and/or some code in
the error path to discontinue setting the field if the device returns
INVALID FIELD IN CDB or something, like we do for disabling discard
commands if they don't actually work in sd_done().

-Ewan


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

* Re: [PATCH] scsi: associate bio write hint with WRITE CDB
  2019-01-03 21:40       ` Ewan D. Milne
@ 2019-01-04  4:57         ` Martin K. Petersen
  2019-01-04  5:22           ` Randall Huang
  0 siblings, 1 reply; 10+ messages in thread
From: Martin K. Petersen @ 2019-01-04  4:57 UTC (permalink / raw)
  To: Ewan D. Milne
  Cc: dgilbert, Randall Huang, Christoph Hellwig, huangrandall, jejb,
	martin.petersen, linux-scsi, linux-kernel


Ewan,

> SBC-5 says that support for the grouping function is indicated by the
> GROUP_SUP bit in the Extended Inquiry VPD page (86h).  I'm not sure
> how many devices actually support that page though.  Probably most
> don't.

Several devices support it, albeit for various different purposes. It's
one of these wonderful features whose interpretation was left outside
the scope of the spec for a long time.

So even though we absolutely and positively need to make setting GROUP
NUMBER conditional on GROUP_SUP being reported, we also need additional
information from the storage about how the field should be interpreted.

The official way to report hinting is for the device to implement the IO
Advice Hints Grouping mode page. I wrote some code to support that but
no vendors that I know of ended up actually shipping an implementation.
A few implemented my older I/O class proposal but didn't ship that
either despite really convincing performance results.

If Randall has access to a device which implements hinting, I'd love to
know more.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] scsi: associate bio write hint with WRITE CDB
  2019-01-04  4:57         ` Martin K. Petersen
@ 2019-01-04  5:22           ` Randall Huang
  2019-01-04  6:11             ` Martin K. Petersen
  2019-01-10 17:33             ` Alex Lemberg
  0 siblings, 2 replies; 10+ messages in thread
From: Randall Huang @ 2019-01-04  5:22 UTC (permalink / raw)
  To: Martin K. Petersen; +Cc: jejb, linux-scsi, linux-kernel, huangrandall

On Thu, Jan 03, 2019 at 11:57:38PM -0500, Martin K. Petersen wrote:
> 
> Ewan,
> 
> > SBC-5 says that support for the grouping function is indicated by the
> > GROUP_SUP bit in the Extended Inquiry VPD page (86h).  I'm not sure
> > how many devices actually support that page though.  Probably most
> > don't.
> 
> Several devices support it, albeit for various different purposes. It's
> one of these wonderful features whose interpretation was left outside
> the scope of the spec for a long time.
> 
> So even though we absolutely and positively need to make setting GROUP
> NUMBER conditional on GROUP_SUP being reported, we also need additional
> information from the storage about how the field should be interpreted.
> 
> The official way to report hinting is for the device to implement the IO
> Advice Hints Grouping mode page. I wrote some code to support that but
> no vendors that I know of ended up actually shipping an implementation.
> A few implemented my older I/O class proposal but didn't ship that
> either despite really convincing performance results.
> 
> If Randall has access to a device which implements hinting, I'd love to
> know more.
I am working on Android phone.
The idea is to enable write hint for Turbo write UFS feature.
Turbo write feature in UFS 3.x is under discussion in JEDEC JC-64. 
This patch is the under-lying framework for supporting this feature.
> 
> -- 
> Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] scsi: associate bio write hint with WRITE CDB
  2019-01-04  5:22           ` Randall Huang
@ 2019-01-04  6:11             ` Martin K. Petersen
  2019-01-10 17:33             ` Alex Lemberg
  1 sibling, 0 replies; 10+ messages in thread
From: Martin K. Petersen @ 2019-01-04  6:11 UTC (permalink / raw)
  To: Randall Huang
  Cc: Martin K. Petersen, jejb, linux-scsi, linux-kernel, huangrandall


Hi Randall,

> I am working on Android phone.

> The idea is to enable write hint for Turbo write UFS feature.  Turbo
> write feature in UFS 3.x is under discussion in JEDEC JC-64.  This
> patch is the under-lying framework for supporting this feature.

OK, but we can't blindly go setting GROUP NUMBER to a non-zero value.
That'll break a massive amount of devices which will fail READ/WRITE
commands with INVALID FIELD IN CDB.

So aside from requiring the device to report GROUP_SUP=1, we'll need
some sort of indication that this device supports the UFS Turbo Write
feature. If you are engaged with JEDEC on this, please tell them we'll
need a VPD page, a mode page, or something similar to use as trigger to
entertain enabling this feature.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

* Re: [PATCH] scsi: associate bio write hint with WRITE CDB
  2019-01-04  5:22           ` Randall Huang
  2019-01-04  6:11             ` Martin K. Petersen
@ 2019-01-10 17:33             ` Alex Lemberg
  1 sibling, 0 replies; 10+ messages in thread
From: Alex Lemberg @ 2019-01-10 17:33 UTC (permalink / raw)
  To: ihhuang; +Cc: jejb, linux-scsi, linux-kernel, huangrandall, martin.petersen

Hi Randall,

On Fri, 2019-01-04 at 13:22 +0800, Randall Huang wrote:
> On Thu, Jan 03, 2019 at 11:57:38PM -0500, Martin K. Petersen wrote:
> > 
> > Ewan,
> > 
> > > SBC-5 says that support for the grouping function is indicated by the
> > > GROUP_SUP bit in the Extended Inquiry VPD page (86h).  I'm not sure
> > > how many devices actually support that page though.  Probably most
> > > don't.
> > 
> > Several devices support it, albeit for various different purposes. It's
> > one of these wonderful features whose interpretation was left outside
> > the scope of the spec for a long time.
> > 
> > So even though we absolutely and positively need to make setting GROUP
> > NUMBER conditional on GROUP_SUP being reported, we also need additional
> > information from the storage about how the field should be interpreted.
> > 
> > The official way to report hinting is for the device to implement the IO
> > Advice Hints Grouping mode page. I wrote some code to support that but
> > no vendors that I know of ended up actually shipping an implementation.
> > A few implemented my older I/O class proposal but didn't ship that
> > either despite really convincing performance results.
> > 
> > If Randall has access to a device which implements hinting, I'd love to
> > know more.
> I am working on Android phone.
> The idea is to enable write hint for Turbo write UFS feature.
> Turbo write feature in UFS 3.x is under discussion in JEDEC JC-64. 
> This patch is the under-lying framework for supporting this feature.

As far as I know, there are more than one Turbo Write feature
proposals in JEDEC, which are currently under discussion.
For now, not all proposals are using CDB bytes for enabling
TurboWrite.
So, maybe making this change in SCSI is still too early.

> > 
> > -- 
> > Martin K. Petersen	Oracle Linux Engineering


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

* [PATCH] scsi: associate bio write hint with WRITE CDB
@ 2019-01-03  9:55 Randall Huang
  0 siblings, 0 replies; 10+ messages in thread
From: Randall Huang @ 2019-01-03  9:55 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi, linux-kernel; +Cc: huangrandall

In SPC-3, WRITE(10)/(16) support grouping function.
Let's associate bio write hint with group number for
enabling StreamID or Turbo Write feature.

Change-Id: I565c8e0c1d10e17a23e73f2a02c1adbd198b04b3
Signed-off-by: Randall Huang <huangrandall@google.com>
---
 drivers/scsi/sd.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 4b49cb67617e..db48a849107e 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1201,7 +1201,11 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
 		SCpnt->cmnd[11] = (unsigned char) (this_count >> 16) & 0xff;
 		SCpnt->cmnd[12] = (unsigned char) (this_count >> 8) & 0xff;
 		SCpnt->cmnd[13] = (unsigned char) this_count & 0xff;
-		SCpnt->cmnd[14] = SCpnt->cmnd[15] = 0;
+		if (rq_data_dir(rq) == WRITE)
+			SCpnt->cmnd[14] = rq->bio->bi_write_hint & 0x3f;
+		else
+			SCpnt->cmnd[14] = 0;
+		SCpnt->cmnd[15] = 0;
 	} else if ((this_count > 0xff) || (block > 0x1fffff) ||
 		   scsi_device_protection(SCpnt->device) ||
 		   SCpnt->device->use_10_for_rw) {
@@ -1211,9 +1215,13 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
 		SCpnt->cmnd[3] = (unsigned char) (block >> 16) & 0xff;
 		SCpnt->cmnd[4] = (unsigned char) (block >> 8) & 0xff;
 		SCpnt->cmnd[5] = (unsigned char) block & 0xff;
-		SCpnt->cmnd[6] = SCpnt->cmnd[9] = 0;
+		if (rq_data_dir(rq) == WRITE)
+			SCpnt->cmnd[6] = rq->bio->bi_write_hint & 0x1f;
+		else
+			SCpnt->cmnd[6] = 0;
 		SCpnt->cmnd[7] = (unsigned char) (this_count >> 8) & 0xff;
 		SCpnt->cmnd[8] = (unsigned char) this_count & 0xff;
+		SCpnt->cmnd[9] = 0;
 	} else {
 		if (unlikely(rq->cmd_flags & REQ_FUA)) {
 			/*
-- 
2.20.1.415.g653613c723-goog


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

* [PATCH] scsi: associate bio write hint with WRITE CDB
@ 2019-01-03  9:19 Randall Huang
  0 siblings, 0 replies; 10+ messages in thread
From: Randall Huang @ 2019-01-03  9:19 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi, linux-kernel; +Cc: huangrandall

In SPC-3, WRITE(10)/(16) support grouping function.
Let's associate bio write hint with group number for
enabling StreamID or Turbo Write feature.

Bug: 120900381
Change-Id: I565c8e0c1d10e17a23e73f2a02c1adbd198b04b3
Signed-off-by: Randall Huang <huangrandall@google.com>
---
 drivers/scsi/sd.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 4b49cb67617e..831c0c81ffb9 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1201,7 +1201,11 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
 		SCpnt->cmnd[11] = (unsigned char) (this_count >> 16) & 0xff;
 		SCpnt->cmnd[12] = (unsigned char) (this_count >> 8) & 0xff;
 		SCpnt->cmnd[13] = (unsigned char) this_count & 0xff;
-		SCpnt->cmnd[14] = SCpnt->cmnd[15] = 0;
+		if (rq_data_dir(rq) == WRITE) {
+			SCpnt->cmnd[14] = rq->bio->bi_write_hint & 0x3f;
+		} else
+			SCpnt->cmnd[14] = 0;
+		SCpnt->cmnd[15] = 0;
 	} else if ((this_count > 0xff) || (block > 0x1fffff) ||
 		   scsi_device_protection(SCpnt->device) ||
 		   SCpnt->device->use_10_for_rw) {
@@ -1211,9 +1215,13 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
 		SCpnt->cmnd[3] = (unsigned char) (block >> 16) & 0xff;
 		SCpnt->cmnd[4] = (unsigned char) (block >> 8) & 0xff;
 		SCpnt->cmnd[5] = (unsigned char) block & 0xff;
-		SCpnt->cmnd[6] = SCpnt->cmnd[9] = 0;
+		if (rq_data_dir(rq) == WRITE) {
+			SCpnt->cmnd[6] = rq->bio->bi_write_hint & 0x1f;
+		} else
+			SCpnt->cmnd[6] = 0;
 		SCpnt->cmnd[7] = (unsigned char) (this_count >> 8) & 0xff;
 		SCpnt->cmnd[8] = (unsigned char) this_count & 0xff;
+		SCpnt->cmnd[9] = 0;
 	} else {
 		if (unlikely(rq->cmd_flags & REQ_FUA)) {
 			/*
-- 
2.20.1.415.g653613c723-goog


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

* [PATCH] scsi: associate bio write hint with WRITE CDB
@ 2018-12-26  5:51 Randall Huang
  0 siblings, 0 replies; 10+ messages in thread
From: Randall Huang @ 2018-12-26  5:51 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi, linux-kernel; +Cc: huangrandall

In SPC-3, WRITE(10)/(16) support grouping function.
Let's associate bio write hint with group number for
enabling StreamID or Turbo Write feature.

Signed-off-by: Randall Huang <huangrandall@google.com>
---
 drivers/scsi/sd.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 4b49cb67617e..28bfa9ed2b54 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -1201,7 +1201,12 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
 		SCpnt->cmnd[11] = (unsigned char) (this_count >> 16) & 0xff;
 		SCpnt->cmnd[12] = (unsigned char) (this_count >> 8) & 0xff;
 		SCpnt->cmnd[13] = (unsigned char) this_count & 0xff;
-		SCpnt->cmnd[14] = SCpnt->cmnd[15] = 0;
+		if (rq_data_dir(rq) == WRITE) {
+			SCpnt->cmnd[14] = rq->bio->bi_write_hint & 0x3f;
+		} else {
+			SCpnt->cmnd[14] = 0;
+		}
+		SCpnt->cmnd[15] = 0;
 	} else if ((this_count > 0xff) || (block > 0x1fffff) ||
 		   scsi_device_protection(SCpnt->device) ||
 		   SCpnt->device->use_10_for_rw) {
@@ -1211,9 +1216,14 @@ static int sd_setup_read_write_cmnd(struct scsi_cmnd *SCpnt)
 		SCpnt->cmnd[3] = (unsigned char) (block >> 16) & 0xff;
 		SCpnt->cmnd[4] = (unsigned char) (block >> 8) & 0xff;
 		SCpnt->cmnd[5] = (unsigned char) block & 0xff;
-		SCpnt->cmnd[6] = SCpnt->cmnd[9] = 0;
+		if (rq_data_dir(rq) == WRITE) {
+			SCpnt->cmnd[6] = rq->bio->bi_write_hint & 0x1f;
+		} else {
+			SCpnt->cmnd[6] = 0;
+		}
 		SCpnt->cmnd[7] = (unsigned char) (this_count >> 8) & 0xff;
 		SCpnt->cmnd[8] = (unsigned char) this_count & 0xff;
+		SCpnt->cmnd[9] = 0;
 	} else {
 		if (unlikely(rq->cmd_flags & REQ_FUA)) {
 			/*
-- 
2.20.1.415.g653613c723-goog


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

end of thread, other threads:[~2019-01-10 17:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20181226041504.66283-1-huangrandall@google.com>
     [not found] ` <20190103075133.GA5141@infradead.org>
2019-01-03  9:47   ` [PATCH] scsi: associate bio write hint with WRITE CDB Randall Huang
2019-01-03 21:00     ` Douglas Gilbert
2019-01-03 21:40       ` Ewan D. Milne
2019-01-04  4:57         ` Martin K. Petersen
2019-01-04  5:22           ` Randall Huang
2019-01-04  6:11             ` Martin K. Petersen
2019-01-10 17:33             ` Alex Lemberg
2019-01-03  9:55 Randall Huang
  -- strict thread matches above, loose matches on Subject: below --
2019-01-03  9:19 Randall Huang
2018-12-26  5:51 Randall Huang

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).