[sheepdog] [PATCH 1/7] local: remove checksum

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Tue Sep 4 10:05:37 CEST 2012


Currently, local driver doesn't update both queue and checksum data
atomically, so if the process exits unexpectedly after updating queue
and before doing checksum, a newly started process can regard the
queue as invalid.

This patch removes checksum feature completely from local driver.
Though we should introduce something like journaling to update queue
safely, it looks overkill because local driver is only for testing
purpose.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 sheep/cluster/local.c |   25 -------------------------
 1 files changed, 0 insertions(+), 25 deletions(-)

diff --git a/sheep/cluster/local.c b/sheep/cluster/local.c
index 3e6333a..a5b28b6 100644
--- a/sheep/cluster/local.c
+++ b/sheep/cluster/local.c
@@ -58,8 +58,6 @@ struct local_event {
 /* shared memory queue */
 
 struct shm_queue {
-	uint64_t chksum;
-
 	int pos;
 	struct local_event events[MAX_EVENTS];
 } *shm_queue;
@@ -125,26 +123,12 @@ static struct local_event *shm_queue_pop(void)
 	return shm_queue->events + event_pos;
 }
 
-static uint64_t shm_queue_calc_chksum(void)
-{
-	return fnv_64a_buf(shm_queue->events + shm_queue->pos,
-			   sizeof(*shm_queue->events), FNV1A_64_INIT);
-}
-
-static void shm_queue_set_chksum(void)
-{
-	shm_queue->chksum = shm_queue_calc_chksum();
-	msync(&shm_queue->chksum, sizeof(shm_queue->chksum), MS_SYNC);
-}
-
 static void shm_queue_notify(void)
 {
 	int i;
 	size_t nr;
 	pid_t pids[SD_MAX_NODES];
 
-	shm_queue_set_chksum();
-
 	nr = get_nodes(NULL, pids);
 
 	for (i = 0; i < nr; i++)
@@ -157,11 +141,6 @@ static int is_shm_queue_valid(void)
 	size_t nr;
 	pid_t pids[SD_MAX_NODES];
 
-	if (shm_queue->chksum != shm_queue_calc_chksum()) {
-		dprintf("invalid shm queue\n");
-		return 0;
-	}
-
 	nr = get_nodes(NULL, pids);
 
 	if (nr == 0)
@@ -200,8 +179,6 @@ static void shm_queue_init(void)
 		assert(ret == 0);
 		ret = ftruncate(shmfd, sizeof(*shm_queue));
 		assert(ret == 0);
-
-		shm_queue_set_chksum();
 	}
 
 	shm_queue_unlock();
@@ -378,8 +355,6 @@ static bool local_process_event(void)
 			ev->nr_nodes = 1;
 			ev->nodes[0] = this_node;
 			ev->pids[0] = getpid();
-
-			shm_queue_set_chksum();
 		}
 
 		sd_join_handler(&ev->sender, ev->nodes, ev->nr_nodes,
-- 
1.7.2.5




More information about the sheepdog mailing list