From patchwork Fri Sep 15 18:38:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13387484 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 3958DEED61A for ; Fri, 15 Sep 2023 18:40:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C5E226B03DB; Fri, 15 Sep 2023 14:40:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BE5846B03DD; Fri, 15 Sep 2023 14:40:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C5EC6B03DE; Fri, 15 Sep 2023 14:40:01 -0400 (EDT) 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 806B66B03DB for ; Fri, 15 Sep 2023 14:40:01 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 57E67C0769 for ; Fri, 15 Sep 2023 18:40:01 +0000 (UTC) X-FDA: 81239696202.28.6A1DB81 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) by imf18.hostedemail.com (Postfix) with ESMTP id A95A01C001C for ; Fri, 15 Sep 2023 18:39:59 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=YWBaYLR8; dmarc=none; spf=pass (imf18.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1694803199; 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=rdyOm0E20W1O08Haq+wboPt6O9fnOeXgM7VNGHdT/wc=; b=r9YcsJOQqHSwrumzHIgFPEQPGIvtrDKiDOGGQHT8low2NTNTFipv2bdYPNSh6rIKIfxcC6 W5PEihTuzq1osg9ZdMYjw2s7185Ug5QH5tIdqo8FECt2OJzuFQV2HwfuNMZiaBtKq0+bY+ BU3lnxCXuFwW2ZDgcZ+EvnXh3SanUac= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=YWBaYLR8; dmarc=none; spf=pass (imf18.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.172 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1694803199; a=rsa-sha256; cv=none; b=S8AxqTAz8ypF9bp+C64tj8DUXLNY2HsRm14MLIb7YKH0VGsPHNDwmMAkkeQlIhBhHW+Pxi 7JhtsqdrGkQoChl07xQk8KR+k/XPTB+8taA9D4j7LiUbJgTZdL7hL6DPGRoTe6urZ4hoab pLN1VEncNIxljbDHIFqjXFWzT4S1T2Y= Received: from smtp202.mailbox.org (smtp202.mailbox.org [10.196.197.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4RnNK84kWKz9sWQ; Fri, 15 Sep 2023 20:39:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1694803196; 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=rdyOm0E20W1O08Haq+wboPt6O9fnOeXgM7VNGHdT/wc=; b=YWBaYLR8wP7FiydPN5L35PApcVVJVdWdr9JQ0wve5greLck+YNw4kh4nrPZG0I3Irb8ki0 iuokOs97BSQFNTgm6YhdORbefrutGfT1KELpkS/3XMgdCJ9oOH4CtnvKt/LPo0PALntzFv p3aHYP5rCYGypOCX8eQG6C8LNjayrhZbhVYUtmATnzcj1I2hW2uQpwW6y/BQVis0Zw0/VG 5DwtrDMNHLI60IzV77LR+S96bZ65EDdStUam1CBD+ng7P3QZexi7+Gw76NWeAcNZn30u4d ZF4HNoSpiJ8j4mP9R3KSBmGwbUH3gqxJZAlgZODdsgOKSUDIhWjurPKl2hsTaw== From: Pankaj Raghav To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: p.raghav@samsung.com, david@fromorbit.com, da.gomez@samsung.com, akpm@linux-foundation.org, linux-kernel@vger.kernel.org, willy@infradead.org, djwong@kernel.org, linux-mm@kvack.org, chandan.babu@oracle.com, mcgrof@kernel.org, gost.dev@samsung.com Subject: [RFC 23/23] xfs: set minimum order folio for page cache based on blocksize Date: Fri, 15 Sep 2023 20:38:48 +0200 Message-Id: <20230915183848.1018717-24-kernel@pankajraghav.com> In-Reply-To: <20230915183848.1018717-1-kernel@pankajraghav.com> References: <20230915183848.1018717-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A95A01C001C X-Stat-Signature: fiqdzep94shju1ckmnsw9w3wi75pdtu3 X-Rspam-User: X-HE-Tag: 1694803199-209438 X-HE-Meta: U2FsdGVkX1/ncE0CDfOyPoqvcJimVYyiwi4EfCC/V0is+92My/ZnASsGsapMRQgnbcciyFq1EEAhrOj2Yx7PwAreI8EdTH/Y0QPdnxKnEx4UeCSqcI7iifLNfGNfCrNHp4Nug0Y+eWcvS240vM0OXBJ4GFxsZVS+UFdxaG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zYIMjqT8sr+3XgPp7GrJhUEuEnQH8Bm2nJJXwaY7u8CslfGF825D+Q889s1dYsR6Uhad+bVl2TJGzqRvdOmVWy2kGNcaswXbcmRBmNfvAi/T+BlIbQ/ODqcwiULhmoXFxuJipzQ== 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: From: Pankaj Raghav Enabling a block size > PAGE_SIZE is only possible if we can ensure that the filesystem allocations for the block size is treated atomically and we do this with the min order folio requirement for the inode. This allows the page cache to treat this inode atomically even if on the block layer we may treat it separately. For instance, on x86 this enables eventual usage of block size > 4k so long as you use a sector size set of 4k. Signed-off-by: Pankaj Raghav Signed-off-by: Luis Chamberlain --- fs/xfs/xfs_icache.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fs/xfs/xfs_icache.c b/fs/xfs/xfs_icache.c index aacc7eec2497..81f07503f5ca 100644 --- a/fs/xfs/xfs_icache.c +++ b/fs/xfs/xfs_icache.c @@ -73,6 +73,7 @@ xfs_inode_alloc( xfs_ino_t ino) { struct xfs_inode *ip; + int min_order = 0; /* * XXX: If this didn't occur in transactions, we could drop GFP_NOFAIL @@ -88,7 +89,8 @@ xfs_inode_alloc( /* VFS doesn't initialise i_mode or i_state! */ VFS_I(ip)->i_mode = 0; VFS_I(ip)->i_state = 0; - mapping_set_large_folios(VFS_I(ip)->i_mapping); + min_order = max(min_order, ilog2(mp->m_sb.sb_blocksize) - PAGE_SHIFT); + mapping_set_folio_orders(VFS_I(ip)->i_mapping, min_order, MAX_PAGECACHE_ORDER); XFS_STATS_INC(mp, vn_active); ASSERT(atomic_read(&ip->i_pincount) == 0); @@ -313,6 +315,7 @@ xfs_reinit_inode( dev_t dev = inode->i_rdev; kuid_t uid = inode->i_uid; kgid_t gid = inode->i_gid; + int min_order = 0; error = inode_init_always(mp->m_super, inode); @@ -323,7 +326,8 @@ xfs_reinit_inode( inode->i_rdev = dev; inode->i_uid = uid; inode->i_gid = gid; - mapping_set_large_folios(inode->i_mapping); + min_order = max(min_order, ilog2(mp->m_sb.sb_blocksize) - PAGE_SHIFT); + mapping_set_folio_orders(inode->i_mapping, min_order, MAX_PAGECACHE_ORDER); return error; }