From patchwork Tue Aug 16 10:08:55 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Thornber X-Patchwork-Id: 1070902 Received: from mx4-phx2.redhat.com (mx4-phx2.redhat.com [209.132.183.25]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p7GAB3dI015796 for ; Tue, 16 Aug 2011 10:11:24 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx4-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p7GA931a004684; Tue, 16 Aug 2011 06:09:04 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p7GA92dj019866 for ; Tue, 16 Aug 2011 06:09:02 -0400 Received: from localhost (vpn1-6-145.ams2.redhat.com [10.36.6.145]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p7GA8uQP015377; Tue, 16 Aug 2011 06:08:56 -0400 Date: Tue, 16 Aug 2011 11:08:55 +0100 From: Joe Thornber To: Mikulas Patocka Message-ID: <20110816100855.GD4284@ubuntu> Mail-Followup-To: Mikulas Patocka , dm-devel@redhat.com References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com Subject: Re: [dm-devel] [PATCH] dm-space-map-disk: improve bit testing X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 16 Aug 2011 10:11:24 +0000 (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 --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); }