Skip to contentSkip to conversation

Btrfs: fix compile warning from __btrfs_map_block

PATCH In review liubo 2 participants 3 messages Mar 31, 2011 – Apr 1, 2011 1 message not in the archive Btrfs file system

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

liubo

author
#1 lore raw

PATCH 1/1 Btrfs: fix compile warning from __btrfs_map_block

While compile btrfs modules on 32bit box, I encounter the following:

WARNING: "__umoddi3" [fs/btrfs/btrfs.ko] undefined!

The WARNING comes from that __btrfs_map_block does not use do_div() for relative operations, this will cause problems on 32bit box, for values with "u64" type should use do_div() instead of a direct "%".

---
 fs/btrfs/volumes.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)
fs/btrfs/volumes.c +15 -8
index 41afd50..7b23d0f 100644
@@ -3076,16 +3076,19 @@ again:
 			multi->stripes[i].dev = map->stripes[stripe_index].dev;
 
 			if (map->type & BTRFS_BLOCK_GROUP_RAID0) {
-				u64 stripes;
-				int last_stripe = (stripe_nr_end - 1) %
-					map->num_stripes;
+				u64 stripes = stripe_nr_end - 1;
+				int last_stripe = do_div(stripes,
+					map->num_stripes);
 				int j;
 
 				for (j = 0; j < map->num_stripes; j++) {
-					if ((stripe_nr_end - 1 - j) %
-					      map->num_stripes == stripe_index)
+					stripes = stripe_nr_end - 1 - j;
+
+					if (do_div(stripes, map->num_stripes) ==
+					    stripe_index)
 						break;
 				}
+
 				stripes = stripe_nr_end - 1 - j;
 				do_div(stripes, map->num_stripes);
 				multi->stripes[i].length = map->stripe_len *
@@ -3100,18 +3103,22 @@ again:
 					multi->stripes[i].length -=
 						stripe_end_offset;
 			} else if (map->type & BTRFS_BLOCK_GROUP_RAID10) {
-				u64 stripes;
+				u64 stripes = stripe_nr_end - 1;
 				int j;
 				int factor = map->num_stripes /
 					     map->sub_stripes;
-				int last_stripe = (stripe_nr_end - 1) % factor;
+				int last_stripe = do_div(stripes, factor);
+
 				last_stripe *= map->sub_stripes;
 
 				for (j = 0; j < factor; j++) {
-					if ((stripe_nr_end - 1 - j) % factor ==
+					stripes = stripe_nr_end - 1 - j;
+
+					if (do_div(stripes, factor) ==
 					    stripe_index / map->sub_stripes)
 						break;
 				}
+
 				stripes = stripe_nr_end - 1 - j;
 				do_div(stripes, factor);
 				multi->stripes[i].length = map->stripe_len *
Signature · 1 line
1.6.5.2
#2 lore raw

Excerpts from liubo's message of 2011-03-31 05:45:20 -0400:

Quoted 8 lines

While compile btrfs modules on 32bit box, I encounter the following:

WARNING: "__umoddi3" [fs/btrfs/btrfs.ko] undefined!

The WARNING comes from that __btrfs_map_block does not use do_div() for relative operations, this will cause problems on 32bit box, for values with "u64" type should use do_div() instead of a direct "%".

Which kernel tree was this against? I had rebased the for-linus and for-linus-unmerged branch to get rid of it.

Sorry for the confusion.

-chris

Quoted 61 lines
---
 fs/btrfs/volumes.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)
fs/btrfs/volumes.c +15 -8
index 41afd50..7b23d0f 100644
@@ -3076,16 +3076,19 @@ again:
             multi->stripes[i].dev = map->stripes[stripe_index].dev;
 
             if (map->type & BTRFS_BLOCK_GROUP_RAID0) {
-                u64 stripes;
-                int last_stripe = (stripe_nr_end - 1) %
-                    map->num_stripes;
+                u64 stripes = stripe_nr_end - 1;
+                int last_stripe = do_div(stripes,
+                    map->num_stripes);
                 int j;
 
                 for (j = 0; j < map->num_stripes; j++) {
-                    if ((stripe_nr_end - 1 - j) %
-                          map->num_stripes == stripe_index)
+                    stripes = stripe_nr_end - 1 - j;
+
+                    if (do_div(stripes, map->num_stripes) ==
+                        stripe_index)
                         break;
                 }
+
                 stripes = stripe_nr_end - 1 - j;
                 do_div(stripes, map->num_stripes);
                 multi->stripes[i].length = map->stripe_len *
@@ -3100,18 +3103,22 @@ again:
                     multi->stripes[i].length -=
                         stripe_end_offset;
             } else if (map->type & BTRFS_BLOCK_GROUP_RAID10) {
-                u64 stripes;
+                u64 stripes = stripe_nr_end - 1;
                 int j;
                 int factor = map->num_stripes /
                          map->sub_stripes;
-                int last_stripe = (stripe_nr_end - 1) % factor;
+                int last_stripe = do_div(stripes, factor);
+
                 last_stripe *= map->sub_stripes;
 
                 for (j = 0; j < factor; j++) {
-                    if ((stripe_nr_end - 1 - j) % factor ==
+                    stripes = stripe_nr_end - 1 - j;
+
+                    if (do_div(stripes, factor) ==
                         stripe_index / map->sub_stripes)
                         break;
                 }
+
                 stripes = stripe_nr_end - 1 - j;
                 do_div(stripes, factor);
                 multi->stripes[i].length = map->stripe_len *
author
#3 lore raw
Quoted 5 lines · Chris Mason

Excerpts from liubo's message of 2011-03-31 05:45:20 -0400:

Quoted 4 lines

While compile btrfs modules on 32bit box, I encounter the following:

WARNING: "__umoddi3" [fs/btrfs/btrfs.ko] undefined!

Quoted 8 lines
Quoted 3 lines

The WARNING comes from that __btrfs_map_block does not use do_div() for relative operations, this will cause problems on 32bit box, for values with "u64" type should use do_div() instead of a direct "%".

Which kernel tree was this against? I had rebased the for-linus and for-linus-unmerged branch to get rid of it.

Sorry for the confusion.

Ah, it is my fault to neglect the version, I found this warning while compiling the latest for-linus tree (top commit: c1e1f82c56af1a286fd747e809c94628c2ca15fb).

thanks,
liubo

Quoted 68 lines

-chris

Quoted 50 lines
---
 fs/btrfs/volumes.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)
fs/btrfs/volumes.c +11 -8
index 41afd50..7b23d0f 100644
@@ -3076,16 +3076,19 @@ again:
             multi->stripes[i].dev = map->stripes[stripe_index].dev;
 
             if (map->type & BTRFS_BLOCK_GROUP_RAID0) {
-                u64 stripes;
-                int last_stripe = (stripe_nr_end - 1) %
-                    map->num_stripes;
+                u64 stripes = stripe_nr_end - 1;
+                int last_stripe = do_div(stripes,
+                    map->num_stripes);
                 int j;
 
                 for (j = 0; j < map->num_stripes; j++) {
-                    if ((stripe_nr_end - 1 - j) %
-                          map->num_stripes == stripe_index)
+                    stripes = stripe_nr_end - 1 - j;
+
+                    if (do_div(stripes, map->num_stripes) ==
+                        stripe_index)
                         break;
                 }
+
                 stripes = stripe_nr_end - 1 - j;
                 do_div(stripes, map->num_stripes);
                 multi->stripes[i].length = map->stripe_len *
@@ -3100,18 +3103,22 @@ again:
                     multi->stripes[i].length -=
                         stripe_end_offset;
             } else if (map->type & BTRFS_BLOCK_GROUP_RAID10) {
-                u64 stripes;
+                u64 stripes = stripe_nr_end - 1;
                 int j;
                 int factor = map->num_stripes /
                          map->sub_stripes;
-                int last_stripe = (stripe_nr_end - 1) % factor;
+                int last_stripe = do_div(stripes, factor);
+
                 last_stripe *= map->sub_stripes;
 
                 for (j = 0; j < factor; j++) {
-                    if ((stripe_nr_end - 1 - j) % factor ==

fs/btrfs/volumes.c again: · line 3124

Quoted 10 lines
fs/btrfs/volumes.c +4 -0
+                    stripes = stripe_nr_end - 1 - j;
+
+                    if (do_div(stripes, factor) ==
                         stripe_index / map->sub_stripes)
                         break;
                 }
+
                 stripes = stripe_nr_end - 1 - j;
                 do_div(stripes, factor);
                 multi->stripes[i].length = map->stripe_len *

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html