Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 12 Mar 1998 22:31:02 -0600
From:      Karl Denninger  <karl@mcs.net>
To:        hackers@FreeBSD.ORG
Subject:   Odd problem we're seeing here
Message-ID:  <19980312223102.50360@mcs.net>

next in thread | raw e-mail | index | archive | help
I'm seeing an interesting problem here.

Assuming two writers to an NFS file from the SAME machine.

Writer #1 has opened the file O_RDWR and intends to do a set of random
operations on it.

Writer #2 has opened the file O_WRONLY|O_APPEND and intends only to add
to the end of the file.

Writer #1 gets an flock on the file, and does things to the file.  He
might even do an ftruncate at some point to roll back the contents.

Writer #2, in the meantime, attempts to get an flock on the file and 
(correctly) blocks, waiting for Writer #1 to finish.

Writer #1 gets done, and releases his lock.

Writer #2 *SOMETIMES DOES NOT WRITE TO THE CORRECT (END OF FILE) PLACE*.

This is difficult to reproduce, but it can be done.  It appears that the
O_APPEND isn't causing the implied lseek(....., 0, SEEK_END) to be done
before each write in this situation.

I'm trying to nail this one down.  The latest patches to the NFS code appear 
to make this happen more often than it did before, but it did occasionally
happen even before the patches.

This NEVER happens on locally mounted files, but occasionally happens
on NFS mounted files.

Yes, I know flock is local to the machine it is executed on.  That's ok; the
two processes ARE running on the same machine.

-CURRENT from a couple of days ago....

--
-- 
Karl Denninger (karl@MCS.Net)| MCSNet - Serving Chicagoland and Wisconsin
http://www.mcs.net/          | T1's from $600 monthly / All Lines K56Flex/DOV
			     | NEW! Corporate ISDN Prices dropped by up to 50%!
Voice: [+1 312 803-MCS1 x219]| EXCLUSIVE NEW FEATURE ON ALL PERSONAL ACCOUNTS
Fax:   [+1 312 803-4929]     | *SPAMBLOCK* Technology now included at no cost

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19980312223102.50360>