All of lore.kernel.org
 help / color / mirror / Atom feed
From: jbrassow@sourceware.org <jbrassow@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/cmirror-kernel/src dm-cmirror-client.c ...
Date: 27 Jun 2006 20:19:57 -0000	[thread overview]
Message-ID: <20060627201957.9006.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	STABLE
Changes by:	jbrassow at 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);



             reply	other threads:[~2006-06-27 20:19 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-06-27 20:19 jbrassow [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-10-03 19:02 [Cluster-devel] cluster/cmirror-kernel/src dm-cmirror-client.c jbrassow
2007-09-27 20:31 jbrassow
2007-09-26  3:15 jbrassow
2007-09-21 20:07 jbrassow
2007-09-13 15:24 jbrassow
2007-07-11 16:18 jbrassow
2007-04-26 16:55 jbrassow
2007-04-26 16:54 jbrassow
2007-04-24 20:10 jbrassow
2007-04-24 20:08 jbrassow
2007-04-10  7:13 jbrassow
2007-04-10  7:12 jbrassow
2007-04-05 21:33 jbrassow
2007-04-05 21:32 jbrassow
2007-04-03 18:23 jbrassow
2007-04-03 18:21 jbrassow
2007-03-22 22:34 jbrassow
2007-03-22 22:22 jbrassow
2007-03-14  4:28 jbrassow
2007-02-26 17:38 jbrassow
2007-02-20 19:35 jbrassow
2007-02-19 16:29 jbrassow
2007-02-14 17:44 jbrassow
2007-02-02 17:22 jbrassow
2007-01-08 19:28 jbrassow
2006-12-07 18:58 jbrassow
2006-09-05 17:50 jbrassow
2006-09-05 17:48 jbrassow
2006-07-27 23:11 jbrassow
2006-07-27 23:11 jbrassow
2006-07-22 22:19 jbrassow
2006-07-22 22:19 jbrassow
2006-07-22 22:12 jbrassow
2006-06-29 19:49 jbrassow
2006-06-29 19:48 jbrassow
2006-06-29 19:46 jbrassow
2006-06-15 19:48 jbrassow
2006-06-15 19:34 jbrassow
2006-06-13 16:26 jbrassow

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20060627201957.9006.qmail@sourceware.org \
    --to=jbrassow@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.