Whamcloud - gitweb
LU-13004 ptlrpc: Allow BULK_BUF_KIOV to accept a kvec
[fs/lustre-release.git] / lustre / ptlrpc / nrs_orr.c
index c848cde..38e2d05 100644 (file)
@@ -20,7 +20,7 @@
  * GPL HEADER END
  */
 /*
- * Copyright (c) 2013, 2016, Intel Corporation.
+ * Copyright (c) 2013, 2017, Intel Corporation.
  *
  * Copyright 2012 Xyratex Technology Limited
  */
@@ -1160,11 +1160,9 @@ static void nrs_orr_req_stop(struct ptlrpc_nrs_policy *policy,
 }
 
 /**
- * lprocfs interface
+ * debugfs interface
  */
 
-#ifdef CONFIG_PROC_FS
-
 /**
  * This allows to bundle the policy name into the lprocfs_vars::data pointer
  * so that lprocfs read/write functions can be used by both the ORR and TRR
@@ -1309,8 +1307,9 @@ ptlrpc_lprocfs_nrs_orr_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;
        }
 
@@ -1325,7 +1324,9 @@ ptlrpc_lprocfs_nrs_orr_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;
        }
@@ -1335,10 +1336,9 @@ ptlrpc_lprocfs_nrs_orr_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;
 
@@ -1386,7 +1386,8 @@ ptlrpc_lprocfs_nrs_orr_quantum_seq_write(struct file *file,
 
        return rc == -ENODEV && rc2 == -ENODEV ? -ENODEV : count;
 }
-LPROC_SEQ_FOPS(ptlrpc_lprocfs_nrs_orr_quantum);
+
+LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_nrs_orr_quantum);
 
 #define LPROCFS_NRS_OFF_NAME_REG               "reg_offset_type:"
 #define LPROCFS_NRS_OFF_NAME_HP                        "hp_offset_type:"
@@ -1606,7 +1607,8 @@ ptlrpc_lprocfs_nrs_orr_offset_type_seq_write(struct file *file,
 
        return rc == -ENODEV && rc2 == -ENODEV ? -ENODEV : count;
 }
-LPROC_SEQ_FOPS(ptlrpc_lprocfs_nrs_orr_offset_type);
+
+LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_nrs_orr_offset_type);
 
 #define NRS_LPROCFS_REQ_SUPP_NAME_REG          "reg_supported:"
 #define NRS_LPROCFS_REQ_SUPP_NAME_HP           "hp_supported:"
@@ -1857,7 +1859,8 @@ ptlrpc_lprocfs_nrs_orr_supported_seq_write(struct file *file,
 
        return rc == -ENODEV && rc2 == -ENODEV ? -ENODEV : count;
 }
-LPROC_SEQ_FOPS(ptlrpc_lprocfs_nrs_orr_supported);
+
+LDEBUGFS_SEQ_FOPS(ptlrpc_lprocfs_nrs_orr_supported);
 
 static int nrs_orr_lprocfs_init(struct ptlrpc_service *svc)
 {
@@ -1873,7 +1876,7 @@ static int nrs_orr_lprocfs_init(struct ptlrpc_service *svc)
                { NULL }
        };
 
-       if (svc->srv_procroot == NULL)
+       if (!svc->srv_debugfs_entry)
                return 0;
 
        lprocfs_orr_data.svc = svc;
@@ -1881,21 +1884,10 @@ static int nrs_orr_lprocfs_init(struct ptlrpc_service *svc)
        for (i = 0; i < ARRAY_SIZE(nrs_orr_lprocfs_vars); i++)
                nrs_orr_lprocfs_vars[i].data = &lprocfs_orr_data;
 
-       return lprocfs_add_vars(svc->srv_procroot, nrs_orr_lprocfs_vars, NULL);
-}
-
-static void nrs_orr_lprocfs_fini(struct ptlrpc_service *svc)
-{
-       if (svc->srv_procroot == NULL)
-               return;
-
-       lprocfs_remove_proc_entry("nrs_orr_quantum", svc->srv_procroot);
-       lprocfs_remove_proc_entry("nrs_orr_offset_type", svc->srv_procroot);
-       lprocfs_remove_proc_entry("nrs_orr_supported", svc->srv_procroot);
+       return ldebugfs_add_vars(svc->srv_debugfs_entry, nrs_orr_lprocfs_vars,
+                                NULL);
 }
 
-#endif /* CONFIG_PROC_FS */
-
 static const struct ptlrpc_nrs_pol_ops nrs_orr_ops = {
        .op_policy_init         = nrs_orr_init,
        .op_policy_start        = nrs_orr_start,
@@ -1907,10 +1899,7 @@ static const struct ptlrpc_nrs_pol_ops nrs_orr_ops = {
        .op_req_enqueue         = nrs_orr_req_add,
        .op_req_dequeue         = nrs_orr_req_del,
        .op_req_stop            = nrs_orr_req_stop,
-#ifdef CONFIG_PROC_FS
        .op_lprocfs_init        = nrs_orr_lprocfs_init,
-       .op_lprocfs_fini        = nrs_orr_lprocfs_fini,
-#endif
 };
 
 struct ptlrpc_nrs_pol_conf nrs_conf_orr = {
@@ -1925,9 +1914,6 @@ struct ptlrpc_nrs_pol_conf nrs_conf_orr = {
  *
  * TRR reuses much of the functions and data structures of ORR
  */
-
-#ifdef CONFIG_PROC_FS
-
 static int nrs_trr_lprocfs_init(struct ptlrpc_service *svc)
 {
        int     i;
@@ -1942,7 +1928,7 @@ static int nrs_trr_lprocfs_init(struct ptlrpc_service *svc)
                { NULL }
        };
 
-       if (svc->srv_procroot == NULL)
+       if (!svc->srv_debugfs_entry)
                return 0;
 
        lprocfs_trr_data.svc = svc;
@@ -1950,21 +1936,10 @@ static int nrs_trr_lprocfs_init(struct ptlrpc_service *svc)
        for (i = 0; i < ARRAY_SIZE(nrs_trr_lprocfs_vars); i++)
                nrs_trr_lprocfs_vars[i].data = &lprocfs_trr_data;
 
-       return lprocfs_add_vars(svc->srv_procroot, nrs_trr_lprocfs_vars, NULL);
+       return ldebugfs_add_vars(svc->srv_debugfs_entry, nrs_trr_lprocfs_vars,
+                                NULL);
 }
 
-static void nrs_trr_lprocfs_fini(struct ptlrpc_service *svc)
-{
-       if (svc->srv_procroot == NULL)
-               return;
-
-       lprocfs_remove_proc_entry("nrs_trr_quantum", svc->srv_procroot);
-       lprocfs_remove_proc_entry("nrs_trr_offset_type", svc->srv_procroot);
-       lprocfs_remove_proc_entry("nrs_trr_supported", svc->srv_procroot);
-}
-
-#endif /* CONFIG_PROC_FS */
-
 /**
  * Reuse much of the ORR functionality for TRR.
  */
@@ -1979,10 +1954,7 @@ static const struct ptlrpc_nrs_pol_ops nrs_trr_ops = {
        .op_req_enqueue         = nrs_orr_req_add,
        .op_req_dequeue         = nrs_orr_req_del,
        .op_req_stop            = nrs_orr_req_stop,
-#ifdef CONFIG_PROC_FS
        .op_lprocfs_init        = nrs_trr_lprocfs_init,
-       .op_lprocfs_fini        = nrs_trr_lprocfs_fini,
-#endif
 };
 
 struct ptlrpc_nrs_pol_conf nrs_conf_trr = {