ocfs2/dlm: Use negotiated o2dlm protocol version
PATCH 1/8 ocfs2/dlm: Use negotiated o2dlm protocol version
Patch fixes a bug in the o2dlm protocol negotiation in that it is using the builtin version rather than the negotiated version during the domain join. This causes join errors when a node having kernel >= 2.6.37 joins a cluster with nodes having kernels < 2.6.37.
This only affects the o2cb cluster stack.
--- fs/ocfs2/dlm/dlmdomain.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
fs/ocfs2/dlm/dlmdomain.c +2 -1
@@ -1614,7 +1614,8 @@ static int dlm_try_to_join_domain(struct dlm_ctxt *dlm)spin_unlock (&dlm->spinlock);/* Support for global heartbeat and node info was added in 1.1 */ -if (dlm_protocol.pv_major >1 || dlm_protocol.pv_minor >0 ) { +if (dlm->dlm_locking_proto.pv_major >1 || + dlm->dlm_locking_proto.pv_minor >0 ) { status =dlm_send_nodeinfo (dlm, ctxt->yes_resp_map);if (status) {mlog_errno (status);
Signature · 1 line
1.7.4.1
PATCH 2/8 ocfs2/cluster: Increase the live threshold for global heartbeat
We have seen isolated cases (very few, I might add) of o2hb not detecting all live nodes on startup. One plausible reasoning for it is that other node had a hb io delay at the same time. The live threshold set at 2 (as low as it can be) could be increased to ameliorate the situation.
But increasing the threshold directly affects mount time. Currently it takes around 5 secs to mount a volume in o2cb cluster with local heartbeat. Increasing the threshold will make mounts even slower. As the issue itself is rare, we have left things as they are for the local heartbeat mode.
However we can improve the situation for global heartbeat mode as in that mode, we start the heartbeat much before the mount.
This patch doubles the live threshold for the start of the first region in global heartbeat mode.
Addresses internal Oracle bug#10635585.
--- fs/ocfs2/cluster/heartbeat.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-)
fs/ocfs2/cluster/heartbeat.c +12 -1
@@ -1690,6 +1690,7 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg,struct file *filp =NULL ;struct inode *inode =NULL ;ssize_t ret = -EINVAL ; +int live_threshold;if (reg->hr_bdev) goto out;
@@ -1766,8 +1767,18 @@ static ssize_t o2hb_region_dev_write(struct o2hb_region *reg,* A node is considered live after it has beat LIVE_THRESHOLD * times. We're not steady until we've given them a chance * _after_ our first read. +* The default threshold is bare minimum so as to limit the delay +* during mounts. For global heartbeat, the threshold doubled for the +* first region. */ -atomic_set (®->hr_steady_iterations,O2HB_LIVE_THRESHOLD +1 ); + live_threshold =O2HB_LIVE_THRESHOLD ; +if (o2hb_global_heartbeat_active ()) { +spin_lock (&o2hb_live_lock); +if (o2hb_pop_count (&o2hb_region_bitmap,O2NM_MAX_REGIONS ) ==1 ) + live_threshold <<=1 ; +spin_unlock (&o2hb_live_lock); + } +atomic_set (®->hr_steady_iterations, live_threshold +1 ); hb_task =kthread_run (o2hb_thread, reg,"o2hb-%s" , reg->hr_item.ci_name);
Signature · 1 line
1.7.4.1
PATCH 3/8 ocfs2/cluster: Heartbeat mismatch message improved
In reply to Sunil MushranIf o2hb finds unexpected values in the heartbeat slot, it prints a message "ERROR: Device "dm-6": another node is heartbeating in our slot!"
This message could be misleading. This patch adds two more messages to help users better diagnose the problem.
--- fs/ocfs2/cluster/heartbeat.c | 48 +++++++++++++++++++++++++++-------------- 1 files changed, 31 insertions(+), 17 deletions(-)
fs/ocfs2/cluster/heartbeat.c +31 -17
@@ -539,25 +539,41 @@ static int o2hb_verify_crc(struct o2hb_region *reg,/* We want to make sure that nobody is heartbeating on top of us -- * this will help detect an invalid configuration. */ -static int o2hb_check_last_timestamp (struct o2hb_region *reg) +static void o2hb_check_last_timestamp (struct o2hb_region *reg) { -int node_num, ret;struct o2hb_disk_slot *slot;struct o2hb_disk_heartbeat_block *hb_block; +char *errstr; - node_num =o2nm_this_node (); - - ret =1 ; - slot = ®->hr_slots[node_num]; + slot = ®->hr_slots[o2nm_this_node ()];/* Don't check on our 1st timestamp */ -if (slot->ds_last_time) { - hb_block = slot->ds_raw_block; +if (!slot->ds_last_time) +return ; -if (le64_to_cpu (hb_block->hb_seq) != slot->ds_last_time) - ret =0 ; - } + hb_block = slot->ds_raw_block; +if (le64_to_cpu (hb_block->hb_seq) == slot->ds_last_time && +le64_to_cpu (hb_block->hb_generation) == slot->ds_last_generation && + hb_block->hb_node == slot->ds_node_num) +return ; -return ret; +#define ERRSTR1 "Another node is heartbeating on device" +#define ERRSTR2 "Heartbeat generation mismatch on device" +#define ERRSTR3 "Heartbeat sequence mismatch on device" + +if (hb_block->hb_node != slot->ds_node_num) + errstr =ERRSTR1 ; +else if (le64_to_cpu (hb_block->hb_generation) != + slot->ds_last_generation) + errstr =ERRSTR2 ; +else + errstr =ERRSTR3 ; + +mlog (ML_ERROR ,"%s (%s): expected(%u:0x%llx, 0x%llx), " +"ondisk(%u:0x%llx, 0x%llx)\n" , errstr, reg->hr_dev_name, + slot->ds_node_num, (unsigned long long )slot->ds_last_generation, + (unsigned long long )slot->ds_last_time, hb_block->hb_node, + (unsigned long long )le64_to_cpu (hb_block->hb_generation), + (unsigned long long )le64_to_cpu (hb_block->hb_seq)); } static inline void o2hb_prepare_block(struct o2hb_region *reg,
@@ -983,9 +999,7 @@ static int o2hb_do_disk_heartbeat(struct o2hb_region *reg)/* With an up to date view of the slots, we can check that no * other node has been improperly configured to heartbeat in * our slot. */ -if (!o2hb_check_last_timestamp (reg)) -mlog (ML_ERROR ,"Device \"%s\": another node is heartbeating " -"in our slot!\n" , reg->hr_dev_name); +o2hb_check_last_timestamp (reg);/* fill in the proper info for our next heartbeat */ o2hb_prepare_block (reg, reg->hr_generation);
@@ -999,8 +1013,8 @@ static int o2hb_do_disk_heartbeat(struct o2hb_region *reg) } i =-1 ; -while ((i =find_next_bit (configured_nodes,O2NM_MAX_NODES , i +1 )) <O2NM_MAX_NODES ) { - +while ((i =find_next_bit (configured_nodes, +O2NM_MAX_NODES , i +1 )) <O2NM_MAX_NODES ) { change |=o2hb_check_slot (reg, ®->hr_slots[i]); }
Signature · 1 line
1.7.4.1
PATCH 4/8 ocfs2: Skip mount recovery for hard-ro mounts
In reply to Sunil MushranPatch skips mount recovery for hard-ro mounts which otherwise leads to an oops.
--- fs/ocfs2/journal.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
fs/ocfs2/journal.c +3 -0
@@ -1260,6 +1260,9 @@ void ocfs2_complete_mount_recovery(struct ocfs2_super *osb) {struct ocfs2_journal *journal = osb->journal; +if (ocfs2_is_hard_readonly (osb)) +return ; +/* No need to queue up our truncate_log as regular cleanup will catch * that */ ocfs2_queue_recovery_completion(journal, osb->slot_num,
Signature · 1 line
1.7.4.1
PATCH 5/8 ocfs2/dlm: dlm_is_lockres_migrateable() returns boolean
In reply to Sunil MushranPatch cleans up the gunk added by commit 388c4bcb4e63e88fb1f312a2f5f9eb2623afcf5b. dlm_is_lockres_migrateable() now returns 1 if lockresource is deemed migrateable and 0 if not.
--- fs/ocfs2/dlm/dlmcommon.h | 12 ++++ fs/ocfs2/dlm/dlmmaster.c | 135 +++++++++++++++++---------------------------- 2 files changed, 63 insertions(+), 84 deletions(-)
fs/ocfs2/dlm/dlmcommon.h +12 -0
@@ -401,6 +401,18 @@ static inline int dlm_lvb_is_empty(char *lvb)return 1 ; } +static inline char *dlm_list_in_text (enum dlm_lockres_list idx) +{ +if (idx ==DLM_GRANTED_LIST ) +return "granted" ; +else if (idx ==DLM_CONVERTING_LIST ) +return "converting" ; +else if (idx ==DLM_BLOCKED_LIST ) +return "blocked" ; +else +return "unknown" ; +} +static inline struct list_head *dlm_list_idx_to_ptr (struct dlm_lock_resource *res,enum dlm_lockres_list idx) {
fs/ocfs2/dlm/dlmmaster.c +51 -84
201 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 6/8 ocfs2/dlm: Add new dlm message DLM_BEGIN_EXIT_DOMAIN_MSG
In reply to Sunil MushranThis patch adds a new dlm message DLM_BEGIN_EXIT_DOMAIN_MSG and ups the dlm protocol to 1.2.
o2dlm sends this new message in dlm_unregister_domain() to mark the beginning of the exit domain. This message is sent to all nodes in the domain.
Currently o2dlm has no way of informing other nodes of its impending exit. This information is useful as the other nodes could disregard the exiting node in certain operations. For example, in resource migration. If two or more nodes were umounting in parallel, it would be more efficient if o2dlm were to choose a non-exiting node to be the new master node rather than an exiting one.
--- fs/ocfs2/dlm/dlmcommon.h | 2 + fs/ocfs2/dlm/dlmdebug.c | 6 +++ fs/ocfs2/dlm/dlmdomain.c | 84 ++++++++++++++++++++++++++++++++++++++------ fs/ocfs2/dlm/dlmrecovery.c | 1 + 4 files changed, 82 insertions(+), 11 deletions(-)
fs/ocfs2/dlm/dlmcommon.h +2 -0
@@ -144,6 +144,7 @@ struct dlm_ctxtwait_queue_head_t dlm_join_events;unsigned long live_nodes_map[BITS_TO_LONGS (O2NM_MAX_NODES )];unsigned long domain_map[BITS_TO_LONGS (O2NM_MAX_NODES )]; +unsigned long exit_domain_map[BITS_TO_LONGS (O2NM_MAX_NODES )];unsigned long recovery_map[BITS_TO_LONGS (O2NM_MAX_NODES )];struct dlm_recovery_ctxt reco;spinlock_t master_lock;
@@ -460,6 +461,7 @@ enum {DLM_FINALIZE_RECO_MSG =518 ,DLM_QUERY_REGION =519 ,DLM_QUERY_NODEINFO =520 , + DLM_BEGIN_EXIT_DOMAIN_MSG = 521, };struct dlm_reco_node_data
fs/ocfs2/dlm/dlmdebug.c +6 -0
@@ -756,6 +756,12 @@ static int debug_state_print(struct dlm_ctxt *dlm, char *buf, int len) buf + out, len - out); out +=snprintf (buf + out, len - out,"\n" ); +/* Exit Domain Map: xx xx xx */ + out +=snprintf (buf + out, len - out,"Exit Domain Map: " ); + out +=stringify_nodemap (dlm->exit_domain_map,O2NM_MAX_NODES , + buf + out, len - out); + out +=snprintf (buf + out, len - out,"\n" ); +/* Live Map: xx xx xx */ out +=snprintf (buf + out, len - out,"Live Map: " ); out += stringify_nodemap(dlm->live_nodes_map, O2NM_MAX_NODES,
fs/ocfs2/dlm/dlmdomain.c +73 -11
149 lines not on this page · raw message
fs/ocfs2/dlm/dlmrecovery.c +1 -0
@@ -2393,6 +2393,7 @@ static void __dlm_hb_node_down(struct dlm_ctxt *dlm, int idx)mlog (0 ,"node %u being removed from domain map!\n" , idx);clear_bit (idx, dlm->domain_map); +clear_bit (idx, dlm->exit_domain_map);/* wake up migration waiters if a node goes down. * perhaps later we can genericize this for other waiters. */ wake_up (&dlm->migration_wq);
Signature · 1 line
1.7.4.1
PATCH 7/8 ocfs2/dlm: Do not migrate resource to a node that is leaving the domain
In reply to Sunil MushranDuring dlm domain shutdown, o2dlm has to free all the lock resources. Ones that have no locks and references are freed. Ones that have locks and/or references are migrated to another node.
The first task in migration is finding a target. Currently we scan the lock resource and find one node that either has a lock or a reference. This is not very efficient in a parallel umount case as we might end up migrating the lock resource to a node which itself may have to migrate it to a third node.
The patch scans the dlm->exit_domain_map to ensure the target node is not leaving the domain. If no valid target node is found, o2dlm does not migrate the resource but instead waits for the unlock and deref messages that will allow it to free the resource.
--- fs/ocfs2/dlm/dlmdomain.c | 10 ++- fs/ocfs2/dlm/dlmmaster.c | 142 ++++++++++++++++------------------------------ 2 files changed, 57 insertions(+), 95 deletions(-)
fs/ocfs2/dlm/dlmdomain.c +7 -3
@@ -451,14 +451,18 @@ redo_bucket: dropped =dlm_empty_lockres (dlm, res);spin_lock (&res->spinlock); -__dlm_lockres_calc_usage (dlm, res); - iter = res->hash_node.next; +if (dropped) +__dlm_lockres_calc_usage (dlm, res); +else + iter = res->hash_node.next;spin_unlock (&res->spinlock);dlm_lockres_put (res); -if (dropped) +if (dropped) { +cond_resched_lock (&dlm->spinlock); goto redo_bucket; + } }cond_resched_lock (&dlm->spinlock); num += n;
fs/ocfs2/dlm/dlmmaster.c +50 -92
220 lines not on this page · raw message
Signature · 1 line
1.7.4.1
PATCH 8/8 ocfs2/dlm: Target node death during resource migration leads to thread spin
In reply to Sunil MushranDuring resource migration, if the target node were to die, the thread doing the migration spins until the target node is not removed from the domain map. This patch slows the spin by making the thread wait for the recovery to kick in.
--- fs/ocfs2/dlm/dlmmaster.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
fs/ocfs2/dlm/dlmmaster.c +3 -0
@@ -2522,6 +2522,9 @@ fail: res->state &= ~DLM_LOCK_RES_MIGRATING ; wake =1 ;spin_unlock (&res->spinlock); +if (dlm_is_host_down (ret)) +dlm_wait_for_node_death (dlm, target, +DLM_NODE_DEATH_WAIT_MAX ); goto leave; }
Signature · 1 line
1.7.4.1