linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ufs: Fix build errors on 32 bit machines
@ 2017-06-17 17:35 Guenter Roeck
  2017-06-17 18:23 ` Al Viro
  0 siblings, 1 reply; 4+ messages in thread
From: Guenter Roeck @ 2017-06-17 17:35 UTC (permalink / raw)
  To: Evgeniy Dushistov
  Cc: Mark Brown, linux-kernel, Guenter Roeck, Arnd Bergmann, Al Viro

Various 32 builds fail with error messages such as

ERROR: "__udivdi3" [fs/ufs/ufs.ko] undefined!

due to a variable type change from 32 bit to 64 bit.

Fixes: c596961d1b4c ("ufs: fix s_size/s_dsize users")
Reported-by: Arnd Bergmann <arnd@arndb.de>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 fs/ufs/balloc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c
index 0315fea1d589..a93121873fa6 100644
--- a/fs/ufs/balloc.c
+++ b/fs/ufs/balloc.c
@@ -459,7 +459,7 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment,
 	    case UFS_OPTSPACE:
 		request = newcount;
 		if (uspi->s_minfree < 5 || uspi->cs_total.cs_nffree
-		    > uspi->s_dsize * uspi->s_minfree / (2 * 100))
+		    > div_u64(uspi->s_dsize * uspi->s_minfree, 2 * 100))
 			break;
 		usb1->fs_optim = cpu_to_fs32(sb, UFS_OPTTIME);
 		break;
@@ -468,8 +468,8 @@ u64 ufs_new_fragments(struct inode *inode, void *p, u64 fragment,
 	
 	    case UFS_OPTTIME:
 		request = uspi->s_fpb;
-		if (uspi->cs_total.cs_nffree < uspi->s_dsize *
-		    (uspi->s_minfree - 2) / 100)
+		if (uspi->cs_total.cs_nffree <
+		    div_u64(uspi->s_dsize * (uspi->s_minfree - 2), 100))
 			break;
 		usb1->fs_optim = cpu_to_fs32(sb, UFS_OPTTIME);
 		break;
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ufs: Fix build errors on 32 bit machines
  2017-06-17 17:35 [PATCH] ufs: Fix build errors on 32 bit machines Guenter Roeck
@ 2017-06-17 18:23 ` Al Viro
  2017-06-17 18:51   ` Al Viro
  2017-06-18  9:30   ` Guenter Roeck
  0 siblings, 2 replies; 4+ messages in thread
From: Al Viro @ 2017-06-17 18:23 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Evgeniy Dushistov, Mark Brown, linux-kernel, Arnd Bergmann

On Sat, Jun 17, 2017 at 10:35:13AM -0700, Guenter Roeck wrote:
> Various 32 builds fail with error messages such as
> 
> ERROR: "__udivdi3" [fs/ufs/ufs.ko] undefined!
> 
> due to a variable type change from 32 bit to 64 bit.

Actually, that's not the only problem in that place.  The breakage
came in 2.4.14.7; the critical part was this:
            default:
-               usb1->fs_optim = SWAB32(UFS_OPTTIME);
+               usb1->fs_optim = cpu_to_fs32(sb, UFS_OPTTIME);
        
            case UFS_OPTTIME:
                request = uspi->s_fpb;
-               if (SWAB32(usb1->fs_cstotal.cs_nffree) < uspi->s_dsize *
+               if (fs32_to_cpu(sb, usb1->fs_cstotal.cs_nffree) < uspi->s_dsize *
                    (uspi->s_minfree - 2) / 100)
                        break;
-               usb1->fs_optim = SWAB32(UFS_OPTSPACE);
+               usb1->fs_optim = cpu_to_fs32(sb, UFS_OPTTIME);
                break;

See the problem?  Instead of hysteresis loop flipping between optspace and opttime
allocation policies, it *never* switches out of opttime.

That came in

commit 6293d56ca18db9ed322b2a5550ac7b27bd538cff
Author: Linus Torvalds <torvalds@athlon.transmeta.com>
Date:   Mon Feb 4 20:33:51 2002 -0800

    v2.4.14.6 -> v2.4.14.7
    
      - Jeff Garzik: network driver updates
      - Christoph Hellwig: UFS filesystem byteorder cleanups
      - me: modified Andrea VM page allocator tuning

so probably a typo in Christoph's patches, missed by everyone at the time.

And I would prefer to have the nffree levels at which we switch back and
forth precalculated at mount time.  I'll send a fix (along with those
for the last remaining xfstests failures) later today.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ufs: Fix build errors on 32 bit machines
  2017-06-17 18:23 ` Al Viro
@ 2017-06-17 18:51   ` Al Viro
  2017-06-18  9:30   ` Guenter Roeck
  1 sibling, 0 replies; 4+ messages in thread
From: Al Viro @ 2017-06-17 18:51 UTC (permalink / raw)
  To: Guenter Roeck; +Cc: Evgeniy Dushistov, Mark Brown, linux-kernel, Arnd Bergmann

On Sat, Jun 17, 2017 at 07:23:28PM +0100, Al Viro wrote:
> On Sat, Jun 17, 2017 at 10:35:13AM -0700, Guenter Roeck wrote:
> > Various 32 builds fail with error messages such as
> > 
> > ERROR: "__udivdi3" [fs/ufs/ufs.ko] undefined!
> > 
> > due to a variable type change from 32 bit to 64 bit.
> 
> Actually, that's not the only problem in that place.  The breakage
> came in 2.4.14.7; the critical part was this:
[snip]

Some background: there are two possible allocation policies for the
bad case of tail unpacking.  If a small (less than 192K, on typical
ufs1) file has the last block packed along with those of other files
and we can't just expand that tail in place, we need to find a place
for longer tail somewhere and copy the old data over there.

First policy: try and put it into a block already containing tail(s).
Kinder on space, higher odds of having to do relocation the next time
that tail needs to grow.  That's what OPTSPACE is.

Second policy: pick a free block and put the expanded tail there.
Better chance of being able to expand in place when/if the tail needs
to grow again, harsher on space.  That's OPTTIME.

The choice between those is controlled by the amount of space left
in partially filled blocks.  If it's high, we need to go for OPTSPACE,
if it's low - OPTTIME.  Cutoff values depend upon the amount of
space reserved for root; for 5% (default) it's "go for OPTSPACE when
more than 3% of total space are taken by free space in partially
filled blocks, go for OPTTIME when fragmentation is less than 2.5%,
stay with the previous state when it's between 2.5% and 3%".

(Christoph's?) typo in 2.4.14.7 has broken the switch from OPTTIME to
OPTSPACE; once in OPTTIME it's stuck in OPTTIME.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ufs: Fix build errors on 32 bit machines
  2017-06-17 18:23 ` Al Viro
  2017-06-17 18:51   ` Al Viro
@ 2017-06-18  9:30   ` Guenter Roeck
  1 sibling, 0 replies; 4+ messages in thread
From: Guenter Roeck @ 2017-06-18  9:30 UTC (permalink / raw)
  To: Al Viro; +Cc: Evgeniy Dushistov, Mark Brown, linux-kernel, Arnd Bergmann

On 06/17/2017 11:23 AM, Al Viro wrote:
> On Sat, Jun 17, 2017 at 10:35:13AM -0700, Guenter Roeck wrote:
>> Various 32 builds fail with error messages such as
>>
>> ERROR: "__udivdi3" [fs/ufs/ufs.ko] undefined!
>>
>> due to a variable type change from 32 bit to 64 bit.
> 
> Actually, that's not the only problem in that place.  The breakage
> came in 2.4.14.7; the critical part was this:
>              default:
> -               usb1->fs_optim = SWAB32(UFS_OPTTIME);
> +               usb1->fs_optim = cpu_to_fs32(sb, UFS_OPTTIME);
>          
>              case UFS_OPTTIME:
>                  request = uspi->s_fpb;
> -               if (SWAB32(usb1->fs_cstotal.cs_nffree) < uspi->s_dsize *
> +               if (fs32_to_cpu(sb, usb1->fs_cstotal.cs_nffree) < uspi->s_dsize *
>                      (uspi->s_minfree - 2) / 100)
>                          break;
> -               usb1->fs_optim = SWAB32(UFS_OPTSPACE);
> +               usb1->fs_optim = cpu_to_fs32(sb, UFS_OPTTIME);
>                  break;
> 
> See the problem?  Instead of hysteresis loop flipping between optspace and opttime
> allocation policies, it *never* switches out of opttime.
> 
Yes. Nice catch.

> That came in
> 
> commit 6293d56ca18db9ed322b2a5550ac7b27bd538cff
> Author: Linus Torvalds <torvalds@athlon.transmeta.com>
> Date:   Mon Feb 4 20:33:51 2002 -0800
> 
>      v2.4.14.6 -> v2.4.14.7
>      
>        - Jeff Garzik: network driver updates
>        - Christoph Hellwig: UFS filesystem byteorder cleanups
>        - me: modified Andrea VM page allocator tuning
> 
> so probably a typo in Christoph's patches, missed by everyone at the time.
> 
> And I would prefer to have the nffree levels at which we switch back and
> forth precalculated at mount time.  I'll send a fix (along with those
> for the last remaining xfstests failures) later today.
> 

Agreed, but wouldn't it be more important to get the code to compile for now ?
After all, optimizing the calculation is an enhancement, not a bug fix.

Thanks,
Guenter

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-06-18  9:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-17 17:35 [PATCH] ufs: Fix build errors on 32 bit machines Guenter Roeck
2017-06-17 18:23 ` Al Viro
2017-06-17 18:51   ` Al Viro
2017-06-18  9:30   ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).