mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-04 12:12:05 +00:00
ocfs2: use bitmap API in fill_node_map
Pass bits directly into fill_node_map helper and use bitmap API directly to simplify code. Link: https://lkml.kernel.org/r/20221007124846.186453-2-joseph.qi@linux.alibaba.com Signed-off-by: Joseph Qi <joseph.qi@linux.alibaba.com> Cc: Changwei Ge <gechangwei@live.cn> Cc: Gang He <ghe@suse.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Jun Piao <piaojun@huawei.com> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Mark Fasheh <mark@fasheh.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
This commit is contained in:
parent
71dd5d651b
commit
6d4a93b680
@ -375,7 +375,7 @@ static void o2hb_nego_timeout(struct work_struct *work)
|
||||
if (reg->hr_last_hb_status)
|
||||
return;
|
||||
|
||||
o2hb_fill_node_map(live_node_bitmap, sizeof(live_node_bitmap));
|
||||
o2hb_fill_node_map(live_node_bitmap, O2NM_MAX_NODES);
|
||||
/* lowest node as master node to make negotiate decision. */
|
||||
master_node = find_first_bit(live_node_bitmap, O2NM_MAX_NODES);
|
||||
|
||||
@ -1087,7 +1087,7 @@ static int o2hb_do_disk_heartbeat(struct o2hb_region *reg)
|
||||
* If a node is not configured but is in the livemap, we still need
|
||||
* to read the slot so as to be able to remove it from the livemap.
|
||||
*/
|
||||
o2hb_fill_node_map(live_node_bitmap, sizeof(live_node_bitmap));
|
||||
o2hb_fill_node_map(live_node_bitmap, O2NM_MAX_NODES);
|
||||
i = -1;
|
||||
while ((i = find_next_bit(live_node_bitmap,
|
||||
O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES) {
|
||||
@ -1450,23 +1450,21 @@ void o2hb_init(void)
|
||||
|
||||
/* if we're already in a callback then we're already serialized by the sem */
|
||||
static void o2hb_fill_node_map_from_callback(unsigned long *map,
|
||||
unsigned bytes)
|
||||
unsigned int bits)
|
||||
{
|
||||
BUG_ON(bytes < (BITS_TO_LONGS(O2NM_MAX_NODES) * sizeof(unsigned long)));
|
||||
|
||||
memcpy(map, &o2hb_live_node_bitmap, bytes);
|
||||
bitmap_copy(map, o2hb_live_node_bitmap, bits);
|
||||
}
|
||||
|
||||
/*
|
||||
* get a map of all nodes that are heartbeating in any regions
|
||||
*/
|
||||
void o2hb_fill_node_map(unsigned long *map, unsigned bytes)
|
||||
void o2hb_fill_node_map(unsigned long *map, unsigned int bits)
|
||||
{
|
||||
/* callers want to serialize this map and callbacks so that they
|
||||
* can trust that they don't miss nodes coming to the party */
|
||||
down_read(&o2hb_callback_sem);
|
||||
spin_lock(&o2hb_live_lock);
|
||||
o2hb_fill_node_map_from_callback(map, bytes);
|
||||
o2hb_fill_node_map_from_callback(map, bits);
|
||||
spin_unlock(&o2hb_live_lock);
|
||||
up_read(&o2hb_callback_sem);
|
||||
}
|
||||
@ -2460,7 +2458,7 @@ int o2hb_check_node_heartbeating_no_sem(u8 node_num)
|
||||
unsigned long testing_map[BITS_TO_LONGS(O2NM_MAX_NODES)];
|
||||
|
||||
spin_lock(&o2hb_live_lock);
|
||||
o2hb_fill_node_map_from_callback(testing_map, sizeof(testing_map));
|
||||
o2hb_fill_node_map_from_callback(testing_map, O2NM_MAX_NODES);
|
||||
spin_unlock(&o2hb_live_lock);
|
||||
if (!test_bit(node_num, testing_map)) {
|
||||
mlog(ML_HEARTBEAT,
|
||||
@ -2477,7 +2475,7 @@ int o2hb_check_node_heartbeating_from_callback(u8 node_num)
|
||||
{
|
||||
unsigned long testing_map[BITS_TO_LONGS(O2NM_MAX_NODES)];
|
||||
|
||||
o2hb_fill_node_map_from_callback(testing_map, sizeof(testing_map));
|
||||
o2hb_fill_node_map_from_callback(testing_map, O2NM_MAX_NODES);
|
||||
if (!test_bit(node_num, testing_map)) {
|
||||
mlog(ML_HEARTBEAT,
|
||||
"node (%u) does not have heartbeating enabled.\n",
|
||||
|
@ -59,7 +59,7 @@ int o2hb_register_callback(const char *region_uuid,
|
||||
void o2hb_unregister_callback(const char *region_uuid,
|
||||
struct o2hb_callback_func *hc);
|
||||
void o2hb_fill_node_map(unsigned long *map,
|
||||
unsigned bytes);
|
||||
unsigned int bits);
|
||||
void o2hb_exit(void);
|
||||
void o2hb_init(void);
|
||||
int o2hb_check_node_heartbeating_no_sem(u8 node_num);
|
||||
|
@ -438,7 +438,7 @@ static int o2net_fill_bitmap(char *buf, int len)
|
||||
unsigned long map[BITS_TO_LONGS(O2NM_MAX_NODES)];
|
||||
int i = -1, out = 0;
|
||||
|
||||
o2net_fill_node_map(map, sizeof(map));
|
||||
o2net_fill_node_map(map, O2NM_MAX_NODES);
|
||||
|
||||
while ((i = find_next_bit(map, O2NM_MAX_NODES, i + 1)) < O2NM_MAX_NODES)
|
||||
out += scnprintf(buf + out, PAGE_SIZE - out, "%d ", i);
|
||||
|
@ -990,14 +990,12 @@ static int o2net_tx_can_proceed(struct o2net_node *nn,
|
||||
}
|
||||
|
||||
/* Get a map of all nodes to which this node is currently connected to */
|
||||
void o2net_fill_node_map(unsigned long *map, unsigned bytes)
|
||||
void o2net_fill_node_map(unsigned long *map, unsigned int bits)
|
||||
{
|
||||
struct o2net_sock_container *sc;
|
||||
int node, ret;
|
||||
|
||||
BUG_ON(bytes < (BITS_TO_LONGS(O2NM_MAX_NODES) * sizeof(unsigned long)));
|
||||
|
||||
memset(map, 0, bytes);
|
||||
bitmap_zero(map, bits);
|
||||
for (node = 0; node < O2NM_MAX_NODES; ++node) {
|
||||
if (!o2net_tx_can_proceed(o2net_nn_from_num(node), &sc, &ret))
|
||||
continue;
|
||||
|
@ -1604,7 +1604,7 @@ static int dlm_try_to_join_domain(struct dlm_ctxt *dlm)
|
||||
/* group sem locking should work for us here -- we're already
|
||||
* registered for heartbeat events so filling this should be
|
||||
* atomic wrt getting those handlers called. */
|
||||
o2hb_fill_node_map(dlm->live_nodes_map, sizeof(dlm->live_nodes_map));
|
||||
o2hb_fill_node_map(dlm->live_nodes_map, O2NM_MAX_NODES);
|
||||
|
||||
spin_lock(&dlm->spinlock);
|
||||
memcpy(ctxt->live_map, dlm->live_nodes_map, sizeof(ctxt->live_map));
|
||||
|
@ -273,17 +273,17 @@ static int o2cb_cluster_check(void)
|
||||
*/
|
||||
#define O2CB_MAP_STABILIZE_COUNT 60
|
||||
for (i = 0; i < O2CB_MAP_STABILIZE_COUNT; ++i) {
|
||||
o2hb_fill_node_map(hbmap, sizeof(hbmap));
|
||||
o2hb_fill_node_map(hbmap, O2NM_MAX_NODES);
|
||||
if (!test_bit(node_num, hbmap)) {
|
||||
printk(KERN_ERR "o2cb: %s heartbeat has not been "
|
||||
"started.\n", (o2hb_global_heartbeat_active() ?
|
||||
"Global" : "Local"));
|
||||
return -EINVAL;
|
||||
}
|
||||
o2net_fill_node_map(netmap, sizeof(netmap));
|
||||
o2net_fill_node_map(netmap, O2NM_MAX_NODES);
|
||||
/* Force set the current node to allow easy compare */
|
||||
set_bit(node_num, netmap);
|
||||
if (!memcmp(hbmap, netmap, sizeof(hbmap)))
|
||||
if (bitmap_equal(hbmap, netmap, O2NM_MAX_NODES))
|
||||
return 0;
|
||||
if (i < O2CB_MAP_STABILIZE_COUNT - 1)
|
||||
msleep(1000);
|
||||
|
Loading…
Reference in New Issue
Block a user