public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Use do_div() instead of native 64-bit division in btrfs_ordered_sum_size()
@ 2008-07-22  3:32 David Woodhouse
  2008-07-22  3:36 ` kernel BUG at extent_map.c:275! David Woodhouse
  2008-07-23 11:13 ` [PATCH] Use do_div() instead of native 64-bit division in btrfs_ordered_sum_size() Christoph Hellwig
  0 siblings, 2 replies; 15+ messages in thread
From: David Woodhouse @ 2008-07-22  3:32 UTC (permalink / raw)
  To: linux-btrfs

Prevents the compiler emitting calls to __udivdi3() from libgcc on some
platforms:
WARNING: "__udivdi3" [/shiny/git/btrfs-kernel-unstable/btrfs.ko] undefi=
ned!

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
---
Untested but ObviouslyCorrect=E2=84=A2. Now that I can load the module,=
 I hit a
BUG() immediately -- but I don't think it's caused by this patch. qv.

diff --git a/ordered-data.h b/ordered-data.h
index 1794efd..1abe5f5 100644
--- a/ordered-data.h
+++ b/ordered-data.h
@@ -97,9 +97,12 @@ struct btrfs_ordered_extent {
  */
 static inline int btrfs_ordered_sum_size(struct btrfs_root *root, u64 =
bytes)
 {
-	unsigned long num_sectors =3D (bytes + root->sectorsize - 1) /
-		root->sectorsize;
-	num_sectors++;
+	unsigned long num_sectors;
+
+	bytes +=3D root->sectorsize - 1;
+	do_div(bytes, root->sectorsize);
+	num_sectors =3D bytes + 1;
+
 	return sizeof(struct btrfs_ordered_sum) +
 		num_sectors * sizeof(struct btrfs_sector_sum);
 }

--=20
David Woodhouse                            Open Source Technology Centr=
e
David.Woodhouse@intel.com                              Intel Corporatio=
n


--
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 related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2008-07-24 14:34 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-22  3:32 [PATCH] Use do_div() instead of native 64-bit division in btrfs_ordered_sum_size() David Woodhouse
2008-07-22  3:36 ` kernel BUG at extent_map.c:275! David Woodhouse
2008-07-22 10:21   ` Chris Mason
2008-07-22 14:35     ` David Woodhouse
2008-07-22 17:03       ` Chris Mason
2008-07-22 17:41         ` David Woodhouse
2008-07-22 17:42           ` Zach Brown
2008-07-22 18:04             ` David Woodhouse
2008-07-24 14:34               ` Chris Mason
2008-07-22 18:12           ` Chris Mason
2008-07-22 14:43   ` [PATCH] Remove BUG_ON(spin_trylock()) checks which have false positives on UP David Woodhouse
2008-07-23 11:13 ` [PATCH] Use do_div() instead of native 64-bit division in btrfs_ordered_sum_size() Christoph Hellwig
2008-07-23 13:28   ` Chris Mason
2008-07-23 21:07     ` David Woodhouse
2008-07-24  0:19       ` Chris Mason

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