4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License version 2 for more details.
15 * You should have received a copy of the GNU General Public License
16 * version 2 along with this program; If not, see
17 * http://www.gnu.org/licenses/gpl-2.0.html
22 * Copyright (c) 2014, Intel Corporation.
24 * Copyright 2012 Xyratex Technology Limited
28 * Network Request Scheduler (NRS) Object-based Round Robin and Target-based
29 * Round Robin (ORR and TRR) policies
33 #ifndef _LUSTRE_NRS_ORR_H
34 #define _LUSTRE_NRS_ORR_H
36 #ifdef HAVE_XARRAY_SUPPORT
37 #include <linux/xarray.h>
39 #include <libcfs/linux/xarray.h>
43 * ORR policy operations
45 #define NRS_CTL_ORR_RD_QUANTUM PTLRPC_NRS_CTL_POL_SPEC_01
46 #define NRS_CTL_ORR_WR_QUANTUM PTLRPC_NRS_CTL_POL_SPEC_02
47 #define NRS_CTL_ORR_RD_OFF_TYPE PTLRPC_NRS_CTL_POL_SPEC_03
48 #define NRS_CTL_ORR_WR_OFF_TYPE PTLRPC_NRS_CTL_POL_SPEC_04
49 #define NRS_CTL_ORR_RD_SUPP_REQ PTLRPC_NRS_CTL_POL_SPEC_05
50 #define NRS_CTL_ORR_WR_SUPP_REQ PTLRPC_NRS_CTL_POL_SPEC_06
55 * ORR/TRR (Object-based Round Robin/Target-based Round Robin) NRS policies
60 * Lower and upper byte offsets of a brw RPC
62 struct nrs_orr_req_range {
68 * RPC types supported by the ORR/TRR policies
71 NOS_OST_READ = BIT(0),
72 NOS_OST_WRITE = BIT(1),
73 NOS_OST_RW = (NOS_OST_READ | NOS_OST_WRITE),
75 * Default value for policies.
77 NOS_DFLT = NOS_OST_READ
81 * As unique keys for grouping RPCs together, we use the object's OST FID for
82 * the ORR policy, and the OST index for the TRR policy.
84 * XXX: We waste some space for TRR policy instances by using a union, but it
85 * allows to consolidate some of the code between ORR and TRR, and these
86 * policies will probably eventually merge into one anyway.
90 /** object FID for ORR */
92 /** OST index for TRR */
98 * The largest base string for unique hash/slab object names is
99 * "nrs_orr_reg_", so 13 characters. We add 3 to this to be used for the CPT
100 * id number, so this _should_ be more than enough for the maximum number of
101 * CPTs on any system. If it does happen that this statement is incorrect,
102 * nrs_orr_genobjname() will inevitably yield a non-unique name and cause
103 * kmem_cache_create() to complain (on Linux), so the erroneous situation
104 * will hopefully not go unnoticed.
106 #define NRS_ORR_OBJ_NAME_MAX (sizeof("nrs_orr_reg_") + 3)
109 * private data structure for ORR and TRR NRS
111 struct nrs_orr_data {
112 struct ptlrpc_nrs_resource od_res;
113 struct binheap *od_binheap;
114 struct rhashtable od_obj_hash;
115 struct xarray od_trr_objs;
116 struct kmem_cache *od_cache;
118 * Used when a new scheduling round commences, in order to synchronize
119 * all object or OST batches with the new round number.
123 * Determines the relevant ordering amongst request batches within a
128 * RPC types that are currently supported.
130 enum nrs_orr_supp od_supp;
132 * Round Robin quantum; the maxium number of RPCs that each request
133 * batch for each object or OST can have in a scheduling round.
137 * Whether to use physical disk offsets or logical file offsets.
141 * XXX: We need to provide a persistently allocated string to hold
142 * unique object names for this policy, since in currently supported
143 * versions of Linux by Lustre, kmem_cache_create() just sets a pointer
144 * to the name string provided. kstrdup() is used in the version of
145 * kmeme_cache_create() in current Linux mainline, so we may be able to
146 * remove this in the future.
148 char od_objname[NRS_ORR_OBJ_NAME_MAX];
152 * Represents a backend-fs object or OST in the ORR and TRR policies
155 struct nrs_orr_object {
156 struct ptlrpc_nrs_resource oo_res;
157 struct rhash_head oo_rhead;
159 * The round number against which requests are being scheduled for this
164 * The sequence number used for requests scheduled for this object or
165 * OST during the current round number.
169 * The key of the object or OST for which this structure
170 * instance is scheduling RPCs
172 struct nrs_orr_key oo_key;
174 * The reference count of this object. Once it hits zero free
175 * it from the hash table.
179 * Round Robin quantum; the maximum number of RPCs that are allowed to
180 * be scheduled for the object or OST in a single batch of each round.
184 * # of pending requests for this object or OST, on all existing rounds
188 * Needed to free this structure from the RCU.
190 struct rcu_head oo_rcu_head;
194 * ORR/TRR NRS request definition
198 * The offset range this request covers
200 struct nrs_orr_req_range or_range;
202 * Round number for this request; shared with all other requests in the
207 * Sequence number for this request; shared with all other requests in
212 * For debugging purposes.
214 struct nrs_orr_key or_key;
216 * An ORR policy instance has filled in request information while
217 * enqueueing the request on the service partition's regular NRS head.
219 unsigned int or_orr_set:1;
221 * A TRR policy instance has filled in request information while
222 * enqueueing the request on the service partition's regular NRS head.
224 unsigned int or_trr_set:1;
226 * Request offset ranges have been filled in with logical offset
229 unsigned int or_logical_set:1;
231 * Request offset ranges have been filled in with physical offset
234 unsigned int or_physical_set:1;