Whamcloud - gitweb
LU-10467 lustre: use l_wait_event_abortable where appropriate.
[fs/lustre-release.git] / lustre / ptlrpc / nrs_delay.c
index fec9c2f..9c1b238 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"
@@ -252,12 +255,11 @@ 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);
@@ -790,7 +792,7 @@ 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,