Skip to content
Permalink
1139b72d5e
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
243 lines (206 sloc) 6.1 KB
/*
* (C) 2003 Clemson University and The University of Chicago
*
* See COPYING in top-level directory.
*/
/** \file
* \ingroup mgmtint
*
* PVFS management interface routines for obtaining server UID (user ID)
* information. This is used to determine which user's are sending
* requests to a given server.
*/
#include "client-state-machine.h"
#include "pvfs2-debug.h"
#include "job.h"
#include "gossip.h"
#include "pvfs2-mgmt.h"
extern job_context_id pint_client_sm_context;
static int get_uid_list_comp_fn(
void* v_p, struct PVFS_server_resp *resp_p, int i);
%%
machine pvfs2_client_mgmt_get_uid_list_sm
{
state setup_msgpair
{
run mgmt_get_uid_list_setup_msgpair;
success => xfer_msgpair;
default => cleanup;
}
state xfer_msgpair
{
jump pvfs2_msgpairarray_sm;
default => cleanup;
}
state cleanup
{
run mgmt_get_uid_list_cleanup;
default => terminate;
}
}
%%
PVFS_error PVFS_imgmt_get_uid_list(
PVFS_fs_id fs_id,
PVFS_credentials *credentials,
int server_count,
PVFS_BMI_addr_t *addr_array,
uint32_t history,
PVFS_uid_info_s **uid_info_array,
uint32_t *uid_count,
PVFS_mgmt_op_id *op_id,
PVFS_hint hints,
void *user_ptr)
{
PINT_smcb *smcb = NULL;
PINT_client_sm *sm_p = NULL;
int ret = 0;
gossip_debug(GOSSIP_CLIENT_DEBUG,
"PVFS_imgmt_get_uid_list entered\n");
if ((server_count < 1) || (!addr_array) || (history < 1) ||
(!uid_info_array) || (!uid_count))
{
return -PVFS_EINVAL;
}
PINT_smcb_alloc(&smcb, PVFS_MGMT_GET_UID_LIST,
sizeof(struct PINT_client_sm),
client_op_state_get_machine,
client_state_machine_terminate,
pint_client_sm_context);
if (!smcb)
{
return -PVFS_ENOMEM;
}
sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
PINT_init_msgarray_params(sm_p, fs_id);
PINT_init_sysint_credentials(sm_p->cred_p, credentials);
sm_p->u.get_uid_list.uid_statistics = uid_info_array;
sm_p->u.get_uid_list.history = history;
sm_p->u.get_uid_list.fs_id = fs_id;
sm_p->u.get_uid_list.server_count = server_count;
sm_p->u.get_uid_list.addr_array = addr_array;
sm_p->u.get_uid_list.uid_count = uid_count;
PVFS_hint_copy(hints, &sm_p->hints);
ret = PINT_msgpairarray_init(&sm_p->msgarray_op, server_count);
if (ret != 0)
{
PINT_smcb_free(smcb);
return ret;
}
return PINT_client_state_machine_post(
smcb, op_id, user_ptr);
}
PVFS_error PVFS_mgmt_get_uid_list(
PVFS_fs_id fs_id,
PVFS_credentials *credentials,
int server_count,
PVFS_BMI_addr_t *addr_array,
uint32_t history,
PVFS_uid_info_s **uid_info_array,
uint32_t *uid_count,
PVFS_hint hints,
void *user_ptr)
{
PVFS_error ret = -PVFS_EINVAL, error = 0;
PVFS_mgmt_op_id op_id;
gossip_debug(GOSSIP_CLIENT_DEBUG,
"PVFS_mgmt_get_uid_list entered\n");
ret = PVFS_imgmt_get_uid_list(fs_id, credentials, server_count, addr_array,
history, uid_info_array, uid_count, &op_id, hints, NULL);
if (ret)
{
PVFS_perror_gossip("PVFS_imgmt_get_uid_list call", ret);
error = ret;
}
else
{
ret = PVFS_mgmt_wait(op_id, "get_uid_list", &error);
if (ret)
{
PVFS_perror_gossip("PVFS_mgmt_wait call", ret);
error = ret;
}
}
gossip_debug(GOSSIP_CLIENT_DEBUG,
"PVFS_mgmt_get_uid_list completed\n");
PINT_mgmt_release(op_id);
return error;
}
static PINT_sm_action mgmt_get_uid_list_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 i = 0;
PINT_sm_msgpair_state *msg_p = NULL;
gossip_debug(GOSSIP_CLIENT_DEBUG, "get_uid_list state: "
"mgmt_get_uid_list_setup_msgpair\n");
/* setup msgpair array */
foreach_msgpair(&sm_p->msgarray_op, msg_p, i)
{
PINT_SERVREQ_MGMT_GET_UID_FILL(
msg_p->req,
*sm_p->cred_p,
sm_p->u.get_uid_list.history,
sm_p->hints);
msg_p->fs_id = sm_p->u.get_uid_list.fs_id;
msg_p->handle = PVFS_HANDLE_NULL;
msg_p->retry_flag = PVFS_MSGPAIR_RETRY;
msg_p->comp_fn = get_uid_list_comp_fn;
msg_p->svr_addr = sm_p->u.get_uid_list.addr_array[i];
}
/* immediate return: next state jumps to msgpairarray machine */
js_p->error_code = 0;
PINT_sm_push_frame(smcb, 0, &sm_p->msgarray_op);
return SM_ACTION_COMPLETE;
}
static PINT_sm_action mgmt_get_uid_list_cleanup(
struct PINT_smcb *smcb, job_status_s *js_p)
{
struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
PINT_msgpairarray_destroy(&sm_p->msgarray_op);
sm_p->error_code = js_p->error_code;
PINT_SET_OP_COMPLETE;
return SM_ACTION_TERMINATE;
}
static int get_uid_list_comp_fn(void* v_p,
struct PVFS_server_resp *resp_p,
int i)
{
int j = 0;
PINT_smcb *smcb = v_p;
PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_MSGPAIR_PARENT_SM);
/* if this particular request was successful, then store the
* performance information in an array to be returned to caller
*/
if (sm_p->msgarray_op.msgarray[i].op_status == 0)
{
(sm_p->u.get_uid_list.uid_count)[i] =
resp_p->u.mgmt_get_uid.uid_info_array_count;
memcpy(sm_p->u.get_uid_list.uid_statistics[i],
resp_p->u.mgmt_get_uid.uid_info_array,
resp_p->u.mgmt_get_uid.uid_info_array_count
* sizeof(PVFS_uid_info_s));
}
/* if this is the last response, check all of the status values and
* return error code if any requests failed
*/
if (i == (sm_p->msgarray_op.count -1))
{
for (j=0; j < sm_p->msgarray_op.count; j++)
{
if (sm_p->msgarray_op.msgarray[j].op_status != 0)
{
return(sm_p->msgarray_op.msgarray[j].op_status);
}
}
}
return 0;
}
/*
* Local variables:
* mode: c
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ft=c ts=8 sts=4 sw=4 expandtab
*/