From patchwork Tue Feb 13 09:37:11 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: 13554793 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 87986C4829A for ; Tue, 13 Feb 2024 09:38:07 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1CB898D000B; Tue, 13 Feb 2024 04:38:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 12D358D0001; Tue, 13 Feb 2024 04:38:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE9C38D000B; Tue, 13 Feb 2024 04:38:06 -0500 (EST) 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 D81938D0001 for ; Tue, 13 Feb 2024 04:38:06 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id B7DD840284 for ; Tue, 13 Feb 2024 09:38:06 +0000 (UTC) X-FDA: 81786279372.28.FFD1679 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by imf22.hostedemail.com (Postfix) with ESMTP id 1AFAAC0025 for ; Tue, 13 Feb 2024 09:38:04 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b="WxRaE/Va"; dmarc=none; spf=pass (imf22.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 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=1707817085; 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=vzZe/GhW0AKuEEGxmrsisVmOwc1fDz2jZ00nW20jdYY=; b=RcGt6r7rGxbO+Et6dlARiHEHg4nA4mq+Z0n1X69ORFiyedx/yLy0rU5BSEdiTWHL0xsOVV pbarTx5AbIj2Ko7SJnCYVPLATjzO9V1MqR9qE1zYI9XDeFZ9XEjmDxnqEAwI32qI4qH1rz 5KCT3To/oxqsy59wVNSS/KjE+95J8ic= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b="WxRaE/Va"; dmarc=none; spf=pass (imf22.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=me@pankajraghav.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1707817085; a=rsa-sha256; cv=none; b=VoDTgUparMYM/E1HFCW5AHoPm3OjfQPVr03uRyB9fUAAmuteQ9Rqw/nFKwIfW3B1MmjgKc MCkrNrmr/rzofR1Doq/dIAyGWAOktmm5uXcZgKZ0buIGHkovbdfst02jzKFN0F127IJ1lN 8PFyitm4+f7/Qx5PB3J9O0WcfYrXspc= Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (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 4TYx894brXz9sq8; Tue, 13 Feb 2024 10:38:01 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1707817081; 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=vzZe/GhW0AKuEEGxmrsisVmOwc1fDz2jZ00nW20jdYY=; b=WxRaE/VaFusCFl5KQNguCwied061qANl5HTR9V9OJtzJe7ZG6mjmEis1M1BAnz6yvnvEHC Nzf87hlFBc4f43/BSJaMthC/KNrvWMe4PJaq0ITrrMSZgEwSJkSKiPG4hjT8OYYNVT1U05 5ckop88rRS+YSwN0H/gTEa2H+P1LDxjxKr4efXJ9CIgXLF4TUZHddADytDu7kvt01z+2VT GdFqmNf7DPnSJu4Tame5pp+JQjC4DSsYSHACxPoPkZFDSKwCrsSdshkNN9EgvAgYFytnql Leiu+FIkvhBgHBxs8VORK/8FPFWm2a6oCwlNjL0S2A9yNcrXB4yCGzHqPGEWGw== From: "Pankaj Raghav (Samsung)" To: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: mcgrof@kernel.org, gost.dev@samsung.com, akpm@linux-foundation.org, kbusch@kernel.org, djwong@kernel.org, chandan.babu@oracle.com, p.raghav@samsung.com, linux-kernel@vger.kernel.org, hare@suse.de, willy@infradead.org, linux-mm@kvack.org, david@fromorbit.com Subject: [RFC v2 12/14] xfs: make the calculation generic in xfs_sb_validate_fsb_count() Date: Tue, 13 Feb 2024 10:37:11 +0100 Message-ID: <20240213093713.1753368-13-kernel@pankajraghav.com> In-Reply-To: <20240213093713.1753368-1-kernel@pankajraghav.com> References: <20240213093713.1753368-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 1AFAAC0025 X-Stat-Signature: jsijabffmhqmd1jjzuabbfty4w5h7bzc X-HE-Tag: 1707817084-953157 X-HE-Meta: U2FsdGVkX19VvuQLERgpce0t5ngMuyReieI6uCjcsrhZJE7+2ptUokFrNGhC/fvonHeigbWSTSHQ4V59BFS5/Mm/3Z3MSP3TP6g7uVtz209ReRmdRuAieEg5mcAADoDXGjo803Pggz6opz0MG5KuMcA7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li8O3k5Ree+rPn9812CcTxdCMHIy/jeIa+25f54wlO8ACA8GIQePBIFAIQ1vTy5k3pDSy+RhLrUr3cLOy6EzioyiB38s5tNn8LodepC+xbzC7bZdR89GRjRgsBD8CtofoVhzhKx8smur0pykZdVaJ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000311, 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 Instead of assuming that PAGE_SHIFT is always higher than the blocklog, make the calculation generic so that page cache count can be calculated correctly for LBS. Signed-off-by: Pankaj Raghav --- fs/xfs/xfs_mount.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c index aabb25dc3efa..bfbaaecaf668 100644 --- a/fs/xfs/xfs_mount.c +++ b/fs/xfs/xfs_mount.c @@ -133,9 +133,13 @@ xfs_sb_validate_fsb_count( { ASSERT(PAGE_SHIFT >= sbp->sb_blocklog); ASSERT(sbp->sb_blocklog >= BBSHIFT); + unsigned long mapping_count; + uint64_t bytes = nblocks << sbp->sb_blocklog; + + mapping_count = bytes >> PAGE_SHIFT; /* Limited by ULONG_MAX of page cache index */ - if (nblocks >> (PAGE_SHIFT - sbp->sb_blocklog) > ULONG_MAX) + if (mapping_count > ULONG_MAX) return -EFBIG; return 0; }