Don't allow stateids to clear the open file pointer until they are being destroyed. Signed-off-by: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx> --- fs/nfsd/nfs4state.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index afb767319f66..51ef179339ae 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -394,7 +394,7 @@ kmem_cache *slab) struct nfs4_stid *stid; int new_id; - stid = kmem_cache_alloc(slab, GFP_KERNEL); + stid = kmem_cache_zalloc(slab, GFP_KERNEL); if (!stid) return NULL; @@ -481,6 +481,8 @@ void nfs4_put_delegation(struct nfs4_delegation *dp) { if (atomic_dec_and_test(&dp->dl_stid.sc_count)) { + if (dp->dl_file) + put_nfs4_file(dp->dl_file); nfs4_free_stid(deleg_slab, &dp->dl_stid); num_delegations--; } @@ -528,10 +530,8 @@ unhash_delegation(struct nfs4_delegation *dp) spin_unlock(&fp->fi_inode->i_lock); } nfs4_put_deleg_lease(fp); - dp->dl_file = NULL; spin_unlock(&fp->fi_lock); spin_unlock(&state_lock); - put_nfs4_file(fp); } @@ -701,13 +701,13 @@ static void unhash_generic_stateid(struct nfs4_ol_stateid *stp) static void close_generic_stateid(struct nfs4_ol_stateid *stp) { release_all_access(stp); - put_nfs4_file(stp->st_file); - stp->st_file = NULL; } static void free_generic_stateid(struct nfs4_ol_stateid *stp) { remove_stid(&stp->st_stid); + if (stp->st_file) + put_nfs4_file(stp->st_file); nfs4_free_stid(stateid_slab, &stp->st_stid); } @@ -3265,8 +3265,6 @@ unlock_and_free: spin_unlock(&fp->fi_lock); spin_unlock(&state_lock); out_free: - put_nfs4_file(fp); - dp->dl_file = fp; return status; } -- 1.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html