[Pvfs2-cvs] commit by slang in pvfs2/src/common/misc: state-machine-fns.c state-machine.h

CVS commit program cvs at parl.clemson.edu
Wed Apr 18 12:38:58 EDT 2007


Update of /projects/cvsroot/pvfs2/src/common/misc
In directory parlweb1:/tmp/cvs-serv1686/src/common/misc

Modified Files:
	state-machine-fns.c state-machine.h 
Log Message:
This patch fixes the errors seen when the attr cache was enabled with a non-zero timeout.  The problem was that getattr was completing immediately, which the client-core code didn't handle properly.  Now it does (I hope).  Also, the smcb was still being added to the completion list even on immediate completion, and once the client-core code cleaned up the smcb, pulling it off the completion list later and trying to service it was causing memory errors.

To fix it, I added a PINT_state_machine_continue call, which is a wrapper around PINT_state_machine_next, and calls terminate (which then calls the terminate callback, and adds the smcb to the completion list).  This allows us to call PINT_state_machine_next from PINT_state_machine_start, without calling terminate if the state machine completes immediately.


Index: state-machine-fns.c
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/common/misc/state-machine-fns.c,v
diff -p -u -r1.2 -r1.3
--- state-machine-fns.c	13 Apr 2007 05:14:20 -0000	1.2
+++ state-machine-fns.c	18 Apr 2007 16:38:58 -0000	1.3
@@ -178,8 +178,16 @@ PINT_sm_action PINT_state_machine_start(
     /* run the current state action function */
     ret = PINT_state_machine_invoke(smcb, r);
     if (ret == SM_ACTION_COMPLETE || ret == SM_ACTION_TERMINATE)
+    {
         /* keep running until state machine deferrs or terminates */
         ret = PINT_state_machine_next(smcb, r);
+        
+        /* note that if ret == SM_ACTION_TERMINATE, we _don't_ call
+         * PINT_state_machine_terminate here because that adds the smcb
+         * to the completion list.  We don't want to do that on immediate
+         * completion
+         */
+    }
     return ret;
 }
 
@@ -255,8 +263,6 @@ PINT_sm_action PINT_state_machine_next(s
                             " without returning SM_ACTION_TERMINATE\n");
                     smcb->op_terminate = 1;
                 }
-                /* process terminating SM */
-                PINT_state_machine_terminate(smcb, r);
                 return SM_ACTION_TERMINATE;
 	    }
 	    if (transtbl[i].flag == SM_RETURN)
@@ -280,6 +286,30 @@ PINT_sm_action PINT_state_machine_next(s
         /* runs state_action and returns the return code */
         ret = PINT_state_machine_invoke(smcb, r);
     } while (ret == SM_ACTION_COMPLETE || ret == SM_ACTION_TERMINATE);
+    return ret;
+}
+
+/* Function: PINT_state_machine_continue
+   Params: smcb pointer and job status pointer
+   Returns: return value of last state action
+   Synopsis: This function essentially calls next, and if the state
+             machine terminates, calls terminate to perform cleanup.
+             This allows separation from the start call (which calls
+             next but does not call terminate if the state machine
+             terminates).
+*/
+PINT_sm_action PINT_state_machine_continue(struct PINT_smcb *smcb, job_status_s *r)
+{
+    int ret;
+
+    ret = PINT_state_machine_next(smcb, r);
+
+    if(ret == SM_ACTION_TERMINATE)
+    {
+        /* process terminating SM */
+        PINT_state_machine_terminate(smcb, r);
+    }
+
     return ret;
 }
 

Index: state-machine.h
===================================================================
RCS file: /projects/cvsroot/pvfs2/src/common/misc/state-machine.h,v
diff -p -u -r1.14 -r1.15
--- state-machine.h	13 Apr 2007 05:14:20 -0000	1.14
+++ state-machine.h	18 Apr 2007 16:38:58 -0000	1.15
@@ -184,6 +184,8 @@ int PINT_state_machine_terminate(struct 
 PINT_sm_action PINT_state_machine_next(struct PINT_smcb *,job_status_s *);
 PINT_sm_action PINT_state_machine_invoke(struct PINT_smcb *, job_status_s *);
 PINT_sm_action PINT_state_machine_start(struct PINT_smcb *, job_status_s *);
+PINT_sm_action PINT_state_machine_continue(
+    struct PINT_smcb *smcb, job_status_s *r);
 int PINT_state_machine_locate(struct PINT_smcb *) __attribute__((used));
 int PINT_smcb_set_op(struct PINT_smcb *smcb, int op);
 int PINT_smcb_op(struct PINT_smcb *smcb);



More information about the Pvfs2-cvs mailing list