[Top][All Lists]

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

Salvage partial reads

From: Eliyahu Saks
Subject: Salvage partial reads
Date: Tue, 7 Jan 2020 16:39:10 +0200


On linux, reads to a block device that fail on a sector return a
failure for the *entire* read, as if no bytes were read, and the location
of the exact sector that failed is not provided. [You can test this out,
and it's also apparent from reading the kernel source code.]

However, when doing a direct read, the good sectors up until the read error
are actually transferred to the userspace buffer, even though read()
returns -1.

Perhaps you could implement a 'paranoid' mode that prewrites known data to
the read buffer before each read. On an I/O error, it can see how many
'sectors' no longer match the original data and assume that those sectors
were correctly read, and mark the following sector as a 'bad sector'. It
would be possible to write a routine to check for the correctness/validity
of this method vs. a specific drive one a known bad sector is found.


Eli Saks

reply via email to

[Prev in Thread] Current Thread [Next in Thread]