Add linux-next specific files for 20110831
[linux-2.6/next.git] / include / scsi / osd_ore.h
blob0ac493142056874bef6e7e8f822bb844f95a0b6f
1 /*
2 * Copyright (C) 2011
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
22 #ifndef __ORE_H__
23 #define __ORE_H__
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>
30 struct ore_comp {
31 struct osd_obj_id obj;
32 u8 cred[OSD_CAP_LEN];
35 struct ore_layout {
36 /* Our way of looking at the data_map */
37 enum pnfs_osd_raid_algorithm4
38 raid_algorithm;
39 unsigned stripe_unit;
40 unsigned mirrors_p1;
42 unsigned group_width;
43 u64 group_depth;
44 unsigned group_count;
47 struct 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
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 */
59 struct ore_io_state;
60 typedef void (*ore_io_done_fn)(struct ore_io_state *ios, void *private);
62 struct ore_io_state {
63 struct kref kref;
65 void *private;
66 ore_io_done_fn done;
68 struct ore_layout *layout;
69 struct ore_components *comps;
71 /* Global read/write IO*/
72 loff_t offset;
73 unsigned long length;
74 void *kern_buff;
76 struct page **pages;
77 unsigned nr_pages;
78 unsigned pgbase;
79 unsigned pages_consumed;
81 /* Attributes */
82 unsigned in_attr_len;
83 struct osd_attr *in_attr;
84 unsigned out_attr_len;
85 struct osd_attr *out_attr;
87 bool reading;
89 /* Variable array of size numdevs */
90 unsigned numdevs;
91 struct ore_per_dev_state {
92 struct osd_request *or;
93 struct bio *bio;
94 loff_t offset;
95 unsigned length;
96 unsigned dev;
97 } per_dev[];
100 static inline unsigned ore_io_state_size(unsigned numdevs)
102 return sizeof(struct ore_io_state) +
103 sizeof(struct ore_per_dev_state) * numdevs;
106 /* ore.c */
107 int ore_get_rw_state(struct ore_layout *layout, struct ore_components *comps,
108 bool is_reading, u64 offset, u64 length,
109 struct ore_io_state **ios);
110 int ore_get_io_state(struct ore_layout *layout, struct ore_components *comps,
111 struct ore_io_state **ios);
112 void ore_put_io_state(struct ore_io_state *ios);
114 int ore_check_io(struct ore_io_state *ios, u64 *resid);
116 int ore_create(struct ore_io_state *ios);
117 int ore_remove(struct ore_io_state *ios);
118 int ore_write(struct ore_io_state *ios);
119 int ore_read(struct ore_io_state *ios);
120 int ore_truncate(struct ore_layout *layout, struct ore_components *comps,
121 u64 size);
123 int extract_attr_from_ios(struct ore_io_state *ios, struct osd_attr *attr);
125 extern const struct osd_attr g_attr_logical_length;
127 #endif