diff options
author | Boaz Harrosh <bharrosh@panasas.com> | 2009-11-08 07:54:08 -0500 |
---|---|---|
committer | Boaz Harrosh <bharrosh@panasas.com> | 2009-12-10 02:59:22 -0500 |
commit | 06886a5a3dc5a5abe0a4d257c26317bde7047be8 (patch) | |
tree | 858ac56e120c0473d764fc64a2660e6d79729c8c /fs/exofs/exofs.h | |
parent | 8ce9bdd1fbe962933736d7977e972972cd5d754c (diff) |
exofs: Move all operations to an io_engine
In anticipation for multi-device operations, we separate osd operations
into an abstract I/O API. Currently only one device is used but later
when adding more devices, we will drive all devices in parallel according
to a "data_map" that describes how data is arranged on multiple devices.
The file system level operates, like before, as if there is one object
(inode-number) and an i_size. The io engine will split this to the same
object-number but on multiple device.
At first we introduce Mirror (raid 1) layout. But at the final outcome
we intend to fully implement the pNFS-Objects data-map, including
raid 0,4,5,6 over mirrored devices, over multiple device-groups. And
more. See: http://tools.ietf.org/html/draft-ietf-nfsv4-pnfs-obj-12
* Define an io_state based API for accessing osd storage devices
in an abstract way.
Usage:
First a caller allocates an io state with:
exofs_get_io_state(struct exofs_sb_info *sbi,
struct exofs_io_state** ios);
Then calles one of:
exofs_sbi_create(struct exofs_io_state *ios);
exofs_sbi_remove(struct exofs_io_state *ios);
exofs_sbi_write(struct exofs_io_state *ios);
exofs_sbi_read(struct exofs_io_state *ios);
exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
And when done
exofs_put_io_state(struct exofs_io_state *ios);
* Convert all source files to use this new API
* Convert from bio_alloc to bio_kmalloc
* In io engine we make use of the now fixed osd_req_decode_sense
There are no functional changes or on disk additions after this patch.
Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Diffstat (limited to 'fs/exofs/exofs.h')
-rw-r--r-- | fs/exofs/exofs.h | 87 |
1 files changed, 84 insertions, 3 deletions
diff --git a/fs/exofs/exofs.h b/fs/exofs/exofs.h index 5ec72e020b22..2e08859a89e8 100644 --- a/fs/exofs/exofs.h +++ b/fs/exofs/exofs.h | |||
@@ -30,14 +30,13 @@ | |||
30 | * along with exofs; if not, write to the Free Software | 30 | * along with exofs; if not, write to the Free Software |
31 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | 31 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
32 | */ | 32 | */ |
33 | #ifndef __EXOFS_H__ | ||
34 | #define __EXOFS_H__ | ||
33 | 35 | ||
34 | #include <linux/fs.h> | 36 | #include <linux/fs.h> |
35 | #include <linux/time.h> | 37 | #include <linux/time.h> |
36 | #include "common.h" | 38 | #include "common.h" |
37 | 39 | ||
38 | #ifndef __EXOFS_H__ | ||
39 | #define __EXOFS_H__ | ||
40 | |||
41 | #define EXOFS_ERR(fmt, a...) printk(KERN_ERR "exofs: " fmt, ##a) | 40 | #define EXOFS_ERR(fmt, a...) printk(KERN_ERR "exofs: " fmt, ##a) |
42 | 41 | ||
43 | #ifdef CONFIG_EXOFS_DEBUG | 42 | #ifdef CONFIG_EXOFS_DEBUG |
@@ -56,6 +55,7 @@ | |||
56 | */ | 55 | */ |
57 | struct exofs_sb_info { | 56 | struct exofs_sb_info { |
58 | struct osd_dev *s_dev; /* returned by get_osd_dev */ | 57 | struct osd_dev *s_dev; /* returned by get_osd_dev */ |
58 | struct exofs_fscb s_fscb; /* Written often, pre-allocate*/ | ||
59 | osd_id s_pid; /* partition ID of file system*/ | 59 | osd_id s_pid; /* partition ID of file system*/ |
60 | int s_timeout; /* timeout for OSD operations */ | 60 | int s_timeout; /* timeout for OSD operations */ |
61 | uint64_t s_nextid; /* highest object ID used */ | 61 | uint64_t s_nextid; /* highest object ID used */ |
@@ -79,6 +79,50 @@ struct exofs_i_info { | |||
79 | struct inode vfs_inode; /* normal in-memory inode */ | 79 | struct inode vfs_inode; /* normal in-memory inode */ |
80 | }; | 80 | }; |
81 | 81 | ||
82 | static inline osd_id exofs_oi_objno(struct exofs_i_info *oi) | ||
83 | { | ||
84 | return oi->vfs_inode.i_ino + EXOFS_OBJ_OFF; | ||
85 | } | ||
86 | |||
87 | struct exofs_io_state; | ||
88 | typedef void (*exofs_io_done_fn)(struct exofs_io_state *or, void *private); | ||
89 | |||
90 | struct exofs_io_state { | ||
91 | struct kref kref; | ||
92 | |||
93 | void *private; | ||
94 | exofs_io_done_fn done; | ||
95 | |||
96 | struct exofs_sb_info *sbi; | ||
97 | struct osd_obj_id obj; | ||
98 | u8 *cred; | ||
99 | |||
100 | /* Global read/write IO*/ | ||
101 | loff_t offset; | ||
102 | unsigned long length; | ||
103 | void *kern_buff; | ||
104 | struct bio *bio; | ||
105 | |||
106 | /* Attributes */ | ||
107 | unsigned in_attr_len; | ||
108 | struct osd_attr *in_attr; | ||
109 | unsigned out_attr_len; | ||
110 | struct osd_attr *out_attr; | ||
111 | |||
112 | /* Variable array of size numdevs */ | ||
113 | unsigned numdevs; | ||
114 | struct exofs_per_dev_state { | ||
115 | struct osd_request *or; | ||
116 | struct bio *bio; | ||
117 | } per_dev[]; | ||
118 | }; | ||
119 | |||
120 | static inline unsigned exofs_io_state_size(unsigned numdevs) | ||
121 | { | ||
122 | return sizeof(struct exofs_io_state) + | ||
123 | sizeof(struct exofs_per_dev_state) * numdevs; | ||
124 | } | ||
125 | |||
82 | /* | 126 | /* |
83 | * our inode flags | 127 | * our inode flags |
84 | */ | 128 | */ |
@@ -130,6 +174,42 @@ static inline struct exofs_i_info *exofs_i(struct inode *inode) | |||
130 | /************************* | 174 | /************************* |
131 | * function declarations * | 175 | * function declarations * |
132 | *************************/ | 176 | *************************/ |
177 | |||
178 | /* ios.c */ | ||
179 | void exofs_make_credential(u8 cred_a[OSD_CAP_LEN], | ||
180 | const struct osd_obj_id *obj); | ||
181 | int exofs_read_kern(struct osd_dev *od, u8 *cred, struct osd_obj_id *obj, | ||
182 | u64 offset, void *p, unsigned length); | ||
183 | |||
184 | int exofs_get_io_state(struct exofs_sb_info *sbi, struct exofs_io_state** ios); | ||
185 | void exofs_put_io_state(struct exofs_io_state *ios); | ||
186 | |||
187 | int exofs_check_io(struct exofs_io_state *ios, u64 *resid); | ||
188 | |||
189 | int exofs_sbi_create(struct exofs_io_state *ios); | ||
190 | int exofs_sbi_remove(struct exofs_io_state *ios); | ||
191 | int exofs_sbi_write(struct exofs_io_state *ios); | ||
192 | int exofs_sbi_read(struct exofs_io_state *ios); | ||
193 | |||
194 | int extract_attr_from_ios(struct exofs_io_state *ios, struct osd_attr *attr); | ||
195 | |||
196 | int exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len); | ||
197 | static inline int exofs_oi_write(struct exofs_i_info *oi, | ||
198 | struct exofs_io_state *ios) | ||
199 | { | ||
200 | ios->obj.id = exofs_oi_objno(oi); | ||
201 | ios->cred = oi->i_cred; | ||
202 | return exofs_sbi_write(ios); | ||
203 | } | ||
204 | |||
205 | static inline int exofs_oi_read(struct exofs_i_info *oi, | ||
206 | struct exofs_io_state *ios) | ||
207 | { | ||
208 | ios->obj.id = exofs_oi_objno(oi); | ||
209 | ios->cred = oi->i_cred; | ||
210 | return exofs_sbi_read(ios); | ||
211 | } | ||
212 | |||
133 | /* inode.c */ | 213 | /* inode.c */ |
134 | void exofs_truncate(struct inode *inode); | 214 | void exofs_truncate(struct inode *inode); |
135 | int exofs_setattr(struct dentry *, struct iattr *); | 215 | int exofs_setattr(struct dentry *, struct iattr *); |
@@ -169,6 +249,7 @@ extern const struct file_operations exofs_file_operations; | |||
169 | 249 | ||
170 | /* inode.c */ | 250 | /* inode.c */ |
171 | extern const struct address_space_operations exofs_aops; | 251 | extern const struct address_space_operations exofs_aops; |
252 | extern const struct osd_attr g_attr_logical_length; | ||
172 | 253 | ||
173 | /* namei.c */ | 254 | /* namei.c */ |
174 | extern const struct inode_operations exofs_dir_inode_operations; | 255 | extern const struct inode_operations exofs_dir_inode_operations; |