diff options
author | J. Bruce Fields <bfields@redhat.com> | 2011-10-13 15:12:59 -0400 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2011-10-17 17:33:57 -0400 |
commit | d29b20cd589128a599e5045d4effc2d7dbc388f5 (patch) | |
tree | 48794b614b23f4159f2edeef484b1ff9c93ffbd7 /fs/nfsd/nfs4state.c | |
parent | bcf130f9dfbaccf91376a44b18f51ed8007840d6 (diff) |
nfsd4: clean up open owners on OPEN failure
If process_open1() creates a new open owner, but the open later fails,
the current code will leave the open owner around. It won't be on the
close_lru list, and the client isn't expected to send a CLOSE, so it
will hang around as long as the client does.
Similarly, if process_open1() removes an existing open owner from the
close lru, anticipating that an open owner that previously had no
associated stateid's now will, but the open subsequently fails, then
we'll again be left with the same leak.
Fix both problems.
Reported-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r-- | fs/nfsd/nfs4state.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 62aa91ae278b..2c9a1a20e014 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -2320,7 +2320,7 @@ alloc_init_open_stateowner(unsigned int strhashval, struct nfs4_client *clp, str | |||
2320 | return NULL; | 2320 | return NULL; |
2321 | oo->oo_owner.so_is_open_owner = 1; | 2321 | oo->oo_owner.so_is_open_owner = 1; |
2322 | oo->oo_owner.so_seqid = open->op_seqid; | 2322 | oo->oo_owner.so_seqid = open->op_seqid; |
2323 | oo->oo_flags = 0; | 2323 | oo->oo_flags = NFS4_OO_NEW; |
2324 | oo->oo_time = 0; | 2324 | oo->oo_time = 0; |
2325 | oo->oo_last_closed_stid = NULL; | 2325 | oo->oo_last_closed_stid = NULL; |
2326 | INIT_LIST_HEAD(&oo->oo_close_lru); | 2326 | INIT_LIST_HEAD(&oo->oo_close_lru); |
@@ -2526,7 +2526,6 @@ nfsd4_process_open1(struct nfsd4_compound_state *cstate, | |||
2526 | open->op_openowner = NULL; | 2526 | open->op_openowner = NULL; |
2527 | goto new_owner; | 2527 | goto new_owner; |
2528 | } | 2528 | } |
2529 | list_del_init(&oo->oo_close_lru); | ||
2530 | return nfsd4_check_seqid(cstate, &oo->oo_owner, open->op_seqid); | 2529 | return nfsd4_check_seqid(cstate, &oo->oo_owner, open->op_seqid); |
2531 | new_owner: | 2530 | new_owner: |
2532 | oo = alloc_init_open_stateowner(strhashval, clp, open); | 2531 | oo = alloc_init_open_stateowner(strhashval, clp, open); |
@@ -2946,6 +2945,23 @@ out: | |||
2946 | return status; | 2945 | return status; |
2947 | } | 2946 | } |
2948 | 2947 | ||
2948 | void nfsd4_cleanup_open_state(struct nfsd4_open *open, __be32 status) | ||
2949 | { | ||
2950 | if (open->op_openowner) { | ||
2951 | struct nfs4_openowner *oo = open->op_openowner; | ||
2952 | |||
2953 | if (!list_empty(&oo->oo_owner.so_stateids)) | ||
2954 | list_del_init(&oo->oo_close_lru); | ||
2955 | if (oo->oo_flags & NFS4_OO_NEW) { | ||
2956 | if (status) { | ||
2957 | release_openowner(oo); | ||
2958 | open->op_openowner = NULL; | ||
2959 | } else | ||
2960 | oo->oo_flags &= ~NFS4_OO_NEW; | ||
2961 | } | ||
2962 | } | ||
2963 | } | ||
2964 | |||
2949 | __be32 | 2965 | __be32 |
2950 | nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | 2966 | nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, |
2951 | clientid_t *clid) | 2967 | clientid_t *clid) |