xref: /OK3568_Linux_fs/kernel/include/linux/crush/mapper.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef CEPH_CRUSH_MAPPER_H
3*4882a593Smuzhiyun #define CEPH_CRUSH_MAPPER_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun /*
6*4882a593Smuzhiyun  * CRUSH functions for find rules and then mapping an input to an
7*4882a593Smuzhiyun  * output set.
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  * LGPL2
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #include "crush.h"
13*4882a593Smuzhiyun 
14*4882a593Smuzhiyun extern int crush_find_rule(const struct crush_map *map, int ruleset, int type, int size);
15*4882a593Smuzhiyun int crush_do_rule(const struct crush_map *map,
16*4882a593Smuzhiyun 		  int ruleno, int x, int *result, int result_max,
17*4882a593Smuzhiyun 		  const __u32 *weight, int weight_max,
18*4882a593Smuzhiyun 		  void *cwin, const struct crush_choose_arg *choose_args);
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun /*
21*4882a593Smuzhiyun  * Returns the exact amount of workspace that will need to be used
22*4882a593Smuzhiyun  * for a given combination of crush_map and result_max. The caller can
23*4882a593Smuzhiyun  * then allocate this much on its own, either on the stack, in a
24*4882a593Smuzhiyun  * per-thread long-lived buffer, or however it likes.
25*4882a593Smuzhiyun  */
crush_work_size(const struct crush_map * map,int result_max)26*4882a593Smuzhiyun static inline size_t crush_work_size(const struct crush_map *map,
27*4882a593Smuzhiyun 				     int result_max)
28*4882a593Smuzhiyun {
29*4882a593Smuzhiyun 	return map->working_size + result_max * 3 * sizeof(__u32);
30*4882a593Smuzhiyun }
31*4882a593Smuzhiyun 
32*4882a593Smuzhiyun void crush_init_workspace(const struct crush_map *map, void *v);
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun #endif
35