Whamcloud - gitweb
LU-6142 obd: fix white space, header
[fs/lustre-release.git] / lustre / include / lustre_nrs_orr.h
1 /*
2  * GPL HEADER START
3  *
4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5  *
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.
9  *
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.
14  *
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
18  *
19  * GPL HEADER END
20  */
21 /*
22  * Copyright (c) 2014, Intel Corporation.
23  *
24  * Copyright 2012 Xyratex Technology Limited
25  */
26 /*
27  *
28  * Network Request Scheduler (NRS) Object-based Round Robin and Target-based
29  * Round Robin (ORR and TRR) policies
30  *
31  */
32
33 #ifndef _LUSTRE_NRS_ORR_H
34 #define _LUSTRE_NRS_ORR_H
35
36 /**
37  * ORR policy operations
38  */
39 #define NRS_CTL_ORR_RD_QUANTUM PTLRPC_NRS_CTL_POL_SPEC_01
40 #define NRS_CTL_ORR_WR_QUANTUM PTLRPC_NRS_CTL_POL_SPEC_02
41 #define NRS_CTL_ORR_RD_OFF_TYPE PTLRPC_NRS_CTL_POL_SPEC_03
42 #define NRS_CTL_ORR_WR_OFF_TYPE PTLRPC_NRS_CTL_POL_SPEC_04
43 #define NRS_CTL_ORR_RD_SUPP_REQ PTLRPC_NRS_CTL_POL_SPEC_05
44 #define NRS_CTL_ORR_WR_SUPP_REQ PTLRPC_NRS_CTL_POL_SPEC_06
45
46 /**
47  * \name ORR/TRR
48  *
49  * ORR/TRR (Object-based Round Robin/Target-based Round Robin) NRS policies
50  * @{
51  */
52
53 /**
54  * Lower and upper byte offsets of a brw RPC
55  */
56 struct nrs_orr_req_range {
57         __u64           or_start;
58         __u64           or_end;
59 };
60
61 /**
62  * RPC types supported by the ORR/TRR policies
63  */
64 enum nrs_orr_supp {
65         NOS_OST_READ    = BIT(0),
66         NOS_OST_WRITE   = BIT(1),
67         NOS_OST_RW      = (NOS_OST_READ | NOS_OST_WRITE),
68         /**
69          * Default value for policies.
70          */
71         NOS_DFLT        = NOS_OST_READ
72 };
73
74 /**
75  * As unique keys for grouping RPCs together, we use the object's OST FID for
76  * the ORR policy, and the OST index for the TRR policy.
77  *
78  * XXX: We waste some space for TRR policy instances by using a union, but it
79  *      allows to consolidate some of the code between ORR and TRR, and these
80  *      policies will probably eventually merge into one anyway.
81  */
82 struct nrs_orr_key {
83         union {
84                 /** object FID for ORR */
85                 struct lu_fid   ok_fid;
86                 /** OST index for TRR */
87                 __u32           ok_idx;
88         };
89 };
90
91 /**
92  * The largest base string for unique hash/slab object names is
93  * "nrs_orr_reg_", so 13 characters. We add 3 to this to be used for the CPT
94  * id number, so this _should_ be more than enough for the maximum number of
95  * CPTs on any system. If it does happen that this statement is incorrect,
96  * nrs_orr_genobjname() will inevitably yield a non-unique name and cause
97  * kmem_cache_create() to complain (on Linux), so the erroneous situation
98  * will hopefully not go unnoticed.
99  */
100 #define NRS_ORR_OBJ_NAME_MAX    (sizeof("nrs_orr_reg_") + 3)
101
102 /**
103  * private data structure for ORR and TRR NRS
104  */
105 struct nrs_orr_data {
106         struct ptlrpc_nrs_resource      od_res;
107         struct binheap         *od_binheap;
108         struct cfs_hash                *od_obj_hash;
109         struct kmem_cache              *od_cache;
110         /**
111          * Used when a new scheduling round commences, in order to synchronize
112          * all object or OST batches with the new round number.
113          */
114         __u64                           od_round;
115         /**
116          * Determines the relevant ordering amongst request batches within a
117          * scheduling round.
118          */
119         __u64                           od_sequence;
120         /**
121          * RPC types that are currently supported.
122          */
123         enum nrs_orr_supp               od_supp;
124         /**
125          * Round Robin quantum; the maxium number of RPCs that each request
126          * batch for each object or OST can have in a scheduling round.
127          */
128         __u16                           od_quantum;
129         /**
130          * Whether to use physical disk offsets or logical file offsets.
131          */
132         bool                            od_physical;
133         /**
134          * XXX: We need to provide a persistently allocated string to hold
135          * unique object names for this policy, since in currently supported
136          * versions of Linux by Lustre, kmem_cache_create() just sets a pointer
137          * to the name string provided. kstrdup() is used in the version of
138          * kmeme_cache_create() in current Linux mainline, so we may be able to
139          * remove this in the future.
140          */
141         char                            od_objname[NRS_ORR_OBJ_NAME_MAX];
142 };
143
144 /**
145  * Represents a backend-fs object or OST in the ORR and TRR policies
146  * respectively
147  */
148 struct nrs_orr_object {
149         struct ptlrpc_nrs_resource      oo_res;
150         struct hlist_node               oo_hnode;
151         /**
152          * The round number against which requests are being scheduled for this
153          * object or OST
154          */
155         __u64                           oo_round;
156         /**
157          * The sequence number used for requests scheduled for this object or
158          * OST during the current round number.
159          */
160         __u64                           oo_sequence;
161         /**
162          * The key of the object or OST for which this structure instance is
163          * scheduling RPCs
164          */
165         struct nrs_orr_key              oo_key;
166         long                            oo_ref;
167         /**
168          * Round Robin quantum; the maximum number of RPCs that are allowed to
169          * be scheduled for the object or OST in a single batch of each round.
170          */
171         __u16                           oo_quantum;
172         /**
173          * # of pending requests for this object or OST, on all existing rounds
174          */
175         __u16                           oo_active;
176 };
177
178 /**
179  * ORR/TRR NRS request definition
180  */
181 struct nrs_orr_req {
182         /**
183          * The offset range this request covers
184          */
185         struct nrs_orr_req_range        or_range;
186         /**
187          * Round number for this request; shared with all other requests in the
188          * same batch.
189          */
190         __u64                           or_round;
191         /**
192          * Sequence number for this request; shared with all other requests in
193          * the same batch.
194          */
195         __u64                           or_sequence;
196         /**
197          * For debugging purposes.
198          */
199         struct nrs_orr_key              or_key;
200         /**
201          * An ORR policy instance has filled in request information while
202          * enqueueing the request on the service partition's regular NRS head.
203          */
204         unsigned int                    or_orr_set:1;
205         /**
206          * A TRR policy instance has filled in request information while
207          * enqueueing the request on the service partition's regular NRS head.
208          */
209         unsigned int                    or_trr_set:1;
210         /**
211          * Request offset ranges have been filled in with logical offset
212          * values.
213          */
214         unsigned int                    or_logical_set:1;
215         /**
216          * Request offset ranges have been filled in with physical offset
217          * values.
218          */
219         unsigned int                    or_physical_set:1;
220 };
221
222 /** @} ORR/TRR */
223 #endif