Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752431AbbGMIlF (ORCPT ); Mon, 13 Jul 2015 04:41:05 -0400 Received: from victor.provo.novell.com ([137.65.250.26]:60439 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751908AbbGMIjy (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 08/10] drbd: Function to work with packet P_ZERO_OUT Date: Mon, 13 Jul 2015 16:39:02 +0800 Message-Id: <1436776744-3135-9-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: 2469 Lines: 74 Using packet P_ZERO_OUT to update zero out status of peer node. 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 | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drbd/drbd_receiver.c b/drbd/drbd_receiver.c index 5e6b149..6eae84f 100644 --- a/drbd/drbd_receiver.c +++ b/drbd/drbd_receiver.c @@ -4383,6 +4383,41 @@ static union drbd_state convert_state(union drbd_state ps) return ms; } +static int receive_zero_out_state(struct drbd_connection *connection, struct packet_info *pi) +{ + struct drbd_peer_device *peer_device; + struct drbd_device *device; + struct p_state *p = pi->data; + unsigned int isfail; + + peer_device = conn_peer_device(connection, pi->vnr); + if (!peer_device) + return -EIO; + device = peer_device->device; + + isfail = be32_to_cpu(p->state); + + if (isfail) { + drbd_info(device, "Failed to zero out peer device\n"); + set_bit(ZERO_FAIL, &device->flags); + } else { + drbd_info(device, "Finished zero out peer device\n"); + if (test_and_clear_bit(ZERO_DONE, &device->flags)) { + drbd_info(device, "Both side finished zeroing.\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); + drbd_send_zero_out_finish(peer_device); + } else { + /* waiting for local device finished */ + set_bit(ZERO_DONE, &device->flags); + } + } + + return 0; +} + static int receive_req_state(struct drbd_connection *connection, struct packet_info *pi) { struct drbd_peer_device *peer_device; @@ -5008,6 +5043,7 @@ static struct data_cmd drbd_cmd_handler[] = { [P_CONN_ST_CHG_REQ] = { 0, sizeof(struct p_req_state), receive_req_conn_state }, [P_PROTOCOL_UPDATE] = { 1, sizeof(struct p_protocol), receive_protocol }, [P_TRIM] = { 0, sizeof(struct p_trim), receive_Data }, + [P_ZERO_OUT] = { 0, sizeof(struct p_state), receive_zero_out_state }, }; static void drbdd(struct drbd_connection *connection) -- 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/