mapper.h 1002 B

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