]>
Commit | Line | Data |
---|---|---|
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 | ||
30 | struct ore_comp { | |
31 | struct osd_obj_id obj; | |
32 | u8 cred[OSD_CAP_LEN]; | |
33 | }; | |
34 | ||
35 | struct 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; | |
43 | u64 group_depth; | |
44 | unsigned group_count; | |
5a51c0c7 BH |
45 | |
46 | /* Cached often needed calculations filled in by | |
47 | * ore_verify_layout | |
48 | */ | |
49 | unsigned long max_io_length; /* Max length that should be passed to | |
50 | * ore_get_rw_state | |
51 | */ | |
8ff660ab BH |
52 | }; |
53 | ||
d866d875 BH |
54 | struct ore_dev { |
55 | struct osd_dev *od; | |
56 | }; | |
57 | ||
8ff660ab | 58 | struct ore_components { |
3bd98568 | 59 | unsigned first_dev; /* First logical device no */ |
8ff660ab BH |
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 | |
63 | */ | |
64 | enum EC_COMP_USAGE { | |
65 | EC_SINGLE_COMP = 0, EC_MULTPLE_COMPS = 0xffffffff | |
66 | } single_comp; | |
67 | struct ore_comp *comps; | |
d866d875 BH |
68 | |
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 | |
72 | * structure. | |
73 | */ | |
74 | struct ore_dev **ods; | |
8ff660ab BH |
75 | }; |
76 | ||
d866d875 BH |
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) | |
80 | { | |
3bd98568 BH |
81 | BUG_ON((i < oc->first_dev) || (oc->first_dev + oc->numdevs <= i)); |
82 | return oc->ods[i - oc->first_dev]->od; | |
d866d875 BH |
83 | } |
84 | ||
85 | static inline void ore_comp_set_dev( | |
86 | struct ore_components *oc, unsigned i, struct osd_dev *od) | |
87 | { | |
3bd98568 | 88 | oc->ods[i - oc->first_dev]->od = od; |
d866d875 BH |
89 | } |
90 | ||
eb507bc1 BH |
91 | struct ore_striping_info { |
92 | u64 obj_offset; | |
93 | u64 group_length; | |
94 | u64 M; /* for truncate */ | |
95 | unsigned dev; | |
96 | unsigned unit_off; | |
97 | }; | |
98 | ||
8ff660ab BH |
99 | struct ore_io_state; |
100 | typedef void (*ore_io_done_fn)(struct ore_io_state *ios, void *private); | |
101 | ||
102 | struct ore_io_state { | |
103 | struct kref kref; | |
98260754 | 104 | struct ore_striping_info si; |
8ff660ab BH |
105 | |
106 | void *private; | |
107 | ore_io_done_fn done; | |
108 | ||
109 | struct ore_layout *layout; | |
5bf696da | 110 | struct ore_components *oc; |
8ff660ab BH |
111 | |
112 | /* Global read/write IO*/ | |
113 | loff_t offset; | |
114 | unsigned long length; | |
115 | void *kern_buff; | |
116 | ||
117 | struct page **pages; | |
118 | unsigned nr_pages; | |
119 | unsigned pgbase; | |
120 | unsigned pages_consumed; | |
121 | ||
122 | /* Attributes */ | |
123 | unsigned in_attr_len; | |
124 | struct osd_attr *in_attr; | |
125 | unsigned out_attr_len; | |
126 | struct osd_attr *out_attr; | |
127 | ||
128 | bool reading; | |
129 | ||
130 | /* Variable array of size numdevs */ | |
131 | unsigned numdevs; | |
132 | struct ore_per_dev_state { | |
133 | struct osd_request *or; | |
134 | struct bio *bio; | |
135 | loff_t offset; | |
136 | unsigned length; | |
137 | unsigned dev; | |
138 | } per_dev[]; | |
139 | }; | |
140 | ||
141 | static inline unsigned ore_io_state_size(unsigned numdevs) | |
142 | { | |
143 | return sizeof(struct ore_io_state) + | |
144 | sizeof(struct ore_per_dev_state) * numdevs; | |
145 | } | |
146 | ||
147 | /* ore.c */ | |
5a51c0c7 | 148 | int ore_verify_layout(unsigned total_comps, struct ore_layout *layout); |
8ff660ab BH |
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); | |
155 | ||
156 | int ore_check_io(struct ore_io_state *ios, u64 *resid); | |
157 | ||
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, | |
163 | u64 size); | |
164 | ||
165 | int extract_attr_from_ios(struct ore_io_state *ios, struct osd_attr *attr); | |
166 | ||
167 | extern const struct osd_attr g_attr_logical_length; | |
168 | ||
169 | #endif |