diff options
author | J. Bruce Fields <bfields@citi.umich.edu> | 2009-01-11 14:27:17 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@citi.umich.edu> | 2009-03-18 17:30:47 -0400 |
commit | 2283963f27fdd56b185e49a964c290130c7c95ab (patch) | |
tree | c1b54a9b233baa004e8a17662b6c3f08fdb523c4 /fs/nfsd/nfs4state.c | |
parent | a1e4ee22863d41a6fbb24310d7951836cb6dafe7 (diff) |
nfsd4: split lockstateid/openstateid release logic
The flags here attempt to make the code more general, but I find it
actually just adds confusion.
I think it's clearer to separate the logic for the open and lock cases
entirely. And eventually we may want to separate the stateowner and
stateid types as well, as many of the fields aren't shared between the
lock and open cases.
Also move to eliminate forward references.
Start with the stateid's.
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Reviewed-by: Benny Halevy <bhalevy@panasas.com>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r-- | fs/nfsd/nfs4state.c | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index b6f60f48e94b..e83b3c865aa3 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -119,7 +119,6 @@ opaque_hashval(const void *ptr, int nbytes) | |||
119 | 119 | ||
120 | /* forward declarations */ | 120 | /* forward declarations */ |
121 | static void release_stateowner(struct nfs4_stateowner *sop); | 121 | static void release_stateowner(struct nfs4_stateowner *sop); |
122 | static void release_stateid(struct nfs4_stateid *stp, int flags); | ||
123 | 122 | ||
124 | /* | 123 | /* |
125 | * Delegation state | 124 | * Delegation state |
@@ -311,6 +310,34 @@ static struct list_head unconf_id_hashtbl[CLIENT_HASH_SIZE]; | |||
311 | static struct list_head client_lru; | 310 | static struct list_head client_lru; |
312 | static struct list_head close_lru; | 311 | static struct list_head close_lru; |
313 | 312 | ||
313 | static void unhash_generic_stateid(struct nfs4_stateid *stp) | ||
314 | { | ||
315 | list_del(&stp->st_hash); | ||
316 | list_del(&stp->st_perfile); | ||
317 | list_del(&stp->st_perstateowner); | ||
318 | } | ||
319 | |||
320 | static void free_generic_stateid(struct nfs4_stateid *stp) | ||
321 | { | ||
322 | put_nfs4_file(stp->st_file); | ||
323 | kmem_cache_free(stateid_slab, stp); | ||
324 | } | ||
325 | |||
326 | static void release_lock_stateid(struct nfs4_stateid *stp) | ||
327 | { | ||
328 | unhash_generic_stateid(stp); | ||
329 | locks_remove_posix(stp->st_vfs_file, (fl_owner_t)stp->st_stateowner); | ||
330 | free_generic_stateid(stp); | ||
331 | } | ||
332 | |||
333 | static void release_open_stateid(struct nfs4_stateid *stp) | ||
334 | { | ||
335 | unhash_generic_stateid(stp); | ||
336 | release_stateid_lockowners(stp); | ||
337 | nfsd_close(stp->st_vfs_file); | ||
338 | free_generic_stateid(stp); | ||
339 | } | ||
340 | |||
314 | static inline void | 341 | static inline void |
315 | renew_client(struct nfs4_client *clp) | 342 | renew_client(struct nfs4_client *clp) |
316 | { | 343 | { |
@@ -1065,9 +1092,9 @@ unhash_stateowner(struct nfs4_stateowner *sop) | |||
1065 | stp = list_entry(sop->so_stateids.next, | 1092 | stp = list_entry(sop->so_stateids.next, |
1066 | struct nfs4_stateid, st_perstateowner); | 1093 | struct nfs4_stateid, st_perstateowner); |
1067 | if (sop->so_is_open_owner) | 1094 | if (sop->so_is_open_owner) |
1068 | release_stateid(stp, OPEN_STATE); | 1095 | release_open_stateid(stp); |
1069 | else | 1096 | else |
1070 | release_stateid(stp, LOCK_STATE); | 1097 | release_lock_stateid(stp); |
1071 | } | 1098 | } |
1072 | } | 1099 | } |
1073 | 1100 | ||
@@ -1106,24 +1133,6 @@ init_stateid(struct nfs4_stateid *stp, struct nfs4_file *fp, struct nfsd4_open * | |||
1106 | } | 1133 | } |
1107 | 1134 | ||
1108 | static void | 1135 | static void |
1109 | release_stateid(struct nfs4_stateid *stp, int flags) | ||
1110 | { | ||
1111 | struct file *filp = stp->st_vfs_file; | ||
1112 | |||
1113 | list_del(&stp->st_hash); | ||
1114 | list_del(&stp->st_perfile); | ||
1115 | list_del(&stp->st_perstateowner); | ||
1116 | if (flags & OPEN_STATE) { | ||
1117 | release_stateid_lockowners(stp); | ||
1118 | stp->st_vfs_file = NULL; | ||
1119 | nfsd_close(filp); | ||
1120 | } else if (flags & LOCK_STATE) | ||
1121 | locks_remove_posix(filp, (fl_owner_t) stp->st_stateowner); | ||
1122 | put_nfs4_file(stp->st_file); | ||
1123 | kmem_cache_free(stateid_slab, stp); | ||
1124 | } | ||
1125 | |||
1126 | static void | ||
1127 | move_to_close_lru(struct nfs4_stateowner *sop) | 1136 | move_to_close_lru(struct nfs4_stateowner *sop) |
1128 | { | 1137 | { |
1129 | dprintk("NFSD: move_to_close_lru nfs4_stateowner %p\n", sop); | 1138 | dprintk("NFSD: move_to_close_lru nfs4_stateowner %p\n", sop); |
@@ -1764,7 +1773,7 @@ nfsd4_process_open2(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nf | |||
1764 | init_stateid(stp, fp, open); | 1773 | init_stateid(stp, fp, open); |
1765 | status = nfsd4_truncate(rqstp, current_fh, open); | 1774 | status = nfsd4_truncate(rqstp, current_fh, open); |
1766 | if (status) { | 1775 | if (status) { |
1767 | release_stateid(stp, OPEN_STATE); | 1776 | release_open_stateid(stp); |
1768 | goto out; | 1777 | goto out; |
1769 | } | 1778 | } |
1770 | } | 1779 | } |
@@ -2373,7 +2382,7 @@ nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
2373 | memcpy(&close->cl_stateid, &stp->st_stateid, sizeof(stateid_t)); | 2382 | memcpy(&close->cl_stateid, &stp->st_stateid, sizeof(stateid_t)); |
2374 | 2383 | ||
2375 | /* release_stateid() calls nfsd_close() if needed */ | 2384 | /* release_stateid() calls nfsd_close() if needed */ |
2376 | release_stateid(stp, OPEN_STATE); | 2385 | release_open_stateid(stp); |
2377 | 2386 | ||
2378 | /* place unused nfs4_stateowners on so_close_lru list to be | 2387 | /* place unused nfs4_stateowners on so_close_lru list to be |
2379 | * released by the laundromat service after the lease period | 2388 | * released by the laundromat service after the lease period |