diff options
author | Tigran Mkrtchyan <kofemann@gmail.com> | 2012-02-13 16:55:32 -0500 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2012-02-15 11:20:45 -0500 |
commit | 37c593c57324740821766c56e48cf09776a68a9c (patch) | |
tree | 9c6f91acb532da56f5d5f24c2aa8a345f717c81a /fs/nfsd | |
parent | 9428fe1abb672c67169d3b6abf0faa120f020c32 (diff) |
nfsd41: use current stateid by value
Signed-off-by: Tigran Mkrtchyan <kofemann@gmail.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/current_stateid.h | 1 | ||||
-rw-r--r-- | fs/nfsd/nfs4proc.c | 12 | ||||
-rw-r--r-- | fs/nfsd/nfs4state.c | 16 | ||||
-rw-r--r-- | fs/nfsd/xdr4.h | 13 |
4 files changed, 33 insertions, 9 deletions
diff --git a/fs/nfsd/current_stateid.h b/fs/nfsd/current_stateid.h index d8c99928b431..4123551208d8 100644 --- a/fs/nfsd/current_stateid.h +++ b/fs/nfsd/current_stateid.h | |||
@@ -4,6 +4,7 @@ | |||
4 | #include "state.h" | 4 | #include "state.h" |
5 | #include "xdr4.h" | 5 | #include "xdr4.h" |
6 | 6 | ||
7 | extern void clear_current_stateid(struct nfsd4_compound_state *cstate); | ||
7 | /* | 8 | /* |
8 | * functions to set current state id | 9 | * functions to set current state id |
9 | */ | 10 | */ |
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 1ee0e7c42e97..53636ff0e6ae 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -453,7 +453,10 @@ nfsd4_restorefh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
453 | return nfserr_restorefh; | 453 | return nfserr_restorefh; |
454 | 454 | ||
455 | fh_dup2(&cstate->current_fh, &cstate->save_fh); | 455 | fh_dup2(&cstate->current_fh, &cstate->save_fh); |
456 | cstate->current_stateid = cstate->save_stateid; | 456 | if (HAS_STATE_ID(cstate, SAVED_STATE_ID_FLAG)) { |
457 | memcpy(&cstate->current_stateid, &cstate->save_stateid, sizeof(stateid_t)); | ||
458 | SET_STATE_ID(cstate, CURRENT_STATE_ID_FLAG); | ||
459 | } | ||
457 | return nfs_ok; | 460 | return nfs_ok; |
458 | } | 461 | } |
459 | 462 | ||
@@ -465,7 +468,10 @@ nfsd4_savefh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
465 | return nfserr_nofilehandle; | 468 | return nfserr_nofilehandle; |
466 | 469 | ||
467 | fh_dup2(&cstate->save_fh, &cstate->current_fh); | 470 | fh_dup2(&cstate->save_fh, &cstate->current_fh); |
468 | cstate->save_stateid = cstate->current_stateid; | 471 | if (HAS_STATE_ID(cstate, CURRENT_STATE_ID_FLAG)) { |
472 | memcpy(&cstate->save_stateid, &cstate->current_stateid, sizeof(stateid_t)); | ||
473 | SET_STATE_ID(cstate, SAVED_STATE_ID_FLAG); | ||
474 | } | ||
469 | return nfs_ok; | 475 | return nfs_ok; |
470 | } | 476 | } |
471 | 477 | ||
@@ -1238,7 +1244,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, | |||
1238 | opdesc->op_set_currentstateid(cstate, &op->u); | 1244 | opdesc->op_set_currentstateid(cstate, &op->u); |
1239 | 1245 | ||
1240 | if (opdesc->op_flags & OP_CLEAR_STATEID) | 1246 | if (opdesc->op_flags & OP_CLEAR_STATEID) |
1241 | cstate->current_stateid = NULL; | 1247 | clear_current_stateid(cstate); |
1242 | 1248 | ||
1243 | if (need_wrongsec_check(rqstp)) | 1249 | if (need_wrongsec_check(rqstp)) |
1244 | op->status = check_nfsd_access(cstate->current_fh.fh_export, rqstp); | 1250 | op->status = check_nfsd_access(cstate->current_fh.fh_export, rqstp); |
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 7b0b6f0f69cb..cf62079e9b71 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -4699,15 +4699,23 @@ nfs4_state_shutdown(void) | |||
4699 | static void | 4699 | static void |
4700 | get_stateid(struct nfsd4_compound_state *cstate, stateid_t *stateid) | 4700 | get_stateid(struct nfsd4_compound_state *cstate, stateid_t *stateid) |
4701 | { | 4701 | { |
4702 | if (cstate->current_stateid && CURRENT_STATEID(stateid)) | 4702 | if (HAS_STATE_ID(cstate, CURRENT_STATE_ID_FLAG) && CURRENT_STATEID(stateid)) |
4703 | memcpy(stateid, cstate->current_stateid, sizeof(stateid_t)); | 4703 | memcpy(stateid, &cstate->current_stateid, sizeof(stateid_t)); |
4704 | } | 4704 | } |
4705 | 4705 | ||
4706 | static void | 4706 | static void |
4707 | put_stateid(struct nfsd4_compound_state *cstate, stateid_t *stateid) | 4707 | put_stateid(struct nfsd4_compound_state *cstate, stateid_t *stateid) |
4708 | { | 4708 | { |
4709 | if (cstate->minorversion) | 4709 | if (cstate->minorversion) { |
4710 | cstate->current_stateid = stateid; | 4710 | memcpy(&cstate->current_stateid, stateid, sizeof(stateid_t)); |
4711 | SET_STATE_ID(cstate, CURRENT_STATE_ID_FLAG); | ||
4712 | } | ||
4713 | } | ||
4714 | |||
4715 | void | ||
4716 | clear_current_stateid(struct nfsd4_compound_state *cstate) | ||
4717 | { | ||
4718 | CLEAR_STATE_ID(cstate, CURRENT_STATE_ID_FLAG); | ||
4711 | } | 4719 | } |
4712 | 4720 | ||
4713 | /* | 4721 | /* |
diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 3c1ddd7f13a4..12789eb3f911 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h | |||
@@ -43,6 +43,13 @@ | |||
43 | #define NFSD4_MAX_TAGLEN 128 | 43 | #define NFSD4_MAX_TAGLEN 128 |
44 | #define XDR_LEN(n) (((n) + 3) & ~3) | 44 | #define XDR_LEN(n) (((n) + 3) & ~3) |
45 | 45 | ||
46 | #define CURRENT_STATE_ID_FLAG (1<<0) | ||
47 | #define SAVED_STATE_ID_FLAG (1<<1) | ||
48 | |||
49 | #define SET_STATE_ID(c, f) ((c)->sid_flags |= (f)) | ||
50 | #define HAS_STATE_ID(c, f) ((c)->sid_flags & (f)) | ||
51 | #define CLEAR_STATE_ID(c, f) ((c)->sid_flags &= ~(f)) | ||
52 | |||
46 | struct nfsd4_compound_state { | 53 | struct nfsd4_compound_state { |
47 | struct svc_fh current_fh; | 54 | struct svc_fh current_fh; |
48 | struct svc_fh save_fh; | 55 | struct svc_fh save_fh; |
@@ -54,8 +61,10 @@ struct nfsd4_compound_state { | |||
54 | size_t iovlen; | 61 | size_t iovlen; |
55 | u32 minorversion; | 62 | u32 minorversion; |
56 | u32 status; | 63 | u32 status; |
57 | const stateid_t *current_stateid; | 64 | stateid_t current_stateid; |
58 | const stateid_t *save_stateid; | 65 | stateid_t save_stateid; |
66 | /* to indicate current and saved state id presents */ | ||
67 | u32 sid_flags; | ||
59 | }; | 68 | }; |
60 | 69 | ||
61 | static inline bool nfsd4_has_session(struct nfsd4_compound_state *cs) | 70 | static inline bool nfsd4_has_session(struct nfsd4_compound_state *cs) |