Blame view

include/scsi/osd_ore.h 5.31 KB
8ff660ab8   Boaz Harrosh   exofs: Rename rai...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
  /*
   * Copyright (C) 2011
   * Boaz Harrosh <bharrosh@panasas.com>
   *
   * Public Declarations of the ORE API
   *
   * This file is part of the ORE (Object Raid Engine) library.
   *
   * ORE is free software; you can redistribute it and/or modify
   * it under the terms of the GNU General Public License version 2 as published
   * by the Free Software Foundation. (GPL v2)
   *
   * ORE is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   * GNU General Public License for more details.
   *
   * You should have received a copy of the GNU General Public License
   * along with the ORE; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   */
  #ifndef __ORE_H__
  #define __ORE_H__
  
  #include <scsi/osd_initiator.h>
  #include <scsi/osd_attributes.h>
  #include <scsi/osd_sec.h>
  #include <linux/pnfs_osd_xdr.h>
  
  struct ore_comp {
  	struct osd_obj_id	obj;
  	u8			cred[OSD_CAP_LEN];
  };
  
  struct ore_layout {
  	/* Our way of looking at the data_map */
8d2d83a83   Boaz Harrosh   exofs: Remove unu...
37
38
  	enum pnfs_osd_raid_algorithm4
  		 raid_algorithm;
8ff660ab8   Boaz Harrosh   exofs: Rename rai...
39
40
41
42
  	unsigned stripe_unit;
  	unsigned mirrors_p1;
  
  	unsigned group_width;
a1fec1dbb   Boaz Harrosh   ore: RAID5 read
43
  	unsigned parity;
8ff660ab8   Boaz Harrosh   exofs: Rename rai...
44
45
  	u64	 group_depth;
  	unsigned group_count;
5a51c0c7e   Boaz Harrosh   ore/exofs: Define...
46
47
48
49
50
51
52
  
  	/* Cached often needed calculations filled in by
  	 * ore_verify_layout
  	 */
  	unsigned long max_io_length;	/* Max length that should be passed to
  					 * ore_get_rw_state
  					 */
8ff660ab8   Boaz Harrosh   exofs: Rename rai...
53
  };
d866d875f   Boaz Harrosh   ore/exofs: Change...
54
55
56
  struct ore_dev {
  	struct osd_dev *od;
  };
8ff660ab8   Boaz Harrosh   exofs: Rename rai...
57
  struct ore_components {
3bd985685   Boaz Harrosh   ore: Support for ...
58
  	unsigned	first_dev;		/* First logical device no    */
8ff660ab8   Boaz Harrosh   exofs: Rename rai...
59
60
61
62
63
64
65
66
  	unsigned	numdevs;		/* Num of devices in array    */
  	/* If @single_comp == EC_SINGLE_COMP, @comps points to a single
  	 * component. else there are @numdevs components
  	 */
  	enum EC_COMP_USAGE {
  		EC_SINGLE_COMP = 0, EC_MULTPLE_COMPS = 0xffffffff
  	}		single_comp;
  	struct ore_comp	*comps;
d866d875f   Boaz Harrosh   ore/exofs: Change...
67
68
69
70
71
72
73
  
  	/* Array of pointers to ore_dev-* . User will usually have these pointed
  	 * too a bigger struct which contain an "ore_dev ored" member and use
  	 * container_of(oc->ods[i], struct foo_dev, ored) to access the bigger
  	 * structure.
  	 */
  	struct ore_dev	**ods;
8ff660ab8   Boaz Harrosh   exofs: Rename rai...
74
  };
d866d875f   Boaz Harrosh   ore/exofs: Change...
75
76
77
78
  /* ore_comp_dev Recievies a logical device index */
  static inline struct osd_dev *ore_comp_dev(
  	const struct ore_components *oc, unsigned i)
  {
3bd985685   Boaz Harrosh   ore: Support for ...
79
80
  	BUG_ON((i < oc->first_dev) || (oc->first_dev + oc->numdevs <= i));
  	return oc->ods[i - oc->first_dev]->od;
d866d875f   Boaz Harrosh   ore/exofs: Change...
81
82
83
84
85
  }
  
  static inline void ore_comp_set_dev(
  	struct ore_components *oc, unsigned i, struct osd_dev *od)
  {
3bd985685   Boaz Harrosh   ore: Support for ...
86
  	oc->ods[i - oc->first_dev]->od = od;
d866d875f   Boaz Harrosh   ore/exofs: Change...
87
  }
eb507bc18   Boaz Harrosh   ore: Make ore_str...
88
  struct ore_striping_info {
a1fec1dbb   Boaz Harrosh   ore: RAID5 read
89
  	u64 offset;
eb507bc18   Boaz Harrosh   ore: Make ore_str...
90
  	u64 obj_offset;
a1fec1dbb   Boaz Harrosh   ore: RAID5 read
91
92
  	u64 length;
  	u64 first_stripe_start; /* only used in raid writes */
eb507bc18   Boaz Harrosh   ore: Make ore_str...
93
  	u64 M; /* for truncate */
a1fec1dbb   Boaz Harrosh   ore: RAID5 read
94
  	unsigned bytes_in_stripe;
eb507bc18   Boaz Harrosh   ore: Make ore_str...
95
  	unsigned dev;
a1fec1dbb   Boaz Harrosh   ore: RAID5 read
96
  	unsigned par_dev;
eb507bc18   Boaz Harrosh   ore: Make ore_str...
97
  	unsigned unit_off;
769ba8d92   Boaz Harrosh   ore: RAID5 Write
98
  	unsigned cur_pg;
a1fec1dbb   Boaz Harrosh   ore: RAID5 read
99
  	unsigned cur_comp;
eb507bc18   Boaz Harrosh   ore: Make ore_str...
100
  };
8ff660ab8   Boaz Harrosh   exofs: Rename rai...
101
102
  struct ore_io_state;
  typedef void (*ore_io_done_fn)(struct ore_io_state *ios, void *private);
769ba8d92   Boaz Harrosh   ore: RAID5 Write
103
104
105
106
107
  struct _ore_r4w_op {
  	/* @Priv given here is passed ios->private */
  	struct page * (*get_page)(void *priv, u64 page_index, bool *uptodate);
  	void (*put_page)(void *priv, struct page *page);
  };
8ff660ab8   Boaz Harrosh   exofs: Rename rai...
108
109
110
  
  struct ore_io_state {
  	struct kref		kref;
982607540   Boaz Harrosh   ore: cleanup: Emb...
111
  	struct ore_striping_info si;
8ff660ab8   Boaz Harrosh   exofs: Rename rai...
112
113
114
115
116
  
  	void			*private;
  	ore_io_done_fn	done;
  
  	struct ore_layout	*layout;
5bf696dad   Boaz Harrosh   exofs: Rename str...
117
  	struct ore_components	*oc;
8ff660ab8   Boaz Harrosh   exofs: Rename rai...
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
  
  	/* Global read/write IO*/
  	loff_t			offset;
  	unsigned long		length;
  	void			*kern_buff;
  
  	struct page		**pages;
  	unsigned		nr_pages;
  	unsigned		pgbase;
  	unsigned		pages_consumed;
  
  	/* Attributes */
  	unsigned		in_attr_len;
  	struct osd_attr		*in_attr;
  	unsigned		out_attr_len;
  	struct osd_attr		*out_attr;
  
  	bool			reading;
a1fec1dbb   Boaz Harrosh   ore: RAID5 read
136
137
138
139
140
141
  	/* House keeping of Parity pages */
  	bool			extra_part_alloc;
  	struct page		**parity_pages;
  	unsigned		max_par_pages;
  	unsigned		cur_par_page;
  	unsigned		sgs_per_dev;
769ba8d92   Boaz Harrosh   ore: RAID5 Write
142
143
144
  	struct __stripe_pages_2d *sp2d;
  	struct ore_io_state	 *ios_read_4_write;
  	const struct _ore_r4w_op *r4w;
a1fec1dbb   Boaz Harrosh   ore: RAID5 read
145

8ff660ab8   Boaz Harrosh   exofs: Rename rai...
146
147
148
149
150
151
152
  	/* Variable array of size numdevs */
  	unsigned numdevs;
  	struct ore_per_dev_state {
  		struct osd_request *or;
  		struct bio *bio;
  		loff_t offset;
  		unsigned length;
a1fec1dbb   Boaz Harrosh   ore: RAID5 read
153
  		unsigned last_sgs_total;
8ff660ab8   Boaz Harrosh   exofs: Rename rai...
154
  		unsigned dev;
a1fec1dbb   Boaz Harrosh   ore: RAID5 read
155
156
  		struct osd_sg_entry *sglist;
  		unsigned cur_sg;
8ff660ab8   Boaz Harrosh   exofs: Rename rai...
157
158
159
160
161
162
163
164
165
166
  	} per_dev[];
  };
  
  static inline unsigned ore_io_state_size(unsigned numdevs)
  {
  	return sizeof(struct ore_io_state) +
  		sizeof(struct ore_per_dev_state) * numdevs;
  }
  
  /* ore.c */
5a51c0c7e   Boaz Harrosh   ore/exofs: Define...
167
  int ore_verify_layout(unsigned total_comps, struct ore_layout *layout);
611d7a5dc   Boaz Harrosh   ore: Make ore_cal...
168
  void ore_calc_stripe_info(struct ore_layout *layout, u64 file_offset,
a1fec1dbb   Boaz Harrosh   ore: RAID5 read
169
  			  u64 length, struct ore_striping_info *si);
8ff660ab8   Boaz Harrosh   exofs: Rename rai...
170
171
172
173
174
175
  int ore_get_rw_state(struct ore_layout *layout, struct ore_components *comps,
  		     bool is_reading, u64 offset, u64 length,
  		     struct ore_io_state **ios);
  int ore_get_io_state(struct ore_layout *layout, struct ore_components *comps,
  		     struct ore_io_state **ios);
  void ore_put_io_state(struct ore_io_state *ios);
4b46c9f5c   Boaz Harrosh   ore/exofs: Change...
176
177
178
179
  typedef void (*ore_on_dev_error)(struct ore_io_state *ios, struct ore_dev *od,
  	unsigned dev_index, enum osd_err_priority oep,
  	u64 dev_offset, u64  dev_len);
  int ore_check_io(struct ore_io_state *ios, ore_on_dev_error rep);
8ff660ab8   Boaz Harrosh   exofs: Rename rai...
180
181
182
183
184
185
186
187
188
189
190
191
192
  
  int ore_create(struct ore_io_state *ios);
  int ore_remove(struct ore_io_state *ios);
  int ore_write(struct ore_io_state *ios);
  int ore_read(struct ore_io_state *ios);
  int ore_truncate(struct ore_layout *layout, struct ore_components *comps,
  		 u64 size);
  
  int extract_attr_from_ios(struct ore_io_state *ios, struct osd_attr *attr);
  
  extern const struct osd_attr g_attr_logical_length;
  
  #endif