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
46 /* Cached often needed calculations filled in by
49 unsigned long max_io_length; /* Max length that should be passed to
58 struct ore_components {
59 unsigned first_dev; /* First logical device no */
60 unsigned numdevs; /* Num of devices in array */
61 /* If @single_comp == EC_SINGLE_COMP, @comps points to a single
62 * component. else there are @numdevs components
65 EC_SINGLE_COMP = 0, EC_MULTPLE_COMPS = 0xffffffff
67 struct ore_comp *comps;
69 /* Array of pointers to ore_dev-* . User will usually have these pointed
70 * too a bigger struct which contain an "ore_dev ored" member and use
71 * container_of(oc->ods[i], struct foo_dev, ored) to access the bigger
77 /* ore_comp_dev Recievies a logical device index */
78 static inline struct osd_dev *ore_comp_dev(
79 const struct ore_components *oc, unsigned i)
81 BUG_ON((i < oc->first_dev) || (oc->first_dev + oc->numdevs <= i));
82 return oc->ods[i - oc->first_dev]->od;
85 static inline void ore_comp_set_dev(
86 struct ore_components *oc, unsigned i, struct osd_dev *od)
88 oc->ods[i - oc->first_dev]->od = od;
91 struct ore_striping_info {
94 u64 M; /* for truncate */
100 typedef void (*ore_io_done_fn)(struct ore_io_state *ios, void *private);
102 struct ore_io_state {
104 struct ore_striping_info si;
109 struct ore_layout *layout;
110 struct ore_components *oc;
112 /* Global read/write IO*/
114 unsigned long length;
120 unsigned pages_consumed;
123 unsigned in_attr_len;
124 struct osd_attr *in_attr;
125 unsigned out_attr_len;
126 struct osd_attr *out_attr;
130 /* Variable array of size numdevs */
132 struct ore_per_dev_state {
133 struct osd_request *or;
141 static inline unsigned ore_io_state_size(unsigned numdevs)
143 return sizeof(struct ore_io_state) +
144 sizeof(struct ore_per_dev_state) * numdevs;
148 int ore_verify_layout(unsigned total_comps, struct ore_layout *layout);
149 int ore_get_rw_state(struct ore_layout *layout, struct ore_components *comps,
150 bool is_reading, u64 offset, u64 length,
151 struct ore_io_state **ios);
152 int ore_get_io_state(struct ore_layout *layout, struct ore_components *comps,
153 struct ore_io_state **ios);
154 void ore_put_io_state(struct ore_io_state *ios);
156 int ore_check_io(struct ore_io_state *ios, u64 *resid);
158 int ore_create(struct ore_io_state *ios);
159 int ore_remove(struct ore_io_state *ios);
160 int ore_write(struct ore_io_state *ios);
161 int ore_read(struct ore_io_state *ios);
162 int ore_truncate(struct ore_layout *layout, struct ore_components *comps,
165 int extract_attr_from_ios(struct ore_io_state *ios, struct osd_attr *attr);
167 extern const struct osd_attr g_attr_logical_length;