[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b46ad433-04a5-47d4-9cd0-84f4ab3b86e5@gmx.com>
Date: Mon, 16 Dec 2024 19:07:45 +1030
From: Qu Wenruo <quwenruo.btrfs@....com>
To: Arnd Bergmann <arnd@...nel.org>, Chris Mason <clm@...com>,
Josef Bacik <josef@...icpanda.com>, David Sterba <dsterba@...e.com>,
Anand Jain <anand.jain@...cle.com>
Cc: Arnd Bergmann <arnd@...db.de>, Qu Wenruo <wqu@...e.com>,
Johannes Thumshirn <johannes.thumshirn@....com>, Boris Burkov
<boris@....io>, Naohiro Aota <naohiro.aota@....com>,
linux-btrfs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] btrfs: avoid opencoded 64-bit div/mod operation
在 2024/12/16 19:02, Arnd Bergmann 写道:
> From: Arnd Bergmann <arnd@...db.de>
>
> 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 <arnd@...db.de>
> ---
> 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);
The original check is already bad, it's just a IS_ALIGNED().
So a much simpler solution is:
+ if (!IS_ALIGNED(value, fs_info->sectorsize)) {
Thanks,
Qu
> + 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);
Powered by blists - more mailing lists