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
Unified · Split
| @@ -205,6 +205,14 @@ static inline struct exofs_i_info *exofs_i(struct inode *inode) · 204 unmodified lines | ||
| 205 | 205 | */ |
| 206 | 206 | unsigned exofs_layout_od_id(struct exofs_layout *layout, |
| 207 | 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 | 217 | * Maximum count of links to a file |
| 210 | 218 | */ |
| @@ -215,11 +223,6 @@ unsigned exofs_layout_od_id(struct exofs_layout *layout, · 4 unmodified lines | ||
| 215 | 223 | *************************/ |
| 216 | 224 | |
| 217 | 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 | 226 | int exofs_get_rw_state(struct exofs_layout *layout, bool is_reading, |
| 224 | 227 | u64 offset, u64 length, struct exofs_io_state **ios); |
| 225 | 228 | int exofs_get_io_state(struct exofs_layout *layout, |
| @@ -234,6 +237,7 @@ int exofs_sbi_write(struct exofs_io_state *ios); · 8 unmodified lines | ||
| 234 | 237 | int exofs_sbi_read(struct exofs_io_state *ios); |
| 235 | 238 | |
| 236 | 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 | 242 | int exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len); |
| 239 | 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 *, · 38 unmodified lines | ||
| 278 | 282 | struct inode *); |
| 279 | 283 | |
| 280 | 284 | /* super.c */ |
| 285 | +void exofs_make_credential(u8 cred_a[OSD_CAP_LEN], | |
| 286 | + const struct osd_obj_id *obj); | |
| 281 | 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; · 8 unmodified lines | ||
| 292 | 298 | |
| 293 | 299 | /* inode.c */ |
| 294 | 300 | extern const struct address_space_operations exofs_aops; |
| 295 | −extern const struct osd_attr g_attr_logical_length; | |
| 296 | 301 | |
| 297 | 302 | /* namei.c */ |
| 298 | 303 | extern const struct inode_operations exofs_dir_inode_operations; |
| @@ -852,9 +852,6 @@ static inline int exofs_inode_is_fast_symlink(struct inode *inode) · 851 unmodified lines | ||
| 852 | 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 | 855 | static int _do_truncate(struct inode *inode, loff_t newsize) |
| 859 | 856 | { |
| 860 | 857 | struct exofs_i_info *oi = exofs_i(inode); |
| @@ -31,44 +31,6 @@ · 30 unmodified lines | ||
| 31 | 31 | #define EXOFS_DBGMSG2(M...) do {} while (0) |
| 32 | 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 | 34 | int exofs_get_rw_state(struct exofs_layout *layout, bool is_reading, |
| 73 | 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) · 44 unmodified lines | ||
| 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 | 84 | static void _sync_done(struct exofs_io_state *ios, void *p) |
| 146 | 85 | { |
| 147 | 86 | struct completion *waiting = p; |
| @@ -844,3 +783,6 @@ out: · 696 unmodified lines | ||
| 844 | 783 | exofs_put_io_state(ios); |
| 845 | 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); | |
| @@ -40,6 +40,8 @@ · 39 unmodified lines | ||
| 40 | 40 | |
| 41 | 41 | #include "exofs.h" |
| 42 | 42 | |
| 43 | +#define EXOFS_DBGMSG2(M...) do {} while (0) | |
| 44 | + | |
| 43 | 45 | /****************************************************************************** |
| 44 | 46 | * MOUNT OPTIONS |
| 45 | 47 | *****************************************************************************/ |
| @@ -208,10 +210,64 @@ static void destroy_inodecache(void) · 162 unmodified lines | ||
| 208 | 210 | } |
| 209 | 211 | |
| 210 | 212 | /****************************************************************************** |
| 211 | − * SUPERBLOCK FUNCTIONS | |
| 213 | + * Some osd helpers | |
| 212 | 214 | *****************************************************************************/ |
| 213 | −static const struct super_operations exofs_sops; | |
| 214 | −static const struct export_operations exofs_export_ops; | |
| 215 | +void exofs_make_credential(u8 cred_a[OSD_CAP_LEN], const struct osd_obj_id *obj) | |
| 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 | 272 | static const struct osd_attr g_attr_sb_stats = ATTR_DEF( |
| 217 | 273 | EXOFS_APAGE_SB_DATA, |
| @@ -308,6 +364,12 @@ int exofs_sbi_write_stats(struct exofs_sb_info *sbi) · 90 unmodified lines | ||
| 308 | 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 | 374 | * Write the superblock to the OSD |
| 313 | 375 | */ |