From: Douglas Gilbert <dougg@torque.net>
To: hiren_mehta@agilent.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: question about scsi generic behavior
Date: Sat, 09 Jun 2001 13:19:07 -0400 [thread overview]
Message-ID: <3B225A8B.C03306AD@torque.net> (raw)
In-Reply-To: <FEEBE78C8360D411ACFD00D0B7477971880AA8@xsj02.sjs.agilent.com>
hiren_mehta@agilent.com wrote:
>
> Hi List,
>
> I am trying to use sg_dd which goes through the scsi generic driver.
> This is how use it.
>
> sg_dd if=/dev/zero of=/dev/sg5 bs=4096 count=1
>
> And sg5 is actually a disk.
See "man sg_dd" which is provided with the sg_utils
package. The "bs" argument given to sg_dd must match
the physical block size of the device. [This is different from
"dd" in which bs can sensibly be an integral multiple of the
physical block size.] The above command would have written
zeroes over the first 512 byte block on the disk. So the
above should probably read:
sg_dd if=/dev/zero of=/dev/sg5 bs=512 count=8
> The question that I have is, does the scsi generic driver have a knowledge
> about what kind of device it is dealing with ?
No. It assumes as little as possible. It only does a
READ CAPACITY if a "count" argument is not given.
One reason is that not all devices that I may wish
to use sg_dd on support READ CAPACITY (or the figure
is wrong (e.g. cdroms)). In the case of the above
command, only one WRITE(10) SCSI command should be
issued to the disk.
> As you know, all disk drives
> have block size of 512 bytes. So, according to the above command, I am
> suppose
> write 4096 bytes of data. But when my driver gets the CDB, I see that
> the transfer length is set to 1 block instead of 8 blocks.
As expected.
> And to transfer
> 4096 bytes, obviously we need transfer length=8 in CDB. Since, the transfer
> length
> is set to 1, the drive comes back with 1 512 byte block and then comes back
> with
> a good status because of which sg_dd command is not able to transfer all
> 4096 bytes
> of data.
>
> Any input on this ?
To control the number of blocks transferred with each SCSI
command, the sg_dd command has a "bpt" (blocks per transfer)
command. Its default value is 128. The command:
sg_dd if=/dev/zero of=/dev/sg5 bs=512 count=8 bpt=5
will transmit two SCSI commands, the first writing 5
512 byte blocks from block number 0, while the second
SCSI command will write 3 blocks from block number 5.
[/dev/sg5 is again assumed to be a disk blocked to 512 bytes.]
This is a finer grain of control than offered by the
generic dd command.
Doug Gilbert
next prev parent reply other threads:[~2001-06-09 17:21 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-06-08 23:22 question about scsi generic behavior hiren_mehta
2001-06-09 17:19 ` Douglas Gilbert [this message]
-- strict thread matches above, loose matches on Subject: below --
2001-06-08 23:49 David Chambliss
2001-06-09 0:13 hiren_mehta
2001-06-09 0:37 ` Alan Cox
2001-06-09 1:27 hiren_mehta
2001-06-09 4:40 David Chambliss
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=3B225A8B.C03306AD@torque.net \
--to=dougg@torque.net \
--cc=hiren_mehta@agilent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.