Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B458CC0650E for ; Sun, 7 Jul 2019 08:52:16 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 832192083B for ; Sun, 7 Jul 2019 08:52:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 832192083B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:34366 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hk2u7-0001fb-RE for qemu-devel@archiver.kernel.org; Sun, 07 Jul 2019 04:52:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45749) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hk2tF-00013b-Qg for qemu-devel@nongnu.org; Sun, 07 Jul 2019 04:51:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hk2tD-00073B-I0 for qemu-devel@nongnu.org; Sun, 07 Jul 2019 04:51:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41100) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hk2t7-0006rR-ID; Sun, 07 Jul 2019 04:51:15 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AE837308FBA6; Sun, 7 Jul 2019 08:51:11 +0000 (UTC) Received: from dhcp-4-67.tlv.redhat.com (dhcp-4-67.tlv.redhat.com [10.35.4.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id C98DC1001947; Sun, 7 Jul 2019 08:51:07 +0000 (UTC) Message-ID: <122c16fd1765879df746d341ffa2b8167dd3d2b2.camel@redhat.com> From: Maxim Levitsky To: Max Reitz , qemu-devel@nongnu.org Date: Sun, 07 Jul 2019 11:51:06 +0300 In-Reply-To: References: <20190703155944.9637-1-mlevitsk@redhat.com> <20190703155944.9637-4-mlevitsk@redhat.com> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Sun, 07 Jul 2019 08:51:11 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: Re: [Qemu-devel] [PATCH v3 3/6] block/nvme: support larger that 512 bytes sector devices X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Paolo Bonzini , John Snow , qemu-block@nongnu.org, Kevin Wolf Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Fri, 2019-07-05 at 13:58 +0200, Max Reitz wrote: > On 03.07.19 17:59, Maxim Levitsky wrote: > > Currently the driver hardcodes the sector size to 512, > > and doesn't check the underlying device. Fix that. > >=20 > > Also fail if underlying nvme device is formatted with metadata > > as this needs special support. > >=20 > > Signed-off-by: Maxim Levitsky > > --- > > block/nvme.c | 45 ++++++++++++++++++++++++++++++++++++++++----- > > 1 file changed, 40 insertions(+), 5 deletions(-) > >=20 > > diff --git a/block/nvme.c b/block/nvme.c > > index 52798081b2..1f0d09349f 100644 > > --- a/block/nvme.c > > +++ b/block/nvme.c >=20 > [...] >=20 > > @@ -463,7 +467,22 @@ static void nvme_identify(BlockDriverState *bs, = int namespace, Error **errp) > > } > > =20 > > s->nsze =3D le64_to_cpu(idns->nsze); > > + lbaf =3D &idns->lbaf[NVME_ID_NS_FLBAS_INDEX(idns->flbas)]; > > + > > + if (lbaf->ms) { > > + error_setg(errp, "Namespaces with metadata are not yet suppo= rted"); > > + goto out; > > + } > > + > > + hwsect_size =3D 1 << lbaf->ds; > > + > > + if (hwsect_size < BDRV_SECTOR_BITS || hwsect_size > s->page_size= ) { >=20 > s/BDRV_SECTOR_BITS/BDRV_SECTOR_SIZE/ Oops. >=20 > > + error_setg(errp, "Namespace has unsupported block size (%d)"= , > > + hwsect_size); > > + goto out; > > + } > > =20 > > + s->blkshift =3D lbaf->ds; > > out: > > qemu_vfio_dma_unmap(s->vfio, resp); > > qemu_vfree(resp); > > @@ -782,8 +801,22 @@ fail: > > static int64_t nvme_getlength(BlockDriverState *bs) > > { > > BDRVNVMeState *s =3D bs->opaque; > > + return s->nsze << s->blkshift; > > +} > > =20 > > - return s->nsze << BDRV_SECTOR_BITS; > > +static int64_t nvme_get_blocksize(BlockDriverState *bs) > > +{ > > + BDRVNVMeState *s =3D bs->opaque; > > + assert(s->blkshift >=3D 9); >=20 > I think BDRV_SECTOR_BITS is more correct here (this is about what the > general block layer code expects). Also, there=E2=80=99s no pain in do= ing so, > as you did check against BDRV_SECTOR_SIZE in nvme_identify(). > Max Of course, thanks!! >=20 > > + return 1 << s->blkshift; > > +} > > + > > +static int nvme_probe_blocksizes(BlockDriverState *bs, BlockSizes *b= sz) > > +{ > > + int64_t blocksize =3D nvme_get_blocksize(bs); > > + bsz->phys =3D blocksize; > > + bsz->log =3D blocksize; > > + return 0; > > } > > =20 > > /* Called with s->dma_map_lock */ >=20 >=20 Thanks for the review, Best regards, Maxim Levitsky