• J. Bruce Fields's avatar
    lockd: don't depend on lockd main loop to end grace · c8ab5f2a
    J. Bruce Fields authored
    End lockd's grace period using schedule_delayed_work() instead of a
    check on every pass through the main loop.
    
    After a later patch, we'll depend on lockd to end its grace period even
    if it's not currently handling requests; so it shouldn't depend on being
    woken up from the main loop to do so.
    
    Also, Nakano Hiroaki (who independently produced a similar patch)
    noticed that the current behavior is buggy in the face of jiffies
    wraparound:
    
    	"lockd uses time_before() to determine whether the grace period
    	has expired. This would seem to be enough to avoid timer
    	wrap-around issues, but, unfortunately, that is not the case.
    	The time_* family of comparison functions can be safely used to
    	compare jiffies relatively close in time, but they stop working
    	after approximately LONG_MAX/2 ticks. nfsd can suffer this
    	problem because the time_before() comparison in lockd() is not
    	performed until the first request comes in, which means that if
    	there is no lockd traffic for more than LONG_MAX/2 ticks we are
    	screwed.
    
    	"The implication of this is that once time_before() starts
    	misbehaving any attempt from a NFS client to execute fcntl()
    	will be received with a NLM_LCK_DENIED_GRACE_PERIOD message for
    	25 days (assuming HZ=1000). In other words, the 50 seconds grace
    	period could turn into a grace period of 50 days or more.
    
    	"Note: This bug was analyzed independently by Oda-san
    	<oda@valinux.co.jp> and myself."
    Signed-off-by: default avatarJ. Bruce Fields <bfields@citi.umich.edu>
    Cc: Nakano Hiroaki <nakano.hiroaki@oss.ntt.co.jp>
    Cc: Itsuro Oda <oda@valinux.co.jp>
    c8ab5f2a
svc.c 13.3 KB