login
Header Space

 
 

Re: nfs: infinite loop in fcntl(F_SETLKW)

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Miklos Szeredi <miklos@...>
Cc: <trond.myklebust@...>, <eshel@...>, <neilb@...>, <akpm@...>, <linux-nfs@...>, <linux-kernel@...>, <linux-fsdevel@...>
Date: Tuesday, April 15, 2008 - 2:58 pm

On Mon, Apr 14, 2008 at 11:15:53PM +0200, Miklos Szeredi wrote:

Not quite; the original idea was that we didn't care about the blocking
lock case, since there's already a lock manager callback for that.
(It's arguably a minor abuse for us to return NLM_LCK_BLOCKED and then
do a grant later even in the case where there's no conflict, but it
works.)  So we only changed the nonblocking case.

Which may be sacrificing elegance for expediency, and I'm not opposed to
fixing that in whatever way seems best.  As a start, we could document
this better.  So:


I'd put it this way (after a quick check of the code to convince myself
I'm remembering this right...):

  1) If FL_SLEEP, then return 0 if granted, and on contention either:
     a) block, or
     b) return -EAGAIN, and call fl_notify when the lock should be
        retried.
  2) If !FL_SLEEP, then either
     a) return a result now, or
     b) return -EINPROGRESS, then call fl_grant with the result.

In each case, b) is only of course allowed if the corresponding callback
is defined.  If you want to support NFS exports, then you should also
take option b) when possible.  (Though note only 1b is *required* to
avoid deadlocks; 2b is basically just a performance enhancement.  We
could perhaps even ditch 2b if we fixed lockd's BKL reliance and made it
multithreaded.)

The names can be confusing, since fl_notify generally results in
granting a previously blocked lock, whereas fl_grant just returns the
result (positive or negative) of a single lock request.  They have the
names they do because of the difference in their semantics:

	- With fl_grant the filesystem says: I'm giving you the final
	  result of the lock operation.  In particular, if I'm telling
	  you it succeeded, that means I've already granted you the
	  lock; don't ask me about it again.

	- With fl_notify the filesystem says: something just happened to
	  this lock.  I'm not guaranteeing anything, I'm just telling
	  you this would be a good time to try the lock again.  Do it
	  and maybe you'll get lucky!

This difference is why the fl_grant() operation takes a status argument
(to tell the lock manager what happened), whereas fl_notify() doesn't
(since it's just a poke in the ribs, and only the subsequent lock call
will give the real status).

Is that explanation helpful?

OK, but I haven't read your patch yet, apologies....

--b.

--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
nfs: infinite loop in fcntl(F_SETLKW), Miklos Szeredi, (Thu Apr 10, 3:51 pm)
Re: nfs: infinite loop in fcntl(F_SETLKW), Trond Myklebust, (Thu Apr 10, 5:02 pm)
Re: nfs: infinite loop in fcntl(F_SETLKW), Trond Myklebust, (Thu Apr 10, 5:07 pm)
Re: nfs: infinite loop in fcntl(F_SETLKW), Trond Myklebust, (Thu Apr 10, 5:20 pm)
Re: nfs: infinite loop in fcntl(F_SETLKW), J. Bruce Fields, (Thu Apr 10, 5:54 pm)
Re: nfs: infinite loop in fcntl(F_SETLKW), Miklos Szeredi, (Sun Apr 13, 4:28 am)
Re: nfs: infinite loop in fcntl(F_SETLKW), J. Bruce Fields, (Mon Apr 14, 1:19 pm)
Re: nfs: infinite loop in fcntl(F_SETLKW), Miklos Szeredi, (Mon Apr 14, 5:15 pm)
Re: nfs: infinite loop in fcntl(F_SETLKW), J. Bruce Fields, (Tue Apr 15, 2:58 pm)
Re: nfs: infinite loop in fcntl(F_SETLKW), Miklos Szeredi, (Wed Apr 16, 12:28 pm)
Re: nfs: infinite loop in fcntl(F_SETLKW), J. Bruce Fields, (Thu Apr 17, 6:26 pm)
Re: nfs: infinite loop in fcntl(F_SETLKW), Miklos Szeredi, (Fri Apr 18, 8:47 am)
Re: nfs: infinite loop in fcntl(F_SETLKW), Miklos Szeredi, (Fri Apr 11, 3:12 pm)
Re: nfs: infinite loop in fcntl(F_SETLKW), J. Bruce Fields, (Sat Apr 12, 8:08 pm)
Re: nfs: infinite loop in fcntl(F_SETLKW), Miklos Szeredi, (Sun Apr 13, 4:13 am)
Re: nfs: infinite loop in fcntl(F_SETLKW), J. Bruce Fields, (Mon Apr 14, 1:07 pm)
Re: nfs: infinite loop in fcntl(F_SETLKW), J. Bruce Fields, (Fri Apr 11, 3:19 pm)
Re: nfs: infinite loop in fcntl(F_SETLKW), Miklos Szeredi, (Fri Apr 11, 3:22 pm)
speck-geostationary