[SRU,Xenial] nbd: fix 64-bit division

Message ID 20180606122223.29829-1-juergh@canonical.com
State New
Headers show
Series
  • [SRU,Xenial] nbd: fix 64-bit division
Related show

Commit Message

Juerg Haefliger June 6, 2018, 12:22 p.m.
From: Jens Axboe <axboe@fb.com>

BugLink: http://bugs.launchpad.net/bugs/1772575

We have this:

ERROR: "__aeabi_ldivmod" [drivers/block/nbd.ko] undefined!
ERROR: "__divdi3" [drivers/block/nbd.ko] undefined!
nbd.c:(.text+0x247c72): undefined reference to `__divdi3'

due to a recent commit, that did 64-bit division. Use the proper
divider function so that 32-bit compiles don't break.

Fixes: ef77b515243b ("nbd: use loff_t for blocksize and nbd_set_size args")
Signed-off-by: Jens Axboe <axboe@fb.com>
(cherry picked from commit e88f72cb9f54f6d244e55f629fe5e2f34ca6f9ed)
Signed-off-by: Juerg Haefliger <juergh@canonical.com>
---
 drivers/block/nbd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Juerg Haefliger June 6, 2018, 12:23 p.m. | #1
We also need this patch to prevent compilation errors on non-64bit arches.

...Juerg

On 06/06/2018 02:22 PM, Juerg Haefliger wrote:
> From: Jens Axboe <axboe@fb.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1772575
> 
> We have this:
> 
> ERROR: "__aeabi_ldivmod" [drivers/block/nbd.ko] undefined!
> ERROR: "__divdi3" [drivers/block/nbd.ko] undefined!
> nbd.c:(.text+0x247c72): undefined reference to `__divdi3'
> 
> due to a recent commit, that did 64-bit division. Use the proper
> divider function so that 32-bit compiles don't break.
> 
> Fixes: ef77b515243b ("nbd: use loff_t for blocksize and nbd_set_size args")
> Signed-off-by: Jens Axboe <axboe@fb.com>
> (cherry picked from commit e88f72cb9f54f6d244e55f629fe5e2f34ca6f9ed)
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
> ---
>  drivers/block/nbd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 673632c301dc..754b6fd9d2f4 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -750,7 +750,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
>  
>  	case NBD_SET_SIZE:
>  		return nbd_size_set(nbd, bdev, nbd->blksize,
> -				    arg / nbd->blksize);
> +					div_s64(arg, nbd->blksize));
>  
>  	case NBD_SET_SIZE_BLOCKS:
>  		return nbd_size_set(nbd, bdev, nbd->blksize, arg);
>
Thadeu Lima de Souza Cascardo June 6, 2018, 12:29 p.m. | #2
On Wed, Jun 06, 2018 at 02:22:23PM +0200, Juerg Haefliger wrote:
> From: Jens Axboe <axboe@fb.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1772575
> 
> We have this:
> 
> ERROR: "__aeabi_ldivmod" [drivers/block/nbd.ko] undefined!
> ERROR: "__divdi3" [drivers/block/nbd.ko] undefined!
> nbd.c:(.text+0x247c72): undefined reference to `__divdi3'
> 
> due to a recent commit, that did 64-bit division. Use the proper
> divider function so that 32-bit compiles don't break.
> 
> Fixes: ef77b515243b ("nbd: use loff_t for blocksize and nbd_set_size args")
> Signed-off-by: Jens Axboe <axboe@fb.com>
> (cherry picked from commit e88f72cb9f54f6d244e55f629fe5e2f34ca6f9ed)
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
> ---
>  drivers/block/nbd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 673632c301dc..754b6fd9d2f4 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -750,7 +750,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
>  
>  	case NBD_SET_SIZE:
>  		return nbd_size_set(nbd, bdev, nbd->blksize,
> -				    arg / nbd->blksize);
> +					div_s64(arg, nbd->blksize));
>  
>  	case NBD_SET_SIZE_BLOCKS:
>  		return nbd_size_set(nbd, bdev, nbd->blksize, arg);
> -- 
> 2.17.1

Acked-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
Stefan Bader June 6, 2018, 12:57 p.m. | #3
On 06.06.2018 05:22, Juerg Haefliger wrote:
> From: Jens Axboe <axboe@fb.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1772575
> 
> We have this:
> 
> ERROR: "__aeabi_ldivmod" [drivers/block/nbd.ko] undefined!
> ERROR: "__divdi3" [drivers/block/nbd.ko] undefined!
> nbd.c:(.text+0x247c72): undefined reference to `__divdi3'
> 
> due to a recent commit, that did 64-bit division. Use the proper
> divider function so that 32-bit compiles don't break.
> 
> Fixes: ef77b515243b ("nbd: use loff_t for blocksize and nbd_set_size args")
> Signed-off-by: Jens Axboe <axboe@fb.com>
> (cherry picked from commit e88f72cb9f54f6d244e55f629fe5e2f34ca6f9ed)
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>

> ---
>  drivers/block/nbd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 673632c301dc..754b6fd9d2f4 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -750,7 +750,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
>  
>  	case NBD_SET_SIZE:
>  		return nbd_size_set(nbd, bdev, nbd->blksize,
> -				    arg / nbd->blksize);
> +					div_s64(arg, nbd->blksize));
>  
>  	case NBD_SET_SIZE_BLOCKS:
>  		return nbd_size_set(nbd, bdev, nbd->blksize, arg);
>
Juerg Haefliger June 6, 2018, 2:03 p.m. | #4
Applied to xenial/master-next.

...Juerg

On 06/06/2018 02:22 PM, Juerg Haefliger wrote:
> From: Jens Axboe <axboe@fb.com>
> 
> BugLink: http://bugs.launchpad.net/bugs/1772575
> 
> We have this:
> 
> ERROR: "__aeabi_ldivmod" [drivers/block/nbd.ko] undefined!
> ERROR: "__divdi3" [drivers/block/nbd.ko] undefined!
> nbd.c:(.text+0x247c72): undefined reference to `__divdi3'
> 
> due to a recent commit, that did 64-bit division. Use the proper
> divider function so that 32-bit compiles don't break.
> 
> Fixes: ef77b515243b ("nbd: use loff_t for blocksize and nbd_set_size args")
> Signed-off-by: Jens Axboe <axboe@fb.com>
> (cherry picked from commit e88f72cb9f54f6d244e55f629fe5e2f34ca6f9ed)
> Signed-off-by: Juerg Haefliger <juergh@canonical.com>
> ---
>  drivers/block/nbd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 673632c301dc..754b6fd9d2f4 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -750,7 +750,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
>  
>  	case NBD_SET_SIZE:
>  		return nbd_size_set(nbd, bdev, nbd->blksize,
> -				    arg / nbd->blksize);
> +					div_s64(arg, nbd->blksize));
>  
>  	case NBD_SET_SIZE_BLOCKS:
>  		return nbd_size_set(nbd, bdev, nbd->blksize, arg);
>

Patch

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 673632c301dc..754b6fd9d2f4 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -750,7 +750,7 @@  static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
 
 	case NBD_SET_SIZE:
 		return nbd_size_set(nbd, bdev, nbd->blksize,
-				    arg / nbd->blksize);
+					div_s64(arg, nbd->blksize));
 
 	case NBD_SET_SIZE_BLOCKS:
 		return nbd_size_set(nbd, bdev, nbd->blksize, arg);