Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 25 Apr 95 19:41:42 MDT
From:      terry@cs.weber.edu (Terry Lambert)
To:        syssgm@devetir.qld.gov.au (Stephen McKay)
Cc:        current@FreeBSD.org, syssgm@devetir.qld.gov.au
Subject:   Re: fcntl F_SETLK backward compatibility hack implemented
Message-ID:  <9504260141.AA03577@cs.weber.edu>
In-Reply-To: <199504250815.SAA15397@pandora.devetir.qld.gov.au> from "Stephen McKay" at Apr 25, 95 06:15:37 pm

next in thread | previous in thread | raw e-mail | index | archive | help
> Well, since nobody objected :-) I went and implemented my proposed fix to
> fcntl locking.  Here are patches to sys/fcntl.h and kern/kern_descrip.c
> plus two test programs.  The 'break' program demonstrates how the scheme
> can fail, and allows you to look at the pretty console warnings.
> The ftest program sets a few random locks and checks for clashes.  If any
> console messages turn up, it has failed.  I compile it on a 1.1.5 system
> and a 2.0 system then run it like:
> 
> $ ./ftest.1.1.5 & ./ftest.2.0 ; sleep 3
> 048901919: 374: OK F_WRLCK SEEK_CUR -3722  6989 ==  2201 to  9189
> 048937427: 375: NO F_WRLCK SEEK_SET  6048  3952 ==  6048 to  9999
> 048940850: 375: -> F_WRLCK SEEK_SET  2201  6989 ==  2201 to  9189 PID:374
> 050970752: 375: OK F_WRLCK SEEK_SET  6048  3952 ==  6048 to  9999
> 051003186: 374: OK F_WRLCK SEEK_CUR    33  1554 ==  4191 to  5744
> ...
> 
> This shows a microsecond timestamp, the pid, success/failure/reason, and
> the expanded flock structure.
> 
> I think the patch works well, and since it changes the real fcntl lock code
> so little, it won't make things any worse!

Coolness, Parker.  8-) 8-).

If you're still in the neighborhood, could you add a long of 'sysid'
to the flock structure, pass 0 for the local machine, and use the number
to preterb the pid hash and lookup and compare it where you compare
the pid?

You should force the sysid to 0 for the F_SETLK, F_SETLKW, and F_GETLK
calls, and implement F_RSETLK, F_RSETLKW, and F_RGETLK, which fail
for non-root users and respect the passed 'sysid' for root users?

This would be a good step towards lockd support.

If it's too much of a pain, forget it and I'll probably hit it at some
indefinite future date myself.


					Regards,
					Terry Lambert
					terry@cs.weber.edu
---
Any opinions in this posting are my own and not those of my present
or previous employers.



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