aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4state.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r--fs/nfsd/nfs4state.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index ceb66170fda3..65978a9aa877 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -2639,6 +2639,26 @@ static bool nfsd4_cb_channel_good(struct nfs4_client *clp)
2639 return clp->cl_minorversion && clp->cl_cb_state == NFSD4_CB_UNKNOWN; 2639 return clp->cl_minorversion && clp->cl_cb_state == NFSD4_CB_UNKNOWN;
2640} 2640}
2641 2641
2642static struct file_lock *nfs4_alloc_init_lease(struct nfs4_delegation *dp, int flag)
2643{
2644 struct file_lock *fl;
2645
2646 fl = locks_alloc_lock();
2647 if (!fl)
2648 return NULL;
2649 locks_init_lock(fl);
2650 fl->fl_lmops = &nfsd_lease_mng_ops;
2651 fl->fl_flags = FL_LEASE;
2652 fl->fl_type = flag == NFS4_OPEN_DELEGATE_READ? F_RDLCK: F_WRLCK;
2653 fl->fl_end = OFFSET_MAX;
2654 fl->fl_owner = (fl_owner_t)dp;
2655 fl->fl_file = dp->dl_vfs_file;
2656 BUG_ON(!fl->fl_file);
2657 fl->fl_pid = current->tgid;
2658 dp->dl_flock = fl;
2659 return fl;
2660}
2661
2642/* 2662/*
2643 * Attempt to hand out a delegation. 2663 * Attempt to hand out a delegation.
2644 */ 2664 */
@@ -2684,20 +2704,9 @@ nfs4_open_delegation(struct svc_fh *fh, struct nfsd4_open *open, struct nfs4_sta
2684 goto out; 2704 goto out;
2685 } 2705 }
2686 status = -ENOMEM; 2706 status = -ENOMEM;
2687 fl = locks_alloc_lock(); 2707 fl = nfs4_alloc_init_lease(dp, flag);
2688 if (!fl) 2708 if (!fl)
2689 goto out; 2709 goto out;
2690 locks_init_lock(fl);
2691 fl->fl_lmops = &nfsd_lease_mng_ops;
2692 fl->fl_flags = FL_LEASE;
2693 fl->fl_type = flag == NFS4_OPEN_DELEGATE_READ? F_RDLCK: F_WRLCK;
2694 fl->fl_end = OFFSET_MAX;
2695 fl->fl_owner = (fl_owner_t)dp;
2696 fl->fl_file = find_readable_file(stp->st_file);
2697 BUG_ON(!fl->fl_file);
2698 fl->fl_pid = current->tgid;
2699 dp->dl_flock = fl;
2700
2701 /* vfs_setlease checks to see if delegation should be handed out. 2710 /* vfs_setlease checks to see if delegation should be handed out.
2702 * the lock_manager callback fl_change is used 2711 * the lock_manager callback fl_change is used
2703 */ 2712 */