* nr_pages calculation in scsi_req_map_sg()
@ 2008-07-22 12:43 Jan Beulich
2008-07-22 13:28 ` Boaz Harrosh
0 siblings, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2008-07-22 12:43 UTC (permalink / raw)
To: James.Bottomley; +Cc: linux-scsi
James,
while reviewing code derived from that function I found this calculation
to be suspicious: I would think that it should get it wrong when both
start and end of the buffer area are misaligned (e.g. consider the case
where sgl->offset equals PAGE_SIZE-1 and bufflen equals 2 - the result
would be 1 when it should have been 2).
Is there something preventing this from happening?
Thanks, Jan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: nr_pages calculation in scsi_req_map_sg()
2008-07-22 12:43 nr_pages calculation in scsi_req_map_sg() Jan Beulich
@ 2008-07-22 13:28 ` Boaz Harrosh
2008-07-22 14:36 ` Jan Beulich
0 siblings, 1 reply; 4+ messages in thread
From: Boaz Harrosh @ 2008-07-22 13:28 UTC (permalink / raw)
To: Jan Beulich; +Cc: James.Bottomley, linux-scsi
Jan Beulich wrote:
> James,
>
> while reviewing code derived from that function I found this calculation
> to be suspicious: I would think that it should get it wrong when both
> start and end of the buffer area are misaligned (e.g. consider the case
> where sgl->offset equals PAGE_SIZE-1 and bufflen equals 2 - the result
> would be 1 when it should have been 2).
> Is there something preventing this from happening?
>
> Thanks, Jan
>
> --
It has been discussed before for example look here:
http://www.spinics.net/lists/linux-scsi/msg13454.html
But for me the main reason it is not fixed is because
this is only called from scsi_execute_async() which
is a deprecated function. It is still used by old code
which is supposed to be removed soon. Any new code will
not be accepted if it uses scsi_execute_async().
Boaz
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: nr_pages calculation in scsi_req_map_sg()
2008-07-22 13:28 ` Boaz Harrosh
@ 2008-07-22 14:36 ` Jan Beulich
2008-07-22 15:11 ` Boaz Harrosh
0 siblings, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2008-07-22 14:36 UTC (permalink / raw)
To: Boaz Harrosh; +Cc: James.Bottomley, linux-scsi
>>> Boaz Harrosh <bharrosh@panasas.com> 22.07.08 15:28 >>>
>Jan Beulich wrote:
>> James,
>>
>> while reviewing code derived from that function I found this calculation
>> to be suspicious: I would think that it should get it wrong when both
>> start and end of the buffer area are misaligned (e.g. consider the case
>> where sgl->offset equals PAGE_SIZE-1 and bufflen equals 2 - the result
>> would be 1 when it should have been 2).
>> Is there something preventing this from happening?
>>
>> Thanks, Jan
>>
>> --
>
>It has been discussed before for example look here:
>http://www.spinics.net/lists/linux-scsi/msg13454.html
>
>But for me the main reason it is not fixed is because
>this is only called from scsi_execute_async() which
>is a deprecated function. It is still used by old code
>which is supposed to be removed soon. Any new code will
>not be accepted if it uses scsi_execute_async().
No, that's a different issue: Even if the sg elements are all contiguous,
the count can be wrong, as described in the original mail. And as said,
I found this in code cloned from scsi_req_map_sg(), hence would be
interested in confirmation of that fact (or explanation why it's not an
issue) regardless of the function itself sitting in a to-be-removed code
path only.
Thanks, Jan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: nr_pages calculation in scsi_req_map_sg()
2008-07-22 14:36 ` Jan Beulich
@ 2008-07-22 15:11 ` Boaz Harrosh
0 siblings, 0 replies; 4+ messages in thread
From: Boaz Harrosh @ 2008-07-22 15:11 UTC (permalink / raw)
To: Jan Beulich; +Cc: James.Bottomley, linux-scsi
Jan Beulich wrote:
>>>> Boaz Harrosh <bharrosh@panasas.com> 22.07.08 15:28 >>>
>> Jan Beulich wrote:
>>> James,
>>>
>>> while reviewing code derived from that function I found this calculation
>>> to be suspicious: I would think that it should get it wrong when both
>>> start and end of the buffer area are misaligned (e.g. consider the case
>>> where sgl->offset equals PAGE_SIZE-1 and bufflen equals 2 - the result
>>> would be 1 when it should have been 2).
>>> Is there something preventing this from happening?
>>>
>>> Thanks, Jan
>>>
>>> --
>> It has been discussed before for example look here:
>> http://www.spinics.net/lists/linux-scsi/msg13454.html
>>
>> But for me the main reason it is not fixed is because
>> this is only called from scsi_execute_async() which
>> is a deprecated function. It is still used by old code
>> which is supposed to be removed soon. Any new code will
>> not be accepted if it uses scsi_execute_async().
>
> No, that's a different issue: Even if the sg elements are all contiguous,
> the count can be wrong, as described in the original mail. And as said,
> I found this in code cloned from scsi_req_map_sg(), hence would be
> interested in confirmation of that fact (or explanation why it's not an
> issue) regardless of the function itself sitting in a to-be-removed code
> path only.
>
> Thanks, Jan
>
lets write it like this:
nr_pages = (bufflen + sgl[0].offset + PAGE_SIZE - 1) / PAGE_SIZE;
now you say:
nr_pages = (2 + (PAGE_SIZE-1) + PAGE_SIZE - 1) / PAGE_SIZE;
which is (PAGE_SIZE + PAGE_SIZE) / PAGE_SIZE; No?
What am I missing?
Boaz
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-07-22 15:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-22 12:43 nr_pages calculation in scsi_req_map_sg() Jan Beulich
2008-07-22 13:28 ` Boaz Harrosh
2008-07-22 14:36 ` Jan Beulich
2008-07-22 15:11 ` Boaz Harrosh
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).