Re: [PATCH] btrfs: avoid opencoded 64-bit div/mod operation
From: Anand Jain
Date: Mon Dec 16 2024 - 04:23:24 EST
@@ -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)) {
Right, this was also in the review comment by David, and the change
is already in the local work-space. I will be sending v4 out.
Currently dealing with some rebase issues.
Thanks, Anand