diff mbox

dm-space-map-disk: improve bit testing

Message ID 20110816100855.GD4284@ubuntu (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Joe Thornber Aug. 16, 2011, 10:08 a.m. UTC
On Mon, Aug 15, 2011 at 02:52:14PM -0400, Mikulas Patocka wrote:
> dm-space-map-disk: improve bit testing

Very nice, thanks.  btw, you can get rid of WORD_MASK_LOW too:


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
diff mbox

Patch

diff --git a/drivers/md/persistent-data/dm-space-map-disk.c b/drivers/md/persistent-data/dm-space-map-disk.c
index 8d2c4c2..fbfa6f3 100644
--- a/drivers/md/persistent-data/dm-space-map-disk.c
+++ b/drivers/md/persistent-data/dm-space-map-disk.c
@@ -69,7 +69,6 @@  void *dm_bitmap_data(struct dm_block *b)
 	return dm_block_data(b) + sizeof(struct disk_bitmap_header);
 }
 
-#define WORD_MASK_LOW 0x5555555555555555ULL
 #define WORD_MASK_HIGH 0xAAAAAAAAAAAAAAAAULL
 
 static unsigned bitmap_word_used(void *addr, unsigned b)
@@ -78,7 +77,7 @@  static unsigned bitmap_word_used(void *addr, unsigned b)
 	__le64 *w_le = words_le + (b >> ENTRIES_SHIFT);
 
 	uint64_t bits = le64_to_cpu(*w_le);
-	uint64_t mask = (bits - WORD_MASK_LOW) & WORD_MASK_HIGH;
+	uint64_t mask = (bits + WORD_MASK_HIGH + 1) & WORD_MASK_HIGH;
 
 	return !(~bits & mask);
 }