Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2129202pxb; Fri, 5 Mar 2021 07:56:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyBfBhyZYMLPlzMnll3MXgikwFsYZFpCH8afTHbSJ3TUpexXKWViHSARhTcOE5P7UBFZYSl X-Received: by 2002:aa7:c804:: with SMTP id a4mr9433415edt.251.1614959800535; Fri, 05 Mar 2021 07:56:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614959800; cv=none; d=google.com; s=arc-20160816; b=CEY1BgtKBzQo5okt7I/kFyBgcnQidoo9I+WRGqPDst0XFKa1wuNPcpoNXYo/5M/2aq PLS6FEXKe8oGQMJiIx0BMIekPBnhmbkflOAAiUFlfisi2cT4LZLKIaOmh+b1X+bO3NQN nhr8ChCQivNc+HI0+Dhq7Uz/Loi7GTnsjutXL404+Uwo9Cdc72+MuLuvb5fwDZDuyyu8 cn8/Gu4gjVHhqSvRFDRi2085homVvtHMFBWOSpUSJgwV9rqL9156qmd7n8NsCByhbTfh RsGYN1Tuo4yEhdJyS54K6R9EBdDVrpzTCNrCVzFALfAeKCQQT6Y+Bsfc6kIrmK0gOCg5 GT7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=SMTXXm3v6m+9Q2KLS4Dhwr7eX8Qndjre0BEx5947iJg=; b=JPQPyI8Sh1LiEUE29u8+GsfMhc3eoDf3/8uFV87Q6RJ6iWG8y22un7MYSwyd2Fruzf 1b55y3Q5ifE6lL00x13YG5GiZsNnCjVZQ5MNvym1ObtyrDhsh0xj12BL1VWV3Ec12Kh0 W3PDw5eNeeJfXpCD0Id+eEt9RawqxEN5oEyzdydaCniOFmJvDGQZob9XLzx2n+2UQ7lC Omf2Bj2KQC4mx7xvGcloR5GXUf4VRW5RuMxkirqsJ6YCd2p2aNnl8nxTkQN5qldQgwvU CbpW0Vj0CMWjsMfSGxkp8YZX5nWe1k8/WyCt2yNsv/xJsCBClpvK0I+WMVN09LIWqiWp n4Yw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k6si1674882edo.113.2021.03.05.07.56.14; Fri, 05 Mar 2021 07:56:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230083AbhCEPzd (ORCPT + 99 others); Fri, 5 Mar 2021 10:55:33 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:36957 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229935AbhCEPzT (ORCPT ); Fri, 5 Mar 2021 10:55:19 -0500 Received: from cwcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 125FtCkw029315 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 5 Mar 2021 10:55:12 -0500 Received: by cwcc.thunk.org (Postfix, from userid 15806) id EC1F815C3A88; Fri, 5 Mar 2021 10:55:11 -0500 (EST) Date: Fri, 5 Mar 2021 10:55:11 -0500 From: "Theodore Ts'o" To: Lukas Czerner Cc: Sedat Dilek , linux-ext4@vger.kernel.org Subject: Re: badblocks from e2fsprogs Message-ID: References: <20210305115957.x4gbppxpzxuvn2kd@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210305115957.x4gbppxpzxuvn2kd@work> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Fri, Mar 05, 2021 at 12:59:57PM +0100, Lukas Czerner wrote: > > Just note that not even the device firmware can't really know whether the > block is good/bad unless it tries to read/write it. In that way I still > find the badblocks useful because it can "force" the device to notice > that there is something wrong and try to fix it (perhaps by remapping > the bad block to spare one). Well, there are various different types of smart tests that you can request via SMART, although most of them don't do a full surface scan on the disk --- simply because on large disks, this can take 24 to 36 hours to read every single sector. Also, an HDD also does do some background reading and re-writing of some blocks, to remediate against adjacent track interference (ATI) and far track interference. In addition, although it's not as bad as with flash, there is actually a slight effect merely *reading* from a track can cause minor disturbances in the force^H^H^H^H^H^H adjacent tracks, and of course, writing to a track can definitely cause a minor weakening of an adjacent track. This is why, when the disk is idle, an HDD will spend some of its time reading and then rewriting tracks that might have been sufficiently weakened by ATI and FTI effects it would be good to refresh those tracks to prevent data loss. Some times, when it reads a block which is marginal, it will get the correct checksum when it retries the read, and in some cases the disk will automatically rewrite the block with the known correct value. In that case, where it's not a matter of the media going bad, but merely the magnetic signal recorded on the media getting weaker, it won't be necessary to remap the block(s). > Of course you could use dd for that, but there are several reasons > why badblocks is still more convenient tool to do that. Note that badblocks does not support more than 16TB disks currently. Part of this is because ext4 doesn't support more than 16TB in its bad blocks inode (which has to use indirect mapped blocks), and part of this is because of the "do you really want to spend 36 hours doing all of these reads"? If someone wants to work on making badblocks support 64-bit block numbers, patches are gratefully accepted, but it's a lot of work, and I've never thought it was worth my personal time.... - Ted P.S. If there are bad blocks, modern disks will automatically remap them when you first write to a block. And if the block already contains data, it won't get remapped until you try writing to the block, in which case you need to decide how to handle the fact that the previous contents of that block might contain file data or metadata block data. So doing something much more sophisticated probably means more work to e2fsck as well in the ideal case. Or just buy high quality HDD's, and do regular backups, or use RAID, or use a cluster file system which uses Reed Solomon Codes or other erasure encodings. :-)