From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcin Slusarz Subject: Re: [PATCH 6/8] omfs: add bitmap routines Date: Sun, 20 Apr 2008 00:03:12 +0200 Message-ID: <20080419220307.GB7888@joi> References: <1208637457-24969-7-git-send-email-me@bobcopeland.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: akpm@linux-foundation.org, hch@infradead.org, alan@lxorguk.ukuu.org.uk, miklos@szeredi.hu, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org To: Bob Copeland Return-path: Received: from fg-out-1718.google.com ([72.14.220.158]:8184 "EHLO fg-out-1718.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756164AbYDSWDr (ORCPT ); Sat, 19 Apr 2008 18:03:47 -0400 Received: by fg-out-1718.google.com with SMTP id l27so1125462fgb.17 for ; Sat, 19 Apr 2008 15:03:44 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1208637457-24969-7-git-send-email-me@bobcopeland.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: On Sat, Apr 19, 2008 at 04:37:35PM -0400, Bob Copeland wrote: > +unsigned long omfs_count_free(struct super_block *sb) > +{ > + unsigned int i, j; > + u64 *map; > + unsigned long sum = 0; > + struct omfs_sb_info *sbi = OMFS_SB(sb); > + > + for (i = 0; i < sbi->s_imap_size; i++) { > + map = (u64 *) sbi->s_imap[i]; > + for (j = 0; j < sb->s_blocksize / 8; j++) > + sum += hweight64(~map[j]); > + } > + return sum; > +} I think inner loop can be replaced with something like: sum += sb->s_blocksize * 8 - bitmap_weight(map, sb->s_blocksize * 8); Marcin