From patchwork Fri Jul 26 11:59:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13742709 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 E6B80C3DA7F for ; Fri, 26 Jul 2024 12:00:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B42D6B00B9; Fri, 26 Jul 2024 08:00:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 763236B00BA; Fri, 26 Jul 2024 08:00:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B5656B00BB; Fri, 26 Jul 2024 08:00:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 39CF56B00B9 for ; Fri, 26 Jul 2024 08:00:57 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id C4C7E8181C for ; Fri, 26 Jul 2024 12:00:56 +0000 (UTC) X-FDA: 82381762512.01.7775A0A Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by imf20.hostedemail.com (Postfix) with ESMTP id D58051C002E for ; Fri, 26 Jul 2024 12:00:54 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=WhYRX2zo; spf=pass (imf20.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1721995216; h=from:from: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=F5f9Z6yQ2HFDvQ0pXyKnZ1CF8pk601QiTcma43W9nDA=; b=mQMXU5ZoU6WM8s/tN1Ir1zfdO6ZfOsqX3X7SW2N12HyCOAX+f4+N13iGbePM7jWsTCm1r7 U2I/+jEYgIFXPBAJpWe3Ap5eUHE4EV6Uz3xxG3ONhKM+HuOGvDFuKzVn1aizcKujmGgEH6 XNu+zqZCsqXcslhp01YdsxgVBH7ttXs= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=WhYRX2zo; spf=pass (imf20.hostedemail.com: domain of kernel@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=kernel@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1721995216; a=rsa-sha256; cv=none; b=uPpazZo/BjHnN/dCVKTuopqm2ctcQry5IvJ26/f9EO0KEz3/uDQk+Dr7TlgfVTf3oe589M FklZVRSpOJ95bjjrrGYedtGv8Vq/GH1n+Bk7YB8mt1Zv4PBOAxKgRpF4baxi7iQ4H+o+y6 gIgPQ25VQ6OfD2GTvAoVRzlWBoNG+xw= Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4WVmYH3fHRz9tCK; Fri, 26 Jul 2024 14:00:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1721995251; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F5f9Z6yQ2HFDvQ0pXyKnZ1CF8pk601QiTcma43W9nDA=; b=WhYRX2zoWCyU64ct7fWgdmTh0apq/E/Lo9f4nPIwy1jVr1lBXETBOP9sCtAyvGXLYY64Kf ACFyhbhl58Pq/6UVIJUEUMxXpZOaxv2wxOOOQJBt0wjTLAccoVhwQBdBsAPOlqxrkW1F4B OKmo+ew6Nbny60i6utNWuB8Wy/rj1DZg6+kNImhyghxzGAscWxe9ZxcYh2lFTNDSu+Pos6 lTphduaqav0l2aMCgBJe7ubQ5wiv1VTqkOeIg2c+WYTYF4oF5G/C1DESw7UkFVJoO3ak8H 54roaIrREc2n52i6R/5gl84b4437MmrABkWiUEonTikoaixiAkTo2AXmyKbGWQ== From: "Pankaj Raghav (Samsung)" To: david@fromorbit.com, willy@infradead.org, chandan.babu@oracle.com, djwong@kernel.org, brauner@kernel.org, akpm@linux-foundation.org Cc: yang@os.amperecomputing.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org, john.g.garry@oracle.com, linux-fsdevel@vger.kernel.org, hare@suse.de, p.raghav@samsung.com, mcgrof@kernel.org, gost.dev@samsung.com, cl@os.amperecomputing.com, linux-xfs@vger.kernel.org, kernel@pankajraghav.com, ryan.roberts@arm.com, hch@lst.de, Zi Yan Subject: [PATCH v11 10/10] xfs: enable block size larger than page size support Date: Fri, 26 Jul 2024 13:59:56 +0200 Message-ID: <20240726115956.643538-11-kernel@pankajraghav.com> In-Reply-To: <20240726115956.643538-1-kernel@pankajraghav.com> References: <20240726115956.643538-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Stat-Signature: f84cjh459ydydhpze535gqsx1aj66o1s X-Rspam-User: X-Rspamd-Queue-Id: D58051C002E X-Rspamd-Server: rspam02 X-HE-Tag: 1721995254-62116 X-HE-Me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EDfMb0XUzpqqBmeNW3/7AFTTQMdFTMqD052G1GiCgOd6WLwOkGi+VzqmFcRnLfxTHoIFMSrIyrgJuSWH2cElcxG34FV/h2PdUjiuQvFpF2ObP86nwzW6rnDxaoNpZW20my2j6OKk8MTzdCaWTwFH6bn5avEZoSkCQJYGgG4tUSy29ZThszKtNxKUGg53bYfCLuxYFhEkkVGHoSsfeNWAMhQEmqkPJg1 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: From: Pankaj Raghav Page cache now has the ability to have a minimum order when allocating a folio which is a prerequisite to add support for block size > page size. Signed-off-by: Pankaj Raghav Signed-off-by: Luis Chamberlain Reviewed-by: Darrick J. Wong Reviewed-by: Dave Chinner --- fs/xfs/libxfs/xfs_ialloc.c | 5 +++++ fs/xfs/libxfs/xfs_shared.h | 3 +++ fs/xfs/xfs_icache.c | 6 ++++-- fs/xfs/xfs_mount.c | 1 - fs/xfs/xfs_super.c | 28 ++++++++++++++++++++-------- include/linux/pagemap.h | 13 +++++++++++++ 6 files changed, 45 insertions(+), 11 deletions(-) diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c index 0af5b7a33d055..1921b689888b8 100644 --- a/fs/xfs/libxfs/xfs_ialloc.c +++ b/fs/xfs/libxfs/xfs_ialloc.c @@ -3033,6 +3033,11 @@ xfs_ialloc_setup_geometry( igeo->ialloc_align = mp->m_dalign; else igeo->ialloc_align = 0; + + if (mp->m_sb.sb_blocksize > PAGE_SIZE) + igeo->min_folio_order = mp->m_sb.sb_blocklog - PAGE_SHIFT; + else + igeo->min_folio_order = 0; } /* Compute the location of the root directory inode that is laid out by mkfs. */ diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h index 2f7413afbf46c..33b84a3a83ff6 100644 --- a/fs/xfs/libxfs/xfs_shared.h +++ b/fs/xfs/libxfs/xfs_shared.h @@ -224,6 +224,9 @@ struct xfs_ino_geometry { /* precomputed value for di_flags2 */ uint64_t new_diflags2; + /* minimum folio order of a page cache allocation */ + unsigned int min_folio_order; + }; #endif /* __XFS_SHARED_H__ */ diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index cf629302d48e7..0fcf235e50235 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -88,7 +88,8 @@ xfs_inode_alloc( /* VFS doesn't initialise i_mode! */ VFS_I(ip)->i_mode = 0; - mapping_set_large_folios(VFS_I(ip)->i_mapping); + mapping_set_folio_min_order(VFS_I(ip)->i_mapping, + M_IGEO(mp)->min_folio_order); XFS_STATS_INC(mp, vn_active); ASSERT(atomic_read(&ip->i_pincount) == 0); @@ -325,7 +326,8 @@ xfs_reinit_inode( inode->i_uid = uid; inode->i_gid = gid; inode->i_state = state; - mapping_set_large_folios(inode->i_mapping); + mapping_set_folio_min_order(inode->i_mapping, + M_IGEO(mp)->min_folio_order); return error; } diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index 3949f720b5354..c6933440f8066 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -134,7 +134,6 @@ xfs_sb_validate_fsb_count( { uint64_t max_bytes; - ASSERT(PAGE_SHIFT >= sbp->sb_blocklog); ASSERT(sbp->sb_blocklog >= BBSHIFT); if (check_shl_overflow(nblocks, sbp->sb_blocklog, &max_bytes)) diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 27e9f749c4c7f..b2f5a1706c59d 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1638,16 +1638,28 @@ xfs_fs_fill_super( goto out_free_sb; } - /* - * Until this is fixed only page-sized or smaller data blocks work. - */ if (mp->m_sb.sb_blocksize > PAGE_SIZE) { - xfs_warn(mp, - "File system with blocksize %d bytes. " - "Only pagesize (%ld) or less will currently work.", + size_t max_folio_size = mapping_max_folio_size_supported(); + + if (!xfs_has_crc(mp)) { + xfs_warn(mp, +"V4 Filesystem with blocksize %d bytes. Only pagesize (%ld) or less is supported.", mp->m_sb.sb_blocksize, PAGE_SIZE); - error = -ENOSYS; - goto out_free_sb; + error = -ENOSYS; + goto out_free_sb; + } + + if (mp->m_sb.sb_blocksize > max_folio_size) { + xfs_warn(mp, +"block size (%u bytes) not supported; Only block size (%ld) or less is supported", + mp->m_sb.sb_blocksize, max_folio_size); + error = -ENOSYS; + goto out_free_sb; + } + + xfs_warn(mp, +"EXPERIMENTAL: V5 Filesystem with Large Block Size (%d bytes) enabled.", + mp->m_sb.sb_blocksize); } /* Ensure this filesystem fits in the page cache limits */ diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 3a876d6801a90..61a7649d86e57 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -373,6 +373,19 @@ static inline void mapping_set_gfp_mask(struct address_space *m, gfp_t mask) #define MAX_XAS_ORDER (XA_CHUNK_SHIFT * 2 - 1) #define MAX_PAGECACHE_ORDER min(MAX_XAS_ORDER, PREFERRED_MAX_PAGECACHE_ORDER) +/* + * mapping_max_folio_size_supported() - Check the max folio size supported + * + * The filesystem should call this function at mount time if there is a + * requirement on the folio mapping size in the page cache. + */ +static inline size_t mapping_max_folio_size_supported(void) +{ + if (IS_ENABLED(CONFIG_TRANSPARENT_HUGEPAGE)) + return 1U << (PAGE_SHIFT + MAX_PAGECACHE_ORDER); + return PAGE_SIZE; +} + /* * mapping_set_folio_order_range() - Set the orders supported by a file. * @mapping: The address space of the file.