xref: /linux-6.15/include/linux/crush/mapper.h (revision b2441318)
1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
23d14c5d2SYehuda Sadeh #ifndef CEPH_CRUSH_MAPPER_H
33d14c5d2SYehuda Sadeh #define CEPH_CRUSH_MAPPER_H
43d14c5d2SYehuda Sadeh 
53d14c5d2SYehuda Sadeh /*
63d14c5d2SYehuda Sadeh  * CRUSH functions for find rules and then mapping an input to an
73d14c5d2SYehuda Sadeh  * output set.
83d14c5d2SYehuda Sadeh  *
93d14c5d2SYehuda Sadeh  * LGPL2
103d14c5d2SYehuda Sadeh  */
113d14c5d2SYehuda Sadeh 
12b459be73SIlya Dryomov #include "crush.h"
133d14c5d2SYehuda Sadeh 
148b12d47bSSage Weil extern int crush_find_rule(const struct crush_map *map, int ruleset, int type, int size);
15069f3222SIlya Dryomov int crush_do_rule(const struct crush_map *map,
16069f3222SIlya Dryomov 		  int ruleno, int x, int *result, int result_max,
17069f3222SIlya Dryomov 		  const __u32 *weight, int weight_max,
18069f3222SIlya Dryomov 		  void *cwin, const struct crush_choose_arg *choose_args);
19743efcffSIlya Dryomov 
20743efcffSIlya Dryomov /*
21743efcffSIlya Dryomov  * Returns the exact amount of workspace that will need to be used
22743efcffSIlya Dryomov  * for a given combination of crush_map and result_max. The caller can
23743efcffSIlya Dryomov  * then allocate this much on its own, either on the stack, in a
24743efcffSIlya Dryomov  * per-thread long-lived buffer, or however it likes.
25743efcffSIlya Dryomov  */
crush_work_size(const struct crush_map * map,int result_max)26743efcffSIlya Dryomov static inline size_t crush_work_size(const struct crush_map *map,
27743efcffSIlya Dryomov 				     int result_max)
28743efcffSIlya Dryomov {
29743efcffSIlya Dryomov 	return map->working_size + result_max * 3 * sizeof(__u32);
30743efcffSIlya Dryomov }
3166a0e2d5SIlya Dryomov 
3266a0e2d5SIlya Dryomov void crush_init_workspace(const struct crush_map *map, void *v);
333d14c5d2SYehuda Sadeh 
343d14c5d2SYehuda Sadeh #endif
35