Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp620716ybh; Tue, 21 Jul 2020 03:58:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZj2PsfR8ERJVj7fEzbl42rXISNESfhvOoA0QOh3VIRG5CAua5dTo0VzgLk4T5Dv68zmvb X-Received: by 2002:aa7:c816:: with SMTP id a22mr25555533edt.28.1595329111714; Tue, 21 Jul 2020 03:58:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595329111; cv=none; d=google.com; s=arc-20160816; b=NCnyhA9dCcnc3/r6X6LcsBvxkupoCh+vhJOJl2kDqN/nk/ipcn0+Jnl/uNVqkv0RL/ DqxYXondSgXBE4C5SGR9ff7cKi4k3mLIsJbPXVx47a4ZYSRQdzBSg6sZItB5MjGtyb1m Nx8vWNRzRGiyOMqq3QwwmMr7R09P7hPAvV0TgqAZTNhdFM+Yit5+nq5+sGCQC/Xs7PuP A8iiexosrSrY7hig4BfVxQxbTVomFgFZJHfSBheV+uwPc6EebcWOOJtfrRWepPqaRji+ hMthJwxJEzwBB8lUZoKQ+HRinjE/bMwJqZLWVUk12rwX7XxadShsvCmpZaLmKo69oGBX T6Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SJjcpKw0ZA3kjqBFD5ZKn58x1VX76xeTbrTHk9kDWMo=; b=AYXzannMtrml67o/spysO9kahDVlQh70a3ZR2aWlihTbaZteGw76DXWvN0udGY9n4H /NcOuFGzkFVFFBt0AhhHJV1WPpaOSFbGgyjqDst0FwenlAUZyPrKIU0ij1g6XL9cjv7u zAxNj+yX0nv3MZj/dy/GAN98GWzUMF0BtAjrDNamitW2uYbFO8AsMcM/ecVhpK/V2dCq UxZZHnissE3Yn1TTAPrdNkFbr44C5PKpfVv0nN2sHl1nniEja5lPCMAslyyxfYIV4Lha N1WXnIOVk7BE3gGtNUZ8ME2QMCm0CjO5BdgpB2mEFmMD7sHI+H/ZUb8lQZwtQcWa/s0X cKow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=GVBh5eoW; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ss20si12129202ejb.700.2020.07.21.03.58.09; Tue, 21 Jul 2020 03:58:31 -0700 (PDT) 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=@redhat.com header.s=mimecast20190719 header.b=GVBh5eoW; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729459AbgGUKzW (ORCPT + 99 others); Tue, 21 Jul 2020 06:55:22 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:33582 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726977AbgGUKzV (ORCPT ); Tue, 21 Jul 2020 06:55:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595328920; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SJjcpKw0ZA3kjqBFD5ZKn58x1VX76xeTbrTHk9kDWMo=; b=GVBh5eoWWTyRsccK902MlQ2TX9xI1an+5KES22KnruMk4snydYoiQ6mvoM29+peYSLkcaW vqA78HF/D2ri+RX8cIpO6uuKegQg1dYtxR1sGrl2YtMlK6zxI/xT+FcP8nmNgRUyjwhxOL mGOD8ea8vm7tRA2Ju8pvDY+aWbG2vis= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-133-ev4DS7OXNkerwJINJoEjIA-1; Tue, 21 Jul 2020 06:55:18 -0400 X-MC-Unique: ev4DS7OXNkerwJINJoEjIA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AE4E98015FB; Tue, 21 Jul 2020 10:55:15 +0000 (UTC) Received: from localhost.localdomain (unknown [10.35.206.163]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5CF461C4; Tue, 21 Jul 2020 10:55:00 +0000 (UTC) From: Maxim Levitsky To: linux-kernel@vger.kernel.org Cc: Keith Busch , Josef Bacik , linux-block@vger.kernel.org (open list:BLOCK LAYER), Sagi Grimberg , Jens Axboe , linux-nvme@lists.infradead.org (open list:NVM EXPRESS DRIVER), linux-scsi@vger.kernel.org (open list:SCSI CDROM DRIVER), Tejun Heo , Bart Van Assche , "Martin K. Petersen" , Damien Le Moal , Jason Wang , Maxim Levitsky , Stefan Hajnoczi , Colin Ian King , "Michael S. Tsirkin" , Paolo Bonzini , Ulf Hansson , Ajay Joshi , Ming Lei , linux-mmc@vger.kernel.org (open list:SONY MEMORYSTICK SUBSYSTEM), Christoph Hellwig , Satya Tangirala , nbd@other.debian.org (open list:NETWORK BLOCK DEVICE (NBD)), Hou Tao , Jens Axboe , virtualization@lists.linux-foundation.org (open list:VIRTIO CORE AND NET DRIVERS), "James E.J. Bottomley" , Alex Dubov , Maxim Levitsky Subject: [PATCH 08/10] block: nvme: use blk_is_valid_logical_block_size Date: Tue, 21 Jul 2020 13:52:37 +0300 Message-Id: <20200721105239.8270-9-mlevitsk@redhat.com> In-Reply-To: <20200721105239.8270-1-mlevitsk@redhat.com> References: <20200721105239.8270-1-mlevitsk@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This replaces manual checking in the driver Signed-off-by: Maxim Levitsky --- drivers/nvme/host/core.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index add040168e67e..8014b3046992a 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -1849,10 +1849,16 @@ static void nvme_update_disk_info(struct gendisk *disk, unsigned short bs = 1 << ns->lba_shift; u32 atomic_bs, phys_bs, io_opt = 0; - if (ns->lba_shift > PAGE_SHIFT) { - /* unsupported block size, set capacity to 0 later */ + /* + * The block layer can't support LBA sizes larger than the page size + * yet, so catch this early and don't allow block I/O. + */ + + if (!blk_is_valid_logical_block_size(bs)) { bs = (1 << 9); + capacity = 0; } + blk_mq_freeze_queue(disk->queue); blk_integrity_unregister(disk); @@ -1887,13 +1893,6 @@ static void nvme_update_disk_info(struct gendisk *disk, blk_queue_io_min(disk->queue, phys_bs); blk_queue_io_opt(disk->queue, io_opt); - /* - * The block layer can't support LBA sizes larger than the page size - * yet, so catch this early and don't allow block I/O. - */ - if (ns->lba_shift > PAGE_SHIFT) - capacity = 0; - /* * Register a metadata profile for PI, or the plain non-integrity NVMe * metadata masquerading as Type 0 if supported, otherwise reject block -- 2.26.2