summaryrefslogtreecommitdiffstats
path: root/fs/exofs/exofs.h
diff options
context:
space:
mode:
authorBoaz Harrosh <bharrosh@panasas.com>2011-08-05 15:06:04 -0700
committerBoaz Harrosh <bharrosh@panasas.com>2011-08-06 19:35:32 -0700
commit9e9db45649eb5d3ee5622fdad741914ecf1016a0 (patch)
tree19ab9e1431e3d6535cef3f2cba6fcff12bb6ba6c /fs/exofs/exofs.h
parent85e44df4748670a1a7d8441b2d75843cdebc478a (diff)
downloadlinux-9e9db45649eb5d3ee5622fdad741914ecf1016a0.tar.gz
linux-9e9db45649eb5d3ee5622fdad741914ecf1016a0.tar.bz2
linux-9e9db45649eb5d3ee5622fdad741914ecf1016a0.zip
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 @@
/* u64 has problems with printk this will cast it to unsigned long long */
#define _LLU(x) (unsigned long long)(x)
-struct exofs_layout {
- osd_id s_pid; /* partition ID of file system*/
+struct exofs_comp {
+ struct osd_obj_id obj;
+ u8 cred[OSD_CAP_LEN];
+};
+struct exofs_layout {
/* Our way of looking at the data_map */
unsigned stripe_unit;
unsigned mirrors_p1;
@@ -62,11 +65,18 @@ struct exofs_layout {
unsigned group_width;
u64 group_depth;
unsigned group_count;
+};
- enum exofs_inode_layout_gen_functions lay_func;
-
- unsigned s_numdevs; /* Num of devices in array */
- struct osd_dev **s_ods; /* osd_dev array */
+struct exofs_components {
+ unsigned numdevs; /* Num of devices in array */
+ /* If @single_comp == EC_SINGLE_COMP, @comps points to a single
+ * component. else there are @numdevs components
+ */
+ enum EC_COMP_USAGE {
+ EC_SINGLE_COMP = 0, EC_MULTPLE_COMPS = 0xffffffff
+ } single_comp;
+ struct exofs_comp *comps;
+ struct osd_dev **ods; /* osd_dev array */
};
/*
@@ -81,12 +91,13 @@ struct exofs_sb_info {
spinlock_t s_next_gen_lock; /* spinlock for gen # update */
u32 s_next_generation; /* next gen # to use */
atomic_t s_curr_pending; /* number of pending commands */
- uint8_t s_cred[OSD_CAP_LEN]; /* credential for the fscb */
struct pnfs_osd_data_map data_map; /* Default raid to use
* FIXME: Needed ?
*/
struct exofs_layout layout; /* Default files layout */
+ struct exofs_comp one_comp; /* id & cred of partition id=0*/
+ struct exofs_components comps; /* comps for the partition */
struct osd_dev *_min_one_dev[1]; /* Place holder for one dev */
};
@@ -100,7 +111,8 @@ struct exofs_i_info {
uint32_t i_data[EXOFS_IDATA];/*short symlink names and device #s*/
uint32_t i_dir_start_lookup; /* which page to start lookup */
uint64_t i_commit_size; /* the object's written length */
- uint8_t i_cred[OSD_CAP_LEN];/* all-powerful credential */
+ struct exofs_comp one_comp; /* same component for all devices */
+ struct exofs_components comps; /* inode view of the device table */
};
static inline osd_id exofs_oi_objno(struct exofs_i_info *oi)
@@ -118,8 +130,7 @@ struct exofs_io_state {
exofs_io_done_fn done;
struct exofs_layout *layout;
- struct osd_obj_id obj;
- u8 *cred;
+ struct exofs_components *comps;
/* Global read/write IO*/
loff_t offset;
@@ -200,20 +211,6 @@ static inline struct exofs_i_info *exofs_i(struct inode *inode)
}
/*
- * Given a layout, object_number and stripe_index return the associated global
- * dev_index
- */
-unsigned exofs_layout_od_id(struct exofs_layout *layout,
- osd_id obj_no, unsigned layout_index);
-
-static inline struct osd_dev *exofs_ios_od(struct exofs_io_state *ios,
- unsigned layout_index)
-{
- return ios->layout->s_ods[
- exofs_layout_od_id(ios->layout, ios->obj.id, layout_index)];
-}
-
-/*
* Maximum count of links to a file
*/
#define EXOFS_LINK_MAX 32000
@@ -223,10 +220,13 @@ static inline struct osd_dev *exofs_ios_od(struct exofs_io_state *ios,
*************************/
/* ios.c */
-int exofs_get_rw_state(struct exofs_layout *layout, bool is_reading,
- u64 offset, u64 length, struct exofs_io_state **ios);
-int exofs_get_io_state(struct exofs_layout *layout,
- struct exofs_io_state **ios);
+int exofs_get_rw_state(struct exofs_layout *layout,
+ struct exofs_components *comps,
+ bool is_reading, u64 offset, u64 length,
+ struct exofs_io_state **ios);
+int exofs_get_io_state(struct exofs_layout *layout,
+ struct exofs_components *comps,
+ struct exofs_io_state **ios);
void exofs_put_io_state(struct exofs_io_state *ios);
int exofs_check_io(struct exofs_io_state *ios, u64 *resid);
@@ -235,27 +235,12 @@ int exofs_sbi_create(struct exofs_io_state *ios);
int exofs_sbi_remove(struct exofs_io_state *ios);
int exofs_sbi_write(struct exofs_io_state *ios);
int exofs_sbi_read(struct exofs_io_state *ios);
+int exofs_truncate(struct exofs_layout *layout, struct exofs_components *comps,
+ u64 size);
int extract_attr_from_ios(struct exofs_io_state *ios, struct osd_attr *attr);
extern const struct osd_attr g_attr_logical_length;
-int exofs_oi_truncate(struct exofs_i_info *oi, u64 new_len);
-static inline int exofs_oi_write(struct exofs_i_info *oi,
- struct exofs_io_state *ios)
-{
- ios->obj.id = exofs_oi_objno(oi);
- ios->cred = oi->i_cred;
- return exofs_sbi_write(ios);
-}
-
-static inline int exofs_oi_read(struct exofs_i_info *oi,
- struct exofs_io_state *ios)
-{
- ios->obj.id = exofs_oi_objno(oi);
- ios->cred = oi->i_cred;
- return exofs_sbi_read(ios);
-}
-
/* inode.c */
unsigned exofs_max_io_pages(struct exofs_layout *layout,
unsigned expected_pages);
@@ -307,4 +292,33 @@ extern const struct inode_operations exofs_special_inode_operations;
extern const struct inode_operations exofs_symlink_inode_operations;
extern const struct inode_operations exofs_fast_symlink_inode_operations;
+/* exofs_init_comps will initialize an exofs_components device array
+ * pointing to a single exofs_comp struct, and a round-robin view
+ * of the device table.
+ * The first device of each inode is the [inode->ino % num_devices]
+ * and the rest of the devices sequentially following where the
+ * first device is after the last device.
+ * It is assumed that the global device array at @sbi is twice
+ * bigger and that the device table repeats twice.
+ * See: exofs_read_lookup_dev_table()
+ */
+static inline void exofs_init_comps(struct exofs_components *comps,
+ struct exofs_comp *one_comp,
+ struct exofs_sb_info *sbi, osd_id oid)
+{
+ unsigned dev_mod = (unsigned)oid, first_dev;
+
+ one_comp->obj.partition = sbi->one_comp.obj.partition;
+ one_comp->obj.id = oid;
+ exofs_make_credential(one_comp->cred, &one_comp->obj);
+
+ comps->numdevs = sbi->comps.numdevs;
+ comps->single_comp = EC_SINGLE_COMP;
+ comps->comps = one_comp;
+
+ /* Round robin device view of the table */
+ first_dev = (dev_mod * sbi->layout.mirrors_p1) % sbi->comps.numdevs;
+ comps->ods = sbi->comps.ods + first_dev;
+}
+
#endif