From patchwork Tue Jul 21 10:52:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 11675435 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3442F618 for ; Tue, 21 Jul 2020 10:55:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1DB97206E9 for ; Tue, 21 Jul 2020 10:55:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NYVxouLM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728028AbgGUKzZ (ORCPT ); Tue, 21 Jul 2020 06:55:25 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:51689 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726977AbgGUKzY (ORCPT ); Tue, 21 Jul 2020 06:55:24 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1595328922; 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=NYVxouLMNNBXPFO/dzLT2AiCbYlj1Ud7UxeT2HcvzNo2l58IA/rgnyNfXQ3xYa2O0UFPC3 QvP5eW5etk7CFrPqcCr8W4mCe2Cv6ddlkcApUzuIDYS1q2OeGrIuUMlxSenEPYPaY/4IsO 2D6OT0VtH8rS5RmthNuhoB8iNcGUwaU= 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 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org This replaces manual checking in the driver Signed-off-by: Maxim Levitsky Reviewed-by: Damien Le Moal --- 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