]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
nfs41: implement cb_recall_slot
authorAndy Adamson <andros@netapp.com>
Wed, 20 Jan 2010 21:06:27 +0000 (16:06 -0500)
committerTrond Myklebust <Trond.Myklebust@netapp.com>
Wed, 10 Feb 2010 13:30:59 +0000 (08:30 -0500)
Drain the fore channel and reset the max_slots to the new value.

Signed-off-by: Andy Adamson <andros@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
fs/nfs/callback.h
fs/nfs/callback_proc.c
fs/nfs/callback_xdr.c
fs/nfs/nfs4_fs.h
fs/nfs/nfs4state.c
include/linux/nfs_fs_sb.h

index d4036be0b589ffd24c391b53bded40bc55a6ab5f..85a7cfd1b8dda66bd7a25dcb8e0be91845b191ac 100644 (file)
@@ -119,6 +119,14 @@ struct cb_recallanyargs {
 };
 
 extern unsigned nfs4_callback_recallany(struct cb_recallanyargs *args, void *dummy);
+
+struct cb_recallslotargs {
+       struct sockaddr *crsa_addr;
+       uint32_t        crsa_target_max_slots;
+};
+extern unsigned nfs4_callback_recallslot(struct cb_recallslotargs *args,
+                                         void *dummy);
+
 #endif /* CONFIG_NFS_V4_1 */
 
 extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres *res);
index 4062f7690a33f363ede1d823120272e68a48cd0b..e5155d9df595edfc25e2ab5d184a13daec38c467 100644 (file)
@@ -361,4 +361,36 @@ out:
        dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
        return status;
 }
+
+/* Reduce the fore channel's max_slots to the target value */
+unsigned nfs4_callback_recallslot(struct cb_recallslotargs *args, void *dummy)
+{
+       struct nfs_client *clp;
+       struct nfs4_slot_table *fc_tbl;
+       int status;
+
+       status = htonl(NFS4ERR_OP_NOT_IN_SESSION);
+       clp = nfs_find_client(args->crsa_addr, 4);
+       if (clp == NULL)
+               goto out;
+
+       dprintk("NFS: CB_RECALL_SLOT request from %s target max slots %d\n",
+               rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR),
+               args->crsa_target_max_slots);
+
+       fc_tbl = &clp->cl_session->fc_slot_table;
+
+       status = htonl(NFS4ERR_BAD_HIGH_SLOT);
+       if (args->crsa_target_max_slots >= fc_tbl->max_slots ||
+           args->crsa_target_max_slots < 1)
+               goto out;
+
+       fc_tbl->target_max_slots = args->crsa_target_max_slots;
+       nfs41_handle_recall_slot(clp);
+       status = htonl(NFS4_OK);
+       nfs_put_client(clp);    /* balance nfs_find_client */
+out:
+       dprintk("%s: exit with status = %d\n", __func__, ntohl(status));
+       return status;
+}
 #endif /* CONFIG_NFS_V4_1 */
index 08b430d922c43960814ea6664c8ab60610620a96..8e66e20b59fd92f38b36836e5156791b2466f722 100644 (file)
@@ -24,6 +24,7 @@
 #define CB_OP_SEQUENCE_RES_MAXSZ       (CB_OP_HDR_RES_MAXSZ + \
                                        4 + 1 + 3)
 #define CB_OP_RECALLANY_RES_MAXSZ      (CB_OP_HDR_RES_MAXSZ)
+#define CB_OP_RECALLSLOT_RES_MAXSZ     (CB_OP_HDR_RES_MAXSZ)
 #endif /* CONFIG_NFS_V4_1 */
 
 #define NFSDBG_FACILITY NFSDBG_CALLBACK
@@ -349,6 +350,20 @@ static unsigned decode_recallany_args(struct svc_rqst *rqstp,
        return 0;
 }
 
+static unsigned decode_recallslot_args(struct svc_rqst *rqstp,
+                                       struct xdr_stream *xdr,
+                                       struct cb_recallslotargs *args)
+{
+       __be32 *p;
+
+       args->crsa_addr = svc_addr(rqstp);
+       p = read_buf(xdr, 4);
+       if (unlikely(p == NULL))
+               return htonl(NFS4ERR_BADXDR);
+       args->crsa_target_max_slots = ntohl(*p++);
+       return 0;
+}
+
 #endif /* CONFIG_NFS_V4_1 */
 
 static __be32 encode_string(struct xdr_stream *xdr, unsigned int len, const char *str)
@@ -557,6 +572,7 @@ preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op)
        case OP_CB_RECALL:
        case OP_CB_SEQUENCE:
        case OP_CB_RECALL_ANY:
+       case OP_CB_RECALL_SLOT:
                *op = &callback_ops[op_nr];
                break;
 
@@ -565,7 +581,6 @@ preprocess_nfs41_op(int nop, unsigned int op_nr, struct callback_op **op)
        case OP_CB_NOTIFY:
        case OP_CB_PUSH_DELEG:
        case OP_CB_RECALLABLE_OBJ_AVAIL:
-       case OP_CB_RECALL_SLOT:
        case OP_CB_WANTS_CANCELLED:
        case OP_CB_NOTIFY_LOCK:
                return htonl(NFS4ERR_NOTSUPP);
@@ -734,6 +749,11 @@ static struct callback_op callback_ops[] = {
                .decode_args = (callback_decode_arg_t)decode_recallany_args,
                .res_maxsize = CB_OP_RECALLANY_RES_MAXSZ,
        },
+       [OP_CB_RECALL_SLOT] = {
+               .process_op = (callback_process_op_t)nfs4_callback_recallslot,
+               .decode_args = (callback_decode_arg_t)decode_recallslot_args,
+               .res_maxsize = CB_OP_RECALLSLOT_RES_MAXSZ,
+       },
 #endif /* CONFIG_NFS_V4_1 */
 };
 
index 0c6fda33d66ec170a6ecd00a03ba600168b34e70..a187200a7aac254414d2ba7ad94277e712a24742 100644 (file)
@@ -46,6 +46,7 @@ enum nfs4_client_state {
        NFS4CLNT_DELEGRETURN,
        NFS4CLNT_SESSION_RESET,
        NFS4CLNT_SESSION_DRAINING,
+       NFS4CLNT_RECALL_SLOT,
 };
 
 /*
@@ -280,6 +281,7 @@ extern void nfs4_schedule_state_manager(struct nfs_client *);
 extern int nfs4_state_mark_reclaim_nograce(struct nfs_client *clp, struct nfs4_state *state);
 extern int nfs4_state_mark_reclaim_reboot(struct nfs_client *clp, struct nfs4_state *state);
 extern void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags);
+extern void nfs41_handle_recall_slot(struct nfs_client *clp);
 extern void nfs4_put_lock_state(struct nfs4_lock_state *lsp);
 extern int nfs4_set_lock_state(struct nfs4_state *state, struct file_lock *fl);
 extern void nfs4_copy_stateid(nfs4_stateid *, struct nfs4_state *, fl_owner_t);
index 8406cacd32408cc9c7d2258e90e291bf135397b7..9164758c1ace41078f39f73a936c2bc2ad595255 100644 (file)
@@ -1249,6 +1249,12 @@ static int nfs4_reclaim_lease(struct nfs_client *clp)
 }
 
 #ifdef CONFIG_NFS_V4_1
+void nfs41_handle_recall_slot(struct nfs_client *clp)
+{
+       set_bit(NFS4CLNT_RECALL_SLOT, &clp->cl_state);
+       nfs4_schedule_state_recovery(clp);
+}
+
 void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags)
 {
        if (!flags)
@@ -1299,9 +1305,38 @@ out:
        return status;
 }
 
+static int nfs4_recall_slot(struct nfs_client *clp)
+{
+       struct nfs4_slot_table *fc_tbl = &clp->cl_session->fc_slot_table;
+       struct nfs4_channel_attrs *fc_attrs = &clp->cl_session->fc_attrs;
+       struct nfs4_slot *new, *old;
+       int i;
+
+       nfs4_begin_drain_session(clp);
+       new = kmalloc(fc_tbl->target_max_slots * sizeof(struct nfs4_slot),
+                     GFP_KERNEL);
+        if (!new)
+               return -ENOMEM;
+
+       spin_lock(&fc_tbl->slot_tbl_lock);
+       for (i = 0; i < fc_tbl->target_max_slots; i++)
+               new[i].seq_nr = fc_tbl->slots[i].seq_nr;
+       old = fc_tbl->slots;
+       fc_tbl->slots = new;
+       fc_tbl->max_slots = fc_tbl->target_max_slots;
+       fc_tbl->target_max_slots = 0;
+       fc_attrs->max_reqs = fc_tbl->max_slots;
+       spin_unlock(&fc_tbl->slot_tbl_lock);
+
+       kfree(old);
+       nfs4_end_drain_session(clp);
+       return 0;
+}
+
 #else /* CONFIG_NFS_V4_1 */
 static int nfs4_reset_session(struct nfs_client *clp) { return 0; }
 static int nfs4_end_drain_session(struct nfs_client *clp) { return 0; }
+static int nfs4_recall_slot(struct nfs_client *clp) { return 0; }
 #endif /* CONFIG_NFS_V4_1 */
 
 /* Set NFS4CLNT_LEASE_EXPIRED for all v4.0 errors and for recoverable errors
@@ -1398,6 +1433,15 @@ static void nfs4_state_manager(struct nfs_client *clp)
                        nfs_client_return_marked_delegations(clp);
                        continue;
                }
+               /* Recall session slots */
+               if (test_and_clear_bit(NFS4CLNT_RECALL_SLOT, &clp->cl_state)
+                  && nfs4_has_session(clp)) {
+                       status = nfs4_recall_slot(clp);
+                       if (status < 0)
+                               goto out_error;
+                       continue;
+               }
+
 
                nfs4_clear_state_manager_bit(clp);
                /* Did we race with an attempt to give us more work? */
index 34fc6be5bfcfd95d03534b59687564fe82071042..ecd9e6c74d06c3d46610cea4641b4fb5d296c97b 100644 (file)
@@ -193,6 +193,8 @@ struct nfs4_slot_table {
        int             max_slots;              /* # slots in table */
        int             highest_used_slotid;    /* sent to server on each SEQ.
                                                 * op for dynamic resizing */
+       int             target_max_slots;       /* Set by CB_RECALL_SLOT as
+                                                * the new max_slots */
 };
 
 static inline int slot_idx(struct nfs4_slot_table *tbl, struct nfs4_slot *sp)