Commit 64ba9926 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'for-linus' of git://git.open-osd.org/linux-open-osd

* 'for-linus' of git://git.open-osd.org/linux-open-osd:
  exofs: groups support
  exofs: Prepare for groups
  exofs: Error recovery if object is missing from storage
  exofs: convert io_state to use pages array instead of bio at input
  exofs: RAID0 support
  exofs: Define on-disk per-inode optional layout attribute
  exofs: unindent exofs_sbi_read
  exofs: Move layout related members to a layout structure
  exofs: Recover in the case of read-passed-end-of-file
  exofs: Micro-optimize exofs_i_info
  exofs: debug print even less
parents 6895210e 50a76fd3
......@@ -55,6 +55,8 @@
/* exofs Application specific page/attribute */
# define EXOFS_APAGE_FS_DATA (OSD_APAGE_APP_DEFINED_FIRST + 3)
# define EXOFS_ATTR_INODE_DATA 1
# define EXOFS_ATTR_INODE_FILE_LAYOUT 2
# define EXOFS_ATTR_INODE_DIR_LAYOUT 3
/*
* The maximum number of files we can have is limited by the size of the
......@@ -206,4 +208,41 @@ enum {
(((name_len) + offsetof(struct exofs_dir_entry, name) + \
EXOFS_DIR_ROUND) & ~EXOFS_DIR_ROUND)
/*
* The on-disk (optional) layout structure.
* sits in an EXOFS_ATTR_INODE_FILE_LAYOUT or EXOFS_ATTR_INODE_DIR_LAYOUT
* attribute, attached to any inode, usually to a directory.
*/
enum exofs_inode_layout_gen_functions {
LAYOUT_MOVING_WINDOW = 0,
LAYOUT_IMPLICT = 1,
};
struct exofs_on_disk_inode_layout {
__le16 gen_func; /* One of enum exofs_inode_layout_gen_functions */
__le16 pad;
union {
/* gen_func == LAYOUT_MOVING_WINDOW (default) */
struct exofs_layout_sliding_window {
__le32 num_devices; /* first n devices in global-table*/
} sliding_window __packed;
/* gen_func == LAYOUT_IMPLICT */
struct exofs_layout_implict_list {
struct exofs_dt_data_map data_map;
/* Variable array of size data_map.cb_num_comps. These
* are device indexes of the devices in the global table
*/
__le32 dev_indexes[];
} implict __packed;
};
} __packed;
static inline size_t exofs_on_disk_inode_layout_size(unsigned max_devs)
{
return sizeof(struct exofs_on_disk_inode_layout) +
max_devs * sizeof(__le32);
}
#endif /*ifndef __EXOFS_COM_H__*/
......@@ -55,12 +55,28 @@
/* 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*/
/* Our way of looking at the data_map */
unsigned stripe_unit;
unsigned mirrors_p1;
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[0]; /* Variable length */
};
/*
* our extension to the in-memory superblock
*/
struct exofs_sb_info {
struct exofs_fscb s_fscb; /* Written often, pre-allocate*/
osd_id s_pid; /* partition ID of file system*/
int s_timeout; /* timeout for OSD operations */
uint64_t s_nextid; /* highest object ID used */
uint32_t s_numfiles; /* number of files on fs */
......@@ -69,22 +85,27 @@ struct exofs_sb_info {
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 */
unsigned s_numdevs; /* Num of devices in array */
struct osd_dev *s_ods[1]; /* Variable length, minimum 1 */
struct pnfs_osd_data_map data_map; /* Default raid to use
* FIXME: Needed ?
*/
/* struct exofs_layout dir_layout;*/ /* Default dir layout */
struct exofs_layout layout; /* Default files layout,
* contains the variable osd_dev
* array. Keep last */
struct osd_dev *_min_one_dev[1]; /* Place holder for one dev */
};
/*
* our extension to the in-memory inode
*/
struct exofs_i_info {
struct inode vfs_inode; /* normal in-memory inode */
wait_queue_head_t i_wq; /* wait queue for inode */
unsigned long i_flags; /* various atomic flags */
uint32_t i_data[EXOFS_IDATA];/*short symlink names and device #s*/
uint32_t i_dir_start_lookup; /* which page to start lookup */
wait_queue_head_t i_wq; /* wait queue for inode */
uint64_t i_commit_size; /* the object's written length */
uint8_t i_cred[OSD_CAP_LEN];/* all-powerful credential */
struct inode vfs_inode; /* normal in-memory inode */
};
static inline osd_id exofs_oi_objno(struct exofs_i_info *oi)
......@@ -101,7 +122,7 @@ struct exofs_io_state {
void *private;
exofs_io_done_fn done;
struct exofs_sb_info *sbi;
struct exofs_layout *layout;
struct osd_obj_id obj;
u8 *cred;
......@@ -109,7 +130,11 @@ struct exofs_io_state {
loff_t offset;
unsigned long length;
void *kern_buff;
struct bio *bio;
struct page **pages;
unsigned nr_pages;
unsigned pgbase;
unsigned pages_consumed;
/* Attributes */
unsigned in_attr_len;
......@@ -122,6 +147,9 @@ struct exofs_io_state {
struct exofs_per_dev_state {
struct osd_request *or;
struct bio *bio;
loff_t offset;
unsigned length;
unsigned dev;
} per_dev[];
};
......@@ -174,6 +202,12 @@ static inline struct exofs_i_info *exofs_i(struct inode *inode)
return container_of(inode, struct exofs_i_info, vfs_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);
/*
* Maximum count of links to a file
*/
......@@ -189,7 +223,8 @@ void exofs_make_credential(u8 cred_a[OSD_CAP_LEN],
int exofs_read_kern(struct osd_dev *od, u8 *cred, struct osd_obj_id *obj,
u64 offset, void *p, unsigned length);
int exofs_get_io_state(struct exofs_sb_info *sbi, struct exofs_io_state** ios);
int exofs_get_io_state(struct exofs_layout *layout,
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);
......
This diff is collapsed.
This diff is collapsed.
......@@ -210,7 +210,7 @@ int exofs_sync_fs(struct super_block *sb, int wait)
sbi = sb->s_fs_info;
fscb = &sbi->s_fscb;
ret = exofs_get_io_state(sbi, &ios);
ret = exofs_get_io_state(&sbi->layout, &ios);
if (ret)
goto out;
......@@ -264,12 +264,12 @@ static void _exofs_print_device(const char *msg, const char *dev_path,
void exofs_free_sbi(struct exofs_sb_info *sbi)
{
while (sbi->s_numdevs) {
int i = --sbi->s_numdevs;
struct osd_dev *od = sbi->s_ods[i];
while (sbi->layout.s_numdevs) {
int i = --sbi->layout.s_numdevs;
struct osd_dev *od = sbi->layout.s_ods[i];
if (od) {
sbi->s_ods[i] = NULL;
sbi->layout.s_ods[i] = NULL;
osduld_put_device(od);
}
}
......@@ -298,7 +298,8 @@ static void exofs_put_super(struct super_block *sb)
msecs_to_jiffies(100));
}
_exofs_print_device("Unmounting", NULL, sbi->s_ods[0], sbi->s_pid);
_exofs_print_device("Unmounting", NULL, sbi->layout.s_ods[0],
sbi->layout.s_pid);
exofs_free_sbi(sbi);
sb->s_fs_info = NULL;
......@@ -307,6 +308,8 @@ static void exofs_put_super(struct super_block *sb)
static int _read_and_match_data_map(struct exofs_sb_info *sbi, unsigned numdevs,
struct exofs_device_table *dt)
{
u64 stripe_length;
sbi->data_map.odm_num_comps =
le32_to_cpu(dt->dt_data_map.cb_num_comps);
sbi->data_map.odm_stripe_unit =
......@@ -320,13 +323,62 @@ static int _read_and_match_data_map(struct exofs_sb_info *sbi, unsigned numdevs,
sbi->data_map.odm_raid_algorithm =
le32_to_cpu(dt->dt_data_map.cb_raid_algorithm);
/* FIXME: Hard coded mirror only for now. if not so do not mount */
if ((sbi->data_map.odm_num_comps != numdevs) ||
(sbi->data_map.odm_stripe_unit != EXOFS_BLKSIZE) ||
(sbi->data_map.odm_raid_algorithm != PNFS_OSD_RAID_0) ||
(sbi->data_map.odm_mirror_cnt != (numdevs - 1)))
/* FIXME: Only raid0 for now. if not so, do not mount */
if (sbi->data_map.odm_num_comps != numdevs) {
EXOFS_ERR("odm_num_comps(%u) != numdevs(%u)\n",
sbi->data_map.odm_num_comps, numdevs);
return -EINVAL;
else
}
if (sbi->data_map.odm_raid_algorithm != PNFS_OSD_RAID_0) {
EXOFS_ERR("Only RAID_0 for now\n");
return -EINVAL;
}
if (0 != (numdevs % (sbi->data_map.odm_mirror_cnt + 1))) {
EXOFS_ERR("Data Map wrong, numdevs=%d mirrors=%d\n",
numdevs, sbi->data_map.odm_mirror_cnt);
return -EINVAL;
}
if (0 != (sbi->data_map.odm_stripe_unit & ~PAGE_MASK)) {
EXOFS_ERR("Stripe Unit(0x%llx)"
" must be Multples of PAGE_SIZE(0x%lx)\n",
_LLU(sbi->data_map.odm_stripe_unit), PAGE_SIZE);
return -EINVAL;
}
sbi->layout.stripe_unit = sbi->data_map.odm_stripe_unit;
sbi->layout.mirrors_p1 = sbi->data_map.odm_mirror_cnt + 1;
if (sbi->data_map.odm_group_width) {
sbi->layout.group_width = sbi->data_map.odm_group_width;
sbi->layout.group_depth = sbi->data_map.odm_group_depth;
if (!sbi->layout.group_depth) {
EXOFS_ERR("group_depth == 0 && group_width != 0\n");
return -EINVAL;
}
sbi->layout.group_count = sbi->data_map.odm_num_comps /
sbi->layout.mirrors_p1 /
sbi->data_map.odm_group_width;
} else {
if (sbi->data_map.odm_group_depth) {
printk(KERN_NOTICE "Warning: group_depth ignored "
"group_width == 0 && group_depth == %d\n",
sbi->data_map.odm_group_depth);
sbi->data_map.odm_group_depth = 0;
}
sbi->layout.group_width = sbi->data_map.odm_num_comps /
sbi->layout.mirrors_p1;
sbi->layout.group_depth = -1;
sbi->layout.group_count = 1;
}
stripe_length = (u64)sbi->layout.group_width * sbi->layout.stripe_unit;
if (stripe_length >= (1ULL << 32)) {
EXOFS_ERR("Total Stripe length(0x%llx)"
" >= 32bit is not supported\n", _LLU(stripe_length));
return -EINVAL;
}
return 0;
}
......@@ -361,7 +413,7 @@ static int exofs_read_lookup_dev_table(struct exofs_sb_info **psbi,
{
struct exofs_sb_info *sbi = *psbi;
struct osd_dev *fscb_od;
struct osd_obj_id obj = {.partition = sbi->s_pid,
struct osd_obj_id obj = {.partition = sbi->layout.s_pid,
.id = EXOFS_DEVTABLE_ID};
struct exofs_device_table *dt;
unsigned table_bytes = table_count * sizeof(dt->dt_dev_table[0]) +
......@@ -376,9 +428,9 @@ static int exofs_read_lookup_dev_table(struct exofs_sb_info **psbi,
return -ENOMEM;
}
fscb_od = sbi->s_ods[0];
sbi->s_ods[0] = NULL;
sbi->s_numdevs = 0;
fscb_od = sbi->layout.s_ods[0];
sbi->layout.s_ods[0] = NULL;
sbi->layout.s_numdevs = 0;
ret = exofs_read_kern(fscb_od, sbi->s_cred, &obj, 0, dt, table_bytes);
if (unlikely(ret)) {
EXOFS_ERR("ERROR: reading device table\n");
......@@ -397,14 +449,15 @@ static int exofs_read_lookup_dev_table(struct exofs_sb_info **psbi,
goto out;
if (likely(numdevs > 1)) {
unsigned size = numdevs * sizeof(sbi->s_ods[0]);
unsigned size = numdevs * sizeof(sbi->layout.s_ods[0]);
sbi = krealloc(sbi, sizeof(*sbi) + size, GFP_KERNEL);
if (unlikely(!sbi)) {
ret = -ENOMEM;
goto out;
}
memset(&sbi->s_ods[1], 0, size - sizeof(sbi->s_ods[0]));
memset(&sbi->layout.s_ods[1], 0,
size - sizeof(sbi->layout.s_ods[0]));
*psbi = sbi;
}
......@@ -427,8 +480,8 @@ static int exofs_read_lookup_dev_table(struct exofs_sb_info **psbi,
* line. We always keep them in device-table order.
*/
if (fscb_od && osduld_device_same(fscb_od, &odi)) {
sbi->s_ods[i] = fscb_od;
++sbi->s_numdevs;
sbi->layout.s_ods[i] = fscb_od;
++sbi->layout.s_numdevs;
fscb_od = NULL;
continue;
}
......@@ -441,8 +494,8 @@ static int exofs_read_lookup_dev_table(struct exofs_sb_info **psbi,
goto out;
}
sbi->s_ods[i] = od;
++sbi->s_numdevs;
sbi->layout.s_ods[i] = od;
++sbi->layout.s_numdevs;
/* Read the fscb of the other devices to make sure the FS
* partition is there.
......@@ -499,9 +552,15 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent)
goto free_sbi;
}
sbi->s_ods[0] = od;
sbi->s_numdevs = 1;
sbi->s_pid = opts->pid;
/* Default layout in case we do not have a device-table */
sbi->layout.stripe_unit = PAGE_SIZE;
sbi->layout.mirrors_p1 = 1;
sbi->layout.group_width = 1;
sbi->layout.group_depth = -1;
sbi->layout.group_count = 1;
sbi->layout.s_ods[0] = od;
sbi->layout.s_numdevs = 1;
sbi->layout.s_pid = opts->pid;
sbi->s_timeout = opts->timeout;
/* fill in some other data by hand */
......@@ -514,7 +573,7 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent)
sb->s_bdev = NULL;
sb->s_dev = 0;
obj.partition = sbi->s_pid;
obj.partition = sbi->layout.s_pid;
obj.id = EXOFS_SUPER_ID;
exofs_make_credential(sbi->s_cred, &obj);
......@@ -578,13 +637,13 @@ static int exofs_fill_super(struct super_block *sb, void *data, int silent)
goto free_sbi;
}
_exofs_print_device("Mounting", opts->dev_name, sbi->s_ods[0],
sbi->s_pid);
_exofs_print_device("Mounting", opts->dev_name, sbi->layout.s_ods[0],
sbi->layout.s_pid);
return 0;
free_sbi:
EXOFS_ERR("Unable to mount exofs on %s pid=0x%llx err=%d\n",
opts->dev_name, sbi->s_pid, ret);
opts->dev_name, sbi->layout.s_pid, ret);
exofs_free_sbi(sbi);
return ret;
}
......@@ -627,7 +686,7 @@ static int exofs_statfs(struct dentry *dentry, struct kstatfs *buf)
uint8_t cred_a[OSD_CAP_LEN];
int ret;
ret = exofs_get_io_state(sbi, &ios);
ret = exofs_get_io_state(&sbi->layout, &ios);
if (ret) {
EXOFS_DBGMSG("exofs_get_io_state failed.\n");
return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment