g_raid_tr_if.m 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #-
  2. # Copyright (c) 2010 Alexander Motin
  3. # All rights reserved.
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions
  7. # are met:
  8. #
  9. # 1. Redistributions of source code must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. # 2. Redistributions in binary form must reproduce the above copyright
  12. # notice, this list of conditions and the following disclaimer in the
  13. # documentation and/or other materials provided with the distribution.
  14. #
  15. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
  16. # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  17. # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  18. # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
  19. # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  20. # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  21. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  22. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  23. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  24. # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. #
  26. #include <sys/param.h>
  27. #include <sys/lock.h>
  28. #include <sys/malloc.h>
  29. #include <sys/mutex.h>
  30. #include <sys/sbuf.h>
  31. #include <sys/bus.h>
  32. #include <machine/bus.h>
  33. #include <sys/systm.h>
  34. #include <geom/geom.h>
  35. #include <geom/raid/g_raid.h>
  36. # The G_RAID transformation class interface.
  37. INTERFACE g_raid_tr;
  38. # Default implementations of methods.
  39. CODE {
  40. static int
  41. g_raid_tr_locked_default(struct g_raid_tr_object *tr, void *argp)
  42. {
  43. return (0);
  44. }
  45. };
  46. HEADER {
  47. #define G_RAID_TR_TASTE_FAIL -1
  48. #define G_RAID_TR_TASTE_SUCCEED 0
  49. };
  50. # taste() - volume taste method.
  51. METHOD int taste {
  52. struct g_raid_tr_object *tr;
  53. struct g_raid_volume *volume;
  54. };
  55. # event() - events handling method.
  56. METHOD int event {
  57. struct g_raid_tr_object *tr;
  58. struct g_raid_subdisk *sd;
  59. u_int event;
  60. };
  61. # start() - begin operation.
  62. METHOD int start {
  63. struct g_raid_tr_object *tr;
  64. };
  65. # stop() - stop operation.
  66. METHOD int stop {
  67. struct g_raid_tr_object *tr;
  68. };
  69. # iorequest() - manage forward transformation and generates requests to disks.
  70. METHOD void iostart {
  71. struct g_raid_tr_object *tr;
  72. struct bio *bp;
  73. };
  74. # iodone() - manages backward transformation and reports completion status.
  75. METHOD void iodone {
  76. struct g_raid_tr_object *tr;
  77. struct g_raid_subdisk *sd;
  78. struct bio *bp;
  79. };
  80. # kerneldump() - optimized for rebustness (simplified) kernel dumping routine.
  81. METHOD int kerneldump {
  82. struct g_raid_tr_object *tr;
  83. void *virtual;
  84. off_t offset;
  85. size_t length;
  86. } DEFAULT g_raid_tr_kerneldump_common;
  87. # locked() - callback method for lock().
  88. METHOD int locked {
  89. struct g_raid_tr_object *tr;
  90. void *argp;
  91. } DEFAULT g_raid_tr_locked_default;
  92. # free() - destructor.
  93. METHOD int free {
  94. struct g_raid_tr_object *tr;
  95. };
  96. # idle() - callback when the volume is idle for a while and the TR wants
  97. # to schedule some work for that idle period.
  98. METHOD int idle {
  99. struct g_raid_tr_object *tr;
  100. };