These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / fs / nfs / callback_proc.c
index 197806f..807eb6e 100644 (file)
@@ -17,9 +17,7 @@
 #include "nfs4session.h"
 #include "nfs4trace.h"
 
-#ifdef NFS_DEBUG
 #define NFSDBG_FACILITY NFSDBG_CALLBACK
-#endif
 
 __be32 nfs4_callback_getattr(struct cb_getattrargs *args,
                             struct cb_getattrres *res,
@@ -40,8 +38,11 @@ __be32 nfs4_callback_getattr(struct cb_getattrargs *args,
                rpc_peeraddr2str(cps->clp->cl_rpcclient, RPC_DISPLAY_ADDR));
 
        inode = nfs_delegation_find_inode(cps->clp, &args->fh);
-       if (inode == NULL)
+       if (inode == NULL) {
+               trace_nfs4_cb_getattr(cps->clp, &args->fh, NULL,
+                               -ntohl(res->status));
                goto out;
+       }
        nfsi = NFS_I(inode);
        rcu_read_lock();
        delegation = rcu_dereference(nfsi->delegation);
@@ -60,6 +61,7 @@ __be32 nfs4_callback_getattr(struct cb_getattrargs *args,
        res->status = 0;
 out_iput:
        rcu_read_unlock();
+       trace_nfs4_cb_getattr(cps->clp, &args->fh, inode, -ntohl(res->status));
        iput(inode);
 out:
        dprintk("%s: exit with status = %d\n", __func__, ntohl(res->status));
@@ -194,6 +196,7 @@ unlock:
        spin_unlock(&ino->i_lock);
        pnfs_free_lseg_list(&free_me_list);
        pnfs_put_layout_hdr(lo);
+       trace_nfs4_cb_layoutrecall_inode(clp, &args->cbl_fh, ino, -rv);
        iput(ino);
 out:
        return rv;
@@ -327,10 +330,8 @@ validate_seqid(struct nfs4_slot_table *tbl, struct cb_sequenceargs * args)
        dprintk("%s slot table seqid: %u\n", __func__, slot->seq_nr);
 
        /* Normal */
-       if (likely(args->csa_sequenceid == slot->seq_nr + 1)) {
-               slot->seq_nr++;
+       if (likely(args->csa_sequenceid == slot->seq_nr + 1))
                goto out_ok;
-       }
 
        /* Replay */
        if (args->csa_sequenceid == slot->seq_nr) {
@@ -418,6 +419,7 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
                              struct cb_process_state *cps)
 {
        struct nfs4_slot_table *tbl;
+       struct nfs4_slot *slot;
        struct nfs_client *clp;
        int i;
        __be32 status = htonl(NFS4ERR_BADSESSION);
@@ -429,25 +431,32 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
 
        if (!(clp->cl_session->flags & SESSION4_BACK_CHAN))
                goto out;
+
        tbl = &clp->cl_session->bc_slot_table;
+       slot = tbl->slots + args->csa_slotid;
 
        spin_lock(&tbl->slot_tbl_lock);
        /* state manager is resetting the session */
        if (test_bit(NFS4_SLOT_TBL_DRAINING, &tbl->slot_tbl_state)) {
-               spin_unlock(&tbl->slot_tbl_lock);
                status = htonl(NFS4ERR_DELAY);
                /* Return NFS4ERR_BADSESSION if we're draining the session
                 * in order to reset it.
                 */
                if (test_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state))
                        status = htonl(NFS4ERR_BADSESSION);
-               goto out;
+               goto out_unlock;
        }
 
-       status = validate_seqid(&clp->cl_session->bc_slot_table, args);
-       spin_unlock(&tbl->slot_tbl_lock);
+       memcpy(&res->csr_sessionid, &args->csa_sessionid,
+              sizeof(res->csr_sessionid));
+       res->csr_sequenceid = args->csa_sequenceid;
+       res->csr_slotid = args->csa_slotid;
+       res->csr_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;
+       res->csr_target_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;
+
+       status = validate_seqid(tbl, args);
        if (status)
-               goto out;
+               goto out_unlock;
 
        cps->slotid = args->csa_slotid;
 
@@ -458,15 +467,17 @@ __be32 nfs4_callback_sequence(struct cb_sequenceargs *args,
         */
        if (referring_call_exists(clp, args->csa_nrclists, args->csa_rclists)) {
                status = htonl(NFS4ERR_DELAY);
-               goto out;
+               goto out_unlock;
        }
 
-       memcpy(&res->csr_sessionid, &args->csa_sessionid,
-              sizeof(res->csr_sessionid));
-       res->csr_sequenceid = args->csa_sequenceid;
-       res->csr_slotid = args->csa_slotid;
-       res->csr_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;
-       res->csr_target_highestslotid = NFS41_BC_MAX_CALLBACKS - 1;
+       /*
+        * RFC5661 20.9.3
+        * If CB_SEQUENCE returns an error, then the state of the slot
+        * (sequence ID, cached reply) MUST NOT change.
+        */
+       slot->seq_nr++;
+out_unlock:
+       spin_unlock(&tbl->slot_tbl_lock);
 
 out:
        cps->clp = clp; /* put in nfs4_callback_compound */
@@ -546,7 +557,7 @@ __be32 nfs4_callback_recallslot(struct cb_recallslotargs *args, void *dummy,
        status = htonl(NFS4_OK);
 
        nfs41_set_target_slotid(fc_tbl, args->crsa_target_highest_slotid);
-       nfs41_server_notify_target_slotid_update(cps->clp);
+       nfs41_notify_server(cps->clp);
 out:
        dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
        return status;