nfsd4: initialize delegation pointer to lease

The NFSv4 server was initializing the dp->dl_flock pointer by the
somewhat ridiculous method of a locks_copy_lock callback.

Now that setlease uses the passed-in lock instead of doing a copy,
dl_flock no longer gets set, resulting in the lock leaking on delegation
release, and later possible hangs (among other problems).

So, initialize dl_flock and get rid of the callback.

Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by J. Bruce Fields and committed by Linus Torvalds fcf744a9 05fa3135

+2 -17
+2 -17
fs/nfsd/nfs4state.c
··· 2310 2310 } 2311 2311 2312 2312 /* 2313 - * Set the delegation file_lock back pointer. 2314 - * 2315 - * Called from setlease() with lock_kernel() held. 2316 - */ 2317 - static 2318 - void nfsd_copy_lock_deleg_cb(struct file_lock *new, struct file_lock *fl) 2319 - { 2320 - struct nfs4_delegation *dp = (struct nfs4_delegation *)new->fl_owner; 2321 - 2322 - dprintk("NFSD: nfsd_copy_lock_deleg_cb: new fl %p dp %p\n", new, dp); 2323 - if (!dp) 2324 - return; 2325 - dp->dl_flock = new; 2326 - } 2327 - 2328 - /* 2329 2313 * Called from setlease() with lock_kernel() held 2330 2314 */ 2331 2315 static ··· 2339 2355 static const struct lock_manager_operations nfsd_lease_mng_ops = { 2340 2356 .fl_break = nfsd_break_deleg_cb, 2341 2357 .fl_release_private = nfsd_release_deleg_cb, 2342 - .fl_copy_lock = nfsd_copy_lock_deleg_cb, 2343 2358 .fl_mylease = nfsd_same_client_deleg_cb, 2344 2359 .fl_change = nfsd_change_deleg_cb, 2345 2360 }; ··· 2644 2661 fl->fl_file = find_readable_file(stp->st_file); 2645 2662 BUG_ON(!fl->fl_file); 2646 2663 fl->fl_pid = current->tgid; 2664 + dp->dl_flock = fl; 2647 2665 2648 2666 /* vfs_setlease checks to see if delegation should be handed out. 2649 2667 * the lock_manager callbacks fl_mylease and fl_change are used 2650 2668 */ 2651 2669 if ((status = vfs_setlease(fl->fl_file, fl->fl_type, &fl))) { 2652 2670 dprintk("NFSD: setlease failed [%d], no delegation\n", status); 2671 + dp->dl_flock = NULL; 2653 2672 unhash_delegation(dp); 2654 2673 flag = NFS4_OPEN_DELEGATE_NONE; 2655 2674 goto out;