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
190 lines (160 sloc) 4.43 KB
/*
* (C) 2003 Clemson University and The University of Chicago
*
* See COPYING in top-level directory.
*/
/** \file
* \ingroup mgmtint
*
* PVFS2 management interface routines for obtaining datafile handles
* for a given file.
*
* This are used primarily for file system check and repair purposes.
*/
#include <string.h>
#include <assert.h>
#include "client-state-machine.h"
#include "pvfs2-debug.h"
#include "job.h"
#include "gossip.h"
#include "str-utils.h"
#include "pint-cached-config.h"
#include "PINT-reqproto-encode.h"
#include "pint-util.h"
extern job_context_id pint_client_sm_context;
%%
machine pvfs2_client_mgmt_get_dfile_array_sm
{
state getattr
{
jump pvfs2_client_getattr_sm;
default => cleanup;
}
state cleanup
{
run mgmt_get_dfile_array_cleanup;
default => terminate;
}
}
%%
/** Initiate retrieval of list of handles of datafiles associated with
* a given file.
*/
PVFS_error PVFS_imgmt_get_dfile_array(
PVFS_object_ref ref,
PVFS_credentials *credentials,
PVFS_handle *dfile_array,
int dfile_count,
PVFS_mgmt_op_id *op_id,
PVFS_hint hints,
void *user_ptr)
{
PVFS_error ret = -PVFS_EINVAL;
PINT_smcb *smcb = NULL;
PINT_client_sm *sm_p = NULL;
gossip_debug(GOSSIP_CLIENT_DEBUG,
"PVFS_imgmt_get_dfile_array entered\n");
if (!dfile_array)
{
return ret;
}
PINT_smcb_alloc(&smcb, PVFS_MGMT_GET_DFILE_ARRAY,
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, ref.fs_id);
PINT_init_sysint_credentials(sm_p->cred_p, credentials);
sm_p->object_ref = ref;
sm_p->u.get_dfile_array.dfile_array = dfile_array;
sm_p->u.get_dfile_array.dfile_count = dfile_count;
PVFS_hint_copy(hints, &sm_p->hints);
PINT_SM_GETATTR_STATE_FILL(
sm_p->getattr,
ref,
PVFS_ATTR_META_ALL|PVFS_ATTR_COMMON_TYPE,
PVFS_TYPE_METAFILE,
0);
return PINT_client_state_machine_post(
smcb, op_id, user_ptr);
}
/** Obtain the list of handles of datafiles associated with a given file.
*/
PVFS_error PVFS_mgmt_get_dfile_array(
PVFS_object_ref ref,
PVFS_credentials *credentials,
PVFS_handle *dfile_array,
int dfile_count,
PVFS_hint hints)
{
PVFS_error ret = -PVFS_EINVAL, error = 0;
PVFS_mgmt_op_id op_id;
gossip_debug(GOSSIP_CLIENT_DEBUG,
"PVFS_mgmt_get_dfile_array entered\n");
ret = PVFS_imgmt_get_dfile_array(
ref, credentials, dfile_array, dfile_count, &op_id, hints, NULL);
if (ret)
{
PVFS_perror_gossip("PVFS_imgmt_get_dfile_array call", ret);
error = ret;
}
else
{
if (op_id >= 0) /* -1 means completed immediately */
{
ret = PVFS_mgmt_wait(op_id, "get_dfile_array", &error);
if (ret)
{
PVFS_perror_gossip("PVFS_mgmt_wait call", ret);
error = ret;
}
}
}
if (op_id >= 0)
PINT_mgmt_release(op_id);
return error;
}
/****************************************************************/
static PINT_sm_action mgmt_get_dfile_array_cleanup(
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;
gossip_debug(GOSSIP_CLIENT_DEBUG,
"mgmt_get_dfile_array state: cleanup\n");
sm_p->error_code = js_p->error_code;
if (sm_p->error_code == 0)
{
attr = &sm_p->getattr.attr;
assert(attr);
assert(attr->mask & PVFS_ATTR_META_DFILES);
assert(attr->u.meta.dfile_count > 0);
/* copy out going parameters */
sm_p->u.get_dfile_array.dfile_count =
attr->u.meta.dfile_count;
memcpy(sm_p->u.get_dfile_array.dfile_array,
attr->u.meta.dfile_array,
(attr->u.meta.dfile_count * sizeof(PVFS_handle)));
}
else
{
PINT_acache_invalidate(sm_p->object_ref);
}
PINT_SM_GETATTR_STATE_CLEAR(sm_p->getattr);
PINT_SET_OP_COMPLETE;
return SM_ACTION_TERMINATE;
}
/*
* Local variables:
* mode: c
* c-indent-level: 4
* c-basic-offset: 4
* End:
*
* vim: ft=c ts=8 sts=4 sw=4 expandtab
*/