diff options
| author | Boaz Harrosh <bharrosh@panasas.com> | 2011-05-16 08:26:47 -0400 |
|---|---|---|
| committer | Boaz Harrosh <bharrosh@panasas.com> | 2011-08-06 22:35:31 -0400 |
| commit | 85e44df4748670a1a7d8441b2d75843cdebc478a (patch) | |
| tree | c5bc0cdf7dad56cc6f3a38f99c88f62325a1e029 | |
| parent | e1042ba0991aab80ced34f7dade6ec25f22b4304 (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>
| -rw-r--r-- | fs/exofs/exofs.h | 17 | ||||
| -rw-r--r-- | fs/exofs/inode.c | 3 | ||||
| -rw-r--r-- | fs/exofs/ios.c | 64 | ||||
| -rw-r--r-- | fs/exofs/super.c | 68 |
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 | */ |
| 206 | unsigned exofs_layout_od_id(struct exofs_layout *layout, | 206 | unsigned 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 | |||
| 209 | static 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 */ |
| 218 | void exofs_make_credential(u8 cred_a[OSD_CAP_LEN], | ||
| 219 | const struct osd_obj_id *obj); | ||
| 220 | int exofs_read_kern(struct osd_dev *od, u8 *cred, struct osd_obj_id *obj, | ||
| 221 | u64 offset, void *p, unsigned length); | ||
| 222 | |||
| 223 | int exofs_get_rw_state(struct exofs_layout *layout, bool is_reading, | 226 | int 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); |
| 225 | int exofs_get_io_state(struct exofs_layout *layout, | 228 | int exofs_get_io_state(struct exofs_layout *layout, |
| @@ -234,6 +237,7 @@ int exofs_sbi_write(struct exofs_io_state *ios); | |||
| 234 | int exofs_sbi_read(struct exofs_io_state *ios); | 237 | int exofs_sbi_read(struct exofs_io_state *ios); |
| 235 | 238 | ||
| 236 | int extract_attr_from_ios(struct exofs_io_state *ios, struct osd_attr *attr); | 239 | int extract_attr_from_ios(struct exofs_io_state *ios, struct osd_attr *attr); |
| 240 | extern const struct osd_attr g_attr_logical_length; | ||
| 237 | 241 | ||
| 238 | int exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len); | 242 | int exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len); |
| 239 | static inline int exofs_oi_write(struct exofs_i_info *oi, | 243 | static 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 */ |
| 285 | void exofs_make_credential(u8 cred_a[OSD_CAP_LEN], | ||
| 286 | const struct osd_obj_id *obj); | ||
| 281 | int exofs_sbi_write_stats(struct exofs_sb_info *sbi); | 287 | int 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 */ |
| 294 | extern const struct address_space_operations exofs_aops; | 300 | extern const struct address_space_operations exofs_aops; |
| 295 | extern const struct osd_attr g_attr_logical_length; | ||
| 296 | 301 | ||
| 297 | /* namei.c */ | 302 | /* namei.c */ |
| 298 | extern const struct inode_operations exofs_dir_inode_operations; | 303 | extern 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 | ||
| 855 | const struct osd_attr g_attr_logical_length = ATTR_DEF( | ||
| 856 | OSD_APAGE_OBJECT_INFORMATION, OSD_ATTR_OI_LOGICAL_LENGTH, 8); | ||
| 857 | |||
| 858 | static int _do_truncate(struct inode *inode, loff_t newsize) | 855 | static 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 | ||
| 34 | void 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 | |||
| 39 | int 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 | |||
| 67 | out: | ||
| 68 | osd_end_request(or); | ||
| 69 | return ret; | ||
| 70 | } | ||
| 71 | |||
| 72 | int exofs_get_rw_state(struct exofs_layout *layout, bool is_reading, | 34 | int 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 | ||
| 122 | unsigned 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 | |||
| 138 | static 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 | |||
| 145 | static void _sync_done(struct exofs_io_state *ios, void *p) | 84 | static 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 | |||
| 787 | const 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 | *****************************************************************************/ |
| 213 | static const struct super_operations exofs_sops; | 215 | void exofs_make_credential(u8 cred_a[OSD_CAP_LEN], const struct osd_obj_id *obj) |
| 214 | static const struct export_operations exofs_export_ops; | 216 | { |
| 217 | osd_sec_init_nosec_doall_caps(cred_a, obj, false, true); | ||
| 218 | } | ||
| 219 | |||
| 220 | static 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 | |||
| 248 | out: | ||
| 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 | |||
| 256 | unsigned 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 | ||
| 216 | static const struct osd_attr g_attr_sb_stats = ATTR_DEF( | 272 | static 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 | *****************************************************************************/ | ||
| 370 | static const struct super_operations exofs_sops; | ||
| 371 | static 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 | */ |
