ore: RAID5 read
[deliverable/linux.git] / include / scsi / osd_ore.h
CommitLineData
8ff660ab
BH
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
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>
29
30struct ore_comp {
31 struct osd_obj_id obj;
32 u8 cred[OSD_CAP_LEN];
33};
34
35struct ore_layout {
36 /* Our way of looking at the data_map */
8d2d83a8
BH
37 enum pnfs_osd_raid_algorithm4
38 raid_algorithm;
8ff660ab
BH
39 unsigned stripe_unit;
40 unsigned mirrors_p1;
41
42 unsigned group_width;
a1fec1db 43 unsigned parity;
8ff660ab
BH
44 u64 group_depth;
45 unsigned group_count;
5a51c0c7
BH
46
47 /* Cached often needed calculations filled in by
48 * ore_verify_layout
49 */
50 unsigned long max_io_length; /* Max length that should be passed to
51 * ore_get_rw_state
52 */
8ff660ab
BH
53};
54
d866d875
BH
55struct ore_dev {
56 struct osd_dev *od;
57};
58
8ff660ab 59struct ore_components {
3bd98568 60 unsigned first_dev; /* First logical device no */
8ff660ab
BH
61 unsigned numdevs; /* Num of devices in array */
62 /* If @single_comp == EC_SINGLE_COMP, @comps points to a single
63 * component. else there are @numdevs components
64 */
65 enum EC_COMP_USAGE {
66 EC_SINGLE_COMP = 0, EC_MULTPLE_COMPS = 0xffffffff
67 } single_comp;
68 struct ore_comp *comps;
d866d875
BH
69
70 /* Array of pointers to ore_dev-* . User will usually have these pointed
71 * too a bigger struct which contain an "ore_dev ored" member and use
72 * container_of(oc->ods[i], struct foo_dev, ored) to access the bigger
73 * structure.
74 */
75 struct ore_dev **ods;
8ff660ab
BH
76};
77
d866d875
BH
78/* ore_comp_dev Recievies a logical device index */
79static inline struct osd_dev *ore_comp_dev(
80 const struct ore_components *oc, unsigned i)
81{
3bd98568
BH
82 BUG_ON((i < oc->first_dev) || (oc->first_dev + oc->numdevs <= i));
83 return oc->ods[i - oc->first_dev]->od;
d866d875
BH
84}
85
86static inline void ore_comp_set_dev(
87 struct ore_components *oc, unsigned i, struct osd_dev *od)
88{
3bd98568 89 oc->ods[i - oc->first_dev]->od = od;
d866d875
BH
90}
91
eb507bc1 92struct ore_striping_info {
a1fec1db 93 u64 offset;
eb507bc1 94 u64 obj_offset;
a1fec1db
BH
95 u64 length;
96 u64 first_stripe_start; /* only used in raid writes */
eb507bc1 97 u64 M; /* for truncate */
a1fec1db 98 unsigned bytes_in_stripe;
eb507bc1 99 unsigned dev;
a1fec1db 100 unsigned par_dev;
eb507bc1 101 unsigned unit_off;
a1fec1db 102 unsigned cur_comp;
eb507bc1
BH
103};
104
8ff660ab
BH
105struct ore_io_state;
106typedef void (*ore_io_done_fn)(struct ore_io_state *ios, void *private);
107
108struct ore_io_state {
109 struct kref kref;
98260754 110 struct ore_striping_info si;
8ff660ab
BH
111
112 void *private;
113 ore_io_done_fn done;
114
115 struct ore_layout *layout;
5bf696da 116 struct ore_components *oc;
8ff660ab
BH
117
118 /* Global read/write IO*/
119 loff_t offset;
120 unsigned long length;
121 void *kern_buff;
122
123 struct page **pages;
124 unsigned nr_pages;
125 unsigned pgbase;
126 unsigned pages_consumed;
127
128 /* Attributes */
129 unsigned in_attr_len;
130 struct osd_attr *in_attr;
131 unsigned out_attr_len;
132 struct osd_attr *out_attr;
133
134 bool reading;
135
a1fec1db
BH
136 /* House keeping of Parity pages */
137 bool extra_part_alloc;
138 struct page **parity_pages;
139 unsigned max_par_pages;
140 unsigned cur_par_page;
141 unsigned sgs_per_dev;
142
8ff660ab
BH
143 /* Variable array of size numdevs */
144 unsigned numdevs;
145 struct ore_per_dev_state {
146 struct osd_request *or;
147 struct bio *bio;
148 loff_t offset;
149 unsigned length;
a1fec1db 150 unsigned last_sgs_total;
8ff660ab 151 unsigned dev;
a1fec1db
BH
152 struct osd_sg_entry *sglist;
153 unsigned cur_sg;
8ff660ab
BH
154 } per_dev[];
155};
156
157static inline unsigned ore_io_state_size(unsigned numdevs)
158{
159 return sizeof(struct ore_io_state) +
160 sizeof(struct ore_per_dev_state) * numdevs;
161}
162
163/* ore.c */
5a51c0c7 164int ore_verify_layout(unsigned total_comps, struct ore_layout *layout);
611d7a5d 165void ore_calc_stripe_info(struct ore_layout *layout, u64 file_offset,
a1fec1db 166 u64 length, struct ore_striping_info *si);
8ff660ab
BH
167int ore_get_rw_state(struct ore_layout *layout, struct ore_components *comps,
168 bool is_reading, u64 offset, u64 length,
169 struct ore_io_state **ios);
170int ore_get_io_state(struct ore_layout *layout, struct ore_components *comps,
171 struct ore_io_state **ios);
172void ore_put_io_state(struct ore_io_state *ios);
173
4b46c9f5
BH
174typedef void (*ore_on_dev_error)(struct ore_io_state *ios, struct ore_dev *od,
175 unsigned dev_index, enum osd_err_priority oep,
176 u64 dev_offset, u64 dev_len);
177int ore_check_io(struct ore_io_state *ios, ore_on_dev_error rep);
8ff660ab
BH
178
179int ore_create(struct ore_io_state *ios);
180int ore_remove(struct ore_io_state *ios);
181int ore_write(struct ore_io_state *ios);
182int ore_read(struct ore_io_state *ios);
183int ore_truncate(struct ore_layout *layout, struct ore_components *comps,
184 u64 size);
185
186int extract_attr_from_ios(struct ore_io_state *ios, struct osd_attr *attr);
187
188extern const struct osd_attr g_attr_logical_length;
189
190#endif
This page took 0.077225 seconds and 5 git commands to generate.