aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ. Bruce Fields <bfields@citi.umich.edu>2009-02-02 17:23:10 -0500
committerJ. Bruce Fields <bfields@citi.umich.edu>2009-03-18 17:30:49 -0400
commita4773c08f2872626cb923433284488fbe8acb0ae (patch)
tree772342b775cef615b19060158900981e0985ff9f
parent13024b7b4097d33fe6bba34b1c83602e88753270 (diff)
nfsd4: use helper for copying filehandles for replay
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
-rw-r--r--fs/nfsd/nfs4proc.c17
-rw-r--r--include/linux/nfsd/nfsfh.h7
-rw-r--r--include/linux/nfsd/state.h3
3 files changed, 14 insertions, 13 deletions
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index 326506272258..af66073ed423 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -123,10 +123,8 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o
123 fh_dup2(current_fh, &resfh); 123 fh_dup2(current_fh, &resfh);
124 124
125 /* set reply cache */ 125 /* set reply cache */
126 open->op_stateowner->so_replay.rp_openfh_len = resfh.fh_handle.fh_size; 126 fh_copy_shallow(&open->op_stateowner->so_replay.rp_openfh,
127 memcpy(open->op_stateowner->so_replay.rp_openfh, 127 &resfh.fh_handle);
128 &resfh.fh_handle.fh_base, resfh.fh_handle.fh_size);
129
130 if (!created) 128 if (!created)
131 status = do_open_permission(rqstp, current_fh, open, 129 status = do_open_permission(rqstp, current_fh, open,
132 NFSD_MAY_NOP); 130 NFSD_MAY_NOP);
@@ -152,10 +150,8 @@ do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_
152 memset(&open->op_cinfo, 0, sizeof(struct nfsd4_change_info)); 150 memset(&open->op_cinfo, 0, sizeof(struct nfsd4_change_info));
153 151
154 /* set replay cache */ 152 /* set replay cache */
155 open->op_stateowner->so_replay.rp_openfh_len = current_fh->fh_handle.fh_size; 153 fh_copy_shallow(&open->op_stateowner->so_replay.rp_openfh,
156 memcpy(open->op_stateowner->so_replay.rp_openfh, 154 &current_fh->fh_handle);
157 &current_fh->fh_handle.fh_base,
158 current_fh->fh_handle.fh_size);
159 155
160 open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) && 156 open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) &&
161 (open->op_iattr.ia_size == 0); 157 (open->op_iattr.ia_size == 0);
@@ -187,9 +183,8 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
187 if (status == nfserr_replay_me) { 183 if (status == nfserr_replay_me) {
188 struct nfs4_replay *rp = &open->op_stateowner->so_replay; 184 struct nfs4_replay *rp = &open->op_stateowner->so_replay;
189 fh_put(&cstate->current_fh); 185 fh_put(&cstate->current_fh);
190 cstate->current_fh.fh_handle.fh_size = rp->rp_openfh_len; 186 fh_copy_shallow(&cstate->current_fh.fh_handle,
191 memcpy(&cstate->current_fh.fh_handle.fh_base, rp->rp_openfh, 187 &rp->rp_openfh);
192 rp->rp_openfh_len);
193 status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP); 188 status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP);
194 if (status) 189 if (status)
195 dprintk("nfsd4_open: replay failed" 190 dprintk("nfsd4_open: replay failed"
diff --git a/include/linux/nfsd/nfsfh.h b/include/linux/nfsd/nfsfh.h
index fa317f6c154b..afa19016c4a8 100644
--- a/include/linux/nfsd/nfsfh.h
+++ b/include/linux/nfsd/nfsfh.h
@@ -269,6 +269,13 @@ fh_copy(struct svc_fh *dst, struct svc_fh *src)
269 return dst; 269 return dst;
270} 270}
271 271
272static inline void
273fh_copy_shallow(struct knfsd_fh *dst, struct knfsd_fh *src)
274{
275 dst->fh_size = src->fh_size;
276 memcpy(&dst->fh_base, &src->fh_base, src->fh_size);
277}
278
272static __inline__ struct svc_fh * 279static __inline__ struct svc_fh *
273fh_init(struct svc_fh *fhp, int maxsize) 280fh_init(struct svc_fh *fhp, int maxsize)
274{ 281{
diff --git a/include/linux/nfsd/state.h b/include/linux/nfsd/state.h
index 128298c0362d..b65b2a6274b0 100644
--- a/include/linux/nfsd/state.h
+++ b/include/linux/nfsd/state.h
@@ -168,8 +168,7 @@ struct nfs4_replay {
168 unsigned int rp_buflen; 168 unsigned int rp_buflen;
169 char *rp_buf; 169 char *rp_buf;
170 unsigned intrp_allocated; 170 unsigned intrp_allocated;
171 int rp_openfh_len; 171 struct knfsd_fh rp_openfh;
172 char rp_openfh[NFS4_FHSIZE];
173 char rp_ibuf[NFSD4_REPLAY_ISIZE]; 172 char rp_ibuf[NFSD4_REPLAY_ISIZE];
174}; 173};
175 174