Whamcloud - gitweb
LU-3289 gss: Add two additional security flavors for sk
[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 enum nrs_ctl_orr {
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,
46 };
47
48 /**
49  * \name ORR/TRR
50  *
51  * ORR/TRR (Object-based Round Robin/Target-based Round Robin) NRS policies
52  * @{
53  */
54
55 /**
56  * Lower and upper byte offsets of a brw RPC
57  */
58 struct nrs_orr_req_range {
59         __u64           or_start;
60         __u64           or_end;
61 };
62
63 /**
64  * RPC types supported by the ORR/TRR policies
65  */
66 enum nrs_orr_supp {
67         NOS_OST_READ  = (1 << 0),
68         NOS_OST_WRITE = (1 << 1),
69         NOS_OST_RW    = (NOS_OST_READ | NOS_OST_WRITE),
70         /**
71          * Default value for policies.
72          */
73         NOS_DFLT      = NOS_OST_READ
74 };
75
76 /**
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.
79  *
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.
83  */
84 struct nrs_orr_key {
85         union {
86                 /** object FID for ORR */
87                 struct lu_fid   ok_fid;
88                 /** OST index for TRR */
89                 __u32           ok_idx;
90         };
91 };
92
93 /**
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.
101  */
102 #define NRS_ORR_OBJ_NAME_MAX    (sizeof("nrs_orr_reg_") + 3)
103
104 /**
105  * private data structure for ORR and TRR NRS
106  */
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;
112         /**
113          * Used when a new scheduling round commences, in order to synchronize
114          * all object or OST batches with the new round number.
115          */
116         __u64                           od_round;
117         /**
118          * Determines the relevant ordering amongst request batches within a
119          * scheduling round.
120          */
121         __u64                           od_sequence;
122         /**
123          * RPC types that are currently supported.
124          */
125         enum nrs_orr_supp               od_supp;
126         /**
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.
129          */
130         __u16                           od_quantum;
131         /**
132          * Whether to use physical disk offsets or logical file offsets.
133          */
134         bool                            od_physical;
135         /**
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.
142          */
143         char                            od_objname[NRS_ORR_OBJ_NAME_MAX];
144 };
145
146 /**
147  * Represents a backend-fs object or OST in the ORR and TRR policies
148  * respectively
149  */
150 struct nrs_orr_object {
151         struct ptlrpc_nrs_resource      oo_res;
152         struct hlist_node               oo_hnode;
153         /**
154          * The round number against which requests are being scheduled for this
155          * object or OST
156          */
157         __u64                           oo_round;
158         /**
159          * The sequence number used for requests scheduled for this object or
160          * OST during the current round number.
161          */
162         __u64                           oo_sequence;
163         /**
164          * The key of the object or OST for which this structure instance is
165          * scheduling RPCs
166          */
167         struct nrs_orr_key              oo_key;
168         long                            oo_ref;
169         /**
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.
172          */
173         __u16                           oo_quantum;
174         /**
175          * # of pending requests for this object or OST, on all existing rounds
176          */
177         __u16                           oo_active;
178 };
179
180 /**
181  * ORR/TRR NRS request definition
182  */
183 struct nrs_orr_req {
184         /**
185          * The offset range this request covers
186          */
187         struct nrs_orr_req_range        or_range;
188         /**
189          * Round number for this request; shared with all other requests in the
190          * same batch.
191          */
192         __u64                           or_round;
193         /**
194          * Sequence number for this request; shared with all other requests in
195          * the same batch.
196          */
197         __u64                           or_sequence;
198         /**
199          * For debugging purposes.
200          */
201         struct nrs_orr_key              or_key;
202         /**
203          * An ORR policy instance has filled in request information while
204          * enqueueing the request on the service partition's regular NRS head.
205          */
206         unsigned int                    or_orr_set:1;
207         /**
208          * A TRR policy instance has filled in request information while
209          * enqueueing the request on the service partition's regular NRS head.
210          */
211         unsigned int                    or_trr_set:1;
212         /**
213          * Request offset ranges have been filled in with logical offset
214          * values.
215          */
216         unsigned int                    or_logical_set:1;
217         /**
218          * Request offset ranges have been filled in with physical offset
219          * values.
220          */
221         unsigned int                    or_physical_set:1;
222 };
223
224 /** @} ORR/TRR */
225 #endif