Skip to content

Commit

Permalink
Mkdir checks if the given directory already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
cek10006 committed Oct 11, 2012
1 parent 9a237d9 commit 061124e
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 24 deletions.
2 changes: 1 addition & 1 deletion config.save
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ s,@ECHO_C@,,;t t
s,@ECHO_N@,-n,;t t
s,@ECHO_T@,,;t t
s,@LIBS@, -lcrypto -lssl -ldl,;t t
s,@PVFS2_VERSION@,2.8.6-orangefs-2012-10-03-152301,;t t
s,@PVFS2_VERSION@,2.8.6-orangefs-2012-10-11-023730,;t t
s,@PVFS2_VERSION_MAJOR@,2,;t t
s,@PVFS2_VERSION_MINOR@,8,;t t
s,@PVFS2_VERSION_SUB@,6,;t t
Expand Down
2 changes: 0 additions & 2 deletions src/apps/admin/pvfs2-ls.c
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,6 @@ void print_entry_attr(
if ((attr->objtype == PVFS_TYPE_METAFILE) &&
(attr->mask & PVFS_ATTR_SYS_SIZE))
{
printf("in_here\n");
size = attr->size;
}
else if ((attr->objtype == PVFS_TYPE_SYMLINK) &&
Expand Down Expand Up @@ -1094,7 +1093,6 @@ static void usage(int argc, char** argv)

int main(int argc, char **argv)
{
printf("START_LIST\n");
int ret = -1, i = 0;
char pvfs_path[MAX_NUM_PATHS][PVFS_NAME_MAX];
PVFS_fs_id fs_id_array[MAX_NUM_PATHS] = {0};
Expand Down
13 changes: 13 additions & 0 deletions src/apps/admin/pvfs2-mkdir.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,19 @@ static int make_directory(PVFS_credentials * credentials,
parent_ref.handle = resp_lookup.ref.handle;
parent_ref.fs_id = resp_lookup.ref.fs_id;

/* Clear out any info from previous calls */
memset(&resp_lookup, 0, sizeof(resp_lookup));

ret = PVFS_sys_ref_lookup(fs_id, basename_ptr,
parent_ref, credentials, &resp_lookup,
PVFS2_LOOKUP_LINK_FOLLOW, NULL);

if( ret == 0)
{
fprintf(stderr, "directory exists\n");
return(-1);
}

/* Clear out any info from previous calls */
memset(&resp_mkdir, 0, sizeof(PVFS_sysresp_mkdir));

Expand Down
5 changes: 3 additions & 2 deletions src/client/sysint/sys-create.sm
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ PVFS_error PVFS_sys_create(
static PINT_sm_action create_init(
struct PINT_smcb *smcb, job_status_s *js_p)
{
gossip_err("create_init\n");
struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
job_id_t tmp_id;

Expand Down Expand Up @@ -577,9 +578,9 @@ static int create_datafiles_comp_fn(void *v_p,

gossip_err("create_oid: %d\n", oid);

if (oid < first || oid > last)
/*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));
__func__, llu(oid), llu(first), llu(last));*/

/* The first datafile also happens to be the metafile */
if (is_osd_md && index == 0) {
Expand Down
1 change: 0 additions & 1 deletion src/client/sysint/sys-osd-dir.sm
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,6 @@ static PINT_sm_action osd_dirops_attr4_setup_insert_remove_msgpair(

attr.number = jenkins_one_at_a_time_hash((uint8_t *)object_name,
strlen(object_name) + 1);
gossip_err("sertac: %d\n", attr.number);

ret = osd_command_set_set_attributes(command, PVFS_OSD_META_PID, oid);
if (ret) {
Expand Down
7 changes: 5 additions & 2 deletions src/client/sysint/sys-readdir.sm
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ PVFS_error PVFS_sys_readdir(
static PINT_sm_action readdir_init(
struct PINT_smcb *smcb, job_status_s *js_p)
{
gossip_err("readdir_init\n");
struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
gossip_debug(GOSSIP_CLIENT_DEBUG, "readdir state: init\n");

Expand All @@ -239,7 +238,6 @@ static PINT_sm_action readdir_init(
static PINT_sm_action readdir_msg_setup_msgpair(
struct PINT_smcb *smcb, job_status_s *js_p)
{
gossip_err("readdir_msg_setup_msgpair\n");
struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
int ret = -PVFS_EINVAL;
PINT_sm_msgpair_state *msg_p = NULL;
Expand Down Expand Up @@ -296,6 +294,8 @@ static PINT_sm_action readdir_msg_setup_msgpair(

/* Retrieve the attributes of the collection object */
/* Retrieved attribute numbers are the hashed name of each directory entry */
/*ret = osd_command_set_list_collection(command, PVFS_OSD_META_PID, oid, 0, 1024, 0, 0);*/

ret = osd_command_set_get_attributes(command, PVFS_OSD_META_PID, oid);
if (ret) {
osd_error_xerrno(ret, "%s: osd_command_set_get_attributes failed",
Expand Down Expand Up @@ -334,6 +334,7 @@ static int readdir_msg_comp_fn(void *v_p,
struct PVFS_server_resp *resp_p,
int index)
{
osd_debug("readdir_msg_comp_fn\n");
int ret = 0;
PINT_smcb *smcb = v_p;
PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM);
Expand All @@ -357,6 +358,8 @@ static int readdir_msg_comp_fn(void *v_p,
return ret;
}

//ret = osd_command_list_collection_resolve(command);

/*
* XXX readdir.token and readdir.directory_version are used when we
* use multiple passes to retrieve the dirents. For now, we retrieve
Expand Down
15 changes: 0 additions & 15 deletions src/client/sysint/sys-readdirplus.sm
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,6 @@ static int list_of_meta_servers(PINT_client_sm *sm_p)
PVFS_sysresp_readdirplus *readdirplus_resp = sm_p->u.readdirplus.readdirplus_resp;
int i, ret, err_array_len, attr_array_len;

gossip_err("LIST_OF_META_SERVERS\n");
int is_osd_md = fsid_is_osd_md(sm_p->object_ref.fs_id);
assert(readdirplus_resp);
err_array_len = (sizeof(PVFS_error) *
Expand Down Expand Up @@ -502,7 +501,6 @@ static int list_of_meta_servers(PINT_client_sm *sm_p)
static PINT_sm_action readdirplus_fetch_attrs_setup_msgpair(struct PINT_smcb *smcb,
job_status_s *js_p)
{
gossip_err("readdirplus_fetch_attrs_setup_msgpair\n");
int i, ret;
struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
PINT_sm_msgpair_state *msg_p = NULL;
Expand Down Expand Up @@ -649,7 +647,6 @@ static int readdirplus_fetch_attrs_comp_fn(void *v_p,
struct PVFS_server_resp *resp_p,
int index)
{
gossip_err("readdirplus_fetch_attrs_comp_fn\n");
int ret, status;
PVFS_object_attr *attr = NULL;
PINT_smcb *smcb = v_p;
Expand Down Expand Up @@ -705,7 +702,6 @@ static int readdirplus_fetch_attrs_comp_fn(void *v_p,
return ret;
}

gossip_err("cem: %d\n", sm_p->u.readdirplus.handle_count[index]);
if (sm_p->u.readdirplus.handle_count[index] > 1)
{
for (i = 0; i < sm_p->u.readdirplus.handle_count[index]; i++) {
Expand All @@ -715,7 +711,6 @@ static int readdirplus_fetch_attrs_comp_fn(void *v_p,
&handle_index,
NULL);
assert(handle_index >= 0);
gossip_err("handle_index: %d\n", handle_index);

memcpy(&sm_p->u.readdirplus.obj_attr_array[handle_index].owner, ((struct attribute_get_multi_results *)attr[0].val)->val[((struct attribute_get_multi_results *)attr[0].val)->numoid-(sm_p->u.readdirplus.nhandles-i)], ((struct attribute_get_multi_results *)attr[0].val)->outlen[((struct attribute_get_multi_results *)attr[0].val)->numoid-(sm_p->u.readdirplus.nhandles-i)]);

Expand All @@ -731,7 +726,6 @@ static int readdirplus_fetch_attrs_comp_fn(void *v_p,
sm_p->u.readdirplus.handles[index][0],
&handle_index,
NULL);
gossip_err("handle_index: %d\n", handle_index);

/* memcpy the attributes from osd_command attr to sm_p attr object */
if (*(PVFS_ds_type*)command->attr[4].val == PVFS_TYPE_DIRECTORY) {
Expand Down Expand Up @@ -799,7 +793,6 @@ static int list_of_data_servers(PINT_client_sm *sm_p)
{
int i, ret, nhandles;

gossip_err("LIST_OF_DATA_SERVERS\n");
sm_p->u.readdirplus.svr_count = 0;
sm_p->u.readdirplus.server_addresses = NULL;
sm_p->u.readdirplus.handles = NULL;
Expand Down Expand Up @@ -884,7 +877,6 @@ static int list_of_data_servers(PINT_client_sm *sm_p)
static PINT_sm_action readdirplus_fetch_sizes_setup_msgpair(
struct PINT_smcb *smcb, job_status_s *js_p)
{
gossip_err("readdirplus_fetch_sizes_setup_msgpair\n");
int i, ret;
struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
PINT_sm_msgpair_state *msg_p;
Expand All @@ -911,7 +903,6 @@ static PINT_sm_action readdirplus_fetch_sizes_setup_msgpair(
js_p->error_code = ret;
return SM_ACTION_COMPLETE;
}
gossip_err("sm_p->u.readdirplus.svr_count: %d\n", sm_p->u.readdirplus.svr_count);
if (sm_p->u.readdirplus.svr_count == 0)
{
/* no need to contact any server since there are no regular meta files */
Expand Down Expand Up @@ -1030,8 +1021,6 @@ static PINT_sm_action readdirplus_fetch_sizes_setup_msgpair(
ret = osd_command_set_get_attributes(command, PVFS_OSD_DATA_PID,
sm_p->u.readdirplus.input_handle_array[i].handle);

gossip_err("oid: %d\n", sm_p->u.readdirplus.input_handle_array[i].handle);

if (ret) {
osd_error_xerrno(ret,
"%s: osd_command_set_get_attributes failed",
Expand Down Expand Up @@ -1087,7 +1076,6 @@ static int readdirplus_fetch_sizes_comp_fn(void *v_p,
struct PVFS_server_resp *resp_p,
int index)
{
gossip_err("fetch_sizes_comp_fn\n");
PINT_smcb *smcb = v_p;
PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM);
PVFS_error status;
Expand Down Expand Up @@ -1209,8 +1197,6 @@ static int readdirplus_fetch_sizes_comp_fn(void *v_p,
sm_p->msgarray_op.msgarray[index].handle,
&handle_index,
&aux_index);
gossip_err("handle_index: %d\n", handle_index);
gossip_err("aux_index: %d\n", aux_index);
//sm_p->u.readdirplus.size_array[handle_index][aux_index] = get_ntohll(command->attr[10].val);

/* memcpy the attributes from osd_command attr to sm_p attr object */
Expand Down Expand Up @@ -1267,7 +1253,6 @@ static PINT_sm_action readdirplus_msg_failure(
static PINT_sm_action readdirplus_cleanup(
struct PINT_smcb *smcb, job_status_s *js_p)
{
gossip_err("readdirplus_cleanup\n");
int i;
PVFS_sysresp_readdirplus *readdirplus_resp;
struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
Expand Down
21 changes: 21 additions & 0 deletions src/common/misc/server-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ static DOTCONF_CB(get_osd_type);
static DOTCONF_CB(get_osd_dir_type);
static DOTCONF_CB(get_create_type);
static DOTCONF_CB(get_member_attr_type);
static DOTCONF_CB(get_coll_object_type);
static DOTCONF_CB(get_eco_type);
static DOTCONF_CB(get_eco_num);
static DOTCONF_CB(get_small_file_size);
Expand Down Expand Up @@ -1024,6 +1025,11 @@ static const configoption_t options[] =
* Specifies if getting member attributes is enabled or not
*/
{ "MemberAttr", ARG_STR, get_member_attr_type, NULL, CTX_DEFAULTS, "no" },

/*
* Specifies if collection object should be used as a dir object or not
*/
{ "CollectionObject", ARG_STR, get_coll_object_type, NULL, CTX_DEFAULTS, "no" },

/*
* Specifies if energy saving mode is enabled or not
Expand Down Expand Up @@ -3060,6 +3066,21 @@ static DOTCONF_CB(get_member_attr_type)
return ret;
}

static DOTCONF_CB(get_coll_object_type)
{
const char *str = cmd->data.str;
struct server_configuration_s *config = cmd->context;
const char *ret = NULL;

if (!strcmp(str, "no"))
config->coll_object = NO_COLL_OBJECT;
else if (!strcmp(str, "yes"))
config->coll_object = COLL_OBJECT;
else
ret = "get_coll_object_type: unknown FileSystem CollectionObject option\n";
return ret;
}

static DOTCONF_CB(get_eco_type)
{
const char *str = cmd->data.str;
Expand Down
6 changes: 5 additions & 1 deletion src/common/misc/server-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,11 @@ typedef struct server_configuration_s
NO_MEMBER_ATTR, /* fetch attributes of a single object at once */
GET_MEMBER_ATTR, /* fetch attributes of all the objects that are members of a collection */
} member_attr;


enum {
NO_COLL_OBJECT, /* do not use the collection objects as directories */
COLL_OBJECT, /* use the collection objects as directories */
} coll_object;
enum {
NO_ENERGY_SAVING, /* fetch attributes of a single object at once */
ENERGY_SAVING, /* fetch attributes of all the objects that are members of a collection */
Expand Down

0 comments on commit 061124e

Please sign in to comment.