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
37 * ORR policy operations
40 NRS_CTL_ORR_RD_QUANTUM = PTLRPC_NRS_CTL_1ST_POL_SPEC,
41 NRS_CTL_ORR_WR_QUANTUM,
42 NRS_CTL_ORR_RD_OFF_TYPE,
43 NRS_CTL_ORR_WR_OFF_TYPE,
44 NRS_CTL_ORR_RD_SUPP_REQ,
45 NRS_CTL_ORR_WR_SUPP_REQ,
51 * ORR/TRR (Object-based Round Robin/Target-based Round Robin) NRS policies
56 * Lower and upper byte offsets of a brw RPC
58 struct nrs_orr_req_range {
64 * RPC types supported by the ORR/TRR policies
67 NOS_OST_READ = (1 << 0),
68 NOS_OST_WRITE = (1 << 1),
69 NOS_OST_RW = (NOS_OST_READ | NOS_OST_WRITE),
71 * Default value for policies.
73 NOS_DFLT = NOS_OST_READ
77 * As unique keys for grouping RPCs together, we use the object's OST FID for
78 * the ORR policy, and the OST index for the TRR policy.
80 * XXX: We waste some space for TRR policy instances by using a union, but it
81 * allows to consolidate some of the code between ORR and TRR, and these
82 * policies will probably eventually merge into one anyway.
86 /** object FID for ORR */
88 /** OST index for TRR */
94 * The largest base string for unique hash/slab object names is
95 * "nrs_orr_reg_", so 13 characters. We add 3 to this to be used for the CPT
96 * id number, so this _should_ be more than enough for the maximum number of
97 * CPTs on any system. If it does happen that this statement is incorrect,
98 * nrs_orr_genobjname() will inevitably yield a non-unique name and cause
99 * kmem_cache_create() to complain (on Linux), so the erroneous situation
100 * will hopefully not go unnoticed.
102 #define NRS_ORR_OBJ_NAME_MAX (sizeof("nrs_orr_reg_") + 3)
105 * private data structure for ORR and TRR NRS
107 struct nrs_orr_data {
108 struct ptlrpc_nrs_resource od_res;
109 struct cfs_binheap *od_binheap;
110 struct cfs_hash *od_obj_hash;
111 struct kmem_cache *od_cache;
113 * Used when a new scheduling round commences, in order to synchronize
114 * all object or OST batches with the new round number.
118 * Determines the relevant ordering amongst request batches within a
123 * RPC types that are currently supported.
125 enum nrs_orr_supp od_supp;
127 * Round Robin quantum; the maxium number of RPCs that each request
128 * batch for each object or OST can have in a scheduling round.
132 * Whether to use physical disk offsets or logical file offsets.
136 * XXX: We need to provide a persistently allocated string to hold
137 * unique object names for this policy, since in currently supported
138 * versions of Linux by Lustre, kmem_cache_create() just sets a pointer
139 * to the name string provided. kstrdup() is used in the version of
140 * kmeme_cache_create() in current Linux mainline, so we may be able to
141 * remove this in the future.
143 char od_objname[NRS_ORR_OBJ_NAME_MAX];
147 * Represents a backend-fs object or OST in the ORR and TRR policies
150 struct nrs_orr_object {
151 struct ptlrpc_nrs_resource oo_res;
152 struct hlist_node oo_hnode;
154 * The round number against which requests are being scheduled for this
159 * The sequence number used for requests scheduled for this object or
160 * OST during the current round number.
164 * The key of the object or OST for which this structure instance is
167 struct nrs_orr_key oo_key;
170 * Round Robin quantum; the maximum number of RPCs that are allowed to
171 * be scheduled for the object or OST in a single batch of each round.
175 * # of pending requests for this object or OST, on all existing rounds
181 * ORR/TRR NRS request definition
185 * The offset range this request covers
187 struct nrs_orr_req_range or_range;
189 * Round number for this request; shared with all other requests in the
194 * Sequence number for this request; shared with all other requests in
199 * For debugging purposes.
201 struct nrs_orr_key or_key;
203 * An ORR policy instance has filled in request information while
204 * enqueueing the request on the service partition's regular NRS head.
206 unsigned int or_orr_set:1;
208 * A TRR policy instance has filled in request information while
209 * enqueueing the request on the service partition's regular NRS head.
211 unsigned int or_trr_set:1;
213 * Request offset ranges have been filled in with logical offset
216 unsigned int or_logical_set:1;
218 * Request offset ranges have been filled in with physical offset
221 unsigned int or_physical_set:1;