dm-path-selector.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * Copyright (C) 2003 Sistina Software.
  3. * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
  4. *
  5. * Module Author: Heinz Mauelshagen
  6. *
  7. * This file is released under the GPL.
  8. *
  9. * Path-Selector registration.
  10. */
  11. #ifndef DM_PATH_SELECTOR_H
  12. #define DM_PATH_SELECTOR_H
  13. #include <linux/device-mapper.h>
  14. #include "dm-mpath.h"
  15. /*
  16. * We provide an abstraction for the code that chooses which path
  17. * to send some io down.
  18. */
  19. struct path_selector_type;
  20. struct path_selector {
  21. struct path_selector_type *type;
  22. void *context;
  23. };
  24. /* Information about a path selector type */
  25. struct path_selector_type {
  26. char *name;
  27. struct module *module;
  28. unsigned int table_args;
  29. unsigned int info_args;
  30. /*
  31. * Constructs a path selector object, takes custom arguments
  32. */
  33. int (*create) (struct path_selector *ps, unsigned argc, char **argv);
  34. void (*destroy) (struct path_selector *ps);
  35. /*
  36. * Add an opaque path object, along with some selector specific
  37. * path args (eg, path priority).
  38. */
  39. int (*add_path) (struct path_selector *ps, struct dm_path *path,
  40. int argc, char **argv, char **error);
  41. /*
  42. * Chooses a path for this io, if no paths are available then
  43. * NULL will be returned.
  44. *
  45. * repeat_count is the number of times to use the path before
  46. * calling the function again. 0 means don't call it again unless
  47. * the path fails.
  48. */
  49. struct dm_path *(*select_path) (struct path_selector *ps,
  50. unsigned *repeat_count,
  51. size_t nr_bytes);
  52. /*
  53. * Notify the selector that a path has failed.
  54. */
  55. void (*fail_path) (struct path_selector *ps, struct dm_path *p);
  56. /*
  57. * Ask selector to reinstate a path.
  58. */
  59. int (*reinstate_path) (struct path_selector *ps, struct dm_path *p);
  60. /*
  61. * Table content based on parameters added in ps_add_path_fn
  62. * or path selector status
  63. */
  64. int (*status) (struct path_selector *ps, struct dm_path *path,
  65. status_type_t type, char *result, unsigned int maxlen);
  66. int (*start_io) (struct path_selector *ps, struct dm_path *path,
  67. size_t nr_bytes);
  68. int (*end_io) (struct path_selector *ps, struct dm_path *path,
  69. size_t nr_bytes);
  70. };
  71. /* Register a path selector */
  72. int dm_register_path_selector(struct path_selector_type *type);
  73. /* Unregister a path selector */
  74. int dm_unregister_path_selector(struct path_selector_type *type);
  75. /* Returns a registered path selector type */
  76. struct path_selector_type *dm_get_path_selector(const char *name);
  77. /* Releases a path selector */
  78. void dm_put_path_selector(struct path_selector_type *pst);
  79. #endif