[Ocfs2-commits] manish commits r2308 - in trunk/fs/ocfs2: . cluster dlm

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon May 23 18:35:23 CDT 2005


Author: manish
Signed-off-by: jlbec
Date: 2005-05-23 18:35:22 -0500 (Mon, 23 May 2005)
New Revision: 2308

Modified:
   trunk/fs/ocfs2/alloc.c
   trunk/fs/ocfs2/cluster/heartbeat.c
   trunk/fs/ocfs2/cluster/ocfs2_nodemanager.h
   trunk/fs/ocfs2/dlm/dlmdomain.c
   trunk/fs/ocfs2/dlm/dlmrecovery.c
   trunk/fs/ocfs2/heartbeat.c
   trunk/fs/ocfs2/inode.c
   trunk/fs/ocfs2/journal.c
   trunk/fs/ocfs2/namei.c
   trunk/fs/ocfs2/ocfs.h
   trunk/fs/ocfs2/ocfs2_fs.h
   trunk/fs/ocfs2/slot_map.c
   trunk/fs/ocfs2/slot_map.h
   trunk/fs/ocfs2/super.c
   trunk/fs/ocfs2/vote.c
Log:
Fix node/slot confusion, and make consistent use of constants

Signed-off-by: jlbec


Modified: trunk/fs/ocfs2/alloc.c
===================================================================
--- trunk/fs/ocfs2/alloc.c	2005-05-23 23:28:05 UTC (rev 2307)
+++ trunk/fs/ocfs2/alloc.c	2005-05-23 23:35:22 UTC (rev 2308)
@@ -139,7 +139,7 @@
 
 /* expects array to already be malloced 
  *
- * sets h_signature, h_blkno, h_suballoc_bit, h_suballoc_node, and
+ * sets h_signature, h_blkno, h_suballoc_bit, h_suballoc_slot, and
  * l_count for you 
  */
 static int ocfs_create_new_meta_bhs(ocfs_super *osb, 
@@ -196,10 +196,10 @@
 			eb->h_fs_generation = cpu_to_le32(osb->fs_generation);
 
 #ifndef OCFS_USE_ALL_METADATA_SUBALLOCATORS
-			/* we always use node zeros suballocator */
-			eb->h_suballoc_node = 0;
+			/* we always use slot zero's suballocator */
+			eb->h_suballoc_slot = 0;
 #else
-			eb->h_suballoc_node = cpu_to_le16(osb->slot_num);
+			eb->h_suballoc_slot = cpu_to_le16(osb->slot_num);
 #endif
 			eb->h_suballoc_bit = cpu_to_le16(suballoc_bit_start);
 			eb->h_list.l_count = ocfs2_extent_recs_per_eb(osb->sb);
@@ -1608,7 +1608,7 @@
 
 		if (!el->l_next_free_rec) {
 			mlog(0, "deleting this extent block.\n");
-			OCFS_ASSERT(!eb->h_suballoc_node);
+			OCFS_ASSERT(!eb->h_suballoc_slot);
 			OCFS_ASSERT(!el->l_recs[0].e_clusters);
 			OCFS_ASSERT(!el->l_recs[0].e_cpos);
 			OCFS_ASSERT(!el->l_recs[0].e_blkno);

Modified: trunk/fs/ocfs2/cluster/heartbeat.c
===================================================================
--- trunk/fs/ocfs2/cluster/heartbeat.c	2005-05-23 23:28:05 UTC (rev 2307)
+++ trunk/fs/ocfs2/cluster/heartbeat.c	2005-05-23 23:35:22 UTC (rev 2308)
@@ -422,7 +422,7 @@
 	node_num = nm_this_node();
 	slot = &reg->hr_slots[node_num];
 
-	hb_block = (struct hb_disk_heartbeat_block *) slot->ds_raw_block;
+	hb_block = (struct hb_disk_heartbeat_block *)slot->ds_raw_block;
 	memset(hb_block, 0, reg->hr_block_bytes);
 	/* TODO: time stuff */
 	cputime = CURRENT_TIME.tv_sec;
@@ -900,7 +900,7 @@
 	if (!p || (*p && (*p != '\n')))
 		return -EINVAL;
 
-	if (tmp >= NM_MAX_NODES)
+	if (tmp > NM_MAX_NODES || tmp == 0)
 		return -ERANGE;
 
 	reg->hr_blocks = (unsigned int)tmp;

Modified: trunk/fs/ocfs2/cluster/ocfs2_nodemanager.h
===================================================================
--- trunk/fs/ocfs2/cluster/ocfs2_nodemanager.h	2005-05-23 23:28:05 UTC (rev 2307)
+++ trunk/fs/ocfs2/cluster/ocfs2_nodemanager.h	2005-05-23 23:35:22 UTC (rev 2308)
@@ -28,12 +28,10 @@
 #ifndef _OCFS2_NODEMANAGER_H
 #define _OCFS2_NODEMANAGER_H
 
-#include "ocfs2_heartbeat.h"
-
 #define NM_API_VERSION		2
 
 #define NM_MAX_NODES		255
-#define NM_INVALID_SLOT_NUM	255
+#define NM_INVALID_NODE_NUM	255
 
 /* host name, group name, cluster name all 64 bytes */
 #define NM_MAX_NAME_LEN          64    // __NEW_UTS_LEN

Modified: trunk/fs/ocfs2/dlm/dlmdomain.c
===================================================================
--- trunk/fs/ocfs2/dlm/dlmdomain.c	2005-05-23 23:28:05 UTC (rev 2307)
+++ trunk/fs/ocfs2/dlm/dlmdomain.c	2005-05-23 23:35:22 UTC (rev 2308)
@@ -1193,8 +1193,8 @@
 	dlm->joining_node = DLM_LOCK_RES_OWNER_UNKNOWN;
 	init_waitqueue_head(&dlm->dlm_join_events);
 
-	dlm->reco.new_master = NM_INVALID_SLOT_NUM;
-	dlm->reco.dead_node = NM_INVALID_SLOT_NUM;
+	dlm->reco.new_master = NM_INVALID_NODE_NUM;
+	dlm->reco.dead_node = NM_INVALID_NODE_NUM;
 	atomic_set(&dlm->local_resources, 0);
 	atomic_set(&dlm->remote_resources, 0);
 	atomic_set(&dlm->unknown_resources, 0);

Modified: trunk/fs/ocfs2/dlm/dlmrecovery.c
===================================================================
--- trunk/fs/ocfs2/dlm/dlmrecovery.c	2005-05-23 23:28:05 UTC (rev 2307)
+++ trunk/fs/ocfs2/dlm/dlmrecovery.c	2005-05-23 23:35:22 UTC (rev 2308)
@@ -117,8 +117,8 @@
 {
 	spin_lock(&dlm->spinlock);
 	clear_bit(dlm->reco.dead_node, dlm->recovery_map);
-	dlm->reco.dead_node = NM_INVALID_SLOT_NUM;
-	dlm->reco.new_master = NM_INVALID_SLOT_NUM;
+	dlm->reco.dead_node = NM_INVALID_NODE_NUM;
+	dlm->reco.new_master = NM_INVALID_NODE_NUM;
 	spin_unlock(&dlm->spinlock);
 }
 
@@ -259,31 +259,31 @@
 	spin_lock(&dlm->spinlock);
 
 	/* check to see if the new master has died */
-	if (dlm->reco.new_master != NM_INVALID_SLOT_NUM &&
+	if (dlm->reco.new_master != NM_INVALID_NODE_NUM &&
 	    test_bit(dlm->reco.new_master, dlm->recovery_map)) {
 		mlog(0, "new master %u died while recovering %u!\n",
 		     dlm->reco.new_master, dlm->reco.dead_node);
 		/* unset the new_master, leave dead_node */
-		dlm->reco.new_master = NM_INVALID_SLOT_NUM;
+		dlm->reco.new_master = NM_INVALID_NODE_NUM;
 	}
 
 	/* select a target to recover */
-	if (dlm->reco.dead_node == NM_INVALID_SLOT_NUM) {
+	if (dlm->reco.dead_node == NM_INVALID_NODE_NUM) {
 		int bit;
 
 		bit = find_next_bit (dlm->recovery_map, NM_MAX_NODES+1, 0);
 		if (bit >= NM_MAX_NODES || bit < 0)
-			dlm->reco.dead_node = NM_INVALID_SLOT_NUM;
+			dlm->reco.dead_node = NM_INVALID_NODE_NUM;
 		else 
 			dlm->reco.dead_node = bit;
 	} else if (!test_bit(dlm->reco.dead_node, dlm->recovery_map)) {
 		/* BUG? */
 		mlog(ML_ERROR, "dead_node %u no longer in recovery map!\n",
 		     dlm->reco.dead_node);
-		dlm->reco.dead_node = NM_INVALID_SLOT_NUM;
+		dlm->reco.dead_node = NM_INVALID_NODE_NUM;
 	}
 
-	if (dlm->reco.dead_node == NM_INVALID_SLOT_NUM) {
+	if (dlm->reco.dead_node == NM_INVALID_NODE_NUM) {
 		// mlog(0, "nothing to recover!  sleeping now!\n");
 		spin_unlock(&dlm->spinlock);
 		/* return to main thread loop and sleep. */
@@ -300,7 +300,7 @@
 	if (dlm->reco.new_master == dlm->node_num)
 		goto master_here;
 
-	if (dlm->reco.new_master == NM_INVALID_SLOT_NUM) {
+	if (dlm->reco.new_master == NM_INVALID_NODE_NUM) {
 		/* choose a new master */
 		if (!dlm_pick_recovery_master(dlm)) {
 			/* already notified everyone.  go. */
@@ -1690,7 +1690,7 @@
 		}
 	} else if (ret == DLM_NOTQUEUED) {
 		/* another node is master. wait on 
-		 * reco.new_master != NM_INVALID_SLOT_NUM */
+		 * reco.new_master != NM_INVALID_NODE_NUM */
 		status = -EEXIST;
 	} 
 
@@ -1763,11 +1763,11 @@
 	mlog(0, "node %u wants to recover node %u\n",
 		  br->node_idx, br->dead_node);
 	spin_lock(&dlm->spinlock);
-	if (dlm->reco.new_master != NM_INVALID_SLOT_NUM) {
+	if (dlm->reco.new_master != NM_INVALID_NODE_NUM) {
 		mlog(0, "new_master already set to %u!\n",
 			  dlm->reco.new_master);
 	}
-	if (dlm->reco.dead_node != NM_INVALID_SLOT_NUM) {
+	if (dlm->reco.dead_node != NM_INVALID_NODE_NUM) {
 		mlog(0, "dead_node already set to %u!\n",
 			  dlm->reco.dead_node);
 	}

Modified: trunk/fs/ocfs2/heartbeat.c
===================================================================
--- trunk/fs/ocfs2/heartbeat.c	2005-05-23 23:28:05 UTC (rev 2307)
+++ trunk/fs/ocfs2/heartbeat.c	2005-05-23 23:35:22 UTC (rev 2308)
@@ -155,7 +155,7 @@
 		return;
 	}
 
-	argv[0] = (char *) nm_get_hb_ctl_path();
+	argv[0] = (char *)nm_get_hb_ctl_path();
 	argv[1] = "-K";
 	argv[2] = "-u";
 	argv[3] = osb->uuid_str;
@@ -312,9 +312,9 @@
 {
 	int i = idx;
 
-	idx = OCFS_INVALID_NODE_NUM;
+	idx = NM_INVALID_NODE_NUM;
 	spin_lock(&osb->node_map_lock);
-	if ((i != OCFS_INVALID_NODE_NUM) &&
+	if ((i != NM_INVALID_NODE_NUM) &&
 	    (i >= 0) &&
 	    (i < map->num_nodes)) {
 		while(i < map->num_nodes) {

Modified: trunk/fs/ocfs2/inode.c
===================================================================
--- trunk/fs/ocfs2/inode.c	2005-05-23 23:28:05 UTC (rev 2307)
+++ trunk/fs/ocfs2/inode.c	2005-05-23 23:35:22 UTC (rev 2308)
@@ -248,7 +248,7 @@
 		     OCFS2_I(inode)->ip_blkno, fe->i_blkno);
 
 	OCFS2_I(inode)->ip_clusters = fe->i_clusters;
-	OCFS2_I(inode)->ip_orphaned_slot = OCFS_INVALID_NODE_NUM;
+	OCFS2_I(inode)->ip_orphaned_slot = OCFS2_INVALID_SLOT;
 
 	if (create_ino)
 		inode->i_ino = ino_from_blkno(inode->i_sb, fe->i_blkno);
@@ -529,7 +529,7 @@
 	orphaned_slot = OCFS2_I(inode)->ip_orphaned_slot;
 	spin_unlock(&OCFS2_I(inode)->ip_lock);
 
-	if (orphaned_slot == OCFS_INVALID_NODE_NUM) {
+	if (orphaned_slot == OCFS2_INVALID_SLOT) {
 		/* Nobody knew which slot this inode was orphaned
 		 * into. This may happen during node death and
 		 * recovery knows how to clean it up so we can safely
@@ -601,7 +601,9 @@
 		goto bail;
 	}
 
-	inode_alloc_inode = ocfs_get_system_file_inode(osb, INODE_ALLOC_SYSTEM_INODE, le16_to_cpu(fe->i_suballoc_node));
+	inode_alloc_inode =
+		ocfs_get_system_file_inode(osb, INODE_ALLOC_SYSTEM_INODE,
+					   le16_to_cpu(fe->i_suballoc_slot));
 	if (!inode_alloc_inode) {
 		status = -EEXIST;
 		mlog_errno(status);

Modified: trunk/fs/ocfs2/journal.c
===================================================================
--- trunk/fs/ocfs2/journal.c	2005-05-23 23:28:05 UTC (rev 2307)
+++ trunk/fs/ocfs2/journal.c	2005-05-23 23:35:22 UTC (rev 2308)
@@ -1011,7 +1011,7 @@
 	while(!ocfs_node_map_is_empty(osb, &osb->recovery_map)) {
 		node_num = ocfs_node_map_first_set_bit(osb,
 						       &osb->recovery_map);
-		if (node_num == OCFS_INVALID_NODE_NUM) {
+		if (node_num == NM_INVALID_NODE_NUM) {
 			mlog(0, "Out of nodes to recover.\n");
 			break;
 		}
@@ -1236,7 +1236,7 @@
 		BUG();
 
 	slot_num = ocfs2_node_num_to_slot(si, node_num);
-	if (slot_num == OCFS_INVALID_NODE_NUM) {
+	if (slot_num == OCFS2_INVALID_SLOT) {
 		status = 0;
 		mlog(0, "no slot for this node, so no recovery required.\n");
 		goto done;
@@ -1335,11 +1335,12 @@
 
 	spin_lock(&si->si_lock);
 	for(i = 0; i < si->si_num_slots; i++) {
-		node_num = si->si_global_node_nums[i];
 		if (i == osb->slot_num)
 			continue;
-		if (node_num == OCFS_INVALID_NODE_NUM)
+		if (ocfs2_is_empty_slot(si, i))
 			continue;
+
+		node_num = si->si_global_node_nums[i];
 		if (ocfs_node_map_test_bit(osb, &osb->recovery_map, node_num))
 			continue;
 		spin_unlock(&si->si_lock);

Modified: trunk/fs/ocfs2/namei.c
===================================================================
--- trunk/fs/ocfs2/namei.c	2005-05-23 23:28:05 UTC (rev 2307)
+++ trunk/fs/ocfs2/namei.c	2005-05-23 23:35:22 UTC (rev 2308)
@@ -547,7 +547,7 @@
 	fe->i_fs_generation = cpu_to_le32(osb->fs_generation);
 	fe->i_blkno = fe_blkno;
 	fe->i_suballoc_bit = cpu_to_le16(suballoc_bit);
-	fe->i_suballoc_node = cpu_to_le16(osb->slot_num);
+	fe->i_suballoc_slot = cpu_to_le16(osb->slot_num);
 	fe->i_uid = current->fsuid;
 	if (dir->i_mode & S_ISGID) {
 		fe->i_gid = dir->i_gid;

Modified: trunk/fs/ocfs2/ocfs.h
===================================================================
--- trunk/fs/ocfs2/ocfs.h	2005-05-23 23:28:05 UTC (rev 2307)
+++ trunk/fs/ocfs2/ocfs.h	2005-05-23 23:35:22 UTC (rev 2308)
@@ -58,8 +58,6 @@
 
 #define  OCFS_MAX_OSB_ID             65536
 
-#define  OCFS_INVALID_NODE_NUM         -1
-
 #define OCFS2_IS_VALID_DINODE(ptr)					\
 	(!strcmp((ptr)->i_signature, OCFS2_INODE_SIGNATURE))
 
@@ -267,7 +265,7 @@
 
 	unsigned long s_mount_opt;
 
-	u16 max_nodes;
+	u16 max_slots;
 	u16 num_nodes;
 	s16 node_num;
 	s16 slot_num;

Modified: trunk/fs/ocfs2/ocfs2_fs.h
===================================================================
--- trunk/fs/ocfs2/ocfs2_fs.h	2005-05-23 23:28:05 UTC (rev 2307)
+++ trunk/fs/ocfs2/ocfs2_fs.h	2005-05-23 23:35:22 UTC (rev 2308)
@@ -111,9 +111,9 @@
 /* System inode flags */
 #define OCFS2_SYSTEM_FL		(0x00000010)	/* System inode */
 #define OCFS2_SUPER_BLOCK_FL	(0x00000020)	/* Super block */
-#define OCFS2_LOCAL_ALLOC_FL	(0x00000040)	/* Node local alloc bitmap */
+#define OCFS2_LOCAL_ALLOC_FL	(0x00000040)	/* Slot local alloc bitmap */
 #define OCFS2_BITMAP_FL		(0x00000080)	/* Allocation bitmap */
-#define OCFS2_JOURNAL_FL	(0x00000100)	/* Node journal */
+#define OCFS2_JOURNAL_FL	(0x00000100)	/* Slot local journal */
 #define OCFS2_HEARTBEAT_FL	(0x00000200)	/* Heartbeat area */
 #define OCFS2_CHAIN_FL		(0x00000400)	/* Chain allocator */
 #define OCFS2_DEALLOC_FL	(0x00000800)	/* Truncate log */
@@ -131,15 +131,15 @@
 /* Limit of space in ocfs2_dir_entry */
 #define OCFS2_MAX_FILENAME_LEN		255
 
-/* Limit of node map bits in ocfs2_disk_lock */
-#define OCFS2_MAX_NODES			255
+/* Maximum slots on an ocfs2 file system */
+#define OCFS2_MAX_SLOTS			255
 
+/* Slot map indicator for an empty slot */
+#define OCFS2_INVALID_SLOT		-1
+
 #define OCFS2_VOL_UUID_LEN		16
 #define OCFS2_MAX_VOL_LABEL_LEN		64
 
-#define OCFS2_MAX_CLUSTER_NAME_LEN	64
-
-
 /* Journal limits (in bytes) */
 #define OCFS2_MIN_JOURNAL_SIZE		(4 * 1024 * 1024)
 #define OCFS2_MAX_JOURNAL_SIZE		(500 * 1024 * 1024)
@@ -179,7 +179,7 @@
 	[HEARTBEAT_SYSTEM_INODE]		= { "heartbeat", OCFS2_HEARTBEAT_FL, S_IFREG | 0644 },
 	[GLOBAL_BITMAP_SYSTEM_INODE]		= { "global_bitmap", 0, S_IFREG | 0644 },
 
-	/* Node-specific system inodes (one copy per node) */
+	/* Slot-specific system inodes (one copy per slot) */
 	[ORPHAN_DIR_SYSTEM_INODE]		= { "orphan_dir:%04d", 0, S_IFDIR | 0755 },
 	[EXTENT_ALLOC_SYSTEM_INODE]		= { "extent_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
 	[INODE_ALLOC_SYSTEM_INODE]		= { "inode_alloc:%04d", OCFS2_BITMAP_FL | OCFS2_CHAIN_FL, S_IFREG | 0644 },
@@ -313,9 +313,9 @@
 {
 /*00*/	__u8 h_signature[8];		/* Signature for verification */
 	__u64 h_reserved1;
-/*10*/	__s16 h_suballoc_node;		/* Node suballocator this
+/*10*/	__s16 h_suballoc_slot;		/* Slot suballocator this
 					   extent_header belongs to */
-	__u16 h_suballoc_bit;		/* Bit offset in suballocater
+	__u16 h_suballoc_bit;		/* Bit offset in suballocator
 					   block group */
 	__u32 h_fs_generation;		/* Must match super block */
 	__u64 h_blkno;			/* Offset on disk, in blocks */
@@ -351,8 +351,8 @@
 					   directory dinode */
 	__u32 s_blocksize_bits;		/* Blocksize for this fs */
 	__u32 s_clustersize_bits;	/* Clustersize for this fs */
-/*40*/	__u16 s_max_nodes;		/* Max nodes in this cluster before
-					   tunefs required */
+/*40*/	__u16 s_max_slots;		/* Max number of simultaneous mounts
+					   before tunefs required */
 	__u16 s_reserved1;
 	__u32 s_reserved2;
 	__u64 s_first_cluster_group;	/* Block offset of 1st cluster
@@ -363,8 +363,8 @@
 } ocfs2_super_block;
 
 /*
- * Local allocation bitmap for OCFS2 nodes
- * Node that it exists inside an ocfs2_dinode, so all offsets are
+ * Local allocation bitmap for OCFS2 slots
+ * Note that it exists inside an ocfs2_dinode, so all offsets are
  * relative to the start of ocfs2_dinode.id2.
  */
 typedef struct _ocfs2_local_alloc
@@ -382,9 +382,9 @@
 typedef struct _ocfs2_dinode {
 /*00*/	__u8 i_signature[8];		/* Signature for validation */
 	__u32 i_generation;		/* Generation number */
-	__s16 i_suballoc_node;		/* Node suballocater this inode
+	__s16 i_suballoc_slot;		/* Slot suballocator this inode
 					   belongs to */
-	__u16 i_suballoc_bit;		/* Bit offset in suballocater
+	__u16 i_suballoc_bit;		/* Bit offset in suballocator
 					   block group */
 /*10*/	__u32 i_reserved0;
 	__u32 i_clusters;		/* Cluster count */
@@ -613,14 +613,14 @@
 }
 
 static inline int ocfs2_sprintf_system_inode_name(char *buf, int len,
-						  int type, int node)
+						  int type, int slot)
 {
 	int chars;
 
         /*
          * Global system inodes can only have one copy.  Everything
          * after OCFS_LAST_GLOBAL_SYSTEM_INODE in the system inode
-         * list has a copy per node.
+         * list has a copy per slot.
          */
 	if (type <= OCFS2_LAST_GLOBAL_SYSTEM_INODE)
 		chars = snprintf(buf, len,
@@ -628,7 +628,7 @@
 	else
 		chars = snprintf(buf, len,
 				 ocfs2_system_inodes[type].si_name,
-				 node);
+				 slot);
 
 	return chars;
 }

Modified: trunk/fs/ocfs2/slot_map.c
===================================================================
--- trunk/fs/ocfs2/slot_map.c	2005-05-23 23:28:05 UTC (rev 2307)
+++ trunk/fs/ocfs2/slot_map.c	2005-05-23 23:35:22 UTC (rev 2308)
@@ -61,7 +61,7 @@
 	spin_lock(&si->si_lock);
 
 	for (i = 0; i < si->si_size; i++)
-		if (si->si_global_node_nums[i] != OCFS_INVALID_NODE_NUM)
+		if (si->si_global_node_nums[i] != OCFS2_INVALID_SLOT)
 			ocfs_node_map_set_bit(osb, &osb->mounted_map,
 					      si->si_global_node_nums[i]);
 
@@ -106,12 +106,12 @@
 }
 
 /* try to find global node in the slot info. Returns
- * OCFS_INVALID_NODE_NUM if nothing is found. */
+ * OCFS2_INVALID_SLOT if nothing is found. */
 static s16 __ocfs2_node_num_to_slot(ocfs2_slot_info *si,
 				    s16 global)
 {
 	int i;
-	s16 ret = OCFS_INVALID_NODE_NUM;
+	s16 ret = OCFS2_INVALID_SLOT;
 
 	for(i = 0; i < si->si_num_slots; i++) {
 		if (global == si->si_global_node_nums[i]) {
@@ -122,6 +122,20 @@
 	return ret;
 }
 
+static s16 __ocfs2_find_empty_slot(ocfs2_slot_info *si)
+{
+	int i;
+	s16 ret = OCFS2_INVALID_SLOT;
+
+	for(i = 0; i < si->si_num_slots; i++) {
+		if (OCFS2_INVALID_SLOT == si->si_global_node_nums[i]) {
+			ret = (s16) i;
+			break;
+		}
+	}
+	return ret;
+}
+
 s16 ocfs2_node_num_to_slot(ocfs2_slot_info *si,
 			   s16 global)
 {
@@ -137,10 +151,10 @@
 			      s16 slot_num,
 			      s16 node_num)
 {
-	OCFS_ASSERT(slot_num != OCFS_INVALID_NODE_NUM);
+	OCFS_ASSERT(slot_num != OCFS2_INVALID_SLOT);
 	OCFS_ASSERT(slot_num < si->si_num_slots);
-	OCFS_ASSERT((node_num == OCFS_INVALID_NODE_NUM) || 
-		    (node_num < OCFS2_MAX_NODES));
+	OCFS_ASSERT((node_num == NM_INVALID_NODE_NUM) || 
+		    (node_num < NM_MAX_NODES));
 
 	si->si_global_node_nums[slot_num] = node_num;
 }
@@ -149,7 +163,7 @@
 		      s16 slot_num)
 {
 	spin_lock(&si->si_lock);
-	__ocfs2_fill_slot(si, slot_num, OCFS_INVALID_NODE_NUM);
+	__ocfs2_fill_slot(si, slot_num, OCFS2_INVALID_SLOT);
 	spin_unlock(&si->si_lock);
 }
 
@@ -169,11 +183,11 @@
 	}
 	memset(si, 0, sizeof(ocfs2_slot_info));
 	spin_lock_init(&si->si_lock);
-	si->si_num_slots = osb->max_nodes;
-	si->si_size = OCFS2_MAX_NODES;
+	si->si_num_slots = osb->max_slots;
+	si->si_size = OCFS2_MAX_SLOTS;
 
 	for(i = 0; i < si->si_num_slots; i++)
-		si->si_global_node_nums[i] = OCFS_INVALID_NODE_NUM;
+		si->si_global_node_nums[i] = OCFS2_INVALID_SLOT;
 
 	inode = ocfs_get_system_file_inode(osb, SLOT_MAP_SYSTEM_INODE, -1);
 	if (!inode) {
@@ -231,11 +245,11 @@
 	 * own journal recovery? Possibly not, though we certainly
 	 * need to warn to the user */
 	slot = __ocfs2_node_num_to_slot(si, osb->node_num);
-	if (slot == OCFS_INVALID_NODE_NUM) {
+	if (slot == OCFS2_INVALID_SLOT) {
 		/* if no slot yet, then just take 1st available
 		 * one. */
-		slot = __ocfs2_node_num_to_slot(si, OCFS_INVALID_NODE_NUM);
-		if (slot == OCFS_INVALID_NODE_NUM) {
+		slot = __ocfs2_find_empty_slot(si);
+		if (slot == OCFS2_INVALID_SLOT) {
 			spin_unlock(&si->si_lock);
 			mlog(ML_ERROR, "no free slots available!\n");
 			status = -EINVAL;
@@ -271,8 +285,8 @@
 	ocfs2_update_slot_info(si);
 
 	spin_lock(&si->si_lock);
-	__ocfs2_fill_slot(si, osb->slot_num, OCFS_INVALID_NODE_NUM);
-	osb->slot_num = OCFS_INVALID_NODE_NUM;
+	__ocfs2_fill_slot(si, osb->slot_num, OCFS2_INVALID_SLOT);
+	osb->slot_num = OCFS2_INVALID_SLOT;
 	spin_unlock(&si->si_lock);
 
 	status = ocfs2_update_disk_slots(osb, si);

Modified: trunk/fs/ocfs2/slot_map.h
===================================================================
--- trunk/fs/ocfs2/slot_map.h	2005-05-23 23:28:05 UTC (rev 2307)
+++ trunk/fs/ocfs2/slot_map.h	2005-05-23 23:35:22 UTC (rev 2308)
@@ -34,7 +34,7 @@
 	struct buffer_head *si_bh;
 	unsigned int si_num_slots;
 	unsigned int si_size;
-	s16 si_global_node_nums[OCFS2_MAX_NODES];
+	s16 si_global_node_nums[OCFS2_MAX_SLOTS];
 } ocfs2_slot_info;
 
 int ocfs2_init_slot_info(ocfs_super *osb);
@@ -54,4 +54,13 @@
 
 void ocfs2_populate_mounted_map(ocfs_super *osb);
 
+static inline int ocfs2_is_empty_slot(ocfs2_slot_info *si,
+				      int slot_num)
+{
+	BUG_ON(slot_num == OCFS2_INVALID_SLOT);
+	assert_spin_locked(&si->si_lock);
+
+	return si->si_global_node_nums[slot_num] == OCFS2_INVALID_SLOT;
+}
+
 #endif

Modified: trunk/fs/ocfs2/super.c
===================================================================
--- trunk/fs/ocfs2/super.c	2005-05-23 23:28:05 UTC (rev 2307)
+++ trunk/fs/ocfs2/super.c	2005-05-23 23:35:22 UTC (rev 2308)
@@ -1008,7 +1008,7 @@
 		if (tmp < 0)
 			mlog_errno(tmp);
 
-		if (osb->slot_num != OCFS_INVALID_NODE_NUM)
+		if (osb->slot_num != OCFS2_INVALID_SLOT)
 			ocfs2_put_slot(osb);
 	}
 
@@ -1115,8 +1115,8 @@
 	atomic_set(&osb->needs_checkpoint, 0);
 	atomic_set(&osb->clean_buffer_seq, 1);
 
-	osb->node_num = OCFS_INVALID_NODE_NUM;
-	osb->slot_num = OCFS_INVALID_NODE_NUM;
+	osb->node_num = NM_INVALID_NODE_NUM;
+	osb->slot_num = OCFS2_INVALID_SLOT;
 
 	osb->local_alloc_state = OCFS2_LA_UNUSED;
 	osb->local_alloc_bh = NULL;
@@ -1139,16 +1139,16 @@
 		goto bail;
 	}
 
-	di = (ocfs2_dinode *) bh->b_data;
+	di = (ocfs2_dinode *)bh->b_data;
 
-	osb->max_nodes = le16_to_cpu(di->id2.i_super.s_max_nodes);
-	if (osb->max_nodes > OCFS2_MAX_NODES || osb->max_nodes == 0) {
-		mlog(ML_ERROR, "Invalid number of nodes (%u)\n",
-		     osb->max_nodes);
+	osb->max_slots = le16_to_cpu(di->id2.i_super.s_max_slots);
+	if (osb->max_slots > OCFS2_MAX_SLOTS || osb->max_slots == 0) {
+		mlog(ML_ERROR, "Invalid number of node slots (%u)\n",
+		     osb->max_slots);
 		status = -EINVAL;
 		goto bail;
 	}
-	mlog(ML_NOTICE, "max_nodes for this device: %u\n", osb->max_nodes);
+	mlog(ML_NOTICE, "max_slots for this device: %u\n", osb->max_slots);
 
 	osb->s_feature_compat =
 		le32_to_cpu(OCFS2_RAW_SB(di)->s_feature_compat);
@@ -1259,27 +1259,6 @@
 		goto bail;
 	}
 
-	/*
-	 * an inode for the heartbeat area
-	 */	
-	inode = ocfs_get_system_file_inode(osb, HEARTBEAT_SYSTEM_INODE, -1);
-	if (!inode) {
-		status = -EINVAL;
-		mlog_errno(status);
-		goto bail;
-	}
-
-	if (inode->i_size >> osb->sb->s_blocksize_bits < OCFS2_MAX_NODES) {
-		mlog(ML_ERROR,
-		     "heartbeat area size incorrect: found=%llu, need=%u\n",
-		     inode->i_size,
-		     OCFS2_MAX_NODES << osb->sb->s_blocksize_bits);
-		status = -EINVAL;
-		goto bail;
-
-	}
-	iput(inode);
-	
 	/* 
 	 * global bitmap 
 	 */	
@@ -1372,11 +1351,12 @@
 			mlog(ML_ERROR, "bad root_blkno: 0\n");
 		} else if (!le64_to_cpu(di->id2.i_super.s_system_dir_blkno)) {
 			mlog(ML_ERROR, "bad system_dir_blkno: 0\n");
-		} else if (le16_to_cpu(di->id2.i_super.s_max_nodes) > OCFS2_MAX_NODES) {
-			mlog(ML_ERROR, "max_nodes found greater than maximum: "
-			     "found %u, max %u\n",
-			     le16_to_cpu(di->id2.i_super.s_max_nodes),
-			     OCFS2_MAX_NODES);
+		} else if (le16_to_cpu(di->id2.i_super.s_max_slots) > OCFS2_MAX_SLOTS) {
+			mlog(ML_ERROR,
+			     "Superblock slots found greater than file system "
+			     "maximum: found %u, max %u\n",
+			     le16_to_cpu(di->id2.i_super.s_max_slots),
+			     OCFS2_MAX_SLOTS);
 		} else {
 			/* found it! */
 			status = 0;

Modified: trunk/fs/ocfs2/vote.c
===================================================================
--- trunk/fs/ocfs2/vote.c	2005-05-23 23:28:05 UTC (rev 2307)
+++ trunk/fs/ocfs2/vote.c	2005-05-23 23:35:22 UTC (rev 2308)
@@ -165,11 +165,11 @@
 	 * did not know which slot the inode is orphaned in but we
 	 * respond with BUSY he doesn't actually need the orphaned
 	 * slot, but it doesn't hurt to do it here anyway. */
-	if ((*orphaned_slot) != OCFS_INVALID_NODE_NUM) {
+	if ((*orphaned_slot) != OCFS2_INVALID_SLOT) {
 		spin_lock(&OCFS2_I(inode)->ip_lock);
 
 		mlog_bug_on_msg(OCFS2_I(inode)->ip_orphaned_slot != 
-				OCFS_INVALID_NODE_NUM && 
+				OCFS2_INVALID_SLOT && 
 				OCFS2_I(inode)->ip_orphaned_slot != 
 				(*orphaned_slot),
 				"Inode %"MLFu64": This node thinks it's "
@@ -564,7 +564,7 @@
 
 	i = ocfs_node_map_iterate(osb, &osb->mounted_map, 0);
 
-	while (i != OCFS_INVALID_NODE_NUM) {
+	while (i != NM_INVALID_NODE_NUM) {
 		if (i != osb->node_num) {
 			mlog(0, "trying to send request to node %i\n", i);
 			ocfs_node_map_set_bit(osb, &w->n_node_map, i);
@@ -714,7 +714,7 @@
 
 	/* The other node may not actually know which slot the inode
 	 * is orphaned in. */
-	if (orphaned_slot == OCFS_INVALID_NODE_NUM)
+	if (orphaned_slot == OCFS2_INVALID_SLOT)
 		return;
 
 	/* Ok, the responding node knows which slot this inode is
@@ -724,7 +724,7 @@
 	spin_lock(&OCFS2_I(inode)->ip_lock);
 	mlog_bug_on_msg(OCFS2_I(inode)->ip_orphaned_slot != orphaned_slot &&
 			OCFS2_I(inode)->ip_orphaned_slot 
-			!= OCFS_INVALID_NODE_NUM, "Inode %"MLFu64": Node %d "
+			!= OCFS2_INVALID_SLOT, "Inode %"MLFu64": Node %d "
 			"says it's orphaned in slot %d, we think it's in %d\n",
 			OCFS2_I(inode)->ip_blkno, ntohl(resp->r_hdr.h_node_num),
 			orphaned_slot, OCFS2_I(inode)->ip_orphaned_slot);
@@ -758,7 +758,7 @@
 {
 	return ocfs2_request_vote(inode,
 				  OCFS2_VOTE_REQ_UNLINK,
-				  OCFS_INVALID_NODE_NUM,
+				  OCFS2_INVALID_SLOT,
 				  NULL);
 }
 
@@ -766,7 +766,7 @@
 {
 	return ocfs2_request_vote(inode,
 				  OCFS2_VOTE_REQ_RENAME,
-				  OCFS_INVALID_NODE_NUM,
+				  OCFS2_INVALID_SLOT,
 				  NULL);
 }
 
@@ -785,7 +785,7 @@
 
 		status = ocfs2_do_request_vote(osb, 0ULL, 0,
 					       OCFS2_VOTE_REQ_MOUNT,
-					       OCFS_INVALID_NODE_NUM, NULL);
+					       OCFS2_INVALID_SLOT, NULL);
 	}
 	return status;
 }
@@ -805,7 +805,7 @@
 
 		status = ocfs2_do_request_vote(osb, 0ULL, 0,
 					       OCFS2_VOTE_REQ_UMOUNT,
-					       OCFS_INVALID_NODE_NUM, NULL);
+					       OCFS2_INVALID_SLOT, NULL);
 	}
 	return status;
 }



More information about the Ocfs2-commits mailing list