Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 262647
b: refs/heads/master
c: 9e9db45
h: refs/heads/master
i:
  262645: 8ed1084
  262643: ab51ee8
  262639: 578571f
v: v3
  • Loading branch information
Boaz Harrosh committed Aug 7, 2011
1 parent e20f90c commit 8bc5aff
Show file tree
Hide file tree
Showing 5 changed files with 219 additions and 184 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 85e44df4748670a1a7d8441b2d75843cdebc478a
refs/heads/master: 9e9db45649eb5d3ee5622fdad741914ecf1016a0
104 changes: 59 additions & 45 deletions trunk/fs/exofs/exofs.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,31 @@
/* 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;

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 */
};

/*
Expand All @@ -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 */
};

Expand All @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -199,20 +210,6 @@ 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);

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
*/
Expand All @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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
59 changes: 27 additions & 32 deletions trunk/fs/exofs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ static int read_exec(struct page_collect *pcol)
return 0;

if (!pcol->ios) {
int ret = exofs_get_rw_state(&pcol->sbi->layout, true,
int ret = exofs_get_rw_state(&pcol->sbi->layout, &oi->comps, true,
pcol->pg_first << PAGE_CACHE_SHIFT,
pcol->length, &pcol->ios);

Expand All @@ -283,7 +283,7 @@ static int read_exec(struct page_collect *pcol)
ios->nr_pages = pcol->nr_pages;

if (pcol->read_4_write) {
exofs_oi_read(oi, pcol->ios);
exofs_sbi_read(pcol->ios);
return __readpages_done(pcol);
}

Expand All @@ -296,14 +296,14 @@ static int read_exec(struct page_collect *pcol)
*pcol_copy = *pcol;
ios->done = readpages_done;
ios->private = pcol_copy;
ret = exofs_oi_read(oi, ios);
ret = exofs_sbi_read(ios);
if (unlikely(ret))
goto err;

atomic_inc(&pcol->sbi->s_curr_pending);

EXOFS_DBGMSG2("read_exec obj=0x%llx start=0x%llx length=0x%lx\n",
ios->obj.id, _LLU(ios->offset), pcol->length);
oi->one_comp.obj.id, _LLU(ios->offset), pcol->length);

/* pages ownership was passed to pcol_copy */
_pcol_reset(pcol);
Expand Down Expand Up @@ -516,7 +516,7 @@ static int write_exec(struct page_collect *pcol)
return 0;

BUG_ON(pcol->ios);
ret = exofs_get_rw_state(&pcol->sbi->layout, false,
ret = exofs_get_rw_state(&pcol->sbi->layout, &oi->comps, false,
pcol->pg_first << PAGE_CACHE_SHIFT,
pcol->length, &pcol->ios);

Expand All @@ -538,9 +538,9 @@ static int write_exec(struct page_collect *pcol)
ios->done = writepages_done;
ios->private = pcol_copy;

ret = exofs_oi_write(oi, ios);
ret = exofs_sbi_write(ios);
if (unlikely(ret)) {
EXOFS_ERR("write_exec: exofs_oi_write() Failed\n");
EXOFS_ERR("write_exec: exofs_sbi_write() Failed\n");
goto err;
}

Expand Down Expand Up @@ -855,11 +855,12 @@ static inline int exofs_inode_is_fast_symlink(struct inode *inode)
static int _do_truncate(struct inode *inode, loff_t newsize)
{
struct exofs_i_info *oi = exofs_i(inode);
struct exofs_sb_info *sbi = inode->i_sb->s_fs_info;
int ret;

inode->i_mtime = inode->i_ctime = CURRENT_TIME;

ret = exofs_oi_truncate(oi, (u64)newsize);
ret = exofs_truncate(&sbi->layout, &oi->comps, (u64)newsize);
if (likely(!ret))
truncate_setsize(inode, newsize);

Expand Down Expand Up @@ -926,26 +927,22 @@ static int exofs_get_inode(struct super_block *sb, struct exofs_i_info *oi,
struct exofs_on_disk_inode_layout *layout;
int ret;

ret = exofs_get_io_state(&sbi->layout, &ios);
ret = exofs_get_io_state(&sbi->layout, &oi->comps, &ios);
if (unlikely(ret)) {
EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__);
return ret;
}

ios->obj.id = exofs_oi_objno(oi);
exofs_make_credential(oi->i_cred, &ios->obj);
ios->cred = oi->i_cred;

attrs[1].len = exofs_on_disk_inode_layout_size(sbi->layout.s_numdevs);
attrs[2].len = exofs_on_disk_inode_layout_size(sbi->layout.s_numdevs);
attrs[1].len = exofs_on_disk_inode_layout_size(sbi->comps.numdevs);
attrs[2].len = exofs_on_disk_inode_layout_size(sbi->comps.numdevs);

ios->in_attr = attrs;
ios->in_attr_len = ARRAY_SIZE(attrs);

ret = exofs_sbi_read(ios);
if (unlikely(ret)) {
EXOFS_ERR("object(0x%llx) corrupted, return empty file=>%d\n",
_LLU(ios->obj.id), ret);
_LLU(oi->one_comp.obj.id), ret);
memset(inode, 0, sizeof(*inode));
inode->i_mode = 0040000 | (0777 & ~022);
/* If object is lost on target we might as well enable it's
Expand Down Expand Up @@ -1021,6 +1018,8 @@ struct inode *exofs_iget(struct super_block *sb, unsigned long ino)
return inode;
oi = exofs_i(inode);
__oi_init(oi);
exofs_init_comps(&oi->comps, &oi->one_comp, sb->s_fs_info,
exofs_oi_objno(oi));

/* read the inode from the osd */
ret = exofs_get_inode(sb, oi, &fcb);
Expand Down Expand Up @@ -1126,7 +1125,8 @@ static void create_done(struct exofs_io_state *ios, void *p)

if (unlikely(ret)) {
EXOFS_ERR("object=0x%llx creation failed in pid=0x%llx",
_LLU(exofs_oi_objno(oi)), _LLU(sbi->layout.s_pid));
_LLU(exofs_oi_objno(oi)),
_LLU(oi->one_comp.obj.partition));
/*TODO: When FS is corrupted creation can fail, object already
* exist. Get rid of this asynchronous creation, if exist
* increment the obj counter and try the next object. Until we
Expand All @@ -1145,14 +1145,13 @@ static void create_done(struct exofs_io_state *ios, void *p)
*/
struct inode *exofs_new_inode(struct inode *dir, int mode)
{
struct super_block *sb;
struct super_block *sb = dir->i_sb;
struct exofs_sb_info *sbi = sb->s_fs_info;
struct inode *inode;
struct exofs_i_info *oi;
struct exofs_sb_info *sbi;
struct exofs_io_state *ios;
int ret;

sb = dir->i_sb;
inode = new_inode(sb);
if (!inode)
return ERR_PTR(-ENOMEM);
Expand All @@ -1162,8 +1161,6 @@ struct inode *exofs_new_inode(struct inode *dir, int mode)

set_obj_2bcreated(oi);

sbi = sb->s_fs_info;

inode->i_mapping->backing_dev_info = sb->s_bdi;
inode_init_owner(inode, dir, mode);
inode->i_ino = sbi->s_nextid++;
Expand All @@ -1175,22 +1172,21 @@ struct inode *exofs_new_inode(struct inode *dir, int mode)
spin_unlock(&sbi->s_next_gen_lock);
insert_inode_hash(inode);

exofs_init_comps(&oi->comps, &oi->one_comp, sb->s_fs_info,
exofs_oi_objno(oi));
exofs_sbi_write_stats(sbi); /* Make sure new sbi->s_nextid is on disk */

mark_inode_dirty(inode);

ret = exofs_get_io_state(&sbi->layout, &ios);
ret = exofs_get_io_state(&sbi->layout, &oi->comps, &ios);
if (unlikely(ret)) {
EXOFS_ERR("exofs_new_inode: exofs_get_io_state failed\n");
return ERR_PTR(ret);
}

ios->obj.id = exofs_oi_objno(oi);
exofs_make_credential(oi->i_cred, &ios->obj);

ios->done = create_done;
ios->private = inode;
ios->cred = oi->i_cred;

ret = exofs_sbi_create(ios);
if (ret) {
exofs_put_io_state(ios);
Expand Down Expand Up @@ -1271,7 +1267,7 @@ static int exofs_update_inode(struct inode *inode, int do_sync)
} else
memcpy(fcb->i_data, oi->i_data, sizeof(fcb->i_data));

ret = exofs_get_io_state(&sbi->layout, &ios);
ret = exofs_get_io_state(&sbi->layout, &oi->comps, &ios);
if (unlikely(ret)) {
EXOFS_ERR("%s: exofs_get_io_state failed.\n", __func__);
goto free_args;
Expand All @@ -1290,7 +1286,7 @@ static int exofs_update_inode(struct inode *inode, int do_sync)
ios->private = args;
}

ret = exofs_oi_write(oi, ios);
ret = exofs_sbi_write(ios);
if (!do_sync && !ret) {
atomic_inc(&sbi->s_curr_pending);
goto out; /* deallocation in updatei_done */
Expand Down Expand Up @@ -1354,16 +1350,15 @@ void exofs_evict_inode(struct inode *inode)
/* ignore the error, attempt a remove anyway */

/* Now Remove the OSD objects */
ret = exofs_get_io_state(&sbi->layout, &ios);
ret = exofs_get_io_state(&sbi->layout, &oi->comps, &ios);
if (unlikely(ret)) {
EXOFS_ERR("%s: exofs_get_io_state failed\n", __func__);
return;
}

ios->obj.id = exofs_oi_objno(oi);
ios->done = delete_done;
ios->private = sbi;
ios->cred = oi->i_cred;

ret = exofs_sbi_remove(ios);
if (ret) {
EXOFS_ERR("%s: exofs_sbi_remove failed\n", __func__);
Expand Down
Loading

0 comments on commit 8bc5aff

Please sign in to comment.