public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* lockd's interactions with locks.c
@ 2002-08-01  1:28 Matthew Wilcox
  2002-08-02 15:56 ` Trond Myklebust
  0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2002-08-01  1:28 UTC (permalink / raw)
  To: linux-fsdevel, neilb, nfs-devel, trond.myklebust, okir


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.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2002-08-02 17:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-08-01  1:28 lockd's interactions with locks.c Matthew Wilcox
2002-08-02 15:56 ` Trond Myklebust
2002-08-02 17:21   ` Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox