linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Linux next-20170407 failed to build on ARM due to usage of mod in btrfs code
@ 2017-04-08 16:02 Icenowy Zheng
  2017-04-08 17:45 ` Fabio Estevam
  0 siblings, 1 reply; 9+ messages in thread
From: Icenowy Zheng @ 2017-04-08 16:02 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba
  Cc: linux-btrfs, linux-kernel, linux-arm-kernel

Hello everyone,
Today I tried to build a kernel with btrfs enabled on ARM, then when 
linking I met such an error:

```
fs/built-in.o: In function `scrub_bio_end_io_worker':
acl.c:(.text+0x2f0450): undefined reference to `__aeabi_uldivmod'
fs/built-in.o: In function `scrub_extent_for_parity':
acl.c:(.text+0x2f0bcc): undefined reference to `__aeabi_uldivmod'
fs/built-in.o: In function `scrub_raid56_parity':
acl.c:(.text+0x2f12a8): undefined reference to `__aeabi_uldivmod'
acl.c:(.text+0x2f15c4): undefined reference to `__aeabi_uldivmod'
```

These functions are found at fs/btrfs/scrub.c .

After disabling btrfs the kernel is successfully built.

For this problem, see also [1], which used to be a similar bug in PL330 
driver code.

[1] https://patchwork.kernel.org/patch/5299081/

Thanks,
Icenowy

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

* Re: Linux next-20170407 failed to build on ARM due to usage of mod in btrfs code
  2017-04-08 16:02 Linux next-20170407 failed to build on ARM due to usage of mod in btrfs code Icenowy Zheng
@ 2017-04-08 17:45 ` Fabio Estevam
  2017-04-08 18:38   ` Adam Borowski
  2017-04-08 21:07   ` [PATCH] btrfs: scrub: use do_div() for 64-by-32 division Adam Borowski
  0 siblings, 2 replies; 9+ messages in thread
From: Fabio Estevam @ 2017-04-08 17:45 UTC (permalink / raw)
  To: Icenowy Zheng
  Cc: Chris Mason, Josef Bacik, David Sterba, linux-arm-kernel,
	linux-kernel, linux-btrfs

On Sat, Apr 8, 2017 at 1:02 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
> Hello everyone,
> Today I tried to build a kernel with btrfs enabled on ARM, then when linking
> I met such an error:
>
> ```
> fs/built-in.o: In function `scrub_bio_end_io_worker':
> acl.c:(.text+0x2f0450): undefined reference to `__aeabi_uldivmod'
> fs/built-in.o: In function `scrub_extent_for_parity':
> acl.c:(.text+0x2f0bcc): undefined reference to `__aeabi_uldivmod'
> fs/built-in.o: In function `scrub_raid56_parity':
> acl.c:(.text+0x2f12a8): undefined reference to `__aeabi_uldivmod'
> acl.c:(.text+0x2f15c4): undefined reference to `__aeabi_uldivmod'
> ```
>
> These functions are found at fs/btrfs/scrub.c .
>
> After disabling btrfs the kernel is successfully built.

I see the same error with ARM imx_v6_v7_defconfig + btrfs support.

Looks like it is caused by commit 7d0ef8b4dbbd220 ("Btrfs: update
scrub_parity to use u64 stripe_len").

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

* Re: Linux next-20170407 failed to build on ARM due to usage of mod in btrfs code
  2017-04-08 17:45 ` Fabio Estevam
@ 2017-04-08 18:38   ` Adam Borowski
  2017-04-08 21:07   ` [PATCH] btrfs: scrub: use do_div() for 64-by-32 division Adam Borowski
  1 sibling, 0 replies; 9+ messages in thread
From: Adam Borowski @ 2017-04-08 18:38 UTC (permalink / raw)
  To: Fabio Estevam
  Cc: Icenowy Zheng, Chris Mason, Josef Bacik, David Sterba,
	linux-arm-kernel, linux-kernel, linux-btrfs

On Sat, Apr 08, 2017 at 02:45:34PM -0300, Fabio Estevam wrote:
> On Sat, Apr 8, 2017 at 1:02 PM, Icenowy Zheng <icenowy@aosc.io> wrote:
> > Hello everyone,
> > Today I tried to build a kernel with btrfs enabled on ARM, then when linking
> > I met such an error:
> >
> > ```
> > fs/built-in.o: In function `scrub_bio_end_io_worker':
> > acl.c:(.text+0x2f0450): undefined reference to `__aeabi_uldivmod'
> > fs/built-in.o: In function `scrub_extent_for_parity':
> > acl.c:(.text+0x2f0bcc): undefined reference to `__aeabi_uldivmod'
> > fs/built-in.o: In function `scrub_raid56_parity':
> > acl.c:(.text+0x2f12a8): undefined reference to `__aeabi_uldivmod'
> > acl.c:(.text+0x2f15c4): undefined reference to `__aeabi_uldivmod'
> > ```
> >
> > These functions are found at fs/btrfs/scrub.c .
> >
> > After disabling btrfs the kernel is successfully built.
> 
> I see the same error with ARM imx_v6_v7_defconfig + btrfs support.
> 
> Looks like it is caused by commit 7d0ef8b4dbbd220 ("Btrfs: update
> scrub_parity to use u64 stripe_len").

+1, my bisect just finished, same bad commit.

-- 
⢀⣴⠾⠻⢶⣦⠀ Meow!
⣾⠁⢠⠒⠀⣿⡁
⢿⡄⠘⠷⠚⠋⠀ Collisions shmolisions, let's see them find a collision or second
⠈⠳⣄⠀⠀⠀⠀ preimage for double rot13!

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

* [PATCH] btrfs: scrub: use do_div() for 64-by-32 division
  2017-04-08 17:45 ` Fabio Estevam
  2017-04-08 18:38   ` Adam Borowski
@ 2017-04-08 21:07   ` Adam Borowski
  2017-04-09  3:58     ` Adam Borowski
                       ` (3 more replies)
  1 sibling, 4 replies; 9+ messages in thread
From: Adam Borowski @ 2017-04-08 21:07 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, linux-arm-kernel,
	linux-kernel, linux-btrfs, Icenowy Zheng, Fabio Estevam
  Cc: Adam Borowski

Unbreaks ARM and possibly other 32-bit architectures.

Fixes: 7d0ef8b4d: Btrfs: update scrub_parity to use u64 stripe_len
Reported-by: Icenowy Zheng <icenowy@aosc.io>
Signed-off-by: Adam Borowski <kilobyte@angband.pl>
---
You'd probably want to squash this with Liu's commit, to be nice to future
bisects.

Tested on amd64 where all is fine, and on arm (Odroid-U2) where scrub
sometimes works, but, like most operations, randomly dies with some badness
that doesn't look related: io_schedule, kunmap_high.  That badness wasn't
there in 4.11-rc5, needs investigating, but since it's not connected to our
issue at hand, I consider this patch sort-of tested.

 fs/btrfs/scrub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
index b6fe1cd08048..95372e3679f3 100644
--- a/fs/btrfs/scrub.c
+++ b/fs/btrfs/scrub.c
@@ -2407,7 +2407,7 @@ static inline void __scrub_mark_bitmap(struct scrub_parity *sparity,
 
 	start -= sparity->logic_start;
 	start = div64_u64_rem(start, sparity->stripe_len, &offset);
-	offset /= sectorsize;
+	do_div(offset, sectorsize);
 	nsectors = (int)len / sectorsize;
 
 	if (offset + nsectors <= sparity->nsectors) {
-- 
2.11.0

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

* Re: [PATCH] btrfs: scrub: use do_div() for 64-by-32 division
  2017-04-08 21:07   ` [PATCH] btrfs: scrub: use do_div() for 64-by-32 division Adam Borowski
@ 2017-04-09  3:58     ` Adam Borowski
  2017-04-10  1:13       ` Adam Borowski
  2017-04-10 11:13     ` David Sterba
                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Adam Borowski @ 2017-04-09  3:58 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, linux-arm-kernel,
	linux-kernel, linux-btrfs, Icenowy Zheng, Fabio Estevam

On Sat, Apr 08, 2017 at 11:07:37PM +0200, Adam Borowski wrote:
> Unbreaks ARM and possibly other 32-bit architectures.

Turns out those "other 32-bit architectures" happen to include i386.

A modular build:

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

With the patch, i386 builds fine.

> Tested on amd64 where all is fine, and on arm (Odroid-U2) where scrub
> sometimes works, but, like most operations, randomly dies with some badness
> that doesn't look related: io_schedule, kunmap_high.  That badness wasn't
> there in 4.11-rc5, needs investigating, but since it's not connected to our
> issue at hand, I consider this patch sort-of tested.

Looks like current -next is pretty broken: while amd64 is ok, on an i386 box
(non-NX Pentium 4) it hangs very early during boot, way before filesystem
modules would be loaded.  Qemu boots but has random hangs.

So it looks like it's compile only for now...

-- 
⢀⣴⠾⠻⢶⣦⠀ Meow!
⣾⠁⢠⠒⠀⣿⡁
⢿⡄⠘⠷⠚⠋⠀ Collisions shmolisions, let's see them find a collision or second
⠈⠳⣄⠀⠀⠀⠀ preimage for double rot13!

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

* Re: [PATCH] btrfs: scrub: use do_div() for 64-by-32 division
  2017-04-09  3:58     ` Adam Borowski
@ 2017-04-10  1:13       ` Adam Borowski
  0 siblings, 0 replies; 9+ messages in thread
From: Adam Borowski @ 2017-04-10  1:13 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, linux-arm-kernel,
	linux-kernel, linux-btrfs, Icenowy Zheng, Fabio Estevam

[-- Attachment #1: Type: text/plain, Size: 1858 bytes --]

On Sun, Apr 09, 2017 at 05:58:54AM +0200, Adam Borowski wrote:
> On Sat, Apr 08, 2017 at 11:07:37PM +0200, Adam Borowski wrote:
> > Unbreaks ARM and possibly other 32-bit architectures.
> 
> Turns out those "other 32-bit architectures" happen to include i386.
> 
> A modular build:
> ERROR: "__udivdi3" [fs/btrfs/btrfs.ko] undefined!
> With the patch, i386 builds fine.
> 
> > Tested on amd64 where all is fine, and on arm (Odroid-U2) where scrub
> > sometimes works, but, like most operations, randomly dies with some badness
> > that doesn't look related: io_schedule, kunmap_high.  That badness wasn't
> > there in 4.11-rc5, needs investigating, but since it's not connected to our
> > issue at hand, I consider this patch sort-of tested.
> 
> Looks like current -next is pretty broken: while amd64 is ok, on an i386 box
> (non-NX Pentium 4) it hangs very early during boot, way before filesystem
> modules would be loaded.  Qemu boots but has random hangs.

A non-modular i386_defconfig + btrfs of -next is ok; whatever the problem
is, it's not relevant to our division build failure in scrub.

But, it looks like parity scrub is ${EXPLETIVE}ed on 32-bit.  Not just on
-next, also on 4.11-rc5 and 4.9.  Test script I used is attached, although
it's enough to just scrub a kosher filesystem without even damaging it.
On 64-bit it mostly works, but still warns about bogus unrecoverable errors
when in fact it succeeded.

Thus, I'd recommend:
* applying this patch to at least make it compile
* taking steps to warn outside people about RAID5/6

Let's discuss the rest in another thread, it's no longer interesting to ARM
people, they just want no build failures.

-- 
⢀⣴⠾⠻⢶⣦⠀ Meow!
⣾⠁⢠⠒⠀⣿⡁
⢿⡄⠘⠷⠚⠋⠀ Collisions shmolisions, let's see them find a collision or second
⠈⠳⣄⠀⠀⠀⠀ preimage for double rot13!

[-- Attachment #2: scrubtest --]
[-- Type: text/plain, Size: 1299 bytes --]

#!/bin/sh
set -x
DATA=/usr/bin  # use whole /usr on non-bloated VMs


mkdir -p /mnt/vol1
umount /mnt/vol1; losetup -D   # clean up after repeats

dd if=/dev/zero bs=1048576 count=1 seek=4095 of=ra
dd if=/dev/zero bs=1048576 count=1 seek=4095 of=rb
dd if=/dev/zero bs=1048576 count=1 seek=4095 of=rc
dd if=/dev/zero bs=1048576 count=1 seek=4095 of=rd

mkfs.btrfs -draid10 -mraid1 ra rb rc rd

losetup -D
losetup -f ra
losetup -f rb
losetup -f rc
losetup -f rd
sleep 2  # race with fsid detection
mount -onoatime /dev/loop0 /mnt/vol1 || exit $?
cp -pr "$DATA" /mnt/vol1
btrfs fi sync /mnt/vol1
btrfs fi us /mnt/vol1

btrfs balance start -dconvert=raid5 -mconvert=raid6 /mnt/vol1

btrfs scrub start -B /mnt/vol1
btrfs scrub start -B /mnt/vol1

umount /mnt/vol1
dd if=/dev/urandom of=rd bs=1048576 seek=96 count=4000
mount -onoatime /dev/loop0 /mnt/vol1 || exit $?
btrfs scrub start -B /mnt/vol1
btrfs scrub start -B /mnt/vol1

btrfs balance start -dconvert=raid10 -mconvert=raid1 /mnt/vol1

btrfs scrub start -B /mnt/vol1
btrfs scrub start -B /mnt/vol1

umount /mnt/vol1
dd if=/dev/urandom of=rd bs=1048576 seek=96 count=4000
mount -onoatime /dev/loop0 /mnt/vol1 || exit $?
btrfs scrub start -B /mnt/vol1
btrfs scrub start -B /mnt/vol1

diff -urd --no-dereference "$DATA" /mnt/vol1/*

umount /mnt/vol1

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

* Re: [PATCH] btrfs: scrub: use do_div() for 64-by-32 division
  2017-04-08 21:07   ` [PATCH] btrfs: scrub: use do_div() for 64-by-32 division Adam Borowski
  2017-04-09  3:58     ` Adam Borowski
@ 2017-04-10 11:13     ` David Sterba
  2017-04-10 12:50     ` Austin S. Hemmelgarn
  2017-04-10 18:41     ` Liu Bo
  3 siblings, 0 replies; 9+ messages in thread
From: David Sterba @ 2017-04-10 11:13 UTC (permalink / raw)
  To: Adam Borowski
  Cc: Icenowy Zheng, Chris Mason, Josef Bacik, Fabio Estevam,
	linux-arm-kernel, linux-btrfs, linux-kernel

On Sat, Apr 08, 2017 at 11:07:37PM +0200, Adam Borowski wrote:
> Unbreaks ARM and possibly other 32-bit architectures.
> 
> Fixes: 7d0ef8b4d: Btrfs: update scrub_parity to use u64 stripe_len
> Reported-by: Icenowy Zheng <icenowy@aosc.io>
> Signed-off-by: Adam Borowski <kilobyte@angband.pl>
> ---
> You'd probably want to squash this with Liu's commit, to be nice to future
> bisects.

Thanks for finding it!

> Tested on amd64 where all is fine, and on arm (Odroid-U2) where scrub
> sometimes works, but, like most operations, randomly dies with some badness
> that doesn't look related: io_schedule, kunmap_high.  That badness wasn't
> there in 4.11-rc5, needs investigating, but since it's not connected to our
> issue at hand, I consider this patch sort-of tested.
> 
>  fs/btrfs/scrub.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
> index b6fe1cd08048..95372e3679f3 100644
> --- a/fs/btrfs/scrub.c
> +++ b/fs/btrfs/scrub.c
> @@ -2407,7 +2407,7 @@ static inline void __scrub_mark_bitmap(struct scrub_parity *sparity,
>  
>  	start -= sparity->logic_start;
>  	start = div64_u64_rem(start, sparity->stripe_len, &offset);
> -	offset /= sectorsize;
> +	do_div(offset, sectorsize);

I'll use the div_u64 helper instead, I don't want to reintroduce do_div
to fs/btrfs , for-next will be updated in a minute.

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

* Re: [PATCH] btrfs: scrub: use do_div() for 64-by-32 division
  2017-04-08 21:07   ` [PATCH] btrfs: scrub: use do_div() for 64-by-32 division Adam Borowski
  2017-04-09  3:58     ` Adam Borowski
  2017-04-10 11:13     ` David Sterba
@ 2017-04-10 12:50     ` Austin S. Hemmelgarn
  2017-04-10 18:41     ` Liu Bo
  3 siblings, 0 replies; 9+ messages in thread
From: Austin S. Hemmelgarn @ 2017-04-10 12:50 UTC (permalink / raw)
  To: Adam Borowski, Chris Mason, Josef Bacik, David Sterba,
	linux-arm-kernel, linux-kernel, linux-btrfs, Icenowy Zheng,
	Fabio Estevam

On 2017-04-08 17:07, Adam Borowski wrote:
> Unbreaks ARM and possibly other 32-bit architectures.
>
> Fixes: 7d0ef8b4d: Btrfs: update scrub_parity to use u64 stripe_len
> Reported-by: Icenowy Zheng <icenowy@aosc.io>
> Signed-off-by: Adam Borowski <kilobyte@angband.pl>
> ---
> You'd probably want to squash this with Liu's commit, to be nice to future
> bisects.
>
> Tested on amd64 where all is fine, and on arm (Odroid-U2) where scrub
> sometimes works, but, like most operations, randomly dies with some badness
> that doesn't look related: io_schedule, kunmap_high.  That badness wasn't
> there in 4.11-rc5, needs investigating, but since it's not connected to our
> issue at hand, I consider this patch sort-of tested.
>
>  fs/btrfs/scrub.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
> index b6fe1cd08048..95372e3679f3 100644
> --- a/fs/btrfs/scrub.c
> +++ b/fs/btrfs/scrub.c
> @@ -2407,7 +2407,7 @@ static inline void __scrub_mark_bitmap(struct scrub_parity *sparity,
>
>  	start -= sparity->logic_start;
>  	start = div64_u64_rem(start, sparity->stripe_len, &offset);
> -	offset /= sectorsize;
> +	do_div(offset, sectorsize);
>  	nsectors = (int)len / sectorsize;
>
>  	if (offset + nsectors <= sparity->nsectors) {
>
Also fixes things on:
32-bit MIPS (eb and el variants)
32-bit SPARC
32-bit PPC

You can add my Tested-by if you want.

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

* Re: [PATCH] btrfs: scrub: use do_div() for 64-by-32 division
  2017-04-08 21:07   ` [PATCH] btrfs: scrub: use do_div() for 64-by-32 division Adam Borowski
                       ` (2 preceding siblings ...)
  2017-04-10 12:50     ` Austin S. Hemmelgarn
@ 2017-04-10 18:41     ` Liu Bo
  3 siblings, 0 replies; 9+ messages in thread
From: Liu Bo @ 2017-04-10 18:41 UTC (permalink / raw)
  To: Adam Borowski
  Cc: Chris Mason, Josef Bacik, David Sterba, linux-arm-kernel,
	linux-kernel, linux-btrfs, Icenowy Zheng, Fabio Estevam

On Sat, Apr 08, 2017 at 11:07:37PM +0200, Adam Borowski wrote:
> Unbreaks ARM and possibly other 32-bit architectures.
>

Thanks a lot for the fix.

Reviewed-by: Liu Bo <bo.li.liu@oracle.com>

Thanks,

-liubo

> Fixes: 7d0ef8b4d: Btrfs: update scrub_parity to use u64 stripe_len
> Reported-by: Icenowy Zheng <icenowy@aosc.io>
> Signed-off-by: Adam Borowski <kilobyte@angband.pl>
> ---
> You'd probably want to squash this with Liu's commit, to be nice to future
> bisects.
> 
> Tested on amd64 where all is fine, and on arm (Odroid-U2) where scrub
> sometimes works, but, like most operations, randomly dies with some badness
> that doesn't look related: io_schedule, kunmap_high.  That badness wasn't
> there in 4.11-rc5, needs investigating, but since it's not connected to our
> issue at hand, I consider this patch sort-of tested.
> 
>  fs/btrfs/scrub.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c
> index b6fe1cd08048..95372e3679f3 100644
> --- a/fs/btrfs/scrub.c
> +++ b/fs/btrfs/scrub.c
> @@ -2407,7 +2407,7 @@ static inline void __scrub_mark_bitmap(struct scrub_parity *sparity,
>  
>  	start -= sparity->logic_start;
>  	start = div64_u64_rem(start, sparity->stripe_len, &offset);
> -	offset /= sectorsize;
> +	do_div(offset, sectorsize);
>  	nsectors = (int)len / sectorsize;
>  
>  	if (offset + nsectors <= sparity->nsectors) {
> -- 
> 2.11.0
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

end of thread, other threads:[~2017-04-10 18:44 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-08 16:02 Linux next-20170407 failed to build on ARM due to usage of mod in btrfs code Icenowy Zheng
2017-04-08 17:45 ` Fabio Estevam
2017-04-08 18:38   ` Adam Borowski
2017-04-08 21:07   ` [PATCH] btrfs: scrub: use do_div() for 64-by-32 division Adam Borowski
2017-04-09  3:58     ` Adam Borowski
2017-04-10  1:13       ` Adam Borowski
2017-04-10 11:13     ` David Sterba
2017-04-10 12:50     ` Austin S. Hemmelgarn
2017-04-10 18:41     ` Liu Bo

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).