From patchwork Mon Jul 1 05:17:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13717556 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA56E22084 for ; Mon, 1 Jul 2024 05:18:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719811088; cv=none; b=ii+9UqGOSYtPL1YxRA0gDAg0BdDalg10x7SJA1G7PtvAK9qmAZGXU7yxybJPq8Xb3Ln4d+dsVG2atc+ZkERFZo7MxHZByO8ck3vvycaadpKwC/iQ3ALIyGHjHe3bZC7Ze4d3wp31NCkPKDHA3MuY3IR4ljzLk0T2UGIqwdGXXzA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719811088; c=relaxed/simple; bh=MT0ZcDryw2IN+GsdJuqwZgr3IrPsv8PFZoN/X/bjEOU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qZxGBBE+Dzpf4H7m2jfyR5xLMMo+gj2tekZMvKwODYggMfityS7edSBtWHj1X/QagnRK+N+C4PgMNPe44uKgPpTS8S4Q41OgPiRG9clfVWHzSL+Yiwu9jKuzZtxnmvSrlNO21ek4Z36fE8sYgP9xD3S2sM0rGlSYgVtOJqgdh9o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=PcB9EvGY; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="PcB9EvGY" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=U0Knn9m9suWr0HwuV6YXzPRah7+Yr1TuKS4G5vkqDZc=; b=PcB9EvGYRRtOu+zh9CDxxcfG1k L6swJ+7Zp0aNHxiRKireoKVAELs6BIb1khu+IYP7SKg10wL+8AE/t1geGFQh4rR76nVqAqd4VwEIK 5VZTziSNICHCdkddBhtaSpvpjTuTAEBK8f9pCQfNiSZf40EZCRhVBXbtZGbQBFAC5UFPup3iCWaoR bUe03pVo/fgjywTY5oBE67QcGiVhyOax9nUm2sys2pn3pI+KkojlkBfJQ9whCBe8zumWweKfV6tYr 5GCAVyb3rVlULejVLcYIO+Tx2iQpBbUEzczpyIxuhtO+Go+8D14yWZa7jfhJoq3Jucfm4UzG3Nj8x uHIaD6Hg==; Received: from 2a02-8389-2341-5b80-ec0f-1986-7d09-2a29.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:ec0f:1986:7d09:2a29] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sO9QS-00000001ivY-3aHR; Mon, 01 Jul 2024 05:18:05 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Keith Busch , Sagi Grimberg , "Martin K . Petersen" , linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Subject: [PATCH 1/3] block: remove a duplicate io_min check in blk_validate_limits Date: Mon, 1 Jul 2024 07:17:50 +0200 Message-ID: <20240701051800.1245240-2-hch@lst.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240701051800.1245240-1-hch@lst.de> References: <20240701051800.1245240-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html If io_min is larger than the cap, it must by definition be non-zero. Signed-off-by: Christoph Hellwig Reviewed-by: Chaitanya Kulkarni Reviewed-by: Sagi Grimberg --- block/blk-settings.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index 2e559cf97cc834..ff8bbc101fedaa 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -279,8 +279,7 @@ static int blk_validate_limits(struct queue_limits *lim) } else if (lim->io_opt) { lim->max_sectors = min(max_hw_sectors, lim->io_opt >> SECTOR_SHIFT); - } else if (lim->io_min && - lim->io_min > (BLK_DEF_MAX_SECTORS_CAP << SECTOR_SHIFT)) { + } else if (lim->io_min > (BLK_DEF_MAX_SECTORS_CAP << SECTOR_SHIFT)) { lim->max_sectors = min(max_hw_sectors, lim->io_min >> SECTOR_SHIFT); } else { From patchwork Mon Jul 1 05:17:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13717557 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86D6E22084 for ; Mon, 1 Jul 2024 05:18:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719811090; cv=none; b=Lj3CFeWFErrPztcPCikkuWBZoXq99TeehkQL83tTaZ8Sm3NhCyOExRhntC9PGe9QsNRZgBXmBShhU3G/Tgn1Sgxa6SDqKkBxg7YWMlaGfpihDCJgRG5RDl7mXzQ28XsxNm6TZGclKx/Lcl9GfYp/b/gdx72+vmc/1K0BNCgstzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719811090; c=relaxed/simple; bh=JWaKP1eF2Rp7cFPg+XpJbJbakaAy6t1BVUdjV4CYq+s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pINK0HRpu1JRU/AMhZKu4hyaVBmc9EaSX/T2wQIBVDuAvayNrrIqxlbVchevXAGScxDeSzuLOPzjHvG5BCdtXfRjgq20fOeBIW097PmLwXtW+e2MTO+ApKwDDSxfd9qnSQDLAuSjbBrVquojxh3LoC3uQ8VicE1RsXzTYWKHjQs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=2U1CdAtI; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="2U1CdAtI" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=lKV4FlE+MDVTwx+RZft9uF3aE5eOzhTGFxSym4mL4q0=; b=2U1CdAtIHw7yYurNR1awM4rwHh MZSlGnX42fTUthSy3aR5c3qVJ1YOb8mjdeSWGubrQbyCCzwUCOqBinSFx1eKXHjW13yFIO3g0jWvo VlB5GJdTNoFatih/CXkKIjbfLyoYxCdYMLXcPwZfF46QLvomvG19gYLElXVOR8PJrJ/If7AsQwW3W L8xyZeWVmLkMhznKh2hjUATpWu8CxsGAB9y3L99hIvi1uAc/6tN/uZilJhWK16/zrQxAaVOHynuoc MZ2xCdhbNp16w/GBFoS45bBcIFqQ8csbfqzGh4dgkjE6ckVk2vGRhIltBbbOONnxBKwiOi+2LiF/z Ud6nqINg==; Received: from 2a02-8389-2341-5b80-ec0f-1986-7d09-2a29.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:ec0f:1986:7d09:2a29] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sO9QV-00000001iwA-2Gnq; Mon, 01 Jul 2024 05:18:08 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Keith Busch , Sagi Grimberg , "Martin K . Petersen" , linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Subject: [PATCH 2/3] block: don't reduce max_sectors based on io_opt Date: Mon, 1 Jul 2024 07:17:51 +0200 Message-ID: <20240701051800.1245240-3-hch@lst.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240701051800.1245240-1-hch@lst.de> References: <20240701051800.1245240-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Don't reduce the max_sectors value below the normal cap when the driver advertsizes a very low io_opt. This restores the behavior we had before the recent changes to the max_sectors calculation. Signed-off-by: Christoph Hellwig Reviewed-by: Chaitanya Kulkarni Reviewed-by: Sagi Grimberg --- block/blk-settings.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/blk-settings.c b/block/blk-settings.c index ff8bbc101fedaa..9fa4eed4df06b0 100644 --- a/block/blk-settings.c +++ b/block/blk-settings.c @@ -276,7 +276,7 @@ static int blk_validate_limits(struct queue_limits *lim) if (lim->max_user_sectors < PAGE_SIZE / SECTOR_SIZE) return -EINVAL; lim->max_sectors = min(max_hw_sectors, lim->max_user_sectors); - } else if (lim->io_opt) { + } else if (lim->io_opt > (BLK_DEF_MAX_SECTORS_CAP << SECTOR_SHIFT)) { lim->max_sectors = min(max_hw_sectors, lim->io_opt >> SECTOR_SHIFT); } else if (lim->io_min > (BLK_DEF_MAX_SECTORS_CAP << SECTOR_SHIFT)) { From patchwork Mon Jul 1 05:17:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 13717558 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B6DE22BB0D for ; Mon, 1 Jul 2024 05:18:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719811093; cv=none; b=cRWAlPJMD7LYPkwqu/uw9PJ3BN6jGefuLi9Kck5TrVO1Ta9F3n42DDDa+ROyhbkodHyyVKntyphSXC+452T8tCx4gJhg4ouc3XH9Rjirfazb1J5p4tOwdp5n7yOPnnyX/slFHCjEblF6P/ioYgEwnYbJHyj2thTOFNspIc/Oldk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719811093; c=relaxed/simple; bh=78oPaiT5fIP5Ap/kwsz966ZjEM9W/5vvGfAO9TqJ4ug=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mrQHUwDqWDF++J5Hcg14v0ca77Luy3W30h8gEXXFHBFeW3bp+6WwTPDJzOcxBqBiNg5+22ClSjLejeUF2XMPM+6sIGWbiUQ/GdpT5siAGVjz4C+x4tW31ZnlT2m1oTJz+wOv15DG6k2pJ6J2Rsn8dsHok0Rm+XM7zzfkn5kPr7s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de; spf=none smtp.mailfrom=bombadil.srs.infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=twbmOjqA; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=lst.de Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=bombadil.srs.infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="twbmOjqA" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description; bh=/CijqbYlkFh+sW64CWr9CSIh+vK9hGYl7zQAQz0uqRY=; b=twbmOjqA62RtPt6aus5e2NwulN 8Q12ESllHNZl0cXAZcLpFuWJ7JjzI9gyDqlWY43GUiuPwPDD1ioPpsr9nqqtriWA43/Yn+SxOou/t 8PQ6edbhXkfJlHD31WlJCit3F+1rpGWvxHpm+BCtTdUiL/tsLX0E/cQlETROr2qrBFz6YfJjuAHAW UIw3+ls5gycaemP94azI00G3us1vR5rJQ345fKVUaRYBVfX6alXuaA2U+5jbBEa//RNc6/Fy1z2u5 tQMjCg6D1BSUC3M0qwaN/Osl8zhNXdVdTYhhfj9NC2EwVnK5fDrB0Q5EZ3aKdM1dk66VMuMZhgTXE LMQiKaaQ==; Received: from 2a02-8389-2341-5b80-ec0f-1986-7d09-2a29.cable.dynamic.v6.surfer.at ([2a02:8389:2341:5b80:ec0f:1986:7d09:2a29] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1sO9QY-00000001iwr-07vB; Mon, 01 Jul 2024 05:18:10 +0000 From: Christoph Hellwig To: Jens Axboe Cc: Keith Busch , Sagi Grimberg , "Martin K . Petersen" , linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Subject: [PATCH 3/3] nvme: don't set io_opt if NOWS is zero Date: Mon, 1 Jul 2024 07:17:52 +0200 Message-ID: <20240701051800.1245240-4-hch@lst.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240701051800.1245240-1-hch@lst.de> References: <20240701051800.1245240-1-hch@lst.de> Precedence: bulk X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html NOWS is one of the annoying "0's based values" in NVMe, where 0 means one and we thus can't detect if it isn't set. Thus a NOWS value of 0 means that the Namespace Optimal Write Size is a single LBA, which is clearly bogus. Ignore the value in that case and don't propagate an io_opt value to the block layer. Signed-off-by: Christoph Hellwig Reviewed-by: Chaitanya Kulkarni Reviewed-by: Sagi Grimberg --- drivers/nvme/host/core.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index ab0429644fe378..6784fc6e95625e 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2025,7 +2025,8 @@ static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id, /* NPWG = Namespace Preferred Write Granularity */ phys_bs = bs * (1 + le16_to_cpu(id->npwg)); /* NOWS = Namespace Optimal Write Size */ - io_opt = bs * (1 + le16_to_cpu(id->nows)); + if (id->nows) + io_opt = bs * (1 + le16_to_cpu(id->nows)); } /*