[Drbd-dev] [PATCH 2/3] Make the drbd driver generate resync-source callbacks

Iustin Pop iustin at google.com
Mon May 17 14:37:59 CEST 2010


---
 drbd/drbd_worker.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/drbd/drbd_worker.c b/drbd/drbd_worker.c
index df50bef..bee4ce2 100644
--- a/drbd/drbd_worker.c
+++ b/drbd/drbd_worker.c
@@ -761,6 +761,9 @@ int drbd_resync_finished(struct drbd_conf *mdev)
 		if (os.conn == C_SYNC_TARGET || os.conn == C_PAUSED_SYNC_T)
 			khelper_cmd = "after-resync-target";
 
+		if (os.conn == C_SYNC_SOURCE || os.conn == C_PAUSED_SYNC_S)
+			khelper_cmd = "after-resync-source";
+
 		if (mdev->csums_tfm && mdev->rs_total) {
 			const unsigned long s = mdev->rs_same_csum;
 			const unsigned long t = mdev->rs_total;
@@ -1365,6 +1368,17 @@ void drbd_start_resync(struct drbd_conf *mdev, enum drbd_conns side)
 			drbd_force_state(mdev, NS(conn, C_DISCONNECTING));
 			return;
 		}
+	} else {
+		/* Notify the user-space helper that we're becoming
+		   the source of a resync */
+		r = drbd_khelper(mdev, "before-resync-source");
+		r = (r >> 8) & 0xff;
+		if (r > 0) {
+			dev_info(DEV, "before-resync-source handler returned %d, "
+			     "dropping connection.\n", r);
+			drbd_force_state(mdev, NS(conn, C_DISCONNECTING));
+			return;
+		}
 	}
 
 	drbd_state_lock(mdev);
-- 
1.7.0.1



More information about the drbd-dev mailing list