Skip to content

Commit

Permalink
"new post create code is working, readdir has not been tested yet"
Browse files Browse the repository at this point in the history
git-svn-id: svn+ssh://137.99.13.219/srv/svn/ofsproject/ofsproject/2.8.4-stock/osd_branch@58 dfcdf660-53a5-499b-8775-f9b82cf2d3b9
  • Loading branch information
cek10006 committed Mar 20, 2012
1 parent 9f19ad3 commit 7e68c6f
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 154 deletions.
3 changes: 2 additions & 1 deletion src/client/sysint/client-state-machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -440,9 +440,10 @@ PVFS_error PINT_client_state_machine_post(
start state machine and continue advancing while we're getting
immediate completions
*/

sm_ret = PINT_state_machine_start(smcb, &js);
assert(SM_ACTION_ISVALID(sm_ret));

if(sm_ret < 0)
{
/* state machine code failed */
Expand Down
169 changes: 83 additions & 86 deletions src/client/sysint/sys-create.sm
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ enum {
OSD_MSGPAIR = 2001,
OSD_CREATE_MSGPAIR = 2002,
OSD_MDFILE_MSGPAIR = 2003,
OSD_NOT_EXIST = 2004
OSD_POST_CREATE = 2004
};

%%
Expand All @@ -79,6 +79,7 @@ machine pvfs2_client_create_sm
state parent_getattr_inspect
{
run create_parent_getattr_inspect;
OSD_POST_CREATE => cleanup;
success => create_setup_msgpair;
default => cleanup;
}
Expand Down Expand Up @@ -125,7 +126,6 @@ machine pvfs2_client_create_sm
{
run create_datafiles_setup_msgpair_array;
OSD_MSGPAIR => datafiles_xfer_osd_msgpair_array;
OSD_NOT_EXIST => create_setattr_setup_msgpair;
default => cleanup;
}

Expand All @@ -140,7 +140,6 @@ machine pvfs2_client_create_sm
{
run create_setattr_setup_msgpair;
OSD_MSGPAIR => create_setattr_xfer_osd_msgpair;
OSD_NOT_EXIST => crdirent_setup_msgpair;
success => create_setattr_xfer_msgpair;
default => cleanup;
}
Expand Down Expand Up @@ -398,7 +397,7 @@ static PINT_sm_action create_init(
{
struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
job_id_t tmp_id;

assert((js_p->error_code == 0) ||
(js_p->error_code == CREATE_RETRY));

Expand Down Expand Up @@ -426,8 +425,7 @@ static PINT_sm_action create_init(
pint_client_sm_context);
}


return SM_ACTION_COMPLETE;
return SM_ACTION_COMPLETE;
}

static int create_comp_fn(void *v_p,
Expand Down Expand Up @@ -555,23 +553,24 @@ static int create_datafiles_comp_fn(void *v_p,
PVFS_handle first = ea->extent_array[0].first;
PVFS_handle last = ea->extent_array[0].last;

ret = osd_command_attr_resolve(&sm_p->msgarray_op.msgarray[index].osd_command);
/* ret = osd_command_attr_resolve(&sm_p->msgarray_op.msgarray[index].osd_command);*/

if (ret)
osd_error_xerrno(ret, "%s: attr_resolve failed", __func__);
oid = get_ntohll(sm_p->msgarray_op.msgarray[index].osd_command.attr[0].val);
/* if (ret)*/
/* osd_error_xerrno(ret, "%s: attr_resolve failed", __func__);*/
/* oid = get_ntohll(sm_p->msgarray_op.msgarray[index].osd_command.attr[0].val);*/
oid = sm_p->u.create.datafile_handles[index];
if (oid < first || oid > last)
gossip_err("%s: OSD-assigned oid %llu out of range %llu-%llu\n",
__func__, llu(oid), llu(first), llu(last));
sm_p->u.create.datafile_handles[index] = oid;
/* sm_p->u.create.datafile_handles[index] = oid;*/

/* The first datafile also happens to be the metafile */
if (is_osd_md && index == 0) {
sm_p->u.create.metafile_handle = oid;
sm_p->u.create.create_resp->ref.handle = oid;
sm_p->u.create.create_resp->ref.fs_id = sm_p->object_ref.fs_id;
}
osd_command_attr_free(&sm_p->msgarray_op.msgarray[index].osd_command);
/* osd_command_attr_free(&sm_p->msgarray_op.msgarray[index].osd_command);*/
}

gossip_debug(GOSSIP_CLIENT_DEBUG, "Datafile handle %d is %llu\n",
Expand Down Expand Up @@ -628,6 +627,11 @@ static PINT_sm_action create_create_setup_msgpair(
PVFS_handle_extent_array meta_handle_extent_array;
PINT_sm_msgpair_state *msg_p = NULL;
int server_type;
struct server_configuration_s *server_config;

server_config = PINT_get_server_config_struct(
sm_p->object_ref.fs_id);
PINT_put_server_config_struct(server_config);

/*
* Check whether we're storing file metadata on a dedicated OSD MDS
Expand Down Expand Up @@ -721,7 +725,7 @@ static PINT_sm_action create_create_setup_msgpair(
sm_p->u.create.layout,
sm_p->hints);
js_p->error_code = 0;
if (is_osd)
if (is_osd && !server_config->post_create)
js_p->error_code = OSD_CREATE_MSGPAIR;
}

Expand All @@ -742,6 +746,7 @@ static PINT_sm_action create_create_setup_msgpair(
static PINT_sm_action create_datafiles_setup_msgpair_array(
struct PINT_smcb *smcb, job_status_s *js_p)
{
gossip_err("create_datafiles_setup_msgpair_array\n");
struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
int ret = -PVFS_EINVAL;
struct server_configuration_s *server_config;
Expand Down Expand Up @@ -806,58 +811,57 @@ static PINT_sm_action create_datafiles_setup_msgpair_array(
return SM_ACTION_COMPLETE;
}

if(!server_config->post_create) {
PINT_msgpair_init(&sm_p->msgarray_op);
msg_p = &sm_p->msgarray_op.msgpair;
PINT_msgpair_init(&sm_p->msgarray_op);
msg_p = &sm_p->msgarray_op.msgpair;

#define CURRENT_COMMAND_PAGE 0xfffffffeUL
#define CURRENT_COMMAND_PAGE_OID 4

if (is_osd) {
struct osd_command *command = &sm_p->msgarray_op.msgarray[0].osd_command;
uint64_t attrval;
struct attribute_list attrs[] = {{ ATTR_GET, CUR_CMD_ATTR_PG,
CCAP_OID, NULL, CCAP_OID_LEN },
{ ATTR_SET, USER_COLL_PG, 1, &attrval, 8}};
if (is_osd) {
struct osd_command *command = &sm_p->msgarray_op.msgarray[0].osd_command;
uint64_t attrval;
/* struct attribute_list attrs[] = {{ ATTR_GET, CUR_CMD_ATTR_PG,*/
/* CCAP_OID, NULL, CCAP_OID_LEN },*/
/* { ATTR_SET, USER_COLL_PG, 1, &attrval, 8}};*/

if(!sm_p->getattr.attr.cid) {
sm_p->getattr.attr.cid = COLLECTION_OID_LB; /* root directory */
}
set_htonll(&attrval, sm_p->getattr.attr.cid);

/*
* A hack in PVFS_util_init_defaults has set up an object an the
* low bound of the extent array. So as we create handles, we get
* them in increasing order that satisfies our extent bounds.
*/
ret = osd_command_set_create(command, PVFS_OSD_DATA_PID, sm_p->u.create.datafile_handles[0], 1);
if (ret) {
osd_error_xerrno(ret, "%s: osd_command_set_create failed",
struct attribute_list attr = {ATTR_SET, USER_COLL_PG, 1, &attrval, 8};

if(!sm_p->getattr.attr.cid) {
sm_p->getattr.attr.cid = COLLECTION_OID_LB; /* root directory */
}
set_htonll(&attrval, sm_p->getattr.attr.cid);

/*
* A hack in PVFS_util_init_defaults has set up an object an the
* low bound of the extent array. So as we create handles, we get
* them in increasing order that satisfies our extent bounds.
*/
ret = osd_command_set_create(command, PVFS_OSD_DATA_PID, sm_p->u.create.datafile_handles[0], 1);
if (ret) {
osd_error_xerrno(ret, "%s: osd_command_set_create failed",
__func__);
js_p->error_code = ret;
return 1;
}
js_p->error_code = ret;
return 1;
}

ret = osd_command_attr_build(command, attrs, 2);
if (ret) {
osd_error_xerrno(ret, "%s: osd_command_attr_build failed",
/* ret = osd_command_attr_build(command, attrs, 2);*/
ret = osd_command_attr_build(command, &attr, 1);
if (ret) {
osd_error_xerrno(ret, "%s: osd_command_attr_build failed",
__func__);
js_p->error_code = ret;
return 1;
}
js_p->error_code = ret;
return 1;
}
}

msg_p->fs_id = sm_p->object_ref.fs_id;
msg_p->handle = sm_p->u.create.io_handle_extent_array[0].
extent_array[0].first;
msg_p->retry_flag = PVFS_MSGPAIR_NO_RETRY;
msg_p->comp_fn = create_datafiles_comp_fn;
msg_p->svr_addr = sm_p->u.create.data_server_addrs[0];
msg_p->fs_id = sm_p->object_ref.fs_id;
msg_p->handle = sm_p->u.create.io_handle_extent_array[0].
extent_array[0].first;
msg_p->retry_flag = PVFS_MSGPAIR_NO_RETRY;
msg_p->comp_fn = create_datafiles_comp_fn;
msg_p->svr_addr = sm_p->u.create.data_server_addrs[0];

PINT_sm_push_frame(smcb, 0, &sm_p->msgarray_op);
} else {
js_p->error_code = OSD_NOT_EXIST;
}
PINT_sm_push_frame(smcb, 0, &sm_p->msgarray_op);

return SM_ACTION_COMPLETE;
}
Expand Down Expand Up @@ -992,32 +996,21 @@ static PINT_sm_action create_setattr_setup_msgpair(
PINT_DIST_PACK_SIZE(sm_p->u.create.dist);
}

if(!server_config->post_create) {
msg_p->fs_id = sm_p->object_ref.fs_id;
msg_p->handle = sm_p->u.create.metafile_handle;
msg_p->retry_flag = PVFS_MSGPAIR_NO_RETRY;
msg_p->comp_fn = create_setattr_comp_fn;
msg_p->fs_id = sm_p->object_ref.fs_id;
msg_p->handle = sm_p->u.create.metafile_handle;
msg_p->retry_flag = PVFS_MSGPAIR_NO_RETRY;
msg_p->comp_fn = create_setattr_comp_fn;

ret = PINT_cached_config_map_to_server(
&msg_p->svr_addr, msg_p->handle, msg_p->fs_id);
ret = PINT_cached_config_map_to_server(
&msg_p->svr_addr, msg_p->handle, msg_p->fs_id);

if (ret)
{
gossip_err("Failed to map meta server address\n");
js_p->error_code = ret;
}
js_p->error_code = (is_osd_meta || is_osd_md) ? OSD_MSGPAIR : 0;
PINT_sm_push_frame(smcb, 0, &sm_p->msgarray_op);
} else {
js_p->error_code = OSD_NOT_EXIST;
ret = PINT_copy_object_attr(&sm_p->u.create.cache_attr,
&sm_p->msgarray_op.msgpair.req.u.setattr.attr);

if(ret != 0)
{
js_p->error_code = ret;
}
if (ret)
{
gossip_err("Failed to map meta server address\n");
js_p->error_code = ret;
}
js_p->error_code = (is_osd_meta || is_osd_md) ? OSD_MSGPAIR : 0;
PINT_sm_push_frame(smcb, 0, &sm_p->msgarray_op);

return SM_ACTION_COMPLETE;
}
Expand Down Expand Up @@ -1095,15 +1088,20 @@ static PINT_sm_action create_cleanup(
PVFS_object_ref metafile_ref;
PVFS_size tmp_size = 0;
int ret;

gossip_debug(GOSSIP_CLIENT_DEBUG, "create state: cleanup\n");


PINT_free_object_attr(&sm_p->u.create.attr);

if(js_p->error_code == OSD_POST_CREATE)
js_p->error_code = 0;

PINT_SM_GETATTR_STATE_CLEAR(sm_p->getattr);

sm_p->error_code = (sm_p->u.create.stored_error_code ?
sm_p->u.create.stored_error_code :
js_p->error_code);

memset(&metafile_ref, 0, sizeof(metafile_ref));

if (sm_p->error_code == 0)
Expand All @@ -1124,7 +1122,7 @@ static PINT_sm_action create_cleanup(
sm_p->u.create.datafile_handles;
sm_p->u.create.attr.u.meta.dfile_count =
sm_p->u.create.datafile_count;

if(sm_p->u.create.stuffed)
{
gossip_debug(GOSSIP_CLIENT_DEBUG, "created stuffed file\n");
Expand Down Expand Up @@ -1154,7 +1152,7 @@ static PINT_sm_action create_cleanup(
sm_p->u.create.attr.mask &= (~(PVFS_ATTR_COMMON_CTIME));
sm_p->u.create.attr.mask &= (~(PVFS_ATTR_COMMON_ATIME));
ret = PINT_acache_update(metafile_ref,
&sm_p->u.create.cache_attr,
&sm_p->u.create.attr,
&tmp_size);
if(ret < 0)
{
Expand All @@ -1174,8 +1172,6 @@ static PINT_sm_action create_cleanup(
return SM_ACTION_COMPLETE;
}

PINT_free_object_attr(&sm_p->u.create.cache_attr);

if(sm_p->u.create.layout.algorithm == PVFS_SYS_LAYOUT_LIST)
{
free(sm_p->u.create.layout.server_list.servers);
Expand All @@ -1193,7 +1189,7 @@ static PINT_sm_action create_cleanup(
free(sm_p->u.create.datafile_handles);
sm_p->u.create.datafile_handles = NULL;
}

PINT_msgpairarray_destroy(&sm_p->msgarray_op);

PINT_SET_OP_COMPLETE;
Expand All @@ -1207,11 +1203,12 @@ static PINT_sm_action create_parent_getattr_inspect(
struct PINT_smcb *smcb, job_status_s *js_p)
{
struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);

PVFS_object_attr *attr = NULL;
PINT_dist *current_dist;
int ret = 0;
int num_dfiles_requested = 0;

gossip_debug(GOSSIP_CLIENT_DEBUG, "create state: parent_getattr_inspect\n");

attr = &sm_p->getattr.attr;
Expand Down
19 changes: 7 additions & 12 deletions src/client/sysint/sys-getattr.sm
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ nested machine pvfs2_client_getattr_sm
run getattr_acache_lookup;
GETATTR_ACACHE_MISS => object_getattr_setup_msgpair;
GETATTR_NEED_DATAFILE_SIZES => datafile_get_sizes;
IO_DO_OSD => acache_insert;
IO_DO_OSD => cleanup;
default => cleanup;
}

Expand Down Expand Up @@ -336,16 +336,17 @@ static PINT_sm_action getattr_acache_lookup(
js_p->error_code = 0;

object_ref = sm_p->getattr.object_ref;


server_config = PINT_get_server_config_struct(
sm_p->object_ref.fs_id);
PINT_put_server_config_struct(server_config);

assert(object_ref.handle != PVFS_HANDLE_NULL);
assert(object_ref.fs_id != PVFS_FS_ID_NULL);

gossip_debug(GOSSIP_ACACHE_DEBUG, "%s: handle %llu fsid %d\n",
__func__, llu(object_ref.handle), object_ref.fs_id);

server_config = PINT_get_server_config_struct(
sm_p->object_ref.fs_id);
PINT_put_server_config_struct(server_config);

/* The sys attr mask request is converted to object
* attr mask values for comparison with the cached
Expand All @@ -370,12 +371,6 @@ static PINT_sm_action getattr_acache_lookup(
&sm_p->getattr.size,
&size_status);

if(sm_p->u.io.io_type == PVFS_IO_WRITE && server_config->post_create) {
/* the object that we are trying to write to has not been created */
js_p->error_code = IO_DO_OSD;
return SM_ACTION_COMPLETE;
}

if(ret < 0 || attr_status < 0)
{
gossip_debug(GOSSIP_ACACHE_DEBUG, "acache: clean acache miss: "
Expand Down Expand Up @@ -1386,7 +1381,7 @@ static PINT_sm_action getattr_acache_insert(
{
struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
PVFS_size* tmp_size = NULL;

if( sm_p->getattr.attr.objtype == PVFS_TYPE_METAFILE ||
sm_p->getattr.attr.objtype == PVFS_TYPE_DIRECTORY ||
sm_p->getattr.attr.objtype == PVFS_TYPE_SYMLINK )
Expand Down
Loading

0 comments on commit 7e68c6f

Please sign in to comment.