Linux Audio

Check our new training course

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