Bug 187210
Summary: | flock(2) LOCK_EX doesn't work as documented | ||
---|---|---|---|
Product: | [Fedora] Fedora | Reporter: | JW <ohtmvyyn> |
Component: | kernel | Assignee: | Dave Jones <davej> |
Status: | CLOSED UPSTREAM | QA Contact: | Brian Brock <bbrock> |
Severity: | medium | Docs Contact: | |
Priority: | medium | ||
Version: | 5 | CC: | pfrields, wtogami |
Target Milestone: | --- | Keywords: | Reopened |
Target Release: | --- | ||
Hardware: | All | ||
OS: | Linux | ||
Whiteboard: | |||
Fixed In Version: | Doc Type: | Bug Fix | |
Doc Text: | Story Points: | --- | |
Clone Of: | Environment: | ||
Last Closed: | 2006-10-17 05:20:23 UTC | Type: | --- |
Regression: | --- | Mount Type: | --- |
Documentation: | --- | CRM: | |
Verified Versions: | Category: | --- | |
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |
Cloudforms Team: | --- | Target Upstream Version: | |
Embargoed: |
Description
JW
2006-03-29 08:35:56 UTC
[This comment added as part of a mass-update to all open FC4 kernel bugs] FC4 has now transitioned to the Fedora legacy project, which will continue to release security related updates for the kernel. As this bug is not security related, it is unlikely to be fixed in an update for FC4, and has been migrated to FC5. Please retest with Fedora Core 5. Thank you. A new kernel update has been released (Version: 2.6.18-1.2200.fc5) based upon a new upstream kernel release. Please retest against this new kernel, as a large number of patches go into each upstream release, possibly including changes that may address this problem. This bug has been placed in NEEDINFO state. Due to the large volume of inactive bugs in bugzilla, if this bug is still in this state in two weeks time, it will be closed. Should this bug still be relevant after this period, the reporter can reopen the bug at any time. Any other users on the Cc: list of this bug can request that the bug be reopened by adding a comment to the bug. In the last few updates, some users upgrading from FC4->FC5 have reported that installing a kernel update has left their systems unbootable. If you have been affected by this problem please check you only have one version of device-mapper & lvm2 installed. See bug 207474 for further details. If this bug is a problem preventing you from installing the release this version is filed against, please see bug 169613. If this bug has been fixed, but you are now experiencing a different problem, please file a separate bug for the new problem. Thank you. I asked the upstream flock() maintainer to take a look at this. Here's his response: Sorry, you've misunderstood how file locks work. Unfortunately, flock() isn't specified by POSIX or Single Unix (it came from BSD). But it is documented to work this way in the Linux flock(2) manpage: If a process uses open(2) (or similar) to obtain more than one descrip- tor for the same file, these descriptors are treated independently by flock(). An attempt to lock the file using one of these file descrip- tors may be denied by a lock that the calling process has already placed via another descriptor. Your 'structured code' example is just using the wrong tool for the job -- a file lock is inappropriate; you probably wanted to use pthread_mutex_lock() Change state to NOTABUG ... and title to 'working exactly as documented' ;-) >Your 'structured code' example is just using the wrong tool for
>the job -- a file lock is inappropriate; you probably wanted to use
>pthread_mutex_lock()
Wow! What an insightful presumption. You have instantly denigrated a bug based
on some totally insane assumption.
The file lock is being used to lock a real file, not to serialize access to a
thread-shared resource.
Please, given that open() shares the underlying file structure then it would be
correct, regardless of what the flock() maintainer says, to also correct to
share locks.
Sorry, but the maintainer is quite wrong.
Also, your contention that the function works as documented flies in the face of
the actual documentation. To quote:
"A process may only hold one type of lock (shared or exclusive) on a"
"file. Subsequent flock() calls on an already locked file will convert"
"an existing lock to the new lock mode."
So a subsequent lock on already locked file is supposed to work. Because that
is exactly what the documentation says. Read it first, before making the
outlandish claim that the function works "as documented".
Feel free to argue your case on linux-kernel.org Any change in behaviour in this function would have to happen upstream regardless. |