aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd
diff options
context:
space:
mode:
authorAndy Adamson <andros@netapp.com>2009-04-03 01:28:50 -0400
committerJ. Bruce Fields <bfields@citi.umich.edu>2009-04-03 20:41:20 -0400
commit60adfc50de3855628dea8f8896a65f471f51301c (patch)
tree56b0b32f5c46cee80128ffaec1ac41588a821673 /fs/nfsd
parent496c262cf01106a546ffb7df6fea84b8b881ee19 (diff)
nfsd41: clientid handling
Extract the clientid from sessionid to set the op_clientid on open. Verify that the clid for other stateful ops is zero for minorversion != 0 Do all other checks for stateful ops without sessions. Signed-off-by: Benny Halevy <bhalevy@panasas.com> Signed-off-by: Andy Adamson <andros@netapp.com> [fixed whitespace indent] Signed-off-by: Benny Halevy <bhalevy@panasas.com> [nfsd41 remove sl_session from nfsd4_open] Signed-off-by: Andy Adamson <andros@netapp.com> Signed-off-by: Benny Halevy <bhalevy@panasas.com> Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Diffstat (limited to 'fs/nfsd')
-rw-r--r--fs/nfsd/nfs4proc.c12
-rw-r--r--fs/nfsd/nfs4state.c14
-rw-r--r--fs/nfsd/nfs4xdr.c9
3 files changed, 29 insertions, 6 deletions
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
index aeb4888bdfad..3fdcca53212a 100644
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -162,6 +162,15 @@ do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_
162 return status; 162 return status;
163} 163}
164 164
165static void
166copy_clientid(clientid_t *clid, struct nfsd4_session *session)
167{
168 struct nfsd4_sessionid *sid =
169 (struct nfsd4_sessionid *)session->se_sessionid.data;
170
171 clid->cl_boot = sid->clientid.cl_boot;
172 clid->cl_id = sid->clientid.cl_id;
173}
165 174
166static __be32 175static __be32
167nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, 176nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
@@ -178,6 +187,9 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
178 if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL) 187 if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL)
179 return nfserr_inval; 188 return nfserr_inval;
180 189
190 if (nfsd4_has_session(cstate))
191 copy_clientid(&open->op_clientid, cstate->session);
192
181 nfs4_lock_state(); 193 nfs4_lock_state();
182 194
183 /* check seqid for replay. set nfs4_owner */ 195 /* check seqid for replay. set nfs4_owner */
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index bbaf3c9bfe5a..d227f85b5ed2 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -603,8 +603,8 @@ STALE_CLIENTID(clientid_t *clid)
603{ 603{
604 if (clid->cl_boot == boot_time) 604 if (clid->cl_boot == boot_time)
605 return 0; 605 return 0;
606 dprintk("NFSD stale clientid (%08x/%08x)\n", 606 dprintk("NFSD stale clientid (%08x/%08x) boot_time %08lx\n",
607 clid->cl_boot, clid->cl_id); 607 clid->cl_boot, clid->cl_id, boot_time);
608 return 1; 608 return 1;
609} 609}
610 610
@@ -2965,8 +2965,9 @@ nfs4_preprocess_seqid_op(struct nfsd4_compound_state *cstate, u32 seqid,
2965 if (lock->lk_is_new) { 2965 if (lock->lk_is_new) {
2966 if (!sop->so_is_open_owner) 2966 if (!sop->so_is_open_owner)
2967 return nfserr_bad_stateid; 2967 return nfserr_bad_stateid;
2968 if (!same_clid(&clp->cl_clientid, lockclid)) 2968 if (!(flags & HAS_SESSION) &&
2969 return nfserr_bad_stateid; 2969 !same_clid(&clp->cl_clientid, lockclid))
2970 return nfserr_bad_stateid;
2970 /* stp is the open stateid */ 2971 /* stp is the open stateid */
2971 status = nfs4_check_openmode(stp, lkflg); 2972 status = nfs4_check_openmode(stp, lkflg);
2972 if (status) 2973 if (status)
@@ -3507,7 +3508,8 @@ nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3507 struct nfs4_file *fp; 3508 struct nfs4_file *fp;
3508 3509
3509 status = nfserr_stale_clientid; 3510 status = nfserr_stale_clientid;
3510 if (STALE_CLIENTID(&lock->lk_new_clientid)) 3511 if (!nfsd4_has_session(cstate) &&
3512 STALE_CLIENTID(&lock->lk_new_clientid))
3511 goto out; 3513 goto out;
3512 3514
3513 /* validate and update open stateid and open seqid */ 3515 /* validate and update open stateid and open seqid */
@@ -3661,7 +3663,7 @@ nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
3661 nfs4_lock_state(); 3663 nfs4_lock_state();
3662 3664
3663 status = nfserr_stale_clientid; 3665 status = nfserr_stale_clientid;
3664 if (STALE_CLIENTID(&lockt->lt_clientid)) 3666 if (!nfsd4_has_session(cstate) && STALE_CLIENTID(&lockt->lt_clientid))
3665 goto out; 3667 goto out;
3666 3668
3667 if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0))) { 3669 if ((status = fh_verify(rqstp, &cstate->current_fh, S_IFREG, 0))) {
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index 7fdee828f44e..059d4aad39b8 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -189,6 +189,11 @@ static __be32 *read_buf(struct nfsd4_compoundargs *argp, u32 nbytes)
189 return p; 189 return p;
190} 190}
191 191
192static int zero_clientid(clientid_t *clid)
193{
194 return (clid->cl_boot == 0) && (clid->cl_id == 0);
195}
196
192static int 197static int
193defer_free(struct nfsd4_compoundargs *argp, 198defer_free(struct nfsd4_compoundargs *argp,
194 void (*release)(const void *), void *p) 199 void (*release)(const void *), void *p)
@@ -584,6 +589,8 @@ nfsd4_decode_lockt(struct nfsd4_compoundargs *argp, struct nfsd4_lockt *lockt)
584 READ_BUF(lockt->lt_owner.len); 589 READ_BUF(lockt->lt_owner.len);
585 READMEM(lockt->lt_owner.data, lockt->lt_owner.len); 590 READMEM(lockt->lt_owner.data, lockt->lt_owner.len);
586 591
592 if (argp->minorversion && !zero_clientid(&lockt->lt_clientid))
593 return nfserr_inval;
587 DECODE_TAIL; 594 DECODE_TAIL;
588} 595}
589 596
@@ -994,6 +1001,8 @@ nfsd4_decode_release_lockowner(struct nfsd4_compoundargs *argp, struct nfsd4_rel
994 READ_BUF(rlockowner->rl_owner.len); 1001 READ_BUF(rlockowner->rl_owner.len);
995 READMEM(rlockowner->rl_owner.data, rlockowner->rl_owner.len); 1002 READMEM(rlockowner->rl_owner.data, rlockowner->rl_owner.len);
996 1003
1004 if (argp->minorversion && !zero_clientid(&rlockowner->rl_clientid))
1005 return nfserr_inval;
997 DECODE_TAIL; 1006 DECODE_TAIL;
998} 1007}
999 1008