aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ocfs2
diff options
context:
space:
mode:
authorAkinobu Mita <akinobu.mita@gmail.com>2013-11-12 18:06:58 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2013-11-12 22:09:01 -0500
commita8f70de37bbb991033208edff7758d997d68db37 (patch)
treec11748600e76cc237a389370b1791f7f5415d2d4 /fs/ocfs2
parent910bffe0861c956096c31ad7e887cc23169955ed (diff)
ocfs2: use bitmap_weight()
Use bitmap_weight() instead of reinventing the wheel. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: Mark Fasheh <mfasheh@suse.com> Cc: Joel Becker <jlbec@evilplan.org> Signed-off-by: Joel Becker <jlbec@evilplan.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ocfs2')
-rw-r--r--fs/ocfs2/cluster/heartbeat.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 363f0dcc924f..292a13b05b6e 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -35,6 +35,7 @@
35#include <linux/time.h> 35#include <linux/time.h>
36#include <linux/debugfs.h> 36#include <linux/debugfs.h>
37#include <linux/slab.h> 37#include <linux/slab.h>
38#include <linux/bitmap.h>
38 39
39#include "heartbeat.h" 40#include "heartbeat.h"
40#include "tcp.h" 41#include "tcp.h"
@@ -282,15 +283,6 @@ struct o2hb_bio_wait_ctxt {
282 int wc_error; 283 int wc_error;
283}; 284};
284 285
285static int o2hb_pop_count(void *map, int count)
286{
287 int i = -1, pop = 0;
288
289 while ((i = find_next_bit(map, count, i + 1)) < count)
290 pop++;
291 return pop;
292}
293
294static void o2hb_write_timeout(struct work_struct *work) 286static void o2hb_write_timeout(struct work_struct *work)
295{ 287{
296 int failed, quorum; 288 int failed, quorum;
@@ -307,9 +299,9 @@ static void o2hb_write_timeout(struct work_struct *work)
307 spin_lock_irqsave(&o2hb_live_lock, flags); 299 spin_lock_irqsave(&o2hb_live_lock, flags);
308 if (test_bit(reg->hr_region_num, o2hb_quorum_region_bitmap)) 300 if (test_bit(reg->hr_region_num, o2hb_quorum_region_bitmap))
309 set_bit(reg->hr_region_num, o2hb_failed_region_bitmap); 301 set_bit(reg->hr_region_num, o2hb_failed_region_bitmap);
310 failed = o2hb_pop_count(&o2hb_failed_region_bitmap, 302 failed = bitmap_weight(o2hb_failed_region_bitmap,
311 O2NM_MAX_REGIONS); 303 O2NM_MAX_REGIONS);
312 quorum = o2hb_pop_count(&o2hb_quorum_region_bitmap, 304 quorum = bitmap_weight(o2hb_quorum_region_bitmap,
313 O2NM_MAX_REGIONS); 305 O2NM_MAX_REGIONS);
314 spin_unlock_irqrestore(&o2hb_live_lock, flags); 306 spin_unlock_irqrestore(&o2hb_live_lock, flags);
315 307
@@ -765,7 +757,7 @@ static void o2hb_set_quorum_device(struct o2hb_region *reg)
765 * If global heartbeat active, unpin all regions if the 757 * If global heartbeat active, unpin all regions if the
766 * region count > CUT_OFF 758 * region count > CUT_OFF
767 */ 759 */
768 if (o2hb_pop_count(&o2hb_quorum_region_bitmap, 760 if (bitmap_weight(o2hb_quorum_region_bitmap,
769 O2NM_MAX_REGIONS) > O2HB_PIN_CUT_OFF) 761 O2NM_MAX_REGIONS) > O2HB_PIN_CUT_OFF)
770 o2hb_region_unpin(NULL); 762 o2hb_region_unpin(NULL);
771unlock: 763unlock:
@@ -1829,7 +1821,7 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg,
1829 live_threshold = O2HB_LIVE_THRESHOLD; 1821 live_threshold = O2HB_LIVE_THRESHOLD;
1830 if (o2hb_global_heartbeat_active()) { 1822 if (o2hb_global_heartbeat_active()) {
1831 spin_lock(&o2hb_live_lock); 1823 spin_lock(&o2hb_live_lock);
1832 if (o2hb_pop_count(&o2hb_region_bitmap, O2NM_MAX_REGIONS) == 1) 1824 if (bitmap_weight(o2hb_region_bitmap, O2NM_MAX_REGIONS) == 1)
1833 live_threshold <<= 1; 1825 live_threshold <<= 1;
1834 spin_unlock(&o2hb_live_lock); 1826 spin_unlock(&o2hb_live_lock);
1835 } 1827 }
@@ -2180,7 +2172,7 @@ static void o2hb_heartbeat_group_drop_item(struct config_group *group,
2180 if (!o2hb_dependent_users) 2172 if (!o2hb_dependent_users)
2181 goto unlock; 2173 goto unlock;
2182 2174
2183 if (o2hb_pop_count(&o2hb_quorum_region_bitmap, 2175 if (bitmap_weight(o2hb_quorum_region_bitmap,
2184 O2NM_MAX_REGIONS) <= O2HB_PIN_CUT_OFF) 2176 O2NM_MAX_REGIONS) <= O2HB_PIN_CUT_OFF)
2185 o2hb_region_pin(NULL); 2177 o2hb_region_pin(NULL);
2186 2178
@@ -2480,7 +2472,7 @@ static int o2hb_region_inc_user(const char *region_uuid)
2480 if (o2hb_dependent_users > 1) 2472 if (o2hb_dependent_users > 1)
2481 goto unlock; 2473 goto unlock;
2482 2474
2483 if (o2hb_pop_count(&o2hb_quorum_region_bitmap, 2475 if (bitmap_weight(o2hb_quorum_region_bitmap,
2484 O2NM_MAX_REGIONS) <= O2HB_PIN_CUT_OFF) 2476 O2NM_MAX_REGIONS) <= O2HB_PIN_CUT_OFF)
2485 ret = o2hb_region_pin(NULL); 2477 ret = o2hb_region_pin(NULL);
2486 2478