Skip to contentSkip to conversation

avoid long long division in _hash_fn

PATCH In review Lars Marowsky-Bree 2 participants 2 messages Feb 21, 2005 – Feb 22, 2005 DRBD driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 avoid long long division in _hash_fn

sector_t might be 64 bit, but long long divisions aren't supported in kernel space in i386. This patch adds a straightforward cast to avoid an unresolved symbol for __umoddi3.

drbd_main.c (working copy) renamed from drbd_main.c (revision 1763) +2 -2
Index: drbd/drbd_main.c
===================================================================
@@ -164,7 +164,7 @@
 
 STATIC unsigned int tl_hash_fn(drbd_dev *mdev, sector_t sector)
 {
-       return (sector>>HT_SHIFT) % mdev->tl_hash_s;
+       return (unsigned int)(sector>>HT_SHIFT) % mdev->tl_hash_s;
 }
 
 
@@ -367,7 +367,7 @@
 
 STATIC unsigned int ee_hash_fn(drbd_dev *mdev, sector_t sector)
 {
-       return (sector>>HT_SHIFT) % mdev->ee_hash_s;
+       return (unsigned int)(sector>>HT_SHIFT) % mdev->ee_hash_s;
 }
 
 STATIC int overlaps(sector_t s1, int l1, sector_t s2, int l2)

Sincerely,
Lars Marowsky-Brée <[email protected]>

Signature · 3 lines
High Availability & Clustering
SUSE Labs, Research and Development
SUSE LINUX Products GmbH - A Novell Business
maintainer
#1 lore raw

Am Montag, 21. Februar 2005 18:11 schrieb Lars Marowsky-Bree:

Quoted 28 lines

sector_t might be 64 bit, but long long divisions aren't supported in kernel space in i386. This patch adds a straightforward cast to avoid an unresolved symbol for __umoddi3.

Index: drbd/drbd_main.c
===================================================================

drbd_main.c (working copy) renamed from drbd_main.c (revision 1763) +2 -2
@@ -164,7 +164,7 @@
 
 STATIC unsigned int tl_hash_fn(drbd_dev *mdev, sector_t sector)
 {
-       return (sector>>HT_SHIFT) % mdev->tl_hash_s;
+       return (unsigned int)(sector>>HT_SHIFT) % mdev->tl_hash_s;
 }
 
 
@@ -367,7 +367,7 @@
 
 STATIC unsigned int ee_hash_fn(drbd_dev *mdev, sector_t sector)
 {
-       return (sector>>HT_SHIFT) % mdev->ee_hash_s;
+       return (unsigned int)(sector>>HT_SHIFT) % mdev->ee_hash_s;
 }
 
 STATIC int overlaps(sector_t s1, int l1, sector_t s2, int l2)
Quoted 2 lines

Sincerely,
Lars Marowsky-Brée <[email protected]>

Both patches found their way into SVN...

-phil

Signature · 3 lines
: Dipl-Ing Philipp Reisner                      Tel +43-1-8178292-50 :
: LINBIT Information Technologies GmbH          Fax +43-1-8178292-82 :
: Schönbrunnerstr 244, 1120 Vienna, Austria    http://www.linbit.com :