From patchwork Wed Dec 18 02:02:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13912878 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 392D7E77184 for ; Wed, 18 Dec 2024 02:02:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 391EC6B008A; Tue, 17 Dec 2024 21:02:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 312BC6B0085; Tue, 17 Dec 2024 21:02:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1629B6B0089; Tue, 17 Dec 2024 21:02:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EA9966B0083 for ; Tue, 17 Dec 2024 21:02:24 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 75DE6A0B46 for ; Wed, 18 Dec 2024 02:02:24 +0000 (UTC) X-FDA: 82906429914.29.75CD464 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf20.hostedemail.com (Postfix) with ESMTP id BC1811C000C for ; Wed, 18 Dec 2024 02:01:49 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=1Cdajrxu; spf=none (imf20.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1734487328; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=jhZCWpmhBitik/IbLKGzmJ1c/5BHTYghYQVmmbUuo2g=; b=CjZe9ISY7kBu9xB5irvmWEeiD2hZOQDPEOsJVsQuD9XYopdjPlMaglKQ/Ms4i4+1gtlSAK 4EMB6OgGkH+wghXNWU9ZgpuQHfWW/7MaQqIaYhJqz65s/+5GFCyuQrMkokyjKEWHUMmYWy YLT0+D82wMtbS0iL+XGhPVoohU6cF8s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734487328; a=rsa-sha256; cv=none; b=0YXMlERxJEkpnOrVKb5qSnPVkFa306CsXtJaRqnjk/p6teOLr7n6ZhGJk5KR2Ak7RShuRq 4j5Wk/GuOj1nTAHTbCkNwqxVtQSiy58TjeLgzwdZi6BgBrTNLcr4xvGAMOaR7xZPgjKzzF iC7OHstVQXXLmciwoKVVJ2xwMVCLxIc= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=1Cdajrxu; spf=none (imf20.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=jhZCWpmhBitik/IbLKGzmJ1c/5BHTYghYQVmmbUuo2g=; b=1CdajrxuJNxyHpIMNzIBpre/8y QSUHrRIiKEh6adHNpYl+AxDESq0LFLW4ofR/bg6Xt+VDn2AiBExJjTX5tH1OlHs3nnZToCAm+Vyta w23OOl37keMa+LW8hBC1wrNVksggV/DAfhCGEQm10KDpCdBWVAzLABpsZJ8eeiVlZ+gDCKFk7zoJG PKHERu2/5Y3HBK/b2iC2284JbauKJvPPj4KgU7Udc37PckHm/UiMdkMJb7BmGuj204FhN1K/4rUQW wWHTGj0KN+RJ8PgDJtSy7BukbBXrPu0vg0SKOhKU+vhoV5x/SGdfv5JXJV3AdiFbyBrxi1XsK6zNh 4g2xRPQQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tNjO9-0000000FLOJ-1Q9w; Wed, 18 Dec 2024 02:02:13 +0000 From: Luis Chamberlain To: axboe@kernel.dk, hch@lst.de, hare@suse.de, kbusch@kernel.org, sagi@grimberg.me, linux-nvme@lists.infradead.org, willy@infradead.org, dave@stgolabs.net, david@fromorbit.com, djwong@kernel.org Cc: john.g.garry@oracle.com, ritesh.list@gmail.com, linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org, gost.dev@samsung.com, p.raghav@samsung.com, da.gomez@samsung.com, kernel@pankajraghav.com, mcgrof@kernel.org Subject: [PATCH 2/2] nvme: use blk_validate_block_size() for max LBA check Date: Tue, 17 Dec 2024 18:02:12 -0800 Message-ID: <20241218020212.3657139-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241218020212.3657139-1-mcgrof@kernel.org> References: <20241218020212.3657139-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: BC1811C000C X-Stat-Signature: ccehg1tndcf31yrehz7bf9dob8b6xk8u X-Rspam-User: X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1734487309-241886 X-HE-Meta: U2FsdGVkX1/Hgc+Cj5GfocgcFemWg8QYq2FTKqH8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gFabqajiore5RS+rdr39JUGZXFZLwC02Tp2kyZobwncTdD6hNavuy4SOpXvJWL1FQFjmgd+B0vHwrvBzxFzv+GT5d6aAXSsfmgbq3jBvcWXHSufgLahZEzshwNbf6mTQkQ0EaLl+Mnq+dqj2uwAH5SD82FF0Z8ZpOiX1Tea7w0aS7obz33MIEMjY5W9AnoydJJKCblaejUYB89WIzCsKO07WCtMPhRi+4pW5LzXx6bqsQdtrs4MTYED6YR2w9WqaSGu5hsDw9dAoYUg7QcwqJgq3QbQQAxc/+nVp3+lJFxTPxxGpcRG+sENI0OGGicqWpL+LMgX3TCOhXsSKyxLHk7j7pI3KLlUJL5lvnY6CHe472Tv6nc35kM7ZYBE+FKOuEHw2nY0CgE+KUp1p9f1CEg4zzuzsVvcVCWFTP7YNyiJel+0= X-Bogosity: Ham, tests=bogofilter, spamicity=0.003492, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: The block layer already has support to validates proper block sizes with blk_validate_block_size(), we can leverage that as well. No functional changes. Signed-off-by: Luis Chamberlain Reviewed-by: John Garry --- drivers/nvme/host/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index d169a30eb935..a970168a3014 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -2034,7 +2034,7 @@ static bool nvme_update_disk_info(struct nvme_ns *ns, struct nvme_id_ns *id, * or smaller than a sector size yet, so catch this early and don't * allow block I/O. */ - if (head->lba_shift > PAGE_SHIFT || head->lba_shift < SECTOR_SHIFT) { + if (blk_validate_block_size(bs)) { bs = (1 << 9); valid = false; }