aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Reisner <philipp.reisner@linbit.com>2010-02-02 15:03:50 -0500
committerPhilipp Reisner <philipp.reisner@linbit.com>2010-03-11 09:51:23 -0500
commitcf14c2e987ba0a09a7b09be2ecd55af0bc9c17b4 (patch)
tree3e403ecc535e3860ab5835343fd428c77cad9f5c
parent8a03ae2a5baed3df09e5643615bdd853fc142a09 (diff)
drbd: --dry-run option for drbdsetup net ( drbdadm -- --dry-run connect <res> )
Signed-off-by: Philipp Reisner <philipp.reisner@linbit.com> Signed-off-by: Lars Ellenberg <lars.ellenberg@linbit.com>
-rw-r--r--drivers/block/drbd/drbd_int.h8
-rw-r--r--drivers/block/drbd/drbd_main.c16
-rw-r--r--drivers/block/drbd/drbd_receiver.c22
-rw-r--r--include/linux/drbd.h2
-rw-r--r--include/linux/drbd_nl.h1
5 files changed, 43 insertions, 6 deletions
diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
index 2bf3a6ef3684..1aae724e37fb 100644
--- a/drivers/block/drbd/drbd_int.h
+++ b/drivers/block/drbd/drbd_int.h
@@ -443,13 +443,18 @@ struct p_rs_param_89 {
443 char csums_alg[SHARED_SECRET_MAX]; 443 char csums_alg[SHARED_SECRET_MAX];
444} __packed; 444} __packed;
445 445
446enum drbd_conn_flags {
447 CF_WANT_LOSE = 1,
448 CF_DRY_RUN = 2,
449};
450
446struct p_protocol { 451struct p_protocol {
447 struct p_header head; 452 struct p_header head;
448 u32 protocol; 453 u32 protocol;
449 u32 after_sb_0p; 454 u32 after_sb_0p;
450 u32 after_sb_1p; 455 u32 after_sb_1p;
451 u32 after_sb_2p; 456 u32 after_sb_2p;
452 u32 want_lose; 457 u32 conn_flags;
453 u32 two_primaries; 458 u32 two_primaries;
454 459
455 /* Since protocol version 87 and higher. */ 460 /* Since protocol version 87 and higher. */
@@ -791,6 +796,7 @@ enum {
791 * while this is set. */ 796 * while this is set. */
792 RESIZE_PENDING, /* Size change detected locally, waiting for the response from 797 RESIZE_PENDING, /* Size change detected locally, waiting for the response from
793 * the peer, if it changed there as well. */ 798 * the peer, if it changed there as well. */
799 CONN_DRY_RUN, /* Expect disconnect after resync handshake. */
794}; 800};
795 801
796struct drbd_bitmap; /* opaque for drbd_conf */ 802struct drbd_bitmap; /* opaque for drbd_conf */
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
index ab871e00ffc5..b2d347d18c7d 100644
--- a/drivers/block/drbd/drbd_main.c
+++ b/drivers/block/drbd/drbd_main.c
@@ -1668,7 +1668,7 @@ int drbd_send_sync_param(struct drbd_conf *mdev, struct syncer_conf *sc)
1668int drbd_send_protocol(struct drbd_conf *mdev) 1668int drbd_send_protocol(struct drbd_conf *mdev)
1669{ 1669{
1670 struct p_protocol *p; 1670 struct p_protocol *p;
1671 int size, rv; 1671 int size, cf, rv;
1672 1672
1673 size = sizeof(struct p_protocol); 1673 size = sizeof(struct p_protocol);
1674 1674
@@ -1685,9 +1685,21 @@ int drbd_send_protocol(struct drbd_conf *mdev)
1685 p->after_sb_0p = cpu_to_be32(mdev->net_conf->after_sb_0p); 1685 p->after_sb_0p = cpu_to_be32(mdev->net_conf->after_sb_0p);
1686 p->after_sb_1p = cpu_to_be32(mdev->net_conf->after_sb_1p); 1686 p->after_sb_1p = cpu_to_be32(mdev->net_conf->after_sb_1p);
1687 p->after_sb_2p = cpu_to_be32(mdev->net_conf->after_sb_2p); 1687 p->after_sb_2p = cpu_to_be32(mdev->net_conf->after_sb_2p);
1688 p->want_lose = cpu_to_be32(mdev->net_conf->want_lose);
1689 p->two_primaries = cpu_to_be32(mdev->net_conf->two_primaries); 1688 p->two_primaries = cpu_to_be32(mdev->net_conf->two_primaries);
1690 1689
1690 cf = 0;
1691 if (mdev->net_conf->want_lose)
1692 cf |= CF_WANT_LOSE;
1693 if (mdev->net_conf->dry_run) {
1694 if (mdev->agreed_pro_version >= 92)
1695 cf |= CF_DRY_RUN;
1696 else {
1697 dev_err(DEV, "--dry-run is not supported by peer");
1698 return 0;
1699 }
1700 }
1701 p->conn_flags = cpu_to_be32(cf);
1702
1691 if (mdev->agreed_pro_version >= 87) 1703 if (mdev->agreed_pro_version >= 87)
1692 strcpy(p->integrity_alg, mdev->net_conf->integrity_alg); 1704 strcpy(p->integrity_alg, mdev->net_conf->integrity_alg);
1693 1705
diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
index d065c646b35a..8bcde4a9632b 100644
--- a/drivers/block/drbd/drbd_receiver.c
+++ b/drivers/block/drbd/drbd_receiver.c
@@ -2538,6 +2538,16 @@ static enum drbd_conns drbd_sync_handshake(struct drbd_conf *mdev, enum drbd_rol
2538 } 2538 }
2539 } 2539 }
2540 2540
2541 if (mdev->net_conf->dry_run || test_bit(CONN_DRY_RUN, &mdev->flags)) {
2542 if (hg == 0)
2543 dev_info(DEV, "dry-run connect: No resync, would become Connected immediately.\n");
2544 else
2545 dev_info(DEV, "dry-run connect: Would become %s, doing a %s resync.",
2546 drbd_conn_str(hg > 0 ? C_SYNC_SOURCE : C_SYNC_TARGET),
2547 abs(hg) >= 2 ? "full" : "bit-map based");
2548 return C_MASK;
2549 }
2550
2541 if (abs(hg) >= 2) { 2551 if (abs(hg) >= 2) {
2542 dev_info(DEV, "Writing the whole bitmap, full sync required after drbd_sync_handshake.\n"); 2552 dev_info(DEV, "Writing the whole bitmap, full sync required after drbd_sync_handshake.\n");
2543 if (drbd_bitmap_io(mdev, &drbd_bmio_set_n_write, "set_n_write from sync_handshake")) 2553 if (drbd_bitmap_io(mdev, &drbd_bmio_set_n_write, "set_n_write from sync_handshake"))
@@ -2585,7 +2595,7 @@ static int receive_protocol(struct drbd_conf *mdev, struct p_header *h)
2585 struct p_protocol *p = (struct p_protocol *)h; 2595 struct p_protocol *p = (struct p_protocol *)h;
2586 int header_size, data_size; 2596 int header_size, data_size;
2587 int p_proto, p_after_sb_0p, p_after_sb_1p, p_after_sb_2p; 2597 int p_proto, p_after_sb_0p, p_after_sb_1p, p_after_sb_2p;
2588 int p_want_lose, p_two_primaries; 2598 int p_want_lose, p_two_primaries, cf;
2589 char p_integrity_alg[SHARED_SECRET_MAX] = ""; 2599 char p_integrity_alg[SHARED_SECRET_MAX] = "";
2590 2600
2591 header_size = sizeof(*p) - sizeof(*h); 2601 header_size = sizeof(*p) - sizeof(*h);
@@ -2598,8 +2608,14 @@ static int receive_protocol(struct drbd_conf *mdev, struct p_header *h)
2598 p_after_sb_0p = be32_to_cpu(p->after_sb_0p); 2608 p_after_sb_0p = be32_to_cpu(p->after_sb_0p);
2599 p_after_sb_1p = be32_to_cpu(p->after_sb_1p); 2609 p_after_sb_1p = be32_to_cpu(p->after_sb_1p);
2600 p_after_sb_2p = be32_to_cpu(p->after_sb_2p); 2610 p_after_sb_2p = be32_to_cpu(p->after_sb_2p);
2601 p_want_lose = be32_to_cpu(p->want_lose);
2602 p_two_primaries = be32_to_cpu(p->two_primaries); 2611 p_two_primaries = be32_to_cpu(p->two_primaries);
2612 cf = be32_to_cpu(p->conn_flags);
2613 p_want_lose = cf & CF_WANT_LOSE;
2614
2615 clear_bit(CONN_DRY_RUN, &mdev->flags);
2616
2617 if (cf & CF_DRY_RUN)
2618 set_bit(CONN_DRY_RUN, &mdev->flags);
2603 2619
2604 if (p_proto != mdev->net_conf->wire_protocol) { 2620 if (p_proto != mdev->net_conf->wire_protocol) {
2605 dev_err(DEV, "incompatible communication protocols\n"); 2621 dev_err(DEV, "incompatible communication protocols\n");
@@ -3125,6 +3141,8 @@ static int receive_state(struct drbd_conf *mdev, struct p_header *h)
3125 dev_err(DEV, "Disk attach process on the peer node was aborted.\n"); 3141 dev_err(DEV, "Disk attach process on the peer node was aborted.\n");
3126 peer_state.disk = D_DISKLESS; 3142 peer_state.disk = D_DISKLESS;
3127 } else { 3143 } else {
3144 if (test_and_clear_bit(CONN_DRY_RUN, &mdev->flags))
3145 return FALSE;
3128 D_ASSERT(oconn == C_WF_REPORT_PARAMS); 3146 D_ASSERT(oconn == C_WF_REPORT_PARAMS);
3129 drbd_force_state(mdev, NS(conn, C_DISCONNECTING)); 3147 drbd_force_state(mdev, NS(conn, C_DISCONNECTING));
3130 return FALSE; 3148 return FALSE;
diff --git a/include/linux/drbd.h b/include/linux/drbd.h
index 78962272338a..4341b1a97a34 100644
--- a/include/linux/drbd.h
+++ b/include/linux/drbd.h
@@ -56,7 +56,7 @@ extern const char *drbd_buildtag(void);
56#define REL_VERSION "8.3.7" 56#define REL_VERSION "8.3.7"
57#define API_VERSION 88 57#define API_VERSION 88
58#define PRO_VERSION_MIN 86 58#define PRO_VERSION_MIN 86
59#define PRO_VERSION_MAX 91 59#define PRO_VERSION_MAX 92
60 60
61 61
62enum drbd_io_error_p { 62enum drbd_io_error_p {
diff --git a/include/linux/drbd_nl.h b/include/linux/drbd_nl.h
index a4d82f895994..b41050e8cc2f 100644
--- a/include/linux/drbd_nl.h
+++ b/include/linux/drbd_nl.h
@@ -63,6 +63,7 @@ NL_PACKET(net_conf, 5,
63 NL_BIT( 41, T_MAY_IGNORE, always_asbp) 63 NL_BIT( 41, T_MAY_IGNORE, always_asbp)
64 NL_BIT( 61, T_MAY_IGNORE, no_cork) 64 NL_BIT( 61, T_MAY_IGNORE, no_cork)
65 NL_BIT( 62, T_MANDATORY, auto_sndbuf_size) 65 NL_BIT( 62, T_MANDATORY, auto_sndbuf_size)
66 NL_BIT( 70, T_MANDATORY, dry_run)
66) 67)
67 68
68NL_PACKET(disconnect, 6, ) 69NL_PACKET(disconnect, 6, )