@@ -206,7 +206,7 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_stateid *stp, struct svc_f
206
206
dp -> dl_recall .cbr_dp = NULL ;
207
207
dp -> dl_recall .cbr_ident = cb -> cb_ident ;
208
208
dp -> dl_recall .cbr_trunc = 0 ;
209
- dp -> dl_stateid .si_boot = boot_time ;
209
+ dp -> dl_stateid .si_boot = get_seconds () ;
210
210
dp -> dl_stateid .si_stateownerid = current_delegid ++ ;
211
211
dp -> dl_stateid .si_fileid = 0 ;
212
212
dp -> dl_stateid .si_generation = 0 ;
@@ -1883,7 +1883,7 @@ init_stateid(struct nfs4_stateid *stp, struct nfs4_file *fp, struct nfsd4_open *
1883
1883
stp -> st_stateowner = sop ;
1884
1884
get_nfs4_file (fp );
1885
1885
stp -> st_file = fp ;
1886
- stp -> st_stateid .si_boot = boot_time ;
1886
+ stp -> st_stateid .si_boot = get_seconds () ;
1887
1887
stp -> st_stateid .si_stateownerid = sop -> so_id ;
1888
1888
stp -> st_stateid .si_fileid = fp -> fi_id ;
1889
1889
stp -> st_stateid .si_generation = 0 ;
@@ -2739,12 +2739,42 @@ nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stateid *stp)
2739
2739
static int
2740
2740
STALE_STATEID (stateid_t * stateid )
2741
2741
{
2742
- if (stateid -> si_boot == boot_time )
2743
- return 0 ;
2744
- dprintk ("NFSD: stale stateid (%08x/%08x/%08x/%08x)!\n" ,
2745
- stateid -> si_boot , stateid -> si_stateownerid , stateid -> si_fileid ,
2746
- stateid -> si_generation );
2747
- return 1 ;
2742
+ if (time_after ((unsigned long )boot_time ,
2743
+ (unsigned long )stateid -> si_boot )) {
2744
+ dprintk ("NFSD: stale stateid (%08x/%08x/%08x/%08x)!\n" ,
2745
+ stateid -> si_boot , stateid -> si_stateownerid ,
2746
+ stateid -> si_fileid , stateid -> si_generation );
2747
+ return 1 ;
2748
+ }
2749
+ return 0 ;
2750
+ }
2751
+
2752
+ static int
2753
+ EXPIRED_STATEID (stateid_t * stateid )
2754
+ {
2755
+ if (time_before ((unsigned long )boot_time ,
2756
+ ((unsigned long )stateid -> si_boot )) &&
2757
+ time_before ((stateid -> si_boot + lease_time ), get_seconds ())) {
2758
+ dprintk ("NFSD: expired stateid (%08x/%08x/%08x/%08x)!\n" ,
2759
+ stateid -> si_boot , stateid -> si_stateownerid ,
2760
+ stateid -> si_fileid , stateid -> si_generation );
2761
+ return 1 ;
2762
+ }
2763
+ return 0 ;
2764
+ }
2765
+
2766
+ static __be32
2767
+ stateid_error_map (stateid_t * stateid )
2768
+ {
2769
+ if (STALE_STATEID (stateid ))
2770
+ return nfserr_stale_stateid ;
2771
+ if (EXPIRED_STATEID (stateid ))
2772
+ return nfserr_expired ;
2773
+
2774
+ dprintk ("NFSD: bad stateid (%08x/%08x/%08x/%08x)!\n" ,
2775
+ stateid -> si_boot , stateid -> si_stateownerid ,
2776
+ stateid -> si_fileid , stateid -> si_generation );
2777
+ return nfserr_bad_stateid ;
2748
2778
}
2749
2779
2750
2780
static inline int
@@ -2868,8 +2898,10 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate,
2868
2898
status = nfserr_bad_stateid ;
2869
2899
if (is_delegation_stateid (stateid )) {
2870
2900
dp = find_delegation_stateid (ino , stateid );
2871
- if (!dp )
2901
+ if (!dp ) {
2902
+ status = stateid_error_map (stateid );
2872
2903
goto out ;
2904
+ }
2873
2905
status = check_stateid_generation (stateid , & dp -> dl_stateid ,
2874
2906
flags );
2875
2907
if (status )
@@ -2882,8 +2914,10 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate,
2882
2914
* filpp = dp -> dl_vfs_file ;
2883
2915
} else { /* open or lock stateid */
2884
2916
stp = find_stateid (stateid , flags );
2885
- if (!stp )
2917
+ if (!stp ) {
2918
+ status = stateid_error_map (stateid );
2886
2919
goto out ;
2920
+ }
2887
2921
if (nfs4_check_fh (current_fh , stp ))
2888
2922
goto out ;
2889
2923
if (!stp -> st_stateowner -> so_confirmed )
@@ -2957,7 +2991,7 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
2957
2991
*/
2958
2992
sop = search_close_lru (stateid -> si_stateownerid , flags );
2959
2993
if (sop == NULL )
2960
- return nfserr_bad_stateid ;
2994
+ return stateid_error_map ( stateid ) ;
2961
2995
* sopp = sop ;
2962
2996
goto check_replay ;
2963
2997
}
@@ -3228,8 +3262,10 @@ nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3228
3262
if (!is_delegation_stateid (stateid ))
3229
3263
goto out ;
3230
3264
dp = find_delegation_stateid (inode , stateid );
3231
- if (!dp )
3265
+ if (!dp ) {
3266
+ status = stateid_error_map (stateid );
3232
3267
goto out ;
3268
+ }
3233
3269
status = check_stateid_generation (stateid , & dp -> dl_stateid , flags );
3234
3270
if (status )
3235
3271
goto out ;
@@ -3456,7 +3492,7 @@ alloc_init_lock_stateid(struct nfs4_stateowner *sop, struct nfs4_file *fp, struc
3456
3492
stp -> st_stateowner = sop ;
3457
3493
get_nfs4_file (fp );
3458
3494
stp -> st_file = fp ;
3459
- stp -> st_stateid .si_boot = boot_time ;
3495
+ stp -> st_stateid .si_boot = get_seconds () ;
3460
3496
stp -> st_stateid .si_stateownerid = sop -> so_id ;
3461
3497
stp -> st_stateid .si_fileid = fp -> fi_id ;
3462
3498
stp -> st_stateid .si_generation = 0 ;
0 commit comments