From: Akinobu Mita <akinobu.mita@gmail.com>
To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org
Cc: Akinobu Mita <akinobu.mita@gmail.com>
Subject: [PATCH v3 2/9] qnx4fs: use memweight()
Date: Sat, 9 Jun 2012 09:50:31 +0900 [thread overview]
Message-ID: <1339203038-13069-2-git-send-email-akinobu.mita@gmail.com> (raw)
In-Reply-To: <1339203038-13069-1-git-send-email-akinobu.mita@gmail.com>
Use memweight() to count the total number of bits clear in memory area.
Note that this memweight() call can't be replaced with a single
bitmap_weight() call, although the pointer to the memory area is
aligned to long-word boundary. Because the size of the memory area
may not be a multiple of BITS_PER_LONG, then it returns wrong value on
big-endian architecture.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: Anders Larsen <al@alarsen.net>
---
v3: add note in the patch description
v2: put whitespace before '-'
fs/qnx4/bitmap.c | 24 +++++-------------------
1 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/fs/qnx4/bitmap.c b/fs/qnx4/bitmap.c
index 22e0d60..76a7a69 100644
--- a/fs/qnx4/bitmap.c
+++ b/fs/qnx4/bitmap.c
@@ -17,23 +17,6 @@
#include <linux/bitops.h>
#include "qnx4.h"
-static void count_bits(register const char *bmPart, register int size,
- int *const tf)
-{
- char b;
- int tot = *tf;
-
- if (size > QNX4_BLOCK_SIZE) {
- size = QNX4_BLOCK_SIZE;
- }
- do {
- b = *bmPart++;
- tot += 8 - hweight8(b);
- size--;
- } while (size != 0);
- *tf = tot;
-}
-
unsigned long qnx4_count_free_blocks(struct super_block *sb)
{
int start = le32_to_cpu(qnx4_sb(sb)->BitMap->di_first_xtnt.xtnt_blk) - 1;
@@ -44,13 +27,16 @@ unsigned long qnx4_count_free_blocks(struct super_block *sb)
struct buffer_head *bh;
while (total < size) {
+ int bytes = min(size - total, QNX4_BLOCK_SIZE);
+
if ((bh = sb_bread(sb, start + offset)) == NULL) {
printk(KERN_ERR "qnx4: I/O error in counting free blocks\n");
break;
}
- count_bits(bh->b_data, size - total, &total_free);
+ total_free += bytes * BITS_PER_BYTE -
+ memweight(bh->b_data, bytes);
brelse(bh);
- total += QNX4_BLOCK_SIZE;
+ total += bytes;
offset++;
}
--
1.7.7.6
next prev parent reply other threads:[~2012-06-09 0:50 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-09 0:50 [PATCH v3 1/9] string: introduce memweight Akinobu Mita
2012-06-09 0:50 ` Akinobu Mita [this message]
2012-06-09 0:50 ` [PATCH v3 3/9] dm: use memweight() Akinobu Mita
2012-06-09 0:50 ` [PATCH v3 4/9] affs: " Akinobu Mita
2012-06-09 0:50 ` [PATCH v3 5/9] video/uvc: " Akinobu Mita
2012-06-18 23:06 ` Mauro Carvalho Chehab
2012-06-09 0:50 ` [PATCH v3 6/9] ocfs2: " Akinobu Mita
2012-06-09 0:50 ` [PATCH v3 7/9] ext2: " Akinobu Mita
2012-06-12 9:14 ` Jan Kara
2012-06-09 0:50 ` [PATCH v3 8/9] ext3: " Akinobu Mita
2012-06-12 9:14 ` Jan Kara
2012-06-09 0:50 ` [PATCH v3 9/9] ext4: " Akinobu Mita
2012-06-11 23:17 ` [PATCH v3 1/9] string: introduce memweight Andrew Morton
2012-06-20 23:12 ` Tony Luck
2012-06-21 9:07 ` 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=1339203038-13069-2-git-send-email-akinobu.mita@gmail.com \
--to=akinobu.mita@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
/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
Powered by JetHome