[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] cluster/cmirror-kernel/src dm-cmirror-client.c ...



CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	STABLE
Changes by:	jbrassow sourceware org	2006-06-27 20:19:53

Modified files:
	cmirror-kernel/src: dm-cmirror-client.c dm-cmirror-common.h 
	                    dm-cmirror-server.c dm-cmirror-xfr.h 
	                    dm-log.h 

Log message:
	- bring logging functions inline with upstream API

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cmirror-kernel/src/dm-cmirror-client.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.1.4.1&r2=1.1.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cmirror-kernel/src/dm-cmirror-common.h.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.1.4.1&r2=1.1.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cmirror-kernel/src/dm-cmirror-server.c.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.1.4.1&r2=1.1.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cmirror-kernel/src/dm-cmirror-xfr.h.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.1.4.1&r2=1.1.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/cmirror-kernel/src/dm-log.h.diff?cvsroot=cluster&only_with_tag=STABLE&r1=1.1.4.1&r2=1.1.4.2

--- cluster/cmirror-kernel/src/Attic/dm-cmirror-client.c	2006/06/27 18:36:09	1.1.4.1
+++ cluster/cmirror-kernel/src/Attic/dm-cmirror-client.c	2006/06/27 20:19:53	1.1.4.2
@@ -58,7 +58,7 @@
 static int mark_req2ser=0;
 static int insync_req2ser=0;
 
-static void *region_state_alloc(int gfp_mask, void *pool_data){
+static void *region_state_alloc(gfp_t gfp_mask, void *pool_data){
 	return kmalloc(sizeof(struct region_state), gfp_mask);
 }
 
@@ -810,20 +810,6 @@
 	return rtn;
 }
 
-static int cluster_is_remote_recovering(struct dirty_log *log, region_t region)
-{
-	int rtn;
-	struct log_c *lc = (struct log_c *) log->context;
-
-/* take out optimization
-	if(atomic_read(&lc->in_sync) == 1){
-		return 0;
-	}
-*/
-	rtn = consult_server(lc, region, LRT_IS_REMOTE_RECOVERING, NULL);
-	return rtn;
-}
-
 static int cluster_in_sync(struct dirty_log *log, region_t region, int block)
 {
 	int rtn;
@@ -1128,6 +1114,36 @@
 	return lc->failure_response;
 }
 
+static int cluster_is_remote_recovering(struct dirty_log *log, region_t region)
+{
+	int rtn;
+	struct log_c *lc = (struct log_c *) log->context;
+
+/* take out optimization
+	if(atomic_read(&lc->in_sync) == 1){
+		return 0;
+	}
+*/
+	rtn = consult_server(lc, region, LRT_IS_REMOTE_RECOVERING, NULL);
+	return rtn;
+}
+
+static int cluster_set_default_mirror(struct dirty_log *log, int mirror)
+{
+	int rtn;
+	struct log_c *lc = (struct log_c *) log->context;
+	rtn = consult_server(lc, (region_t)mirror, LRT_SET_DEFAULT_MIRROR, NULL);
+	return rtn;
+}
+
+static int cluster_get_default_mirror(struct dirty_log *log)
+{
+	int rtn;
+	struct log_c *lc = (struct log_c *) log->context;
+	rtn = consult_server(lc, 0, LRT_GET_DEFAULT_MIRROR, NULL);
+	return rtn;
+}
+
 static int clog_stop(void *data){
 	struct log_c *lc;
 
@@ -1255,16 +1271,18 @@
 	.resume = cluster_resume,
 	.get_region_size = cluster_get_region_size,
 	.is_clean = cluster_is_clean,
-	.is_remote_recovering = cluster_is_remote_recovering,
 	.in_sync = cluster_in_sync,
 	.flush = cluster_flush,
 	.mark_region = cluster_mark_region,
 	.clear_region = cluster_clear_region,
 	.get_resync_work = cluster_get_resync_work,
-	.complete_resync_work = cluster_complete_resync_work,
+	.set_region_sync = cluster_complete_resync_work,
 	.get_sync_count = cluster_get_sync_count,
 	.status = cluster_status,
 	.get_failure_response = cluster_get_failure_response,
+	.is_remote_recovering = cluster_is_remote_recovering,
+	.set_default_mirror = cluster_set_default_mirror,
+	.get_default_mirror = cluster_get_default_mirror,
 };
 
 static struct dirty_log_type _clustered_disk_type = {
@@ -1277,16 +1295,18 @@
 	.resume = cluster_resume,
 	.get_region_size = cluster_get_region_size,
 	.is_clean = cluster_is_clean,
-	.is_remote_recovering = cluster_is_remote_recovering,
 	.in_sync = cluster_in_sync,
 	.flush = cluster_flush,
 	.mark_region = cluster_mark_region,
 	.clear_region = cluster_clear_region,
 	.get_resync_work = cluster_get_resync_work,
-	.complete_resync_work = cluster_complete_resync_work,
+	.set_region_sync = cluster_complete_resync_work,
 	.get_sync_count = cluster_get_sync_count,
 	.status = cluster_status,
 	.get_failure_response = cluster_get_failure_response,
+	.is_remote_recovering = cluster_is_remote_recovering,
+	.set_default_mirror = cluster_set_default_mirror,
+	.get_default_mirror = cluster_get_default_mirror,
 };
 
 #define CMIRROR_RELEASE_NAME "0.1.0"
--- cluster/cmirror-kernel/src/Attic/dm-cmirror-common.h	2006/06/27 18:36:09	1.1.4.1
+++ cluster/cmirror-kernel/src/Attic/dm-cmirror-common.h	2006/06/27 20:19:53	1.1.4.2
@@ -82,6 +82,7 @@
 	uint32_t version;
 	sector_t nr_regions;
 	char uuid[MAX_NAME_LEN];
+	int default_mirror;
 };
 
 struct log_c {
--- cluster/cmirror-kernel/src/Attic/dm-cmirror-server.c	2006/06/27 18:36:09	1.1.4.1
+++ cluster/cmirror-kernel/src/Attic/dm-cmirror-server.c	2006/06/27 20:19:53	1.1.4.2
@@ -49,7 +49,7 @@
 static int debug_disk_write = 0;
 extern struct list_head log_list_head;
 
-static void *region_user_alloc(int gfp_mask, void *pool_data){
+static void *region_user_alloc(gfp_t gfp_mask, void *pool_data){
 	return kmalloc(sizeof(struct region_user), gfp_mask);
 }
 
@@ -89,6 +89,7 @@
 	disk->version = cpu_to_le32(core->version);
 	disk->nr_regions = cpu_to_le64(core->nr_regions);
 	memcpy(disk->uuid, core->uuid, MAX_NAME_LEN);
+	disk->default_mirror = cpu_to_le32(core->default_mirror);
 }
 
 static void header_from_disk(struct log_header *core, struct log_header *disk)
@@ -97,6 +98,7 @@
 	core->version = le32_to_cpu(disk->version);
 	core->nr_regions = le64_to_cpu(disk->nr_regions);
 	memcpy(core->uuid, disk->uuid, MAX_NAME_LEN);
+	core->default_mirror = cpu_to_le32(disk->default_mirror);
 }
 
 int read_header(struct log_c *log)
@@ -449,19 +451,6 @@
 	return 0;
 }
 
-static int server_is_remote_recovering(struct log_c *lc, struct log_request *lr)
-{
-	struct region_user *ru;
-
-	if ((ru = find_ru_by_region(lc, lr->u.lr_region)) && 
-	    (ru->ru_rw == RU_RECOVER))
-		lr->u.lr_int_rtn = 1;
-	else
-		lr->u.lr_int_rtn = 0;
-
-	return 0;
-}
-
 static int server_in_sync(struct log_c *lc, struct log_request *lr)
 {
 	if(likely(log_test_bit(lc->sync_bits, lr->u.lr_region)))
@@ -586,7 +575,7 @@
 		}
 	} else if (log_test_bit(lc->sync_bits, lr->u.lr_region)) {
 		DMERR("complete_resync_work region going out-of-sync: disk failure");
-		/* gone for now: lc->sync_count--; */
+		lc->sync_count--;
 		log_clear_bit(lc, lc->sync_bits, lr->u.lr_region);
 	}
 
@@ -610,6 +599,37 @@
 }
 
 
+static int server_is_remote_recovering(struct log_c *lc, struct log_request *lr)
+{
+	struct region_user *ru;
+
+	if ((ru = find_ru_by_region(lc, lr->u.lr_region)) && 
+	    (ru->ru_rw == RU_RECOVER))
+		lr->u.lr_int_rtn = 1;
+	else
+		lr->u.lr_int_rtn = 0;
+
+	return 0;
+}
+
+static int server_set_default_mirror(struct log_c *lc, struct log_request *lr)
+{
+	lc->disk_header->default_mirror = (int)lr->u.lr_region;
+	if (write_header(lc))
+		DMERR("Failed to commit default mirror to disk log");
+
+	lr->u.lr_int_rtn = 0;
+
+	return 0;
+}
+
+static int server_get_default_mirror(struct log_c *lc, struct log_request *lr)
+{
+	lr->u.lr_int_rtn = lc->disk_header->default_mirror;
+
+	return 0;
+}
+
 static struct log_c *get_log_context(char *uuid){
 	struct log_c *lc, *r = NULL;
 
@@ -816,9 +836,6 @@
 		case LRT_IS_CLEAN:
 			error = server_is_clean(lc, &lr);
 			break;
-		case LRT_IS_REMOTE_RECOVERING:
-			error = server_is_remote_recovering(lc, &lr);
-			break;
 		case LRT_IN_SYNC:
 			error = server_in_sync(lc, &lr);
 			break;
@@ -853,6 +870,15 @@
 		case LRT_GET_SYNC_COUNT:
 			error = server_get_sync_count(lc, &lr);
 			break;
+		case LRT_IS_REMOTE_RECOVERING:
+			error = server_is_remote_recovering(lc, &lr);
+			break;
+		case LRT_SET_DEFAULT_MIRROR:
+			error = server_set_default_mirror(lc, &lr);
+			break;
+		case LRT_GET_DEFAULT_MIRROR:
+			error = server_get_default_mirror(lc, &lr);
+			break;
 		default:
 			DMWARN("unknown request type received");
 			return 0;  /* do not send a reply */
--- cluster/cmirror-kernel/src/Attic/dm-cmirror-xfr.h	2006/06/27 18:36:09	1.1.4.1
+++ cluster/cmirror-kernel/src/Attic/dm-cmirror-xfr.h	2006/06/27 20:19:53	1.1.4.2
@@ -23,6 +23,9 @@
 #define LRT_MASTER_ASSIGN		11
 #define LRT_MASTER_LEAVING		12
 
+#define LRT_SET_DEFAULT_MIRROR          13
+#define LRT_GET_DEFAULT_MIRROR          14
+
 #define CLUSTER_LOG_PORT 51005
 
 struct log_request {
--- cluster/cmirror-kernel/src/Attic/dm-log.h	2006/06/27 18:36:09	1.1.4.1
+++ cluster/cmirror-kernel/src/Attic/dm-log.h	2006/06/27 20:19:53	1.1.4.2
@@ -56,16 +56,6 @@
 	int (*is_clean)(struct dirty_log *log, region_t region);
 
 	/*
-	 * Returns: 0, 1
-	 *
-	 * This is necessary for cluster mirroring. It provides
-	 * a way to detect recovery on another node, so we
-	 * aren't writing concurrently.  This function is likely
-	 * to block (when a cluster log is used).
-	 */
-	int (*is_remote_recovering)(struct dirty_log *log, region_t region);
-
-	/*
 	 *  Returns: 0, 1, -EWOULDBLOCK, < 0
 	 *
 	 * A predicate function to check the area given by
@@ -108,12 +98,12 @@
 	int (*get_resync_work)(struct dirty_log *log, region_t *region);
 
 	/*
-	 * This notifies the log that the resync of an area has
-	 * been completed.  The log should then mark this region
-	 * as CLEAN.
+	 * This notifies the log that the resync status of a region
+	 * has changed.  It also clears the region from the recovering
+	 * list (if present).
 	 */
-	void (*complete_resync_work)(struct dirty_log *log,
-				     region_t region, int success);
+	void (*set_region_sync)(struct dirty_log *log,
+				region_t region, int in_sync);
 
         /*
 	 * Returns the number of regions that are in sync.
@@ -131,6 +121,31 @@
 	 * of a device failure.
 	 */
 	int (*get_failure_response)(struct dirty_log *log);
+
+	/*
+	 * Returns: 0, 1
+	 *
+	 * This is necessary for cluster mirroring. It provides
+	 * a way to detect recovery on another node, so we
+	 * aren't writing concurrently.  This function is likely
+	 * to block (when a cluster log is used).
+	 */
+	int (*is_remote_recovering)(struct dirty_log *log, region_t region);
+
+	/*
+	 * Returns: 0 on success, <0 on failure
+	 *
+	 * This function is necessary for cluster mirroring.
+	 * If a node detects the primary device has failed,
+	 * the others must have a way of knowing what its
+	 * successor is.
+	 */
+	int (*set_default_mirror)(struct dirty_log *log, int mirror);
+
+	/*
+	 * Returns: >=0 on success, <0 on failure
+	 */
+	int (*get_default_mirror)(struct dirty_log *log);
 };
 
 int dm_register_dirty_log_type(struct dirty_log_type *type);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]