flock races causes E_NOLCK

From: Mikhail Kruk (meshko@cs.brandeis.edu)
Date: Tue May 06 2003 - 12:33:16 EST


Hello,
I'm having a problem with flock on 2.4.18 kernel.
The scenario is like this:

parent process:
open file
fcntl(file, FD_SETFD, 1) // set CLOEXEC bit
flock file
fork/exec child process
close file

child process
open the same file
flock this file
close file

This sometimes (often) results in child process being unable to do any
further locking with the error 37 (no locks available).
Removing fcntl and doing an explicit close of all open file desciprotrs in
the beginning of child leads to the same problem.

Here is a post from Pat Knight descirbing similar problem:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=linux.fsdevel.sxr8lna7wp.fsf%40eurologic.com&rnum=4&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3DUTF-8%26q%3DRLIMIT_LOCKS%26btnG%3DGoogle%2BSearch

I can't directly map his problem onto mine, but it's pretty clear that
somehow (usigned) current->locks is decremented when it is 0.

For some reason, however, simplistic test program doens't hit this
condition, so I suspect my analysis is not 100% correct. I'm sure, though,
that current->locks is getting messed up somehow.

-
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/



This archive was generated by hypermail 2b29 : Wed May 07 2003 - 22:00:27 EST