From: Matthew Wilcox <willy@debian.org>
To: linux-fsdevel@vger.kernel.org, neilb@cse.unsw.edu.au,
nfs-devel@linux.kernel.org, trond.myklebust@fys.uio.no,
okir@monad.swb.de
Subject: lockd's interactions with locks.c
Date: Thu, 1 Aug 2002 02:28:21 +0100 [thread overview]
Message-ID: <20020801022821.E3797@parcelfarce.linux.theplanet.co.uk> (raw)
There's no-one specifically listed as maintaining lockd, so i'm cc'ing
everyone involved with NFS.
It's clearly a good idea to remove the BKL from the file locking code
-- we have user-provokable O(n^2) behaviour in there; let's limit the
damage to this subsystem. There are other good cleanups I want to do
that influence this too.
Let's look at the current code in nlmsvc_lock(). We do (paraphrased):
if (!(conflock = posix_test_lock(&file->f_file, &lock->fl))) {
error = posix_lock_file(&file->f_file, &lock->fl, 0);
...
}
if (posix_locks_deadlock(&lock->fl, conflock))
return nlm_deadlock;
nlmsvc_insert_block(block, NLM_NEVER);
if (list_empty(&block->b_call.a_args.lock.fl.fl_block))
posix_block_lock(conflock, &block->b_call.a_args.lock.fl);
Now, unless we export a lock from locks.c that lockd can grab around
all this, we're pretty much hosed. I believe that lockd runs with the
BKL at this point, so there's no race currently. Here's my preferred
alternative (untested, i want to get comments on the idea):
if (wait)
lock->fl.fl_flags |= FL_SLEEP;
again:
error = posix_lock_file(&file->f_file, &lock->fl, 0);
if (!error)
return 0;
if (!wait && error != -EAGAIN)
return error;
grab_lockd_blocking_lock();
nlmsvc_insert_block(block, NLM_NEVER);
have_been_woken_up_already = ...;
release_lockd_blocking_lock();
if (have_been_woken_up_already)
goto again;
return error;
notice we've now got _one_ call into locks.c instead of 4. comments?
you can see a modified locks.c (which is also known-buggy) which supports
the FL_SLEEP semantics at
http://ftp.linux.org.uk/pub/linux/willy/patches/flock-2.5.22/flock-A.diff
--
Revolutions do not require corporate support.
next reply other threads:[~2002-08-01 1:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-08-01 1:28 Matthew Wilcox [this message]
2002-08-02 15:56 ` lockd's interactions with locks.c Trond Myklebust
2002-08-02 17:21 ` Matthew Wilcox
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20020801022821.E3797@parcelfarce.linux.theplanet.co.uk \
--to=willy@debian.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=neilb@cse.unsw.edu.au \
--cc=nfs-devel@linux.kernel.org \
--cc=okir@monad.swb.de \
--cc=trond.myklebust@fys.uio.no \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox