Re: Lockless file reading

From: Jamie Lokier
Date: Thu Aug 28 2003 - 01:14:47 EST


Timo Sirainen wrote:
> I'm sure someone has figured out a way to make a checksum of data that
> can detect if there's even a single bit wrong, if the checksum is
> allowed to take as much space as the data itself. I should read more
> about algorithms..

You said that MD5 wasn't strong enough, and you would like a guarantee.

You won't find a guarantee unless you are prepared to use memory
barriers in your code. _Any_ checksum is going to have a chance of
false validation if you are doing out-of-order reads which can observe
parts of the old and new data, and parts of the old and new checksum.

> How about checksum[n] = data[n-1] ^ data[n]? That looks like it would
> work.

Consider when the data {1,0,1,0} is replaced by {2,0,2,0}.

-- Jamie

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/