Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 08 Dec 1999 20:29:38 -0800
From:      Kirk McKusick <mckusick@flamingo.McKusick.COM>
To:        Matthew Dillon <dillon@apollo.backplane.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: mmap/write case brought up again - maybe its time to... 
Message-ID:  <199912090429.UAA15950@flamingo.McKusick.COM>
In-Reply-To: Your message of "Wed, 08 Dec 1999 21:30:37 PST." <199912090530.VAA46209@apollo.backplane.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
Date: Wed, 8 Dec 1999 21:30:37 -0800 (PST)
From: Matthew Dillon <dillon@apollo.backplane.com>
To: freebsd-hackers@FreeBSD.ORG
Cc: Kirk McKusick <mckusick@flamingo.McKusick.COM>
Subject: mmap/write case brought up again - maybe its time to...

    Someone brought up the mmap/write case up again - that's a deadlock
    case that we haven't fixed yet where you write from one descriptor into
    shared writeable file-backed memory area and, from another process,
    do the vise-versa.

    Maybe it's time to make filesystem locks recursive by default.  Doing
    so will allow the above case to be fixed 100% by allowing the read()
    and write() code to pre-lock the underlying vnodes in the correct order
    (by pointer comparison) prior to digging into them.

    I think Kirk may be the best person to make this determination - I
    seem to recall there being some (minor?) issues.  Implementing recursive
    locks may be as simple as adding LK_RECURSE to vn_lock() but I haven't
    researched it heavily.

    This may also tie-in well with the revamping of the VOP code later on.
    There is a significant amount of complexity in the VOP code in having to
    deal with non-recursive locks when a passed argument is supposed to be
    locked and remain locked on return, the return argument is supposed to
    be locked, and the returned argument winds up being the same as the
    passed argument.  With recursive locks as the norm we can remove nearly
    all of those special cases leaving just the one that deals with ".."
    (or perhaps dealing with namei directory locks in a different way).

						-Matt

Recursive locks are easy to implement. Just add LK_CANRECURSE as
the final argument to the call to lockinit at line 1077 in ffs_vget
of ufs/ffs/ffs_vfsops.c. That's it. From there on out all FFS locks
will be recursive and you can begin simplifying away.

	Kirk


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




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