From patchwork Mon Oct 14 10:58:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 1996813 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=ylys=rk=vger.kernel.org=linux-ext4+bounces-4581-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4XRvS40SYPz1xsc for ; Mon, 14 Oct 2024 22:01:40 +1100 (AEDT) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4XRvS30Kydz4x8C for ; Mon, 14 Oct 2024 22:01:39 +1100 (AEDT) Received: by gandalf.ozlabs.org (Postfix) id 4XRvS30HPyz4wbr; Mon, 14 Oct 2024 22:01:39 +1100 (AEDT) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=147.75.199.223 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1728903699; cv=pass; b=uWEdFRXD4hj41cY6IzTLMIffjbZATftbB+f5zcF/aGcctm4RPflRAhNDziw0rzGVkBi5Q6gUtfrK2G6uGE1VoqVl9fBwssu5246jaLXbuCuiC6E0rrzX8JvRkkvH+bSvpQk1YtHHCdlyPv3kacq1b+hDju1UMOcohLAsA9euANUyNnU6o4n1tL3Wq11WNkTgcuTOtQpa00JHCqmeAO5YZJB2+pKc+wwKVRI3DDIYXm8cAECdRNRyX1HGpW1U84v5oXfe9Kw5qnlPEBK1jGP+vT1zLLpOuzlpDLAfaRs3+SSyQ7o2CdO9RsG2oLRcqJWMrH1AH68e86xhwa4aaWJznQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1728903699; c=relaxed/relaxed; bh=4YDRe8auf3W9gPGvw4mfS6WcApteYPOWnCg7H4VxM6g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=La530nAhqNbi4gkXuaWtb+Elg6jiOkalQYmzX3+Bdz7iHh59pyNZf5OwWkjL7zpXJ3CF7PzaFEOKU2skJfpZSIdBIhuLi/XkUX7BmZEQb+sK/qKWFw1XL5w/J2Cn3yv3V7sxAixIaPolqSWnpR8xPizD4uUHWQnfLG3C39DjorKM1/5Y81vATY7z5qy8m5gb8Ya02UMGUnW18Faz+nKWGGzOvWeZV3XiOdExffuK1qE7meHqGrFd4MiqB8fTOLLXi3usJKBK5hYibEL40Gb3vTekUjbeYtgPS8g49NIblFDQyp/zaO5j1PaenYp7CmNnz64CC9E3hcA3a1v+Uf6cpQ== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=fail (p=none dis=none) header.from=arm.com; spf=pass (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-ext4+bounces-4581-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: gandalf.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-ext4+bounces-4581-patchwork-incoming=ozlabs.org@vger.kernel.org; receiver=ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4XRvS24H89z4x8C for ; Mon, 14 Oct 2024 22:01:38 +1100 (AEDT) Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C67B81C23821 for ; Mon, 14 Oct 2024 11:01:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C78EA1A7247; Mon, 14 Oct 2024 11:00:01 +0000 (UTC) X-Original-To: linux-ext4@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 407BD19D062; Mon, 14 Oct 2024 10:59:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728903601; cv=none; b=CVmTu8QbpgCf+ZoiFLfrg0QZzzp8cGHT0hUojEwJo0fqsyf0SJrkUwDEt7+/ZyTwlwvyel0vQpV2jUcYle9JMghNLHQrDgo+mqnAs+Yg264a77WeVmd684BWSf1KBvBMP5uRUrDy70Kq07an/y89InKEyOCt6x7WtvVF0++24xM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728903601; c=relaxed/simple; bh=vfJwjToLALeeCjImxT2qgvgczni/pAelp8cETW25/gs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jvEPLtDCCJQhB2htmy4MoT/s1Xq4Tc/y7w4fS2Cv0TZkZ/K9PgUR5pwS6RHkQrAzcabpei2U4COw8NIezvUVO2Jd6SHs5visMDLDVwdG8hUlG2CVwmk8P5xkQILU2jpWcNvW0O0aSfvR9M8nClSRvmbg6/3hGETiPq3hXLjhAMY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 432CD1684; Mon, 14 Oct 2024 04:00:28 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D33E63F51B; Mon, 14 Oct 2024 03:59:55 -0700 (PDT) From: Ryan Roberts To: "Theodore Ts'o" , Andreas Dilger , Andrew Morton , Anshuman Khandual , Ard Biesheuvel , Catalin Marinas , David Hildenbrand , Greg Marsden , Ivan Ivanov , Kalesh Singh , Marc Zyngier , Mark Rutland , Matthias Brugger , Miroslav Benes , Will Deacon Cc: Ryan Roberts , linux-arm-kernel@lists.infradead.org, linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v1 10/57] fs/ext4: Remove PAGE_SIZE compile-time constant assumption Date: Mon, 14 Oct 2024 11:58:17 +0100 Message-ID: <20241014105912.3207374-10-ryan.roberts@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014105912.3207374-1-ryan.roberts@arm.com> References: <20241014105514.3206191-1-ryan.roberts@arm.com> <20241014105912.3207374-1-ryan.roberts@arm.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 To prepare for supporting boot-time page size selection, refactor code to remove assumptions about PAGE_SIZE being compile-time constant. Code intended to be equivalent when compile-time page size is active. Convert CPP PAGE_SIZE conditionals to C if/else. For compile-time page size, the compiler will strip the dead part, and for boot-time page size, the condition will be evaluated at run time. Signed-off-by: Ryan Roberts --- ***NOTE*** Any confused maintainers may want to read the cover note here for context: https://lore.kernel.org/all/20241014105514.3206191-1-ryan.roberts@arm.com/ fs/ext4/ext4.h | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 08acd152261ed..1a6dbd925024a 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h @@ -2415,31 +2415,31 @@ ext4_rec_len_from_disk(__le16 dlen, unsigned blocksize) { unsigned len = le16_to_cpu(dlen); -#if (PAGE_SIZE >= 65536) - if (len == EXT4_MAX_REC_LEN || len == 0) - return blocksize; - return (len & 65532) | ((len & 3) << 16); -#else - return len; -#endif + if (PAGE_SIZE >= 65536) { + if (len == EXT4_MAX_REC_LEN || len == 0) + return blocksize; + return (len & 65532) | ((len & 3) << 16); + } else { + return len; + } } static inline __le16 ext4_rec_len_to_disk(unsigned len, unsigned blocksize) { BUG_ON((len > blocksize) || (blocksize > (1 << 18)) || (len & 3)); -#if (PAGE_SIZE >= 65536) - if (len < 65536) + if (PAGE_SIZE >= 65536) { + if (len < 65536) + return cpu_to_le16(len); + if (len == blocksize) { + if (blocksize == 65536) + return cpu_to_le16(EXT4_MAX_REC_LEN); + else + return cpu_to_le16(0); + } + return cpu_to_le16((len & 65532) | ((len >> 16) & 3)); + } else { return cpu_to_le16(len); - if (len == blocksize) { - if (blocksize == 65536) - return cpu_to_le16(EXT4_MAX_REC_LEN); - else - return cpu_to_le16(0); } - return cpu_to_le16((len & 65532) | ((len >> 16) & 3)); -#else - return cpu_to_le16(len); -#endif } /*