[sheepdog] [PATCH 1/2] sheep: pass a node list to update_epoch_log

Christoph Hellwig hch at infradead.org
Thu May 17 10:14:51 CEST 2012


Assuming some arguments come from sys while the epoch is passed is a bad
convention.  In addition the next patch will add a caller that doesn't
take the nodes array from sys.

Signed-off-by: Christoph Hellwig <hch at lst.de>
---
 sheep/group.c      |   14 +++++++-------
 sheep/ops.c        |    4 ++--
 sheep/sheep_priv.h |    2 +-
 sheep/store.c      |    8 ++++----
 4 files changed, 14 insertions(+), 14 deletions(-)

Index: sheepdog/sheep/group.c
===================================================================
--- sheepdog.orig/sheep/group.c	2012-05-17 09:56:30.283986140 +0200
+++ sheepdog/sheep/group.c	2012-05-17 09:56:40.431986043 +0200
@@ -628,7 +628,7 @@ static void finish_join(struct join_mess
 
 	if ((msg->cluster_status == SD_STATUS_OK ||
 	     msg->cluster_status == SD_STATUS_HALT) && msg->inc_epoch)
-		update_epoch_log(sys->epoch);
+		update_epoch_log(sys->epoch, sys->nodes, sys->nr_nodes);
 
 	if (!sd_store && strlen((char *)msg->store)) {
 		sd_store = find_store_driver((char *)msg->store);
@@ -660,7 +660,7 @@ static void update_cluster_info(struct j
 	    msg->cluster_status == SD_STATUS_HALT) {
 		if (msg->inc_epoch) {
 			sys->epoch++;
-			update_epoch_log(sys->epoch);
+			update_epoch_log(sys->epoch, sys->nodes, sys->nr_nodes);
 			update_epoch_store(sys->epoch);
 		}
 		/* Fresh node */
@@ -939,7 +939,7 @@ static void __sd_leave_done(struct event
 	if (sys_can_recover()) {
 		sys->epoch++;
 		update_epoch_store(sys->epoch);
-		update_epoch_log(sys->epoch);
+		update_epoch_log(sys->epoch, sys->nodes, sys->nr_nodes);
 	}
 	update_vnode_info();
 
@@ -1247,10 +1247,10 @@ void sd_join_handler(struct sd_node *joi
 		nr = nr_members;
 		nr_leave = get_nodes_nr_from(&sys->leave_list);
 
-		dprintf("%d == %d + %d \n", nr_local, nr, nr_leave);
+		dprintf("%d == %d + %d\n", nr_local, nr, nr_leave);
 		if (nr_local == nr + nr_leave) {
 			sys_stat_set(SD_STATUS_OK);
-			update_epoch_log(sys->epoch);
+			update_epoch_log(sys->epoch, sys->nodes, sys->nr_nodes);
 			update_epoch_store(sys->epoch);
 		}
 		break;
@@ -1288,10 +1288,10 @@ void sd_join_handler(struct sd_node *joi
 		nr = nr_members;
 		nr_leave = get_nodes_nr_from(&sys->leave_list);
 
-		dprintf("%d == %d + %d \n", nr_local, nr, nr_leave);
+		dprintf("%d == %d + %d\n", nr_local, nr, nr_leave);
 		if (nr_local == nr + nr_leave) {
 			sys_stat_set(SD_STATUS_OK);
-			update_epoch_log(sys->epoch);
+			update_epoch_log(sys->epoch, sys->nodes, sys->nr_nodes);
 			update_epoch_store(sys->epoch);
 		}
 
Index: sheepdog/sheep/ops.c
===================================================================
--- sheepdog.orig/sheep/ops.c	2012-05-17 09:49:26.627990180 +0200
+++ sheepdog/sheep/ops.c	2012-05-17 09:56:40.431986043 +0200
@@ -251,7 +251,7 @@ static int cluster_make_fs(const struct
 	sys->epoch = 1;
 	sys->recovered_epoch = 1;
 
-	ret = update_epoch_log(sys->epoch);
+	ret = update_epoch_log(sys->epoch, sys->nodes, sys->nr_nodes);
 	if (ret)
 		return SD_RES_EIO;
 
@@ -498,7 +498,7 @@ static int cluster_manual_recover(const
 		sys->nr_copies);
 
 	sys->epoch++; /* some nodes are left, so we get a new epoch */
-	ret = update_epoch_log(sys->epoch);
+	ret = update_epoch_log(sys->epoch, sys->nodes, sys->nr_nodes);
 	if (ret) {
 		ret = SD_RES_EIO;
 		sys->epoch--;
Index: sheepdog/sheep/sheep_priv.h
===================================================================
--- sheepdog.orig/sheep/sheep_priv.h	2012-05-17 09:56:30.283986140 +0200
+++ sheepdog/sheep/sheep_priv.h	2012-05-17 09:56:40.431986043 +0200
@@ -269,7 +269,7 @@ int read_epoch(uint32_t *epoch, uint64_t
 	       struct sd_node *entries, int *nr_entries);
 
 int update_epoch_store(uint32_t epoch);
-int update_epoch_log(uint32_t epoch);
+int update_epoch_log(uint32_t epoch, struct sd_node *nodes, size_t nr_nodes);
 
 int set_cluster_copies(uint8_t copies);
 int get_cluster_copies(uint8_t *copies);
Index: sheepdog/sheep/store.c
===================================================================
--- sheepdog.orig/sheep/store.c	2012-05-17 09:49:26.627990180 +0200
+++ sheepdog/sheep/store.c	2012-05-17 09:56:40.431986043 +0200
@@ -258,13 +258,13 @@ int update_epoch_store(uint32_t epoch)
 	return 0;
 }
 
-int update_epoch_log(uint32_t epoch)
+int update_epoch_log(uint32_t epoch, struct sd_node *nodes, size_t nr_nodes)
 {
 	int fd, ret, len;
 	time_t t;
 	char path[PATH_MAX];
 
-	dprintf("update epoch: %d, %d\n", epoch, sys->nr_nodes);
+	dprintf("update epoch: %d, %zd\n", epoch, nr_nodes);
 
 	snprintf(path, sizeof(path), "%s%08u", epoch_path, epoch);
 	fd = open(path, O_RDWR | O_CREAT | O_DSYNC, def_fmode);
@@ -273,8 +273,8 @@ int update_epoch_log(uint32_t epoch)
 		goto err_open;
 	}
 
-	len = sys->nr_nodes * sizeof(struct sd_node);
-	ret = write(fd, (char *)sys->nodes, len);
+	len = nr_nodes * sizeof(struct sd_node);
+	ret = write(fd, (char *)nodes, len);
 	if (ret != len)
 		goto err;
 



More information about the sheepdog mailing list