Skip to content

Commit

Permalink
"post_create is done, but should we separete larget writes into small…
Browse files Browse the repository at this point in the history
…er chunks?"

git-svn-id: svn+ssh://137.99.13.219/srv/svn/ofsproject/ofsproject/2.8.4-stock/osd_branch@54 dfcdf660-53a5-499b-8775-f9b82cf2d3b9
  • Loading branch information
cek10006 committed Jan 15, 2012
1 parent 3a6ebe1 commit b5e886c
Show file tree
Hide file tree
Showing 4 changed files with 170 additions and 37 deletions.
52 changes: 34 additions & 18 deletions src/client/sysint/sys-create.sm
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ static PINT_dist* get_default_distribution(PVFS_fs_id fs_id);
enum {
OSD_MSGPAIR = 2001,
OSD_CREATE_MSGPAIR = 2002,
OSD_MDFILE_MSGPAIR = 2003
OSD_MDFILE_MSGPAIR = 2003,
OSD_NOT_EXIST = 2004
};

%%
Expand Down Expand Up @@ -124,6 +125,7 @@ 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 @@ -138,6 +140,7 @@ 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 @@ -574,7 +577,6 @@ static int create_setattr_comp_fn(void *v_p,
int index)
{
int res, status;
PVFS_object_ref refn;
PINT_smcb *smcb = v_p;
PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM);

Expand All @@ -588,9 +590,6 @@ static int create_setattr_comp_fn(void *v_p,
status = resp_p->status;
}

refn.fs_id = sm_p->msgarray_op.msgpair.fs_id;
refn.handle = sm_p->msgarray_op.msgpair.handle;

res = PINT_copy_object_attr(&sm_p->u.create.cache_attr,
&sm_p->msgarray_op.msgpair.req.u.setattr.attr);

Expand Down Expand Up @@ -847,7 +846,7 @@ static PINT_sm_action create_datafiles_setup_msgpair_array(

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

return SM_ACTION_COMPLETE;
Expand All @@ -859,14 +858,19 @@ static PINT_sm_action create_setattr_setup_msgpair(
struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
int ret = -PVFS_EINVAL;
PINT_sm_msgpair_state *msg_p = NULL;
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);

int is_osd_md = fsid_is_osd_md(sm_p->object_ref.fs_id);
int is_osd_meta = fsid_is_osd_meta(sm_p->object_ref.fs_id);

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

js_p->error_code = (is_osd_meta || is_osd_md) ? OSD_MSGPAIR : 0;
js_p->error_code = 0;

gossip_debug(GOSSIP_CLIENT_DEBUG," create: posting setattr req\n");

Expand Down Expand Up @@ -977,21 +981,33 @@ static PINT_sm_action create_setattr_setup_msgpair(
msg_p->req.u.setattr.attr.u.meta.dist_size =
PINT_DIST_PACK_SIZE(sm_p->u.create.dist);
}
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);
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;

if (ret)
{
gossip_err("Failed to map meta server address\n");
js_p->error_code = ret;
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;
}
}

PINT_sm_push_frame(smcb, 0, &sm_p->msgarray_op);
return SM_ACTION_COMPLETE;
}

Expand Down
6 changes: 5 additions & 1 deletion src/client/sysint/sys-getattr.sm
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,7 @@ static PINT_sm_action getattr_acache_lookup(
uint32_t trimmed_mask = 0;
int missing_attrs;
PVFS_object_ref object_ref;
struct server_configuration_s *server_config;
int ret = -1;
int attr_status = -1;
int size_status = -1;
Expand All @@ -338,6 +339,9 @@ static PINT_sm_action getattr_acache_lookup(
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 @@ -362,7 +366,7 @@ static PINT_sm_action getattr_acache_lookup(
&sm_p->getattr.size,
&size_status);

if(sm_p->u.io.io_type == PVFS_IO_WRITE && !sm_p->getattr.attr.u.meta.dfile_count) {
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;
Expand Down
2 changes: 0 additions & 2 deletions src/client/sysint/sys-mkdir.sm
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,6 @@ static PINT_sm_action create_collection_setup_msgpair(
struct attribute_list attr = { ATTR_GET, CUR_CMD_ATTR_PG,
CCAP_OID, NULL, CCAP_OID_LEN };

gossip_err("handle_mkdir: %d\n", sm_p->u.mkdir.metafile_handle);

ret = osd_command_set_create_collection(command, PVFS_OSD_DATA_PID, 0);

if (ret) {
Expand Down
147 changes: 131 additions & 16 deletions src/client/sysint/sys-osd-io.sm
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ static int osd_io_completion_fn(void *user_args,
static int create_and_write_comp_fn(void *v_p,
struct PVFS_server_resp *resp_p,
int index);
static int setattr_comp_fn(void *v_p,
struct PVFS_server_resp *resp_p,
int index);

%%

Expand All @@ -66,6 +69,20 @@ nested machine pvfs2_client_osd_io_sm
state xfer_create_and_write
{
jump pvfs2_osd_msgpairarray_sm;
success => setattr_setup_msgpair;
default => cleanup;
}

state setattr_setup_msgpair
{
run setattr_setup_msgpair;
success => setattr_xfer_msgpair;
default => cleanup;
}

state setattr_xfer_msgpair
{
jump pvfs2_msgpairarray_sm;
default => cleanup;
}

Expand Down Expand Up @@ -627,7 +644,6 @@ out:
static PINT_sm_action create_and_write_setup_msgpair(
struct PINT_smcb *smcb, job_status_s *js_p)
{
gossip_err("create_and_write_setup_msgpair\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 @@ -748,6 +764,7 @@ static int create_and_write_comp_fn(void *v_p,
PINT_smcb *smcb = v_p;
PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM);
int ret;
uint64_t oid;

status = osd_errno_from_status(
sm_p->msgarray_op.msgarray[index].osd_command.status);
Expand All @@ -763,11 +780,103 @@ static int create_and_write_comp_fn(void *v_p,
osd_error_xerrno(ret, "%s: attr_resolve failed", __func__);
}

gossip_err("%d\n", get_ntohll(sm_p->msgarray_op.msgarray[index].osd_command.attr[0].val));
oid = get_ntohll(sm_p->msgarray_op.msgarray[index].osd_command.attr[0].val);

/* allocate memory for the data handles if we haven't already */
if (sm_p->u.create.datafile_handles == NULL)
{
sm_p->u.create.datafile_handles = (PVFS_handle *)malloc(
sm_p->u.io.datafile_count * sizeof(PVFS_handle));

if (sm_p->u.create.datafile_handles == NULL)
{
gossip_err("create: Failed to allocate data handle array\n");
return -PVFS_ENOMEM;
}
memset(sm_p->u.create.datafile_handles, 0,
sm_p->u.io.datafile_count * sizeof(PVFS_handle));
}
sm_p->u.create.datafile_handles[index] = oid;

return 0;
}

static PINT_sm_action setattr_setup_msgpair(
struct PINT_smcb *smcb, job_status_s *js_p)
{
struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
int ret = -PVFS_EINVAL;
PINT_sm_msgpair_state *msg_p = NULL;

js_p->error_code = 0;

PINT_msgpair_init(&sm_p->msgarray_op);
msg_p = &sm_p->msgarray_op.msgpair;

PINT_SERVREQ_SETATTR_FILL(
msg_p->req,
*sm_p->cred_p,
sm_p->object_ref.fs_id,
sm_p->object_ref.handle,
PVFS_TYPE_METAFILE,
sm_p->u.create.attr,
PVFS_ATTR_META_ALL,
sm_p->hints);

msg_p->req.u.setattr.attr.u.meta.dfile_array =
sm_p->u.create.datafile_handles;
msg_p->req.u.setattr.attr.u.meta.dfile_count =
sm_p->u.io.datafile_count;
msg_p->req.u.setattr.attr.u.meta.dist =
sm_p->getattr.attr.u.meta.dist;
msg_p->req.u.setattr.attr.u.meta.dist_size =
PINT_DIST_PACK_SIZE(sm_p->getattr.attr.u.meta.dist);
msg_p->req.u.setattr.attr.owner = sm_p->getattr.attr.owner;
msg_p->req.u.setattr.attr.perms = sm_p->getattr.attr.perms;
msg_p->req.u.setattr.attr.mask = sm_p->getattr.attr.mask;

msg_p->fs_id = sm_p->object_ref.fs_id;
msg_p->handle = sm_p->object_ref.handle;
msg_p->retry_flag = PVFS_MSGPAIR_NO_RETRY;
msg_p->comp_fn = setattr_comp_fn;

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

PINT_sm_push_frame(smcb, 0, &sm_p->msgarray_op);
return SM_ACTION_COMPLETE;
}

static int setattr_comp_fn(void *v_p,
struct PVFS_server_resp *resp_p,
int index)
{
int res, status;
PINT_smcb *smcb = v_p;
PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM);

gossip_debug(GOSSIP_CLIENT_DEBUG, "create_setattr_comp_fn\n");

assert(resp_p->op == PVFS_SERV_SETATTR);
status = resp_p->status;

res = PINT_copy_object_attr(&sm_p->u.create.cache_attr,
&sm_p->msgarray_op.msgpair.req.u.setattr.attr);

if(res != 0)
{
return res;
}

return status;
}

/**
* We assume that the response buffer hasn't been freed yet (before the
* completion function is called. The msgpairarray.sm doesn't free the
Expand Down Expand Up @@ -985,24 +1094,30 @@ out:

static int osd_io_cleanup(struct PINT_smcb *smcb, job_status_s *js_p)
{
gossip_err("osd_io_cleanup\n");
struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
struct PINT_client_io_sm *io = &sm_p->u.io;
int skip = 0;
if(skip) {
free(sm_p->msgarray_op.msgarray);
sm_p->msgarray_op.msgarray = NULL;
sm_p->msgarray_op.count = 0;
PINT_free_request_states(io->file_req_state);
PINT_free_request_states(io->mem_req_state);
PINT_free_request_state(io->temp_req_state);
free(io->short_read);
free(io->file_data);

/* return this to PVFS_sys_io */
io->io_resp_p->total_completed = sm_p->u.io.total_size;
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);

if(server_config->post_create) {
free(sm_p->msgarray_op.msgarray);
sm_p->msgarray_op.msgarray = NULL;
sm_p->msgarray_op.count = 0;
PINT_free_request_states(io->file_req_state);
PINT_free_request_states(io->mem_req_state);
PINT_free_request_state(io->temp_req_state);
free(io->short_read);
free(io->file_data);

/* return this to PVFS_sys_io */
io->io_resp_p->total_completed = sm_p->u.io.total_size;
}

io->io_resp_p->total_completed = sm_p->u.io.mem_req->aggregate_size - sm_p->u.io.file_req_offset;;

return 1;
}

Expand Down

0 comments on commit b5e886c

Please sign in to comment.