ore: Make ore_striping_info and ore_calc_stripe_info public
[linux-2.6-block.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;
43 u64 group_depth;
44 unsigned group_count;
45};
46
47struct ore_components {
48 unsigned numdevs; /* Num of devices in array */
49 /* If @single_comp == EC_SINGLE_COMP, @comps points to a single
50 * component. else there are @numdevs components
51 */
52 enum EC_COMP_USAGE {
53 EC_SINGLE_COMP = 0, EC_MULTPLE_COMPS = 0xffffffff
54 } single_comp;
55 struct ore_comp *comps;
56 struct osd_dev **ods; /* osd_dev array */
57};
58
eb507bc1
BH
59struct ore_striping_info {
60 u64 obj_offset;
61 u64 group_length;
62 u64 M; /* for truncate */
63 unsigned dev;
64 unsigned unit_off;
65};
66
8ff660ab
BH
67struct ore_io_state;
68typedef void (*ore_io_done_fn)(struct ore_io_state *ios, void *private);
69
70struct ore_io_state {
71 struct kref kref;
72
73 void *private;
74 ore_io_done_fn done;
75
76 struct ore_layout *layout;
5bf696da 77 struct ore_components *oc;
8ff660ab
BH
78
79 /* Global read/write IO*/
80 loff_t offset;
81 unsigned long length;
82 void *kern_buff;
83
84 struct page **pages;
85 unsigned nr_pages;
86 unsigned pgbase;
87 unsigned pages_consumed;
88
89 /* Attributes */
90 unsigned in_attr_len;
91 struct osd_attr *in_attr;
92 unsigned out_attr_len;
93 struct osd_attr *out_attr;
94
95 bool reading;
96
97 /* Variable array of size numdevs */
98 unsigned numdevs;
99 struct ore_per_dev_state {
100 struct osd_request *or;
101 struct bio *bio;
102 loff_t offset;
103 unsigned length;
104 unsigned dev;
105 } per_dev[];
106};
107
108static inline unsigned ore_io_state_size(unsigned numdevs)
109{
110 return sizeof(struct ore_io_state) +
111 sizeof(struct ore_per_dev_state) * numdevs;
112}
113
114/* ore.c */
115int ore_get_rw_state(struct ore_layout *layout, struct ore_components *comps,
116 bool is_reading, u64 offset, u64 length,
117 struct ore_io_state **ios);
118int ore_get_io_state(struct ore_layout *layout, struct ore_components *comps,
119 struct ore_io_state **ios);
120void ore_put_io_state(struct ore_io_state *ios);
121
122int ore_check_io(struct ore_io_state *ios, u64 *resid);
123
124int ore_create(struct ore_io_state *ios);
125int ore_remove(struct ore_io_state *ios);
126int ore_write(struct ore_io_state *ios);
127int ore_read(struct ore_io_state *ios);
128int ore_truncate(struct ore_layout *layout, struct ore_components *comps,
129 u64 size);
130
131int extract_attr_from_ios(struct ore_io_state *ios, struct osd_attr *attr);
132
133extern const struct osd_attr g_attr_logical_length;
134
135#endif