aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exofs
diff options
context:
space:
mode:
authorBoaz Harrosh <bharrosh@panasas.com>2011-05-16 08:26:47 -0400
committerBoaz Harrosh <bharrosh@panasas.com>2011-08-06 22:35:31 -0400
commit85e44df4748670a1a7d8441b2d75843cdebc478a (patch)
treec5bc0cdf7dad56cc6f3a38f99c88f62325a1e029 /fs/exofs
parente1042ba0991aab80ced34f7dade6ec25f22b4304 (diff)
exofs: Move exofs specific osd operations out of ios.c
ios.c will be moving to an external library, for use by the objects-layout-driver. Remove from it some exofs specific functions. Also g_attr_logical_length is used both by inode.c and ios.c move definition to the later, to keep it independent Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Diffstat (limited to 'fs/exofs')
-rw-r--r--fs/exofs/exofs.h17
-rw-r--r--fs/exofs/inode.c3
-rw-r--r--fs/exofs/ios.c64
-rw-r--r--fs/exofs/super.c68
4 files changed, 79 insertions, 73 deletions
diff --git a/fs/exofs/exofs.h b/fs/exofs/exofs.h
index fd913ddfd48b..5a77fc76433f 100644
--- a/fs/exofs/exofs.h
+++ b/fs/exofs/exofs.h
@@ -205,6 +205,14 @@ static inline struct exofs_i_info *exofs_i(struct inode *inode)
205 */ 205 */
206unsigned exofs_layout_od_id(struct exofs_layout *layout, 206unsigned exofs_layout_od_id(struct exofs_layout *layout,
207 osd_id obj_no, unsigned layout_index); 207 osd_id obj_no, unsigned layout_index);
208
209static inline struct osd_dev *exofs_ios_od(struct exofs_io_state *ios,
210 unsigned layout_index)
211{
212 return ios->layout->s_ods[
213 exofs_layout_od_id(ios->layout, ios->obj.id, layout_index)];
214}
215
208/* 216/*
209 * Maximum count of links to a file 217 * Maximum count of links to a file
210 */ 218 */
@@ -215,11 +223,6 @@ unsigned exofs_layout_od_id(struct exofs_layout *layout,
215 *************************/ 223 *************************/
216 224
217/* ios.c */ 225/* ios.c */
218void exofs_make_credential(u8 cred_a[OSD_CAP_LEN],
219 const struct osd_obj_id *obj);
220int exofs_read_kern(struct osd_dev *od, u8 *cred, struct osd_obj_id *obj,
221 u64 offset, void *p, unsigned length);
222
223int exofs_get_rw_state(struct exofs_layout *layout, bool is_reading, 226int exofs_get_rw_state(struct exofs_layout *layout, bool is_reading,
224 u64 offset, u64 length, struct exofs_io_state **ios); 227 u64 offset, u64 length, struct exofs_io_state **ios);
225int exofs_get_io_state(struct exofs_layout *layout, 228int exofs_get_io_state(struct exofs_layout *layout,
@@ -234,6 +237,7 @@ int exofs_sbi_write(struct exofs_io_state *ios);
234int exofs_sbi_read(struct exofs_io_state *ios); 237int exofs_sbi_read(struct exofs_io_state *ios);
235 238
236int extract_attr_from_ios(struct exofs_io_state *ios, struct osd_attr *attr); 239int extract_attr_from_ios(struct exofs_io_state *ios, struct osd_attr *attr);
240extern const struct osd_attr g_attr_logical_length;
237 241
238int exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len); 242int exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
239static inline int exofs_oi_write(struct exofs_i_info *oi, 243static inline int exofs_oi_write(struct exofs_i_info *oi,
@@ -278,6 +282,8 @@ int exofs_set_link(struct inode *, struct exofs_dir_entry *, struct page *,
278 struct inode *); 282 struct inode *);
279 283
280/* super.c */ 284/* super.c */
285void exofs_make_credential(u8 cred_a[OSD_CAP_LEN],
286 const struct osd_obj_id *obj);
281int exofs_sbi_write_stats(struct exofs_sb_info *sbi); 287int exofs_sbi_write_stats(struct exofs_sb_info *sbi);
282 288
283/********************* 289/*********************
@@ -292,7 +298,6 @@ extern const struct file_operations exofs_file_operations;
292 298
293/* inode.c */ 299/* inode.c */
294extern const struct address_space_operations exofs_aops; 300extern const struct address_space_operations exofs_aops;
295extern const struct osd_attr g_attr_logical_length;
296 301
297/* namei.c */ 302/* namei.c */
298extern const struct inode_operations exofs_dir_inode_operations; 303extern const struct inode_operations exofs_dir_inode_operations;
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c
index ba9f0bedcbaf..abcdac993039 100644
--- a/fs/exofs/inode.c
+++ b/fs/exofs/inode.c
@@ -852,9 +852,6 @@ static inline int exofs_inode_is_fast_symlink(struct inode *inode)
852 return S_ISLNK(inode->i_mode) && (oi->i_data[0] != 0); 852 return S_ISLNK(inode->i_mode) && (oi->i_data[0] != 0);
853} 853}
854 854
855const struct osd_attr g_attr_logical_length = ATTR_DEF(
856 OSD_APAGE_OBJECT_INFORMATION, OSD_ATTR_OI_LOGICAL_LENGTH, 8);
857
858static int _do_truncate(struct inode *inode, loff_t newsize) 855static int _do_truncate(struct inode *inode, loff_t newsize)
859{ 856{
860 struct exofs_i_info *oi = exofs_i(inode); 857 struct exofs_i_info *oi = exofs_i(inode);
diff --git a/fs/exofs/ios.c b/fs/exofs/ios.c
index 096405e51b94..21d6130b462e 100644
--- a/fs/exofs/ios.c
+++ b/fs/exofs/ios.c
@@ -31,44 +31,6 @@
31#define EXOFS_DBGMSG2(M...) do {} while (0) 31#define EXOFS_DBGMSG2(M...) do {} while (0)
32/* #define EXOFS_DBGMSG2 EXOFS_DBGMSG */ 32/* #define EXOFS_DBGMSG2 EXOFS_DBGMSG */
33 33
34void exofs_make_credential(u8 cred_a[OSD_CAP_LEN], const struct osd_obj_id *obj)
35{
36 osd_sec_init_nosec_doall_caps(cred_a, obj, false, true);
37}
38
39int exofs_read_kern(struct osd_dev *od, u8 *cred, struct osd_obj_id *obj,
40 u64 offset, void *p, unsigned length)
41{
42 struct osd_request *or = osd_start_request(od, GFP_KERNEL);
43/* struct osd_sense_info osi = {.key = 0};*/
44 int ret;
45
46 if (unlikely(!or)) {
47 EXOFS_DBGMSG("%s: osd_start_request failed.\n", __func__);
48 return -ENOMEM;
49 }
50 ret = osd_req_read_kern(or, obj, offset, p, length);
51 if (unlikely(ret)) {
52 EXOFS_DBGMSG("%s: osd_req_read_kern failed.\n", __func__);
53 goto out;
54 }
55
56 ret = osd_finalize_request(or, 0, cred, NULL);
57 if (unlikely(ret)) {
58 EXOFS_DBGMSG("Failed to osd_finalize_request() => %d\n", ret);
59 goto out;
60 }
61
62 ret = osd_execute_request(or);
63 if (unlikely(ret))
64 EXOFS_DBGMSG("osd_execute_request() => %d\n", ret);
65 /* osd_req_decode_sense(or, ret); */
66
67out:
68 osd_end_request(or);
69 return ret;
70}
71
72int exofs_get_rw_state(struct exofs_layout *layout, bool is_reading, 34int exofs_get_rw_state(struct exofs_layout *layout, bool is_reading,
73 u64 offset, u64 length, struct exofs_io_state **pios) 35 u64 offset, u64 length, struct exofs_io_state **pios)
74{ 36{
@@ -119,29 +81,6 @@ void exofs_put_io_state(struct exofs_io_state *ios)
119 } 81 }
120} 82}
121 83
122unsigned exofs_layout_od_id(struct exofs_layout *layout,
123 osd_id obj_no, unsigned layout_index)
124{
125/* switch (layout->lay_func) {
126 case LAYOUT_MOVING_WINDOW:
127 {*/
128 unsigned dev_mod = obj_no;
129
130 return (layout_index + dev_mod * layout->mirrors_p1) %
131 layout->s_numdevs;
132/* }
133 case LAYOUT_FUNC_IMPLICT:
134 return layout->devs[layout_index];
135 }*/
136}
137
138static inline struct osd_dev *exofs_ios_od(struct exofs_io_state *ios,
139 unsigned layout_index)
140{
141 return ios->layout->s_ods[
142 exofs_layout_od_id(ios->layout, ios->obj.id, layout_index)];
143}
144
145static void _sync_done(struct exofs_io_state *ios, void *p) 84static void _sync_done(struct exofs_io_state *ios, void *p)
146{ 85{
147 struct completion *waiting = p; 86 struct completion *waiting = p;
@@ -844,3 +783,6 @@ out:
844 exofs_put_io_state(ios); 783 exofs_put_io_state(ios);
845 return ret; 784 return ret;
846} 785}
786
787const struct osd_attr g_attr_logical_length = ATTR_DEF(
788 OSD_APAGE_OBJECT_INFORMATION, OSD_ATTR_OI_LOGICAL_LENGTH, 8);
diff --git a/fs/exofs/super.c b/fs/exofs/super.c
index 65fe5debe11c..8783f3d33c4a 100644
--- a/fs/exofs/super.c
+++ b/fs/exofs/super.c
@@ -40,6 +40,8 @@
40 40
41#include "exofs.h" 41#include "exofs.h"
42 42
43#define EXOFS_DBGMSG2(M...) do {} while (0)
44
43/****************************************************************************** 45/******************************************************************************
44 * MOUNT OPTIONS 46 * MOUNT OPTIONS
45 *****************************************************************************/ 47 *****************************************************************************/
@@ -208,10 +210,64 @@ static void destroy_inodecache(void)
208} 210}
209 211
210/****************************************************************************** 212/******************************************************************************
211 * SUPERBLOCK FUNCTIONS 213 * Some osd helpers
212 *****************************************************************************/ 214 *****************************************************************************/
213static const struct super_operations exofs_sops; 215void exofs_make_credential(u8 cred_a[OSD_CAP_LEN], const struct osd_obj_id *obj)
214static const struct export_operations exofs_export_ops; 216{
217 osd_sec_init_nosec_doall_caps(cred_a, obj, false, true);
218}
219
220static int exofs_read_kern(struct osd_dev *od, u8 *cred, struct osd_obj_id *obj,
221 u64 offset, void *p, unsigned length)
222{
223 struct osd_request *or = osd_start_request(od, GFP_KERNEL);
224/* struct osd_sense_info osi = {.key = 0};*/
225 int ret;
226
227 if (unlikely(!or)) {
228 EXOFS_DBGMSG("%s: osd_start_request failed.\n", __func__);
229 return -ENOMEM;
230 }
231 ret = osd_req_read_kern(or, obj, offset, p, length);
232 if (unlikely(ret)) {
233 EXOFS_DBGMSG("%s: osd_req_read_kern failed.\n", __func__);
234 goto out;
235 }
236
237 ret = osd_finalize_request(or, 0, cred, NULL);
238 if (unlikely(ret)) {
239 EXOFS_DBGMSG("Failed to osd_finalize_request() => %d\n", ret);
240 goto out;
241 }
242
243 ret = osd_execute_request(or);
244 if (unlikely(ret))
245 EXOFS_DBGMSG("osd_execute_request() => %d\n", ret);
246 /* osd_req_decode_sense(or, ret); */
247
248out:
249 osd_end_request(or);
250 EXOFS_DBGMSG2("read_kern(0x%llx) offset=0x%llx "
251 "length=0x%llx dev=%p ret=>%d\n",
252 _LLU(obj->id), _LLU(offset), _LLU(length), od, ret);
253 return ret;
254}
255
256unsigned exofs_layout_od_id(struct exofs_layout *layout,
257 osd_id obj_no, unsigned layout_index)
258{
259/* switch (layout->lay_func) {
260 case LAYOUT_MOVING_WINDOW:
261 {*/
262 unsigned dev_mod = obj_no;
263
264 return (layout_index + dev_mod * layout->mirrors_p1) %
265 layout->s_numdevs;
266/* }
267 case LAYOUT_FUNC_IMPLICT:
268 return layout->devs[layout_index];
269 }*/
270}
215 271
216static const struct osd_attr g_attr_sb_stats = ATTR_DEF( 272static const struct osd_attr g_attr_sb_stats = ATTR_DEF(
217 EXOFS_APAGE_SB_DATA, 273 EXOFS_APAGE_SB_DATA,
@@ -308,6 +364,12 @@ int exofs_sbi_write_stats(struct exofs_sb_info *sbi)
308 return ret; 364 return ret;
309} 365}
310 366
367/******************************************************************************
368 * SUPERBLOCK FUNCTIONS
369 *****************************************************************************/
370static const struct super_operations exofs_sops;
371static const struct export_operations exofs_export_ops;
372
311/* 373/*
312 * Write the superblock to the OSD 374 * Write the superblock to the OSD
313 */ 375 */