Go to the documentation of this file.00001 #ifndef _CRUSH_CRUSH_H
00002 #define _CRUSH_CRUSH_H
00003
00004 #include<stdint.h>
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #define CRUSH_MAGIC 0x00010000ul
00021
00022
00023 #define CRUSH_MAX_DEPTH 10
00024 #define CRUSH_MAX_SET 10
00025
00026
00027
00028
00029
00030
00031
00032 struct crush_rule_step {
00033 uint32_t op;
00034 int32_t arg1;
00035 int32_t arg2;
00036 };
00037
00038
00039 enum {
00040 CRUSH_RULE_NOOP = 0,
00041 CRUSH_RULE_TAKE = 1,
00042 CRUSH_RULE_CHOOSE_FIRSTN = 2,
00043
00044 CRUSH_RULE_CHOOSE_INDEP = 3,
00045 CRUSH_RULE_EMIT = 4,
00046 CRUSH_RULE_CHOOSE_LEAF_FIRSTN = 6,
00047 CRUSH_RULE_CHOOSE_LEAF_INDEP = 7,
00048 };
00049
00050
00051
00052
00053
00054 #define CRUSH_CHOOSE_N 0
00055 #define CRUSH_CHOOSE_N_MINUS(x) (-(x))
00056
00057
00058
00059
00060
00061
00062 struct crush_rule_mask {
00063 uint8_t ruleset;
00064 uint8_t type;
00065 uint8_t min_size;
00066 uint8_t max_size;
00067 };
00068
00069 struct crush_rule {
00070 uint32_t len;
00071 struct crush_rule_mask mask;
00072 struct crush_rule_step steps[0];
00073 };
00074
00075 #define crush_rule_size(len) (sizeof(struct crush_rule) + \
00076 (len)*sizeof(struct crush_rule_step))
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 enum {
00095 CRUSH_BUCKET_UNIFORM = 1,
00096 CRUSH_BUCKET_LIST = 2,
00097 CRUSH_BUCKET_TREE = 3,
00098 CRUSH_BUCKET_STRAW = 4
00099 };
00100 extern const char *crush_bucket_alg_name(int alg);
00101
00102 struct crush_bucket {
00103 int32_t id;
00104 uint16_t type;
00105 uint8_t alg;
00106 uint8_t hash;
00107 uint32_t weight;
00108 uint32_t size;
00109 int32_t *items;
00110
00111
00112
00113
00114
00115 int64_t perm_x;
00116 uint32_t perm_n;
00117 uint32_t *perm;
00118 };
00119
00120 struct crush_bucket_uniform {
00121 struct crush_bucket h;
00122 uint32_t item_weight;
00123 };
00124
00125 struct crush_bucket_list {
00126 struct crush_bucket h;
00127 uint32_t *item_weights;
00128 uint32_t *sum_weights;
00129
00130 };
00131
00132 struct crush_bucket_tree {
00133 struct crush_bucket h;
00134
00135 uint8_t num_nodes;
00136 uint32_t *node_weights;
00137 };
00138
00139 struct crush_bucket_straw {
00140 struct crush_bucket h;
00141 uint32_t *item_weights;
00142 uint32_t *straws;
00143 };
00144
00145
00146
00147
00148
00149
00150 struct crush_map {
00151 struct crush_bucket **buckets;
00152 struct crush_rule **rules;
00153
00154
00155
00156
00157
00158
00159
00160
00161 uint32_t *bucket_parents;
00162 uint32_t *device_parents;
00163
00164 int32_t max_buckets;
00165 uint32_t max_rules;
00166 int32_t max_devices;
00167 };
00168
00169
00170
00171 extern int crush_get_bucket_item_weight(struct crush_bucket *b, int pos);
00172 extern void crush_calc_parents(struct crush_map *map);
00173 extern void crush_destroy_bucket_uniform(struct crush_bucket_uniform *b);
00174 extern void crush_destroy_bucket_list(struct crush_bucket_list *b);
00175 extern void crush_destroy_bucket_tree(struct crush_bucket_tree *b);
00176 extern void crush_destroy_bucket_straw(struct crush_bucket_straw *b);
00177 extern void crush_destroy_bucket(struct crush_bucket *b);
00178 extern void crush_destroy(struct crush_map *map);
00179
00180 #endif