Skip to contentSkip to conversation

f2fs: fix building on 32-bit architectures

PATCH In review Arnd Bergmann 2 participants 2 messages May 13, 2015 – May 14, 2015 F2FS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 f2fs: fix building on 32-bit architectures

A bug fix to the debug output extended the type of some local variables to 64-bit, which now causes the kernel to fail building because of missing 64-bit division functions:

ERROR: "__aeabi_uldivmod" [fs/f2fs/f2fs.ko] undefined!

In the kernel, we have to use div_u64 or do_div to do this, in order to annotate that this is an expensive operation.

As the function is only called for debug out, we know this is not performance critical, so it is safe to use div_u64.

Fixes d1f85bd38db19 ("f2fs: avoid value overflow in showing current status")

---
This patch is required for ARM allmodconfig builds.

fs/f2fs/debug.c +3 -3
index efbc83f07305..75176e0dd6c8 100644
@@ -113,10 +113,10 @@ static void update_sit_info(struct f2fs_sb_info *sbi)
 			ndirty++;
 		}
 	}
-	dist = MAIN_SECS(sbi) * hblks_per_sec * hblks_per_sec / 100;
-	si->bimodal = bimodal / dist;
+	dist = div_u64(MAIN_SECS(sbi) * hblks_per_sec * hblks_per_sec, 100);
+	si->bimodal = div_u64(bimodal, dist);
 	if (si->dirty_count)
-		si->avg_vblocks = total_vblocks / ndirty;
+		si->avg_vblocks = div_u64(total_vblocks, ndirty);
 	else
 		si->avg_vblocks = 0;
 }
maintainer
#1 lore raw

Hi Arnd,

Thank you for the patch.
Merged and pushed to -next. :)

Thanks,

Quoted 35 lines · Arnd Bergmann

A bug fix to the debug output extended the type of some local variables to 64-bit, which now causes the kernel to fail building because of missing 64-bit division functions:

ERROR: "__aeabi_uldivmod" [fs/f2fs/f2fs.ko] undefined!

In the kernel, we have to use div_u64 or do_div to do this, in order to annotate that this is an expensive operation.

As the function is only called for debug out, we know this is not performance critical, so it is safe to use div_u64.

Fixes d1f85bd38db19 ("f2fs: avoid value overflow in showing current status")

---
This patch is required for ARM allmodconfig builds.

fs/f2fs/debug.c +3 -3
index efbc83f07305..75176e0dd6c8 100644
@@ -113,10 +113,10 @@ static void update_sit_info(struct f2fs_sb_info *sbi)
 			ndirty++;
 		}
 	}
-	dist = MAIN_SECS(sbi) * hblks_per_sec * hblks_per_sec / 100;
-	si->bimodal = bimodal / dist;
+	dist = div_u64(MAIN_SECS(sbi) * hblks_per_sec * hblks_per_sec, 100);
+	si->bimodal = div_u64(bimodal, dist);
 	if (si->dirty_count)
-		si->avg_vblocks = total_vblocks / ndirty;
+		si->avg_vblocks = div_u64(total_vblocks, ndirty);
 	else
 		si->avg_vblocks = 0;
 }