[Pvfs2-cvs] commit by pw in pvfs2/src/client/sysint:
client-state-machine.h sys-lookup.sm
CVS commit program
cvs at parl.clemson.edu
Tue Jan 8 13:38:00 EST 2008
Update of /projects/cvsroot/pvfs2/src/client/sysint
In directory parlweb1:/tmp/cvs-serv1368/src/client/sysint
Modified Files:
client-state-machine.h sys-lookup.sm
Log Message:
Simplify lookup. It used to be that we would call setup_msgpair for every
segment, building the server request, then the ncache query step would look
into the request to figure out what to lookup in the ncache. If there was
a hit there, it would fake a response and call the msgpair callback function.
Instead, just do the ncache query explicitly using the name from the segment
directly. If it hits, record the new handle and jump over all the msgpair
stuff into attribute checking. This removes a good amount of code and
streamlines the ncache hit case.
Index: client-state-machine.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/sysint/client-state-machine.h,v
diff -u -p -p -u -r1.172 -r1.173
--- client-state-machine.h 10 Dec 2007 16:13:53 -0000 1.172
+++ client-state-machine.h 8 Jan 2008 18:38:00 -0000 1.173
@@ -510,9 +510,6 @@ typedef struct PINT_client_sm
* jobs for some states; typically set and
* then decremented to zero as jobs complete */
- /* indicates that an ncache hit has been made */
- int ncache_hit;
-
/* generic getattr used with getattr sub state machines */
PINT_sm_getattr_state getattr;
/* generic dirent array used by both readdir and readdirplus state machines */
Index: sys-lookup.sm
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/client/sysint/sys-lookup.sm,v
diff -u -p -p -u -r1.73 -r1.74
--- sys-lookup.sm 8 Jan 2008 15:33:53 -0000 1.73
+++ sys-lookup.sm 8 Jan 2008 18:38:00 -0000 1.74
@@ -61,9 +61,9 @@ static void finalize_context(
machine pvfs2_client_lookup_sm
{
- state lookup_segment_lookup_setup_msgpair
+ state lookup_segment_start
{
- run lookup_segment_lookup_setup_msgpair;
+ run lookup_segment_start;
success => lookup_segment_query_ncache;
default => lookup_segment_lookup_failure;
}
@@ -72,7 +72,14 @@ machine pvfs2_client_lookup_sm
{
run lookup_segment_query_ncache;
success => lookup_segment_verify_attr_present;
- default => lookup_segment_lookup_xfer_msgpair;
+ default => lookup_segment_setup_msgpair;
+ }
+
+ state lookup_segment_setup_msgpair
+ {
+ run lookup_segment_setup_msgpair;
+ success => lookup_segment_lookup_xfer_msgpair;
+ default => lookup_segment_lookup_failure;
}
state lookup_segment_lookup_xfer_msgpair
@@ -116,21 +123,21 @@ machine pvfs2_client_lookup_sm
state lookup_context_check_completion
{
run lookup_context_check_completion;
- LOOKUP_CONTINUE => lookup_segment_lookup_setup_msgpair;
+ LOOKUP_CONTINUE => lookup_segment_start;
default => lookup_cleanup;
}
state lookup_segment_handle_relative_link
{
run lookup_segment_handle_relative_link;
- success => lookup_segment_lookup_setup_msgpair;
+ success => lookup_segment_start;
default => lookup_cleanup;
}
state lookup_segment_handle_absolute_link
{
run lookup_segment_handle_absolute_link;
- success => lookup_segment_lookup_setup_msgpair;
+ success => lookup_segment_start;
default => lookup_cleanup;
}
@@ -592,8 +599,61 @@ PVFS_error PVFS_sys_lookup(
/****************************************************************/
-static PINT_sm_action lookup_segment_lookup_setup_msgpair(
- struct PINT_smcb *smcb, job_status_s *js_p)
+/*
+ * Reset for next segment lookup.
+ */
+static PINT_sm_action lookup_segment_start(struct PINT_smcb *smcb,
+ job_status_s *js_p)
+{
+ gossip_debug(GOSSIP_CLIENT_DEBUG, "%s\n", __func__);
+
+ js_p->error_code = 0;
+ return SM_ACTION_COMPLETE;
+}
+
+static int lookup_segment_query_ncache(struct PINT_smcb *smcb,
+ job_status_s *js_p)
+{
+ struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
+ PINT_client_lookup_sm_segment *cur_seg;
+ PVFS_object_ref parent_ref, object_ref;
+ int ret;
+
+ cur_seg = GET_CURRENT_SEGMENT(sm_p);
+ gossip_debug(GOSSIP_CLIENT_DEBUG, "%s: segment [%s]\n", __func__,
+ cur_seg->seg_name);
+
+ parent_ref.fs_id = cur_seg->seg_starting_refn.fs_id;
+ parent_ref.handle = cur_seg->seg_starting_refn.handle;
+
+ ret = PINT_ncache_get_cached_entry(cur_seg->seg_name, &object_ref,
+ &parent_ref);
+ if (ret == 0)
+ {
+ gossip_debug(GOSSIP_NCACHE_DEBUG,
+ "*** ncache hit on first segment of %s (%llu|%d)\n",
+ cur_seg->seg_name, llu(object_ref.handle),
+ object_ref.fs_id);
+
+ cur_seg->seg_resolved_refn.handle = object_ref.handle;
+ cur_seg->seg_resolved_refn.fs_id = object_ref.fs_id;
+ js_p->error_code = 0; /* hit */
+ } else {
+ gossip_debug(GOSSIP_NCACHE_DEBUG,
+ "*** ncache clean miss on first segment of %s\n",
+ cur_seg->seg_name);
+
+ js_p->error_code = 1; /* miss */
+ }
+ return SM_ACTION_COMPLETE;
+}
+
+/*
+ * This is called if the ncache lookup failed. It builds the msgpair
+ * so that the next state can jump into xfer msgpair.
+ */
+static PINT_sm_action lookup_segment_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 ret = -PVFS_EINVAL;
@@ -601,9 +661,7 @@ static PINT_sm_action lookup_segment_loo
PINT_client_lookup_sm_segment *cur_seg = NULL;
char *seg_to_lookup = NULL;
- gossip_debug(GOSSIP_CLIENT_DEBUG,
- "lookup state: lookup_segment_lookup_setup_msgpair\n");
-
+ gossip_debug(GOSSIP_CLIENT_DEBUG, "%s\n", __func__);
js_p->error_code = 0;
/* do a lookup on the current segment of the current context */
@@ -622,8 +680,8 @@ static PINT_sm_action lookup_segment_loo
seg_to_lookup is set to seg_name, and never seg_remaining. that
guarantees we're issuing a lookup on a single path segment
*/
- seg_to_lookup = (cur_seg->seg_remaining ? cur_seg->seg_remaining :
- cur_seg->seg_name);
+ seg_to_lookup = cur_seg->seg_remaining ? cur_seg->seg_remaining :
+ cur_seg->seg_name;
PINT_init_msgpair(sm_p, msg_p);
@@ -655,72 +713,6 @@ static PINT_sm_action lookup_segment_loo
return SM_ACTION_COMPLETE;
}
-static int lookup_segment_query_ncache(struct PINT_smcb *smcb,
- job_status_s *js_p)
-{
- struct PINT_client_sm *sm_p = PINT_sm_frame(smcb, PINT_FRAME_CURRENT);
- int ret = -PVFS_EINVAL;
- PVFS_object_ref parent_ref, object_ref;
- char segment[PVFS_NAME_MAX + 1] = {0};
- char* temp;
-
- gossip_debug(GOSSIP_CLIENT_DEBUG, "%s\n", __func__);
-
- parent_ref.fs_id = sm_p->msgpair.fs_id;
- parent_ref.handle = sm_p->msgpair.handle;
-
- assert(parent_ref.handle != PVFS_HANDLE_NULL);
- assert(parent_ref.fs_id != PVFS_FS_ID_NULL);
-
- /* Stripping out first segment for ncache lookup */
- strncpy(segment, sm_p->msgpair.req.u.lookup_path.path, PVFS_NAME_MAX);
-
- assert(segment[0] != '/');
- temp = index(segment,'/');
- if(temp != NULL)
- {
- temp[0] = '\0';
- }
-
- gossip_debug(GOSSIP_CLIENT_DEBUG, "%s: segment [%s]\n", __func__, segment);
-
- sm_p->ncache_hit = 0;
-
- ret = PINT_ncache_get_cached_entry(
- (const char*)segment,
- &object_ref,
- (const PVFS_object_ref*) &parent_ref);
-
- if (ret == 0)
- {
- struct PVFS_server_resp fake_resp;
-
- /* build a fake response, call the completion function on it */
- fake_resp.op = PVFS_SERV_LOOKUP_PATH;
- fake_resp.status = 0;
- fake_resp.u.lookup_path.handle_array = &object_ref.handle;
- fake_resp.u.lookup_path.attr_array = NULL;
- fake_resp.u.lookup_path.handle_count = 1;
- fake_resp.u.lookup_path.attr_count = 0;
-
- gossip_debug(
- GOSSIP_NCACHE_DEBUG, "*** ncache hit on first segment of %s (%llu|%d)!\n",
- sm_p->msgpair.req.u.lookup_path.path,
- llu(object_ref.handle), object_ref.fs_id);
-
- sm_p->ncache_hit = 1;
- ret = sm_p->msgpair.comp_fn(smcb, &fake_resp, 0);
- js_p->error_code = 0; /* hit */
- return SM_ACTION_COMPLETE;
- }
-
- gossip_debug(GOSSIP_NCACHE_DEBUG, "*** ncache clean miss on first segment of %s.\n",
- sm_p->msgpair.req.u.lookup_path.path);
-
- js_p->error_code = 1; /* miss */
- return SM_ACTION_COMPLETE;
-}
-
static PINT_sm_action lookup_segment_lookup_failure(
struct PINT_smcb *smcb, job_status_s *js_p)
{
@@ -729,6 +721,11 @@ static PINT_sm_action lookup_segment_loo
return SM_ACTION_COMPLETE;
}
+/*
+ * We get here either if the ncache hit, or the xfer msgpair finished
+ * successfully. In the ncache hit case, seg_attr will be all zeroes,
+ * so it will head into getattr, which may hit in its own acache.
+ */
static PINT_sm_action lookup_segment_verify_attr_present(
struct PINT_smcb *smcb, job_status_s *js_p)
{
@@ -1162,23 +1159,20 @@ static int lookup_segment_lookup_comp_fn
&(resp_p->u.lookup_path.attr_array[i]));
}
- if (!sm_p->ncache_hit)
- {
- gossip_debug(
- GOSSIP_NCACHE_DEBUG, "*** ncache update on %s "
- "target (%llu|%d) "
- "parent (%llu|%d)\n",
- cur_seg->seg_name,
- llu(last_resolved_refn.handle),
- last_resolved_refn.fs_id,
- llu(cur_seg->seg_starting_refn.handle),
- cur_seg->seg_starting_refn.fs_id);
-
- PINT_ncache_update(
- (const char*) cur_seg->seg_name,
- (const PVFS_object_ref*) &(last_resolved_refn),
- (const PVFS_object_ref*) &(cur_seg->seg_starting_refn));
- }
+ gossip_debug(
+ GOSSIP_NCACHE_DEBUG, "*** ncache update on %s "
+ "target (%llu|%d) "
+ "parent (%llu|%d)\n",
+ cur_seg->seg_name,
+ llu(last_resolved_refn.handle),
+ last_resolved_refn.fs_id,
+ llu(cur_seg->seg_starting_refn.handle),
+ cur_seg->seg_starting_refn.fs_id);
+
+ PINT_ncache_update(
+ (const char*) cur_seg->seg_name,
+ (const PVFS_object_ref*) &(last_resolved_refn),
+ (const PVFS_object_ref*) &(cur_seg->seg_starting_refn));
}
assert(i == resp_p->u.lookup_path.handle_count);
More information about the Pvfs2-cvs
mailing list