Skip to contentSkip to conversation

f2fs compile problem in next-20191220 on x86-32

DISCUSSION Pavel Machek 2 participants 3 messages Dec 22, 2019 – Dec 26, 2019

lore
Share & tools
lore
#0 lore raw

Hi!

I'm getting this:

LD .tmp_vmlinux1
ld: fs/f2fs/file.o: in function `f2fs_truncate_blocks':
file.c:(.text+0x2968): undefined reference to `__udivdi3'
make: *** [Makefile:1079: vmlinux] Error 1

when attempting to compile kernel for x86-32.

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#1 lore raw
Quoted 10 lines · Pavel Machek

Hi!

I'm getting this:

LD .tmp_vmlinux1
ld: fs/f2fs/file.o: in function `f2fs_truncate_blocks':
file.c:(.text+0x2968): undefined reference to `__udivdi3'
make: *** [Makefile:1079: vmlinux] Error 1

when attempting to compile kernel for x86-32.

David bisected it:

https://bugzilla.kernel.org/show_bug.cgi?id=205967

And the bug is actually easy to see:

+int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock) +{
+ u64 free_from = from;
+
+ /*

+        * for compressed file, only support cluster size
+        * aligned truncation.
+        */

+ if (f2fs_compressed_file(inode)) {
+ size_t cluster_size = PAGE_SIZE <<
+ F2FS_I(inode)->i_log_cluster_size;
+
+ free_from = roundup(from, cluster_size);

#define roundup(x, y) (                                 \
{                                                       \
        typeof(y) __y = y;                              \
        (((x) + (__y - 1)) / __y) * __y;                \
}                                                       \

div64 is needed instead of div in the roundup macro. Or actually... It is quite stupid to use roundup like this on value that is power of two, right?

Best regards,
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
#2 lore raw
Quoted 38 lines · Pavel Machek
Quoted 10 lines · Pavel Machek

Hi!

I'm getting this:

LD .tmp_vmlinux1
ld: fs/f2fs/file.o: in function `f2fs_truncate_blocks':
file.c:(.text+0x2968): undefined reference to `__udivdi3'
make: *** [Makefile:1079: vmlinux] Error 1

when attempting to compile kernel for x86-32.

David bisected it:

https://bugzilla.kernel.org/show_bug.cgi?id=205967

And the bug is actually easy to see:

(quoted diff) +13 -0
+int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock)
+{
+       u64 free_from = from;
+
+       /*
+        * for compressed file, only support cluster size
+        * aligned truncation.
+        */
+       if (f2fs_compressed_file(inode)) {
+               size_t cluster_size = PAGE_SIZE <<
+                                       F2FS_I(inode)->i_log_cluster_size;
+
+               free_from = roundup(from, cluster_size);
#define roundup(x, y) (                                 \
{                                                       \
        typeof(y) __y = y;                              \
        (((x) + (__y - 1)) / __y) * __y;                \
}                                                       \
Quoted 3 lines

div64 is needed instead of div in the roundup macro. Or actually... It is quite stupid to use roundup like this on value that is power of two, right?

This has been fixed in dev branch, could you check that? People still saw this issue because linux-next did not update after we fix this bug.

https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git/commit/?h=dev

Thanks,

Quoted 4 lines

Best regards,
Pavel