On Thu, Apr 15, 2004 at 01:40:27PM -0500, AJ Lewis wrote: > The attached patch against 2.6.5-udm4 fixes persistant mirror reactivation: > - count_bits() fxn was broken. It went into an infinite loop because n > was > never incremented. > - the size parameter passed into the find_*_bit fxns from count_bits() was > also wrong - it needs to be in bits, not bytes. Alasdair pointed me at the hweight* fxns - the attached patch is a replacement patch for the previous one I posted to use this to (hopefully) do the same thing more efficiently. So apply this instead of my previous patch. Regards, -- AJ Lewis Voice: 612-638-0500 Red Hat Inc. E-Mail: alewis@xxxxxxxxxx 720 Washington Ave. SE, Suite 200 Minneapolis, MN 55414 Current GPG fingerprint = FE77 4B43 6A9B F982 A731 02FA 2BF5 7574 294A AA5A Grab the key at: http://people.redhat.com/alewis/gpg.html or one of the many keyservers out there... -----Begin Obligatory Humorous Quote---------------------------------------- Your mouse has moved. Windows NT must be restarted for the change to take effect. Reboot now? [ OK ] -----End Obligatory Humorous Quote------------------------------------------
Exchange slow bit-by-bit count to use hweight32 to count bits per uint32_t --- diff/drivers/md/dm-log.c 2004-04-15 14:51:20.625892881 -0500 +++ source/drivers/md/dm-log.c 2004-04-15 14:48:12.293747603 -0500 @@ -424,25 +424,14 @@ core_dtr(log); } -static int count_bits(unsigned long *addr, unsigned size) +static int count_bits32(uint32_t *addr, unsigned size) { - /* FIXME: test this */ -#if 1 - int n, count = 0; + int count = 0, i; - n = find_first_bit(addr, size); - while (n < size) { - count++; - find_next_bit(addr, size, n + 1); + for (i = 0; i < size; i++) { + count += hweight32(*(addr+i)); } - - return count; -#else - int count = 0; - for (i = 0; i < lc->region_count; i++) - count += log_test_bit(lc->sync_bits, i); return count; -#endif } static int disk_resume(struct dirty_log *log) @@ -469,7 +458,7 @@ /* copy clean across to sync */ memcpy(lc->sync_bits, lc->clean_bits, size); - lc->sync_count = count_bits((unsigned long *) lc->clean_bits, size); + lc->sync_count = count_bits32(lc->clean_bits, lc->bitset_uint32_count); /* write the bits */ r = write_bits(lc);
Attachment:
pgppmawWXgbEr.pgp
Description: PGP signature