From 0cf31869cb085cdab90d34665b73f6db2d13361d Mon Sep 17 00:00:00 2001 From: Cengiz Karakoyunlu Date: Fri, 16 Mar 2012 21:04:11 +0000 Subject: [PATCH] "create object and create collection can get oids from the same extent array. failure of creates is not handled yet. none of the osd functions uses 0 oid" git-svn-id: svn+ssh://137.99.13.219/srv/svn/ofsproject/ofsproject/2.8.4-stock/osd_branch@56 dfcdf660-53a5-499b-8775-f9b82cf2d3b9 --- src/client/sysint/client-state-machine.h | 1 + src/client/sysint/sys-create.sm | 1 - src/client/sysint/sys-getattr.sm | 13 ++--- src/client/sysint/sys-mkdir.sm | 48 ++++++++----------- src/client/sysint/sys-setattr.sm | 2 +- .../trove-handle-mgmt/trove-handle-mgmt.c | 17 ------- src/proto/pvfs2-req-proto.h | 6 ++- src/server/create.sm | 1 + src/server/mkdir.sm | 36 +++++++++++++- src/server/module.mk.in | 4 ++ src/server/statfs.sm | 1 - 11 files changed, 71 insertions(+), 59 deletions(-) diff --git a/src/client/sysint/client-state-machine.h b/src/client/sysint/client-state-machine.h index d96812f..f97b2af 100644 --- a/src/client/sysint/client-state-machine.h +++ b/src/client/sysint/client-state-machine.h @@ -107,6 +107,7 @@ struct PINT_client_mkdir_sm PVFS_sys_attr sys_attr; /* input parameter */ PVFS_ds_keyval *key_array; PVFS_ds_keyval *val_array; + PVFS_handle cid; int retry_count; int stored_error_code; diff --git a/src/client/sysint/sys-create.sm b/src/client/sysint/sys-create.sm index 94a24a3..c1a3df7 100644 --- a/src/client/sysint/sys-create.sm +++ b/src/client/sysint/sys-create.sm @@ -830,7 +830,6 @@ static PINT_sm_action create_datafiles_setup_msgpair_array( * low bound of the extent array. So as we create handles, we get * them in increasing order that satisfies our extent bounds. */ - gossip_err("%d\n", sm_p->u.create.datafile_handles[0]); 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", diff --git a/src/client/sysint/sys-getattr.sm b/src/client/sysint/sys-getattr.sm index b2049df..e3a611b 100644 --- a/src/client/sysint/sys-getattr.sm +++ b/src/client/sysint/sys-getattr.sm @@ -369,13 +369,13 @@ static PINT_sm_action getattr_acache_lookup( &attr_status, &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: " @@ -1439,7 +1439,7 @@ static PINT_sm_action getattr_cleanup( { struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); PINT_sm_getattr_state *getattr = &(sm_p->getattr); - + gossip_debug(GOSSIP_CLIENT_DEBUG, "(%p) getattr state: getattr_cleanup\n", sm_p); @@ -1475,7 +1475,7 @@ static PINT_sm_action getattr_cleanup( PINT_dist_free(getattr->attr.u.meta.dist); } }/*end if error*/ - + return SM_ACTION_COMPLETE; } @@ -1491,7 +1491,7 @@ static PINT_sm_action getattr_set_sys_response( PINT_SET_OP_COMPLETE; return SM_ACTION_TERMINATE; } - + attr = &sm_p->getattr.attr; assert(attr); @@ -1591,6 +1591,7 @@ static PINT_sm_action getattr_set_sys_response( sysresp->attr.mask = PVFS_util_object_to_sys_attr_mask(attr->mask); sysresp->attr.size = 0; sysresp->attr.objtype = attr->objtype; + sysresp->attr.cid = attr->cid; if (js_p->error_code == 0) { @@ -1638,7 +1639,7 @@ static PINT_sm_action getattr_set_sys_response( memset(sm_p->u.getattr.getattr_resp_p, 0, sizeof(PVFS_sysresp_getattr)); } - + PINT_SM_GETATTR_STATE_CLEAR(sm_p->getattr); PINT_SET_OP_COMPLETE; diff --git a/src/client/sysint/sys-mkdir.sm b/src/client/sysint/sys-mkdir.sm index bc4dfe1..a1e2825 100644 --- a/src/client/sysint/sys-mkdir.sm +++ b/src/client/sysint/sys-mkdir.sm @@ -55,7 +55,6 @@ machine pvfs2_client_mkdir_sm state init { run mkdir_init; - CREATE_COLLECTION => create_collection; default => parent_getattr; } @@ -83,7 +82,7 @@ machine pvfs2_client_mkdir_sm state mkdir_msg_xfer_msgpair { jump pvfs2_msgpairarray_sm; - success => mkdir_seteattr_setup_msgpair; + success => create_collection; default => mkdir_msg_failure; } @@ -92,6 +91,20 @@ machine pvfs2_client_mkdir_sm run mkdir_msg_failure; default => cleanup; } + + state create_collection + { + run create_collection_setup_msgpair; + success => create_collection_xfer_msgpair; + default => mkdir_crdirent_failure; + } + + state create_collection_xfer_msgpair + { + jump pvfs2_osd_msgpairarray_sm; + success => mkdir_seteattr_setup_msgpair; + default => mkdir_crdirent_failure; + } state mkdir_seteattr_setup_msgpair { @@ -128,20 +141,6 @@ machine pvfs2_client_mkdir_sm default => mkdir_crdirent_failure; } - state create_collection - { - run create_collection_setup_msgpair; - success => create_collection_xfer_msgpair; - default => mkdir_crdirent_failure; - } - - state create_collection_xfer_msgpair - { - jump pvfs2_osd_msgpairarray_sm; - success => parent_getattr; - default => mkdir_crdirent_failure; - } - state mkdir_crdirent_failure { run mkdir_crdirent_failure; @@ -282,14 +281,6 @@ static PINT_sm_action mkdir_init( { struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); job_id_t tmp_id; - 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->member_attr) - js_p->error_code = CREATE_COLLECTION; gossip_debug(GOSSIP_CLIENT_DEBUG, "mkdir state: init\n"); @@ -334,6 +325,7 @@ static int mkdir_msg_comp_fn(void *v_p, /* otherwise, just stash the newly created meta handle */ sm_p->u.mkdir.metafile_handle = resp_p->u.mkdir.handle; + sm_p->u.mkdir.cid = resp_p->u.mkdir.cid; /* also insert entry into attr cache */ PINT_CONVERT_ATTR(&attr, &sm_p->u.mkdir.sys_attr, 0); @@ -395,8 +387,6 @@ static PINT_sm_action mkdir_msg_setup_msgpair( return SM_ACTION_COMPLETE; } - sm_p->u.mkdir.sys_attr.cid = sm_p->object_ref.cid; - PINT_SERVREQ_MKDIR_FILL( msg_p->req, *sm_p->cred_p, @@ -477,7 +467,7 @@ static PINT_sm_action create_collection_setup_msgpair( struct attribute_list attr = { ATTR_GET, CUR_CMD_ATTR_PG, CCAP_OID, NULL, CCAP_OID_LEN }; - ret = osd_command_set_create_collection(command, PVFS_OSD_DATA_PID, 0); + ret = osd_command_set_create_collection(command, PVFS_OSD_DATA_PID, sm_p->u.mkdir.cid); if (ret) { osd_error_xerrno(ret, "%s: osd_command_set_create_collection failed", @@ -527,7 +517,7 @@ static int create_collection_comp_fn(void *v_p, if (ret) { osd_error_xerrno(ret, "%s: attr_resolve failed", __func__); } - + sm_p->object_ref.cid = get_ntohll(sm_p->msgarray_op.msgpair.osd_command.attr[0].val); osd_command_attr_free(&sm_p->msgarray_op.msgpair.osd_command); @@ -677,7 +667,7 @@ static PINT_sm_action mkdir_cleanup( directory_ref.handle = sm_p->u.mkdir.metafile_handle; directory_ref.fs_id = sm_p->object_ref.fs_id; - + sm_p->u.mkdir.mkdir_resp->ref.handle = directory_ref.handle; sm_p->u.mkdir.mkdir_resp->ref.fs_id = directory_ref.fs_id; diff --git a/src/client/sysint/sys-setattr.sm b/src/client/sysint/sys-setattr.sm index 28f10da..b49a81b 100644 --- a/src/client/sysint/sys-setattr.sm +++ b/src/client/sysint/sys-setattr.sm @@ -339,7 +339,7 @@ static PINT_sm_action setattr_msg_setup_msgpair( 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; } diff --git a/src/io/trove/trove-handle-mgmt/trove-handle-mgmt.c b/src/io/trove/trove-handle-mgmt/trove-handle-mgmt.c index 4197341..2049e88 100644 --- a/src/io/trove/trove-handle-mgmt/trove-handle-mgmt.c +++ b/src/io/trove/trove-handle-mgmt/trove-handle-mgmt.c @@ -34,7 +34,6 @@ typedef struct } handle_ledger_t; static struct qhash_table *s_fsid_to_ledger_table = NULL; -static struct qhash_table *s_fsid_to_osd_ledger_table = NULL; /* these are based on code from src/server/request-scheduler.c */ static int hash_fsid(void *fsid, int table_size); @@ -58,7 +57,6 @@ static int trove_check_handle_ranges(TROVE_coll_id coll_id, PINT_llist *extent_list, struct handle_ledger *ledger) { - gossip_err("trove_check_handle_ranges\n"); int ret = -1, i = 0, count = 0, op_count = 0; TROVE_op_id op_id = 0; TROVE_ds_state state = 0; @@ -143,7 +141,6 @@ static int trove_check_handle_ranges(TROVE_coll_id coll_id, static int trove_map_handle_ranges( PINT_llist *extent_list, struct handle_ledger *ledger) { - gossip_err("trove_map_handle_ranges\n"); int ret = -1; PINT_llist *cur = NULL; PVFS_handle_extent *cur_extent = NULL; @@ -179,7 +176,6 @@ static int trove_map_handle_ranges( PINT_llist *extent_list, static handle_ledger_t *get_or_add_handle_ledger(TROVE_coll_id coll_id) { - gossip_err("get_or_add_handle_ledger\n"); handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; @@ -222,7 +218,6 @@ static handle_ledger_t *get_or_add_handle_ledger(TROVE_coll_id coll_id) */ static int hash_fsid(void *fsid, int table_size) { - gossip_err("hash_fsid\n"); /* TODO: update this later with a better hash function, * depending on what fsids look like, for now just modding * @@ -245,7 +240,6 @@ static int hash_fsid(void *fsid, int table_size) */ static int hash_fsid_compare(void *key, struct qlist_head *link) { - gossip_err("hash_fsid_compare\n"); handle_ledger_t *ledger = NULL; TROVE_coll_id *real_fsid = (TROVE_coll_id *)key; @@ -261,7 +255,6 @@ static int hash_fsid_compare(void *key, struct qlist_head *link) int trove_handle_mgmt_initialize() { - gossip_err("trove_handle_mgmt_initialize\n"); /* due to weird trove_initialize usages; this will always succeed unless the hash table initialization really fails. @@ -284,7 +277,6 @@ int trove_set_handle_ranges(TROVE_coll_id coll_id, TROVE_context_id context_id, char *handle_range_str) { - gossip_err("trove_set_handle_ranges\n"); int ret = -TROVE_EINVAL; PINT_llist *extent_list = NULL; handle_ledger_t *ledger = NULL; @@ -342,7 +334,6 @@ int trove_set_handle_timeout(TROVE_coll_id coll_id, TROVE_context_id context_id, struct timeval *timeout) { - gossip_err("trove_set_handle_timeout\n"); int ret = -1; handle_ledger_t *ledger = NULL; @@ -372,7 +363,6 @@ int trove_set_handle_timeout(TROVE_coll_id coll_id, TROVE_handle trove_handle_alloc(TROVE_coll_id coll_id) { - gossip_err("trove_handle_alloc\n"); handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; TROVE_handle handle = TROVE_HANDLE_NULL; @@ -395,7 +385,6 @@ TROVE_handle trove_handle_alloc_from_range( TROVE_coll_id coll_id, TROVE_handle_extent_array *extent_array) { - gossip_err("trove_handle_alloc_from_range\n"); handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; TROVE_handle handle = TROVE_HANDLE_NULL; @@ -429,7 +418,6 @@ int trove_handle_peek( int max_num_handles, int *returned_handle_count) { - gossip_err("trove_handle_peek\n"); int ret = -TROVE_EINVAL; handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; @@ -462,7 +450,6 @@ int trove_handle_peek_from_range( int max_num_handles, int *returned_handle_count) { - gossip_err("trove_handle_peek_from_range\n"); int ret = -TROVE_EINVAL, i = 0; handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; @@ -503,7 +490,6 @@ int trove_handle_peek_from_range( int trove_handle_set_used(TROVE_coll_id coll_id, TROVE_handle handle) { - gossip_err("trove_handle_set_used\n"); int ret = -1; handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; @@ -524,7 +510,6 @@ int trove_handle_set_used(TROVE_coll_id coll_id, TROVE_handle handle) int trove_handle_free(TROVE_coll_id coll_id, TROVE_handle handle) { - gossip_err("trove_handle_free\n"); int ret = -1; handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; @@ -552,7 +537,6 @@ int trove_handle_free(TROVE_coll_id coll_id, TROVE_handle handle) */ int trove_handle_get_statistics(TROVE_coll_id coll_id, uint64_t* free_count) { - gossip_err("trove_handle_get_statistics\n"); handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; @@ -583,7 +567,6 @@ int trove_handle_get_statistics(TROVE_coll_id coll_id, uint64_t* free_count) int trove_handle_mgmt_finalize() { - gossip_err("trove_handle_mgmt_finalize\n"); int i; handle_ledger_t *ledger = NULL; struct qlist_head *hash_link = NULL; diff --git a/src/proto/pvfs2-req-proto.h b/src/proto/pvfs2-req-proto.h index 0c4894f..714f6fb 100644 --- a/src/proto/pvfs2-req-proto.h +++ b/src/proto/pvfs2-req-proto.h @@ -793,10 +793,12 @@ do { \ struct PVFS_servresp_mkdir { PVFS_handle handle; /* handle of new directory */ + PVFS_handle cid; }; -endecode_fields_1_struct( +endecode_fields_2_struct( PVFS_servresp_mkdir, - PVFS_handle, handle); + PVFS_handle, handle, + PVFS_handle, cid); /* create dirent ***********************************************/ /* - creates a new entry within an existing directory */ diff --git a/src/server/create.sm b/src/server/create.sm index 998c891..a42aa56 100644 --- a/src/server/create.sm +++ b/src/server/create.sm @@ -14,6 +14,7 @@ #include "pvfs2-internal.h" #include "pint-util.h" #include "pint-cached-config.h" +#include "trove-handle-mgmt.h" #define REPLACE_DONE 100 diff --git a/src/server/mkdir.sm b/src/server/mkdir.sm index 52467da..b0127a0 100644 --- a/src/server/mkdir.sm +++ b/src/server/mkdir.sm @@ -14,6 +14,8 @@ #include "pvfs2-util.h" #include "pvfs2-internal.h" #include "pint-util.h" +#include "pint-cached-config.h" +#include "trove-handle-mgmt.h" %% @@ -109,7 +111,7 @@ static PINT_sm_action mkdir_create( struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); int ret; job_id_t i; - + gossip_debug(GOSSIP_MKDIR_DEBUG, " creating dspace on coll_id %d\n", s_op->u.mkdir.fs_id); @@ -118,7 +120,7 @@ static PINT_sm_action mkdir_create( "be in starting hrange[0] %llu-%llu\n", llu(s_op->u.mkdir.handle_extent_array.extent_array[0].first), llu(s_op->u.mkdir.handle_extent_array.extent_array[0].last)); - + ret = job_trove_dspace_create( s_op->u.mkdir.fs_id, &s_op->u.mkdir.handle_extent_array, PVFS_TYPE_DIRECTORY, NULL, @@ -282,10 +284,40 @@ static PINT_sm_action mkdir_prep_sm( struct PINT_server_op *s_op = PINT_sm_frame(smcb, PINT_FRAME_CURRENT); PVFS_object_attr *a_p = NULL; PVFS_ds_attributes *ds_attr = NULL; + + PVFS_handle_extent_array data_handle_ext_array; + PINT_llist *cur = NULL; + struct host_alias_s *cur_alias; + server_configuration_s *config = get_server_config_struct(); s_op->u.mkdir.fs_id = s_op->req->u.mkdir.fs_id; s_op->u.mkdir.handle_extent_array = s_op->req->u.mkdir.handle_extent_array; + + if(config->osd_type == OSD_DATAFILE) + { + cur = config->host_aliases; + while(cur) + { + cur_alias = PINT_llist_head(cur); + if (!cur_alias) + { + break; + } + if(!strncmp(cur_alias->bmi_address, "osd", 3)) { + PINT_cached_config_get_server( + s_op->req->u.create.fs_id, + cur_alias->bmi_address, + PINT_SERVER_TYPE_IO, + &data_handle_ext_array); + } + cur = PINT_llist_next(cur); + } + + s_op->resp.u.mkdir.cid = malloc(sizeof(PVFS_handle)); + s_op->resp.u.mkdir.cid = trove_handle_alloc_from_range(s_op->req->u.create.fs_id, &data_handle_ext_array); + s_op->req->u.mkdir.attr.cid = s_op->resp.u.mkdir.cid; + } a_p = &(s_op->req->u.mkdir.attr); diff --git a/src/server/module.mk.in b/src/server/module.mk.in index afbafc7..08db68b 100644 --- a/src/server/module.mk.in +++ b/src/server/module.mk.in @@ -64,6 +64,10 @@ ifdef BUILD_SERVER # to stat the fs, need to know about handle statistics MODCFLAGS_$(DIR)/statfs.c = \ -I$(srcdir)/src/io/trove/trove-handle-mgmt + MODCFLAGS_$(DIR)/create.c = \ + -I$(srcdir)/src/io/trove/trove-handle-mgmt + MODCFLAGS_$(DIR)/mkdir.c = \ + -I$(srcdir)/src/io/trove/trove-handle-mgmt ifdef PVFS2_SEGV_BACKTRACE MODCFLAGS_$(DIR)/pvfs2-server.c := -D__PVFS2_SEGV_BACKTRACE__ diff --git a/src/server/statfs.sm b/src/server/statfs.sm index 9e62503..62c174d 100644 --- a/src/server/statfs.sm +++ b/src/server/statfs.sm @@ -12,7 +12,6 @@ #include #include "pvfs2-server.h" -#include "trove-handle-mgmt.h" #include "pint-cached-config.h" #ifdef HAVE_SYSINFO