osd_ore.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * Copyright (C) 2011
  3. * Boaz Harrosh <bharrosh@panasas.com>
  4. *
  5. * Public Declarations of the ORE API
  6. *
  7. * This file is part of the ORE (Object Raid Engine) library.
  8. *
  9. * ORE is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as published
  11. * by the Free Software Foundation. (GPL v2)
  12. *
  13. * ORE is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with the ORE; if not, write to the Free Software
  20. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  21. */
  22. #ifndef __ORE_H__
  23. #define __ORE_H__
  24. #include <scsi/osd_initiator.h>
  25. #include <scsi/osd_attributes.h>
  26. #include <scsi/osd_sec.h>
  27. #include <linux/pnfs_osd_xdr.h>
  28. struct ore_comp {
  29. struct osd_obj_id obj;
  30. u8 cred[OSD_CAP_LEN];
  31. };
  32. struct ore_layout {
  33. /* Our way of looking at the data_map */
  34. unsigned stripe_unit;
  35. unsigned mirrors_p1;
  36. unsigned group_width;
  37. u64 group_depth;
  38. unsigned group_count;
  39. };
  40. struct ore_components {
  41. unsigned numdevs; /* Num of devices in array */
  42. /* If @single_comp == EC_SINGLE_COMP, @comps points to a single
  43. * component. else there are @numdevs components
  44. */
  45. enum EC_COMP_USAGE {
  46. EC_SINGLE_COMP = 0, EC_MULTPLE_COMPS = 0xffffffff
  47. } single_comp;
  48. struct ore_comp *comps;
  49. struct osd_dev **ods; /* osd_dev array */
  50. };
  51. struct ore_io_state;
  52. typedef void (*ore_io_done_fn)(struct ore_io_state *ios, void *private);
  53. struct ore_io_state {
  54. struct kref kref;
  55. void *private;
  56. ore_io_done_fn done;
  57. struct ore_layout *layout;
  58. struct ore_components *comps;
  59. /* Global read/write IO*/
  60. loff_t offset;
  61. unsigned long length;
  62. void *kern_buff;
  63. struct page **pages;
  64. unsigned nr_pages;
  65. unsigned pgbase;
  66. unsigned pages_consumed;
  67. /* Attributes */
  68. unsigned in_attr_len;
  69. struct osd_attr *in_attr;
  70. unsigned out_attr_len;
  71. struct osd_attr *out_attr;
  72. bool reading;
  73. /* Variable array of size numdevs */
  74. unsigned numdevs;
  75. struct ore_per_dev_state {
  76. struct osd_request *or;
  77. struct bio *bio;
  78. loff_t offset;
  79. unsigned length;
  80. unsigned dev;
  81. } per_dev[];
  82. };
  83. static inline unsigned ore_io_state_size(unsigned numdevs)
  84. {
  85. return sizeof(struct ore_io_state) +
  86. sizeof(struct ore_per_dev_state) * numdevs;
  87. }
  88. /* ore.c */
  89. int ore_get_rw_state(struct ore_layout *layout, struct ore_components *comps,
  90. bool is_reading, u64 offset, u64 length,
  91. struct ore_io_state **ios);
  92. int ore_get_io_state(struct ore_layout *layout, struct ore_components *comps,
  93. struct ore_io_state **ios);
  94. void ore_put_io_state(struct ore_io_state *ios);
  95. int ore_check_io(struct ore_io_state *ios, u64 *resid);
  96. int ore_create(struct ore_io_state *ios);
  97. int ore_remove(struct ore_io_state *ios);
  98. int ore_write(struct ore_io_state *ios);
  99. int ore_read(struct ore_io_state *ios);
  100. int ore_truncate(struct ore_layout *layout, struct ore_components *comps,
  101. u64 size);
  102. int extract_attr_from_ios(struct ore_io_state *ios, struct osd_attr *attr);
  103. extern const struct osd_attr g_attr_logical_length;
  104. #endif