public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* usage of max_sectors in scsi_host_template
@ 2007-11-06 11:22 Erez Zilber
  2007-11-06 18:32 ` Stefan Richter
  0 siblings, 1 reply; 5+ messages in thread
From: Erez Zilber @ 2007-11-06 11:22 UTC (permalink / raw)
  To: linux-scsi

I'm not sure that I understand the meaning of max_sectors in 
scsi_host_template. Is it the maximum data length of a single SCSI 
command? Is it in bytes? What's the size of a sector?


Thanks,

-- 

____________________________________________________________

Erez Zilber | 972-9-971-7689

Software Engineer, Storage Solutions

Voltaire – _The Grid Backbone_

__

www.voltaire.com <http://www.voltaire.com/>


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: usage of max_sectors in scsi_host_template
  2007-11-06 11:22 usage of max_sectors in scsi_host_template Erez Zilber
@ 2007-11-06 18:32 ` Stefan Richter
  2007-11-07 14:46   ` Erez Zilber
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Richter @ 2007-11-06 18:32 UTC (permalink / raw)
  To: Erez Zilber; +Cc: linux-scsi

Erez Zilber wrote:
> I'm not sure that I understand the meaning of max_sectors in 
> scsi_host_template.

Did you have a look at scsi_mid_low_api.txt?
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/scsi/scsi_mid_low_api.txt;h=6f70f2b9327e1f0db7bc05bdbf2d6ce3b2fcbdcf#l1232

> Is it the maximum data length of a single SCSI command?

Yes.

> Is it in bytes?

No, it is in units of 512 bytes.

> What's the size of a sector?

"Usually" 512 bytes according to above doc.  Always 512 bytes from the
point of view of block/ll_rw_blk.c::blk_queue_max_sectors().
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=block/ll_rw_blk.c;h=75c98d58f4ddf7252e2717e0924b9d6a8925b4e5#l590
-- 
Stefan Richter
-=====-=-=== =-== --==-
http://arcgraph.de/sr/

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

* Re: usage of max_sectors in scsi_host_template
  2007-11-06 18:32 ` Stefan Richter
@ 2007-11-07 14:46   ` Erez Zilber
  2007-11-07 18:53     ` Stefan Richter
  2007-11-07 20:24     ` Mike Christie
  0 siblings, 2 replies; 5+ messages in thread
From: Erez Zilber @ 2007-11-07 14:46 UTC (permalink / raw)
  To: Stefan Richter; +Cc: linux-scsi, open-iscsi

Stefan Richter wrote:
>
> Erez Zilber wrote:
> > I'm not sure that I understand the meaning of max_sectors in
> > scsi_host_template.
>
> Did you have a look at scsi_mid_low_api.txt?
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/scsi/scsi_mid_low_api.txt;h=6f70f2b9327e1f0db7bc05bdbf2d6ce3b2fcbdcf#l1232
>

I will go over it. Thanks for the link.

> > Is it the maximum data length of a single SCSI command?
>
> Yes.
>
> > Is it in bytes?
>
> No, it is in units of 512 bytes.
>
> > What's the size of a sector?
>
> "Usually" 512 bytes according to above doc.  Always 512 bytes from the
> point of view of block/ll_rw_blk.c::blk_queue_max_sectors().
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=block/ll_rw_blk.c;h=75c98d58f4ddf7252e2717e0924b9d6a8925b4e5#l590
>

So, ll_rw_blk actually uses the max_sectors value to chop requests 
larger than max_sectors. Am I right? If yes, I have a problem:

I'm running sgp_dd (on RHAS 4 up4 - kernel version is 2.6.9), so it 
calls scsi-ml directly (without going through ll_rw_blk). I ran it with 
the following parameters:

sgp_dd bs=512 of=/dev/null if=/dev/sg1 bpt=2048 thr=4 time=1 count=100k 
deb=9

I see that a single 1MB command is generated. Here's the debug info from 
sgp_dd:

sgp_dd: if=/dev/sg1 skip=0 of=/dev/null seek=0 count=102400
Start of loop, count=102400, in_num_sect=0, out_num_sect=0
Starting worker thread k=0
sg_start_io: SCSI READ, blk=0 num_blks=2048
Read (10) [28 00 00 00 00 00 00 08 00 00 ]
dir=-3, len=1048576, dxfrp=0x2a9558a000, cmd_len=10

Now, the low-level driver below scsi-ml is open-iscsi over iSER. 
max_sectors is set to 1024 (i.e. 512 kB). Still, the iSER driver 
receives a 1MB command. I guess that the max_sectors value is never 
used. Am I right?

Thanks,
Erez

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

* Re: usage of max_sectors in scsi_host_template
  2007-11-07 14:46   ` Erez Zilber
@ 2007-11-07 18:53     ` Stefan Richter
  2007-11-07 20:24     ` Mike Christie
  1 sibling, 0 replies; 5+ messages in thread
From: Stefan Richter @ 2007-11-07 18:53 UTC (permalink / raw)
  To: Erez Zilber; +Cc: linux-scsi, open-iscsi

Erez Zilber wrote:
> I'm running sgp_dd (on RHAS 4 up4 - kernel version is 2.6.9), so it 
> calls scsi-ml directly (without going through ll_rw_blk).
...
> I guess that the max_sectors value is never used. Am I right?

I have no idea.  However you might be able to track how max_sectors
trickles through the layers via LXR:
http://lxr.free-electrons.com/ident?i=max_sectors
(Not all of the LXR sites out there support search for struct members
but free-electrons' does.)
-- 
Stefan Richter
-=====-=-=== =-== --===
http://arcgraph.de/sr/

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

* Re: usage of max_sectors in scsi_host_template
  2007-11-07 14:46   ` Erez Zilber
  2007-11-07 18:53     ` Stefan Richter
@ 2007-11-07 20:24     ` Mike Christie
  1 sibling, 0 replies; 5+ messages in thread
From: Mike Christie @ 2007-11-07 20:24 UTC (permalink / raw)
  To: open-iscsi; +Cc: Stefan Richter, linux-scsi

Erez Zilber wrote:
> Stefan Richter wrote:
>> Erez Zilber wrote:
>>> I'm not sure that I understand the meaning of max_sectors in
>>> scsi_host_template.
>> Did you have a look at scsi_mid_low_api.txt?
>> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=Documentation/scsi/scsi_mid_low_api.txt;h=6f70f2b9327e1f0db7bc05bdbf2d6ce3b2fcbdcf#l1232
>>
> 
> I will go over it. Thanks for the link.
> 
>>> Is it the maximum data length of a single SCSI command?
>> Yes.
>>
>>> Is it in bytes?
>> No, it is in units of 512 bytes.
>>
>>> What's the size of a sector?
>> "Usually" 512 bytes according to above doc.  Always 512 bytes from the
>> point of view of block/ll_rw_blk.c::blk_queue_max_sectors().
>> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=blob;f=block/ll_rw_blk.c;h=75c98d58f4ddf7252e2717e0924b9d6a8925b4e5#l590
>>
> 
> So, ll_rw_blk actually uses the max_sectors value to chop requests 

Well, there is q->max_sectors and q->max_hw_sectors. In current kernels 
q->max_hw_sectors is scsi_host_template->max_sectors. And q->max_sectors 
is sort of a block layer limit to make sure commands to not get too big.


> larger than max_sectors. Am I right? If yes, I have a problem:
> 
> I'm running sgp_dd (on RHAS 4 up4 - kernel version is 2.6.9), so it 
> calls scsi-ml directly (without going through ll_rw_blk). I ran it with 
> the following parameters:

RHEL4's sg.c does not take into account q->max_sectors or q->max_hw_sectors.

In later kernels like in RHEL5 (probably upstream 2.6.16+), sg.c and 
st.c goes through llw_rw_blkc and obeys the sector limit. For pass 
through like sg and block layer sg, the scsi command is limited by 
q->max_hw_sectors which like I said above is 
scsi_host_template->max_sectors. And normal FS commands are limited by 
min(q->max_hw_sectors, q->max_sectors).

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

end of thread, other threads:[~2007-11-07 20:24 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-06 11:22 usage of max_sectors in scsi_host_template Erez Zilber
2007-11-06 18:32 ` Stefan Richter
2007-11-07 14:46   ` Erez Zilber
2007-11-07 18:53     ` Stefan Richter
2007-11-07 20:24     ` Mike Christie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox