cluster/cmirror/src cluster.c cluster.h functi ...
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: jbrassow at sourceware.org 2008-02-08 14:30:10
Modified files:
cmirror/src : cluster.c cluster.h functions.c functions.h
local.c
Log message:
- stop delaying disk log writes
- stop placing requests into the startup queue before initial config
- added recovering_region to checkpoint data to prevent duplicate region syncing assignment.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cmirror/src/cluster.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.2.15&r2=1.1.2.16
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cmirror/src/cluster.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.2.2&r2=1.1.2.3
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cmirror/src/functions.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.2.13&r2=1.1.2.14
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cmirror/src/functions.h.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.2.4&r2=1.1.2.5
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cmirror/src/local.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.1.2.13&r2=1.1.2.14
cmirror/src/Attic/cluster.c +168 -78
@@ -27,6 +27,13 @@static SaCkptCallbacksT callbacks = {0 ,0 };static SaVersionT version = {'B' ,1 ,1 }; +#define DEBUGGING_HISTORY 20 +static char debugging[DEBUGGING_HISTORY ][128 ]; +static int idx =0 ; +static int memberz =0 ; +static int doit =0 ; + +struct checkpoint_data {uint32_t requester;char uuid[CPG_MAX_NAME_LENGTH ];
@@ -34,6 +41,7 @@int bitmap_size;/* in bytes */ char *sync_bits;char *clean_bits; +char *recovering_region;struct checkpoint_data *next; };
@@ -58,44 +66,18 @@static struct list_head clog_cpg_list;/* -* flow_control -* @handle -* -* Returns: 1 if flow control needed, 0 otherwise -*/ -static int flow_control (cpg_handle_t handle) -{ -cpg_flow_control_state_t flow_control_state; -cpg_error_t error; - -/* FIXME: no flow control for now (cmirror should self regulate) */ -return 0 ; - - error =cpg_flow_control_state_get (handle, &flow_control_state); -if (error !=CPG_OK ) { -LOG_ERROR ("Failed to get flow control state. Reason: %d" , error); -/* FIXME: Better error handling */ -return 0 ; - } - -return (flow_control_state ==CPG_FLOW_CONTROL_ENABLED ) ?1 :0 ; -} - -/* * cluster_send * @tfr * * Returns: 0 on success, -Exxx on error */ -int cluster_send (struct clog_tfr *tfr) +static int cluster_send (struct clog_tfr *tfr) {int r;int found;struct iovec iov;struct clog_cpg *entry, *tmp; -ENTER (); -list_for_each_entry_safe (entry, tmp, &clog_cpg_list, list)if (!strncmp (entry->name.value, tfr->uuid,CPG_MAX_NAME_LENGTH )) { found =1 ;
@@ -104,26 +86,35 @@if (!found) { tfr->error = -ENOENT ; -EXIT ();return -ENOENT ; } iov.iov_base = tfr; iov.iov_len =sizeof (struct clog_tfr ) + tfr->data_size; -while (flow_control (entry->handle)) { -/* -* FIXME: Don't need to sleep this long -* -* ... or, we could dispatch the queued messages here. -*/ -LOG_PRINT ("Flow control enabled. Delaying msg [%s]" , -RQ_TYPE (tfr->request_type)); -sleep (1 ); - } + r =cpg_mcast_joined (entry->handle,CPG_TYPE_AGREED , &iov,1 ); +if (r ==CPG_OK ) +return 0 ; +if (r ==SA_AIS_ERR_TRY_AGAIN ) +return -EAGAIN ; + +LOG_ERROR ("cpg_mcast_joined error: %d" , r); + + tfr->error = -EBADE ; +return -EBADE ; +} + +int cluster_send_helper (struct clog_tfr *tfr,int line,char *file,const char *function) +{ +int r; + +do { + r =cluster_send (tfr); +if (r) +LOG_ERROR ("cluster_send failed at: %s:%d (%s)" , + file, line, function); + }while (r == -EAGAIN ); -EXIT (); - tfr->error = r = (r ==CPG_OK ) ?0 : -EBADE ;return r; }
@@ -137,7 +128,7 @@return r; } -static int handle_cluster_request (struct clog_tfr *tfr,int server) +static int handle_cluster_request (struct clog_tfr *tfr,int server,int printz) {int r =0 ;
@@ -152,27 +143,22 @@*/ if ((tfr->request_type !=DM_CLOG_RESUME ) || (tfr->originator == my_cluster_id)) - r =do_request (tfr); + r =do_request (tfr, server);if (server) { -if (r) -LOG_ERROR ("do_request failed, unable to commit log" ); -else - r =commit_log (tfr); - tfr->request_type |=DM_CLOG_RESPONSE ;/* * Errors from previous functions are in the tfr struct. */ - -LOG_DBG ("Sending response to %u on cluster: [%s/%llu]" , - tfr->originator, -RQ_TYPE (tfr->request_type & ~DM_CLOG_RESPONSE ), - (unsigned long long )tfr->seq); +if (printz) +LOG_DBG ("[%s] Sending response to %u on cluster: [%s/%llu]" , +SHORT_UUID (tfr->uuid), tfr->originator, +RQ_TYPE (tfr->request_type & ~DM_CLOG_RESPONSE ), + (unsigned long long )tfr->seq); r =cluster_send (tfr);if (r) -LOG_ERROR ("cluster_send failed" ); +LOG_ERROR ("cluster_send failed: %s" ,strerror (-r)); }EXIT ();
@@ -209,6 +195,8 @@INIT_LIST_HEAD (&l);queue_remove_all (&l, cluster_queue);LOG_ERROR ("Current list:" ); +if (list_empty (&l)) +LOG_ERROR (" [none]" );list_for_each_safe (p, n, &l) {list_del_init (p); t = (struct clog_tfr *)p;
@@ -257,6 +245,7 @@static struct checkpoint_data *prepare_checkpoint (struct clog_cpg *entry,uint32_t cp_requester) { +int r;struct checkpoint_data *new; new =malloc (sizeof (*new));
@@ -270,7 +259,7 @@strncpy (new->uuid, entry->name.value, entry->name.length);if (entry->valid) { - new->bitmap_size =store_bits (entry->name.value,"clean_bits" , + new->bitmap_size =push_state (entry->name.value,"clean_bits" , &new->clean_bits);if (new->bitmap_size <=0 ) { LOG_ERROR("Failed to store clean_bits to checkpoint for node %u",
@@ -279,7 +268,7 @@return NULL ; } - new->bitmap_size =store_bits (entry->name.value, + new->bitmap_size =push_state (entry->name.value,"sync_bits" , &new->sync_bits);if (new->bitmap_size <=0 ) { LOG_ERROR("Failed to store sync_bits to checkpoint for node %u",
@@ -288,6 +277,16 @@free (new);return NULL ; } + + r =push_state (entry->name.value,"recovering_region" , &new->recovering_region); +if (r <=0 ) { +LOG_ERROR ("Failed to store recovering_region to checkpoint for node %u" , + new->requester); +free (new->sync_bits); +free (new->clean_bits); +free (new); +return NULL ; + } }else {/* * We can store bitmaps yet, because the log is not
@@ -309,6 +308,7 @@*/ static void free_checkpoint (struct checkpoint_data *cp) { +free (cp->recovering_region);free (cp->sync_bits);free (cp->clean_bits);free (cp);
@@ -335,9 +335,9 @@ name.length = len; attr.creationFlags =SA_CKPT_WR_ALL_REPLICAS ; - attr.checkpointSize = cp->bitmap_size *2 ; + attr.checkpointSize = cp->bitmap_size *2 +strlen (cp->recovering_region) +1 ; attr.retentionDuration =SA_TIME_MAX ; - attr.maxSections =3 ;/* don't know why we need +1 */ + attr.maxSections =4 ;/* don't know why we need +1 */ attr.maxSectionSize = cp->bitmap_size; attr.maxSectionIdSize =22 ;
@@ -363,6 +363,7 @@EXIT ();return -EIO ;/* FIXME: better error */ } +/* * Add section for sync_bits */
@@ -408,7 +409,7 @@ }if (rv ==SA_AIS_ERR_EXIST ) { -LOG_ERROR ("export_checkpoint: clean checkpoint section already exists" ); +LOG_DBG ("export_checkpoint: clean checkpoint section already exists" );EXIT ();return -EEXIST ; }
@@ -419,6 +420,35 @@return -EIO ;/* FIXME: better error */ } +/* +* Add section for recovering_region +*/ + section_id.idLen =snprintf (buf,32 ,"recovering_region" ); + section_id.id = (unsigned char *)buf; + section_attr.sectionId = §ion_id; + section_attr.expirationTime =SA_TIME_END ; + +rr_create_retry: + rv =saCkptSectionCreate (h, §ion_attr, cp->recovering_region, +strlen (cp->recovering_region) +1 ); +if (rv ==SA_AIS_ERR_TRY_AGAIN ) { +LOG_ERROR ("export_checkpoint: RR create retry" ); +sleep (1 ); + goto rr_create_retry; + } + +if (rv ==SA_AIS_ERR_EXIST ) { +LOG_DBG ("export_checkpoint: RR checkpoint section already exists" ); +EXIT (); +return -EEXIST ; + } + +if (rv !=SA_AIS_OK ) { +LOG_ERROR ("export_checkpoint: RR checkpoint section creation failed" ); +EXIT (); +return -EIO ;/* FIXME: better error */ + } +LOG_DBG ("export_checkpoint: closing checkpoint" );saCkptCheckpointClose (h);
@@ -515,7 +545,7 @@break ; }saCkptSectionIterationFinalize (itr); -if (len !=2 ) { +if (len !=3 ) {LOG_ERROR ("import_checkpoint: %d checkpoint sections found" , len);sleep (1 ); goto init_retry;
@@ -572,8 +602,9 @@*/ if (iov.readSize) { -if (load_bits (entry->name.value, (char *)desc.sectionId.id, bitmap, iov.readSize)) { -LOG_ERROR ("Error loading bits" ); +if (pull_state (entry->name.value, (char *)desc.sectionId.id, bitmap, + iov.readSize)) { +LOG_ERROR ("Error loading state" ); rtn = -EIO ; goto fail; }
@@ -645,6 +676,7 @@int i;int r =0 ;int i_am_server; +int response =0 ;struct clog_tfr *tfr = msg;struct clog_tfr *startup_tfr =NULL ;struct clog_cpg *match;
@@ -665,7 +697,9 @@ (unsigned long long)tfr->seq);if (my_cluster_id ==0xDEAD ) { -LOG_DBG ("Message before init... ignoring.\n" ); +LOG_DBG ("[%s] Message from %u before init [%s/%llu]" , +SHORT_UUID (tfr->uuid), nodeid, +RQ_TYPE (tfr->request_type), (unsigned long long ) tfr->seq);return ; }
@@ -674,6 +708,14 @@LOG_ERROR ("Unable to find clog_cpg for cluster message" );return ; } + +if (match->lowest_id ==0xDEAD ) { +LOG_DBG ("[%s] Message from %u before init* [%s/%llu]" , +SHORT_UUID (tfr->uuid), nodeid, +RQ_TYPE (tfr->request_type), (unsigned long long ) tfr->seq); +return ; + } + i_am_server = (my_cluster_id == match->lowest_id) ?1 :0 ;if (tfr->request_type ==DM_CLOG_CHECKPOINT_READY ) {
@@ -691,7 +733,7 @@LOG_DBG ("Processing delayed request %d: %s" , match->startup_queue->count,RQ_TYPE (startup_tfr->request_type)); - r =handle_cluster_request (startup_tfr, i_am_server); + r =handle_cluster_request (startup_tfr, i_am_server,1 );if (r) {LOG_ERROR ("Error while processing delayed CPG message" );
@@ -732,9 +774,10 @@ match->checkpoint_list = new; } -if (tfr->request_type &DM_CLOG_RESPONSE ) +if (tfr->request_type &DM_CLOG_RESPONSE ) { + response =1 ; r =handle_cluster_response (tfr); -else { + }else { tfr->originator = nodeid;if (!match->valid) {
@@ -757,15 +800,40 @@ goto out; } - r =handle_cluster_request (tfr, i_am_server); + r =handle_cluster_request (tfr, i_am_server, + ((memberz !=4 ) || (--doit >0 ))); } out:if (r) { -LOG_ERROR ("[%s] Error while processing CPG message, %s: %d" , +LOG_ERROR ("[%s] Error while processing CPG message, %s: %s" ,SHORT_UUID (tfr->uuid),RQ_TYPE (tfr->request_type & ~DM_CLOG_RESPONSE ), - r); +strerror (-r)); +LOG_ERROR ("[%s] Response : %s" ,SHORT_UUID (tfr->uuid), + (response) ?"YES" :"NO" ); +LOG_ERROR ("[%s] Originator: %u" ,SHORT_UUID (tfr->uuid), tfr->originator); +if (response) +LOG_ERROR ("[%s] Responder : %u" ,SHORT_UUID (tfr->uuid), nodeid); +LOG_ERROR ("HISTORY::" ); + +for (i =0 ; i <DEBUGGING_HISTORY ; i++) { + idx++; + idx = idx %DEBUGGING_HISTORY ; +if (debugging[idx][0 ] =='\0' ) +continue ; +LOG_ERROR ("%d:%d) %s" , i, idx, debugging[idx]); + } + }else if (!(tfr->request_type &DM_CLOG_RESPONSE )) { +int len; + idx++; + idx = idx %DEBUGGING_HISTORY ; + len =sprintf (debugging[idx],"SEQ#=%llu, UUID=%s, TYPE=%s, ORIG=%u, RESP=%s" , + (unsigned long long )tfr->seq,SHORT_UUID (tfr->uuid), +RQ_TYPE (tfr->request_type), + tfr->originator, (response) ?"YES" :"NO" ); +if (response) +sprintf (debugging[idx] + len,", RSPR=%u" , nodeid); }EXIT (); }
@@ -779,10 +847,12 @@int my_pid =getpid ();int found =0 ;struct clog_cpg *match, *tmp; -uint32_t lowest; +uint32_t lowest =0xDEAD ;ENTER (); + memberz = member_list_entries; +LOG_DBG ("****** CPG config callback **[%s]**" ,SHORT_UUID (gname->value));
@@ -821,6 +891,8 @@ goto out; } + lowest = match->lowest_id; +/* Am I leaving? */ for (i =0 ; i < left_list_entries; i++)if (my_cluster_id == left_list[i].nodeid) {
@@ -863,6 +935,7 @@free (match->startup_queue); match->free_me =1 ; + match->lowest_id =0xDEAD ; goto out; }
@@ -871,8 +944,6 @@if (!left_list_entries && (member_list_entries ==1 ) && (joined_list_entries ==1 ) && (member_list[0 ].nodeid == joined_list[0 ].nodeid)) { -LOG_DBG ("[%s] I am the log server (and first to join)" , -SHORT_UUID (match->name.value)); match->lowest_id = my_cluster_id = joined_list[0 ].nodeid; match->valid =1 ; goto out;
@@ -894,17 +965,15 @@ } } - lowest = match->lowest_id; +if (member_list_entries) + match->lowest_id = member_list[0 ].nodeid; +else + match->lowest_id =0xDEAD ;/* Find the lowest_id, i.e. the server */ -for (i =0 , match->lowest_id = member_list[0 ].nodeid; - i < member_list_entries; i++) +for (i =0 ; i < member_list_entries; i++)if (match->lowest_id > member_list[i].nodeid) match->lowest_id = member_list[i].nodeid; -if (lowest != match->lowest_id) -LOG_DBG ("[%s] Server is now %u" ,SHORT_UUID (match->name.value), - match->lowest_id); -/* * If I am part of the joining list, I do not send checkpoints * FIXME: What are the cases where multiple nodes can join?
@@ -920,6 +989,21 @@ match->checkpoints_needed += i; out: +if (lowest != match->lowest_id) +LOG_DBG ("[%s] Server change %u -> %u (%u %s)" , +SHORT_UUID (match->name.value), + lowest, match->lowest_id, + (joined_list_entries) ? joined_list[0 ].nodeid : left_list[0 ].nodeid, + (joined_list_entries && (member_list_entries ==1 )) ? +"is first to join" : (joined_list_entries) ?"joined" :"left" ); +else +LOG_DBG ("[%s] Server unchanged at %u (%u %s)" , +SHORT_UUID (match->name.value), lowest, + (joined_list_entries) ? joined_list[0 ].nodeid : left_list[0 ].nodeid, + (joined_list_entries) ?"joined" :"left" ); + +if (joined_list_entries && (joined_list[0 ].nodeid == my_cluster_id)) + doit =25 ;EXIT (); }
@@ -1019,6 +1103,12 @@ENTER (); + { +int i; +for (i =0 ; i <DEBUGGING_HISTORY ; i++) + debugging[i][0 ] ='\0' ; + } +INIT_LIST_HEAD (&clog_cpg_list); rv =saCkptInitialize (&ckpt_handle, &callbacks, &version);
cmirror/src/Attic/cluster.h +2 -1
@@ -7,6 +7,7 @@int create_cluster_cpg (char *str);int destroy_cluster_cpg (char *str); -int cluster_send (struct clog_tfr *tfr); +int cluster_send_helper (struct clog_tfr *tfr,int line,char *file,const char *function); +#define cluster_send (x) cluster_send_helper((x), __LINE__, __FILE__, __FUNCTION__)#endif /* __CLUSTER_LOG_CLUSTER_DOT_H__ */
cmirror/src/Attic/functions.c +77 -84
307 lines not on this page · raw message
cmirror/src/Attic/functions.h +8 -2
@@ -8,10 +8,16 @@int local_resume (struct clog_tfr *tfr);int cluster_postsuspend (char *); -int do_request (struct clog_tfr *tfr); -int commit_log (struct clog_tfr *tfr); + +int do_request (struct clog_tfr *tfr,int server); + +/* int store_bits(const char *uuid, const char *which, char **buf); int load_bits(const char *uuid, const char *which, char *buf, int size); +*/ +int push_state (const char *uuid,const char *which,char **buf); +int pull_state (const char *uuid,const char *which,char *buf,int size); +int log_get_state (struct clog_tfr *tfr);int log_status (int );#endif /* __CLOG_FUNCTIONS_DOT_H__ */
cmirror/src/Attic/local.c +5 -2
@@ -166,7 +166,8 @@case DM_CLOG_STATUS_INFO :case DM_CLOG_STATUS_TABLE :case DM_CLOG_PRESUSPEND : - r =do_request (tfr); +/* We do not specify ourselves as server here */ + r =do_request (tfr,0 );if (r)LOG_DBG ("Returning failed request to kernel [%s]" ,RQ_TYPE (tfr->request_type));
@@ -177,7 +178,8 @@break ;case DM_CLOG_POSTSUSPEND : - r =do_request (tfr); +/* We do not specify ourselves as server here */ + r =do_request (tfr,0 );if (r) {LOG_DBG ("Returning failed request to kernel [%s]" ,RQ_TYPE (tfr->request_type));
@@ -212,6 +214,7 @@LOG_ERROR ("[%s] Unable to send %s to cluster: %s" ,SHORT_UUID (tfr->uuid),RQ_TYPE (tfr->request_type),strerror (-r)); + tfr->data_size =0 ; tfr->error = r;kernel_send (tfr); }else {