bug-glibc
[Top][All Lists]
Advanced

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

pread() and pwrite() emulation


From: Per Schröder
Subject: pread() and pwrite() emulation
Date: Mon, 02 Dec 2002 15:58:06 +0100

Hello,

I'm implementing a threaded database server. To me, the pread() and pwrite() routines are very useful since they allow several threads to do I/O to the database file simultaneously. By creating an I/O queue, we can increase I/O throughput (disks may be striped or mirrored; disk head movement may be optimized, etc).

The virtue of pread() and pwrite() is that they can "seek" and read/write atomically which is essential in a threaded application. On platforms where pread/pwrite is not provided, we have to open each file multiple times to be able to do parallell I/O. (dup() is not useful here.)

However, when looking at the glibc sources I see that sometimes pread/pwrite are emulated with calls to seek and read/write. This is extremely scary. In our database server, the pread/pwrite calls MUST NOT EVER be emulated in this way. This is extremely important and I can't stress this enough! Emulated pread/pwrite calls open up a race condition, so that in some cases, reads and writes go to the wrong location on disk. This will corrupt the database files (which can be very huge and valuable). Since the bug does not always occur, a user can test the database server, think that everything is OK, and then have a glitch once a week. This is very nasty!

Is there some way that I can assure that glibc will not attempt to emulate pread/pwrite? Can I tell it somehow? Can I ask it if emulation is used?

Please help! If I'm not 100% sure that pread/pwrite are not emulated, I will have to resort to the ugly "multiple-open" implementation to support multiple parallell I/O's.

Regards
/Per Schröder
http://developer.mimer.com





reply via email to

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