/* since (b->bm_bits % BITS_PER_LONG) != 0, this masks out the remaining bits. Returns the number of bits cleared.  */
static int bm_clear_surplus(struct drbd_bitmap *b)
/* since (b->bm_bits % BITS_PER_LONG) != 0, this masks out the remaining bits. Returns the number of bits cleared.  */
static int bm_clear_surplus(struct drbd_bitmap *b)
{
	const unsigned long mask = (1UL << (b->bm_bits & (BITS_PER_LONG-1))) - 1;
	size_t w = b->bm_bits >> LN2_BPL;
	int cleared = 0;
	unsigned long *p_addr, *bm;
	p_addr = bm_map_paddr(b, w);
	bm = p_addr + MLPP(w);
	if (w < b->bm_words) {
		cleared = hweight_long(*bm & ~mask);
		*bm &= mask;
		w++; bm++;
	}
	if (w < b->bm_words) {
		cleared += hweight_long(*bm);
		*bm = 0;
	}
	bm_unmap(p_addr);
	return cleared;
}