From: Andreas Dilger <adilger@dilger.ca>
To: Akinobu Mita <akinobu.mita@gmail.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
Akinobu Mita <akinobu.mita@gmail.com>,
"Theodore Ts'o" <tytso@mit.edu>,
Andreas Dilger <adilger.kernel@dilger.ca>,
"linux-ext4@vger.kernel.org" <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH v2 10/10] ext4: use memweight()
Date: Sat, 2 Jun 2012 08:35:23 -0600 [thread overview]
Message-ID: <B6D8D29B-9D9E-4248-B1EE-703D46354522@dilger.ca> (raw)
In-Reply-To: <1338644416-11417-10-git-send-email-akinobu.mita@gmail.com>
On 2012-06-02, at 7:40, Akinobu Mita <akinobu.mita@gmail.com> wrote:
> Use memweight() to count the total number of bits clear in memory area.
> This change only affects the code segments enabled by EXT4FS_DEBUG.
Personally, I'd rather still keep a thin wrapper ext4_count_free() and put the memweight() call and math inside that. The function name ext4_count_free() is meaningful to readers, while memweight() is much less so.
Cheers, Andreas
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Cc: "Theodore Ts'o" <tytso@mit.edu>
> Cc: Andreas Dilger <adilger.kernel@dilger.ca>
> Cc: linux-ext4@vger.kernel.org
> ---
>
> v2: don't remove bitmap.c which now has other than ext4_count_free()
>
> fs/ext4/balloc.c | 3 ++-
> fs/ext4/bitmap.c | 18 ------------------
> fs/ext4/ext4.h | 1 -
> fs/ext4/ialloc.c | 4 +++-
> 4 files changed, 5 insertions(+), 21 deletions(-)
>
> diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
> index 99b6324..e5eadfe 100644
> --- a/fs/ext4/balloc.c
> +++ b/fs/ext4/balloc.c
> @@ -609,7 +609,8 @@ ext4_fsblk_t ext4_count_free_clusters(struct super_block *sb)
> if (bitmap_bh == NULL)
> continue;
>
> - x = ext4_count_free(bitmap_bh, sb->s_blocksize);
> + x = sb->s_blocksize * BITS_PER_BYTE -
> + memweight(bitmap_bh->b_data, sb->s_blocksize);
> printk(KERN_DEBUG "group %u: stored = %d, counted = %u\n",
> i, ext4_free_group_clusters(sb, gdp), x);
> bitmap_count += x;
> diff --git a/fs/ext4/bitmap.c b/fs/ext4/bitmap.c
> index b319721..3c67c97 100644
> --- a/fs/ext4/bitmap.c
> +++ b/fs/ext4/bitmap.c
> @@ -11,24 +11,6 @@
> #include <linux/jbd2.h>
> #include "ext4.h"
>
> -#ifdef EXT4FS_DEBUG
> -
> -static const int nibblemap[] = {4, 3, 3, 2, 3, 2, 2, 1, 3, 2, 2, 1, 2, 1, 1, 0};
> -
> -unsigned int ext4_count_free(struct buffer_head *map, unsigned int numchars)
> -{
> - unsigned int i, sum = 0;
> -
> - if (!map)
> - return 0;
> - for (i = 0; i < numchars; i++)
> - sum += nibblemap[map->b_data[i] & 0xf] +
> - nibblemap[(map->b_data[i] >> 4) & 0xf];
> - return sum;
> -}
> -
> -#endif /* EXT4FS_DEBUG */
> -
> int ext4_inode_bitmap_csum_verify(struct super_block *sb, ext4_group_t group,
> struct ext4_group_desc *gdp,
> struct buffer_head *bh, int sz)
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index cfc4e01..3a3511d 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -1852,7 +1852,6 @@ struct mmpd_data {
> # define NORET_AND noreturn,
>
> /* bitmap.c */
> -extern unsigned int ext4_count_free(struct buffer_head *, unsigned);
> void ext4_inode_bitmap_csum_set(struct super_block *sb, ext4_group_t group,
> struct ext4_group_desc *gdp,
> struct buffer_head *bh, int sz);
> diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
> index d48e8b1..1310108 100644
> --- a/fs/ext4/ialloc.c
> +++ b/fs/ext4/ialloc.c
> @@ -1054,7 +1054,9 @@ unsigned long ext4_count_free_inodes(struct super_block *sb)
> if (!bitmap_bh)
> continue;
>
> - x = ext4_count_free(bitmap_bh, EXT4_INODES_PER_GROUP(sb) / 8);
> + x = EXT4_INODES_PER_GROUP(sb) / 8 * BITS_PER_BYTE -
> + memweight(bitmap_bh->b_data,
> + EXT4_INODES_PER_GROUP(sb) / 8);
> printk(KERN_DEBUG "group %lu: stored = %d, counted = %lu\n",
> (unsigned long) i, ext4_free_inodes_count(sb, gdp), x);
> bitmap_count += x;
> --
> 1.7.7.6
>
next prev parent reply other threads:[~2012-06-02 14:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-02 13:40 [PATCH v2 01/10] string: introduce memweight Akinobu Mita
2012-06-02 13:40 ` [PATCH v2 02/10] minixfs: use memweight() Akinobu Mita
2012-06-04 10:26 ` Jan Kara
2012-06-02 13:40 ` [PATCH v2 03/10] qnx4fs: " Akinobu Mita
2012-06-02 13:40 ` [PATCH v2 04/10] dm: " Akinobu Mita
2012-06-02 13:40 ` [PATCH v2 05/10] affs: " Akinobu Mita
2012-06-02 13:40 ` [PATCH v2 06/10] video/uvc: " Akinobu Mita
2012-06-02 13:40 ` [PATCH v2 07/10] ocfs2: " Akinobu Mita
2012-06-02 13:40 ` [PATCH v2 08/10] ext2: " Akinobu Mita
2012-06-04 10:10 ` Jan Kara
2012-06-02 13:40 ` [PATCH v2 09/10] ext3: " Akinobu Mita
2012-06-02 13:40 ` [PATCH v2 10/10] ext4: " Akinobu Mita
2012-06-02 14:35 ` Andreas Dilger [this message]
2012-06-03 12:57 ` Akinobu Mita
2012-06-04 10:12 ` [PATCH v2 01/10] string: introduce memweight Jan Kara
2012-06-04 11:46 ` Akinobu Mita
2012-06-04 13:35 ` Jan Kara
2012-06-05 9:03 ` Akinobu Mita
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=B6D8D29B-9D9E-4248-B1EE-703D46354522@dilger.ca \
--to=adilger@dilger.ca \
--cc=adilger.kernel@dilger.ca \
--cc=akinobu.mita@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®