X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fptlrpc%2Fnrs_orr.c;h=38e2d05adb67c7e718c83141bed8dab75f692712;hb=2519bc95aabb31945d423ce95f5f840280c4adde;hp=9580c6de521ad1a43a90671daebb1dba5ee30cc6;hpb=500f334631c6ebec72f5791472f21603da3e0ef9;p=fs%2Flustre-release.git diff --git a/lustre/ptlrpc/nrs_orr.c b/lustre/ptlrpc/nrs_orr.c index 9580c6d..38e2d05 100644 --- a/lustre/ptlrpc/nrs_orr.c +++ b/lustre/ptlrpc/nrs_orr.c @@ -20,7 +20,7 @@ * GPL HEADER END */ /* - * Copyright (c) 2013, 2015, Intel Corporation. + * Copyright (c) 2013, 2017, Intel Corporation. * * Copyright 2012 Xyratex Technology Limited */ @@ -45,7 +45,6 @@ #include #include #include -#include #include #include "ptlrpc_internal.h" @@ -638,7 +637,7 @@ static int nrs_orr_start(struct ptlrpc_nrs_policy *policy, char *arg) nrs_pol2cptab(policy), nrs_pol2cptid(policy)); if (orrd->od_binheap == NULL) - GOTO(failed, rc = -ENOMEM); + GOTO(out_orrd, rc = -ENOMEM); nrs_orr_genobjname(policy, orrd->od_objname); @@ -649,7 +648,7 @@ static int nrs_orr_start(struct ptlrpc_nrs_policy *policy, char *arg) sizeof(struct nrs_orr_object), 0, 0, NULL); if (orrd->od_cache == NULL) - GOTO(failed, rc = -ENOMEM); + GOTO(out_binheap, rc = -ENOMEM); if (strncmp(policy->pol_desc->pd_name, NRS_POL_NAME_ORR, NRS_POL_NAME_MAX) == 0) { @@ -677,7 +676,7 @@ static int nrs_orr_start(struct ptlrpc_nrs_policy *policy, char *arg) CFS_HASH_MIN_THETA, CFS_HASH_MAX_THETA, ops, flags); if (orrd->od_obj_hash == NULL) - GOTO(failed, rc = -ENOMEM); + GOTO(out_cache, rc = -ENOMEM); /* XXX: Fields accessed unlocked */ orrd->od_quantum = NRS_ORR_QUANTUM_DFLT; @@ -693,12 +692,11 @@ static int nrs_orr_start(struct ptlrpc_nrs_policy *policy, char *arg) RETURN(rc); -failed: - if (orrd->od_cache) - kmem_cache_destroy(orrd->od_cache); - if (orrd->od_binheap != NULL) - cfs_binheap_destroy(orrd->od_binheap); - +out_cache: + kmem_cache_destroy(orrd->od_cache); +out_binheap: + cfs_binheap_destroy(orrd->od_binheap); +out_orrd: OBD_FREE_PTR(orrd); RETURN(rc); @@ -1162,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 @@ -1311,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; } @@ -1327,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; } @@ -1337,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; @@ -1388,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:" @@ -1608,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:" @@ -1859,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) { @@ -1875,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; @@ -1883,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); + return ldebugfs_add_vars(svc->srv_debugfs_entry, 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); -} - -#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, @@ -1909,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 = { @@ -1927,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; @@ -1944,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; @@ -1952,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. */ @@ -1981,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 = {