From patchwork Sat Dec 14 03:10:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 13908276 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 48E2BE77183 for ; Sat, 14 Dec 2024 03:11:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 709676B0099; Fri, 13 Dec 2024 22:11:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 61E8C6B009E; Fri, 13 Dec 2024 22:11:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41CD96B0095; Fri, 13 Dec 2024 22:11:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 090266B0092 for ; Fri, 13 Dec 2024 22:11:02 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id AE8351A14AD for ; Sat, 14 Dec 2024 03:11:01 +0000 (UTC) X-FDA: 82892086704.19.12ED45C Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf08.hostedemail.com (Postfix) with ESMTP id EC329160009 for ; Sat, 14 Dec 2024 03:10:41 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=qL6vJdTy; spf=none (imf08.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=1734145842; 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=nLfCbW88XZtUGGKLjWBTHyDCe42vAPNXKRBtJR7DxnY=; b=mrIS6++Ar6Ude0wEmFP5BbF/uExXJoWqOdRFvV8EOvLCSDfNWFDcVy+AkhOirXDjg2l8aw Dl7NQS1eHItUoTDi74ilw+BzZE/w5xGa9rDHnp3w07C102OI3kFjlFMdSilzMIdT2Sww+j caNjuSkkMTjebNI5PzAZ6Dksjp8TFUo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1734145842; a=rsa-sha256; cv=none; b=pykjFh182UJy4dLujQEQPZJ9OLqwxua8wH4FPB2HqKWIOKieA7zEchZRZroBZq5HMtH7md R++P2lPx92CH8gGza+qtUn1oKBBJiPx0CI6RQ4W7CkjaoX2kS7oQDyQGQTM3DxVJrsdS/q rYTPREKfvWrIKFrtq8uct/+drbJeCqE= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=qL6vJdTy; spf=none (imf08.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=nLfCbW88XZtUGGKLjWBTHyDCe42vAPNXKRBtJR7DxnY=; b=qL6vJdTyzDGrY9BTzxUAOzoxWR GmyxjXs/ypIzQ4OBwJwjxzVHxTYl5WowwA8PlpzdvxsYCfAWKCxVKGzklNbFg+j9lyRrusBf2H2bo GLkVMnOTVZV/lpZd85GFZ1MVi81ANkvcUeR+JJE+WC+Wr3Z0gWG3fCONYfibpZ6l3jyduDgskVKBw zGXlDz4JQevtASwNKCWNnNAOsApI5OkuvhXNNNIaNtVIY0GOanrmRiewmyM4XTWoW+VYaF9Ch6GO/ jAb+ekAcuFvILM50r3oh8PDu2OVvOax56B8d0fV1YdR3Auj0Fd26/gnSmPf68M1AcX68Sws/msj8r Mx/t0qRA==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98 #2 (Red Hat Linux)) id 1tMIYO-00000005c3p-05r5; Sat, 14 Dec 2024 03:10:52 +0000 From: Luis Chamberlain To: willy@infradead.org, hch@lst.de, hare@suse.de, dave@stgolabs.net, 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 v2 09/11] block/bdev: lift block size restrictions and use common definition Date: Fri, 13 Dec 2024 19:10:47 -0800 Message-ID: <20241214031050.1337920-10-mcgrof@kernel.org> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241214031050.1337920-1-mcgrof@kernel.org> References: <20241214031050.1337920-1-mcgrof@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: EC329160009 X-Stat-Signature: af355pqz5f7t7f77o1ibkimz4hqt3px3 X-Rspamd-Pre-Result: action=add header; module=dmarc; Action set by DMARC X-Rspam: Yes X-HE-Tag: 1734145841-888339 X-HE-Meta: U2FsdGVkX1+t0neoIkcS/5LW6XpWe+xjdAzQ6joHAOT7d29d76sFvn13uB6l7qojXy4m3o/9aRKmSVKMrUzUb4ZGgNqav7/orTpwh3lhxl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+1U2kT4iDlzTd6Q6dGpeyuPjJYFlxIIzyIWLnTiYaecvgxC/fRxbmCnmjKOcEVu7pzx5JBpDRdpvWlK49+1klW3je8e93qvwluERld1lBEbDCgJekIl/8RFkOfvX7IQCKi4VaBYj1rhEnjv4Z9BPpZzg/OlY9uG0nVx8ut5CDLXqnIrx4H0QGxzyj2HSnIhS8ALdgPL015F0DiG+UlCa7EQpnwqOwyWwvPlLc+eUhubdUt6dc/nifm4Mjo+PfPvpJKcFqaTxoXlGu/lHqdC1WQLJAICS0uh54FR5ELQGuvnhJEPa72UtBZSLVUnrqxi/8isA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000002, 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 as a sensible limit. The hard limit, however is 1 << (PAGE_SHIFT + MAX_PAGECACHE_ORDER). Signed-off-by: Luis Chamberlain Reviewed-by: Hannes Reinecke Reviewed-by: John Garry --- block/bdev.c | 5 ++--- include/linux/blkdev.h | 11 ++++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/block/bdev.c b/block/bdev.c index 167d82b46781..b57dc4bff81b 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 its 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 08a727b40816..a7303a55ed2a 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -269,10 +269,19 @@ static inline dev_t disk_devt(struct gendisk *disk) return MKDEV(disk->major, disk->first_minor); } +#ifdef CONFIG_TRANSPARENT_HUGEPAGE +/* + * The hard limit is (1 << (PAGE_SHIFT + MAX_PAGECACHE_ORDER). + */ +#define BLK_MAX_BLOCK_SIZE (SZ_64K) +#else +#define BLK_MAX_BLOCK_SIZE (PAGE_SIZE) +#endif + /* 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;