All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan E Brassow <jbrassow@redhat.com>
To: device-mapper development <dm-devel@redhat.com>
Cc: Kergon Alasdair <agk@redhat.com>
Subject: mirroring: [patch 1 of 8] device failure tolerance
Date: Wed, 29 Jun 2005 13:07:49 -0500	[thread overview]
Message-ID: <16a7b346170f3909d57592016a32abc0@redhat.com> (raw)

This patch defines a couple more states that logs can return, and 
checks for those states in the mirror code.  The states are useful for 
logs that have cluster support.

  brassow

diff -urN linux-2.6.12-orig/drivers/md/dm-log.c 
linux-2.6.12-001/drivers/md/dm-log.c
--- linux-2.6.12-orig/drivers/md/dm-log.c	2005-06-17 14:48:29.000000000 
-0500
+++ linux-2.6.12-001/drivers/md/dm-log.c	2005-06-28 14:38:40.349390239 
-0500
@@ -517,13 +517,13 @@
  static int core_is_clean(struct dirty_log *log, region_t region)
  {
  	struct log_c *lc = (struct log_c *) log->context;
-	return log_test_bit(lc->clean_bits, region);
+	return (log_test_bit(lc->clean_bits, region)) ? LOG_CLEAN : LOG_DIRTY;
  }

  static int core_in_sync(struct dirty_log *log, region_t region, int 
block)
  {
  	struct log_c *lc = (struct log_c *) log->context;
-	return log_test_bit(lc->sync_bits, region);
+	return (log_test_bit(lc->sync_bits, region)) ? LOG_CLEAN : LOG_NOSYNC;
  }

  static int core_flush(struct dirty_log *log)
diff -urN linux-2.6.12-orig/drivers/md/dm-log.h 
linux-2.6.12-001/drivers/md/dm-log.h
--- linux-2.6.12-orig/drivers/md/dm-log.h	2005-06-17 14:48:29.000000000 
-0500
+++ linux-2.6.12-001/drivers/md/dm-log.h	2005-06-28 14:23:54.655103852 
-0500
@@ -9,6 +9,12 @@

  #include "dm.h"

+#define LOG_DIRTY              0
+#define LOG_CLEAN              1
+#define LOG_NOSYNC             2
+#define LOG_RECOVERING         3
+#define LOG_REMOTE_RECOVERING  4
+
  typedef sector_t region_t;

  struct dirty_log_type;
diff -urN linux-2.6.12-orig/drivers/md/dm-raid1.c 
linux-2.6.12-001/drivers/md/dm-raid1.c
--- linux-2.6.12-orig/drivers/md/dm-raid1.c	2005-06-17 
14:48:29.000000000 -0500
+++ linux-2.6.12-001/drivers/md/dm-raid1.c	2005-06-28 
14:49:38.985786409 -0500
@@ -91,7 +91,8 @@
  	RH_CLEAN,
  	RH_DIRTY,
  	RH_NOSYNC,
-	RH_RECOVERING
+	RH_RECOVERING,
+	RH_REMOTE_RECOVERING
  };

  struct region {
@@ -234,7 +235,7 @@

  	read_unlock(&rh->hash_lock);
  	nreg = mempool_alloc(rh->region_pool, GFP_NOIO);
-	nreg->state = rh->log->type->in_sync(rh->log, region, 1) ?
+	nreg->state = (rh->log->type->in_sync(rh->log, region, 1) == 
LOG_CLEAN) ?
  		RH_CLEAN : RH_NOSYNC;
  	nreg->rh = rh;
  	nreg->key = region;
@@ -292,13 +293,26 @@
  	 * The region wasn't in the hash, so we fall back to the
  	 * dirty log.
  	 */
-	r = rh->log->type->in_sync(rh->log, region, may_block);
-
+	switch (rh->log->type->in_sync(rh->log, region, may_block)) {
+	case LOG_CLEAN:
+		r = RH_CLEAN;
+		break;
+	case LOG_DIRTY:
+		r = RH_DIRTY;
+		break;
+	case LOG_REMOTE_RECOVERING:
+		r = RH_REMOTE_RECOVERING;
+		break;
+	default:
+		r = RH_NOSYNC;
+		break;
+	}
+	
  	/*
  	 * Any error from the dirty log (eg. -EWOULDBLOCK) gets
  	 * taken as a RH_NOSYNC
  	 */
-	return r == 1 ? RH_CLEAN : RH_NOSYNC;
+	return r;
  }

  static inline int rh_in_sync(struct region_hash *rh,
@@ -702,7 +716,7 @@
  		/*
  		 * We can only read balance if the region is in sync.
  		 */
-		if (rh_in_sync(&ms->rh, region, 0))
+		if (rh_in_sync(&ms->rh, region, 0) == RH_CLEAN)
  			m = choose_mirror(ms, bio->bi_sector);
  		else
  			m = ms->mirror + DEFAULT_MIRROR;
@@ -1117,7 +1131,7 @@
  	if (r < 0 && r != -EWOULDBLOCK)
  		return r;

-	if (r == -EWOULDBLOCK)	/* FIXME: ugly */
+	if (r != RH_CLEAN)
  		r = 0;

  	/*

             reply	other threads:[~2005-06-29 18:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-29 18:07 Jonathan E Brassow [this message]
2005-06-30 11:33 ` mirroring: [patch 1 of 8] device failure tolerance Lars Marowsky-Bree
2005-06-30 11:33   ` [dm-devel] " Lars Marowsky-Bree
2005-06-30 15:13 ` Greg Freemyer
2005-06-30 15:38   ` Jonathan E Brassow
2005-06-30 16:38     ` Greg Freemyer
2005-06-30 18:00       ` Jonathan E Brassow

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=16a7b346170f3909d57592016a32abc0@redhat.com \
    --to=jbrassow@redhat.com \
    --cc=agk@redhat.com \
    --cc=dm-devel@redhat.com \
    /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.