From patchwork Wed Dec 4 14:06:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nikos Tsironis X-Patchwork-Id: 11272983 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ABAD7109A for ; Wed, 4 Dec 2019 14:07:20 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4F8B2206DF for ; Wed, 4 Dec 2019 14:07:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="N6T2eGTt" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F8B2206DF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arrikto.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dm-devel-bounces@redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575468439; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=JS2hYsD6HPLacBfTpFGE+QlRJLASP36aSGfBZz9GE3Y=; b=N6T2eGTtVtfLe3NaThZsug0R9Q1d9i4LrpplPmP49KR5db7v96h5JrpHiXWroFTKyEuqw9 CdZdUNHHoOhWa/J/Fww4MhHUcTmkOZRNWRH3el+MbqNQFuHYJPnhNWCJRrAbjkFvEHxtMD x1CIFFj+39JfIj2Itr79rpH3hY02fvQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-75-CrHFAURZOSKQZOZ5UCX6wg-1; Wed, 04 Dec 2019 09:07:17 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7001C8C2865; Wed, 4 Dec 2019 14:07:12 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8A2D75D9C5; Wed, 4 Dec 2019 14:07:11 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 090B65BC11; Wed, 4 Dec 2019 14:07:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xB4E76fn006851 for ; Wed, 4 Dec 2019 09:07:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id B9BD711793C; Wed, 4 Dec 2019 14:07:06 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B4E43117916 for ; Wed, 4 Dec 2019 14:07:04 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2EC87185B0B2 for ; Wed, 4 Dec 2019 14:07:04 +0000 (UTC) Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-36-a4r3RkZYMDu5KZnZ34NCFw-1; Wed, 04 Dec 2019 09:07:02 -0500 Received: by mail-lf1-f49.google.com with SMTP id q6so6224362lfb.6 for ; Wed, 04 Dec 2019 06:07:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=VyLHeWo1IVwTXJlMm1IiZ3/MNI4cr1AOGINJlNr2F4M=; b=C8HnQA3mbZu+xOMyI7N65HVl0t4eVyVYKqpTUepfOSdlJaP3D6TOxTwqHwvNpD/3+j 7BIjlX+TwIA5rpH7d0Tvge8xuiHGu/rcX9uGm+FVYZyG7BBy/BBRUffPtdihsYtzeDwm 8YJDh0cFufNDcD8cvnyWx5/741dl7+RzmMcPB/fE8nTBW6uK3ETbmAkeCF/W5NxANQ3Y AihFT5NN1cxIGhF1Cl1BlPjhzq+8AvzIOHRvE+ZRI2Dnh0pcytsj/2ur8/2ES83WJ8WQ Jx+jwUFJHNSbNjo3hsZL3WTVwZvxrAA/Fp1mM60bcg8bWjUPxiECh4Uzlq9Rm+fk4ImM FuVg== X-Gm-Message-State: APjAAAW0unXplHyClXkFoSkK3F8DjRUwoZvZQfNrz9GJ5cT7sp3j1FkQ 40SP3ENlPxNR2hxOmfMNrVTQVw== X-Google-Smtp-Source: APXvYqzGjQgnnu5UKXBh4Do+aHwtQfYrLXUF6UO7++fEKvz5GpmWoho5VpXWVw1N34/FRSsLIgphsA== X-Received: by 2002:ac2:4436:: with SMTP id w22mr2184207lfl.185.1575468420399; Wed, 04 Dec 2019 06:07:00 -0800 (PST) Received: from snf-864.vm.snf.arr ([31.177.62.212]) by smtp.gmail.com with ESMTPSA id i19sm3335533ljj.24.2019.12.04.06.06.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Dec 2019 06:06:59 -0800 (PST) From: Nikos Tsironis To: snitzer@redhat.com, agk@redhat.com, dm-devel@redhat.com Date: Wed, 4 Dec 2019 16:06:51 +0200 Message-Id: <20191204140654.26214-1-ntsironis@arrikto.com> X-MC-Unique: a4r3RkZYMDu5KZnZ34NCFw-1 X-MC-Unique: CrHFAURZOSKQZOZ5UCX6wg-1 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-MIME-Autoconverted: from quoted-printable to 8bit by lists01.pubmisc.prod.ext.phx2.redhat.com id xB4E76fn006851 X-loop: dm-devel@redhat.com Cc: vkoukis@arrikto.com, ntsironis@arrikto.com, iliastsi@arrikto.com Subject: [dm-devel] [PATCH 0/3] dm clone: Flush destination device before committing metadata to avoid data corruption X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Mimecast-Spam-Score: 0 dm-clone maintains an on-disk bitmap which records which regions are valid in the destination device, i.e., which regions have already been hydrated, or have been written to directly, via user I/O. Setting a bit in the on-disk bitmap meas the corresponding region is valid in the destination device and we redirect all I/O regarding it to the destination device. Suppose the destination device has a volatile write-back cache and the following sequence of events occur: 1. A region gets hydrated, either through the background hydration or because it was written to directly, via user I/O. 2. The commit timeout expires and we commit the metadata, marking that region as valid in the destination device. 3. The system crashes and the destination device's cache has not been flushed, meaning the region's data are lost. The next time we read that region we read it from the destination device, since the metadata have been successfully committed, but the data are lost due to the crash, so we read garbage instead of the old data. For more information regarding the implications of this please see the relevant commit. To solve this and avoid the potential data corruption we have to flush the destination device before committing the metadata. This ensures that any freshly hydrated regions, for which we commit the metadata, are properly written to non-volatile storage and won't be lost in case of a crash. Nikos Tsironis (3): dm clone metadata: Track exact changes per transaction dm clone metadata: Use a two phase commit dm clone: Flush destination device before committing metadata drivers/md/dm-clone-metadata.c | 136 ++++++++++++++++++++++++++++++----------- drivers/md/dm-clone-metadata.h | 17 ++++++ drivers/md/dm-clone-target.c | 53 +++++++++++++--- 3 files changed, 162 insertions(+), 44 deletions(-)