aboutsummaryrefslogtreecommitdiffstats
path: root/fs/exofs/exofs.h
diff options
context:
space:
mode:
authorBoaz Harrosh <bharrosh@panasas.com>2011-08-05 18:06:04 -0400
committerBoaz Harrosh <bharrosh@panasas.com>2011-08-06 22:35:32 -0400
commit9e9db45649eb5d3ee5622fdad741914ecf1016a0 (patch)
tree19ab9e1431e3d6535cef3f2cba6fcff12bb6ba6c /fs/exofs/exofs.h
parent85e44df4748670a1a7d8441b2d75843cdebc478a (diff)
exofs: ios: Move to a per inode components & device-table
Exofs raid engine was saving on memory space by having a single layout-info, single pid, and a single device-table, global to the filesystem. Then passing a credential and object_id info at the io_state level, private for each inode. It would also devise this contraption of rotating the device table view for each inode->ino to spread out the device usage. This is not compatible with the pnfs-objects standard, demanding that each inode can have it's own layout-info, device-table, and each object component it's own pid, oid and creds. So: Bring exofs raid engine to be usable for generic pnfs-objects use by: * Define an exofs_comp structure that holds obj_id and credential info. * Break up exofs_layout struct to an exofs_components structure that holds a possible array of exofs_comp and the array of devices + the size of the arrays. * Add a "comps" parameter to get_io_state() that specifies the ids creds and device array to use for each IO. This enables to keep the layout global, but the device-table view, creds and IDs at the inode level. It only adds two 64bit to each inode, since some of these members already existed in another form. * ios raid engine now access layout-info and comps-info through the passed pointers. Everything is pre-prepared by caller for generic access of these structures and arrays. At the exofs Level: * Super block holds an exofs_components struct that holds the device array, previously in layout. The devices there are in device-table order. The device-array is twice bigger and repeats the device-table twice so now each inode's device array can point to a random device and have a round-robin view of the table, making it compatible to previous exofs versions. * Each inode has an exofs_components struct that is initialized at load time, with it's own view of the device table IDs and creds. When doing IO this gets passed to the io_state together with the layout. While preforming this change. Bugs where found where credentials with the wrong IDs where used to access the different SB objects (super.c). As well as some dead code. It was never noticed because the target we use does not check the credentials. Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
Diffstat (limited to 'fs/exofs/exofs.h')
-rw-r--r--fs/exofs/exofs.h104
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
55struct exofs_layout { 55struct 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
60struct 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; 70struct 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
106static inline osd_id exofs_oi_objno(struct exofs_i_info *oi) 118static 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 */
206unsigned exofs_layout_od_id(struct exofs_layout *layout,
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
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 */
226int exofs_get_rw_state(struct exofs_layout *layout, bool is_reading, 223int exofs_get_rw_state(struct exofs_layout *layout,
227 u64 offset, u64 length, struct exofs_io_state **ios); 224 struct exofs_components *comps,
228int 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);
227int exofs_get_io_state(struct exofs_layout *layout,
228 struct exofs_components *comps,
229 struct exofs_io_state **ios);
230void exofs_put_io_state(struct exofs_io_state *ios); 230void exofs_put_io_state(struct exofs_io_state *ios);
231 231
232int exofs_check_io(struct exofs_io_state *ios, u64 *resid); 232int exofs_check_io(struct exofs_io_state *ios, u64 *resid);
@@ -235,27 +235,12 @@ int exofs_sbi_create(struct exofs_io_state *ios);
235int exofs_sbi_remove(struct exofs_io_state *ios); 235int exofs_sbi_remove(struct exofs_io_state *ios);
236int exofs_sbi_write(struct exofs_io_state *ios); 236int exofs_sbi_write(struct exofs_io_state *ios);
237int exofs_sbi_read(struct exofs_io_state *ios); 237int exofs_sbi_read(struct exofs_io_state *ios);
238int exofs_truncate(struct exofs_layout *layout, struct exofs_components *comps,
239 u64 size);
238 240
239int extract_attr_from_ios(struct exofs_io_state *ios, struct osd_attr *attr); 241int extract_attr_from_ios(struct exofs_io_state *ios, struct osd_attr *attr);
240extern const struct osd_attr g_attr_logical_length; 242extern const struct osd_attr g_attr_logical_length;
241 243
242int exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
243static 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
251static 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 */
260unsigned exofs_max_io_pages(struct exofs_layout *layout, 245unsigned 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;
307extern const struct inode_operations exofs_symlink_inode_operations; 292extern const struct inode_operations exofs_symlink_inode_operations;
308extern const struct inode_operations exofs_fast_symlink_inode_operations; 293extern 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 */
305static 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