X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fptlrpc%2Fnrs_orr.c;h=a81609a3f084d934f0d7d08b98954c3298a73c1b;hb=7648c1c905b0976fc789cfd9c6bac382389385ee;hp=74578c5064b84f70e4b0f8c3cd862088161d1cc6;hpb=46af0e8dd04d01679865704e06c1037e4f30f1a3;p=fs%2Flustre-release.git diff --git a/lustre/ptlrpc/nrs_orr.c b/lustre/ptlrpc/nrs_orr.c index 74578c5..a81609a 100644 --- a/lustre/ptlrpc/nrs_orr.c +++ b/lustre/ptlrpc/nrs_orr.c @@ -20,7 +20,7 @@ * GPL HEADER END */ /* - * Copyright (c) 2013, 2014, Intel Corporation. + * Copyright (c) 2013, 2017, Intel Corporation. * * Copyright 2012 Xyratex Technology Limited */ @@ -35,7 +35,6 @@ * Author: Liang Zhen * Author: Nikitas Angelinas */ -#ifdef HAVE_SERVER_SUPPORT /** * \addtogoup nrs @@ -45,7 +44,6 @@ #include #include #include -#include #include #include "ptlrpc_internal.h" @@ -232,18 +230,18 @@ static int nrs_orr_range_fill_physical(struct ptlrpc_nrs_request *nrq, struct ptlrpc_request *req = container_of(nrq, struct ptlrpc_request, rq_nrq); - char fiemap_buf[offsetof(struct ll_user_fiemap, + char fiemap_buf[offsetof(struct fiemap, fm_extents[ORR_NUM_EXTENTS])]; - struct ll_user_fiemap *fiemap = (struct ll_user_fiemap *)fiemap_buf; + struct fiemap *fiemap = (struct fiemap *)fiemap_buf; struct ll_fiemap_info_key key; loff_t start; loff_t end; int rc; key = (typeof(key)) { - .name = KEY_FIEMAP, - .oa = *oa, - .fiemap = { + .lfik_name = KEY_FIEMAP, + .lfik_oa = *oa, + .lfik_fiemap = { .fm_start = range->or_start, .fm_length = range->or_end - range->or_start, .fm_extent_count = ORR_NUM_EXTENTS @@ -388,7 +386,8 @@ static void nrs_orr_genobjname(struct ptlrpc_nrs_policy *policy, char *name) #define NRS_TRR_BKT_BITS 2 #define NRS_TRR_HASH_FLAGS CFS_HASH_SPIN_BKTLOCK -static unsigned nrs_orr_hop_hash(cfs_hash_t *hs, const void *key, unsigned mask) +static unsigned +nrs_orr_hop_hash(struct cfs_hash *hs, const void *key, unsigned mask) { return cfs_hash_djb2_hash(key, sizeof(struct nrs_orr_key), mask); } @@ -416,7 +415,7 @@ static void *nrs_orr_hop_object(struct hlist_node *hnode) return hlist_entry(hnode, struct nrs_orr_object, oo_hnode); } -static void nrs_orr_hop_get(cfs_hash_t *hs, struct hlist_node *hnode) +static void nrs_orr_hop_get(struct cfs_hash *hs, struct hlist_node *hnode) { struct nrs_orr_object *orro = hlist_entry(hnode, struct nrs_orr_object, @@ -428,14 +427,14 @@ static void nrs_orr_hop_get(cfs_hash_t *hs, struct hlist_node *hnode) * Removes an nrs_orr_object the hash and frees its memory, if the object has * no active users. */ -static void nrs_orr_hop_put_free(cfs_hash_t *hs, struct hlist_node *hnode) +static void nrs_orr_hop_put_free(struct cfs_hash *hs, struct hlist_node *hnode) { struct nrs_orr_object *orro = hlist_entry(hnode, struct nrs_orr_object, oo_hnode); struct nrs_orr_data *orrd = container_of(orro->oo_res.res_parent, struct nrs_orr_data, od_res); - cfs_hash_bd_t bd; + struct cfs_hash_bd bd; cfs_hash_bd_get_and_lock(hs, &orro->oo_key, &bd, 1); @@ -452,7 +451,7 @@ static void nrs_orr_hop_put_free(cfs_hash_t *hs, struct hlist_node *hnode) OBD_SLAB_FREE_PTR(orro, orrd->od_cache); } -static void nrs_orr_hop_put(cfs_hash_t *hs, struct hlist_node *hnode) +static void nrs_orr_hop_put(struct cfs_hash *hs, struct hlist_node *hnode) { struct nrs_orr_object *orro = hlist_entry(hnode, struct nrs_orr_object, @@ -469,7 +468,7 @@ static int nrs_trr_hop_keycmp(const void *key, struct hlist_node *hnode) return orro->oo_key.ok_idx == ((struct nrs_orr_key *)key)->ok_idx; } -static void nrs_trr_hop_exit(cfs_hash_t *hs, struct hlist_node *hnode) +static void nrs_trr_hop_exit(struct cfs_hash *hs, struct hlist_node *hnode) { struct nrs_orr_object *orro = hlist_entry(hnode, struct nrs_orr_object, @@ -484,7 +483,7 @@ static void nrs_trr_hop_exit(cfs_hash_t *hs, struct hlist_node *hnode) OBD_SLAB_FREE_PTR(orro, orrd->od_cache); } -static cfs_hash_ops_t nrs_orr_hash_ops = { +static struct cfs_hash_ops nrs_orr_hash_ops = { .hs_hash = nrs_orr_hop_hash, .hs_key = nrs_orr_hop_key, .hs_keycmp = nrs_orr_hop_keycmp, @@ -494,7 +493,7 @@ static cfs_hash_ops_t nrs_orr_hash_ops = { .hs_put_locked = nrs_orr_hop_put, }; -static cfs_hash_ops_t nrs_trr_hash_ops = { +static struct cfs_hash_ops nrs_trr_hash_ops = { .hs_hash = nrs_orr_hop_hash, .hs_key = nrs_orr_hop_key, .hs_keycmp = nrs_trr_hop_keycmp, @@ -523,7 +522,8 @@ static cfs_hash_ops_t nrs_trr_hash_ops = { * \retval 0 e1 > e2 * \retval 1 e1 < e2 */ -static int orr_req_compare(cfs_binheap_node_t *e1, cfs_binheap_node_t *e2) +static int +orr_req_compare(struct binheap_node *e1, struct binheap_node *e2) { struct ptlrpc_nrs_request *nrq1; struct ptlrpc_nrs_request *nrq2; @@ -578,7 +578,7 @@ static int orr_req_compare(cfs_binheap_node_t *e1, cfs_binheap_node_t *e2) /** * ORR binary heap operations */ -static cfs_binheap_ops_t nrs_orr_heap_ops = { +static struct binheap_ops nrs_orr_heap_ops = { .hop_enter = NULL, .hop_exit = NULL, .hop_compare = orr_req_compare, @@ -616,7 +616,7 @@ static int nrs_orr_init(struct ptlrpc_nrs_policy *policy) static int nrs_orr_start(struct ptlrpc_nrs_policy *policy, char *arg) { struct nrs_orr_data *orrd; - cfs_hash_ops_t *ops; + struct cfs_hash_ops *ops; unsigned cur_bits; unsigned max_bits; unsigned bkt_bits; @@ -631,12 +631,12 @@ static int nrs_orr_start(struct ptlrpc_nrs_policy *policy, char *arg) /* * Binary heap instance for sorted incoming requests. */ - orrd->od_binheap = cfs_binheap_create(&nrs_orr_heap_ops, + orrd->od_binheap = binheap_create(&nrs_orr_heap_ops, CBH_FLAG_ATOMIC_GROW, 4096, NULL, 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); @@ -647,7 +647,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) { @@ -675,7 +675,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; @@ -691,14 +691,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); - LASSERTF(rc == 0, "Could not destroy od_cache slab\n"); - } - if (orrd->od_binheap != NULL) - cfs_binheap_destroy(orrd->od_binheap); - +out_cache: + kmem_cache_destroy(orrd->od_cache); +out_binheap: + binheap_destroy(orrd->od_binheap); +out_orrd: OBD_FREE_PTR(orrd); RETURN(rc); @@ -722,9 +719,9 @@ static void nrs_orr_stop(struct ptlrpc_nrs_policy *policy) LASSERT(orrd->od_binheap != NULL); LASSERT(orrd->od_obj_hash != NULL); LASSERT(orrd->od_cache != NULL); - LASSERT(cfs_binheap_is_empty(orrd->od_binheap)); + LASSERT(binheap_is_empty(orrd->od_binheap)); - cfs_binheap_destroy(orrd->od_binheap); + binheap_destroy(orrd->od_binheap); cfs_hash_putref(orrd->od_obj_hash); kmem_cache_destroy(orrd->od_cache); @@ -945,7 +942,7 @@ struct ptlrpc_nrs_request *nrs_orr_req_get(struct ptlrpc_nrs_policy *policy, bool peek, bool force) { struct nrs_orr_data *orrd = policy->pol_private; - cfs_binheap_node_t *node = cfs_binheap_root(orrd->od_binheap); + struct binheap_node *node = binheap_root(orrd->od_binheap); struct ptlrpc_nrs_request *nrq; nrq = unlikely(node == NULL) ? NULL : @@ -959,7 +956,7 @@ struct ptlrpc_nrs_request *nrs_orr_req_get(struct ptlrpc_nrs_policy *policy, LASSERT(nrq->nr_u.orr.or_round <= orro->oo_round); - cfs_binheap_remove(orrd->od_binheap, &nrq->nr_node); + binheap_remove(orrd->od_binheap, &nrq->nr_node); orro->oo_active--; if (strncmp(policy->pol_desc->pd_name, NRS_POL_NAME_ORR, @@ -967,19 +964,19 @@ struct ptlrpc_nrs_request *nrs_orr_req_get(struct ptlrpc_nrs_policy *policy, CDEBUG(D_RPCTRACE, "NRS: starting to handle %s request for object " "with FID "DFID", from OST with index %u, with " - "round "LPU64"\n", NRS_POL_NAME_ORR, + "round %llu\n", NRS_POL_NAME_ORR, PFID(&orro->oo_key.ok_fid), nrq->nr_u.orr.or_key.ok_idx, nrq->nr_u.orr.or_round); else CDEBUG(D_RPCTRACE, "NRS: starting to handle %s request from OST " - "with index %u, with round "LPU64"\n", + "with index %u, with round %llu\n", NRS_POL_NAME_TRR, nrq->nr_u.orr.or_key.ok_idx, nrq->nr_u.orr.or_round); /** Peek at the next request to be served */ - node = cfs_binheap_root(orrd->od_binheap); + node = binheap_root(orrd->od_binheap); /** No more requests */ if (unlikely(node == NULL)) { @@ -1079,7 +1076,7 @@ static int nrs_orr_req_add(struct ptlrpc_nrs_policy *policy, nrq->nr_u.orr.or_round = orro->oo_round; nrq->nr_u.orr.or_sequence = orro->oo_sequence; - rc = cfs_binheap_insert(orrd->od_binheap, &nrq->nr_node); + rc = binheap_insert(orrd->od_binheap, &nrq->nr_node); if (rc == 0) { orro->oo_active++; if (--orro->oo_quantum == 0) @@ -1109,9 +1106,9 @@ static void nrs_orr_req_del(struct ptlrpc_nrs_policy *policy, LASSERT(nrq->nr_u.orr.or_round <= orro->oo_round); - is_root = &nrq->nr_node == cfs_binheap_root(orrd->od_binheap); + is_root = &nrq->nr_node == binheap_root(orrd->od_binheap); - cfs_binheap_remove(orrd->od_binheap, &nrq->nr_node); + binheap_remove(orrd->od_binheap, &nrq->nr_node); orro->oo_active--; /** @@ -1120,7 +1117,7 @@ static void nrs_orr_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(orrd->od_binheap); + struct binheap_node *node = binheap_root(orrd->od_binheap); /** No more requests */ if (unlikely(node == NULL)) { @@ -1150,23 +1147,21 @@ static void nrs_orr_req_stop(struct ptlrpc_nrs_policy *policy, NRS_POL_NAME_MAX) == 0) CDEBUG(D_RPCTRACE, "NRS: finished handling %s request for object with FID " - DFID", from OST with index %u, with round "LPU64"\n", + DFID", from OST with index %u, with round %llu\n", NRS_POL_NAME_ORR, PFID(&nrq->nr_u.orr.or_key.ok_fid), nrq->nr_u.orr.or_key.ok_idx, nrq->nr_u.orr.or_round); else CDEBUG(D_RPCTRACE, "NRS: finished handling %s request from OST with index %u," - " with round "LPU64"\n", + " with round %llu\n", NRS_POL_NAME_TRR, nrq->nr_u.orr.or_key.ok_idx, nrq->nr_u.orr.or_round); } /** - * 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 @@ -1278,7 +1273,8 @@ no_hp: * almost identical; it can be reworked and then reused for ORR/TRR. */ static ssize_t -ptlrpc_lprocfs_nrs_orr_quantum_seq_write(struct file *file, const char *buffer, +ptlrpc_lprocfs_nrs_orr_quantum_seq_write(struct file *file, + const char __user *buffer, size_t count, loff_t *off) { struct seq_file *m = file->private_data; @@ -1310,8 +1306,9 @@ ptlrpc_lprocfs_nrs_orr_quantum_seq_write(struct file *file, const char *buffer, 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; } @@ -1326,7 +1323,9 @@ ptlrpc_lprocfs_nrs_orr_quantum_seq_write(struct file *file, const char *buffer, 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; } @@ -1336,10 +1335,9 @@ ptlrpc_lprocfs_nrs_orr_quantum_seq_write(struct file *file, const char *buffer, * 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; @@ -1387,7 +1385,8 @@ ptlrpc_lprocfs_nrs_orr_quantum_seq_write(struct file *file, const char *buffer, 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:" @@ -1492,7 +1491,8 @@ no_hp: */ static ssize_t ptlrpc_lprocfs_nrs_orr_offset_type_seq_write(struct file *file, - const char *buffer, size_t count, + const char __user *buffer, + size_t count, loff_t *off) { struct seq_file *m = file->private_data; @@ -1606,7 +1606,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:" @@ -1751,7 +1752,8 @@ no_hp: */ static ssize_t ptlrpc_lprocfs_nrs_orr_supported_seq_write(struct file *file, - const char *buffer, size_t count, + const char __user *buffer, + size_t count, loff_t *off) { struct seq_file *m = file->private_data; @@ -1856,13 +1858,14 @@ 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) { int i; - struct lprocfs_vars nrs_orr_lprocfs_vars[] = { + struct ldebugfs_vars nrs_orr_lprocfs_vars[] = { { .name = "nrs_orr_quantum", .fops = &ptlrpc_lprocfs_nrs_orr_quantum_fops }, { .name = "nrs_orr_offset_type", @@ -1872,7 +1875,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; @@ -1880,21 +1883,11 @@ 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); -} + 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); + return 0; } -#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, @@ -1906,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 = { @@ -1924,14 +1914,11 @@ 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; - struct lprocfs_vars nrs_trr_lprocfs_vars[] = { + struct ldebugfs_vars nrs_trr_lprocfs_vars[] = { { .name = "nrs_trr_quantum", .fops = &ptlrpc_lprocfs_nrs_orr_quantum_fops }, { .name = "nrs_trr_offset_type", @@ -1941,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; @@ -1949,21 +1936,11 @@ 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); -} - -static void nrs_trr_lprocfs_fini(struct ptlrpc_service *svc) -{ - if (svc->srv_procroot == NULL) - return; + ldebugfs_add_vars(svc->srv_debugfs_entry, nrs_trr_lprocfs_vars, NULL); - 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); + return 0; } -#endif /* CONFIG_PROC_FS */ - /** * Reuse much of the ORR functionality for TRR. */ @@ -1978,10 +1955,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 = { @@ -1994,5 +1968,3 @@ struct ptlrpc_nrs_pol_conf nrs_conf_trr = { /** @} ORR/TRR policy */ /** @} nrs */ - -#endif /* HAVE_SERVER_SUPPORT */