We cannot store LWP pointers permanently in lock structures, for two reasons:
1) They are somewhat ephemeral. Dangling pointers are bad.
2) A different LWP may issue the unlock, and in this case, we were not actually
doing the unlock at all. This was causing processes to exit without undoing
fcntl(2) locks. Furthermore, the locks are process-specific to begin with,
so the test was just plain wrong.
Instead, we go back to storing a proc pointer for POSIX locks. In addition, we
add an extra pointer to the LWP, which is used in deadlock detection. After
the lock is granted, this pointer is 0ed and there is no reference to the LWP.
Now evolution can inc my mail again.
malloc types into a structure, a pointer to which is passed around,
instead of an int constant. Allow the limit to be adjusted when the
malloc type is defined, or with a function call, as suggested by
Jonathan Stone.
int lf_advlock __P((struct lockf **,
off_t, caddr_t, int, struct flock *, int));
to
int lf_advlock __P((struct vop_advlock_args *, struct lockf **, off_t));
This matches common usage and is also compatible with similar change
in FreeBSD (though they use u_quad_t as last arg).
- document a data structure invariant in lockf.h
- add KASSERT() to check the invariant.
- be more consistent about dequeuing ourselves from the blocked list
after a tsleep().
- Fix two places where the invariant is violated.
- correct a few comments here and there
- If we're still following a lock dependancy chain after maxlockdepth
processes and haven't gotten back to the start, assume that we're in a
cycle anyway and return EDEADLK.
Fix is a superset of an existing fix in FreeBSD, but independantly
derived.
Fixes kern/3860.