Skip to content

Commit

Permalink
knfsd: let nfsd manage timing out its own leases
Browse files Browse the repository at this point in the history
Currently there's a race that can cause an oops in generic_setlease.

(In detail: nfsd, when it removes a lease, does so by calling
vfs_setlease() with F_UNLCK and a pointer to the fl_flock field, which
in turn points to nfsd's existing lease; but the first thing the
setlease code does is call time_out_leases().  If the lease happens to
already be beyond the lease break time, that will free the lease and (in
nfsd's release_private callback) set fl_flock to NULL, leading to a NULL
deference soon after in vfs_setlease().)

There are probably other things to fix here too, but it seems inherently
racy to allow either locks.c or nfsd to time out this lease.  Instead
just set the fl_break_time to 0 (preventing locks.c from ever timing out
this lock) and leave it up to nfsd's laundromat thread to deal with it.

Signed-off-by: J. Bruce Fields <[email protected]>
  • Loading branch information
J. Bruce Fields committed Oct 9, 2007
1 parent 354ecbb commit 0272e1f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -1354,8 +1354,12 @@ void nfsd_break_deleg_cb(struct file_lock *fl)
/* only place dl_time is set. protected by lock_kernel*/
dp->dl_time = get_seconds();

/* XXX need to merge NFSD_LEASE_TIME with fs/locks.c:lease_break_time */
fl->fl_break_time = jiffies + NFSD_LEASE_TIME * HZ;
/*
* We don't want the locks code to timeout the lease for us;
* we'll remove it ourself if the delegation isn't returned
* in time.
*/
fl->fl_break_time = 0;

t = kthread_run(do_recall, dp, "%s", "nfs4_cb_recall");
if (IS_ERR(t)) {
Expand Down

0 comments on commit 0272e1f

Please sign in to comment.