Go to file
Mark Vitale 5e09a694ec SOLARIS: Avoid vcache locks when flushing pages for RO vnodes
We have multiple code paths that hold the following locks at the same
time:

    - avc->lock for a vcache
    - The page lock for a page in 'avc'

In order to avoid deadlocks, we need a consistent ordering for obtaining
these two locks. The code in afs_putpage() currently obtains avc->lock
before the page lock (Obtain*Lock is called before pvn_vplist_dirty).

The code in afs_getpages() also obtains avc->lock before the page lock,
but it does so in a loop for all requested pages (via pvn_getpages()).
On the second iteration of that loop, it obtains avc->lock, and the page
from the first iteration of the loop is still locked. Thus, it obtains a
page lock before locking avc->lock in some cases.

Since we have two code paths that obtain those two locks in a different
order, a deadlock can occur. Fixing this properly requires changing at
least one of those code paths, so the locks are taken in a consistent
order. However, doing so is complex and will be done in a separate
future commit.

For this commit, we can avoid the deadlock for RO volumes by simply
avoiding taking avc->lock in afs_putpages() at all while the pages are
locked. Normally, we lock avc->lock because pvn_vplist_dirty() will call
afs_putapage() for each dirty page (and afs_putapage() requires
avc->lock held). But for RO volumes, we will have no dirty pages
(because RO volumes cannot be written to from a client), and so
afs_putapage() will never be called.

So to avoid this deadlock issue for RO volumes, avoid taking avc->lock
across the pvn_vplist_dirty() call in afs_putpage(). We now pass a dummy
pageout callback function to pvn_vplist_dirty() instead, which should
never be called, and which panics if it ever is.

We still need to hold avc->lock a few other times during afs_putpage()
for other minor reasons, but none of these hold page locks at the same
time, so the deadlock issue is still avoided.

[mmeffie: comments, and fix missing write lock, fix lock releases]
[adeason: revised commit message]

Change-Id: Iec11101147220828f319dae4027e7ab1f08483a6
Reviewed-on: https://gerrit.openafs.org/12247
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@dson.org>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
2018-02-04 09:14:56 -05:00
build-tools regen.sh: Use libtoolize -i, and .gitignore generated build-tools 2016-11-06 00:36:18 -04:00
doc doc: add a document to describe rx debug packets 2017-08-03 20:47:43 -04:00
src SOLARIS: Avoid vcache locks when flushing pages for RO vnodes 2018-02-04 09:14:56 -05:00
tests tests: fix out of bounds access in the rx-event test 2017-11-22 20:50:47 -05:00
.gitignore git: add a mailmap file 2016-09-25 21:05:23 -04:00
.mailmap git: add a mailmap file 2016-09-25 21:05:23 -04:00
.splintrc start-splint-support-20030528 2003-05-28 19:18:08 +00:00
acinclude.m4 autoconf: refactor acinclude.m4 2018-01-09 00:22:06 -05:00
CODING CODING: one-line if statements should not have braces 2016-09-11 18:45:00 -04:00
configure-libafs.ac Make OpenAFS 1.8.0pre1 2016-12-07 23:01:51 -05:00
configure.ac Make OpenAFS 1.8.0pre1 2016-12-07 23:01:51 -05:00
CONTRIBUTING openafs: add a contributor code of conduct 2015-09-18 20:38:28 -04:00
INSTALL Document minimum supported compiler versions 2016-08-03 11:13:48 -04:00
libafsdep Move build support files into build-tools 2010-07-14 20:40:36 -07:00
LICENSE readme: move the LICENSE file to the top level directory 2015-08-17 22:10:05 -04:00
Makefile-libafs.in Fix libafs_tree's cross-architecture support 2010-05-24 20:28:41 -07:00
Makefile.in macos: use pkgbuild to build the package on 10.10/10.11 2016-07-17 13:44:48 -04:00
NEWS Default to crypt mode for unix clients 2017-08-05 18:47:04 -04:00
NTMakefile build: remove trailing whitespace from makefiles 2014-10-08 10:46:57 -04:00
README Tweak grammar in README 2015-12-28 19:32:17 -05:00
README-WINDOWS Update windows build documentation 2013-07-02 15:14:09 -07:00
regen.sh regen.sh: Use libtoolize -i, and .gitignore generated build-tools 2016-11-06 00:36:18 -04:00

AFS is a distributed file system that enables users to share and
access all of the files stored in a network of computers as easily as
they access the files stored on their local machines. The file system is
called distributed for this exact reason: files can reside on many
different machines, but are available to users on every machine.

OpenAFS 1.0 was originally released by IBM under the terms of the
IBM Public License 1.0 (IPL10).  For details on IPL10 see the LICENSE
file in this directory.  The current OpenAFS distribution is licensed
under a combination of the IPL10 and many other licenses as granted by
the relevant copyright holders.  The LICENSE file in this directory
contains more details, thought it is not a comprehensive statement.

See INSTALL for information about building and installing OpenAFS
on various platforms.

See CODING for developer information and guidelines.

See NEWS for recent changes to OpenAFS.