Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1674969rwb; Thu, 29 Sep 2022 00:07:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6pSqL9xiE/GSDxDEDStaU+D6SoJK1gj8EHwIhL34PyTecYcV2QFzR17n4A9NitJ55/9X3q X-Received: by 2002:a17:906:da86:b0:77a:52b3:da48 with SMTP id xh6-20020a170906da8600b0077a52b3da48mr1438713ejb.373.1664435259862; Thu, 29 Sep 2022 00:07:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664435259; cv=none; d=google.com; s=arc-20160816; b=Bpv6B4mafX3AkWbOowsySVKIDNkHr4YmJZzvh8Yur30KBig6oBH/wbg8Poh4kTeigO kEX5KVd3BOxmT6opITv4GEH1bxjOnQYjIZ6zWpIWnt78tbPhSpAQjkWsh+tg1J7P4pEf gGzYa6KDnviDUf3dZMSO5Ojh3Glz0ff70zhZrQHcTES3A4ThR2BX+gu5BNWO8nxPm36h 2nM3Q+x9ELULSTu4qp9KTKi9WB4N1Qm642FvqcxDl/eDSKgVdTwT9RKnWi6jR6Z7ouCn FzpkPlYSvTun2J9H56G6E497rTJpoD5CJ9MwdBwY4cibcGbrYG5VyPZz6jXFx0pLhQ82 hblQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :from:references:cc:to:content-language:user-agent:mime-version:date :message-id:dkim-signature; bh=jZ4Es70CWGnrWN0ux3j699Z/wTDLGdzuRh80/FQR1s8=; b=gCDTYAwML0jtYQwO8+sDVP0149Sjdz8DbBTV5xa79aLqmg63kgDNDdA67LmYLlt4Nk LO/yFrp/NvXJURxQI5/QjRuoHOZBKkprwAKgw6Zgm03bVYZAlCKGbtbSoac5h7wwlqjS 8qbSrH9SX9fUfkkMM6CuhbiXAh8FLBNXh3Z65G3puVS3ncN6s8dohx+YyEWn7obm7QTP /deKe/gl0/tdBi6ZR7MD32+QeFBPByp7nEypl9U5rFT8a/eCjjDOsKIGbTinwRV8/gy4 enhFghIGLaPHZFisDB55JdJDQhmwV96ubK5lF0NLQQX+O6EizZ1YRPmXe/ry8Br2O6GH LcUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=GVIQ+Nf+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hh8-20020a170906a94800b007307c26f6ddsi6364767ejb.995.2022.09.29.00.07.12; Thu, 29 Sep 2022 00:07:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.net header.s=badeba3b8450 header.b=GVIQ+Nf+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235012AbiI2HAi (ORCPT + 99 others); Thu, 29 Sep 2022 03:00:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53180 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234981AbiI2HAZ (ORCPT ); Thu, 29 Sep 2022 03:00:25 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DBA375004D; Thu, 29 Sep 2022 00:00:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1664434809; bh=MQ9u1VHs47gY1n/Q8/lklOVfT3g0V7cat9t+os+xW7I=; h=X-UI-Sender-Class:Date:To:Cc:References:From:Subject:In-Reply-To; b=GVIQ+Nf+MXRA1QpT73T2bJEi7ax4QNq868FRyWNxf8yn3QY7kyMUKzJ7X+lUQzWDG ubIaeZDuYY7pmAX9uqph1kKqz6jT0nPO5DZqSU+rFQzJ41egofK7ZwIwQUTW9V+jrs MQliQSNoyXz7a3dlUxYs5eHyvHmv0LH2YqfJsVm4= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from [0.0.0.0] ([149.28.201.231]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1Mt757-1pWb8T1Cdl-00tXk2; Thu, 29 Sep 2022 09:00:08 +0200 Message-ID: <8f1adbef-7146-c8f9-92a3-c18e10e9a66b@gmx.com> Date: Thu, 29 Sep 2022 15:00:03 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Content-Language: en-US To: hmsjwzb , Qu Wenruo Cc: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org References: <20220929014402.2450-1-hmsjwzb@zoho.com> <18acd4e0-9d3d-77a7-a1de-b805bc259bcf@suse.com> From: Qu Wenruo Subject: Re: [PATCH] btrfs:remove redundant index_rbio_pages in raid56_rmw_stripe In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:CHXCsP7YN5FnKLr10iu9q7KXMbq1mpofYPqNlfRw5P9j1jvZit0 cnfjJPpnvrzpxMGRDTk4Juv4oWI75OGJSTJgjb9a1N8iABQF1Ht3xHOxKM/EBwqrqHe8N6a G2YECi1zAzLtUsHX+tzX8J5GYYLtlP7qgap9AFrgvAXltDvshOVZc0bftfPc/xEnE8hoAtT M1M3m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arsAZCb/EluRKkS/klz q+qBgBa4BDX2BTq6U93DqWZ95ax+3ErUAbb9R3PHE4sm9stsozWELJcpw2ip/nxKXV1y3VOMp UVglT5ygrLe9YaHwflI01Z2lfs//JtfdK7IbK6zUepgnY8pyzguRbw6b966PeqwIf4R4xmPYP drvfA68orrW7v3WI//Hzca85qg X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/9/29 14:41, hmsjwzb wrote: > Hi Qu, > > Thanks for your reply. > Here is my plan about destructive RMW. The overall idea is fine, but some details need to be addressed. > > 1. Read all the stripes in through raid56_rmw_stripe. Note that, even we reached raid56_rmw_stripe(), we may still be a full stripe write (due to substripe writes merged into one full stripe). In that case, we should not waste IO to read any stripe. That's what your patch lacks. (Also all the comments should be updated since you changed the behavior) > 2. Do xor operation in finish_rmw. You may want to do the verification/recovery all before finish_rmw(). The function finish_rmw() is currently the last step of RMW. > 3. If the xor result matches, nothing happened. > 4. If the xor result mismatches, we can recover the data or trigger som= e user space progress to fix the data corruption. For now just focus on the recover part, no need to bother user space. > > But here are some problems. > 1. If the stripe is new allocated, the check will fail. For now we should focus on data recovery only (metadata will be much more complex), and for data we will need to grab checksum for the full stripe anyway. So in newly allocated case, there will be no checksum, thus no need to really do any recovery, we just trust all data which doesn't has no checksum. > 2. Is it convient for kernel get checksum in finish_rmw and recover dat= a? If not convenient, you'll need to be creative to grab the checksum. But from what I see, if you pre-fetch the checksum for the full stripe at raid56_parity_write() timing, it should be fine. Thanks, Qu > > Thanks, > Flint > > On 9/28/22 23:13, Qu Wenruo wrote: >> >> >> On 2022/9/29 11:08, Qu Wenruo wrote: >>> >>> >>> On 2022/9/29 09:44, Flint.Wang wrote: >>>> =C2=A0=C2=A0 The index_rbio_pages in raid56_rmw_stripe is redundant. >>> >>> index_rbio_pages() is to populate the rbio->bio_sectors array. >>> >>> In raid56_rmw_stripe() we later calls sector_in_rbio(), which will che= ck if a sector is belonging to bio_lists. >>> >>> If not called, all sector will be returned using the sectors in rbio->= bio_sectors, not using the sectors in bio lists. >>> >>> Have you tried your patch with fstests runs? >> >> Well, for raid56_rmw_stripe() it's fine, as without the index_rbio_page= s() call, we just read all the sectors from the disk. >> >> This would include the new pages from bio lists. >> >> It would only cause extra IO, but since they can all be merged into one= 64K stripe, it should not cause performance problem. >> >> Furthermore it would read all old sectors from disk, allowing us later = to do the verification before doing the writes. >> >> But it should really contain a more detailed explanation. >> >> Thanks, >> Qu >>> >>> IMHO it should fail a lot of very basic writes in RAID56. >>> >>> Thanks, >>> Qu >>> >>>> =C2=A0=C2=A0 It is invoked in finish_rmw anyway. >>>> >>>> Signed-off-by: Flint.Wang >>>> --- >>>> =C2=A0 fs/btrfs/raid56.c | 2 -- >>>> =C2=A0 1 file changed, 2 deletions(-) >>>> >>>> diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c >>>> index f6395e8288d69..44266b2c5b86e 100644 >>>> --- a/fs/btrfs/raid56.c >>>> +++ b/fs/btrfs/raid56.c >>>> @@ -1546,8 +1546,6 @@ static int raid56_rmw_stripe(struct btrfs_raid_= bio *rbio) >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ret) >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 goto cleanup; >>>> -=C2=A0=C2=A0=C2=A0 index_rbio_pages(rbio); >>>> - >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 atomic_set(&rbio->error, 0); >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /* Build a list of bios to read all t= he missing data sectors. */ >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 for (total_sector_nr =3D 0; total_sec= tor_nr < nr_data_sectors;