Re: VFS locking: f_pos thread-safe ?

viro
2004-02-06T11:18:59Z

On Fri, Feb 06, 2004 at 11:19:58AM +0100, Matthias Urlichs wrote:
> I've written one of those... a migration program from an old
> fixed-record-size database to SQL. Somebody had the brilliant idea to let
> two threads read the file concurrently, postprocess the thing (which took
> a variable amount of time depending on what was in the record) and then
> feed it to the database (ditto).

"Somebody made a guess about undefined behaviour"

> When that idea didn't work, I used a separate reader thread and
> coordinated buffer usage with semaphores or whatever, making the thing a
> whole lot more complicated in the process. :-/

"Guess what? It didn't work".

> So count me as one of those people who think that it does matter -- if N
> threads read a file of M bytes, they should collectively get M bytes from
> it (possibly out of order, of course, but that's a different problem).
> Anything else would be inconsistent.

"Please, make that undefined behaviour conform to the guess made by that
somebody. Whaddya mean, 'non-portable' and 'broken application'?!?!?".

> Same thing goes for writing (in append mode as well as otherwise).

Look for ->i_sem use in there.