Skip to contentSkip to conversation

fs/erofs: Fix build for m68k

PATCH In review Daniel Palmer 2 participants 3 messages Apr 19 – Apr 27 EROFS file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs/erofs: Fix build for m68k

Currently the use of roundup() causes GCC to emit a reference to __udivdi3() on m68k and we don't have that:

/usr/bin/m68k-linux-gnu-ld.bfd: fs/erofs/data.o: in function `erofs_map_blocks':
u-boot/fs/erofs/data.c:81:(.text.erofs_map_blocks+0x126): undefined reference to __udivdi3' /usr/bin/m68k-linux-gnu-ld.bfd: u-boot/fs/erofs/data.c:81:(.text.erofs_map_blocks+0x458): undefined reference to __udivdi3'

We could add it but since unit is 4 or 8 we can actually just switch the code to use round_up() instead and not output __udivdi3() in the first place.

---
 fs/erofs/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/erofs/data.c +1 -1
index b58ec6fcc666..95873846f62d 100644
@@ -78,7 +78,7 @@ int erofs_map_blocks(struct erofs_inode *inode,
 		unit = EROFS_BLOCK_MAP_ENTRY_SIZE;	/* block map */
 
 	chunknr = map->m_la >> vi->u.chunkbits;
-	pos = roundup(iloc(vi->nid) + vi->inode_isize +
+	pos = round_up(iloc(vi->nid) + vi->inode_isize +
 		      vi->xattr_isize, unit) + unit * chunknr;
 
 	err = erofs_blk_read(buf, erofs_blknr(pos), 1);
Signature · 1 line
2.53.0
#1 lore raw

Hi Daniel,

Quoted 21 lines · Daniel Palmer

Currently the use of roundup() causes GCC to emit a reference to __udivdi3() on m68k and we don't have that:

/usr/bin/m68k-linux-gnu-ld.bfd: fs/erofs/data.o: in function `erofs_map_blocks':
u-boot/fs/erofs/data.c:81:(.text.erofs_map_blocks+0x126): undefined reference to __udivdi3' /usr/bin/m68k-linux-gnu-ld.bfd: u-boot/fs/erofs/data.c:81:(.text.erofs_map_blocks+0x458): undefined reference to __udivdi3'

We could add it but since unit is 4 or 8 we can actually just switch the code to use round_up() instead and not output __udivdi3() in the first place.

---
 fs/erofs/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/erofs/data.c +0 -0
index b58ec6fcc666..95873846f62d 100644

fs/erofs/data.c int erofs_map_blocks(struct erofs_inode *inode, · line 82

Quoted 6 lines
fs/erofs/data.c +1 -1
@@ -78,7 +78,7 @@ int erofs_map_blocks(struct erofs_inode *inode,
 		unit = EROFS_BLOCK_MAP_ENTRY_SIZE;	/* block map */
 
 	chunknr = map->m_la >> vi->u.chunkbits;
-	pos = roundup(iloc(vi->nid) + vi->inode_isize +
+	pos = round_up(iloc(vi->nid) + vi->inode_isize +
 		      vi->xattr_isize, unit) + unit * chunknr;

Since round_up(x, y) requires y to be a power of two, I was wondering if it might be worth adding an assertion here to ensure this?

Additionally, a bit further down in erofs_map_blocks(), there is another instance where roundup() is used. I haven't checked the generated assembly, but I'm guessing it didn't fail because gcc was smart enough to optimize it into a right shift? Since erofs_blksiz() is defined as (1u << sbi.blkszbits), it is also guaranteed to be a power of two. Perhaps we should replace that one with round_up() as well, for safety and consistency?

Regards,
Kuan-Wei

Quoted 5 lines
fs/erofs/data.c +0 -0
 	err = erofs_blk_read(buf, erofs_blknr(pos), 1);
Signature · 1 line
2.53.0
#2 lore raw

Hi Kuan-Wei,

Quoted 2 lines · Kuan-Wei Chiu

Since round_up(x, y) requires y to be a power of two, I was wondering if it might be worth adding an assertion here to ensure this?

I think if we need that we should maybe wire it into round_up() so it checks everything using it is passing a power of two.
I thought maybe the linux version had some compile time assert thing but it doesn't seem to check either.

Quoted 7 lines

Additionally, a bit further down in erofs_map_blocks(), there is another instance where roundup() is used. I haven't checked the generated assembly, but I'm guessing it didn't fail because gcc was smart enough to optimize it into a right shift? Since erofs_blksiz() is defined as (1u << sbi.blkszbits), it is also guaranteed to be a power of two. Perhaps we should replace that one with round_up() as well, for safety and consistency?

mmm maybe I should grep for all of the instances of roundup() in the erofs code and fix them all at once.

Thanks,

Daniel