From patchwork Mon Dec 16 08:32:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13909384 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B8A191CEAD5; Mon, 16 Dec 2024 08:32:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734337975; cv=none; b=lmcnuDNCc7Y/CESQWY6Rz9dWhI/xqPYN7M41A98O+ygM/iOz4LLKhlwTkUWTYejrUlmxd4lm3Wk6fya4lgodxHMimly5KQPBpgTIAx3+fUb93TBCZ1e1iKDY1VSyKlv/kVgS2/VPq9Qf+srJZqgeO8/kHJJ9kzzyft3eXNtLtMo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1734337975; c=relaxed/simple; bh=olVS1kY17WrcCv3kW793pCXAc2bhMbq54Nxa5kggo2w=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=shlTuxBdT1nWkhzUp0dl/ALsbtfpmK++UTlqeZ4P+KnEkECHM9YkaayHA6yP7+VJurA7x6u5FBUkkSK6R6QFUtDXChugkZr2lQl+Of0emwGPJ5QF7ZlFh/ENXRyQAZazbis6DWSWr7FrvGUeu0A73IQVGN8W/mcO8GfV4DaOyeA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DydwwEHV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DydwwEHV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E694EC4CED0; Mon, 16 Dec 2024 08:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1734337975; bh=olVS1kY17WrcCv3kW793pCXAc2bhMbq54Nxa5kggo2w=; h=From:To:Cc:Subject:Date:From; b=DydwwEHVVJ2uxhaLVBGXpepl8IbQCawS8vI+buXtQh4ej8pIzEKoM2nfHGoHrJt1V 455BaPLqXlwxBlrdSI/V7Pm3kxU5I9U8l0ipjuvQiMAVJwdGCx5DyRv6wtoa9aHxNU 6NO8koBNCmQEmMEgxMIL9xATnvE7v9+JF2krMIhsyYv10vMjJYKElPGb67zXi0d+72 3IJ9w1LdZSgRbQJo8zT6hL1iyVnIZk9xyJB4kZkBXi9CM/EbQjeIyJ8GLTOC9gg6tH xi8SQ7x4cth8GtQLd+/uFmrjpxFfcO+ncASdtf8jHpyx4z2lEViEK0gBY2NyE53g8p gK4GEIeCcdy9w== From: Arnd Bergmann To: Chris Mason , Josef Bacik , David Sterba , Anand Jain Cc: Arnd Bergmann , Qu Wenruo , Johannes Thumshirn , Boris Burkov , Naohiro Aota , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] btrfs: avoid opencoded 64-bit div/mod operation Date: Mon, 16 Dec 2024 09:32:37 +0100 Message-Id: <20241216083248.1816638-1-arnd@kernel.org> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Arnd Bergmann Dividing 64-bit numbers causes a link failure on 32-bit builds: arm-linux-gnueabi-ld: fs/btrfs/sysfs.o: in function `btrfs_read_policy_store': sysfs.c:(.text+0x3ce0): undefined reference to `__aeabi_ldivmod' Use an explicit call to div_u64_rem() here to work around this. It would be possible to optimize this further, but this is not a performance critical operation. Fixes: 185fa5c7ac5a ("btrfs: introduce RAID1 round-robin read balancing") Signed-off-by: Arnd Bergmann --- fs/btrfs/sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/sysfs.c b/fs/btrfs/sysfs.c index 50bc4b6cb821..67bc8fa4d6ab 100644 --- a/fs/btrfs/sysfs.c +++ b/fs/btrfs/sysfs.c @@ -1433,7 +1433,9 @@ static ssize_t btrfs_read_policy_store(struct kobject *kobj, #ifdef CONFIG_BTRFS_EXPERIMENTAL if (index == BTRFS_READ_POLICY_RR) { if (value != -1) { - if ((value % fs_devices->fs_info->sectorsize) != 0) { + u32 rem; + div_u64_rem(value, fs_devices->fs_info->sectorsize, &rem); + if (rem) { btrfs_err(fs_devices->fs_info, "read_policy: min_contiguous_read %lld should be multiples of the sectorsize %u", value, fs_devices->fs_info->sectorsize);