dm-path-selector.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. struct dm_path *(*select_path) (struct path_selector *ps,
  46. size_t nr_bytes);
  47. /*
  48. * Notify the selector that a path has failed.
  49. */
  50. void (*fail_path) (struct path_selector *ps, struct dm_path *p);
  51. /*
  52. * Ask selector to reinstate a path.
  53. */
  54. int (*reinstate_path) (struct path_selector *ps, struct dm_path *p);
  55. /*
  56. * Table content based on parameters added in ps_add_path_fn
  57. * or path selector status
  58. */
  59. int (*status) (struct path_selector *ps, struct dm_path *path,
  60. status_type_t type, char *result, unsigned int maxlen);
  61. int (*start_io) (struct path_selector *ps, struct dm_path *path,
  62. size_t nr_bytes);
  63. int (*end_io) (struct path_selector *ps, struct dm_path *path,
  64. size_t nr_bytes);
  65. };
  66. /* Register a path selector */
  67. int dm_register_path_selector(struct path_selector_type *type);
  68. /* Unregister a path selector */
  69. int dm_unregister_path_selector(struct path_selector_type *type);
  70. /* Returns a registered path selector type */
  71. struct path_selector_type *dm_get_path_selector(const char *name);
  72. /* Releases a path selector */
  73. void dm_put_path_selector(struct path_selector_type *pst);
  74. #endif