Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp4991pxb; Wed, 13 Jan 2021 21:19:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEBZ6+3BaPul+seZ0Norm9uL9Z3ySvmIvOjvwMCs7M59A03Ah+3Wr684doqPkXXuLb4n0h X-Received: by 2002:a17:906:415a:: with SMTP id l26mr4038730ejk.463.1610601596390; Wed, 13 Jan 2021 21:19:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610601596; cv=none; d=google.com; s=arc-20160816; b=ZSaGJzjEZTmoKL3OIjNnL++bNr94RQfEbCDu+ZfXx7D12KrN45y3l3L7qMO6OBArPZ /u1u7zHlNJnR5SL1ssinwcia4Y5yAtNcUQGlMo19N4RldLSAIQjz53yVNNPiWPZh+Vzv ZKOmKR43xahjjHl6fJPiInHc5nC4nbGF0ik3tCH2RughR1NWIP+8QKcnCTnBlHt54Fas Zxh5BOaXfnkl2l0ydRA1sUUMB45zzJiVb5bREtox8JuhVhuHZu26S6nfLRIFf7fb+dIH MfZlL7PcaYQYxc8C7v1G5D+cx0vpGWKJplUElxtXfuZrMVU6mtTbeow6rj9Ffpkago21 nkpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=oCahD8foTVoddxYHsMYM6DUY8gEUtNSocwAU/pMxRNk=; b=PRFZr1+QypxkoHs2yp5dYH9RM6zu4khrjjYL0Hl8VcckdtMioKfAG6ihEWwjgWe3Ri k1e59fnRrpFUhbjQKrL56cIPKk9aPd2AmKKivt6jIMRbWDf0XEVV4HvNQ/PIQzbnhUL5 5vwaW6SZlGfQvKT2eGKbIVj50foFXbmW0v0ddS3rLmELvqmWx4KsHXxQ0L9ItqSoAH4h VVGsYACVkfgieEIwt+d1fS0zRccGbWej0Vga8grbhx1ypOc7XvTsmLpOM3RZaxxit/0u N0GWWFricTSI6y08wCi5mniVtbggH7WjqRDmp2k7VrW/BMKhqbqwzvECqmdwVqE1JA7d W90w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZOeUZm0T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dh5si2145422edb.122.2021.01.13.21.19.30; Wed, 13 Jan 2021 21:19:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZOeUZm0T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726055AbhANFSJ (ORCPT + 99 others); Thu, 14 Jan 2021 00:18:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725825AbhANFSI (ORCPT ); Thu, 14 Jan 2021 00:18:08 -0500 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2822C061794 for ; Wed, 13 Jan 2021 21:17:28 -0800 (PST) Received: by mail-pf1-x42a.google.com with SMTP id q20so2676383pfu.8 for ; Wed, 13 Jan 2021 21:17:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=oCahD8foTVoddxYHsMYM6DUY8gEUtNSocwAU/pMxRNk=; b=ZOeUZm0TD3YyWm4LhewhwjQFxVnPSXbygDaAWHJ3TPVTHS+J7MaGrTmK/FUY2trwCG fF8rrxCErQQrr3WqE2ClGAvCPAKwZqdB0IUE9Y4DdZ7cwntwhLWycL3J1uMDTDDOahS6 HCxUtIJu7SxBppTbt0XrV6k7FhAofK7EblBeTe0Uc9nI75SD8JuG4aNieP6h83ZwysAU JqxYewSU5fOMtkjJeJifNxCpYJHPehNFs4UWbyKWuompazLaHwV1Xe8vTRxffxCuZN6a 3aE749DB0A/nOk6/5glbIGnnbCV8oGqMTGeBxKKXJ9/3C6WQdQloMCVSZzJtNw2OtUMH D2CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=oCahD8foTVoddxYHsMYM6DUY8gEUtNSocwAU/pMxRNk=; b=uK5YvQHU/t1NAnYusI5kNm6Rb3gf54xRMpK9uVpEQrJiVtA1p5jfYbXEumwOFm/6ZI x9QBdqnyrTGXxbn7WoGVHYZcOcCx3pCu+DFAYEEqZGY9CHu9mfEMjn31Fpt4PJd+5a3W ibxT0ZJThtKTJ6GI5qpuoOiykADazxu01LTyKfkIPsB5hITqFW0L13lrjzGRb9x61McA o0LEMDe19Z71YqiZnmQEVFceJGyjwILbOUgSvkEZoIJz4MkBFDRsJXudSpJhZNESjOmh PijXb9z90eq9HrhZN7yR5kxpgKpkRXFnQeD5HMkDVJNMFpSPLv9FFq0ZeC/NBzRPacMM MR1Q== X-Gm-Message-State: AOAM533pYsDZnq+9LYO44f+/MFvYILLRyTSqXXS0bE6xr/vERyLAKIra Ut463QFqphxHoe58kpKF24Xk8pnUyO+VMowo9/buhjl7xEh93iNe X-Received: by 2002:a62:1b14:0:b029:19d:fa85:9f73 with SMTP id b20-20020a621b140000b029019dfa859f73mr5608155pfb.25.1610601448212; Wed, 13 Jan 2021 21:17:28 -0800 (PST) MIME-Version: 1.0 References: <20210113160621.98615-1-fengli@smartx.com> <87698545-de26-c0ca-01e9-4dc2ddcacc80@grimberg.me> In-Reply-To: <87698545-de26-c0ca-01e9-4dc2ddcacc80@grimberg.me> From: Feng Li Date: Thu, 14 Jan 2021 13:17:03 +0800 Message-ID: Subject: Re: [PATCH] nvme: reject the ns when the block size is smaller than a sector To: Sagi Grimberg Cc: Johannes Thumshirn , Li Feng , "martin.petersen@oracle.com" , Keith Busch , Jens Axboe , Christoph Hellwig , "open list:NVM EXPRESS DRIVER" , open list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sagi Grimberg =E4=BA=8E2021=E5=B9=B41=E6=9C=8814=E6=97= =A5=E5=91=A8=E5=9B=9B =E4=B8=8A=E5=8D=886:13=E5=86=99=E9=81=93=EF=BC=9A > > > >> The nvme spec(1.4a, figure 248) says: > >> "A value smaller than 9 (i.e., 512 bytes) is not supported." > >> > >> Signed-off-by: Li Feng > >> --- > >> drivers/nvme/host/core.c | 6 ++++++ > >> 1 file changed, 6 insertions(+) > >> > >> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c > >> index f320273fc672..1f02e6e49a05 100644 > >> --- a/drivers/nvme/host/core.c > >> +++ b/drivers/nvme/host/core.c > >> @@ -2161,6 +2161,12 @@ static int nvme_update_ns_info(struct nvme_ns *= ns, struct nvme_id_ns *id) > >> > >> blk_mq_freeze_queue(ns->disk->queue); > >> ns->lba_shift =3D id->lbaf[lbaf].ds; > >> + if (ns->lba_shift < 9) { > >> + pr_warn("%s: bad lba_shift(%d)\n", ns->disk->disk_name, n= s->lba_shift); > >> + ret =3D -1; > > Meaningful errno would be useful. Also better to use dev_warn > > >> + goto out_unfreeze; > >> + } > >> + > >> nvme_set_queue_limits(ns->ctrl, ns->queue); > >> > >> if (ns->head->ids.csi =3D=3D NVME_CSI_ZNS) { > >> > > > > > > But this only catches a physical block size < 512 for NVMe, not any oth= er block device. > > > > Please fix it for the general case in blk_queue_physical_block_size(). > > We actually call that later and would probably be better to check here.. Thanks for your comments. The prototype is: void blk_queue_logical_block_size(struct request_queue *, unsigned int); So change it to: bool blk_queue_logical_block_size(struct request_queue *, unsigned int); And check all callers of this function, right?