mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH][linux-next] pnfs/blocklayout: Use do_div for 64 bit divide operations
@ 2014-09-19 17:30 Steven Rostedt
  2014-09-19 18:39 ` Trond Myklebust
  0 siblings, 1 reply; 3+ messages in thread
From: Steven Rostedt @ 2014-09-19 17:30 UTC (permalink / raw)
  To: LKML, linux-nfs; +Cc: Trond Myklebust, Christoph Hellwig


Commit 5c83746a0cf2 "pnfs/blocklayout: in-kernel GETDEVICEINFO XDR parsing"
added some open coded 64 bit divisions which caused the following
error on 32 bit builds:

fs/built-in.o: In function `bl_map_stripe':
fs/nfs/blocklayout/dev.c:153: undefined reference to `__udivdi3'
fs/nfs/blocklayout/dev.c:154: undefined reference to `__umoddi3'
fs/nfs/blocklayout/dev.c:168: undefined reference to `__udivdi3'

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
 fs/nfs/blocklayout/dev.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/fs/nfs/blocklayout/dev.c b/fs/nfs/blocklayout/dev.c
index 00f159da06ee..05d32e2175db 100644
--- a/fs/nfs/blocklayout/dev.c
+++ b/fs/nfs/blocklayout/dev.c
@@ -150,10 +150,18 @@ static bool bl_map_stripe(struct pnfs_block_dev *dev, u64 offset,
 		struct pnfs_block_dev_map *map)
 {
 	struct pnfs_block_dev *child;
-	u64 chunk = (offset / dev->chunk_size);
-	int chunk_idx = chunk % dev->nr_children;
+	u64 chunk;
+	u64 chunk_tmp;
+	int chunk_idx;
 	u64 disk_offset;
 
+	chunk = offset;
+	/* chunk = offset / dev->chunk_size */
+	do_div(chunk, dev->chunk_size);
+	chunk_tmp = chunk;
+	/* chunk_idx = chunk % dev->nr_children) */
+	chunk_idx = do_div(chunk_tmp, dev->nr_children);
+
 	if (chunk_idx > dev->nr_children) {
 		dprintk("%s: invalid chunk idx %d (%lld/%lld)\n",
 			__func__, chunk_idx, offset, dev->chunk_size);
@@ -165,7 +173,9 @@ static bool bl_map_stripe(struct pnfs_block_dev *dev, u64 offset,
 	offset = chunk * dev->chunk_size;
 
 	/* disk offset of the stripe */
-	disk_offset = offset / dev->nr_children;
+	disk_offset = offset;
+	/* disk_offset = offset / dev->nr_children */
+	do_div(disk_offset, dev->nr_children);
 
 	child = &dev->children[chunk_idx];
 	child->map(child, disk_offset, map);
-- 
1.8.1.4


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

* Re: [PATCH][linux-next] pnfs/blocklayout: Use do_div for 64 bit divide operations
  2014-09-19 17:30 [PATCH][linux-next] pnfs/blocklayout: Use do_div for 64 bit divide operations Steven Rostedt
@ 2014-09-19 18:39 ` Trond Myklebust
  2014-09-19 19:05   ` Steven Rostedt
  0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2014-09-19 18:39 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: LKML, Linux NFS Mailing List, Christoph Hellwig

Hi Steven,

On Fri, Sep 19, 2014 at 1:30 PM, Steven Rostedt <rostedt@goodmis.org> wrote:
>
> Commit 5c83746a0cf2 "pnfs/blocklayout: in-kernel GETDEVICEINFO XDR parsing"
> added some open coded 64 bit divisions which caused the following
> error on 32 bit builds:
>
> fs/built-in.o: In function `bl_map_stripe':
> fs/nfs/blocklayout/dev.c:153: undefined reference to `__udivdi3'
> fs/nfs/blocklayout/dev.c:154: undefined reference to `__umoddi3'
> fs/nfs/blocklayout/dev.c:168: undefined reference to `__udivdi3'
>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
>  fs/nfs/blocklayout/dev.c | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/fs/nfs/blocklayout/dev.c b/fs/nfs/blocklayout/dev.c
> index 00f159da06ee..05d32e2175db 100644
> --- a/fs/nfs/blocklayout/dev.c
> +++ b/fs/nfs/blocklayout/dev.c
> @@ -150,10 +150,18 @@ static bool bl_map_stripe(struct pnfs_block_dev *dev, u64 offset,
>                 struct pnfs_block_dev_map *map)
>  {
>         struct pnfs_block_dev *child;
> -       u64 chunk = (offset / dev->chunk_size);
> -       int chunk_idx = chunk % dev->nr_children;
> +       u64 chunk;
> +       u64 chunk_tmp;
> +       int chunk_idx;
>         u64 disk_offset;
>
> +       chunk = offset;
> +       /* chunk = offset / dev->chunk_size */
> +       do_div(chunk, dev->chunk_size);
> +       chunk_tmp = chunk;
> +       /* chunk_idx = chunk % dev->nr_children) */
> +       chunk_idx = do_div(chunk_tmp, dev->nr_children);
> +
>         if (chunk_idx > dev->nr_children) {
>                 dprintk("%s: invalid chunk idx %d (%lld/%lld)\n",
>                         __func__, chunk_idx, offset, dev->chunk_size);
> @@ -165,7 +173,9 @@ static bool bl_map_stripe(struct pnfs_block_dev *dev, u64 offset,
>         offset = chunk * dev->chunk_size;
>
>         /* disk offset of the stripe */
> -       disk_offset = offset / dev->nr_children;
> +       disk_offset = offset;
> +       /* disk_offset = offset / dev->nr_children */
> +       do_div(disk_offset, dev->nr_children);
>
>         child = &dev->children[chunk_idx];
>         child->map(child, disk_offset, map);
> --
> 1.8.1.4
>

Thanks. I posted a similar bugfix on the linux-nfs mailing list
yesterday. That hasn't been pushed to linux-next yet because Christoph
wanted to run it through some QA tests first.

Cheers
  Trond

-- 
Trond Myklebust

Linux NFS client maintainer, PrimaryData

trond.myklebust@primarydata.com

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

* Re: [PATCH][linux-next] pnfs/blocklayout: Use do_div for 64 bit divide operations
  2014-09-19 18:39 ` Trond Myklebust
@ 2014-09-19 19:05   ` Steven Rostedt
  0 siblings, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2014-09-19 19:05 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: LKML, Linux NFS Mailing List, Christoph Hellwig

On Fri, 19 Sep 2014 14:39:10 -0400
Trond Myklebust <trond.myklebust@primarydata.com> wrote:

> Thanks. I posted a similar bugfix on the linux-nfs mailing list
> yesterday. That hasn't been pushed to linux-next yet because Christoph
> wanted to run it through some QA tests first.

No problem. As long as it gets fixed before it breaks my test suite ;-)

-- Steve

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

end of thread, other threads:[~2014-09-19 19:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-19 17:30 [PATCH][linux-next] pnfs/blocklayout: Use do_div for 64 bit divide operations Steven Rostedt
2014-09-19 18:39 ` Trond Myklebust
2014-09-19 19:05   ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®