]> git.baikalelectronics.ru Git - kernel.git/commit
nfsd: bump dl_time when unhashing delegation
authorJeff Layton <jeff.layton@primarydata.com>
Tue, 22 Jul 2014 17:52:06 +0000 (13:52 -0400)
committerJ. Bruce Fields <bfields@redhat.com>
Tue, 22 Jul 2014 19:34:47 +0000 (15:34 -0400)
commitcd2fc254dae1597fdb0b7b1c2805d37dd2de26a3
treec8cd6088f54b2e85615107e3bfb59d25b8e6c3bf
parentfe935ad8b1528ac7d5fbc01625e7c9ac5621be1d
nfsd: bump dl_time when unhashing delegation

There's a potential race between a lease break and DELEGRETURN call.

Suppose a lease break comes in and queues the workqueue job for a
delegation, but it doesn't run just yet. Then, a DELEGRETURN comes in
finds the delegation and calls destroy_delegation on it to unhash it and
put its primary reference.

Next, the workqueue job runs and queues the delegation back onto the
del_recall_lru list, issues the CB_RECALL and puts the final reference.
With that, the final reference to the delegation is put, but it's still
on the LRU list.

When we go to unhash a delegation, it's because we intend to get rid of
it soon afterward, so we don't want lease breaks to mess with it once
that occurs. Fix this by bumping the dl_time whenever we unhash a
delegation, to ensure that lease breaks don't monkey with it.

I believe this is a regression due to commit 00e8958d7d3 (nfsd: Avoid
taking state_lock while holding inode lock in nfsd_break_one_deleg).
Prior to that, the state_lock was held in the lm_break callback itself,
and that would have prevented this race.

Cc: Trond Myklebust <trond.myklebust@primarydata.com>
Signed-off-by: Jeff Layton <jlayton@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4state.c