[PATCH 1/2] nilfs2: fix 64-bit division operations in nilfs_bmap_find_target_in_group()

Jeff Layton posted 2 patches 4 weeks, 1 day ago
There is a newer version of this series
[PATCH 1/2] nilfs2: fix 64-bit division operations in nilfs_bmap_find_target_in_group()
Posted by Jeff Layton 4 weeks, 1 day ago
With the change to make inode->i_ino a u64, the build started failing on
32-bit ARM with:

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

Fix this by using the 64-bit division interfaces in
nilfs_bmap_find_target_in_group().

Fixes: 998a59d371c2 ("treewide: fix missed i_ino format specifier conversions")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202603100602.KPxiClIO-lkp@intel.com/
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/nilfs2/bmap.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
index 824f2bd91c167965ec3a660202b6e6c5f1fe007e..4ce9a93149a5af13bc215cc1877a757e2c6cf49b 100644
--- a/fs/nilfs2/bmap.c
+++ b/fs/nilfs2/bmap.c
@@ -455,11 +455,14 @@ __u64 nilfs_bmap_find_target_in_group(const struct nilfs_bmap *bmap)
 {
 	struct inode *dat = nilfs_bmap_get_dat(bmap);
 	unsigned long entries_per_group = nilfs_palloc_entries_per_group(dat);
-	unsigned long group = bmap->b_inode->i_ino / entries_per_group;
+	unsigned long group;
+	u32 rem;
+
+	group = div_u64(bmap->b_inode->i_ino, entries_per_group);
+	div_u64_rem(bmap->b_inode->i_ino, NILFS_BMAP_GROUP_DIV, &rem);
 
 	return group * entries_per_group +
-		(bmap->b_inode->i_ino % NILFS_BMAP_GROUP_DIV) *
-		(entries_per_group / NILFS_BMAP_GROUP_DIV);
+	       rem * (entries_per_group / NILFS_BMAP_GROUP_DIV);
 }
 
 static struct lock_class_key nilfs_bmap_dat_lock_key;

-- 
2.53.0
Re: [PATCH 1/2] nilfs2: fix 64-bit division operations in nilfs_bmap_find_target_in_group()
Posted by Viacheslav Dubeyko 4 weeks, 1 day ago
On Tue, 2026-03-10 at 07:43 -0400, Jeff Layton wrote:
> With the change to make inode->i_ino a u64, the build started failing
> on
> 32-bit ARM with:
> 
>     ERROR: modpost: "__aeabi_uldivmod" [fs/nilfs2/nilfs2.ko]
> undefined!
> 
> Fix this by using the 64-bit division interfaces in
> nilfs_bmap_find_target_in_group().
> 
> Fixes: 998a59d371c2 ("treewide: fix missed i_ino format specifier
> conversions")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes:
> https://lore.kernel.org/oe-kbuild-all/202603100602.KPxiClIO-lkp@intel.com/
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
>  fs/nilfs2/bmap.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
> index
> 824f2bd91c167965ec3a660202b6e6c5f1fe007e..4ce9a93149a5af13bc215cc1877
> a757e2c6cf49b 100644
> --- a/fs/nilfs2/bmap.c
> +++ b/fs/nilfs2/bmap.c
> @@ -455,11 +455,14 @@ __u64 nilfs_bmap_find_target_in_group(const
> struct nilfs_bmap *bmap)
>  {
>  	struct inode *dat = nilfs_bmap_get_dat(bmap);
>  	unsigned long entries_per_group =
> nilfs_palloc_entries_per_group(dat);
> -	unsigned long group = bmap->b_inode->i_ino /
> entries_per_group;
> +	unsigned long group;
> +	u32 rem;
> +
> +	group = div_u64(bmap->b_inode->i_ino, entries_per_group);
> +	div_u64_rem(bmap->b_inode->i_ino, NILFS_BMAP_GROUP_DIV,
> &rem);
>  
>  	return group * entries_per_group +
> -		(bmap->b_inode->i_ino % NILFS_BMAP_GROUP_DIV) *
> -		(entries_per_group / NILFS_BMAP_GROUP_DIV);
> +	       rem * (entries_per_group / NILFS_BMAP_GROUP_DIV);
>  }
>  
>  static struct lock_class_key nilfs_bmap_dat_lock_key;

Makes sense. :) Maybe, rem is not very good variable name, but the
whole logic looks good.

Reviewed-by: Viacheslav Dubeyko <slava@dubeyko.com>

Thanks,
Slava.
Re: [PATCH 1/2] nilfs2: fix 64-bit division operations in nilfs_bmap_find_target_in_group()
Posted by Jeff Layton 4 weeks, 1 day ago
On Tue, 2026-03-10 at 09:54 -0700, Viacheslav Dubeyko wrote:
> On Tue, 2026-03-10 at 07:43 -0400, Jeff Layton wrote:
> > With the change to make inode->i_ino a u64, the build started failing
> > on
> > 32-bit ARM with:
> > 
> >     ERROR: modpost: "__aeabi_uldivmod" [fs/nilfs2/nilfs2.ko]
> > undefined!
> > 
> > Fix this by using the 64-bit division interfaces in
> > nilfs_bmap_find_target_in_group().
> > 
> > Fixes: 998a59d371c2 ("treewide: fix missed i_ino format specifier
> > conversions")
> > Reported-by: kernel test robot <lkp@intel.com>
> > Closes:
> > https://lore.kernel.org/oe-kbuild-all/202603100602.KPxiClIO-lkp@intel.com/
> > Signed-off-by: Jeff Layton <jlayton@kernel.org>
> > ---
> >  fs/nilfs2/bmap.c | 9 ++++++---
> >  1 file changed, 6 insertions(+), 3 deletions(-)
> > 
> > diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
> > index
> > 824f2bd91c167965ec3a660202b6e6c5f1fe007e..4ce9a93149a5af13bc215cc1877
> > a757e2c6cf49b 100644
> > --- a/fs/nilfs2/bmap.c
> > +++ b/fs/nilfs2/bmap.c
> > @@ -455,11 +455,14 @@ __u64 nilfs_bmap_find_target_in_group(const
> > struct nilfs_bmap *bmap)
> >  {
> >  	struct inode *dat = nilfs_bmap_get_dat(bmap);
> >  	unsigned long entries_per_group =
> > nilfs_palloc_entries_per_group(dat);
> > -	unsigned long group = bmap->b_inode->i_ino /
> > entries_per_group;
> > +	unsigned long group;
> > +	u32 rem;
> > +
> > +	group = div_u64(bmap->b_inode->i_ino, entries_per_group);
> > +	div_u64_rem(bmap->b_inode->i_ino, NILFS_BMAP_GROUP_DIV,
> > &rem);
> >  
> >  	return group * entries_per_group +
> > -		(bmap->b_inode->i_ino % NILFS_BMAP_GROUP_DIV) *
> > -		(entries_per_group / NILFS_BMAP_GROUP_DIV);
> > +	       rem * (entries_per_group / NILFS_BMAP_GROUP_DIV);
> >  }
> >  
> >  static struct lock_class_key nilfs_bmap_dat_lock_key;
> 
> Makes sense. :) Maybe, rem is not very good variable name, but the
> whole logic looks good.
> 
> Reviewed-by: Viacheslav Dubeyko <slava@dubeyko.com>
> 

Thanks. My thinking was "remainder" but I don't have an objection if
you guys want to change it.
-- 
Jeff Layton <jlayton@kernel.org>
Re: [PATCH 1/2] nilfs2: fix 64-bit division operations in nilfs_bmap_find_target_in_group()
Posted by Ryusuke Konishi 4 weeks, 1 day ago
On Tue, Mar 10, 2026 at 8:44 PM Jeff Layton wrote:
>
> With the change to make inode->i_ino a u64, the build started failing on
> 32-bit ARM with:
>
>     ERROR: modpost: "__aeabi_uldivmod" [fs/nilfs2/nilfs2.ko] undefined!
>
> Fix this by using the 64-bit division interfaces in
> nilfs_bmap_find_target_in_group().
>
> Fixes: 998a59d371c2 ("treewide: fix missed i_ino format specifier conversions")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202603100602.KPxiClIO-lkp@intel.com/
> Signed-off-by: Jeff Layton <jlayton@kernel.org>

Acked-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>

Thank you.  The conversion seems reasonable.

Ryusuke Konishi

> ---
>  fs/nilfs2/bmap.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/fs/nilfs2/bmap.c b/fs/nilfs2/bmap.c
> index 824f2bd91c167965ec3a660202b6e6c5f1fe007e..4ce9a93149a5af13bc215cc1877a757e2c6cf49b 100644
> --- a/fs/nilfs2/bmap.c
> +++ b/fs/nilfs2/bmap.c
> @@ -455,11 +455,14 @@ __u64 nilfs_bmap_find_target_in_group(const struct nilfs_bmap *bmap)
>  {
>         struct inode *dat = nilfs_bmap_get_dat(bmap);
>         unsigned long entries_per_group = nilfs_palloc_entries_per_group(dat);
> -       unsigned long group = bmap->b_inode->i_ino / entries_per_group;
> +       unsigned long group;
> +       u32 rem;
> +
> +       group = div_u64(bmap->b_inode->i_ino, entries_per_group);
> +       div_u64_rem(bmap->b_inode->i_ino, NILFS_BMAP_GROUP_DIV, &rem);
>
>         return group * entries_per_group +
> -               (bmap->b_inode->i_ino % NILFS_BMAP_GROUP_DIV) *
> -               (entries_per_group / NILFS_BMAP_GROUP_DIV);
> +              rem * (entries_per_group / NILFS_BMAP_GROUP_DIV);
>  }
>
>  static struct lock_class_key nilfs_bmap_dat_lock_key;
>
> --
> 2.53.0
>