From patchwork Wed Dec 18 02:02:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13912880 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 161D1E77184 for ; Wed, 18 Dec 2024 02:02:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8172B6B0083; Tue, 17 Dec 2024 21:02:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 66D346B0088; 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 3852C6B0083; Tue, 17 Dec 2024 21:02:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E9C8F6B0082 for ; Tue, 17 Dec 2024 21:02:24 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 710F01A091D for ; Wed, 18 Dec 2024 02:02:24 +0000 (UTC) X-FDA: 82906428738.03.46D108F Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf25.hostedemail.com (Postfix) with ESMTP id DEAC0A0009 for ; Wed, 18 Dec 2024 02:01:59 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=ARm2XXrf; spf=none (imf25.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=1734487308; 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=WCOIziiQc3yXhNuboxlTSddFpns8L7WWTqCYfZybbD0=; b=adlby89iD8dKWMEMriJNWWwGQKxmX1AzaZcqdpwdBVPAzMsDWvVaQ+L5k/lC1o4aHIgmWn I16ZZU8qaa3ANf+db49GQTNiEuiAY+HhtvJmm9M+MhEKrmUGZ4jwhNF31x2VdK8s82i3DW d1GK9CxYfZDuE4XgM3n9/Twak3UF76o= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734487308; a=rsa-sha256; cv=none; b=2aW5ahr5tvVejDgWAqQbhWpc2BibjY9rXNULruYy/bZdJsSmY8T1mweGvVmyGUhpy9Kv2L KNEQbesZfUZsV4scBYQVKd5QuT9WfjM6Jowmau1RUxvg4UVaYKViUNHIzISjtUmuasm1Ph K694ZX5c4/Ll1DN81aZLjW8D3Gacs5w= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=ARm2XXrf; spf=none (imf25.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=WCOIziiQc3yXhNuboxlTSddFpns8L7WWTqCYfZybbD0=; b=ARm2XXrfPngFRZVJvDGkyfwEt0 LmQCWyMcRxVuhEoAIPM+OXXOFDvt+ACslBENjP3KCFzVur5eYWReWCPj3h467YpcV4mtzCBPAyFHm Gv4kxJdCrLJMMZD3mA/hr1gL/l1o2LDorwVGVfit4yBfdtNVmPyoL2Dhful4neUgJWRbJSnx/z78P O7uOS6+Iwr4Adb9Cz7d+mYv7zZICWc4DsfBVQG0XBL8NhFT3vTalixvi3YiSQRgQqE0FQstM5se5g cCf2adVGPLWAMagHdDEQ8CKmsF38gGHpaQkUR6l+9ZdaspazJRRbr4Af281BjjVh0ik5tPize8Kv6 8uVYBdZQ==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tNjO9-0000000FLOH-1IBp; 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 1/2] block/bdev: use helper for max block size check Date: Tue, 17 Dec 2024 18:02:11 -0800 Message-ID: <20241218020212.3657139-2-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-Queue-Id: DEAC0A0009 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: cu3gnaicy83ggjq17r9rsny6nuju3hrb X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1734487319-763515 X-HE-Meta: U2FsdGVkX1+lL8xOO+k/4o2QtQG7AVIB7D0Uglzrz98gLyWikoJXJrY3KwFdERJH+iODTCv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lbeas/RnS4g+KIOli5POXZLAz38pX5uKRO6BIuQy7kgm8R0gOHSM8IM0LHH+UbMFZTEUDOayvR7hVYPQpO19wcYE6AID3DzUXk+yE7e+WbYbfnSNEm470g1R0B3fvqy4EmdgUVMelcn1Fi1A63mVIjiUAS/Pl92Zmdd6xSYl7AYkOFXc09GZYUWAZBuMlM8gNxSpzSWfHMeGTd+ZY9FcpsehkqnFzmopItGXUf+lRZfLMAOrkq7qlRTOW8QuxWKqk5VVhQAk3Htdzb0SO1vLCEdWqUC6J+ZNL0+E/BSnmOQOFb9dk+ufHHyR90VZo6KV/YwgfhQVeSMhqdbx9MMjQmJBmGy+gf1kbm/H7W+PoRYp+/rLLQYBtkJfxQQc= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000886, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We already have a helper for checking the limits on the block size both low and high, just use that. No functional changes. Reviewed-by: John Garry Signed-off-by: Luis Chamberlain --- block/bdev.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index 738e3c8457e7..9d73a8fbf7f9 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -155,8 +155,7 @@ int set_blocksize(struct file *file, int size) struct inode *inode = file->f_mapping->host; struct block_device *bdev = I_BDEV(inode); - /* Size must be a power of two, and between 512 and PAGE_SIZE */ - if (size > PAGE_SIZE || size < 512 || !is_power_of_2(size)) + if (blk_validate_block_size(size)) return -EINVAL; /* Size cannot be smaller than the size supported by the device */