aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@redhat.com>2018-02-21 15:11:03 -0500
committerJ. Bruce Fields <bfields@redhat.com>2018-03-20 17:51:13 -0400
commit0af6e690f0d4e8196f6cfa10bad5c9ffff565d9b (patch)
treef8f0a126c52bd9cc9680cd2b12bad973066acf67
parent68b18f52947bbe77bc9ddb23626f30ed5cf70641 (diff)
nfsd: factor out common delegation-destruction code
Pull some duplicated code into a common helper. This changes the order in destroy_delegation a little, but it looks to me like that shouldn't matter. Signed-off-by: J. Bruce Fields <bfields@redhat.com> Reviewed-by: Jeff Layton <jlayton@kernel.org>
-rw-r--r--fs/nfsd/nfs4state.c31
1 files changed, 14 insertions, 17 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 9ec485980bf0..5bbe86c6f1cb 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -894,6 +894,13 @@ static void nfs4_put_deleg_lease(struct nfs4_delegation *dp)
894 } 894 }
895} 895}
896 896
897static void destroy_unhashed_deleg(struct nfs4_delegation *dp)
898{
899 put_clnt_odstate(dp->dl_clnt_odstate);
900 nfs4_put_deleg_lease(dp);
901 nfs4_put_stid(&dp->dl_stid);
902}
903
897void nfs4_unhash_stid(struct nfs4_stid *s) 904void nfs4_unhash_stid(struct nfs4_stid *s)
898{ 905{
899 s->sc_type = 0; 906 s->sc_type = 0;
@@ -985,11 +992,8 @@ static void destroy_delegation(struct nfs4_delegation *dp)
985 spin_lock(&state_lock); 992 spin_lock(&state_lock);
986 unhashed = unhash_delegation_locked(dp); 993 unhashed = unhash_delegation_locked(dp);
987 spin_unlock(&state_lock); 994 spin_unlock(&state_lock);
988 if (unhashed) { 995 if (unhashed)
989 put_clnt_odstate(dp->dl_clnt_odstate); 996 destroy_unhashed_deleg(dp);
990 nfs4_put_deleg_lease(dp);
991 nfs4_put_stid(&dp->dl_stid);
992 }
993} 997}
994 998
995static void revoke_delegation(struct nfs4_delegation *dp) 999static void revoke_delegation(struct nfs4_delegation *dp)
@@ -998,17 +1002,14 @@ static void revoke_delegation(struct nfs4_delegation *dp)
998 1002
999 WARN_ON(!list_empty(&dp->dl_recall_lru)); 1003 WARN_ON(!list_empty(&dp->dl_recall_lru));
1000 1004
1001 put_clnt_odstate(dp->dl_clnt_odstate); 1005 if (clp->cl_minorversion) {
1002 nfs4_put_deleg_lease(dp);
1003
1004 if (clp->cl_minorversion == 0)
1005 nfs4_put_stid(&dp->dl_stid);
1006 else {
1007 dp->dl_stid.sc_type = NFS4_REVOKED_DELEG_STID; 1006 dp->dl_stid.sc_type = NFS4_REVOKED_DELEG_STID;
1007 refcount_inc(&dp->dl_stid.sc_count);
1008 spin_lock(&clp->cl_lock); 1008 spin_lock(&clp->cl_lock);
1009 list_add(&dp->dl_recall_lru, &clp->cl_revoked); 1009 list_add(&dp->dl_recall_lru, &clp->cl_revoked);
1010 spin_unlock(&clp->cl_lock); 1010 spin_unlock(&clp->cl_lock);
1011 } 1011 }
1012 destroy_unhashed_deleg(dp);
1012} 1013}
1013 1014
1014/* 1015/*
@@ -1910,9 +1911,7 @@ __destroy_client(struct nfs4_client *clp)
1910 while (!list_empty(&reaplist)) { 1911 while (!list_empty(&reaplist)) {
1911 dp = list_entry(reaplist.next, struct nfs4_delegation, dl_recall_lru); 1912 dp = list_entry(reaplist.next, struct nfs4_delegation, dl_recall_lru);
1912 list_del_init(&dp->dl_recall_lru); 1913 list_del_init(&dp->dl_recall_lru);
1913 put_clnt_odstate(dp->dl_clnt_odstate); 1914 destroy_unhashed_deleg(dp);
1914 nfs4_put_deleg_lease(dp);
1915 nfs4_put_stid(&dp->dl_stid);
1916 } 1915 }
1917 while (!list_empty(&clp->cl_revoked)) { 1916 while (!list_empty(&clp->cl_revoked)) {
1918 dp = list_entry(clp->cl_revoked.next, struct nfs4_delegation, dl_recall_lru); 1917 dp = list_entry(clp->cl_revoked.next, struct nfs4_delegation, dl_recall_lru);
@@ -7280,9 +7279,7 @@ nfs4_state_shutdown_net(struct net *net)
7280 list_for_each_safe(pos, next, &reaplist) { 7279 list_for_each_safe(pos, next, &reaplist) {
7281 dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); 7280 dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru);
7282 list_del_init(&dp->dl_recall_lru); 7281 list_del_init(&dp->dl_recall_lru);
7283 put_clnt_odstate(dp->dl_clnt_odstate); 7282 destroy_unhashed_deleg(dp);
7284 nfs4_put_deleg_lease(dp);
7285 nfs4_put_stid(&dp->dl_stid);
7286 } 7283 }
7287 7284
7288 nfsd4_client_tracking_exit(net); 7285 nfsd4_client_tracking_exit(net);