Whamcloud - gitweb
LU-11564 tests: add version check sanity-hsm tests
[fs/lustre-release.git] / lustre / ptlrpc / nrs_crr.c
index 96be3b7..31a0629 100644 (file)
@@ -20,7 +20,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2011, 2014, Intel Corporation.
+ * Copyright (c) 2013, 2017, Intel Corporation.
  *
  * Copyright 2012 Xyratex Technology Limited
  */
@@ -72,7 +72,8 @@
  * \retval 0 e1 > e2
  * \retval 1 e1 <= e2
  */
-static int crrn_req_compare(cfs_binheap_node_t *e1, cfs_binheap_node_t *e2)
+static int
+crrn_req_compare(struct cfs_binheap_node *e1, struct cfs_binheap_node *e2)
 {
        struct ptlrpc_nrs_request *nrq1;
        struct ptlrpc_nrs_request *nrq2;
@@ -88,7 +89,7 @@ static int crrn_req_compare(cfs_binheap_node_t *e1, cfs_binheap_node_t *e2)
        return nrq1->nr_u.crr.cr_sequence < nrq2->nr_u.crr.cr_sequence;
 }
 
-static cfs_binheap_ops_t nrs_crrn_heap_ops = {
+static struct cfs_binheap_ops nrs_crrn_heap_ops = {
        .hop_enter      = NULL,
        .hop_exit       = NULL,
        .hop_compare    = crrn_req_compare,
@@ -193,7 +194,7 @@ static int nrs_crrn_start(struct ptlrpc_nrs_policy *policy, char *arg)
                                             nrs_pol2cptab(policy),
                                             nrs_pol2cptid(policy));
        if (net->cn_binheap == NULL)
-               GOTO(failed, rc = -ENOMEM);
+               GOTO(out_net, rc = -ENOMEM);
 
        net->cn_cli_hash = cfs_hash_create("nrs_crrn_nid_hash",
                                           NRS_NID_BITS, NRS_NID_BITS,
@@ -203,7 +204,7 @@ static int nrs_crrn_start(struct ptlrpc_nrs_policy *policy, char *arg)
                                           &nrs_crrn_hash_ops,
                                           CFS_HASH_RW_BKTLOCK);
        if (net->cn_cli_hash == NULL)
-               GOTO(failed, rc = -ENOMEM);
+               GOTO(out_binheap, rc = -ENOMEM);
 
        /**
         * Set default quantum value to max_rpcs_in_flight for non-MDS OSCs;
@@ -222,10 +223,9 @@ static int nrs_crrn_start(struct ptlrpc_nrs_policy *policy, char *arg)
 
        RETURN(rc);
 
-failed:
-       if (net->cn_binheap != NULL)
-               cfs_binheap_destroy(net->cn_binheap);
-
+out_binheap:
+       cfs_binheap_destroy(net->cn_binheap);
+out_net:
        OBD_FREE_PTR(net);
 
        RETURN(rc);
@@ -414,7 +414,7 @@ struct ptlrpc_nrs_request *nrs_crrn_req_get(struct ptlrpc_nrs_policy *policy,
                                            bool peek, bool force)
 {
        struct nrs_crrn_net       *net = policy->pol_private;
-       cfs_binheap_node_t        *node = cfs_binheap_root(net->cn_binheap);
+       struct cfs_binheap_node   *node = cfs_binheap_root(net->cn_binheap);
        struct ptlrpc_nrs_request *nrq;
 
        nrq = unlikely(node == NULL) ? NULL :
@@ -436,7 +436,7 @@ struct ptlrpc_nrs_request *nrs_crrn_req_get(struct ptlrpc_nrs_policy *policy,
 
                CDEBUG(D_RPCTRACE,
                       "NRS: starting to handle %s request from %s, with round "
-                      LPU64"\n", NRS_POL_NAME_CRRN,
+                      "%llu\n", NRS_POL_NAME_CRRN,
                       libcfs_id2str(req->rq_peer), nrq->nr_u.crr.cr_round);
 
                /** Peek at the next request to be served */
@@ -576,7 +576,7 @@ static void nrs_crrn_req_del(struct ptlrpc_nrs_policy *policy,
         */
        if (unlikely(is_root)) {
                /** Peek at the next request to be served */
-               cfs_binheap_node_t *node = cfs_binheap_root(net->cn_binheap);
+               struct cfs_binheap_node *node = cfs_binheap_root(net->cn_binheap);
 
                /** No more requests */
                if (unlikely(node == NULL)) {
@@ -605,15 +605,13 @@ static void nrs_crrn_req_stop(struct ptlrpc_nrs_policy *policy,
                                                  rq_nrq);
 
        CDEBUG(D_RPCTRACE,
-              "NRS: finished handling %s request from %s, with round "LPU64
+              "NRS: finished handling %s request from %s, with round %llu"
               "\n", NRS_POL_NAME_CRRN,
               libcfs_id2str(req->rq_peer), nrq->nr_u.crr.cr_round);
 }
 
-#ifdef CONFIG_PROC_FS
-
 /**
- * lprocfs interface
+ * debugfs interface
  */
 
 /**
@@ -731,7 +729,9 @@ ptlrpc_lprocfs_nrs_crrn_quantum_seq_write(struct file *file,
        val = lprocfs_find_named_value(kernbuf, NRS_LPROCFS_QUANTUM_NAME_REG,
                                       &count_copy);
        if (val != kernbuf) {
-               quantum_reg = simple_strtol(val, NULL, 10);
+               rc = kstrtol(val, 10, &quantum_reg);
+               if (rc)
+                       return rc;
 
                queue |= PTLRPC_NRS_QUEUE_REG;
        }
@@ -747,7 +747,9 @@ ptlrpc_lprocfs_nrs_crrn_quantum_seq_write(struct file *file,
                if (!nrs_svc_has_hp(svc))
                        return -ENODEV;
 
-               quantum_hp = simple_strtol(val, NULL, 10);
+               rc = kstrtol(val, 10, &quantum_hp);
+               if (rc)
+                       return rc;
 
                queue |= PTLRPC_NRS_QUEUE_HP;
        }
@@ -757,10 +759,9 @@ ptlrpc_lprocfs_nrs_crrn_quantum_seq_write(struct file *file,
         * value
         */
        if (queue == 0) {
-               if (!isdigit(kernbuf[0]))
-                       return -EINVAL;
-
-               quantum_reg = simple_strtol(kernbuf, NULL, 10);
+               rc = kstrtol(kernbuf, 10, &quantum_reg);
+               if (rc)
+                       return rc;
 
                queue = PTLRPC_NRS_QUEUE_REG;
 
@@ -808,7 +809,8 @@ ptlrpc_lprocfs_nrs_crrn_quantum_seq_write(struct file *file,
 
        return rc == -ENODEV && rc2 == -ENODEV ? -ENODEV : count;
 }
-LPROC_SEQ_FOPS(ptlrpc_lprocfs_nrs_crrn_quantum);
+
+LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_nrs_crrn_quantum);
 
 /**
  * Initializes a CRR-N policy's lprocfs interface for service \a svc
@@ -827,28 +829,13 @@ static int nrs_crrn_lprocfs_init(struct ptlrpc_service *svc)
                { NULL }
        };
 
-       if (svc->srv_procroot == NULL)
+       if (IS_ERR_OR_NULL(svc->srv_debugfs_entry))
                return 0;
 
-       return lprocfs_add_vars(svc->srv_procroot, nrs_crrn_lprocfs_vars, NULL);
+       return ldebugfs_add_vars(svc->srv_debugfs_entry, nrs_crrn_lprocfs_vars, NULL);
 }
 
 /**
- * Cleans up a CRR-N policy's lprocfs interface for service \a svc
- *
- * \param[in] svc the service
- */
-static void nrs_crrn_lprocfs_fini(struct ptlrpc_service *svc)
-{
-       if (svc->srv_procroot == NULL)
-               return;
-
-       lprocfs_remove_proc_entry("nrs_crrn_quantum", svc->srv_procroot);
-}
-
-#endif /* CONFIG_PROC_FS */
-
-/**
  * CRR-N policy operations
  */
 static const struct ptlrpc_nrs_pol_ops nrs_crrn_ops = {
@@ -861,10 +848,7 @@ static const struct ptlrpc_nrs_pol_ops nrs_crrn_ops = {
        .op_req_enqueue         = nrs_crrn_req_add,
        .op_req_dequeue         = nrs_crrn_req_del,
        .op_req_stop            = nrs_crrn_req_stop,
-#ifdef CONFIG_PROC_FS
        .op_lprocfs_init        = nrs_crrn_lprocfs_init,
-       .op_lprocfs_fini        = nrs_crrn_lprocfs_fini,
-#endif
 };
 
 /**