Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754257AbbFJHtl (ORCPT ); Wed, 10 Jun 2015 03:49:41 -0400 Received: from victor.provo.novell.com ([137.65.250.26]:57333 "EHLO prv3-mh.provo.novell.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933543AbbFJHtT (ORCPT ); Wed, 10 Jun 2015 03:49:19 -0400 From: Nick Wang To: philipp.reisner@linbit.com, lars.ellenberg@linbit.com, drbd-dev@lists.linbit.com Cc: linux-kernel@vger.kernel.org, nwang@suse.com Subject: [PATCH 05/10] Start zero out device when drbdadm new-current-uuid --zap-device Date: Wed, 10 Jun 2015 15:48:24 +0800 Message-Id: <1433922509-10280-6-git-send-email-nwang@suse.com> X-Mailer: git-send-email 1.8.4.5 In-Reply-To: <1433922509-10280-1-git-send-email-nwang@suse.com> References: <1433922509-10280-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: 3337 Lines: 95 Two new device flags to represent peer zero out status. Start zero out local device. 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_int.h | 4 ++++ drbd/drbd_nl.c | 33 ++++++++++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/drbd/drbd_int.h b/drbd/drbd_int.h index d43adf2..b49095e 100644 --- a/drbd/drbd_int.h +++ b/drbd/drbd_int.h @@ -623,6 +623,10 @@ enum { RS_START, /* tell worker to start resync/OV */ RS_PROGRESS, /* tell worker that resync made significant progress */ RS_DONE, /* tell worker that resync is done */ + + /* used for zero out device */ + ZERO_DONE, /* succeed on zero out a device */ + ZERO_FAIL, /* fail to zero out a device */ }; struct drbd_bitmap; /* opaque for drbd_device */ diff --git a/drbd/drbd_nl.c b/drbd/drbd_nl.c index 1ef4551..ad499a6 100644 --- a/drbd/drbd_nl.c +++ b/drbd/drbd_nl.c @@ -4001,6 +4001,7 @@ int drbd_adm_new_c_uuid(struct sk_buff *skb, struct genl_info *info) enum drbd_ret_code retcode; int skip_initial_sync = 0; int zero_out_devices = 0; + int zero_out_err = 0; int err; struct new_c_uuid_parms args; @@ -4051,7 +4052,7 @@ int drbd_adm_new_c_uuid(struct sk_buff *skb, struct genl_info *info) drbd_uuid_set(device, UI_BITMAP, 0); /* Rotate UI_BITMAP to History 1, etc... */ drbd_uuid_new_current(device); /* New current, previous to UI_BITMAP */ - if (args.clear_bm) { + if (args.clear_bm || args.zap_devices) { err = drbd_bitmap_io(device, &drbd_bmio_clear_n_write, "clear_n_write from new_c_uuid", BM_LOCKED_MASK); if (err) { @@ -4067,6 +4068,36 @@ int drbd_adm_new_c_uuid(struct sk_buff *skb, struct genl_info *info) CS_VERBOSE, NULL); spin_unlock_irq(&device->resource->req_lock); } + if (zero_out_devices) { + drbd_send_zero_out_start(first_peer_device(device)); + _drbd_uuid_set(device, UI_BITMAP, 0); + drbd_print_uuids(device, "cleared bitmap UUID for zeroing device"); + + /* CLear bit flag of zero out */ + clear_bit(ZERO_DONE, &device->flags); + clear_bit(ZERO_FAIL, &device->flags); + zero_out_err = zero_out_local_device(device); + + if (zero_out_err) { + drbd_err(device, "Failed to zero out local device\n"); + set_bit(ZERO_FAIL, &device->flags); + drbd_chk_io_error(device, 1, DRBD_WRITE_ERROR); + } else { + drbd_info(device, "Finish zero out device\n"); + + if (test_and_clear_bit(ZERO_DONE, &device->flags)) { + 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); + } else if (test_and_clear_bit(ZERO_FAIL, &device->flags)) { + drbd_info(device, "Peer device has already failed on zero out\n"); + } else { + /* waiting for peer device finished */ + set_bit(ZERO_DONE, &device->flags); + } + } + } } drbd_md_sync(device); -- 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/