From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.3 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EACDC2D0CD for ; Tue, 17 Dec 2019 21:05:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3AE0821775 for ; Tue, 17 Dec 2019 21:05:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=toxicpanda-com.20150623.gappssmtp.com header.i=@toxicpanda-com.20150623.gappssmtp.com header.b="kqhButns" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728093AbfLQVF3 (ORCPT ); Tue, 17 Dec 2019 16:05:29 -0500 Received: from mail-qv1-f67.google.com ([209.85.219.67]:44676 "EHLO mail-qv1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726996AbfLQVF2 (ORCPT ); Tue, 17 Dec 2019 16:05:28 -0500 Received: by mail-qv1-f67.google.com with SMTP id n8so4761640qvg.11 for ; Tue, 17 Dec 2019 13:05:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=B/nIEgqm7OioL/7wEl1hDXcP2AhFeFFGi64i4A0ew7U=; b=kqhButns8pFTbsXxUKCTNp0O+N6EM28deKyUq1j7ML/wFB01sL8uwbAmo/9ezWudd9 b1eGwLa0JEcAw3b8Dxn7ln8WJiUhSU5zUC/EWIP+JxWgCfFFmdgmnEWta84nd9bZHhcP PhYN3XROnmkVc4Qz/nWMt/a45o7euRkH4CNNlgqwgBRxTgcxGmuHTubEj1z2uySLwWfj mR8ThebdwiqJmgG6NLNZdlDMu6II++y5v35mFe61oGp0jRobX5aPVwNWwMBdVzu1hIMT R5VuJvV4c7CDJm8ebDjGaOugtvXSn0c1FwOyunvDg56SHqRcuGN9AtMXluTQj345RMga snOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=B/nIEgqm7OioL/7wEl1hDXcP2AhFeFFGi64i4A0ew7U=; b=bljyZx8i72Wc5j7Ljezk5whHaaKWieo5RhC9yO0/r/1Q+ZYKI7JBJEHeNSxIr9yv1u KWGwe4tch5F2ttTLJ722Y5iTUD/UxPpt4OmBYSqlbbJhoIftt6YlJG6qch0T08s9HfFQ oaah2YRyayKdeBFi1StUNQBNTJJM9dhALu6UixyeQZnOCFgEYKe+hlgOe6Z7m+vf69A9 3bdVh79+knwFxcWqRGCDlADLSdftv0YkOfZAPJ0VTw8EsQ32rlwjuI99/Ea+G1GKgCy6 sHVFaFoRrIg5amFJF2ae03lwuoJORg9t0cMgJ3ZDWlSyQ2CWzFCFsPSdMqnTaqHAUyDU 9r0A== X-Gm-Message-State: APjAAAWIlrBiQMMdZsWJ18Ozd2YXmcRSvRRmbupQS+yA9+BCLXyMVDbZ kBhfClanYCizf8v4LVKuFGZxtjmsdp1C+A== X-Google-Smtp-Source: APXvYqw7J4Jh50cAaJ5d2+biAeS3jjGlBUAWwJDfqPYiJOEHT37bBuk1dYEU4Dkn1ajY/ZS54Xtp3Q== X-Received: by 2002:a05:6214:11a8:: with SMTP id u8mr6722944qvv.16.1576616727537; Tue, 17 Dec 2019 13:05:27 -0800 (PST) Received: from ?IPv6:2620:10d:c0a8:1102:ce0:3629:8daa:1271? ([2620:10d:c091:480::4217]) by smtp.gmail.com with ESMTPSA id k29sm11395qtu.54.2019.12.17.13.05.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 17 Dec 2019 13:05:26 -0800 (PST) Subject: Re: [PATCH v6 23/28] btrfs: support dev-replace in HMZONED mode To: Naohiro Aota , linux-btrfs@vger.kernel.org, David Sterba Cc: Chris Mason , Nikolay Borisov , Damien Le Moal , Johannes Thumshirn , Hannes Reinecke , Anand Jain , linux-fsdevel@vger.kernel.org References: <20191213040915.3502922-1-naohiro.aota@wdc.com> <20191213040915.3502922-24-naohiro.aota@wdc.com> From: Josef Bacik Message-ID: <2157b1bb-a64b-eed3-0451-09a8480d0db2@toxicpanda.com> Date: Tue, 17 Dec 2019 16:05:25 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.3.0 MIME-Version: 1.0 In-Reply-To: <20191213040915.3502922-24-naohiro.aota@wdc.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On 12/12/19 11:09 PM, Naohiro Aota wrote: > We have two type of I/Os during the device-replace process. One is a I/O to > "copy" (by the scrub functions) all the device extents on the source device > to the destination device. The other one is a I/O to "clone" (by > handle_ops_on_dev_replace()) new incoming write I/Os from users to the > source device into the target device. > > Cloning incoming I/Os can break the sequential write rule in the target > device. When write is mapped in the middle of a block group, that I/O is > directed in the middle of a zone of target device, which breaks the > sequential write rule. > > However, the cloning function cannot be simply disabled since incoming I/Os > targeting already copied device extents must be cloned so that the I/O is > executed on the target device. > > We cannot use dev_replace->cursor_{left,right} to determine whether bio is > going to not yet copied region. Since we have time gap between finishing > btrfs_scrub_dev() and rewriting the mapping tree in > btrfs_dev_replace_finishing(), we can have newly allocated device extent > which is never cloned nor copied. > > So the point is to copy only already existing device extents. This patch > introduces mark_block_group_to_copy() to mark existing block group as a > target of copying. Then, handle_ops_on_dev_replace() and dev-replace can > check the flag to do their job. > > Device-replace process in HMZONED mode must copy or clone all the extents > in the source device exctly once. So, we need to use to ensure allocations > started just before the dev-replace process to have their corresponding > extent information in the B-trees. finish_extent_writes_for_hmzoned() > implements that functionality, which basically is the removed code in the > commit 042528f8d840 ("Btrfs: fix block group remaining RO forever after > error during device replace"). > > This patch also handles empty region between used extents. Since > dev-replace is smart to copy only used extents on source device, we have to > fill the gap to honor the sequential write rule in the target device. > > Signed-off-by: Naohiro Aota Can you split up the copying part and the cloning part into different patches, this is a bear to review. Also I don't quite understand the zeroout behavior. It _looks_ like for cloning you are doing a zeroout for the gap between the last wp position and the current cloned bio, which makes sense, but doesn't this gap exist because copying is ongoing? Can you copy into a zero'ed out position? Or am I missing something here? Thanks, Josef