Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752285AbbGMIj5 (ORCPT ); Mon, 13 Jul 2015 04:39:57 -0400 Received: from victor.provo.novell.com ([137.65.250.26]:32967 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751972AbbGMIjy (ORCPT ); Mon, 13 Jul 2015 04:39:54 -0400 From: Nick Wang To: nwang@suse.com Cc: philipp.reisner@linbit.com, Lars Ellenberg , drbd-dev@lists.linbit.com, linux-kernel@vger.kernel.org Subject: [Patch v2 09/10] drbd: Handle zero out command from peer node Date: Mon, 13 Jul 2015 16:39:03 +0800 Message-Id: <1436776744-3135-10-git-send-email-nwang@suse.com> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1436776744-3135-1-git-send-email-nwang@suse.com> References: <1436776744-3135-1-git-send-email-nwang@suse.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3000 Lines: 77 Recevie P_UUID flag 16 for starting zero out device, P_UUID flag 32 after both side finished zeroing, Change state to uptodate. Signed-off-by: Nick Wang CC: Philipp Reisner CC: Lars Ellenberg CC: drbd-dev@lists.linbit.com CC: linux-kernel@vger.kernel.org --- drbd/drbd_receiver.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c index 6eae84f..4d6d99a 100644 --- a/drbd/drbd_receiver.c +++ b/drbd/drbd_receiver.c @@ -4317,6 +4317,15 @@ 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); + int zero_out_finish = + device->state.conn == C_CONNECTED && + peer_device->connection->agreed_pro_version >= 90 && + (p_uuid[UI_FLAGS] & 32); 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, @@ -4324,11 +4333,35 @@ static int receive_uuids(struct drbd_connection *connection, struct packet_info BM_LOCKED_TEST_ALLOWED); _drbd_uuid_set(device, UI_CURRENT, p_uuid[UI_CURRENT]); _drbd_uuid_set(device, UI_BITMAP, 0); + spin_lock_irq(&device->resource->req_lock); _drbd_set_state(_NS2(device, disk, D_UP_TO_DATE, pdsk, D_UP_TO_DATE), CS_VERBOSE, NULL); + spin_unlock_irq(&device->resource->req_lock); 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_bitmap_io(device, &drbd_bmio_clear_n_write, + "clear_n_write from receive_uuids", + BM_LOCKED_TEST_ALLOWED); + _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"); + + drbd_device_post_work(device, S_ZERO_START); + updated_uuids = 1; + } + + if (zero_out_finish) { + drbd_info(device, "Both side finished zero out devices.\n"); + spin_lock_irq(&device->resource->req_lock); + _drbd_set_state(_NS2(device, disk, D_UP_TO_DATE, pdsk, D_UP_TO_DATE), + CS_VERBOSE, NULL); + spin_unlock_irq(&device->resource->req_lock); + } + put_ldev(device); } else if (device->state.disk < D_INCONSISTENT && device->state.role == R_PRIMARY) { -- 1.8.4.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/