From owner-svn-src-head@freebsd.org Tue Mar 29 20:05:56 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 C65D0AE2AC1; Tue, 29 Mar 2016 20:05:56 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from citapm.icyb.net.ua (citapm.icyb.net.ua [212.40.38.140]) by mx1.freebsd.org (Postfix) with ESMTP id 0F83C1F47; Tue, 29 Mar 2016 20:05:54 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from porto.starpoint.kiev.ua (porto-e.starpoint.kiev.ua [212.40.38.100]) by citapm.icyb.net.ua (8.8.8p3/ICyb-2.3exp) with ESMTP id XAA15375; Tue, 29 Mar 2016 23:05:52 +0300 (EEST) (envelope-from avg@FreeBSD.org) Received: from localhost ([127.0.0.1]) by porto.starpoint.kiev.ua with esmtp (Exim 4.34 (FreeBSD)) id 1akztg-0005Im-P7; Tue, 29 Mar 2016 23:05:52 +0300 Subject: Re: svn commit: r297396 - head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs To: Alexander Motin , src-committers@FreeBSD.org, svn-src-all@FreeBSD.org, svn-src-head@FreeBSD.org References: <201603291918.u2TJIYRp024552@repo.freebsd.org> From: Andriy Gapon Message-ID: <56FADFE8.6040203@FreeBSD.org> Date: Tue, 29 Mar 2016 23:04:56 +0300 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: <201603291918.u2TJIYRp024552@repo.freebsd.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.21 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, 29 Mar 2016 20:05:56 -0000 On 29/03/2016 22:18, Alexander Motin wrote: > Author: mav > Date: Tue Mar 29 19:18:34 2016 > New Revision: 297396 > URL: https://svnweb.freebsd.org/changeset/base/297396 > > Log: > Modify "4958 zdb trips assert on pools with ashift >= 0xe". > > Unlike Illumos FreeBSD has concept of logical ashift, that specifies > really minimal vdev block size that can be accessed. This knowledge > allows properly pad physical I/O and correctly assert its alignment. > > This change fixes L2ARC write errors when device has logical sector > size above 512 bytes. > > MFC after: 1 month > > Modified: > head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c > > Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c > ============================================================================== > --- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c Tue Mar 29 19:11:04 2016 (r297395) > +++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zio.c Tue Mar 29 19:18:34 2016 (r297396) > @@ -2775,10 +2775,19 @@ zio_vdev_io_start(zio_t *zio) > (void) atomic_cas_64(&spa->spa_last_io, old, new); > } > > +#ifdef illumos > align = 1ULL << vd->vdev_top->vdev_ashift; > > if (!(zio->io_flags & ZIO_FLAG_PHYSICAL) && > P2PHASE(zio->io_size, align) != 0) { > +#else > + if (zio->io_flags & ZIO_FLAG_PHYSICAL) > + align = 1ULL << vd->vdev_top->vdev_logical_ashift; Alexander, I believe that this is wrong. We must not modify any parameters of a physical zio including its size. Otherwise we are going to overwrite something that an originator of the I/O did not intend to overwrite. Here we should have a check (or just the assertion) that the zio conforms to disk characteristics. It's the code that creates physical zio-s that should be made aware of the alignment requirements. Please see my work in this direction: https://reviews.freebsd.org/D2789 (BTW, I added you as a reviewer there). > + else > + align = 1ULL << vd->vdev_top->vdev_ashift; > + > + if (P2PHASE(zio->io_size, align) != 0) { > +#endif > /* Transform logical writes to be a full physical block size. */ > uint64_t asize = P2ROUNDUP(zio->io_size, align); > char *abuf = NULL; > @@ -2794,6 +2803,7 @@ zio_vdev_io_start(zio_t *zio) > zio_subblock); > } > > +#ifdef illumos > /* > * If this is not a physical io, make sure that it is properly aligned > * before proceeding. > @@ -2809,6 +2819,10 @@ zio_vdev_io_start(zio_t *zio) > ASSERT0(P2PHASE(zio->io_offset, SPA_MINBLOCKSIZE)); > ASSERT0(P2PHASE(zio->io_size, SPA_MINBLOCKSIZE)); > } > +#else > + ASSERT0(P2PHASE(zio->io_offset, align)); > + ASSERT0(P2PHASE(zio->io_size, align)); > +#endif > > VERIFY(zio->io_type == ZIO_TYPE_READ || spa_writeable(spa)); > > -- Andriy Gapon