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=-2.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no 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 3781EC433B4 for ; Thu, 13 May 2021 23:33:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 006B361433 for ; Thu, 13 May 2021 23:33:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229524AbhEMXeR (ORCPT ); Thu, 13 May 2021 19:34:17 -0400 Received: from mout.gmx.net ([212.227.17.21]:35597 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229460AbhEMXeQ (ORCPT ); Thu, 13 May 2021 19:34:16 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1620948783; bh=51v77/pSanp8L3Ikpi8dkPZNkNs+CkI8QdrxaDc5qpw=; h=X-UI-Sender-Class:Subject:To:References:From:Date:In-Reply-To; b=ZXMbJvwcD/uUS1u7cGcXfgsZmwM9mkax38Qd0zEmlmKXFbwqKy1S+6j3Y41nzLURM koLLNoItwVLRGNEZmBOE0Z0XTso3y7MKo2la5EYYAEPDvF7Q2QJS/tCSiaJK0Y8jeA 8BCKLu8HJZ0M/qJT+kAEGH5kAmt8jJhz32HwXUBg= 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 1MxDou-1lJ3mI45ai-00xdvm; Fri, 14 May 2021 01:33:03 +0200 Subject: Re: [Patch v2 01/42] btrfs: scrub: fix subpage scrub repair error caused by hardcoded PAGE_SIZE To: dsterba@suse.cz, Qu Wenruo , linux-btrfs@vger.kernel.org References: <20210427230349.369603-1-wqu@suse.com> <20210427230349.369603-2-wqu@suse.com> <20210513225711.GM7604@twin.jikos.cz> From: Qu Wenruo Message-ID: <8b7af653-62e9-358d-d1a9-c2c6d0e2052d@gmx.com> Date: Fri, 14 May 2021 07:32:59 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210513225711.GM7604@twin.jikos.cz> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:43REuUCCx2zdRg2JTjZrooJRoOgI19mxzIEXaVXV23m34L+n91i Mx1izrlw7VK1L4y+wi9z2bFEZOGfJi8WFwM6k9W+OOxZVpQYNm4RCTrIEtQ3iaJA68QQlu3 q0/HpFlRDsdvuDJAvd1k1gmhrJG2KwiqKN3tGdv1oWuyvxGVSMpC04e/UuQK97JOqRfS4xC HVM+FasPuCtXx4SXwrQZg== X-UI-Out-Filterresults: notjunk:1;V03:K0:qeb0IsILl4M=:ziN5wyTMEuxsb/5w67a4ze A1M9W0ilrbVEJ5QLvKc71lK4Ov+9kbHDR0RGlUyVDDRYB1i+UpRiDgF64qCgf9AORQq7JYxPX 4YyTz/M0s70fyTWepdJfoSsub2ZB+faHfMHg2HAA+C8D9gZVeTgJJYCRDuK0MB/qKngfEHckA u7ifqNWiSk+rS+Rlzn1VNg/EJ4XPgtIgNagU+N17yZbq+E9MSJqifRF5tTamOhskXjob51MwA 9/hEuxbh2d3+XrXG/wUO/8mS0DDMsH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2021/5/14 =E4=B8=8A=E5=8D=886:57, David Sterba wrote: > On Wed, Apr 28, 2021 at 07:03:08AM +0800, Qu Wenruo wrote: >> [BUG] >> For the following file layout, btrfs scrub will not be able to repair >> all these two repairable error, but in fact make one corruption even >> unrepairable: >> >> inode offset 0 4k 8K >> Mirror 1 |XXXXXX| | >> Mirror 2 | |XXXXXX| >> >> [CAUSE] >> The root cause is the hard coded PAGE_SIZE, which makes scrub repair to >> go crazy for subpage. >> >> For above case, when reading the first sector, we use PAGE_SIZE other >> than sectorsize to read, which makes us to read the full range [0, 64K)= . >> In fact, after 8K there may be no data at all, we can just get some >> garbage. >> >> Then when doing the repair, we also writeback a full page from mirror 2= , >> this means, we will also writeback the corrupted data in mirror 2 back >> to mirror 1, leaving the range [4K, 8K) unrepairable. >> >> [FIX] >> This patch will modify the following PAGE_SIZE use with sectorsize: > > Let me take this as an example: the changelog is great and descriptive, > the only thing I often change is an extra newline between the > introductory paragraph ended by ":" and the item list. This is maybe a > personal preference but I find it easier to read. Thanks for pointing out, in fact I'm not sure whether a new inline should be added. Now I have a solid answer and will not longer be stingy to use new lines. Thanks, Qu > >> - scrub_print_warning_inode() >> Remove the min() and replace PAGE_SIZE with sectorsize. >> The min() makes no sense, as csum is done for the full sector with >> padding. >> >> This fixes a bug that subpage report extra length like: >> checksum error at logical 298844160 on dev /dev/mapper/arm_nvme-tes= t, >> physical 575668224, root 5, inode 257, offset 0, length 12288, link= s 1 (path: file) >> >> Where the error is only 1 sector. >> >> - scrub_handle_errored_block() >> Comments with PAGE|page involved, all changed to sector. >> >> - scrub_setup_recheck_block() >> - scrub_repair_page_from_good_copy() >> - scrub_add_page_to_wr_bio() >> - scrub_wr_submit() >> - scrub_add_page_to_rd_bio() >> - scrub_block_complete() >> Replace PAGE_SIZE with sectorsize. >> This solves several problems where we read/write extra range for >> subpage case. > > ... >