Further to the thread titled: "evaluation of scsi_cmnd->resid" started by Andreas Herrmann on 2005/4/13, the attachment adds resid handling to the sd driver. The patch is against lk 2.6.12-rc4 . It treats a "short" DMA read operation in a similar fashion to a MEDIUM ERROR. This way the block layer gets as much valid data as is available. Pathological double errors are not handled (e.g. a MEDIUM ERROR on a latter sector in a multi sector read plus a resid that indicates even less data was read (than the MEDIUM ERROR indicates)). The resid field in the scsi_cmnd structure is initialized to zero so older LLDs that don't set it will not trip up the proposed new code. [resid = requested_xfer_len - actual_xfer_len] While testing this patch I noticed MEDIUM ERRORs and resid>0 on READs (since it mimics the former) do not cause errors to appear in the log. Mid level logging does show what is happening but it is not very practical to have that on for very long. Reporting and counting these occurrences may be a good idea. ChangeLog: - in the sd driver check if the LLD reports an abridged DMA transfer on READ operations. If so process in a similar fashion to a MEDIUM ERROR condition. Signed-off-by: Douglas Gilbert