[Drbd-dev] [PATCH 08/10] Receive UI_FLAGS 16 of P_UUIDS to start zero out devices.

Nick Wang nwang at suse.com
Wed Jun 10 09:48:27 CEST 2015


Receive P_UUIDS protocol to start zero out device.

Signed-off-by: Nick Wang <nwang at suse.com>
CC: Philipp Reisner <philipp.reisner at linbit.com>
CC: Lars Ellenberg <lars.ellenberg at linbit.com>
CC: drbd-dev at lists.linbit.com
CC: linux-kernel at vger.kernel.org

---
 drbd/drbd_receiver.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c
index 41c958a..cbb66e6 100644
--- a/drbd/drbd_receiver.c
+++ b/drbd/drbd_receiver.c
@@ -4304,6 +4304,7 @@ static int receive_uuids(struct drbd_connection *connection, struct packet_info
 	struct p_uuids *p = pi->data;
 	u64 *p_uuid;
 	int i, updated_uuids = 0;
+	int zero_out_err = 0;
 
 	peer_device = conn_peer_device(connection, pi->vnr);
 	if (!peer_device)
@@ -4338,6 +4339,11 @@ static int receive_uuids(struct drbd_connection *connection, struct packet_info
 			peer_device->connection->agreed_pro_version >= 90 &&
 			device->ldev->md.uuid[UI_CURRENT] == UUID_JUST_CREATED &&
 			(p_uuid[UI_FLAGS] & 8);
+		int zero_out_devices =
+			device->state.conn == C_CONNECTED &&
+			peer_device->connection->agreed_pro_version >= 90 &&
+			device->ldev->md.uuid[UI_CURRENT] == UUID_JUST_CREATED &&
+			(p_uuid[UI_FLAGS] & 16);
 		if (skip_initial_sync) {
 			drbd_info(device, "Accepted new current UUID, preparing to skip initial sync\n");
 			drbd_bitmap_io(device, &drbd_bmio_clear_n_write,
@@ -4350,6 +4356,23 @@ static int receive_uuids(struct drbd_connection *connection, struct packet_info
 			drbd_md_sync(device);
 			updated_uuids = 1;
 		}
+
+		if (zero_out_devices) {
+			drbd_info(device, "Accepted to zero out devices, will take a long time\n");
+			_drbd_uuid_set(device, UI_CURRENT, p_uuid[UI_CURRENT]);
+			_drbd_uuid_set(device, UI_BITMAP, 0);
+			drbd_print_uuids(device, "cleared bitmap UUID for zeroing device");
+			zero_out_err = zero_out_local_device(device);
+			if (zero_out_err) {
+				drbd_err(device, "Failed to zero out local device\n");
+				drbd_send_zero_out_fail(peer_device);
+				drbd_chk_io_error(device, 1, DRBD_WRITE_ERROR);
+			} else {
+				drbd_info(device, "Finish zero out device\n");
+				drbd_send_zero_out_ok(peer_device);
+			}
+		}
+
 		put_ldev(device);
 	} else if (device->state.disk < D_INCONSISTENT &&
 		   device->state.role == R_PRIMARY) {
-- 
1.8.4.5



More information about the drbd-dev mailing list