Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEAE0C25B50 for ; Tue, 24 Jan 2023 02:32:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232215AbjAXCb7 (ORCPT ); Mon, 23 Jan 2023 21:31:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229603AbjAXCb6 (ORCPT ); Mon, 23 Jan 2023 21:31:58 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A0F4CA11; Mon, 23 Jan 2023 18:31:52 -0800 (PST) Received: from [0.0.0.0] ([149.28.201.231]) by mail.gmx.net (mrgmx004 [212.227.17.184]) with ESMTPSA (Nemesis) id 1MZktZ-1pDnzm2aGN-00Wiw9; Tue, 24 Jan 2023 03:31:50 +0100 Message-ID: <5be2cd86-e535-a4ae-b989-887bf9c2c36d@gmx.com> Date: Tue, 24 Jan 2023 10:31:47 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Content-Language: en-US To: "linux-block@vger.kernel.org" , Linux FS Devel , "linux-block@vger.kernel.org" From: Qu Wenruo Subject: What would happen if the block device driver/firmware found some block of a bio is corrupted? Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K1:Iyx1PrFreA9p+o88m4Se//lm7GE9UXRQDTqAXCMmTaYxZkdfOyp wCSYUjE0rScYrmB51TQRU3PQRyVNuxyOu7emeHeS2uK765RrI+sEk7RrxIOFlT31zdo1Tiz VkdPCxy+hhXY83fpzHCQ4ONd8BVDs+/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PKK1pZqcsTjBZnKGbWpQb+h+5nY= Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org Hi, I'm wondering what would happen if we submit a read bio containing multiple sectors, while the block disk driver/firmware has internal checksum and found just one sector is corrupted (mismatch with its internal csum)? For example, we submit a read bio sized 16KiB, and the device is in 4K sector size (like most modern HDD/SSD). The corruption happens at the 2nd sector of the 16KiB. My instinct points to either of them: A) Mark the whole 16KiB bio as BLK_STS_IOERR This means even we have 3 good sectors, we have to treat them all as errors. B) Ignore the error mark the bio as BLK_STS_OK This means higher layer must have extra ways to verify the contents. But my concern is, if we go path A), it means after a read bio failure, we should try read again with much smaller block size, until we hit a failure with one sector. IIRC VFS would do some retry, but otherwise the FS/driver layer needs to do some internal work and hit an error, then they need to do the split-and-retry manually. On the other hand path B) seems more straightforward, but the problem is also obvious. Thankfully most fses are already doing checksum for their metadata at least. So what's the common solution in real world for device drivers/firmware? Path A/B or some other solution? And should the upper layer do extra split-and-retry by themselves? I know btrfs scrub code and repair is doing such split-and-retry, but not 100% sure if this is really needed or helpful in real world. Thanks, Qu