]> rtime.felk.cvut.cz Git - linux-imx.git/commit
fix medium error problems with some arrays which can cause data corruption
authorJames Bottomley <James.Bottomley@suse.de>
Fri, 17 Dec 2010 20:36:34 +0000 (15:36 -0500)
committerAK <andi@firstfloor.org>
Thu, 31 Mar 2011 18:57:45 +0000 (11:57 -0700)
commit90b97746d7566dd0215f757dffcf6ae02017f533
tree3646cca0e82418a67858553a34223cf3bc9d6c8c
parent724f5feecb5ec1b67db3b67b6aa45d08da2caf59
fix medium error problems with some arrays which can cause data corruption

commit a8733c7baf457b071528e385a0b7d4aaec79287c upstream.

Our current handling of medium error assumes that data is returned up
to the bad sector.  This assumption holds good for all disk devices,
all DIF arrays and most ordinary arrays.  However, an LSI array engine
was recently discovered which reports a medium error without returning
any data.  This means that when we report good data up to the medium
error, we've reported junk originally in the buffer as good.  Worse,
if the read consists of requested data plus a readahead, and the error
occurs in readahead, we'll just strip off the readahead and report
junk up to userspace as good data with no error.

The fix for this is to have the error position computation take into
account the amount of data returned by the driver using the scsi
residual data.  Unfortunately, not every driver fills in this data,
but for those who don't, it's set to zero, which means we'll think a
full set of data was transferred and the behaviour will be identical
to the prior behaviour of the code (believe the buffer up to the error
sector).  All modern drivers seem to set the residual, so that should
fix up the LSI failure/corruption case.

Reported-by: Douglas Gilbert <dgilbert@interlog.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
drivers/scsi/sd.c