diff options
Diffstat (limited to 'fs/nfsd/nfs4state.c')
-rw-r--r-- | fs/nfsd/nfs4state.c | 56 |
1 files changed, 11 insertions, 45 deletions
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 296eded356b6..12f7109720c2 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -190,7 +190,7 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_stateid *stp, struct svc_f | |||
190 | dp->dl_vfs_file = stp->st_vfs_file; | 190 | dp->dl_vfs_file = stp->st_vfs_file; |
191 | dp->dl_type = type; | 191 | dp->dl_type = type; |
192 | dp->dl_ident = cb->cb_ident; | 192 | dp->dl_ident = cb->cb_ident; |
193 | dp->dl_stateid.si_boot = get_seconds(); | 193 | dp->dl_stateid.si_boot = boot_time; |
194 | dp->dl_stateid.si_stateownerid = current_delegid++; | 194 | dp->dl_stateid.si_stateownerid = current_delegid++; |
195 | dp->dl_stateid.si_fileid = 0; | 195 | dp->dl_stateid.si_fileid = 0; |
196 | dp->dl_stateid.si_generation = 0; | 196 | dp->dl_stateid.si_generation = 0; |
@@ -1884,7 +1884,7 @@ init_stateid(struct nfs4_stateid *stp, struct nfs4_file *fp, struct nfsd4_open * | |||
1884 | stp->st_stateowner = sop; | 1884 | stp->st_stateowner = sop; |
1885 | get_nfs4_file(fp); | 1885 | get_nfs4_file(fp); |
1886 | stp->st_file = fp; | 1886 | stp->st_file = fp; |
1887 | stp->st_stateid.si_boot = get_seconds(); | 1887 | stp->st_stateid.si_boot = boot_time; |
1888 | stp->st_stateid.si_stateownerid = sop->so_id; | 1888 | stp->st_stateid.si_stateownerid = sop->so_id; |
1889 | stp->st_stateid.si_fileid = fp->fi_id; | 1889 | stp->st_stateid.si_fileid = fp->fi_id; |
1890 | stp->st_stateid.si_generation = 0; | 1890 | stp->st_stateid.si_generation = 0; |
@@ -2733,39 +2733,11 @@ nfs4_check_fh(struct svc_fh *fhp, struct nfs4_stateid *stp) | |||
2733 | static int | 2733 | static int |
2734 | STALE_STATEID(stateid_t *stateid) | 2734 | STALE_STATEID(stateid_t *stateid) |
2735 | { | 2735 | { |
2736 | if (time_after((unsigned long)boot_time, | 2736 | if (stateid->si_boot == boot_time) |
2737 | (unsigned long)stateid->si_boot)) { | 2737 | return 0; |
2738 | dprintk("NFSD: stale stateid " STATEID_FMT "!\n", | 2738 | dprintk("NFSD: stale stateid " STATEID_FMT "!\n", |
2739 | STATEID_VAL(stateid)); | ||
2740 | return 1; | ||
2741 | } | ||
2742 | return 0; | ||
2743 | } | ||
2744 | |||
2745 | static int | ||
2746 | EXPIRED_STATEID(stateid_t *stateid) | ||
2747 | { | ||
2748 | if (time_before((unsigned long)boot_time, | ||
2749 | ((unsigned long)stateid->si_boot)) && | ||
2750 | time_before((unsigned long)(stateid->si_boot + nfsd4_lease), get_seconds())) { | ||
2751 | dprintk("NFSD: expired stateid " STATEID_FMT "!\n", | ||
2752 | STATEID_VAL(stateid)); | ||
2753 | return 1; | ||
2754 | } | ||
2755 | return 0; | ||
2756 | } | ||
2757 | |||
2758 | static __be32 | ||
2759 | stateid_error_map(stateid_t *stateid) | ||
2760 | { | ||
2761 | if (STALE_STATEID(stateid)) | ||
2762 | return nfserr_stale_stateid; | ||
2763 | if (EXPIRED_STATEID(stateid)) | ||
2764 | return nfserr_expired; | ||
2765 | |||
2766 | dprintk("NFSD: bad stateid " STATEID_FMT "!\n", | ||
2767 | STATEID_VAL(stateid)); | 2739 | STATEID_VAL(stateid)); |
2768 | return nfserr_bad_stateid; | 2740 | return 1; |
2769 | } | 2741 | } |
2770 | 2742 | ||
2771 | static inline int | 2743 | static inline int |
@@ -2889,10 +2861,8 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate, | |||
2889 | status = nfserr_bad_stateid; | 2861 | status = nfserr_bad_stateid; |
2890 | if (is_delegation_stateid(stateid)) { | 2862 | if (is_delegation_stateid(stateid)) { |
2891 | dp = find_delegation_stateid(ino, stateid); | 2863 | dp = find_delegation_stateid(ino, stateid); |
2892 | if (!dp) { | 2864 | if (!dp) |
2893 | status = stateid_error_map(stateid); | ||
2894 | goto out; | 2865 | goto out; |
2895 | } | ||
2896 | status = check_stateid_generation(stateid, &dp->dl_stateid, | 2866 | status = check_stateid_generation(stateid, &dp->dl_stateid, |
2897 | flags); | 2867 | flags); |
2898 | if (status) | 2868 | if (status) |
@@ -2905,10 +2875,8 @@ nfs4_preprocess_stateid_op(struct nfsd4_compound_state *cstate, | |||
2905 | *filpp = dp->dl_vfs_file; | 2875 | *filpp = dp->dl_vfs_file; |
2906 | } else { /* open or lock stateid */ | 2876 | } else { /* open or lock stateid */ |
2907 | stp = find_stateid(stateid, flags); | 2877 | stp = find_stateid(stateid, flags); |
2908 | if (!stp) { | 2878 | if (!stp) |
2909 | status = stateid_error_map(stateid); | ||
2910 | goto out; | 2879 | goto out; |
2911 | } | ||
2912 | if (nfs4_check_fh(current_fh, stp)) | 2880 | if (nfs4_check_fh(current_fh, stp)) |
2913 | goto out; | 2881 | goto out; |
2914 | if (!stp->st_stateowner->so_confirmed) | 2882 | if (!stp->st_stateowner->so_confirmed) |
@@ -2980,7 +2948,7 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid, | |||
2980 | */ | 2948 | */ |
2981 | sop = search_close_lru(stateid->si_stateownerid, flags); | 2949 | sop = search_close_lru(stateid->si_stateownerid, flags); |
2982 | if (sop == NULL) | 2950 | if (sop == NULL) |
2983 | return stateid_error_map(stateid); | 2951 | return nfserr_bad_stateid; |
2984 | *sopp = sop; | 2952 | *sopp = sop; |
2985 | goto check_replay; | 2953 | goto check_replay; |
2986 | } | 2954 | } |
@@ -3247,10 +3215,8 @@ nfsd4_delegreturn(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
3247 | if (!is_delegation_stateid(stateid)) | 3215 | if (!is_delegation_stateid(stateid)) |
3248 | goto out; | 3216 | goto out; |
3249 | dp = find_delegation_stateid(inode, stateid); | 3217 | dp = find_delegation_stateid(inode, stateid); |
3250 | if (!dp) { | 3218 | if (!dp) |
3251 | status = stateid_error_map(stateid); | ||
3252 | goto out; | 3219 | goto out; |
3253 | } | ||
3254 | status = check_stateid_generation(stateid, &dp->dl_stateid, flags); | 3220 | status = check_stateid_generation(stateid, &dp->dl_stateid, flags); |
3255 | if (status) | 3221 | if (status) |
3256 | goto out; | 3222 | goto out; |
@@ -3476,7 +3442,7 @@ alloc_init_lock_stateid(struct nfs4_stateowner *sop, struct nfs4_file *fp, struc | |||
3476 | stp->st_stateowner = sop; | 3442 | stp->st_stateowner = sop; |
3477 | get_nfs4_file(fp); | 3443 | get_nfs4_file(fp); |
3478 | stp->st_file = fp; | 3444 | stp->st_file = fp; |
3479 | stp->st_stateid.si_boot = get_seconds(); | 3445 | stp->st_stateid.si_boot = boot_time; |
3480 | stp->st_stateid.si_stateownerid = sop->so_id; | 3446 | stp->st_stateid.si_stateownerid = sop->so_id; |
3481 | stp->st_stateid.si_fileid = fp->fi_id; | 3447 | stp->st_stateid.si_fileid = fp->fi_id; |
3482 | stp->st_stateid.si_generation = 0; | 3448 | stp->st_stateid.si_generation = 0; |