nfsd4: kill some unneeded setclientid comments
[safe/jmp/linux-2.6] / fs / nfsd / nfs4proc.c
index e1c463b..18ead17 100644 (file)
@@ -47,6 +47,7 @@
 #include <linux/nfsd/state.h>
 #include <linux/nfsd/xdr4.h>
 #include <linux/nfs4_acl.h>
+#include <linux/sunrpc/gss_api.h>
 
 #define NFSDDBG_FACILITY               NFSDDBG_PROC
 
@@ -99,7 +100,15 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o
                status = nfsd_create_v3(rqstp, current_fh, open->op_fname.data,
                                        open->op_fname.len, &open->op_iattr,
                                        &resfh, open->op_createmode,
-                                       (u32 *)open->op_verf.data, &open->op_truncate, &created);
+                                       (u32 *)open->op_verf.data,
+                                       &open->op_truncate, &created);
+
+               /* If we ever decide to use different attrs to store the
+                * verifier in nfsd_create_v3, then we'll need to change this
+                */
+               if (open->op_createmode == NFS4_CREATE_EXCLUSIVE && status == 0)
+                       open->op_bmval[1] |= (FATTR4_WORD1_TIME_ACCESS |
+                                               FATTR4_WORD1_TIME_MODIFY);
        } else {
                status = nfsd_lookup(rqstp, current_fh,
                                     open->op_fname.data, open->op_fname.len, &resfh);
@@ -229,12 +238,12 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
                        break;
                case NFS4_OPEN_CLAIM_DELEGATE_PREV:
                        open->op_stateowner->so_confirmed = 1;
-                       printk("NFSD: unsupported OPEN claim type %d\n",
+                       dprintk("NFSD: unsupported OPEN claim type %d\n",
                                open->op_claim_type);
                        status = nfserr_notsupp;
                        goto out;
                default:
-                       printk("NFSD: Invalid OPEN claim type %d\n",
+                       dprintk("NFSD: Invalid OPEN claim type %d\n",
                                open->op_claim_type);
                        status = nfserr_inval;
                        goto out;
@@ -286,8 +295,7 @@ nfsd4_putrootfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
        __be32 status;
 
        fh_put(&cstate->current_fh);
-       status = exp_pseudoroot(rqstp->rq_client, &cstate->current_fh,
-                             &rqstp->rq_chandle);
+       status = exp_pseudoroot(rqstp, &cstate->current_fh);
        return status;
 }
 
@@ -474,8 +482,8 @@ nfsd4_lookupp(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
        __be32 ret;
 
        fh_init(&tmp_fh, NFS4_FHSIZE);
-       if((ret = exp_pseudoroot(rqstp->rq_client, &tmp_fh,
-                             &rqstp->rq_chandle)) != 0)
+       ret = exp_pseudoroot(rqstp, &tmp_fh);
+       if (ret)
                return ret;
        if (tmp_fh.fh_dentry == cstate->current_fh.fh_dentry) {
                fh_put(&tmp_fh);
@@ -611,6 +619,30 @@ nfsd4_rename(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 }
 
 static __be32
+nfsd4_secinfo(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
+             struct nfsd4_secinfo *secinfo)
+{
+       struct svc_fh resfh;
+       struct svc_export *exp;
+       struct dentry *dentry;
+       __be32 err;
+
+       fh_init(&resfh, NFS4_FHSIZE);
+       err = nfsd_lookup_dentry(rqstp, &cstate->current_fh,
+                                   secinfo->si_name, secinfo->si_namelen,
+                                   &exp, &dentry);
+       if (err)
+               return err;
+       if (dentry->d_inode == NULL) {
+               exp_put(exp);
+               err = nfserr_noent;
+       } else
+               secinfo->si_exp = exp;
+       dput(dentry);
+       return err;
+}
+
+static __be32
 nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
              struct nfsd4_setattr *setattr)
 {
@@ -802,6 +834,10 @@ typedef __be32(*nfsd4op_func)(struct svc_rqst *, struct nfsd4_compound_state *,
 struct nfsd4_operation {
        nfsd4op_func op_func;
        u32 op_flags;
+/* Most ops require a valid current filehandle; a few don't: */
+#define ALLOWED_WITHOUT_FH 1
+/* GETATTR and ops not listed as returning NFS4ERR_MOVED: */
+#define ALLOWED_ON_ABSENT_FS 2
 };
 
 static struct nfsd4_operation nfsd4_ops[];
@@ -872,32 +908,13 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
 
                opdesc = &nfsd4_ops[op->opnum];
 
-               /* All operations except RENEW, SETCLIENTID, RESTOREFH
-               * SETCLIENTID_CONFIRM, PUTFH and PUTROOTFH
-               * require a valid current filehandle
-               */
                if (!cstate->current_fh.fh_dentry) {
-                       if (!((op->opnum == OP_PUTFH) ||
-                             (op->opnum == OP_PUTROOTFH) ||
-                             (op->opnum == OP_SETCLIENTID) ||
-                             (op->opnum == OP_SETCLIENTID_CONFIRM) ||
-                             (op->opnum == OP_RENEW) ||
-                             (op->opnum == OP_RESTOREFH) ||
-                             (op->opnum == OP_RELEASE_LOCKOWNER))) {
+                       if (!(opdesc->op_flags & ALLOWED_WITHOUT_FH)) {
                                op->status = nfserr_nofilehandle;
                                goto encode_op;
                        }
-               }
-               /* Check must be done at start of each operation, except
-                * for GETATTR and ops not listed as returning NFS4ERR_MOVED
-                */
-               else if (cstate->current_fh.fh_export->ex_fslocs.migrated &&
-                        !((op->opnum == OP_GETATTR) ||
-                          (op->opnum == OP_PUTROOTFH) ||
-                          (op->opnum == OP_PUTPUBFH) ||
-                          (op->opnum == OP_RENEW) ||
-                          (op->opnum == OP_SETCLIENTID) ||
-                          (op->opnum == OP_RELEASE_LOCKOWNER))) {
+               } else if (cstate->current_fh.fh_export->ex_fslocs.migrated &&
+                         !(opdesc->op_flags & ALLOWED_ON_ABSENT_FS)) {
                        op->status = nfserr_moved;
                        goto encode_op;
                }
@@ -951,6 +968,7 @@ static struct nfsd4_operation nfsd4_ops[OP_RELEASE_LOCKOWNER+1] = {
        },
        [OP_GETATTR] = {
                .op_func = (nfsd4op_func)nfsd4_getattr,
+               .op_flags = ALLOWED_ON_ABSENT_FS,
        },
        [OP_GETFH] = {
                .op_func = (nfsd4op_func)nfsd4_getfh,
@@ -987,9 +1005,15 @@ static struct nfsd4_operation nfsd4_ops[OP_RELEASE_LOCKOWNER+1] = {
        },
        [OP_PUTFH] = {
                .op_func = (nfsd4op_func)nfsd4_putfh,
+               .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
+       },
+       [OP_PUTPUBFH] = {
+               /* unsupported; just for future reference: */
+               .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
        },
        [OP_PUTROOTFH] = {
                .op_func = (nfsd4op_func)nfsd4_putrootfh,
+               .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
        },
        [OP_READ] = {
                .op_func = (nfsd4op_func)nfsd4_read,
@@ -1008,21 +1032,28 @@ static struct nfsd4_operation nfsd4_ops[OP_RELEASE_LOCKOWNER+1] = {
        },
        [OP_RENEW] = {
                .op_func = (nfsd4op_func)nfsd4_renew,
+               .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
        },
        [OP_RESTOREFH] = {
                .op_func = (nfsd4op_func)nfsd4_restorefh,
+               .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
        },
        [OP_SAVEFH] = {
                .op_func = (nfsd4op_func)nfsd4_savefh,
        },
+       [OP_SECINFO] = {
+               .op_func = (nfsd4op_func)nfsd4_secinfo,
+       },
        [OP_SETATTR] = {
                .op_func = (nfsd4op_func)nfsd4_setattr,
        },
        [OP_SETCLIENTID] = {
                .op_func = (nfsd4op_func)nfsd4_setclientid,
+               .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
        },
        [OP_SETCLIENTID_CONFIRM] = {
                .op_func = (nfsd4op_func)nfsd4_setclientid_confirm,
+               .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
        },
        [OP_VERIFY] = {
                .op_func = (nfsd4op_func)nfsd4_verify,
@@ -1032,6 +1063,7 @@ static struct nfsd4_operation nfsd4_ops[OP_RELEASE_LOCKOWNER+1] = {
        },
        [OP_RELEASE_LOCKOWNER] = {
                .op_func = (nfsd4op_func)nfsd4_release_lockowner,
+               .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
        },
 };