@@ -515,10 +515,6 @@ static struct nfs4_ol_stateid * nfs4_alloc_stateid(struct nfs4_client *clp)
515
515
516
516
static void nfs4_free_deleg (struct nfs4_stid * stid )
517
517
{
518
- struct nfs4_delegation * dp = delegstateid (stid );
519
-
520
- if (dp -> dl_file )
521
- put_nfs4_file (dp -> dl_file );
522
518
kmem_cache_free (deleg_slab , stid );
523
519
atomic_long_dec (& num_delegations );
524
520
}
@@ -636,12 +632,15 @@ alloc_init_deleg(struct nfs4_client *clp, struct svc_fh *current_fh)
636
632
void
637
633
nfs4_put_stid (struct nfs4_stid * s )
638
634
{
635
+ struct nfs4_file * fp = s -> sc_file ;
639
636
struct nfs4_client * clp = s -> sc_client ;
640
637
641
638
if (!atomic_dec_and_test (& s -> sc_count ))
642
639
return ;
643
640
idr_remove (& clp -> cl_stateids , s -> sc_stateid .si_opaque .so_id );
644
641
s -> sc_free (s );
642
+ if (fp )
643
+ put_nfs4_file (fp );
645
644
}
646
645
647
646
static void nfs4_put_deleg_lease (struct nfs4_file * fp )
@@ -677,7 +676,7 @@ hash_delegation_locked(struct nfs4_delegation *dp, struct nfs4_file *fp)
677
676
static void
678
677
unhash_delegation_locked (struct nfs4_delegation * dp )
679
678
{
680
- struct nfs4_file * fp = dp -> dl_file ;
679
+ struct nfs4_file * fp = dp -> dl_stid . sc_file ;
681
680
682
681
lockdep_assert_held (& state_lock );
683
682
@@ -864,29 +863,29 @@ reset_union_bmap_deny(u32 deny, struct nfs4_ol_stateid *stp)
864
863
865
864
/* Recalculate per-file deny mode if there was a change */
866
865
if (change )
867
- recalculate_deny_mode (stp -> st_file );
866
+ recalculate_deny_mode (stp -> st_stid . sc_file );
868
867
}
869
868
870
869
/* release all access and file references for a given stateid */
871
870
static void
872
871
release_all_access (struct nfs4_ol_stateid * stp )
873
872
{
874
873
int i ;
875
- struct nfs4_file * fp = stp -> st_file ;
874
+ struct nfs4_file * fp = stp -> st_stid . sc_file ;
876
875
877
876
if (fp && stp -> st_deny_bmap != 0 )
878
877
recalculate_deny_mode (fp );
879
878
880
879
for (i = 1 ; i < 4 ; i ++ ) {
881
880
if (test_access (i , stp ))
882
- nfs4_file_put_access (stp -> st_file , i );
881
+ nfs4_file_put_access (stp -> st_stid . sc_file , i );
883
882
clear_access (i , stp );
884
883
}
885
884
}
886
885
887
886
static void unhash_generic_stateid (struct nfs4_ol_stateid * stp )
888
887
{
889
- struct nfs4_file * fp = stp -> st_file ;
888
+ struct nfs4_file * fp = stp -> st_stid . sc_file ;
890
889
891
890
spin_lock (& fp -> fi_lock );
892
891
list_del (& stp -> st_perfile );
@@ -899,8 +898,6 @@ static void nfs4_free_ol_stateid(struct nfs4_stid *stid)
899
898
struct nfs4_ol_stateid * stp = openlockstateid (stid );
900
899
901
900
release_all_access (stp );
902
- if (stp -> st_file )
903
- put_nfs4_file (stp -> st_file );
904
901
kmem_cache_free (stateid_slab , stid );
905
902
}
906
903
@@ -911,7 +908,7 @@ static void __release_lock_stateid(struct nfs4_ol_stateid *stp)
911
908
list_del (& stp -> st_locks );
912
909
unhash_generic_stateid (stp );
913
910
unhash_stid (& stp -> st_stid );
914
- file = find_any_file (stp -> st_file );
911
+ file = find_any_file (stp -> st_stid . sc_file );
915
912
if (file )
916
913
filp_close (file , (fl_owner_t )lockowner (stp -> st_stateowner ));
917
914
nfs4_put_stid (& stp -> st_stid );
@@ -2976,7 +2973,7 @@ static void init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp,
2976
2973
list_add (& stp -> st_perstateowner , & oo -> oo_owner .so_stateids );
2977
2974
stp -> st_stateowner = & oo -> oo_owner ;
2978
2975
get_nfs4_file (fp );
2979
- stp -> st_file = fp ;
2976
+ stp -> st_stid . sc_file = fp ;
2980
2977
stp -> st_access_bmap = 0 ;
2981
2978
stp -> st_deny_bmap = 0 ;
2982
2979
stp -> st_openstp = NULL ;
@@ -3097,10 +3094,10 @@ nfs4_share_conflict(struct svc_fh *current_fh, unsigned int deny_type)
3097
3094
3098
3095
void nfsd4_prepare_cb_recall (struct nfs4_delegation * dp )
3099
3096
{
3100
- struct nfs4_client * clp = dp -> dl_stid .sc_client ;
3101
- struct nfsd_net * nn = net_generic ( clp -> net , nfsd_net_id );
3097
+ struct nfsd_net * nn = net_generic ( dp -> dl_stid .sc_client -> net ,
3098
+ nfsd_net_id );
3102
3099
3103
- block_delegations (& dp -> dl_file -> fi_fhandle );
3100
+ block_delegations (& dp -> dl_stid . sc_file -> fi_fhandle );
3104
3101
3105
3102
/*
3106
3103
* We can't do this in nfsd_break_deleg_cb because it is
@@ -3508,7 +3505,7 @@ static struct file_lock *nfs4_alloc_init_lease(struct nfs4_file *fp, int flag)
3508
3505
3509
3506
static int nfs4_setlease (struct nfs4_delegation * dp )
3510
3507
{
3511
- struct nfs4_file * fp = dp -> dl_file ;
3508
+ struct nfs4_file * fp = dp -> dl_stid . sc_file ;
3512
3509
struct file_lock * fl ;
3513
3510
struct file * filp ;
3514
3511
int status = 0 ;
@@ -3573,7 +3570,7 @@ nfs4_set_delegation(struct nfs4_client *clp, struct svc_fh *fh,
3573
3570
get_nfs4_file (fp );
3574
3571
spin_lock (& state_lock );
3575
3572
spin_lock (& fp -> fi_lock );
3576
- dp -> dl_file = fp ;
3573
+ dp -> dl_stid . sc_file = fp ;
3577
3574
if (!fp -> fi_lease ) {
3578
3575
spin_unlock (& fp -> fi_lock );
3579
3576
spin_unlock (& state_lock );
@@ -3669,7 +3666,7 @@ nfs4_open_delegation(struct svc_fh *fh, struct nfsd4_open *open,
3669
3666
default :
3670
3667
goto out_no_deleg ;
3671
3668
}
3672
- dp = nfs4_set_delegation (clp , fh , stp -> st_file );
3669
+ dp = nfs4_set_delegation (clp , fh , stp -> st_stid . sc_file );
3673
3670
if (IS_ERR (dp ))
3674
3671
goto out_no_deleg ;
3675
3672
@@ -3959,7 +3956,7 @@ laundromat_main(struct work_struct *laundry)
3959
3956
3960
3957
static inline __be32 nfs4_check_fh (struct svc_fh * fhp , struct nfs4_ol_stateid * stp )
3961
3958
{
3962
- if (!nfsd_fh_match (& fhp -> fh_handle , & stp -> st_file -> fi_fhandle ))
3959
+ if (!nfsd_fh_match (& fhp -> fh_handle , & stp -> st_stid . sc_file -> fi_fhandle ))
3963
3960
return nfserr_bad_stateid ;
3964
3961
return nfs_ok ;
3965
3962
}
@@ -4167,7 +4164,7 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate,
4167
4164
if (status )
4168
4165
goto out ;
4169
4166
if (filpp ) {
4170
- file = dp -> dl_file -> fi_deleg_file ;
4167
+ file = dp -> dl_stid . sc_file -> fi_deleg_file ;
4171
4168
if (!file ) {
4172
4169
WARN_ON_ONCE (1 );
4173
4170
status = nfserr_serverfault ;
@@ -4189,10 +4186,12 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate,
4189
4186
if (status )
4190
4187
goto out ;
4191
4188
if (filpp ) {
4189
+ struct nfs4_file * fp = stp -> st_stid .sc_file ;
4190
+
4192
4191
if (flags & RD_STATE )
4193
- file = find_readable_file (stp -> st_file );
4192
+ file = find_readable_file (fp );
4194
4193
else
4195
- file = find_writeable_file (stp -> st_file );
4194
+ file = find_writeable_file (fp );
4196
4195
}
4197
4196
break ;
4198
4197
default :
@@ -4212,7 +4211,7 @@ nfsd4_free_lock_stateid(struct nfs4_ol_stateid *stp)
4212
4211
{
4213
4212
struct nfs4_lockowner * lo = lockowner (stp -> st_stateowner );
4214
4213
4215
- if (check_for_locks (stp -> st_file , lo ))
4214
+ if (check_for_locks (stp -> st_stid . sc_file , lo ))
4216
4215
return nfserr_locks_held ;
4217
4216
release_lockowner_if_empty (lo );
4218
4217
return nfs_ok ;
@@ -4403,7 +4402,7 @@ static inline void nfs4_stateid_downgrade_bit(struct nfs4_ol_stateid *stp, u32 a
4403
4402
{
4404
4403
if (!test_access (access , stp ))
4405
4404
return ;
4406
- nfs4_file_put_access (stp -> st_file , access );
4405
+ nfs4_file_put_access (stp -> st_stid . sc_file , access );
4407
4406
clear_access (access , stp );
4408
4407
}
4409
4408
@@ -4492,9 +4491,9 @@ static void nfsd4_close_open_stateid(struct nfs4_ol_stateid *s)
4492
4491
* before returning however.
4493
4492
*/
4494
4493
release_all_access (s );
4495
- if (s -> st_file ) {
4496
- put_nfs4_file (s -> st_file );
4497
- s -> st_file = NULL ;
4494
+ if (s -> st_stid . sc_file ) {
4495
+ put_nfs4_file (s -> st_stid . sc_file );
4496
+ s -> st_stid . sc_file = NULL ;
4498
4497
}
4499
4498
oo -> oo_last_closed_stid = s ;
4500
4499
if (list_empty (& oo -> oo_owner .so_stateids ))
@@ -4695,7 +4694,7 @@ alloc_init_lock_stateid(struct nfs4_lockowner *lo, struct nfs4_file *fp,
4695
4694
list_add (& stp -> st_perstateowner , & lo -> lo_owner .so_stateids );
4696
4695
stp -> st_stateowner = & lo -> lo_owner ;
4697
4696
get_nfs4_file (fp );
4698
- stp -> st_file = fp ;
4697
+ stp -> st_stid . sc_file = fp ;
4699
4698
stp -> st_access_bmap = 0 ;
4700
4699
stp -> st_deny_bmap = open_stp -> st_deny_bmap ;
4701
4700
stp -> st_openstp = open_stp ;
@@ -4712,7 +4711,7 @@ find_lock_stateid(struct nfs4_lockowner *lo, struct nfs4_file *fp)
4712
4711
struct nfs4_ol_stateid * lst ;
4713
4712
4714
4713
list_for_each_entry (lst , & lo -> lo_owner .so_stateids , st_perstateowner ) {
4715
- if (lst -> st_file == fp )
4714
+ if (lst -> st_stid . sc_file == fp )
4716
4715
return lst ;
4717
4716
}
4718
4717
return NULL ;
@@ -4728,7 +4727,7 @@ check_lock_length(u64 offset, u64 length)
4728
4727
4729
4728
static void get_lock_access (struct nfs4_ol_stateid * lock_stp , u32 access )
4730
4729
{
4731
- struct nfs4_file * fp = lock_stp -> st_file ;
4730
+ struct nfs4_file * fp = lock_stp -> st_stid . sc_file ;
4732
4731
4733
4732
lockdep_assert_held (& fp -> fi_lock );
4734
4733
@@ -4740,7 +4739,7 @@ static void get_lock_access(struct nfs4_ol_stateid *lock_stp, u32 access)
4740
4739
4741
4740
static __be32 lookup_or_create_lock_state (struct nfsd4_compound_state * cstate , struct nfs4_ol_stateid * ost , struct nfsd4_lock * lock , struct nfs4_ol_stateid * * lst , bool * new )
4742
4741
{
4743
- struct nfs4_file * fi = ost -> st_file ;
4742
+ struct nfs4_file * fi = ost -> st_stid . sc_file ;
4744
4743
struct nfs4_openowner * oo = openowner (ost -> st_stateowner );
4745
4744
struct nfs4_client * cl = oo -> oo_owner .so_client ;
4746
4745
struct inode * inode = cstate -> current_fh .fh_dentry -> d_inode ;
@@ -4865,7 +4864,7 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
4865
4864
goto out ;
4866
4865
}
4867
4866
4868
- fp = lock_stp -> st_file ;
4867
+ fp = lock_stp -> st_stid . sc_file ;
4869
4868
locks_init_lock (file_lock );
4870
4869
switch (lock -> lk_type ) {
4871
4870
case NFS4_READ_LT :
@@ -5065,7 +5064,7 @@ nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
5065
5064
& stp , nn );
5066
5065
if (status )
5067
5066
goto out ;
5068
- filp = find_any_file (stp -> st_file );
5067
+ filp = find_any_file (stp -> st_stid . sc_file );
5069
5068
if (!filp ) {
5070
5069
status = nfserr_lock_range ;
5071
5070
goto out ;
@@ -5188,7 +5187,7 @@ nfsd4_release_lockowner(struct svc_rqst *rqstp,
5188
5187
lo = lockowner (sop );
5189
5188
/* see if there are still any locks associated with it */
5190
5189
list_for_each_entry (stp , & sop -> so_stateids , st_perstateowner ) {
5191
- if (check_for_locks (stp -> st_file , lo ))
5190
+ if (check_for_locks (stp -> st_stid . sc_file , lo ))
5192
5191
goto out ;
5193
5192
}
5194
5193
0 commit comments