Re: [PATCH v4] sd: Check for unaligned partial completion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Bart,

On 2/16/17 00:10, Bart Van Assche wrote:
> On Wed, 2017-02-15 at 11:12 +0900, Damien Le Moal wrote:
>> +			resid = round_up(resid, sector_size);
>> +			if (resid < good_bytes)
>> +				good_bytes -= resid;
>> +			else
>> +				good_bytes = 0;
>> +			scsi_set_resid(SCpnt, resid);
> 
> Hello Damien,
> 
> If the Data-Out buffer is smaller than a single logical block, can the above
> code cause resid to exceed the Data-Out buffer size? I think we should avoid
> to convert a residual overflow into a residual underflow. Additionally, will
> round_up() work correctly if resid is negative (residual underflow)? How
> about using the following (untested) code instead of the above?
> 
> if (resid > 0) {
>         resid = min(good_bytes, round_up(resid, sector_size));
>         good_bytes -= resid;
>         scsi_set_resid(SCpnt, resid);
> }

Indeed, that would be more solid and cover all possible weird values of
resid. I will resend a v5.

Thanks.

-- 
Damien Le Moal, Ph.D.
Sr. Manager, System Software Research Group,
Western Digital Corporation
Damien.LeMoal@xxxxxxx
(+81) 0466-98-3593 (ext. 513593)
1 kirihara-cho, Fujisawa,
Kanagawa, 252-0888 Japan
www.wdc.com, www.hgst.com



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux