From owner-svn-src-head@freebsd.org Tue May 3 00:09:14 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 80C0EB2B1B6; Tue, 3 May 2016 00:09:14 +0000 (UTC) (envelope-from peter@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4E2551435; Tue, 3 May 2016 00:09:14 +0000 (UTC) (envelope-from peter@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4309DlX097647; Tue, 3 May 2016 00:09:13 GMT (envelope-from peter@FreeBSD.org) Received: (from peter@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4309Dea097646; Tue, 3 May 2016 00:09:13 GMT (envelope-from peter@FreeBSD.org) Message-Id: <201605030009.u4309Dea097646@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: peter set sender to peter@FreeBSD.org using -f From: Peter Wemm Date: Tue, 3 May 2016 00:09:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r298949 - head/sys/boot/i386/zfsboot X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 May 2016 00:09:14 -0000 Author: peter Date: Tue May 3 00:09:13 2016 New Revision: 298949 URL: https://svnweb.freebsd.org/changeset/base/298949 Log: Change a rounding operation that had missing braces into a roundup2() macro. Adjust the buffer clipping code to work as expected. This prevented a number of machines in the FreeBSD.org cluster from booting due to "ZFS: i/o error - all block copies unavailable" after an unclean shutdown. Modified: head/sys/boot/i386/zfsboot/zfsboot.c Modified: head/sys/boot/i386/zfsboot/zfsboot.c ============================================================================== --- head/sys/boot/i386/zfsboot/zfsboot.c Mon May 2 22:58:11 2016 (r298948) +++ head/sys/boot/i386/zfsboot/zfsboot.c Tue May 3 00:09:13 2016 (r298949) @@ -224,21 +224,18 @@ vdev_read(vdev_t *vdev, void *priv, off_ while (bytes > 0) { nb = bytes / DEV_BSIZE; - if (nb > READ_BUF_SIZE / DEV_BSIZE) - nb = READ_BUF_SIZE / DEV_BSIZE; /* * Ensure that the read size plus the leading offset does not * exceed the size of the read buffer. */ - if (nb * DEV_BSIZE + diff > READ_BUF_SIZE) - nb -= diff / DEV_BSIZE; + if (nb > (READ_BUF_SIZE - diff) / DEV_BSIZE) + nb = (READ_BUF_SIZE - diff) / DEV_BSIZE; /* * Round the number of blocks to read up to the nearest multiple * of DEV_GELIBOOT_BSIZE. */ - alignnb = nb + (diff / DEV_BSIZE) + - (DEV_GELIBOOT_BSIZE / DEV_BSIZE - 1) & ~ - (unsigned int)(DEV_GELIBOOT_BSIZE / DEV_BSIZE - 1); + alignnb = roundup2(nb * DEV_BSIZE + diff, DEV_GELIBOOT_BSIZE) + / DEV_BSIZE; if (drvread(dsk, dmadat->rdbuf, alignlba, alignnb)) return -1;