[Ocfs2-commits] smushran commits r2280 - in trunk/fs/ocfs2: . cluster

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed May 18 15:48:56 CDT 2005


Author: smushran
Signed-off-by: zab
Signed-off-by: mfasheh
Date: 2005-05-18 15:48:54 -0500 (Wed, 18 May 2005)
New Revision: 2280

Modified:
   trunk/fs/ocfs2/cluster/heartbeat.c
   trunk/fs/ocfs2/cluster/heartbeat.h
   trunk/fs/ocfs2/heartbeat.c
   trunk/fs/ocfs2/heartbeat.h
   trunk/fs/ocfs2/inode.c
   trunk/fs/ocfs2/super.c
Log:
fixes bugzilla#424
basically not oops on a failed mount
also will expect mount.ocfs2 to stop heartbeat on a failed mount
Signed-off-by: zab
Signed-off-by: mfasheh

Modified: trunk/fs/ocfs2/cluster/heartbeat.c
===================================================================
--- trunk/fs/ocfs2/cluster/heartbeat.c	2005-05-18 06:41:34 UTC (rev 2279)
+++ trunk/fs/ocfs2/cluster/heartbeat.c	2005-05-18 20:48:54 UTC (rev 2280)
@@ -1266,6 +1266,7 @@
 	hc->hc_data = data;
 	hc->hc_priority = priority;
 	hc->hc_type = type;
+	hc->hc_magic = HB_CB_MAGIC;
 }
 EXPORT_SYMBOL(hb_setup_callback);
 
@@ -1275,6 +1276,7 @@
 	struct list_head *iter;
 	struct hb_callback *hbcall;
 
+	BUG_ON(hc->hc_magic != HB_CB_MAGIC);
 	BUG_ON(!list_empty(&hc->hc_item));
 
 	hbcall = hbcall_from_type(hc->hc_type);
@@ -1301,8 +1303,11 @@
 
 int hb_unregister_callback(struct hb_callback_func *hc)
 {
-	BUG_ON(list_empty(&hc->hc_item));
+	BUG_ON(hc->hc_magic != HB_CB_MAGIC);
 
+	if (list_empty(&hc->hc_item))
+		return 0;
+
 	down_write(&hb_callback_sem);
 
 	list_del_init(&hc->hc_item);

Modified: trunk/fs/ocfs2/cluster/heartbeat.h
===================================================================
--- trunk/fs/ocfs2/cluster/heartbeat.h	2005-05-18 06:41:34 UTC (rev 2279)
+++ trunk/fs/ocfs2/cluster/heartbeat.h	2005-05-18 20:48:54 UTC (rev 2280)
@@ -29,6 +29,8 @@
 
 #include "ocfs2_heartbeat.h"
 
+#define HB_CB_MAGIC		0x51d1e4ec
+
 /* callback stuff */
 enum hb_callback_type {
 	HB_NODE_DOWN_CB = 0,
@@ -40,6 +42,7 @@
 typedef void (hb_cb_func)(struct nm_node *, int, void *);
 
 struct hb_callback_func {
+	u32			hc_magic;
 	struct list_head	hc_item;
 	hb_cb_func		*hc_func;
 	void			*hc_data;

Modified: trunk/fs/ocfs2/heartbeat.c
===================================================================
--- trunk/fs/ocfs2/heartbeat.c	2005-05-18 06:41:34 UTC (rev 2279)
+++ trunk/fs/ocfs2/heartbeat.c	2005-05-18 20:48:54 UTC (rev 2280)
@@ -101,21 +101,26 @@
 	ocfs_node_map_clear_bit(osb, &osb->umount_map, node_num);
 }
 
+void ocfs2_setup_hb_callbacks(ocfs_super *osb)
+{
+	hb_setup_callback(&osb->osb_hb_down, HB_NODE_DOWN_CB,
+			  ocfs2_hb_node_down_cb, osb, OCFS2_HB_NODE_DOWN_PRI);
+
+	hb_setup_callback(&osb->osb_hb_up, HB_NODE_UP_CB, ocfs2_hb_node_up_cb,
+			  osb, OCFS2_HB_NODE_UP_PRI);
+}
+
 /* Most functions here are just stubs for now... */
 int ocfs2_register_hb_callbacks(ocfs_super *osb)
 {
 	int status;
 
-	hb_setup_callback(&osb->osb_hb_down, HB_NODE_DOWN_CB,
-			  ocfs2_hb_node_down_cb, osb, OCFS2_HB_NODE_DOWN_PRI);
 	status = hb_register_callback(&osb->osb_hb_down);
 	if (status < 0) {
 		mlog_errno(status);
 		goto bail;
 	}
 
-	hb_setup_callback(&osb->osb_hb_up, HB_NODE_UP_CB, ocfs2_hb_node_up_cb,
-			  osb, OCFS2_HB_NODE_UP_PRI);
 	status = hb_register_callback(&osb->osb_hb_up);
 	if (status < 0)
 		mlog_errno(status);

Modified: trunk/fs/ocfs2/heartbeat.h
===================================================================
--- trunk/fs/ocfs2/heartbeat.h	2005-05-18 06:41:34 UTC (rev 2279)
+++ trunk/fs/ocfs2/heartbeat.h	2005-05-18 20:48:54 UTC (rev 2280)
@@ -28,6 +28,7 @@
 
 void ocfs2_init_node_maps(ocfs_super *osb);
 
+void ocfs2_setup_hb_callbacks(ocfs_super *osb);
 int ocfs2_register_hb_callbacks(ocfs_super *osb);
 void ocfs2_clear_hb_callbacks(ocfs_super *osb);
 void ocfs2_stop_heartbeat(ocfs_super *osb);

Modified: trunk/fs/ocfs2/inode.c
===================================================================
--- trunk/fs/ocfs2/inode.c	2005-05-18 06:41:34 UTC (rev 2279)
+++ trunk/fs/ocfs2/inode.c	2005-05-18 20:48:54 UTC (rev 2280)
@@ -744,6 +744,8 @@
 
 	/* we should not really be using osb in this context. */
 	osb = OCFS2_SB(inode->i_sb);
+	if (!osb)
+		goto bail;
 
 	if (!inode->u.generic_ip) {
 		mlog(ML_ERROR, "inode %lu has no generic_ip!\n", inode->i_ino);

Modified: trunk/fs/ocfs2/super.c
===================================================================
--- trunk/fs/ocfs2/super.c	2005-05-18 06:41:34 UTC (rev 2279)
+++ trunk/fs/ocfs2/super.c	2005-05-18 20:48:54 UTC (rev 2280)
@@ -80,7 +80,7 @@
 
 static void ocfs_put_super(struct super_block *sb);
 static int ocfs_mount_volume(struct super_block *sb);
-static void ocfs_dismount_volume(struct super_block *sb);
+static void ocfs_dismount_volume(struct super_block *sb, int mnt_err);
 static int ocfs_initialize_mem_caches(void);
 static void ocfs_free_mem_caches(void);
 static void ocfs_delete_osb(ocfs_super * osb);
@@ -204,7 +204,8 @@
 		if (!new) {
 			ocfs_release_system_inodes(osb);
 			status = -EINVAL;
-			mlog_errno(status);
+			mlog(ML_ERROR, "status=%d, sysfile=%d, slot=%d\n",
+			     status, i, osb->slot_num);
 			goto bail;
 		}
 		// the array now has one ref, so drop this one
@@ -313,6 +314,8 @@
 	/* ocfs_mount_volume may set osb even on error so we want to
 	 * pull it off for proper cleanup. */
 	osb = OCFS2_SB(sb);
+	if (osb && osb->root_inode)
+		inode = osb->root_inode;
 
 	if (status < 0)
 		goto read_super_error;
@@ -325,7 +328,6 @@
 		goto read_super_error;
 	}
 
-	inode = osb->root_inode;
 	if (!inode) {
 		status = -EIO;
 		mlog_errno(status);
@@ -359,7 +361,7 @@
 	if (osb) {
 		atomic_set(&osb->vol_state, VOLUME_DISABLED);
 		wake_up(&osb->osb_mount_event);
-		ocfs_dismount_volume (sb);
+		ocfs_dismount_volume (sb, 1);
 	}
 
 	if (inode)
@@ -452,7 +454,7 @@
 	mlog_entry ("(0x%p)\n", sb);
 
 	ocfs_sync_blockdev(sb);
-	ocfs_dismount_volume (sb);
+	ocfs_dismount_volume (sb, 0);
 
 	mlog_exit_void ();
 }				/* ocfs_put_super */
@@ -819,7 +821,7 @@
  * ocfs_dismount_volume()
  *
  */
-static void ocfs_dismount_volume (struct super_block *sb)
+static void ocfs_dismount_volume (struct super_block *sb, int mnt_err)
 {
 	int tmp;
 	ocfs_super *osb = NULL;
@@ -868,7 +870,8 @@
 		if (tmp < 0)
 			mlog_errno(tmp);
 
-		ocfs2_put_slot(osb);
+		if (osb->slot_num != OCFS_INVALID_NODE_NUM)
+			ocfs2_put_slot(osb);
 	}
 
 	ocfs_release_system_inodes(osb);
@@ -881,7 +884,8 @@
 
 	ocfs2_clear_hb_callbacks(osb);
 
-	ocfs2_stop_heartbeat(osb);
+	if (!mnt_err)
+		ocfs2_stop_heartbeat(osb);
 
 	atomic_set(&osb->vol_state, VOLUME_DISMOUNTED);
 
@@ -891,6 +895,7 @@
 	ocfs_delete_osb(osb);
 	kfree(osb);
 	sb->s_dev = 0;
+	sb->s_fs_info = NULL;
 }				/* ocfs_dismount_volume */
 
 static int osb_setup_uuid(ocfs_super *osb, const unsigned char *uuid,
@@ -979,6 +984,8 @@
 	osb->local_alloc_state = OCFS2_LA_UNUSED;
 	osb->local_alloc_bh = NULL;
 
+	ocfs2_setup_hb_callbacks(osb);
+
 	init_waitqueue_head(&osb->osb_mount_event);
 	
 	osb->vol_label = kmalloc(64, GFP_KERNEL);



More information about the Ocfs2-commits mailing list