3 * Boaz Harrosh <bharrosh@panasas.com>
5 * Public Declarations of the ORE API
7 * This file is part of the ORE (Object Raid Engine) library.
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)
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.
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
25 #include <scsi/osd_initiator.h>
26 #include <scsi/osd_attributes.h>
27 #include <scsi/osd_sec.h>
28 #include <linux/pnfs_osd_xdr.h>
31 struct osd_obj_id obj;
36 /* Our way of looking at the data_map */
37 enum pnfs_osd_raid_algorithm4
51 struct ore_components {
52 unsigned first_dev; /* First logical device no */
53 unsigned numdevs; /* Num of devices in array */
54 /* If @single_comp == EC_SINGLE_COMP, @comps points to a single
55 * component. else there are @numdevs components
58 EC_SINGLE_COMP = 0, EC_MULTPLE_COMPS = 0xffffffff
60 struct ore_comp *comps;
62 /* Array of pointers to ore_dev-* . User will usually have these pointed
63 * too a bigger struct which contain an "ore_dev ored" member and use
64 * container_of(oc->ods[i], struct foo_dev, ored) to access the bigger
70 /* ore_comp_dev Recievies a logical device index */
71 static inline struct osd_dev *ore_comp_dev(
72 const struct ore_components *oc, unsigned i)
74 BUG_ON((i < oc->first_dev) || (oc->first_dev + oc->numdevs <= i));
75 return oc->ods[i - oc->first_dev]->od;
78 static inline void ore_comp_set_dev(
79 struct ore_components *oc, unsigned i, struct osd_dev *od)
81 oc->ods[i - oc->first_dev]->od = od;
84 struct ore_striping_info {
87 u64 M; /* for truncate */
93 typedef void (*ore_io_done_fn)(struct ore_io_state *ios, void *private);
97 struct ore_striping_info si;
102 struct ore_layout *layout;
103 struct ore_components *oc;
105 /* Global read/write IO*/
107 unsigned long length;
113 unsigned pages_consumed;
116 unsigned in_attr_len;
117 struct osd_attr *in_attr;
118 unsigned out_attr_len;
119 struct osd_attr *out_attr;
123 /* Variable array of size numdevs */
125 struct ore_per_dev_state {
126 struct osd_request *or;
134 static inline unsigned ore_io_state_size(unsigned numdevs)
136 return sizeof(struct ore_io_state) +
137 sizeof(struct ore_per_dev_state) * numdevs;
141 int ore_get_rw_state(struct ore_layout *layout, struct ore_components *comps,
142 bool is_reading, u64 offset, u64 length,
143 struct ore_io_state **ios);
144 int ore_get_io_state(struct ore_layout *layout, struct ore_components *comps,
145 struct ore_io_state **ios);
146 void ore_put_io_state(struct ore_io_state *ios);
148 int ore_check_io(struct ore_io_state *ios, u64 *resid);
150 int ore_create(struct ore_io_state *ios);
151 int ore_remove(struct ore_io_state *ios);
152 int ore_write(struct ore_io_state *ios);
153 int ore_read(struct ore_io_state *ios);
154 int ore_truncate(struct ore_layout *layout, struct ore_components *comps,
157 int extract_attr_from_ios(struct ore_io_state *ios, struct osd_attr *attr);
159 extern const struct osd_attr g_attr_logical_length;