Skip to contentSkip to conversation

zero block writes

DISCUSSION Pat LaVarre 2 participants 6 messages Oct 14, 2003 – Oct 20, 2003 SCSI

lore
Share & tools
lore
#0 lore raw

$

$ sg_dd of=/dev/sg0 if=/dev/null bs=2k count=1
0+0 records in
0+0 records out
$

cdb trace tells me this sg utils idiom assaults the device with a zero block write, specifically:

...
usb-storage: Command WRITE_10 (10 bytes)
usb-storage: 2a 00 00 00 00 00 00 00 00 00
usb-storage: Bulk command S 0x43425355 T 0x1e Trg 0 LUN 0 L 0 F 0 CL 10
...

I wonder if any of you find this sg utils factoid ineffably interesting, as I do?

I know I have a personal history of pain with the scsi folk who dispute the t10 claim that the cdb x 0A 00:00:00 00 00 means write out x100 blocks rather than zero and/or while yet that the cdb x 2A 00 00:00:00:00 00 00:00 00 does mean write out zero blocks.

I know I explicitly wrote code into a revision, at a time beyond the original release of pldd, to discard writes of zero bytes quietly, rather than passing them thru to the device.

I know such pass thru's trip over such unit attentions as x 6 29 reset.

Pat LaVarre

#1 lore raw
Quoted 9 lines · Pat LaVarre

$

$ sg_dd of=/dev/sg0 if=/dev/null bs=2k count=1
0+0 records in
0+0 records out
$

cdb trace tells me this sg utils idiom assaults the device with a zero block write, specifically:

Quoted 8 lines

...
usb-storage: Command WRITE_10 (10 bytes)
usb-storage: 2a 00 00 00 00 00 00 00 00 00
usb-storage: Bulk command S 0x43425355 T 0x1e Trg 0 LUN 0 L 0 F 0 CL 10
...

I wonder if any of you find this sg utils factoid ineffably interesting, as I do?

Pat,
I find some bugs "interesting". BTW if "if=/dev/zero" is used the result is more sane :-)

Also when I tested this on scsi_debug, it complained about getting a NULL data buffer pointer.

Quoted 10 lines

I know I have a personal history of pain with the scsi folk who dispute the t10 claim that the cdb x 0A 00:00:00 00 00 means write out x100 blocks rather than zero and/or while yet that the cdb x 2A 00 00:00:00:00 00 00:00 00 does mean write out zero blocks.

I know I explicitly wrote code into a revision, at a time beyond the original release of pldd, to discard writes of zero bytes quietly, rather than passing them thru to the device.

I know such pass thru's trip over such unit attentions as x 6 29 reset.

A new beta (1.05) should be out tomorrow that fixes this (I just put one up about 1 hour ago).

Doug Gilbert

#2 lore raw
Quoted 2 lines

Also when I tested this on scsi_debug, it complained about getting a NULL data buffer pointer.

CONFIG_SCSI_DEBUG option of .config was new to me, thanks.

Quoted 5 lines
Quoted 3 lines
$ sg_dd of=/dev/sg0 if=/dev/null bs=2k count=1
...
usb-storage: Command WRITE_10 (10 bytes)

...
bugs ...

Is this a bug?

Because CONFIG_SCSI_DEBUG complains of NULL pointers?

What patch do you like? No command at all? A zeroed command with no NULL pointers?

I vote for the patch of no command at all because for me sg_dd exists to let me read and write fragments longer than I can conveniently in the single cdb of a single SG_IO. For me sg_dd doesn't exist to pass thru creative variations of SG_IO. Ditto for you?

I'm guessing I have a clue what round means near hear because to get that clue I reinvented the sg_dd wheel myself. In my pldd I included a -v option to give me a cdb trace without reconfiguring the kernel to run slow, so there I noticed this issue more quickly.

Quoted 2 lines

A new beta (1.05) ... tomorrow ...
one up about 1 hour ago).

Highly responsive, thank you.

I do enjoy perusing the links to the sg home page i.e.
http://www.google.com/search?q=link:www.torque.net/sg/

A google mystery of this moment is why google doesn't yet know that the page where I discuss my reinvented sg_dd indeed does link to sg utils,

I can prove Google has my page cached. The search:
http://www.google.com/search?q=LaVarre+pldd
finds:
http://members.aol.com/plscsi/tools/pldd/

Yet seemingly Google hasn't yet parsed all the links from pldd.

Pat LaVarre

#3 lore raw
Quoted 6 lines
Quoted 4 lines

From: [email protected] ...

Also when I tested this on scsi_debug, it complained about getting a NULL data buffer pointer.

CONFIG_SCSI_DEBUG option of .config ...

I continue to see "scsi_debug" here might mean CONFIG_SCSI_DEBUG. But in review later also I noticed the keyword "scsi_debug" appears nearby in Google in the context:

Linux too has virtual SCSI devices.

For Linux 2.4:
http://www.torque.net/sg/sdebug.html

For Linux 2.6 since 2003 Oct 8:
http://www.torque.net/sg/sdebug26.html

Whether it is the virtual scsi_debug device or the CONFIG_SCSI_DEBUG that complains of NULL data buffer pointers for us, I do not yet know.

Pat LaVarre

#4 lore raw
In reply to Douglas Gilbert
Quoted 12 lines
Quoted 11 lines
$ sg_dd of=/dev/sg0 if=/dev/null bs=2k count=1
0+0 records in
0+0 records out
$

cdb trace tells me this sg utils idiom assaults the device with a zero block write, specifically:
...
usb-storage: Command WRITE_10 (10 bytes)
usb-storage: 2a 00 00 00 00 00 00 00 00 00
...

Quoted 2 lines

A new beta (1.05) should be out tomorrow that fixes this (I just put one up about 1 hour ago).

Looks good, thank you. Again I tried contrasting:

sg_dd of=/dev/sg0 if=/dev/zero bs=2k count=1
sg_dd of=/dev/sg0 if=/dev/null bs=2k count=1

I'm pleased to report the sg3_utils-1.05.tar.gz I fetched today passes cdb's thru drivers/usb/storage/usb.usb_stor_show_command only from /dev/zero, not from /dev/null.

Pat LaVarre

#5 lore raw
In reply to Pat LaVarre
Quoted 7 lines

$

$ sg_dd of=/dev/sg0 if=/dev/null bs=2k count=1
0+0 records in
0+0 records out
$
...
usb-storage:  2a 00 00 00 00 00 00 00 00 00

Kindly offline I'm told I neglected to emphasise, that example of an sg utils sg_dd if=/dev/null command line differs only subtly from the perhaps more familiar:

sg_dd of=/dev/sg0 if=/dev/zero bs=2k count=1

Copying from /dev/zero by design writes lots of zeroed bytes.

Copying from /dev/null via sg_dd doesn't neglect to write, in fact it does write, it just tries to write nothing at a specific address.

Consider, for example:

sg_dd of=/dev/sg0 if=/dev/zero bs=2k seek=259 count=1

That changes the cdb trace so that the starting address passed thru as cdb bytes[2:3:4:5] become x 00:00:01:03 rather than x 00:00:00:00:

x 2A 00 00 00 01 03 00 00 01 00

Pat LaVarre

P.S. Yes indeed I did stumble into this to-me-surprising fact via the bonehead newbie error of typing "null" where I meant "zero".