Whamcloud - gitweb
LU-14475 log: Rewrite some log messages
[fs/lustre-release.git] / lustre / ptlrpc / nrs_delay.c
index fec9c2f..a39a9cf 100644 (file)
@@ -39,6 +39,9 @@
  */
 
 #define DEBUG_SUBSYSTEM S_RPC
+
+#include <linux/random.h>
+
 #include <obd_support.h>
 #include <obd_class.h>
 #include "ptlrpc_internal.h"
@@ -73,8 +76,8 @@
  * \retval 0 start_time(e1) > start_time(e2)
  * \retval 1 start_time(e1) <= start_time(e2)
  */
-static int delay_req_compare(struct cfs_binheap_node *e1,
-                            struct cfs_binheap_node *e2)
+static int delay_req_compare(struct binheap_node *e1,
+                            struct binheap_node *e2)
 {
        struct ptlrpc_nrs_request *nrq1;
        struct ptlrpc_nrs_request *nrq2;
@@ -86,7 +89,7 @@ static int delay_req_compare(struct cfs_binheap_node *e1,
               nrq2->nr_u.delay.req_start_time;
 }
 
-static struct cfs_binheap_ops nrs_delay_heap_ops = {
+static struct binheap_ops nrs_delay_heap_ops = {
        .hop_enter      = NULL,
        .hop_exit       = NULL,
        .hop_compare    = delay_req_compare,
@@ -117,7 +120,7 @@ static int nrs_delay_start(struct ptlrpc_nrs_policy *policy, char *arg)
        if (delay_data == NULL)
                RETURN(-ENOMEM);
 
-       delay_data->delay_binheap = cfs_binheap_create(&nrs_delay_heap_ops,
+       delay_data->delay_binheap = binheap_create(&nrs_delay_heap_ops,
                                                       CBH_FLAG_ATOMIC_GROW,
                                                       4096, NULL,
                                                       nrs_pol2cptab(policy),
@@ -152,9 +155,9 @@ static void nrs_delay_stop(struct ptlrpc_nrs_policy *policy)
 
        LASSERT(delay_data != NULL);
        LASSERT(delay_data->delay_binheap != NULL);
-       LASSERT(cfs_binheap_is_empty(delay_data->delay_binheap));
+       LASSERT(binheap_is_empty(delay_data->delay_binheap));
 
-       cfs_binheap_destroy(delay_data->delay_binheap);
+       binheap_destroy(delay_data->delay_binheap);
 
        OBD_FREE_PTR(delay_data);
 }
@@ -209,10 +212,10 @@ struct ptlrpc_nrs_request *nrs_delay_req_get(struct ptlrpc_nrs_policy *policy,
                                             bool peek, bool force)
 {
        struct nrs_delay_data *delay_data = policy->pol_private;
-       struct cfs_binheap_node *node;
+       struct binheap_node *node;
        struct ptlrpc_nrs_request *nrq;
 
-       node = cfs_binheap_root(delay_data->delay_binheap);
+       node = binheap_root(delay_data->delay_binheap);
        nrq = unlikely(node == NULL) ? NULL :
              container_of(node, struct ptlrpc_nrs_request, nr_node);
 
@@ -221,7 +224,7 @@ struct ptlrpc_nrs_request *nrs_delay_req_get(struct ptlrpc_nrs_policy *policy,
                    ktime_get_real_seconds() < nrq->nr_u.delay.req_start_time)
                        nrq = NULL;
                else if (likely(!peek))
-                       cfs_binheap_remove(delay_data->delay_binheap,
+                       binheap_remove(delay_data->delay_binheap,
                                           &nrq->nr_node);
        }
 
@@ -252,15 +255,14 @@ static int nrs_delay_req_add(struct ptlrpc_nrs_policy *policy,
 
        if (delay_data->delay_pct == 0 || /* Not delaying anything */
            (delay_data->delay_pct != 100 &&
-            delay_data->delay_pct < cfs_rand() % 100))
+            delay_data->delay_pct < prandom_u32_max(100)))
                return 1;
 
-       nrq->nr_u.delay.req_start_time = ktime_get_real_seconds() + cfs_rand() %
-                                        (delay_data->max_delay -
-                                         delay_data->min_delay + 1) +
+       nrq->nr_u.delay.req_start_time = ktime_get_real_seconds() +
+                                        prandom_u32_max(delay_data->max_delay - delay_data->min_delay + 1) +
                                         delay_data->min_delay;
 
-       return cfs_binheap_insert(delay_data->delay_binheap, &nrq->nr_node);
+       return binheap_insert(delay_data->delay_binheap, &nrq->nr_node);
 }
 
 /**
@@ -274,7 +276,7 @@ static void nrs_delay_req_del(struct ptlrpc_nrs_policy *policy,
 {
        struct nrs_delay_data *delay_data = policy->pol_private;
 
-       cfs_binheap_remove(delay_data->delay_binheap, &nrq->nr_node);
+       binheap_remove(delay_data->delay_binheap, &nrq->nr_node);
 }
 
 /**
@@ -777,7 +779,7 @@ LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_nrs_delay_pct);
 
 static int nrs_delay_lprocfs_init(struct ptlrpc_service *svc)
 {
-       struct lprocfs_vars nrs_delay_lprocfs_vars[] = {
+       struct ldebugfs_vars nrs_delay_lprocfs_vars[] = {
                { .name         = "nrs_delay_min",
                  .fops         = &ptlrpc_lprocfs_nrs_delay_min_fops,
                  .data         = svc },
@@ -790,11 +792,12 @@ static int nrs_delay_lprocfs_init(struct ptlrpc_service *svc)
                { NULL }
        };
 
-       if (IS_ERR_OR_NULL(svc->srv_debugfs_entry))
+       if (!svc->srv_debugfs_entry)
                return 0;
 
-       return ldebugfs_add_vars(svc->srv_debugfs_entry, nrs_delay_lprocfs_vars,
-                                NULL);
+       ldebugfs_add_vars(svc->srv_debugfs_entry, nrs_delay_lprocfs_vars, NULL);
+
+       return 0;
 }
 
 /**