[Pvfs2-cvs] commit by dbonnie in pvfs2/src/common/misc: pint-hint.h
msgpairarray.h msgpairarray.sm pint-cached-config.c
pint-util.c pint-util.h pvfs2-util.c server-config.c
state-machine-fns.c
CVS commit program
cvs at parl.clemson.edu
Fri May 16 11:15:35 EDT 2008
Update of /anoncvs/pvfs2/src/common/misc
In directory parlweb1:/tmp/cvs-serv1762/src/common/misc
Modified Files:
Tag: cu-security-branch
msgpairarray.h msgpairarray.sm pint-cached-config.c
pint-util.c pint-util.h pvfs2-util.c server-config.c
state-machine-fns.c
Added Files:
Tag: cu-security-branch
pint-hint.h
Log Message:
Updated branch with code from HEAD
--- /dev/null 2004-06-24 14:04:38.000000000 -0400
+++ pint-hint.h 2008-05-16 11:15:35.000000000 -0400
@@ -0,0 +1,82 @@
+
+/*
+ * (C) 2001 Clemson University and The University of Chicago
+ *
+ * See COPYING in top-level directory.
+ */
+
+#ifndef __PINT_HINT_H__
+#define __PINT_HINT_H__
+
+#define PVFS_HINT_MAX 24
+#define PVFS_HINT_MAX_LENGTH 1024
+#define PVFS_HINT_MAX_NAME_LENGTH 512
+
+#include "pvfs2-hint.h"
+
+enum PINT_hint_type
+{
+ PINT_HINT_UNKNOWN = 0,
+ PINT_HINT_REQUEST_ID,
+ PINT_HINT_CLIENT_ID,
+ PINT_HINT_HANDLE,
+ PINT_HINT_OP_ID,
+};
+
+typedef struct PVFS_hint_s
+{
+ enum PINT_hint_type type;
+ char *type_string;
+ char *value;
+ int32_t length;
+
+ void (*encode)(char **pptr, void *value);
+ void (*decode)(char **pptr, void *value);
+
+ int flags;
+ struct PVFS_hint_s *next;
+
+} PINT_hint;
+
+void encode_PINT_hint(char **pptr, const PINT_hint *hint);
+void decode_PINT_hint(char **pptr, PINT_hint **hint);
+
+void *PINT_hint_get_value_by_type(PINT_hint *hint, enum PINT_hint_type type,
+ int *length);
+
+void *PINT_hint_get_value_by_name(
+ PINT_hint *hint, const char *name, int *length);
+
+int PVFS_hint_add_internal(
+ PVFS_hint *hint,
+ enum PINT_hint_type type,
+ int length,
+ void *value);
+
+#define PINT_HINT_GET_REQUEST_ID(hints) \
+ PINT_hint_get_value_by_type(hints, PINT_HINT_REQUEST_ID, NULL) ? \
+ *(uint32_t *)PINT_hint_get_value_by_type(hints, PINT_HINT_REQUEST_ID, NULL) : 0
+
+#define PINT_HINT_GET_CLIENT_ID(hints) \
+ PINT_hint_get_value_by_type(hints, PINT_HINT_CLIENT_ID, NULL) ? \
+ *(uint32_t *)PINT_hint_get_value_by_type(hints, PINT_HINT_CLIENT_ID, NULL) : 0
+
+#define PINT_HINT_GET_HANDLE(hints) \
+ PINT_hint_get_value_by_type(hints, PINT_HINT_HANDLE, NULL) ? \
+ *(uint64_t *)PINT_hint_get_value_by_type(hints, PINT_HINT_HANDLE, NULL) : 0
+
+#define PINT_HINT_GET_OP_ID(hints) \
+ PINT_hint_get_value_by_type(hints, PINT_HINT_OP_ID, NULL) ? \
+ *(uint32_t *)PINT_hint_get_value_by_type(hints, PINT_HINT_OP_ID, NULL) : 0
+
+#endif /* __PINT_HINT_H__ */
+
+/*
+ * Local variables:
+ * mode: c
+ * c-indent-level: 4
+ * c-basic-offset: 4
+ * End:
+ *
+ * vim: ft=c ts=8 sts=4 sw=4 expandtab
+ */
Index: msgpairarray.h
===================================================================
RCS file: /anoncvs/pvfs2/src/common/misc/msgpairarray.h,v
diff -p -u -r1.11 -r1.11.48.1
--- msgpairarray.h 14 Dec 2005 21:50:19 -0000 1.11
+++ msgpairarray.h 16 May 2008 15:15:34 -0000 1.11.48.1
@@ -22,6 +22,8 @@ extern struct PINT_state_machine_s pvfs2
#define PVFS_MSGPAIR_RETRY 0xFE
#define PVFS_MSGPAIR_NO_RETRY 0xFF
+#define PINT_MSGPAIR_PARENT_SM -1
+
/*
* This structure holds everything that we need for the state of a
* message pair. We need arrays of these in some cases, so it's
@@ -77,7 +79,7 @@ typedef struct PINT_sm_msgpair_state_s
} PINT_sm_msgpair_state;
/* used to pass in parameters that apply to every entry in a msgpair array */
-typedef struct PINT_sm_msgpair_params_s
+typedef struct
{
int job_timeout;
int retry_delay;
@@ -89,14 +91,40 @@ typedef struct PINT_sm_msgpair_params_s
} PINT_sm_msgpair_params;
+typedef struct
+{
+ PINT_sm_msgpair_params params;
+ int count;
+ PINT_sm_msgpair_state *msgarray;
+ PINT_sm_msgpair_state msgpair;
+} PINT_sm_msgarray_op;
+
+#define PINT_msgpair_init(op) \
+ do { \
+ memset(&(op)->msgpair, 0, sizeof(PINT_sm_msgpair_state)); \
+ if((op)->msgarray != &(op)->msgpair) \
+ { \
+ free((op)->msgarray); \
+ (op)->msgarray = NULL; \
+ } \
+ (op)->count = 1; \
+ (op)->msgarray = &(op)->msgpair; \
+ } while(0)
+
+#define foreach_msgpair(__msgarray_op, __msg_p, __i) \
+ for(__i = 0, __msg_p = &((__msgarray_op)->msgarray[__i]); \
+ i < (__msgarray_op)->count; \
+ ++__i, __msg_p = &((__msgarray_op)->msgarray[__i]))
/* helper functions */
int PINT_msgpairarray_init(
- PINT_sm_msgpair_state ** msgpairarray,
+ PINT_sm_msgarray_op *op,
int count);
-void PINT_msgpairarray_destroy(PINT_sm_msgpair_state * msgpairarray);
+void PINT_msgpairarray_destroy(PINT_sm_msgarray_op *op);
+
+int PINT_msgarray_status(PINT_sm_msgarray_op *op);
int PINT_serv_decode_resp(
PVFS_fs_id fs_id,
@@ -113,9 +141,7 @@ int PINT_serv_free_msgpair_resources(
PVFS_BMI_addr_t *svr_addr_p,
int max_resp_sz);
-int PINT_serv_msgpairarray_resolve_addrs(
- int count,
- PINT_sm_msgpair_state* msgarray);
+int PINT_serv_msgpairarray_resolve_addrs(PINT_sm_msgarray_op *op);
#define PRINT_ENCODING_ERROR(type_str, type) \
do { \
Index: msgpairarray.sm
===================================================================
RCS file: /anoncvs/pvfs2/src/common/misc/msgpairarray.sm,v
diff -p -u -r1.45 -r1.45.2.1
--- msgpairarray.sm 14 Feb 2008 00:04:39 -0000 1.45
+++ msgpairarray.sm 16 May 2008 15:15:34 -0000 1.45.2.1
@@ -13,26 +13,6 @@
#include <string.h>
#include <assert.h>
-/* conditionally include different headers to get the type of the state
- * machine struct that contains the msgpair state structs we need to access;
- * this is done to allow the reuse of this nested machine on both client and
- * server side where completely different primary state machine structures
- * are used
- */
-#if defined(__PVFS2_CLIENT__)
-#include "client-state-machine.h"
-#define PARENT_SM PINT_client_sm
-#elif defined(__PVFS2_SERVER__)
-#include "src/server/pvfs2-server.h"
-#define PARENT_SM PINT_server_op
-#else
-/* this condition is only included for dependency building step; will not
- * actually compile cleanly
- */
-#define __SM_CHECK_DEP
-#include "client-state-machine.h"
-#include "src/server/pvfs2-server.h"
-#endif
#include "msgpairarray.h"
#include "pvfs2-debug.h"
#include "pint-cached-config.h"
@@ -43,6 +23,7 @@
#include "pint-util.h"
#include "server-config-mgr.h"
#include "pvfs2-internal.h"
+#include "state-machine.h"
enum
{
@@ -86,6 +67,12 @@ nested machine pvfs2_msgpairarray_sm
run msgpairarray_completion_fn;
MSGPAIRS_RETRY => post_retry;
MSGPAIRS_RETRY_NODELAY => post;
+ default => done;
+ }
+
+ state done
+ {
+ run msgpairarray_done;
default => return;
}
}
@@ -95,23 +82,23 @@ nested machine pvfs2_msgpairarray_sm
static PINT_sm_action msgpairarray_init(
struct PINT_smcb *smcb, job_status_s *js_p)
{
- PARENT_SM *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
+ PINT_sm_msgarray_op *mop = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
int i = 0;
PINT_sm_msgpair_state *msg_p = NULL;
gossip_debug(GOSSIP_MSGPAIR_DEBUG, "(%p) msgpairarray state: init "
- "(%d msgpair(s))\n", smcb, sm_p->msgarray_count);
+ "(%d msgpair(s))\n", smcb, mop->count);
- assert(sm_p->msgarray_count > 0);
+ assert(mop->count > 0);
js_p->error_code = 0;
/* set number of operations that must complete. */
- sm_p->msgarray_params.comp_ct = (2 * sm_p->msgarray_count);
+ mop->params.comp_ct = (2 * mop->count);
- for(i = 0; i < sm_p->msgarray_count; i++)
+ for(i = 0; i < mop->count; i++)
{
- msg_p = &sm_p->msgarray[i];
+ msg_p = &mop->msgarray[i];
assert(msg_p);
assert((msg_p->retry_flag == PVFS_MSGPAIR_RETRY) ||
@@ -145,7 +132,7 @@ static PINT_sm_action msgpairarray_init(
static PINT_sm_action msgpairarray_post(
struct PINT_smcb *smcb, job_status_s *js_p)
{
- PARENT_SM *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
+ PINT_sm_msgarray_op *mop = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
int ret = -PVFS_EINVAL, i = 0, tmp = 0;
struct server_configuration_s *server_config = NULL;
PVFS_msg_tag_t session_tag;
@@ -157,16 +144,16 @@ static PINT_sm_action msgpairarray_post(
gossip_debug(
GOSSIP_MSGPAIR_DEBUG, "%s: sm %p "
"%d total message(s) with %d incomplete\n", __func__, smcb,
- sm_p->msgarray_count * 2, sm_p->msgarray_params.comp_ct);
+ mop->count * 2, mop->params.comp_ct);
js_p->error_code = 0;
- assert(sm_p->msgarray_count > 0);
- assert(sm_p->msgarray_params.comp_ct >= 2);
+ assert(mop->count > 0);
+ assert(mop->params.comp_ct >= 2);
- for (i = 0; i < sm_p->msgarray_count; i++)
+ for (i = 0; i < mop->count; i++)
{
- msg_p = &sm_p->msgarray[i];
+ msg_p = &mop->msgarray[i];
assert(msg_p);
/*
@@ -263,8 +250,8 @@ static PINT_sm_action msgpairarray_post(
i,
&msg_p->recv_status,
&msg_p->recv_id,
- sm_p->msgarray_params.job_context,
- sm_p->msgarray_params.job_timeout);
+ mop->params.job_context,
+ mop->params.job_timeout);
if (ret == 0)
{
/* perform a quick test to see if the recv failed before posting
@@ -274,7 +261,7 @@ static PINT_sm_action msgpairarray_post(
*/
ret = job_test(msg_p->recv_id, &tmp, NULL,
&msg_p->recv_status, 0,
- sm_p->msgarray_params.job_context);
+ mop->params.job_context);
}
if ((ret < 0) || (ret == 1))
@@ -299,7 +286,7 @@ static PINT_sm_action msgpairarray_post(
/* mark send as bad too and don't post it */
msg_p->send_status.error_code = msg_p->recv_status.error_code;
msg_p->op_status = msg_p->recv_status.error_code;
- sm_p->msgarray_params.comp_ct -= 2;
+ mop->params.comp_ct -= 2;
if (local_enc_and_alloc)
{
@@ -332,11 +319,11 @@ static PINT_sm_action msgpairarray_post(
msg_p->encoded_req.buffer_type,
1,
smcb,
- sm_p->msgarray_count+i,
+ mop->count+i,
&msg_p->send_status,
&msg_p->send_id,
- sm_p->msgarray_params.job_context,
- sm_p->msgarray_params.job_timeout);
+ mop->params.job_context,
+ mop->params.job_timeout);
if ((ret < 0) ||
((ret == 1) && (msg_p->send_status.error_code != 0)))
@@ -353,26 +340,26 @@ static PINT_sm_action msgpairarray_post(
gossip_err("Send error: cancelling recv.\n");
- job_bmi_cancel(msg_p->recv_id, sm_p->msgarray_params.job_context);
+ job_bmi_cancel(msg_p->recv_id, mop->params.job_context);
/* we still have to wait for recv completion, so just decrement
* comp_ct by one and keep going
*/
msg_p->op_status = msg_p->send_status.error_code;
msg_p->send_id = 0;
- sm_p->msgarray_params.comp_ct--;
+ mop->params.comp_ct--;
}
else if (ret == 1)
{
/* immediate completion */
msg_p->send_id = 0;
/* decrement our count, since send is already done. */
- sm_p->msgarray_params.comp_ct--;
+ mop->params.comp_ct--;
}
/* else: successful post, no immediate completion */
}
- if (sm_p->msgarray_params.comp_ct == 0)
+ if (mop->params.comp_ct == 0)
{
/* everything is completed already (could happen in some failure
* cases); jump straight to final completion function.
@@ -390,36 +377,36 @@ static PINT_sm_action msgpairarray_post(
static PINT_sm_action msgpairarray_post_retry(
struct PINT_smcb *smcb, job_status_s *js_p)
{
- PARENT_SM *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
+ PINT_sm_msgarray_op *mop = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
job_id_t tmp_id;
gossip_debug(GOSSIP_MSGPAIR_DEBUG, "%s: sm %p, wait %d ms\n",
- __func__, smcb, sm_p->msgarray_params.retry_delay);
+ __func__, smcb, mop->params.retry_delay);
js_p->error_code = 0; /* do not leak MSGPAIRS_RETRY through to wait */
return job_req_sched_post_timer(
- sm_p->msgarray_params.retry_delay,
+ mop->params.retry_delay,
smcb, 0, js_p, &tmp_id,
- sm_p->msgarray_params.job_context);
+ mop->params.job_context);
}
static PINT_sm_action msgpairarray_complete(
struct PINT_smcb *smcb, job_status_s *js_p)
{
- PARENT_SM *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
+ PINT_sm_msgarray_op *mop = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
gossip_debug(GOSSIP_MSGPAIR_DEBUG,
"%s: sm %p status_user_tag %d msgarray_count %d\n",
- __func__, smcb, (int) js_p->status_user_tag, sm_p->msgarray_count);
+ __func__, smcb, (int) js_p->status_user_tag, mop->count);
/* match operation with something in the msgpair array */
/* the first N tags are receives, the second N are sends */
- assert(js_p->status_user_tag < sm_p->msgarray_count*2);
+ assert(js_p->status_user_tag < mop->count*2);
- if (js_p->status_user_tag < sm_p->msgarray_count)
+ if (js_p->status_user_tag < mop->count)
{
PINT_sm_msgpair_state *msg_p =
- &sm_p->msgarray[js_p->status_user_tag];
+ &mop->msgarray[js_p->status_user_tag];
msg_p->recv_id = 0;
msg_p->recv_status = *js_p;
@@ -433,13 +420,13 @@ static PINT_sm_action msgpairarray_compl
/* we got a receive error, but send is still pending. Cancel
* the send
*/
- job_bmi_cancel(msg_p->send_id, sm_p->msgarray_params.job_context);
+ job_bmi_cancel(msg_p->send_id, mop->params.job_context);
}
}
else
{
- PINT_sm_msgpair_state *msg_p = &sm_p->msgarray[
- js_p->status_user_tag - sm_p->msgarray_count];
+ PINT_sm_msgpair_state *msg_p = &mop->msgarray[
+ js_p->status_user_tag - mop->count];
msg_p->send_id = 0;
msg_p->send_status = *js_p;
@@ -453,20 +440,20 @@ static PINT_sm_action msgpairarray_compl
/* we got a send error, but recv is still pending. Cancel
* the recv
*/
- job_bmi_cancel(msg_p->recv_id, sm_p->msgarray_params.job_context);
+ job_bmi_cancel(msg_p->recv_id, mop->params.job_context);
}
}
/* decrement comp_ct until all operations have completed */
- if (--sm_p->msgarray_params.comp_ct > 0)
+ if (--mop->params.comp_ct > 0)
{
gossip_debug(GOSSIP_MSGPAIR_DEBUG,
" msgpairarray: %d operations remain\n",
- sm_p->msgarray_params.comp_ct);
+ mop->params.comp_ct);
return SM_ACTION_DEFERRED;
}
- assert(sm_p->msgarray_params.comp_ct == 0);
+ assert(mop->params.comp_ct == 0);
gossip_debug(GOSSIP_MSGPAIR_DEBUG,
" msgpairarray: all operations complete\n");
@@ -477,7 +464,7 @@ static PINT_sm_action msgpairarray_compl
static PINT_sm_action msgpairarray_completion_fn(
struct PINT_smcb *smcb, job_status_s *js_p)
{
- PARENT_SM *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
+ PINT_sm_msgarray_op *mop = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
int ret = -PVFS_EINVAL, i = 0;
int need_retry = 0;
struct PINT_decoded_msg decoded_resp;
@@ -492,9 +479,9 @@ static PINT_sm_action msgpairarray_compl
gossip_debug(GOSSIP_MSGPAIR_DEBUG, "(%p) msgpairarray state: "
"completion_fn\n", smcb);
- for (i = 0; i < sm_p->msgarray_count; i++)
+ for (i = 0; i < mop->count; i++)
{
- PINT_sm_msgpair_state *msg_p = &sm_p->msgarray[i];
+ PINT_sm_msgpair_state *msg_p = &mop->msgarray[i];
assert(msg_p);
/*
@@ -602,21 +589,21 @@ static PINT_sm_action msgpairarray_compl
* of two since they are pairs. If over the count, do not
* retry, just return one of the error codes.
*/
- sm_p->msgarray_params.comp_ct = 0;
+ mop->params.comp_ct = 0;
js_p->error_code = 0;
- for (i=0; i < sm_p->msgarray_count; i++) {
+ for (i=0; i < mop->count; i++) {
- PINT_sm_msgpair_state *msg_p = &sm_p->msgarray[i];
+ PINT_sm_msgpair_state *msg_p = &mop->msgarray[i];
if (msg_p->complete)
continue;
if (msg_p->retry_flag == PVFS_MSGPAIR_RETRY
&& PVFS_ERROR_CLASS(-msg_p->op_status) == PVFS_ERROR_BMI
- && msg_p->retry_count < sm_p->msgarray_params.retry_limit) {
+ && msg_p->retry_count < mop->params.retry_limit) {
++msg_p->retry_count;
- sm_p->msgarray_params.comp_ct += 2;
+ mop->params.comp_ct += 2;
gossip_debug(GOSSIP_MSGPAIR_DEBUG,
"*** %s: msgpair %d failed, retry %d\n",
__func__, i, msg_p->retry_count);
@@ -669,30 +656,58 @@ static PINT_sm_action msgpairarray_compl
return SM_ACTION_COMPLETE;
}
+static PINT_sm_action msgpairarray_done(
+ struct PINT_smcb *smcb, job_status_s *js_p)
+{
+ int task_id, error_code, remaining;
+ PINT_sm_pop_frame(smcb, &task_id, &error_code, &remaining);
+ js_p->error_code = error_code;
+ return SM_ACTION_COMPLETE;
+}
+
/*********************************************************************
* helper functions used in conjunction with state machine defined above
*/
int PINT_msgpairarray_init(
- PINT_sm_msgpair_state ** msgpairarray,
+ PINT_sm_msgarray_op *op,
int count)
{
- *msgpairarray = (PINT_sm_msgpair_state *)malloc(
+ op->msgarray = (PINT_sm_msgpair_state *)malloc(
count * sizeof(PINT_sm_msgpair_state));
- if(!*msgpairarray)
+ if(!op->msgarray)
{
return -PVFS_ENOMEM;
}
- memset(*msgpairarray, 0, (count * sizeof(PINT_sm_msgpair_state)));
+ memset(op->msgarray, 0, (count * sizeof(PINT_sm_msgpair_state)));
+ op->count = count;
return 0;
}
/* we pass in a pointer to the array so that we can set it to NULL */
void PINT_msgpairarray_destroy(
- PINT_sm_msgpair_state * msgpairarray)
+ PINT_sm_msgarray_op *op)
{
- free(msgpairarray);
+ if(op->msgarray && (&op->msgpair) != op->msgarray)
+ {
+ free(op->msgarray);
+ }
+ op->msgarray = NULL;
+ op->count = 0;
+}
+
+int PINT_msgarray_status(PINT_sm_msgarray_op *op)
+{
+ int i;
+ for (i = 0; i < op->count; i++)
+ {
+ if (op->msgarray[i].op_status != 0)
+ {
+ return op->msgarray[i].op_status;
+ }
+ }
+ return 0;
}
int PINT_serv_decode_resp(PVFS_fs_id fs_id,
@@ -767,16 +782,16 @@ int PINT_serv_free_msgpair_resources(
* returns 0 on success, -PVFS_error on failure
*/
int PINT_serv_msgpairarray_resolve_addrs(
- int count, PINT_sm_msgpair_state *msgarray)
+ PINT_sm_msgarray_op *mop)
{
int i = 0;
int ret = -PVFS_EINVAL;
- if ((count > 0) && msgarray)
+ if ((mop->count > 0) && mop->msgarray)
{
- for(i = 0; i < count; i++)
+ for(i = 0; i < mop->count; i++)
{
- PINT_sm_msgpair_state *msg_p = &msgarray[i];
+ PINT_sm_msgpair_state *msg_p = &mop->msgarray[i];
assert(msg_p);
ret = PINT_cached_config_map_to_server(
Index: pint-cached-config.c
===================================================================
RCS file: /anoncvs/pvfs2/src/common/misc/pint-cached-config.c,v
diff -p -u -r1.23 -r1.23.2.1
--- pint-cached-config.c 14 Feb 2008 00:04:39 -0000 1.23
+++ pint-cached-config.c 16 May 2008 15:15:35 -0000 1.23.2.1
@@ -448,9 +448,10 @@ int PINT_cached_config_map_servers(
struct PINT_llist *server_list;
struct host_handle_mapping_s *cur_mapping = NULL;
struct config_fs_cache_s *cur_config_cache = NULL;
- int num_io_servers, i, j, ret;
+ int num_io_servers, i, ret;
int start_index = -1;
int index;
+ int random_attempts;
assert(inout_num_datafiles);
@@ -544,8 +545,13 @@ int PINT_cached_config_map_servers(
break;
case PVFS_SYS_LAYOUT_RANDOM:
+ /* this layout randomizes the order but still uses each server
+ * only once
+ */
- /* all random */
+ /* limit this layout to a number of datafiles no greater than
+ * the number of servers
+ */
if(num_io_servers < *inout_num_datafiles)
{
*inout_num_datafiles = num_io_servers;
@@ -554,34 +560,51 @@ int PINT_cached_config_map_servers(
/* init all the addrs to 0, so we know whether we've set an
* address at a particular index or not
*/
+ memset(addr_array, 0, (*inout_num_datafiles)*sizeof(*addr_array));
+
for(i = 0; i < *inout_num_datafiles; ++i)
{
+ /* go through server list in order */
+ cur_mapping = PINT_llist_head(server_list);
+ assert(cur_mapping);
+ server_list = PINT_llist_next(server_list);
+
+ /* select random index into caller's list */
index = rand() % *inout_num_datafiles;
- for(j = 0; j < i; ++j)
+ random_attempts = 1;
+
+ /* if we have already filled that index, try another random
+ * index
+ */
+ while(addr_array[index] != 0 && random_attempts < 6)
{
- if(addr_array[index] == 0)
- {
- cur_mapping = PINT_llist_head(server_list);
- assert(cur_mapping);
- server_list = PINT_llist_next(server_list);
-
- /* found an unused index */
- ret = BMI_addr_lookup(
- &addr_array[index],
- cur_mapping->alias_mapping->bmi_address);
- if (ret)
- {
- return ret;
- }
-
- if(handle_extent_array)
- {
- handle_extent_array[index].extent_count =
- cur_mapping->handle_extent_array.extent_count;
- handle_extent_array[index].extent_array =
- cur_mapping->handle_extent_array.extent_array;
- }
- }
+ index = rand() % *inout_num_datafiles;
+ random_attempts++;
+ }
+
+ /* if we exhausted a max number of randomization attempts,
+ * then just go linearly through list
+ */
+ while(addr_array[index] != 0)
+ {
+ index = (index + 1) % *inout_num_datafiles;
+ }
+
+ /* found an unused index */
+ ret = BMI_addr_lookup(
+ &addr_array[index],
+ cur_mapping->alias_mapping->bmi_address);
+ if (ret)
+ {
+ return ret;
+ }
+
+ if(handle_extent_array)
+ {
+ handle_extent_array[index].extent_count =
+ cur_mapping->handle_extent_array.extent_count;
+ handle_extent_array[index].extent_array =
+ cur_mapping->handle_extent_array.extent_array;
}
}
break;
Index: pint-util.c
===================================================================
RCS file: /anoncvs/pvfs2/src/common/misc/pint-util.c,v
diff -p -u -r1.26 -r1.26.2.1
--- pint-util.c 6 Mar 2008 22:15:45 -0000 1.26
+++ pint-util.c 16 May 2008 15:15:35 -0000 1.26.2.1
@@ -14,9 +14,11 @@
#include <assert.h>
#include <sys/time.h>
#include <sys/resource.h>
+#include <unistd.h>
#include "gen-locks.h"
#include "pint-util.h"
+#include "gossip.h"
void PINT_time_mark(PINT_time_marker *out_marker)
{
@@ -183,6 +185,7 @@ int PINT_copy_object_attr(PVFS_object_at
if (dest->u.meta.dfile_array)
{
free(dest->u.meta.dfile_array);
+ dest->u.meta.dfile_array = NULL;
}
}
dest->u.meta.dfile_array = malloc(df_array_size);
@@ -336,6 +339,34 @@ PVFS_time PINT_util_mktime_version(PVFS_
PVFS_time PINT_util_mkversion_time(PVFS_time version)
{
return (PVFS_time)(version >> 32);
+}
+
+char *PINT_util_guess_alias(void)
+{
+ char tmp_alias[1024];
+ char *tmpstr;
+ char *alias;
+ int ret;
+
+ /* hmm...failed to find alias as part of the server config filename,
+ * use the hostname to guess
+ */
+ ret = gethostname(tmp_alias, 1024);
+ if(ret != 0)
+ {
+ gossip_err("Failed to get hostname while attempting to guess "
+ "alias. Use -a to specify the alias for this server "
+ "process directly\n");
+ return NULL;
+ }
+ alias = tmp_alias;
+
+ tmpstr = strstr(tmp_alias, ".");
+ if(tmpstr)
+ {
+ *tmpstr = 0;
+ }
+ return strdup(tmp_alias);
}
/*
Index: pint-util.h
===================================================================
RCS file: /anoncvs/pvfs2/src/common/misc/pint-util.h,v
diff -p -u -r1.13 -r1.13.8.1
--- pint-util.h 20 Jul 2007 19:37:05 -0000 1.13
+++ pint-util.h 16 May 2008 15:15:35 -0000 1.13.8.1
@@ -132,6 +132,8 @@ int PINT_util_digest_sha1(const void *in
int PINT_util_digest_md5(const void *input_message, size_t input_length,
char **output, size_t *output_length);
+char *PINT_util_guess_alias(void);
+
#endif /* __PINT_UTIL_H */
/*
Index: pvfs2-util.c
===================================================================
RCS file: /anoncvs/pvfs2/src/common/misc/pvfs2-util.c,v
diff -p -u -r1.100 -r1.100.2.1
--- pvfs2-util.c 6 Mar 2008 22:11:50 -0000 1.100
+++ pvfs2-util.c 16 May 2008 15:15:35 -0000 1.100.2.1
@@ -1172,43 +1172,55 @@ int PVFS_util_init_defaults(void)
#define KILOBYTE 1024
#define MEGABYTE (1024 * KILOBYTE)
#define GIGABYTE (1024 * MEGABYTE)
-/*
-#define TERABYTE (1024 * GIGABYTE)
-#define PETABYTE (1024 * TERABYTE)
-#define EXABYTE (1024 * PETABYTE)
-#define ZETTABYTE (1024 * EXABYTE)
-#define YOTTABYTE (1024 * ZETTABYTE)
-*/
+#define TERABYTE (1024llu * GIGABYTE)
+#define PETABYTE (1024llu * TERABYTE)
+#define EXABYTE (1024llu * PETABYTE)
+#define ZETTABYTE (1024llu * EXABYTE)
+#define YOTTABYTE (1024llu * ZETTABYTE)
+
/*****************/
/* si size units */
/*****************/
#define SI_KILOBYTE 1000
#define SI_MEGABYTE (1000 * SI_KILOBYTE)
#define SI_GIGABYTE (1000 * SI_MEGABYTE)
-/*
-#define SI_TERABYTE (1000 * SI_GIGABYTE)
-#define SI_PETABYTE (1000 * SI_TERABYTE)
-#define SI_EXABYTE (1000 * SI_PETABYTE)
-#define SI_ZETTABYTE (1000 * SI_EXABYTE)
-#define SI_YOTTABYTE (1000 * SI_ZETTABYTE)
-*/
-#define NUM_SIZES 3
+#define SI_TERABYTE (1000llu * SI_GIGABYTE)
+#define SI_PETABYTE (1000llu * SI_TERABYTE)
+#define SI_EXABYTE (1000llu * SI_PETABYTE)
+#define SI_ZETTABYTE (1000llu * SI_EXABYTE)
+#define SI_YOTTABYTE (1000llu * SI_ZETTABYTE)
+
+#if SIZEOF_LONG_INT == 8
+#define NUM_SIZES 5
+#else
+#define NUM_SIZES 4
+#endif
static PVFS_size PINT_s_size_table[NUM_SIZES] =
{
- /*YOTTABYTE, ZETTABYTE, EXABYTE, PETABYTE, TERABYTE, */
+ /*YOTTABYTE, ZETTABYTE, EXABYTE, */
+#if SIZEOF_LONG_INT == 8
+ PETABYTE,
+ TERABYTE,
+#endif
GIGABYTE, MEGABYTE, KILOBYTE
};
static PVFS_size PINT_s_si_size_table[NUM_SIZES] =
{
- /*SI_YOTTABYTE, SI_ZETTABYTE, SI_EXABYTE, SI_PETABYTE, SI_TERABYTE, */
+ /*SI_YOTTABYTE, SI_ZETTABYTE, SI_EXABYTE, */
+#if SIZEOF_LONG_INT == 8
+ SI_PETABYTE, SI_TERABYTE,
+#endif
SI_GIGABYTE, SI_MEGABYTE, SI_KILOBYTE
};
static const char *PINT_s_str_size_table[NUM_SIZES] =
{
- /*"Y", "Z", "E", "P","T", */
+ /*"Y", "Z", "E", */
+#if SIZEOF_LONG_INT == 8
+ "P","T",
+#endif
"G", "M", "K"
};
Index: server-config.c
===================================================================
RCS file: /anoncvs/pvfs2/src/common/misc/server-config.c,v
diff -p -u -r1.106 -r1.106.8.1
--- server-config.c 7 Nov 2007 22:26:07 -0000 1.106
+++ server-config.c 16 May 2008 15:15:35 -0000 1.106.8.1
@@ -876,6 +876,9 @@ static const configoption_t options[] =
/* This option specifies the method used for trove. Currently the
* dbpf method is the default. Other methods include 'alt-aio'.
*
+ * The null-aio method is an implementation that does no disk I/O at all
+ * and is only useful for development or debugging purposes.
+ *
* Note that this option can be specified in either the <a href="#Defaults">
* Defaults</a> context of the main fs.conf, or in a filesystem specific
* <a href="#StorageHints">StorageHints</a>
@@ -2596,6 +2599,10 @@ DOTCONF_CB(get_trove_method)
else if(!strcmp(cmd->data.str, "alt-aio"))
{
*method = TROVE_METHOD_DBPF_ALTAIO;
+ }
+ else if(!strcmp(cmd->data.str, "null-aio"))
+ {
+ *method = TROVE_METHOD_DBPF_NULLAIO;
}
else
{
Index: state-machine-fns.c
===================================================================
RCS file: /anoncvs/pvfs2/src/common/misc/state-machine-fns.c,v
diff -p -u -r1.12 -r1.12.2.1
--- state-machine-fns.c 2 Apr 2008 17:00:18 -0000 1.12
+++ state-machine-fns.c 16 May 2008 15:15:35 -0000 1.12.2.1
@@ -16,27 +16,6 @@
#include "state-machine.h"
#include "client-state-machine.h"
-/* STATE-MACHINE-FNS.C
- *
- * This file implements a small collection of functions used when
- * interacting with the state machine system implemented in
- * state-machine.h. Probably you'll only need these functions in one
- * file per instance of a state machine implementation.
- *
- * Note that state-machine.h must be included before this is included.
- * This is usually accomplished through including some *other* file that
- * includes state-machine.h, because state-machine.h needs a key #define
- * before it can be included.
- *
- * The PINT_OP_STATE_TABLE has been replaced with a macro that must be #defined
- * instead: PINT_OP_STATE_GET_MACHINE.
- * This allows the _locate function to be used in the client as well.
- *
- * A good example of this is the pvfs2-server.h in the src/server directory,
- * which includes state-machine.h at the bottom, and server-state-machine.c,
- * which includes first pvfs2-server.h and then state-machine-fns.h.
- */
-
struct PINT_frame_s
{
int task_id;
@@ -657,7 +636,7 @@ void *PINT_sm_frame(struct PINT_smcb *sm
return NULL;
}
prev = smcb->frames.prev;
- while(target--)
+ while(target)
{
target--;
prev = prev->prev;
@@ -685,6 +664,7 @@ int PINT_sm_push_frame(struct PINT_smcb
}
newframe->task_id = task_id;
newframe->frame = frame_p;
+ newframe->error = 0;
qlist_add(&newframe->link, &smcb->frames);
smcb->frame_count++;
return 0;
More information about the Pvfs2-cvs
mailing list