truncate and write change i_size, under i_sem. The i_size test on
the read path doesn't really need to be there, I suspect. It handles
the window where i_size has been decreased by truncate but the filesystem
hasn't finished truncating the blocks yet. It also optimises reads
outside the end of file - no point in calling into the filesystem
to try to map blocks which aren't there.
> I also don't see the anything
> like read_barrier_depends() for lockless algorithms or any atomic reads.
> Even on machines with extremely strong memory consistency models like
> i386, as loff_t is long long, it would seem possible to catch a partial
> update and see an entirely bogus ->i_size value.
That's true. sys_stat() also could see a confusing intermediate value.
A while back Ingo and Linus were tossing around possible solutions to
this based on x86 compare-and-exchange operations, but nothing conclusive
came out of it. It's a "known bug".
-
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/