aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/nfs4state.c
diff options
context:
space:
mode:
authorJeff Layton <jlayton@primarydata.com>2014-07-29 21:34:11 -0400
committerJ. Bruce Fields <bfields@redhat.com>2014-07-31 14:19:50 -0400
commitb49e084d8c7df1632bb2b94ae1a21c8a4cf2d8a4 (patch)
tree63cdd1f2ed4f02423ff4cec524a2d07bdd75ea55 /fs/nfsd/nfs4state.c
parent4770d722014b99e5438c0d1dc44db31ac4547af1 (diff)
nfsd: do filp_close in sc_free callback for lock stateids
Releasing locks when we unhash the stateid instead of doing so only when the stateid is actually released will be problematic in later patches when we need to protect the unhashing with spinlocks. Move it into the sc_free operation instead. Signed-off-by: Jeff Layton <jlayton@primarydata.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r--fs/nfsd/nfs4state.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index bb37cc4dd573..8ce5894133aa 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -502,7 +502,7 @@ out_free:
502 return NULL; 502 return NULL;
503} 503}
504 504
505static struct nfs4_ol_stateid * nfs4_alloc_stateid(struct nfs4_client *clp) 505static struct nfs4_ol_stateid * nfs4_alloc_open_stateid(struct nfs4_client *clp)
506{ 506{
507 struct nfs4_stid *stid; 507 struct nfs4_stid *stid;
508 struct nfs4_ol_stateid *stp; 508 struct nfs4_ol_stateid *stp;
@@ -907,16 +907,23 @@ static void nfs4_free_ol_stateid(struct nfs4_stid *stid)
907 kmem_cache_free(stateid_slab, stid); 907 kmem_cache_free(stateid_slab, stid);
908} 908}
909 909
910static void __release_lock_stateid(struct nfs4_ol_stateid *stp) 910static void nfs4_free_lock_stateid(struct nfs4_stid *stid)
911{ 911{
912 struct nfs4_ol_stateid *stp = openlockstateid(stid);
913 struct nfs4_lockowner *lo = lockowner(stp->st_stateowner);
912 struct file *file; 914 struct file *file;
913 915
916 file = find_any_file(stp->st_stid.sc_file);
917 if (file)
918 filp_close(file, (fl_owner_t)lo);
919 nfs4_free_ol_stateid(stid);
920}
921
922static void __release_lock_stateid(struct nfs4_ol_stateid *stp)
923{
914 list_del(&stp->st_locks); 924 list_del(&stp->st_locks);
915 unhash_generic_stateid(stp); 925 unhash_generic_stateid(stp);
916 unhash_stid(&stp->st_stid); 926 unhash_stid(&stp->st_stid);
917 file = find_any_file(stp->st_stid.sc_file);
918 if (file)
919 filp_close(file, (fl_owner_t)lockowner(stp->st_stateowner));
920 nfs4_put_stid(&stp->st_stid); 927 nfs4_put_stid(&stp->st_stid);
921} 928}
922 929
@@ -3287,7 +3294,7 @@ new_owner:
3287 return nfserr_jukebox; 3294 return nfserr_jukebox;
3288 open->op_openowner = oo; 3295 open->op_openowner = oo;
3289alloc_stateid: 3296alloc_stateid:
3290 open->op_stp = nfs4_alloc_stateid(clp); 3297 open->op_stp = nfs4_alloc_open_stateid(clp);
3291 if (!open->op_stp) 3298 if (!open->op_stp)
3292 return nfserr_jukebox; 3299 return nfserr_jukebox;
3293 return nfs_ok; 3300 return nfs_ok;
@@ -4703,17 +4710,20 @@ alloc_init_lock_stateid(struct nfs4_lockowner *lo, struct nfs4_file *fp,
4703 struct inode *inode, 4710 struct inode *inode,
4704 struct nfs4_ol_stateid *open_stp) 4711 struct nfs4_ol_stateid *open_stp)
4705{ 4712{
4713 struct nfs4_stid *s;
4706 struct nfs4_ol_stateid *stp; 4714 struct nfs4_ol_stateid *stp;
4707 struct nfs4_client *clp = lo->lo_owner.so_client; 4715 struct nfs4_client *clp = lo->lo_owner.so_client;
4708 4716
4709 stp = nfs4_alloc_stateid(clp); 4717 s = nfs4_alloc_stid(clp, stateid_slab);
4710 if (stp == NULL) 4718 if (s == NULL)
4711 return NULL; 4719 return NULL;
4720 stp = openlockstateid(s);
4712 stp->st_stid.sc_type = NFS4_LOCK_STID; 4721 stp->st_stid.sc_type = NFS4_LOCK_STID;
4713 list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids); 4722 list_add(&stp->st_perstateowner, &lo->lo_owner.so_stateids);
4714 stp->st_stateowner = &lo->lo_owner; 4723 stp->st_stateowner = &lo->lo_owner;
4715 get_nfs4_file(fp); 4724 get_nfs4_file(fp);
4716 stp->st_stid.sc_file = fp; 4725 stp->st_stid.sc_file = fp;
4726 stp->st_stid.sc_free = nfs4_free_lock_stateid;
4717 stp->st_access_bmap = 0; 4727 stp->st_access_bmap = 0;
4718 stp->st_deny_bmap = open_stp->st_deny_bmap; 4728 stp->st_deny_bmap = open_stp->st_deny_bmap;
4719 stp->st_openstp = open_stp; 4729 stp->st_openstp = open_stp;