From patchwork Wed Jul 5 14:01:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13302191 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 59218EB64DA for ; Wed, 5 Jul 2023 14:01:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232444AbjGEOBo (ORCPT ); Wed, 5 Jul 2023 10:01:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232308AbjGEOBm (ORCPT ); Wed, 5 Jul 2023 10:01:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AD4D10EA; Wed, 5 Jul 2023 07:01:41 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 36B1D61584; Wed, 5 Jul 2023 14:01:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37F2FC433C8; Wed, 5 Jul 2023 14:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688565700; bh=i4WuLKoN0IyluaFAelwAkFb9Rk1qHMBCuaUBAW8Ar9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SvQXJaHkk4ukD90YKcHiOX5/PkUmuljkT4jVmkkhUK7Jl/wzvzJXfsQD29WErL8uD lOVgIGjHEeQMoopAsJRkpNPfWCea9oRPIOT/6DdQnyC3S6TSv8Pg/Ss7NKNS4vIf75 25ntnvl3c/sa47hO689Y8FSb00FfbqPqgD9gi0yv8ZG1mf1cB6+ECuWeWg4hGDMTWx 5JQZDU/1umQRfQrVkwp2tlaAkjP5pjUmAjeo5eFhjopZmcCnWbJC+rZbe8NB4efUSg uFikvcQdGolhU0H+AYW1uImXtMuvzmTa5k3J60qFVSiKmldY5asArIzXBro45/W8jq 68dIvQ0aRfdww== From: Arnd Bergmann To: Chris Mason , Josef Bacik , David Sterba Cc: Arnd Bergmann , Johannes Thumshirn , Qu Wenruo , Anand Jain , Nikolay Borisov , Changbin Du , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] btrfs: fix 64-bit division link failure Date: Wed, 5 Jul 2023 16:01:09 +0200 Message-Id: <20230705140117.795478-2-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230705140117.795478-1-arnd@kernel.org> References: <20230705140117.795478-1-arnd@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Arnd Bergmann Some of the recent refactoring of the statfs code apparently brought back a link failure on older gcc versions that I had fixed before: arm-linux-gnueabi-ld: fs/btrfs/super.o: in function `btrfs_statfs': super.c:(.text+0xec40): undefined reference to `__aeabi_uldivmod' I think what happened is that gcc is free to not inline a function despite the 'inline' annotation, and when this happens it can end up partially inlining the div_u64() helper in a way that breaks the __builtin_constant_p() based optimization. I only see this behavior for gcc-9, but it's possible that the same thing happens in later versions as well when the code changes again. Change this to __always_inline to prevent it from happening again, and add a comment about this. Fixes: 7e17916b35797 ("btrfs: avoid link error with CONFIG_NO_AUTO_INLINE") Signed-off-by: Arnd Bergmann --- fs/btrfs/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index f1dd172d8d5bd..7c8ee0da0f0d1 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c @@ -1902,9 +1902,9 @@ static inline void btrfs_descending_sort_devices( /* * The helper to calc the free space on the devices that can be used to store - * file data. + * file data, always inline to avoid a link failure with gcc-9 and earlier. */ -static inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info, +static __always_inline int btrfs_calc_avail_data_space(struct btrfs_fs_info *fs_info, u64 *free_bytes) { struct btrfs_device_info *devices_info;