drbd: drbd_bitmap: Avoid name collision
Subsystems (2)
PATCH 1/1 drbd: drbd_bitmap: Avoid name collision
From: Fabio Estevam <[email protected]>
Building for ARM64 leads to the following build warnings:
CC drivers/block/drbd/drbd_bitmap.odrivers/block/drbd/drbd_bitmap.c:483:0: warning: "BITS_PER_PAGE" redefined
#define BITS_PER_PAGE (1UL << (PAGE_SHIFT + 3))
^
In file included from include/linux/ptrace.h:8:0,
from ./arch/arm64/include/asm/compat.h:26,
from ./arch/arm64/include/asm/stat.h:23,
from include/linux/stat.h:5,
from include/linux/sysfs.h:21,
from include/linux/kobject.h:21,
from include/linux/device.h:17,
from include/linux/pm_qos.h:10,
from include/linux/netdevice.h:28,
from include/net/sock.h:51,
from include/linux/connector.h:30,
from include/linux/drbd.h:28,
from drivers/block/drbd/drbd_bitmap.c:30:include/linux/pid_namespace.h:18:0: note: this is the location of the previous definition
#define BITS_PER_PAGE (PAGE_SIZE * 8)
^drivers/block/drbd/drbd_bitmap.c:484:0: warning: "BITS_PER_PAGE_MASK" redefined
#define BITS_PER_PAGE_MASK (BITS_PER_PAGE - 1)
^
In file included from include/linux/ptrace.h:8:0,
from ./arch/arm64/include/asm/compat.h:26,
from ./arch/arm64/include/asm/stat.h:23,
from include/linux/stat.h:5,
from include/linux/sysfs.h:21,
from include/linux/kobject.h:21,
from include/linux/device.h:17,
from include/linux/pm_qos.h:10,
from include/linux/netdevice.h:28,
from include/net/sock.h:51,
from include/linux/connector.h:30,
from include/linux/drbd.h:28,
from drivers/block/drbd/drbd_bitmap.c:30:include/linux/pid_namespace.h:19:0: note: this is the location of the previous definition
#define BITS_PER_PAGE_MASK (BITS_PER_PAGE-1)
^
Fix the warnings by using BITS_PER_PAGE_DRBD and BITS_PER_PAGE_MASK_DRBD definitions to avoid the name collision.
--- drivers/block/drbd/drbd_bitmap.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/block/drbd/drbd_bitmap.c +11 -11
@@ -479,8 +479,8 @@ void drbd_bm_cleanup(struct drbd_device *device)* this masks out the remaining bits. * Returns the number of bits cleared. */ -#define BITS_PER_PAGE (1UL << (PAGE_SHIFT + 3)) -#define BITS_PER_PAGE_MASK (BITS_PER_PAGE - 1) +#define BITS_PER_PAGE_DRBD (1UL << (PAGE_SHIFT + 3)) +#define BITS_PER_PAGE_MASK_DRBD (BITS_PER_PAGE_DRBD - 1)#define BITS_PER_LONG_MASK (BITS_PER_LONG - 1)static int bm_clear_surplus (struct drbd_bitmap *b) {
@@ -490,7 +490,7 @@ static int bm_clear_surplus(struct drbd_bitmap *b)int cleared =0 ;/* number of bits modulo bits per page */ - tmp = (b->bm_bits &BITS_PER_PAGE_MASK ); + tmp = (b->bm_bits &BITS_PER_PAGE_MASK_DRBD );/* mask the used bits of the word containing the last bit */ mask = (1UL << (tmp &BITS_PER_LONG_MASK )) -1 ;/* bitmap is always stored little endian,
@@ -526,7 +526,7 @@ static void bm_set_surplus(struct drbd_bitmap *b)int tmp;/* number of bits modulo bits per page */ - tmp = (b->bm_bits &BITS_PER_PAGE_MASK ); + tmp = (b->bm_bits &BITS_PER_PAGE_MASK_DRBD );/* mask the used bits of the word containing the last bit */ mask = (1UL << (tmp &BITS_PER_LONG_MASK )) -1 ;/* bitmap is always stored little endian,
@@ -570,7 +570,7 @@ static unsigned long bm_count_bits(struct drbd_bitmap *b)cond_resched (); }/* last (or only) page */ - last_word = ((b->bm_bits -1 ) &BITS_PER_PAGE_MASK ) >>LN2_BPL ; + last_word = ((b->bm_bits -1 ) &BITS_PER_PAGE_MASK_DRBD ) >>LN2_BPL ; p_addr =__bm_map_pidx (b, idx);for (i =0 ; i < last_word; i++) bits +=hweight_long (p_addr[i]);
@@ -1257,15 +1257,15 @@ static unsigned long __bm_find_next(struct drbd_device *device, unsigned long bm }else {while (bm_fo < b->bm_bits) {/* bit offset of the first bit in the page */ - bit_offset = bm_fo & ~BITS_PER_PAGE_MASK ; + bit_offset = bm_fo & ~BITS_PER_PAGE_MASK_DRBD ; p_addr =__bm_map_pidx (b,bm_bit_to_page_idx (b, bm_fo));if (find_zero_bit) i =find_next_zero_bit_le (p_addr, -PAGE_SIZE *8 , bm_fo &BITS_PER_PAGE_MASK ); +PAGE_SIZE *8 , bm_fo &BITS_PER_PAGE_MASK_DRBD );else i =find_next_bit_le (p_addr, -PAGE_SIZE *8 , bm_fo &BITS_PER_PAGE_MASK ); +PAGE_SIZE *8 , bm_fo &BITS_PER_PAGE_MASK_DRBD );__bm_unmap (p_addr);if (i <PAGE_SIZE *8 ) {
@@ -1366,9 +1366,9 @@ static int __bm_change_bits_to(struct drbd_device *device, const unsigned long s last_page_nr = page_nr; }if (val) - c += (0 ==__test_and_set_bit_le (bitnr &BITS_PER_PAGE_MASK , p_addr)); + c += (0 ==__test_and_set_bit_le (bitnr &BITS_PER_PAGE_MASK_DRBD , p_addr));else - c -= (0 !=__test_and_clear_bit_le (bitnr &BITS_PER_PAGE_MASK , p_addr)); + c -= (0 !=__test_and_clear_bit_le (bitnr &BITS_PER_PAGE_MASK_DRBD , p_addr)); }if (p_addr)__bm_unmap (p_addr);
@@ -1545,7 +1545,7 @@ int drbd_bm_test_bit(struct drbd_device *device, const unsigned long bitnr)bm_print_lock_info (device);if (bitnr < b->bm_bits) { p_addr =bm_map_pidx (b,bm_bit_to_page_idx (b, bitnr)); - i =test_bit_le (bitnr &BITS_PER_PAGE_MASK , p_addr) ?1 :0 ; + i =test_bit_le (bitnr &BITS_PER_PAGE_MASK_DRBD , p_addr) ?1 :0 ;bm_unmap (p_addr); }else if (bitnr == b->bm_bits) { i =-1 ;
Signature · 1 line
1.9.1
Lars Ellenberg
maintainerQuoted 7 lines · Fabio Estevam
From: Fabio Estevam <[email protected]>
Building for ARM64 leads to the following build warnings:
CC
drivers/block/drbd/drbd_bitmap.odrivers/block/drbd/drbd_bitmap.c:483:0: warning: "BITS_PER_PAGE" redefined
#defineBITS_PER_PAGE(1UL << (PAGE_SHIFT+ 3))
Apparently there are more than one consumer of "BITS_PER_PAGE". The commit that moved the now conflicting definition to pid_namespace.h itself already refered to a similar "redefined" warning.
Would it not make more sense to have one such definition next to PAGE_SIZE? Or somewhere central, anyways?
Quoted 2 lines
Fix the warnings by using
BITS_PER_PAGE_DRBDandBITS_PER_PAGE_MASK_DRBDdefinitions to avoid the name collision.
Other than that:
Ack.
Lars Ellenberg
Quoted 6 lines · Lars Ellenberg
Apparently there are more than one consumer of "
BITS_PER_PAGE". The commit that moved the now conflicting definition topid_namespace.hitself already refered to a similar "redefined" warning.Would it not make more sense to have one such definition next to
PAGE_SIZE? Or somewhere central, anyways?
What about this instead?
drivers/block/drbd/drbd_bitmap.c +1 -2
@@ -29,6 +29,7 @@#include <linux/string.h> #include <linux/drbd.h> #include <linux/slab.h> +#include <linux/pid_namespace.h> #include <asm/kmap_types.h> #include "drbd_int.h"
@@ -479,8 +480,6 @@ void drbd_bm_cleanup(struct drbd_device *device)* this masks out the remaining bits. * Returns the number of bits cleared. */ -#define BITS_PER_PAGE (1UL << (PAGE_SHIFT + 3)) -#define BITS_PER_PAGE_MASK (BITS_PER_PAGE - 1)#define BITS_PER_LONG_MASK (BITS_PER_LONG - 1)static int bm_clear_surplus (struct drbd_bitmap *b) {