From owner-dev-commits-src-all@freebsd.org Tue Jan 26 19:47:21 2021 Return-Path: Delivered-To: dev-commits-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 45C224FE157; Tue, 26 Jan 2021 19:47:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4DQHLx1T3fz3snN; Tue, 26 Jan 2021 19:47:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 25571783F; Tue, 26 Jan 2021 19:47:21 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 10QJlLi4071101; Tue, 26 Jan 2021 19:47:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 10QJlLTF071100; Tue, 26 Jan 2021 19:47:21 GMT (envelope-from git) Date: Tue, 26 Jan 2021 19:47:21 GMT Message-Id: <202101261947.10QJlLTF071100@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kirk McKusick Subject: git: 8c22cf9b0997 - main - Fix fsck_ffs incorrectly reporting "CANNOT READ BLK: NNNN" errors. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: mckusick X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 8c22cf9b0997566ff6f576cfc9296b29bb055f65 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 26 Jan 2021 19:47:21 -0000 The branch main has been updated by mckusick: URL: https://cgit.FreeBSD.org/src/commit/?id=8c22cf9b0997566ff6f576cfc9296b29bb055f65 commit 8c22cf9b0997566ff6f576cfc9296b29bb055f65 Author: Kirk McKusick AuthorDate: 2021-01-26 19:46:38 +0000 Commit: Kirk McKusick CommitDate: 2021-01-26 19:46:38 +0000 Fix fsck_ffs incorrectly reporting "CANNOT READ BLK: NNNN" errors. A long-standing bug in Pass 1 of fsck_ffs in which it is reading in blocks of inodes to check their block pointers. It failed to round up the size of the read to a disk block size. When disks would accept 512-byte aligned reads, the bug rarely manifested itself. But many recent disks will no longer accept 512-byte aligned reads but require 4096-byte aligned reads, so the failure to properly round-up read sizes to multiples of 4096 bytes makes the error much more likely to occur. Reported by: Peter Holm and others Tested by: Peter Holm and Rozhuk Ivan MFC after: 3 days Sponsored by: Netflix --- sbin/fsck_ffs/inode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sbin/fsck_ffs/inode.c b/sbin/fsck_ffs/inode.c index 18a015f8187e..60019425c825 100644 --- a/sbin/fsck_ffs/inode.c +++ b/sbin/fsck_ffs/inode.c @@ -611,8 +611,9 @@ setinodebuf(int cg, ino_t inosused) sizeof(struct ufs1_dinode) : sizeof(struct ufs2_dinode)); readpercg = inosused / fullcnt; partialcnt = inosused % fullcnt; - partialsize = partialcnt * ((sblock.fs_magic == FS_UFS1_MAGIC) ? - sizeof(struct ufs1_dinode) : sizeof(struct ufs2_dinode)); + partialsize = fragroundup(&sblock, + partialcnt * ((sblock.fs_magic == FS_UFS1_MAGIC) ? + sizeof(struct ufs1_dinode) : sizeof(struct ufs2_dinode))); if (partialcnt != 0) { readpercg++; } else {