On Fri, May 04, 2001 at 01:52:09AM +0100, Matthew Wilcox wrote:

> Let's just go over the semantics we currently have for posix locks,
> and see if we can come up with `better' lock semantics.
> 
> POSIX locks are advisory (unless you do the mandatory lock dance),
> and apply to a byte-range.  They are checked for deadlock, merged with other
> compatible locks (same PID, same `owner').  (this seems redundant and there's
> a question mark by it in the source... never mind.)
> 
> The POSIX locking rules mean that you can do funky things like:
> 
> lock bytes 0-100
> lock bytes 50-150
> unlock bytes 50-150
> 
> and you have bytes 0-49 left locked.  of course, you can then unlock
> bytes 0-100 and it will remove the lock from 0-49, but this behaviour
> seems unintuitive.
> 
> You can also (and this causes a fair bit of ugliness in the kernel code)
> do:
> 
> lock 0-100
> unlock 25-75
> 
> or, even worse
> 
> lock_read 0-100
> lock_write 25-75
> 
> which leaves you with 0-24 read-locked, 25-75 write-locked and 76-100
> read-locked.
> 
> i can't imagine this is behaviour people actually use/desire.  So for
> a new lock type, i propose the following semantics:

Actually, I have written commercial code that relied upon
these semantics. They are extremly flexible and can be of
great use for atomically doing things between processes.

Atomic lock upgrades/downgrades can be used for all sorts
of interesting things :-).

> byte-range, advisory, non-merging, non-deadlock-checking
> 
> Another semantic issue I want to tie down.  Is it useful for different
> threadsd to be able to share a lock?  Or should locks from different
> threads conflict?  I'm currently leaning towards the latter, but you
> may be able to convince me I'm wrong.

The only change that Samba really requires is a POSIX lock that
has *exactly* the same semantics as present, except for the fact
the close(dup(fd)) doesn't drop all locks on an fd.

IMHO we shouldn't "invent" new lock types just because people cannot
see a use for the current semantics. There are uses, believe me.

The only thing we need to fix (IMHO) is the close(dup(fd)) "bug",
which I have yet to see any application treat as anything other
than a spec. bug that must be worked around.

Thanks,

                Jeremy Allison,
                Samba Team.

-- 
--------------------------------------------------------
Buying an operating system without source is like buying
a self-assembly Space Shuttle with no instructions.
--------------------------------------------------------
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [EMAIL PROTECTED]

Reply via email to