From patchwork Wed Nov 13 09:47:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13895572 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 C815FE7716C for ; Thu, 5 Dec 2024 15:28:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4EDC06B00B7; Thu, 5 Dec 2024 10:19:27 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D350C6B0124; Thu, 5 Dec 2024 10:19:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 704866B00BB; Thu, 5 Dec 2024 10:19:12 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C6ACA6B00C3 for ; Wed, 13 Nov 2024 04:47:36 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7F4DE140986 for ; Wed, 13 Nov 2024 09:47:36 +0000 (UTC) X-FDA: 82780592874.06.86A4464 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf07.hostedemail.com (Postfix) with ESMTP id 4424A40018 for ; Wed, 13 Nov 2024 09:46:34 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=nnsxL9il; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=none (imf07.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1731491167; 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=SXlfkrrZjaYgmSwcVorAtVLJKuW9IZECB9TbzjdaaSk=; b=DEw3edBo0MrkD5xPhEZcX3b0PWT+I+NcA8xyvuWrLURsZACi2IIqILUsE0Cb1Gi5fRmwfx B0BWq2H42+ypS7qyy1OA8I4e4pB5NHmxknB5SPWvWYrPtvutNAYP+ZMkjAdGsNIFueZZap beMeMLqg9XYQKEHqv2BqNZVZx6rV9Ss= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=nnsxL9il; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=kernel.org (policy=quarantine); spf=none (imf07.hostedemail.com: domain of mcgrof@infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=mcgrof@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1731491167; a=rsa-sha256; cv=none; b=GXrh0UIcJtRZHXnZnN0Cz2eMor3cJAreiISJGnWBADphbr3ASKABgoLVj0DE8ZvH3rM9D6 njraFIAR/8AnQgA72ZxKyfJMZshLsLWwul1Weex439G+P3NFube9njKjaWadywjxd4qHmX 0D/1qJ1eUayxjWPlepsfJGtdHJ6bTAs= 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=SXlfkrrZjaYgmSwcVorAtVLJKuW9IZECB9TbzjdaaSk=; b=nnsxL9ilFCNXXb8XhHktNx4MtI eueIODYT+h0QJCHVLB/jX6H7i8oYtPkebZmAJMrKGkCXeLfajcxwviwkIyd9FN/O6mcx+ei3jsMGL lLYSwGU07XuWI+g3iLP7d3UgjI/GLqQO5FhGaTKXyBny+WsdZmcUANr/lu9+td6m7vbxgo+er/c71 m1qm8UVQjWYDifOi1BPw8cxpnWRkEGhaQ/6hn7WDAMT7LXbczwkuLlVFnKOGtIEPK/HkTXT1SJtR4 Ln6zqu8vEI41CkdlDsnYzuTIs5RCI+Dvxy9LXbDxbN7izHu9D2k5p6f4GjegeLd5QXtVzuf05p6JJ 4GE6mnkw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tB9yD-00000006HdK-1w0j; Wed, 13 Nov 2024 09:47:29 +0000 From: Luis Chamberlain To: willy@infradead.org, hch@lst.de, hare@suse.de, david@fromorbit.com, djwong@kernel.org Cc: john.g.garry@oracle.com, ritesh.list@gmail.com, kbusch@kernel.org, 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: [RFC 6/8] block/bdev: lift block size restrictions and use common definition Date: Wed, 13 Nov 2024 01:47:25 -0800 Message-ID: <20241113094727.1497722-7-mcgrof@kernel.org> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241113094727.1497722-1-mcgrof@kernel.org> References: <20241113094727.1497722-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 4424A40018 X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Stat-Signature: pjofen7g94wqi33xzzkh1o531qtyb6py X-Rspam: Yes X-HE-Tag: 1731491194-144060 X-HE-Meta: U2FsdGVkX1+gc6FPslRY0zKfGm8EGePzEnsGp/br1hN+fpt2Gs1cH7rWz5HWRcKIfnjHL1WslneyT/Up9WP9VawLbSGXzDk38C9J2epD4Q6DBmzoijfU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ouOjM933HKnGWQK75fZElffgIgAsMH0sQy+7exEq1oUgDorsHtpKJeJH04fGrEH2LY9WCA3B7hIWcP2Hvrco+7ZXThC1X+S9kOSuTPw5SN1FGHCC2VWTbLsazmTLGotAeZO3+/ezcCs0o0FO24noUXSiC2BHYWZesGRYm2Q091Eg0V8bzBhpUZfHpTEdg4snhGi/K4MeLtENp2w8yFv1xBRWz7kLMwJoimvJ8J3mYvGp2PMepijRW9Tj6onfNB4LoRyo8NNYGbFfaScHi2j5jE5t2BClLDq6Lp7v2g6q/q3I1dQCmEUaw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, 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 now can support blocksizes larger than PAGE_SIZE, so lift the restriction up to the max supported page cache order and just bake this into a common helper used by the block layer. We bound ourselves to 64k, because beyond that we need more testing. Signed-off-by: Luis Chamberlain --- block/bdev.c | 5 ++--- include/linux/blkdev.h | 6 +++++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index 167d82b46781..3a5fd65f6c8e 100644 --- a/block/bdev.c +++ b/block/bdev.c @@ -157,8 +157,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 */ @@ -185,7 +184,7 @@ int sb_set_blocksize(struct super_block *sb, int size) if (set_blocksize(sb->s_bdev_file, size)) return 0; /* If we get here, we know size is power of two - * and it's value is between 512 and PAGE_SIZE */ + * and it's value is larger than 512 */ sb->s_blocksize = size; sb->s_blocksize_bits = blksize_bits(size); return sb->s_blocksize; diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 50c3b959da28..cc9fca1fceaa 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -25,6 +25,7 @@ #include #include #include +#include struct module; struct request_queue; @@ -268,10 +269,13 @@ static inline dev_t disk_devt(struct gendisk *disk) return MKDEV(disk->major, disk->first_minor); } +/* We should strive for 1 << (PAGE_SHIFT + MAX_PAGECACHE_ORDER) */ +#define BLK_MAX_BLOCK_SIZE (SZ_64K) + /* blk_validate_limits() validates bsize, so drivers don't usually need to */ static inline int blk_validate_block_size(unsigned long bsize) { - if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize)) + if (bsize < 512 || bsize > BLK_MAX_BLOCK_SIZE || !is_power_of_2(bsize)) return -EINVAL; return 0;