nfsd41: nfsd DRC logic
[safe/jmp/linux-2.6] / fs / nfsd / nfs4proc.c
index c593db0..9e2ee75 100644 (file)
@@ -71,11 +71,11 @@ do_open_permission(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfs
                return nfserr_inval;
 
        if (open->op_share_access & NFS4_SHARE_ACCESS_READ)
-               accmode |= MAY_READ;
+               accmode |= NFSD_MAY_READ;
        if (open->op_share_access & NFS4_SHARE_ACCESS_WRITE)
-               accmode |= (MAY_WRITE | MAY_TRUNC);
+               accmode |= (NFSD_MAY_WRITE | NFSD_MAY_TRUNC);
        if (open->op_share_deny & NFS4_SHARE_DENY_WRITE)
-               accmode |= MAY_WRITE;
+               accmode |= NFSD_MAY_WRITE;
 
        status = fh_verify(rqstp, current_fh, S_IFREG, accmode);
 
@@ -103,11 +103,13 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o
                                        (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
+               /*
+                * Following rfc 3530 14.2.16, use the returned bitmask
+                * to indicate which attributes we used to store the
+                * verifier:
                 */
                if (open->op_createmode == NFS4_CREATE_EXCLUSIVE && status == 0)
-                       open->op_bmval[1] |= (FATTR4_WORD1_TIME_ACCESS |
+                       open->op_bmval[1] = (FATTR4_WORD1_TIME_ACCESS |
                                                FATTR4_WORD1_TIME_MODIFY);
        } else {
                status = nfsd_lookup(rqstp, current_fh,
@@ -118,15 +120,14 @@ do_open_lookup(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_o
                goto out;
 
        set_change_info(&open->op_cinfo, current_fh);
-
-       /* set reply cache */
        fh_dup2(current_fh, &resfh);
-       open->op_stateowner->so_replay.rp_openfh_len = resfh.fh_handle.fh_size;
-       memcpy(open->op_stateowner->so_replay.rp_openfh,
-                       &resfh.fh_handle.fh_base, resfh.fh_handle.fh_size);
 
+       /* set reply cache */
+       fh_copy_shallow(&open->op_stateowner->so_replay.rp_openfh,
+                       &resfh.fh_handle);
        if (!created)
-               status = do_open_permission(rqstp, current_fh, open, MAY_NOP);
+               status = do_open_permission(rqstp, current_fh, open,
+                                           NFSD_MAY_NOP);
 
 out:
        fh_put(&resfh);
@@ -149,15 +150,14 @@ do_open_fhandle(struct svc_rqst *rqstp, struct svc_fh *current_fh, struct nfsd4_
        memset(&open->op_cinfo, 0, sizeof(struct nfsd4_change_info));
 
        /* set replay cache */
-       open->op_stateowner->so_replay.rp_openfh_len = current_fh->fh_handle.fh_size;
-       memcpy(open->op_stateowner->so_replay.rp_openfh,
-               &current_fh->fh_handle.fh_base,
-               current_fh->fh_handle.fh_size);
+       fh_copy_shallow(&open->op_stateowner->so_replay.rp_openfh,
+                       &current_fh->fh_handle);
 
        open->op_truncate = (open->op_iattr.ia_valid & ATTR_SIZE) &&
                (open->op_iattr.ia_size == 0);
 
-       status = do_open_permission(rqstp, current_fh, open, MAY_OWNER_OVERRIDE);
+       status = do_open_permission(rqstp, current_fh, open,
+                                   NFSD_MAY_OWNER_OVERRIDE);
 
        return status;
 }
@@ -183,10 +183,9 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
        if (status == nfserr_replay_me) {
                struct nfs4_replay *rp = &open->op_stateowner->so_replay;
                fh_put(&cstate->current_fh);
-               cstate->current_fh.fh_handle.fh_size = rp->rp_openfh_len;
-               memcpy(&cstate->current_fh.fh_handle.fh_base, rp->rp_openfh,
-                               rp->rp_openfh_len);
-               status = fh_verify(rqstp, &cstate->current_fh, 0, MAY_NOP);
+               fh_copy_shallow(&cstate->current_fh.fh_handle,
+                               &rp->rp_openfh);
+               status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP);
                if (status)
                        dprintk("nfsd4_open: replay failed"
                                " restoring previous filehandle\n");
@@ -199,18 +198,14 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
        /* Openowner is now set, so sequence id will get bumped.  Now we need
         * these checks before we do any creates: */
        status = nfserr_grace;
-       if (nfs4_in_grace() && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS)
+       if (locks_in_grace() && open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS)
                goto out;
        status = nfserr_no_grace;
-       if (!nfs4_in_grace() && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS)
+       if (!locks_in_grace() && open->op_claim_type == NFS4_OPEN_CLAIM_PREVIOUS)
                goto out;
 
        switch (open->op_claim_type) {
                case NFS4_OPEN_CLAIM_DELEGATE_CUR:
-                       status = nfserr_inval;
-                       if (open->op_create)
-                               goto out;
-                       /* fall through */
                case NFS4_OPEN_CLAIM_NULL:
                        /*
                         * (1) set CURRENT_FH to the file being opened,
@@ -285,7 +280,7 @@ nfsd4_putfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
        cstate->current_fh.fh_handle.fh_size = putfh->pf_fhlen;
        memcpy(&cstate->current_fh.fh_handle.fh_base, putfh->pf_fhval,
               putfh->pf_fhlen);
-       return fh_verify(rqstp, &cstate->current_fh, 0, MAY_NOP);
+       return fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP);
 }
 
 static __be32
@@ -363,7 +358,8 @@ nfsd4_create(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 
        fh_init(&resfh, NFS4_FHSIZE);
 
-       status = fh_verify(rqstp, &cstate->current_fh, S_IFDIR, MAY_CREATE);
+       status = fh_verify(rqstp, &cstate->current_fh, S_IFDIR,
+                          NFSD_MAY_CREATE);
        if (status == nfserr_symlink)
                status = nfserr_notdir;
        if (status)
@@ -445,7 +441,7 @@ nfsd4_getattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 {
        __be32 status;
 
-       status = fh_verify(rqstp, &cstate->current_fh, 0, MAY_NOP);
+       status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP);
        if (status)
                return status;
 
@@ -519,7 +515,7 @@ nfsd4_read(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
        /* check stateid */
        if ((status = nfs4_preprocess_stateid_op(&cstate->current_fh,
                                &read->rd_stateid,
-                               CHECK_FH | RD_STATE, &read->rd_filp))) {
+                               RD_STATE, &read->rd_filp))) {
                dprintk("NFSD: nfsd4_read: couldn't process stateid!\n");
                goto out;
        }
@@ -572,7 +568,7 @@ nfsd4_remove(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 {
        __be32 status;
 
-       if (nfs4_in_grace())
+       if (locks_in_grace())
                return nfserr_grace;
        status = nfsd_unlink(rqstp, &cstate->current_fh, 0,
                             remove->rm_name, remove->rm_namelen);
@@ -593,7 +589,7 @@ nfsd4_rename(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 
        if (!cstate->save_fh.fh_dentry)
                return status;
-       if (nfs4_in_grace() && !(cstate->save_fh.fh_export->ex_flags
+       if (locks_in_grace() && !(cstate->save_fh.fh_export->ex_flags
                                        & NFSEXP_NOSUBTREECHECK))
                return nfserr_grace;
        status = nfsd_rename(rqstp, &cstate->save_fh, rename->rn_sname,
@@ -651,21 +647,26 @@ nfsd4_setattr(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
        if (setattr->sa_iattr.ia_valid & ATTR_SIZE) {
                nfs4_lock_state();
                status = nfs4_preprocess_stateid_op(&cstate->current_fh,
-                       &setattr->sa_stateid, CHECK_FH | WR_STATE, NULL);
+                       &setattr->sa_stateid, WR_STATE, NULL);
                nfs4_unlock_state();
                if (status) {
                        dprintk("NFSD: nfsd4_setattr: couldn't process stateid!\n");
                        return status;
                }
        }
+       status = mnt_want_write(cstate->current_fh.fh_export->ex_path.mnt);
+       if (status)
+               return status;
        status = nfs_ok;
        if (setattr->sa_acl != NULL)
                status = nfsd4_set_nfs4_acl(rqstp, &cstate->current_fh,
                                            setattr->sa_acl);
        if (status)
-               return status;
+               goto out;
        status = nfsd_setattr(rqstp, &cstate->current_fh, &setattr->sa_iattr,
                                0, (time_t)0);
+out:
+       mnt_drop_write(cstate->current_fh.fh_export->ex_path.mnt);
        return status;
 }
 
@@ -677,6 +678,7 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
        struct file *filp = NULL;
        u32 *p;
        __be32 status = nfs_ok;
+       unsigned long cnt;
 
        /* no need to check permission - this will be done in nfsd_write() */
 
@@ -685,7 +687,7 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 
        nfs4_lock_state();
        status = nfs4_preprocess_stateid_op(&cstate->current_fh, stateid,
-                                       CHECK_FH | WR_STATE, &filp);
+                                       WR_STATE, &filp);
        if (filp)
                get_file(filp);
        nfs4_unlock_state();
@@ -695,7 +697,7 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
                return status;
        }
 
-       write->wr_bytes_written = write->wr_buflen;
+       cnt = write->wr_buflen;
        write->wr_how_written = write->wr_stable_how;
        p = (u32 *)write->wr_verifier.data;
        *p++ = nfssvc_boot.tv_sec;
@@ -703,10 +705,12 @@ nfsd4_write(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
 
        status =  nfsd_write(rqstp, &cstate->current_fh, filp,
                             write->wr_offset, rqstp->rq_vec, write->wr_vlen,
-                            write->wr_buflen, &write->wr_how_written);
+                            &cnt, &write->wr_how_written);
        if (filp)
                fput(filp);
 
+       write->wr_bytes_written = cnt;
+
        if (status == nfserr_symlink)
                status = nfserr_inval;
        return status;
@@ -725,7 +729,7 @@ _nfsd4_verify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
        int count;
        __be32 status;
 
-       status = fh_verify(rqstp, &cstate->current_fh, 0, MAY_NOP);
+       status = fh_verify(rqstp, &cstate->current_fh, 0, NFSD_MAY_NOP);
        if (status)
                return status;
 
@@ -805,43 +809,41 @@ static inline void nfsd4_increment_op_stats(u32 opnum)
                nfsdstats.nfs4_opcount[opnum]++;
 }
 
-static void cstate_free(struct nfsd4_compound_state *cstate)
-{
-       if (cstate == NULL)
-               return;
-       fh_put(&cstate->current_fh);
-       fh_put(&cstate->save_fh);
-       BUG_ON(cstate->replay_owner);
-       kfree(cstate);
-}
-
-static struct nfsd4_compound_state *cstate_alloc(void)
-{
-       struct nfsd4_compound_state *cstate;
-
-       cstate = kmalloc(sizeof(struct nfsd4_compound_state), GFP_KERNEL);
-       if (cstate == NULL)
-               return NULL;
-       fh_init(&cstate->current_fh, NFS4_FHSIZE);
-       fh_init(&cstate->save_fh, NFS4_FHSIZE);
-       cstate->replay_owner = NULL;
-       return cstate;
-}
-
 typedef __be32(*nfsd4op_func)(struct svc_rqst *, struct nfsd4_compound_state *,
                              void *);
+enum nfsd4_op_flags {
+       ALLOWED_WITHOUT_FH = 1 << 0,    /* No current filehandle required */
+       ALLOWED_ON_ABSENT_FS = 2 << 0,  /* ops processed on absent fs */
+       ALLOWED_AS_FIRST_OP = 3 << 0,   /* ops reqired first in compound */
+};
 
 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
+       char *op_name;
 };
 
 static struct nfsd4_operation nfsd4_ops[];
 
+static const char *nfsd4_op_name(unsigned opnum);
+
+/*
+ * Enforce NFSv4.1 COMPOUND ordering rules.
+ *
+ * TODO:
+ * - enforce NFS4ERR_NOT_ONLY_OP,
+ * - DESTROY_SESSION MUST be the final operation in the COMPOUND request.
+ */
+static bool nfs41_op_ordering_ok(struct nfsd4_compoundargs *args)
+{
+       if (args->minorversion && args->opcnt > 0) {
+               struct nfsd4_op *op = &args->ops[0];
+               return (op->status == nfserr_op_illegal) ||
+                      (nfsd4_ops[op->opnum].op_flags & ALLOWED_AS_FIRST_OP);
+       }
+       return true;
+}
+
 /*
  * COMPOUND call.
  */
@@ -852,17 +854,13 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
 {
        struct nfsd4_op *op;
        struct nfsd4_operation *opdesc;
-       struct nfsd4_compound_state *cstate = NULL;
+       struct nfsd4_compound_state *cstate = &resp->cstate;
        int             slack_bytes;
        __be32          status;
 
-       status = nfserr_resource;
-       cstate = cstate_alloc();
-       if (cstate == NULL)
-               goto out;
-
        resp->xbuf = &rqstp->rq_res;
-       resp->p = rqstp->rq_res.head[0].iov_base + rqstp->rq_res.head[0].iov_len;
+       resp->p = rqstp->rq_res.head[0].iov_base +
+                                               rqstp->rq_res.head[0].iov_len;
        resp->tagp = resp->p;
        /* reserve space for: taglen, tag, and opcnt */
        resp->p += 2 + XDR_QUADLEN(args->taglen);
@@ -871,6 +869,11 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
        resp->tag = args->tag;
        resp->opcnt = 0;
        resp->rqstp = rqstp;
+       resp->cstate.replay_owner = NULL;
+       fh_init(&resp->cstate.current_fh, NFS4_FHSIZE);
+       fh_init(&resp->cstate.save_fh, NFS4_FHSIZE);
+       /* Use the deferral mechanism only for NFSv4.0 compounds */
+       rqstp->rq_usedeferral = (args->minorversion == 0);
 
        /*
         * According to RFC3010, this takes precedence over all other errors.
@@ -879,11 +882,19 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
        if (args->minorversion > NFSD_SUPPORTED_MINOR_VERSION)
                goto out;
 
+       if (!nfs41_op_ordering_ok(args)) {
+               op = &args->ops[0];
+               op->status = nfserr_sequence_pos;
+               goto encode_op;
+       }
+
        status = nfs_ok;
        while (!status && resp->opcnt < args->opcnt) {
                op = &args->ops[resp->opcnt++];
 
-               dprintk("nfsv4 compound op #%d: %d\n", resp->opcnt, op->opnum);
+               dprintk("nfsv4 compound op #%d/%d: %d (%s)\n",
+                       resp->opcnt, args->opcnt, op->opnum,
+                       nfsd4_op_name(op->opnum));
 
                /*
                 * The XDR decode routines may have pre-set op->status;
@@ -925,6 +936,12 @@ nfsd4_proc_compound(struct svc_rqst *rqstp,
                        BUG_ON(op->status == nfs_ok);
 
 encode_op:
+               /* Only from SEQUENCE or CREATE_SESSION */
+               if (resp->cstate.status == nfserr_replay_cache) {
+                       dprintk("%s NFS4.1 replay from cache\n", __func__);
+                       status = op->status;
+                       goto out;
+               }
                if (op->status == nfserr_replay_me) {
                        op->replay = &cstate->replay_owner->so_replay;
                        nfsd4_encode_replay(resp, op);
@@ -933,6 +950,11 @@ encode_op:
                        nfsd4_encode_operation(resp, op);
                        status = op->status;
                }
+
+               dprintk("nfsv4 compound op %p opcnt %d #%d: %d: status %d\n",
+                       args->ops, args->opcnt, resp->opcnt, op->opnum,
+                       be32_to_cpu(status));
+
                if (cstate->replay_owner) {
                        nfs4_put_stateowner(cstate->replay_owner);
                        cstate->replay_owner = NULL;
@@ -943,130 +965,204 @@ encode_op:
 
                nfsd4_increment_op_stats(op->opnum);
        }
+       if (!rqstp->rq_usedeferral && status == nfserr_dropit) {
+               dprintk("%s Dropit - send NFS4ERR_DELAY\n", __func__);
+               status = nfserr_jukebox;
+       }
 
+       resp->cstate.status = status;
+       fh_put(&resp->cstate.current_fh);
+       fh_put(&resp->cstate.save_fh);
+       BUG_ON(resp->cstate.replay_owner);
 out:
        nfsd4_release_compoundargs(args);
-       cstate_free(cstate);
+       /* Reset deferral mechanism for RPC deferrals */
+       rqstp->rq_usedeferral = 1;
+       dprintk("nfsv4 compound returned %d\n", ntohl(status));
        return status;
 }
 
-static struct nfsd4_operation nfsd4_ops[OP_RELEASE_LOCKOWNER+1] = {
+static struct nfsd4_operation nfsd4_ops[] = {
        [OP_ACCESS] = {
                .op_func = (nfsd4op_func)nfsd4_access,
+               .op_name = "OP_ACCESS",
        },
        [OP_CLOSE] = {
                .op_func = (nfsd4op_func)nfsd4_close,
+               .op_name = "OP_CLOSE",
        },
        [OP_COMMIT] = {
                .op_func = (nfsd4op_func)nfsd4_commit,
+               .op_name = "OP_COMMIT",
        },
        [OP_CREATE] = {
                .op_func = (nfsd4op_func)nfsd4_create,
+               .op_name = "OP_CREATE",
        },
        [OP_DELEGRETURN] = {
                .op_func = (nfsd4op_func)nfsd4_delegreturn,
+               .op_name = "OP_DELEGRETURN",
        },
        [OP_GETATTR] = {
                .op_func = (nfsd4op_func)nfsd4_getattr,
                .op_flags = ALLOWED_ON_ABSENT_FS,
+               .op_name = "OP_GETATTR",
        },
        [OP_GETFH] = {
                .op_func = (nfsd4op_func)nfsd4_getfh,
+               .op_name = "OP_GETFH",
        },
        [OP_LINK] = {
                .op_func = (nfsd4op_func)nfsd4_link,
+               .op_name = "OP_LINK",
        },
        [OP_LOCK] = {
                .op_func = (nfsd4op_func)nfsd4_lock,
+               .op_name = "OP_LOCK",
        },
        [OP_LOCKT] = {
                .op_func = (nfsd4op_func)nfsd4_lockt,
+               .op_name = "OP_LOCKT",
        },
        [OP_LOCKU] = {
                .op_func = (nfsd4op_func)nfsd4_locku,
+               .op_name = "OP_LOCKU",
        },
        [OP_LOOKUP] = {
                .op_func = (nfsd4op_func)nfsd4_lookup,
+               .op_name = "OP_LOOKUP",
        },
        [OP_LOOKUPP] = {
                .op_func = (nfsd4op_func)nfsd4_lookupp,
+               .op_name = "OP_LOOKUPP",
        },
        [OP_NVERIFY] = {
                .op_func = (nfsd4op_func)nfsd4_nverify,
+               .op_name = "OP_NVERIFY",
        },
        [OP_OPEN] = {
                .op_func = (nfsd4op_func)nfsd4_open,
+               .op_name = "OP_OPEN",
        },
        [OP_OPEN_CONFIRM] = {
                .op_func = (nfsd4op_func)nfsd4_open_confirm,
+               .op_name = "OP_OPEN_CONFIRM",
        },
        [OP_OPEN_DOWNGRADE] = {
                .op_func = (nfsd4op_func)nfsd4_open_downgrade,
+               .op_name = "OP_OPEN_DOWNGRADE",
        },
        [OP_PUTFH] = {
                .op_func = (nfsd4op_func)nfsd4_putfh,
                .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
+               .op_name = "OP_PUTFH",
        },
        [OP_PUTPUBFH] = {
-               /* unsupported; just for future reference: */
+               .op_func = (nfsd4op_func)nfsd4_putrootfh,
                .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
+               .op_name = "OP_PUTPUBFH",
        },
        [OP_PUTROOTFH] = {
                .op_func = (nfsd4op_func)nfsd4_putrootfh,
                .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
+               .op_name = "OP_PUTROOTFH",
        },
        [OP_READ] = {
                .op_func = (nfsd4op_func)nfsd4_read,
+               .op_name = "OP_READ",
        },
        [OP_READDIR] = {
                .op_func = (nfsd4op_func)nfsd4_readdir,
+               .op_name = "OP_READDIR",
        },
        [OP_READLINK] = {
                .op_func = (nfsd4op_func)nfsd4_readlink,
+               .op_name = "OP_READLINK",
        },
        [OP_REMOVE] = {
                .op_func = (nfsd4op_func)nfsd4_remove,
+               .op_name = "OP_REMOVE",
        },
        [OP_RENAME] = {
+               .op_name = "OP_RENAME",
                .op_func = (nfsd4op_func)nfsd4_rename,
        },
        [OP_RENEW] = {
                .op_func = (nfsd4op_func)nfsd4_renew,
                .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
+               .op_name = "OP_RENEW",
        },
        [OP_RESTOREFH] = {
                .op_func = (nfsd4op_func)nfsd4_restorefh,
                .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
+               .op_name = "OP_RESTOREFH",
        },
        [OP_SAVEFH] = {
                .op_func = (nfsd4op_func)nfsd4_savefh,
+               .op_name = "OP_SAVEFH",
        },
        [OP_SECINFO] = {
                .op_func = (nfsd4op_func)nfsd4_secinfo,
+               .op_name = "OP_SECINFO",
        },
        [OP_SETATTR] = {
                .op_func = (nfsd4op_func)nfsd4_setattr,
+               .op_name = "OP_SETATTR",
        },
        [OP_SETCLIENTID] = {
                .op_func = (nfsd4op_func)nfsd4_setclientid,
                .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
+               .op_name = "OP_SETCLIENTID",
        },
        [OP_SETCLIENTID_CONFIRM] = {
                .op_func = (nfsd4op_func)nfsd4_setclientid_confirm,
                .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
+               .op_name = "OP_SETCLIENTID_CONFIRM",
        },
        [OP_VERIFY] = {
                .op_func = (nfsd4op_func)nfsd4_verify,
+               .op_name = "OP_VERIFY",
        },
        [OP_WRITE] = {
                .op_func = (nfsd4op_func)nfsd4_write,
+               .op_name = "OP_WRITE",
        },
        [OP_RELEASE_LOCKOWNER] = {
                .op_func = (nfsd4op_func)nfsd4_release_lockowner,
                .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS,
+               .op_name = "OP_RELEASE_LOCKOWNER",
+       },
+
+       /* NFSv4.1 operations */
+       [OP_EXCHANGE_ID] = {
+               .op_func = (nfsd4op_func)nfsd4_exchange_id,
+               .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP,
+               .op_name = "OP_EXCHANGE_ID",
+       },
+       [OP_CREATE_SESSION] = {
+               .op_func = (nfsd4op_func)nfsd4_create_session,
+               .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP,
+               .op_name = "OP_CREATE_SESSION",
+       },
+       [OP_DESTROY_SESSION] = {
+               .op_func = (nfsd4op_func)nfsd4_destroy_session,
+               .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP,
+               .op_name = "OP_DESTROY_SESSION",
+       },
+       [OP_SEQUENCE] = {
+               .op_func = (nfsd4op_func)nfsd4_sequence,
+               .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP,
+               .op_name = "OP_SEQUENCE",
        },
 };
 
+static const char *nfsd4_op_name(unsigned opnum)
+{
+       if (opnum < ARRAY_SIZE(nfsd4_ops))
+               return nfsd4_ops[opnum].op_name;
+       return "unknown_operation";
+}
+
 #define nfs4svc_decode_voidargs                NULL
 #define nfs4svc_release_void           NULL
 #define nfsd4_voidres                  nfsd4_voidargs