[Ocfs2-commits] mfasheh commits r1447 - trunk/src
svn-commits at oss.oracle.com
svn-commits at oss.oracle.com
Thu Sep 9 16:08:29 CDT 2004
Author: mfasheh
Date: 2004-09-09 16:08:27 -0500 (Thu, 09 Sep 2004)
New Revision: 1447
Modified:
trunk/src/heartbeat.c
trunk/src/heartbeat.h
trunk/src/nm.c
trunk/src/nm.h
trunk/src/super.c
Log:
* Move ocfs_volume_thread into heartbeat.c and rename it to
ocfs_heartbeat_thread. Wow, what a concept.
Modified: trunk/src/heartbeat.c
===================================================================
--- trunk/src/heartbeat.c 2004-09-09 21:04:42 UTC (rev 1446)
+++ trunk/src/heartbeat.c 2004-09-09 21:08:27 UTC (rev 1447)
@@ -39,6 +39,7 @@
#include "alloc.h"
#include "heartbeat.h"
#include "util.h"
+#include "volcfg.h"
#include "vote.h"
#include "ocfs_journal.h"
@@ -226,3 +227,132 @@
LOG_EXIT ();
return;
} /* ocfs_update_publish_map */
+
+
+/* half a second timeout */
+#define OCFS_HEARTBEAT_JIFFIES (HZ >> 1)
+
+/*
+ * ocfs_heartbeat_thread()
+ *
+ * This function is executed as a kernel thread for each mounted ocfs volume.
+ */
+int ocfs_heartbeat_thread (void *arg)
+{
+ ocfs_super *osb;
+ char proc[16];
+ int status = 0;
+ __u8 *buffer = NULL;
+ ocfs_publish *publish;
+ unsigned long j;
+ __u16 num_nodes = 0;
+ ocfs_node_config_hdr *node_cfg_hdr = NULL;
+ __u64 cfg_seq_num;
+ struct buffer_head *bh = NULL;
+ siginfo_t info;
+
+ LOG_ENTRY ();
+
+ osb = arg;
+
+ sprintf (proc, "ocfs2nm-%d", osb->osb_id);
+ ocfs_daemonize (proc, strlen(proc), 1);
+
+ osb->dlm_task = current;
+
+ osb->hbt = OCFS_HEARTBEAT_JIFFIES + jiffies;
+ /* The delay changes based on multiplier */
+ while (!(OcfsGlobalCtxt.flags & OCFS_FLAG_SHUTDOWN_VOL_THREAD) &&
+ !(osb->osb_flags & OCFS_OSB_FLAGS_BEING_DISMOUNTED)) {
+
+ buffer = NULL;
+
+ if (!time_after (jiffies, (unsigned long) (osb->hbt)))
+ goto again;
+
+ /* lock publish to prevent overwrites from vote_req and vote_reset */
+ down (&(osb->publish_lock));
+
+ /* Read disk for 4 autoconfig blocks + all nodes publish blocks */
+ status = ocfs_read_bhs(osb,
+ osb->new_autoconfig_blkno << osb->sb->s_blocksize_bits,
+ (u64)osb->total_autoconfig_blocks << osb->sb->s_blocksize_bits,
+ osb->autoconfig_bhs, 0, NULL);
+ if (status < 0) {
+ up (&(osb->publish_lock));
+ LOG_ERROR_STATUS (status);
+ BUG();
+ }
+
+ bh = osb->autoconfig_bhs[OCFS_VOLCFG_NEWCFG_SECTORS + osb->node_num];
+ publish = (ocfs_publish *) bh->b_data;
+ if ((osb->check_mounted) && (publish->mounted == 0)) {
+ printk("ocfs2: Heartbeat timed out, volume has been "
+ "recovered from another node!\n");
+
+ BUG();
+ }
+ bh = NULL;
+
+ ocfs_nm_heart_beat (osb, HEARTBEAT_METHOD_DISK, 0);
+
+ /* release publish lock */
+ up (&(osb->publish_lock));
+
+ /* If another node was added to the config read and update the cfg */
+ node_cfg_hdr =
+ (ocfs_node_config_hdr *) osb->autoconfig_bhs[1]->b_data;
+ num_nodes = node_cfg_hdr->num_nodes;
+ cfg_seq_num = node_cfg_hdr->cfg_seq_num;
+
+ if ((osb->cfg_seq_num != cfg_seq_num) ||
+ (osb->num_cfg_nodes != num_nodes)) {
+ down (&(osb->cfg_lock));
+ status = ocfs_chk_update_config (osb);
+ up (&(osb->cfg_lock));
+ if (status < 0)
+ LOG_ERROR_STATUS (status);
+ }
+
+ num_nodes = osb->max_nodes;
+
+ /* Refresh the publish map */
+ ocfs_update_publish_map (osb, &(osb->autoconfig_bhs[OCFS_VOLCFG_NEWCFG_SECTORS]), 0);
+
+ /* send signal to mount thread to continue */
+ if (atomic_read (&osb->nm_init) < OCFS_HEARTBEAT_INIT) {
+ atomic_inc (&osb->nm_init);
+ } else if (atomic_read(&osb->nm_init) == OCFS_HEARTBEAT_INIT) {
+ wake_up (&osb->nm_init_event);
+ atomic_inc (&osb->nm_init);
+ }
+
+ osb->hbt = OCFS_HEARTBEAT_JIFFIES + jiffies;
+
+again:
+ status = 0;
+
+ if ((OcfsGlobalCtxt.flags & OCFS_FLAG_SHUTDOWN_VOL_THREAD) ||
+ (osb->osb_flags & OCFS_OSB_FLAGS_BEING_DISMOUNTED))
+ break;
+ j = jiffies;
+ if (time_after (j, (unsigned long) (osb->hbt))) {
+ osb->hbt = OCFS_HEARTBEAT_JIFFIES + j;
+ }
+ set_current_state (TASK_INTERRUPTIBLE);
+ schedule_timeout (osb->hbt - j);
+
+ /* ignore the actual signal */
+ if (signal_pending(current)) {
+ dequeue_signal_lock(current, ¤t->blocked, &info);
+ }
+ }
+
+ /* Flush all scheduled tasks */
+ flush_scheduled_work();
+
+ complete (&(osb->dlm_complete));
+
+ LOG_EXIT_INT (0);
+ return 0;
+} /* ocfs_heartbeat_thread */
Modified: trunk/src/heartbeat.h
===================================================================
--- trunk/src/heartbeat.h 2004-09-09 21:04:42 UTC (rev 1446)
+++ trunk/src/heartbeat.h 2004-09-09 21:08:27 UTC (rev 1447)
@@ -32,5 +32,6 @@
int ocfs_nm_heart_beat(ocfs_super *osb, __u32 flag, int read_publish);
void ocfs_update_publish_map(ocfs_super *osb, struct buffer_head *bhs[],
int first_time);
+int ocfs_heartbeat_thread(void *arg);
#endif /* OCFS2_HEARTBEAT_H */
Modified: trunk/src/nm.c
===================================================================
--- trunk/src/nm.c 2004-09-09 21:04:42 UTC (rev 1446)
+++ trunk/src/nm.c 2004-09-09 21:08:27 UTC (rev 1447)
@@ -45,7 +45,6 @@
#include "lockres.h"
#include "nm.h"
#include "util.h"
-#include "volcfg.h"
#include "vote.h"
#include "extmap.h"
#include "file.h"
@@ -167,137 +166,6 @@
return 0;
} /* ocfs_recv_thread */
-
-
-/* half a second timeout */
-#define OCFS_HEARTBEAT_JIFFIES (HZ >> 1)
-
-/*
- * ocfs_volume_thread()
- *
- * This function is executed as a kernel thread for each mounted ocfs volume.
- */
-int ocfs_volume_thread (void *arg)
-{
- ocfs_super *osb;
- char proc[16];
- int status = 0;
- __u8 *buffer = NULL;
- ocfs_publish *publish;
- unsigned long j;
- __u16 num_nodes = 0;
- ocfs_node_config_hdr *node_cfg_hdr = NULL;
- __u64 cfg_seq_num;
- struct buffer_head *bh = NULL;
- siginfo_t info;
-
- LOG_ENTRY ();
-
- osb = arg;
-
- sprintf (proc, "ocfs2nm-%d", osb->osb_id);
- ocfs_daemonize (proc, strlen(proc), 1);
-
- osb->dlm_task = current;
-
- osb->hbt = OCFS_HEARTBEAT_JIFFIES + jiffies;
- /* The delay changes based on multiplier */
- while (!(OcfsGlobalCtxt.flags & OCFS_FLAG_SHUTDOWN_VOL_THREAD) &&
- !(osb->osb_flags & OCFS_OSB_FLAGS_BEING_DISMOUNTED)) {
-
- buffer = NULL;
-
- if (!time_after (jiffies, (unsigned long) (osb->hbt)))
- goto again;
-
- /* lock publish to prevent overwrites from vote_req and vote_reset */
- down (&(osb->publish_lock));
-
- /* Read disk for 4 autoconfig blocks + all nodes publish blocks */
- status = ocfs_read_bhs(osb,
- osb->new_autoconfig_blkno << osb->sb->s_blocksize_bits,
- (u64)osb->total_autoconfig_blocks << osb->sb->s_blocksize_bits,
- osb->autoconfig_bhs, 0, NULL);
- if (status < 0) {
- up (&(osb->publish_lock));
- LOG_ERROR_STATUS (status);
- BUG();
- }
-
- bh = osb->autoconfig_bhs[OCFS_VOLCFG_NEWCFG_SECTORS + osb->node_num];
- publish = (ocfs_publish *) bh->b_data;
- if ((osb->check_mounted) && (publish->mounted == 0)) {
- printk("ocfs2: Heartbeat timed out, volume has been "
- "recovered from another node!\n");
-
- BUG();
- }
- bh = NULL;
-
- ocfs_nm_heart_beat (osb, HEARTBEAT_METHOD_DISK, 0);
-
- /* release publish lock */
- up (&(osb->publish_lock));
-
- /* If another node was added to the config read and update the cfg */
- node_cfg_hdr =
- (ocfs_node_config_hdr *) osb->autoconfig_bhs[1]->b_data;
- num_nodes = node_cfg_hdr->num_nodes;
- cfg_seq_num = node_cfg_hdr->cfg_seq_num;
-
- if ((osb->cfg_seq_num != cfg_seq_num) ||
- (osb->num_cfg_nodes != num_nodes)) {
- down (&(osb->cfg_lock));
- status = ocfs_chk_update_config (osb);
- up (&(osb->cfg_lock));
- if (status < 0)
- LOG_ERROR_STATUS (status);
- }
-
- num_nodes = osb->max_nodes;
-
- /* Refresh the publish map */
- ocfs_update_publish_map (osb, &(osb->autoconfig_bhs[OCFS_VOLCFG_NEWCFG_SECTORS]), 0);
-
- /* send signal to mount thread to continue */
- if (atomic_read (&osb->nm_init) < OCFS_HEARTBEAT_INIT) {
- atomic_inc (&osb->nm_init);
- } else if (atomic_read(&osb->nm_init) == OCFS_HEARTBEAT_INIT) {
- wake_up (&osb->nm_init_event);
- atomic_inc (&osb->nm_init);
- }
-
- osb->hbt = OCFS_HEARTBEAT_JIFFIES + jiffies;
-
-again:
- status = 0;
-
- if ((OcfsGlobalCtxt.flags & OCFS_FLAG_SHUTDOWN_VOL_THREAD) ||
- (osb->osb_flags & OCFS_OSB_FLAGS_BEING_DISMOUNTED))
- break;
- j = jiffies;
- if (time_after (j, (unsigned long) (osb->hbt))) {
- osb->hbt = OCFS_HEARTBEAT_JIFFIES + j;
- }
- set_current_state (TASK_INTERRUPTIBLE);
- schedule_timeout (osb->hbt - j);
-
- /* ignore the actual signal */
- if (signal_pending(current)) {
- dequeue_signal_lock(current, ¤t->blocked, &info);
- }
- }
-
- /* Flush all scheduled tasks */
- flush_scheduled_work();
-
- complete (&(osb->dlm_complete));
-
- LOG_EXIT_INT (0);
- return 0;
-} /* ocfs_volume_thread */
-
-
// gets a best guess (based on dirty read of lockres)
// of whether down_read or down_write should be used on lockres
// NOTE: always RECHECK after getting the lock and follow what
Modified: trunk/src/nm.h
===================================================================
--- trunk/src/nm.h 2004-09-09 21:04:42 UTC (rev 1446)
+++ trunk/src/nm.h 2004-09-09 21:08:27 UTC (rev 1447)
@@ -35,6 +35,5 @@
int ocfs_process_vote (ocfs_super * osb, ocfs_dlm_msg *dlm_msg);
int ocfs_recv_thread(void *unused);
void ocfs_recover_oin_locks(ocfs_super *osb, __u32 node_num);
-int ocfs_volume_thread(void *arg);
#endif /* OCFS2_NM_H */
Modified: trunk/src/super.c
===================================================================
--- trunk/src/super.c 2004-09-09 21:04:42 UTC (rev 1446)
+++ trunk/src/super.c 2004-09-09 21:08:27 UTC (rev 1447)
@@ -984,7 +984,7 @@
/* Launch the NM thread for the mounted volume */
osb->dlm_task = NULL;
- child_pid = kernel_thread (ocfs_volume_thread, osb,
+ child_pid = kernel_thread (ocfs_heartbeat_thread, osb,
CLONE_FS | CLONE_FILES | CLONE_SIGHAND);
if (child_pid < 0) {
LOG_ERROR_ARGS ("unable to launch ocfs2nm thread, error=%d",
More information about the Ocfs2-commits
mailing list