diff options
Diffstat (limited to 'fs/exofs/exofs.h')
-rw-r--r-- | fs/exofs/exofs.h | 104 |
1 files changed, 59 insertions, 45 deletions
diff --git a/fs/exofs/exofs.h b/fs/exofs/exofs.h index 5a77fc76433f..39ad50165162 100644 --- a/fs/exofs/exofs.h +++ b/fs/exofs/exofs.h | |||
@@ -52,9 +52,12 @@ | |||
52 | /* u64 has problems with printk this will cast it to unsigned long long */ | 52 | /* u64 has problems with printk this will cast it to unsigned long long */ |
53 | #define _LLU(x) (unsigned long long)(x) | 53 | #define _LLU(x) (unsigned long long)(x) |
54 | 54 | ||
55 | struct exofs_layout { | 55 | struct exofs_comp { |
56 | osd_id s_pid; /* partition ID of file system*/ | 56 | struct osd_obj_id obj; |
57 | u8 cred[OSD_CAP_LEN]; | ||
58 | }; | ||
57 | 59 | ||
60 | struct exofs_layout { | ||
58 | /* Our way of looking at the data_map */ | 61 | /* Our way of looking at the data_map */ |
59 | unsigned stripe_unit; | 62 | unsigned stripe_unit; |
60 | unsigned mirrors_p1; | 63 | unsigned mirrors_p1; |
@@ -62,11 +65,18 @@ struct exofs_layout { | |||
62 | unsigned group_width; | 65 | unsigned group_width; |
63 | u64 group_depth; | 66 | u64 group_depth; |
64 | unsigned group_count; | 67 | unsigned group_count; |
68 | }; | ||
65 | 69 | ||
66 | enum exofs_inode_layout_gen_functions lay_func; | 70 | struct exofs_components { |
67 | 71 | unsigned numdevs; /* Num of devices in array */ | |
68 | unsigned s_numdevs; /* Num of devices in array */ | 72 | /* If @single_comp == EC_SINGLE_COMP, @comps points to a single |
69 | struct osd_dev **s_ods; /* osd_dev array */ | 73 | * component. else there are @numdevs components |
74 | */ | ||
75 | enum EC_COMP_USAGE { | ||
76 | EC_SINGLE_COMP = 0, EC_MULTPLE_COMPS = 0xffffffff | ||
77 | } single_comp; | ||
78 | struct exofs_comp *comps; | ||
79 | struct osd_dev **ods; /* osd_dev array */ | ||
70 | }; | 80 | }; |
71 | 81 | ||
72 | /* | 82 | /* |
@@ -81,12 +91,13 @@ struct exofs_sb_info { | |||
81 | spinlock_t s_next_gen_lock; /* spinlock for gen # update */ | 91 | spinlock_t s_next_gen_lock; /* spinlock for gen # update */ |
82 | u32 s_next_generation; /* next gen # to use */ | 92 | u32 s_next_generation; /* next gen # to use */ |
83 | atomic_t s_curr_pending; /* number of pending commands */ | 93 | atomic_t s_curr_pending; /* number of pending commands */ |
84 | uint8_t s_cred[OSD_CAP_LEN]; /* credential for the fscb */ | ||
85 | 94 | ||
86 | struct pnfs_osd_data_map data_map; /* Default raid to use | 95 | struct pnfs_osd_data_map data_map; /* Default raid to use |
87 | * FIXME: Needed ? | 96 | * FIXME: Needed ? |
88 | */ | 97 | */ |
89 | struct exofs_layout layout; /* Default files layout */ | 98 | struct exofs_layout layout; /* Default files layout */ |
99 | struct exofs_comp one_comp; /* id & cred of partition id=0*/ | ||
100 | struct exofs_components comps; /* comps for the partition */ | ||
90 | struct osd_dev *_min_one_dev[1]; /* Place holder for one dev */ | 101 | struct osd_dev *_min_one_dev[1]; /* Place holder for one dev */ |
91 | }; | 102 | }; |
92 | 103 | ||
@@ -100,7 +111,8 @@ struct exofs_i_info { | |||
100 | uint32_t i_data[EXOFS_IDATA];/*short symlink names and device #s*/ | 111 | uint32_t i_data[EXOFS_IDATA];/*short symlink names and device #s*/ |
101 | uint32_t i_dir_start_lookup; /* which page to start lookup */ | 112 | uint32_t i_dir_start_lookup; /* which page to start lookup */ |
102 | uint64_t i_commit_size; /* the object's written length */ | 113 | uint64_t i_commit_size; /* the object's written length */ |
103 | uint8_t i_cred[OSD_CAP_LEN];/* all-powerful credential */ | 114 | struct exofs_comp one_comp; /* same component for all devices */ |
115 | struct exofs_components comps; /* inode view of the device table */ | ||
104 | }; | 116 | }; |
105 | 117 | ||
106 | static inline osd_id exofs_oi_objno(struct exofs_i_info *oi) | 118 | static inline osd_id exofs_oi_objno(struct exofs_i_info *oi) |
@@ -118,8 +130,7 @@ struct exofs_io_state { | |||
118 | exofs_io_done_fn done; | 130 | exofs_io_done_fn done; |
119 | 131 | ||
120 | struct exofs_layout *layout; | 132 | struct exofs_layout *layout; |
121 | struct osd_obj_id obj; | 133 | struct exofs_components *comps; |
122 | u8 *cred; | ||
123 | 134 | ||
124 | /* Global read/write IO*/ | 135 | /* Global read/write IO*/ |
125 | loff_t offset; | 136 | loff_t offset; |
@@ -200,20 +211,6 @@ static inline struct exofs_i_info *exofs_i(struct inode *inode) | |||
200 | } | 211 | } |
201 | 212 | ||
202 | /* | 213 | /* |
203 | * Given a layout, object_number and stripe_index return the associated global | ||
204 | * dev_index | ||
205 | */ | ||
206 | unsigned exofs_layout_od_id(struct exofs_layout *layout, | ||
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 | |||
216 | /* | ||
217 | * Maximum count of links to a file | 214 | * Maximum count of links to a file |
218 | */ | 215 | */ |
219 | #define EXOFS_LINK_MAX 32000 | 216 | #define EXOFS_LINK_MAX 32000 |
@@ -223,10 +220,13 @@ static inline struct osd_dev *exofs_ios_od(struct exofs_io_state *ios, | |||
223 | *************************/ | 220 | *************************/ |
224 | 221 | ||
225 | /* ios.c */ | 222 | /* ios.c */ |
226 | int exofs_get_rw_state(struct exofs_layout *layout, bool is_reading, | 223 | int exofs_get_rw_state(struct exofs_layout *layout, |
227 | u64 offset, u64 length, struct exofs_io_state **ios); | 224 | struct exofs_components *comps, |
228 | int exofs_get_io_state(struct exofs_layout *layout, | 225 | bool is_reading, u64 offset, u64 length, |
229 | struct exofs_io_state **ios); | 226 | struct exofs_io_state **ios); |
227 | int exofs_get_io_state(struct exofs_layout *layout, | ||
228 | struct exofs_components *comps, | ||
229 | struct exofs_io_state **ios); | ||
230 | void exofs_put_io_state(struct exofs_io_state *ios); | 230 | void exofs_put_io_state(struct exofs_io_state *ios); |
231 | 231 | ||
232 | int exofs_check_io(struct exofs_io_state *ios, u64 *resid); | 232 | int exofs_check_io(struct exofs_io_state *ios, u64 *resid); |
@@ -235,27 +235,12 @@ int exofs_sbi_create(struct exofs_io_state *ios); | |||
235 | int exofs_sbi_remove(struct exofs_io_state *ios); | 235 | int exofs_sbi_remove(struct exofs_io_state *ios); |
236 | int exofs_sbi_write(struct exofs_io_state *ios); | 236 | int exofs_sbi_write(struct exofs_io_state *ios); |
237 | int exofs_sbi_read(struct exofs_io_state *ios); | 237 | int exofs_sbi_read(struct exofs_io_state *ios); |
238 | int exofs_truncate(struct exofs_layout *layout, struct exofs_components *comps, | ||
239 | u64 size); | ||
238 | 240 | ||
239 | int extract_attr_from_ios(struct exofs_io_state *ios, struct osd_attr *attr); | 241 | int extract_attr_from_ios(struct exofs_io_state *ios, struct osd_attr *attr); |
240 | extern const struct osd_attr g_attr_logical_length; | 242 | extern const struct osd_attr g_attr_logical_length; |
241 | 243 | ||
242 | int exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len); | ||
243 | static inline int exofs_oi_write(struct exofs_i_info *oi, | ||
244 | struct exofs_io_state *ios) | ||
245 | { | ||
246 | ios->obj.id = exofs_oi_objno(oi); | ||
247 | ios->cred = oi->i_cred; | ||
248 | return exofs_sbi_write(ios); | ||
249 | } | ||
250 | |||
251 | static inline int exofs_oi_read(struct exofs_i_info *oi, | ||
252 | struct exofs_io_state *ios) | ||
253 | { | ||
254 | ios->obj.id = exofs_oi_objno(oi); | ||
255 | ios->cred = oi->i_cred; | ||
256 | return exofs_sbi_read(ios); | ||
257 | } | ||
258 | |||
259 | /* inode.c */ | 244 | /* inode.c */ |
260 | unsigned exofs_max_io_pages(struct exofs_layout *layout, | 245 | unsigned exofs_max_io_pages(struct exofs_layout *layout, |
261 | unsigned expected_pages); | 246 | unsigned expected_pages); |
@@ -307,4 +292,33 @@ extern const struct inode_operations exofs_special_inode_operations; | |||
307 | extern const struct inode_operations exofs_symlink_inode_operations; | 292 | extern const struct inode_operations exofs_symlink_inode_operations; |
308 | extern const struct inode_operations exofs_fast_symlink_inode_operations; | 293 | extern const struct inode_operations exofs_fast_symlink_inode_operations; |
309 | 294 | ||
295 | /* exofs_init_comps will initialize an exofs_components device array | ||
296 | * pointing to a single exofs_comp struct, and a round-robin view | ||
297 | * of the device table. | ||
298 | * The first device of each inode is the [inode->ino % num_devices] | ||
299 | * and the rest of the devices sequentially following where the | ||
300 | * first device is after the last device. | ||
301 | * It is assumed that the global device array at @sbi is twice | ||
302 | * bigger and that the device table repeats twice. | ||
303 | * See: exofs_read_lookup_dev_table() | ||
304 | */ | ||
305 | static inline void exofs_init_comps(struct exofs_components *comps, | ||
306 | struct exofs_comp *one_comp, | ||
307 | struct exofs_sb_info *sbi, osd_id oid) | ||
308 | { | ||
309 | unsigned dev_mod = (unsigned)oid, first_dev; | ||
310 | |||
311 | one_comp->obj.partition = sbi->one_comp.obj.partition; | ||
312 | one_comp->obj.id = oid; | ||
313 | exofs_make_credential(one_comp->cred, &one_comp->obj); | ||
314 | |||
315 | comps->numdevs = sbi->comps.numdevs; | ||
316 | comps->single_comp = EC_SINGLE_COMP; | ||
317 | comps->comps = one_comp; | ||
318 | |||
319 | /* Round robin device view of the table */ | ||
320 | first_dev = (dev_mod * sbi->layout.mirrors_p1) % sbi->comps.numdevs; | ||
321 | comps->ods = sbi->comps.ods + first_dev; | ||
322 | } | ||
323 | |||
310 | #endif | 324 | #endif |