diff options
author | Benny Halevy <bhalevy@primarydata.com> | 2014-05-30 09:09:30 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2014-06-04 15:42:04 -0400 |
commit | cdc975050077d707d5315e51c2b05a763d4895e5 (patch) | |
tree | 00d3ed0fb57346f3c1721baf3be2448cdd5ad0a5 /fs/nfsd | |
parent | 7025005d5e7715efa24c115c45f4a6b4f1a545de (diff) |
nfsd4: rename recall_lock to state_lock
...as the name is a bit more descriptive and we've started using it for
other purposes.
Signed-off-by: Benny Halevy <bhalevy@primarydata.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/nfs4state.c | 63 |
1 files changed, 32 insertions, 31 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 05ca64c4599d..63e764506bd2 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -81,7 +81,7 @@ static DEFINE_MUTEX(client_mutex); | |||
81 | * effort to decrease the scope of the client_mutex, this spinlock may | 81 | * effort to decrease the scope of the client_mutex, this spinlock may |
82 | * eventually cover more: | 82 | * eventually cover more: |
83 | */ | 83 | */ |
84 | static DEFINE_SPINLOCK(recall_lock); | 84 | static DEFINE_SPINLOCK(state_lock); |
85 | 85 | ||
86 | static struct kmem_cache *openowner_slab; | 86 | static struct kmem_cache *openowner_slab; |
87 | static struct kmem_cache *lockowner_slab; | 87 | static struct kmem_cache *lockowner_slab; |
@@ -235,9 +235,9 @@ static void nfsd4_free_file(struct nfs4_file *f) | |||
235 | static inline void | 235 | static inline void |
236 | put_nfs4_file(struct nfs4_file *fi) | 236 | put_nfs4_file(struct nfs4_file *fi) |
237 | { | 237 | { |
238 | if (atomic_dec_and_lock(&fi->fi_ref, &recall_lock)) { | 238 | if (atomic_dec_and_lock(&fi->fi_ref, &state_lock)) { |
239 | hlist_del(&fi->fi_hash); | 239 | hlist_del(&fi->fi_hash); |
240 | spin_unlock(&recall_lock); | 240 | spin_unlock(&state_lock); |
241 | iput(fi->fi_inode); | 241 | iput(fi->fi_inode); |
242 | nfsd4_free_file(fi); | 242 | nfsd4_free_file(fi); |
243 | } | 243 | } |
@@ -436,7 +436,7 @@ static void unhash_stid(struct nfs4_stid *s) | |||
436 | static void | 436 | static void |
437 | hash_delegation_locked(struct nfs4_delegation *dp, struct nfs4_file *fp) | 437 | hash_delegation_locked(struct nfs4_delegation *dp, struct nfs4_file *fp) |
438 | { | 438 | { |
439 | lockdep_assert_held(&recall_lock); | 439 | lockdep_assert_held(&state_lock); |
440 | 440 | ||
441 | list_add(&dp->dl_perfile, &fp->fi_delegations); | 441 | list_add(&dp->dl_perfile, &fp->fi_delegations); |
442 | list_add(&dp->dl_perclnt, &dp->dl_stid.sc_client->cl_delegations); | 442 | list_add(&dp->dl_perclnt, &dp->dl_stid.sc_client->cl_delegations); |
@@ -446,11 +446,11 @@ hash_delegation_locked(struct nfs4_delegation *dp, struct nfs4_file *fp) | |||
446 | static void | 446 | static void |
447 | unhash_delegation(struct nfs4_delegation *dp) | 447 | unhash_delegation(struct nfs4_delegation *dp) |
448 | { | 448 | { |
449 | spin_lock(&recall_lock); | 449 | spin_lock(&state_lock); |
450 | list_del_init(&dp->dl_perclnt); | 450 | list_del_init(&dp->dl_perclnt); |
451 | list_del_init(&dp->dl_perfile); | 451 | list_del_init(&dp->dl_perfile); |
452 | list_del_init(&dp->dl_recall_lru); | 452 | list_del_init(&dp->dl_recall_lru); |
453 | spin_unlock(&recall_lock); | 453 | spin_unlock(&state_lock); |
454 | if (dp->dl_file) { | 454 | if (dp->dl_file) { |
455 | nfs4_put_deleg_lease(dp->dl_file); | 455 | nfs4_put_deleg_lease(dp->dl_file); |
456 | put_nfs4_file(dp->dl_file); | 456 | put_nfs4_file(dp->dl_file); |
@@ -1161,13 +1161,13 @@ destroy_client(struct nfs4_client *clp) | |||
1161 | struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); | 1161 | struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); |
1162 | 1162 | ||
1163 | INIT_LIST_HEAD(&reaplist); | 1163 | INIT_LIST_HEAD(&reaplist); |
1164 | spin_lock(&recall_lock); | 1164 | spin_lock(&state_lock); |
1165 | while (!list_empty(&clp->cl_delegations)) { | 1165 | while (!list_empty(&clp->cl_delegations)) { |
1166 | dp = list_entry(clp->cl_delegations.next, struct nfs4_delegation, dl_perclnt); | 1166 | dp = list_entry(clp->cl_delegations.next, struct nfs4_delegation, dl_perclnt); |
1167 | list_del_init(&dp->dl_perclnt); | 1167 | list_del_init(&dp->dl_perclnt); |
1168 | list_move(&dp->dl_recall_lru, &reaplist); | 1168 | list_move(&dp->dl_recall_lru, &reaplist); |
1169 | } | 1169 | } |
1170 | spin_unlock(&recall_lock); | 1170 | spin_unlock(&state_lock); |
1171 | while (!list_empty(&reaplist)) { | 1171 | while (!list_empty(&reaplist)) { |
1172 | dp = list_entry(reaplist.next, struct nfs4_delegation, dl_recall_lru); | 1172 | dp = list_entry(reaplist.next, struct nfs4_delegation, dl_recall_lru); |
1173 | destroy_delegation(dp); | 1173 | destroy_delegation(dp); |
@@ -2539,9 +2539,9 @@ static void nfsd4_init_file(struct nfs4_file *fp, struct inode *ino) | |||
2539 | fp->fi_lease = NULL; | 2539 | fp->fi_lease = NULL; |
2540 | memset(fp->fi_fds, 0, sizeof(fp->fi_fds)); | 2540 | memset(fp->fi_fds, 0, sizeof(fp->fi_fds)); |
2541 | memset(fp->fi_access, 0, sizeof(fp->fi_access)); | 2541 | memset(fp->fi_access, 0, sizeof(fp->fi_access)); |
2542 | spin_lock(&recall_lock); | 2542 | spin_lock(&state_lock); |
2543 | hlist_add_head(&fp->fi_hash, &file_hashtbl[hashval]); | 2543 | hlist_add_head(&fp->fi_hash, &file_hashtbl[hashval]); |
2544 | spin_unlock(&recall_lock); | 2544 | spin_unlock(&state_lock); |
2545 | } | 2545 | } |
2546 | 2546 | ||
2547 | void | 2547 | void |
@@ -2712,15 +2712,15 @@ find_file(struct inode *ino) | |||
2712 | unsigned int hashval = file_hashval(ino); | 2712 | unsigned int hashval = file_hashval(ino); |
2713 | struct nfs4_file *fp; | 2713 | struct nfs4_file *fp; |
2714 | 2714 | ||
2715 | spin_lock(&recall_lock); | 2715 | spin_lock(&state_lock); |
2716 | hlist_for_each_entry(fp, &file_hashtbl[hashval], fi_hash) { | 2716 | hlist_for_each_entry(fp, &file_hashtbl[hashval], fi_hash) { |
2717 | if (fp->fi_inode == ino) { | 2717 | if (fp->fi_inode == ino) { |
2718 | get_nfs4_file(fp); | 2718 | get_nfs4_file(fp); |
2719 | spin_unlock(&recall_lock); | 2719 | spin_unlock(&state_lock); |
2720 | return fp; | 2720 | return fp; |
2721 | } | 2721 | } |
2722 | } | 2722 | } |
2723 | spin_unlock(&recall_lock); | 2723 | spin_unlock(&state_lock); |
2724 | return NULL; | 2724 | return NULL; |
2725 | } | 2725 | } |
2726 | 2726 | ||
@@ -2757,6 +2757,7 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp) | |||
2757 | struct nfs4_client *clp = dp->dl_stid.sc_client; | 2757 | struct nfs4_client *clp = dp->dl_stid.sc_client; |
2758 | struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); | 2758 | struct nfsd_net *nn = net_generic(clp->net, nfsd_net_id); |
2759 | 2759 | ||
2760 | lockdep_assert_held(&state_lock); | ||
2760 | /* We're assuming the state code never drops its reference | 2761 | /* We're assuming the state code never drops its reference |
2761 | * without first removing the lease. Since we're in this lease | 2762 | * without first removing the lease. Since we're in this lease |
2762 | * callback (and since the lease code is serialized by the kernel | 2763 | * callback (and since the lease code is serialized by the kernel |
@@ -2793,11 +2794,11 @@ static void nfsd_break_deleg_cb(struct file_lock *fl) | |||
2793 | */ | 2794 | */ |
2794 | fl->fl_break_time = 0; | 2795 | fl->fl_break_time = 0; |
2795 | 2796 | ||
2796 | spin_lock(&recall_lock); | 2797 | spin_lock(&state_lock); |
2797 | fp->fi_had_conflict = true; | 2798 | fp->fi_had_conflict = true; |
2798 | list_for_each_entry(dp, &fp->fi_delegations, dl_perfile) | 2799 | list_for_each_entry(dp, &fp->fi_delegations, dl_perfile) |
2799 | nfsd_break_one_deleg(dp); | 2800 | nfsd_break_one_deleg(dp); |
2800 | spin_unlock(&recall_lock); | 2801 | spin_unlock(&state_lock); |
2801 | } | 2802 | } |
2802 | 2803 | ||
2803 | static | 2804 | static |
@@ -3077,9 +3078,9 @@ static int nfs4_setlease(struct nfs4_delegation *dp) | |||
3077 | fp->fi_lease = fl; | 3078 | fp->fi_lease = fl; |
3078 | fp->fi_deleg_file = get_file(fl->fl_file); | 3079 | fp->fi_deleg_file = get_file(fl->fl_file); |
3079 | atomic_set(&fp->fi_delegees, 1); | 3080 | atomic_set(&fp->fi_delegees, 1); |
3080 | spin_lock(&recall_lock); | 3081 | spin_lock(&state_lock); |
3081 | hash_delegation_locked(dp, fp); | 3082 | hash_delegation_locked(dp, fp); |
3082 | spin_unlock(&recall_lock); | 3083 | spin_unlock(&state_lock); |
3083 | return 0; | 3084 | return 0; |
3084 | out_free: | 3085 | out_free: |
3085 | locks_free_lock(fl); | 3086 | locks_free_lock(fl); |
@@ -3094,14 +3095,14 @@ static int nfs4_set_delegation(struct nfs4_delegation *dp, struct nfs4_file *fp) | |||
3094 | dp->dl_file = fp; | 3095 | dp->dl_file = fp; |
3095 | if (!fp->fi_lease) | 3096 | if (!fp->fi_lease) |
3096 | return nfs4_setlease(dp); | 3097 | return nfs4_setlease(dp); |
3097 | spin_lock(&recall_lock); | 3098 | spin_lock(&state_lock); |
3098 | atomic_inc(&fp->fi_delegees); | 3099 | atomic_inc(&fp->fi_delegees); |
3099 | if (fp->fi_had_conflict) { | 3100 | if (fp->fi_had_conflict) { |
3100 | spin_unlock(&recall_lock); | 3101 | spin_unlock(&state_lock); |
3101 | return -EAGAIN; | 3102 | return -EAGAIN; |
3102 | } | 3103 | } |
3103 | hash_delegation_locked(dp, fp); | 3104 | hash_delegation_locked(dp, fp); |
3104 | spin_unlock(&recall_lock); | 3105 | spin_unlock(&state_lock); |
3105 | return 0; | 3106 | return 0; |
3106 | } | 3107 | } |
3107 | 3108 | ||
@@ -3435,7 +3436,7 @@ nfs4_laundromat(struct nfsd_net *nn) | |||
3435 | clp->cl_clientid.cl_id); | 3436 | clp->cl_clientid.cl_id); |
3436 | expire_client(clp); | 3437 | expire_client(clp); |
3437 | } | 3438 | } |
3438 | spin_lock(&recall_lock); | 3439 | spin_lock(&state_lock); |
3439 | list_for_each_safe(pos, next, &nn->del_recall_lru) { | 3440 | list_for_each_safe(pos, next, &nn->del_recall_lru) { |
3440 | dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); | 3441 | dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); |
3441 | if (net_generic(dp->dl_stid.sc_client->net, nfsd_net_id) != nn) | 3442 | if (net_generic(dp->dl_stid.sc_client->net, nfsd_net_id) != nn) |
@@ -3447,7 +3448,7 @@ nfs4_laundromat(struct nfsd_net *nn) | |||
3447 | } | 3448 | } |
3448 | list_move(&dp->dl_recall_lru, &reaplist); | 3449 | list_move(&dp->dl_recall_lru, &reaplist); |
3449 | } | 3450 | } |
3450 | spin_unlock(&recall_lock); | 3451 | spin_unlock(&state_lock); |
3451 | list_for_each_safe(pos, next, &reaplist) { | 3452 | list_for_each_safe(pos, next, &reaplist) { |
3452 | dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); | 3453 | dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); |
3453 | revoke_delegation(dp); | 3454 | revoke_delegation(dp); |
@@ -4912,7 +4913,7 @@ static u64 nfsd_find_all_delegations(struct nfs4_client *clp, u64 max, | |||
4912 | struct nfs4_delegation *dp, *next; | 4913 | struct nfs4_delegation *dp, *next; |
4913 | u64 count = 0; | 4914 | u64 count = 0; |
4914 | 4915 | ||
4915 | lockdep_assert_held(&recall_lock); | 4916 | lockdep_assert_held(&state_lock); |
4916 | list_for_each_entry_safe(dp, next, &clp->cl_delegations, dl_perclnt) { | 4917 | list_for_each_entry_safe(dp, next, &clp->cl_delegations, dl_perclnt) { |
4917 | if (victims) | 4918 | if (victims) |
4918 | list_move(&dp->dl_recall_lru, victims); | 4919 | list_move(&dp->dl_recall_lru, victims); |
@@ -4928,9 +4929,9 @@ u64 nfsd_forget_client_delegations(struct nfs4_client *clp, u64 max) | |||
4928 | LIST_HEAD(victims); | 4929 | LIST_HEAD(victims); |
4929 | u64 count; | 4930 | u64 count; |
4930 | 4931 | ||
4931 | spin_lock(&recall_lock); | 4932 | spin_lock(&state_lock); |
4932 | count = nfsd_find_all_delegations(clp, max, &victims); | 4933 | count = nfsd_find_all_delegations(clp, max, &victims); |
4933 | spin_unlock(&recall_lock); | 4934 | spin_unlock(&state_lock); |
4934 | 4935 | ||
4935 | list_for_each_entry_safe(dp, next, &victims, dl_recall_lru) | 4936 | list_for_each_entry_safe(dp, next, &victims, dl_recall_lru) |
4936 | revoke_delegation(dp); | 4937 | revoke_delegation(dp); |
@@ -4944,11 +4945,11 @@ u64 nfsd_recall_client_delegations(struct nfs4_client *clp, u64 max) | |||
4944 | LIST_HEAD(victims); | 4945 | LIST_HEAD(victims); |
4945 | u64 count; | 4946 | u64 count; |
4946 | 4947 | ||
4947 | spin_lock(&recall_lock); | 4948 | spin_lock(&state_lock); |
4948 | count = nfsd_find_all_delegations(clp, max, &victims); | 4949 | count = nfsd_find_all_delegations(clp, max, &victims); |
4949 | list_for_each_entry_safe(dp, next, &victims, dl_recall_lru) | 4950 | list_for_each_entry_safe(dp, next, &victims, dl_recall_lru) |
4950 | nfsd_break_one_deleg(dp); | 4951 | nfsd_break_one_deleg(dp); |
4951 | spin_unlock(&recall_lock); | 4952 | spin_unlock(&state_lock); |
4952 | 4953 | ||
4953 | return count; | 4954 | return count; |
4954 | } | 4955 | } |
@@ -4957,9 +4958,9 @@ u64 nfsd_print_client_delegations(struct nfs4_client *clp, u64 max) | |||
4957 | { | 4958 | { |
4958 | u64 count = 0; | 4959 | u64 count = 0; |
4959 | 4960 | ||
4960 | spin_lock(&recall_lock); | 4961 | spin_lock(&state_lock); |
4961 | count = nfsd_find_all_delegations(clp, max, NULL); | 4962 | count = nfsd_find_all_delegations(clp, max, NULL); |
4962 | spin_unlock(&recall_lock); | 4963 | spin_unlock(&state_lock); |
4963 | 4964 | ||
4964 | nfsd_print_count(clp, count, "delegations"); | 4965 | nfsd_print_count(clp, count, "delegations"); |
4965 | return count; | 4966 | return count; |
@@ -5170,12 +5171,12 @@ nfs4_state_shutdown_net(struct net *net) | |||
5170 | 5171 | ||
5171 | nfs4_lock_state(); | 5172 | nfs4_lock_state(); |
5172 | INIT_LIST_HEAD(&reaplist); | 5173 | INIT_LIST_HEAD(&reaplist); |
5173 | spin_lock(&recall_lock); | 5174 | spin_lock(&state_lock); |
5174 | list_for_each_safe(pos, next, &nn->del_recall_lru) { | 5175 | list_for_each_safe(pos, next, &nn->del_recall_lru) { |
5175 | dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); | 5176 | dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); |
5176 | list_move(&dp->dl_recall_lru, &reaplist); | 5177 | list_move(&dp->dl_recall_lru, &reaplist); |
5177 | } | 5178 | } |
5178 | spin_unlock(&recall_lock); | 5179 | spin_unlock(&state_lock); |
5179 | list_for_each_safe(pos, next, &reaplist) { | 5180 | list_for_each_safe(pos, next, &reaplist) { |
5180 | dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); | 5181 | dp = list_entry (pos, struct nfs4_delegation, dl_recall_lru); |
5181 | destroy_delegation(dp); | 5182 | destroy_delegation(dp); |