[Ocfs2-commits] khackel commits r1069 - branches/format-changes/src

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Sat Jun 12 17:05:21 CDT 2004


Author: khackel
Date: 2004-06-12 16:05:20 -0500 (Sat, 12 Jun 2004)
New Revision: 1069

Added:
   branches/format-changes/src/ocfs1.h
Modified:
   branches/format-changes/src/alloc.c
   branches/format-changes/src/buffer_head_io.c
   branches/format-changes/src/dir.c
   branches/format-changes/src/dlm.c
   branches/format-changes/src/extmap.c
   branches/format-changes/src/file.c
   branches/format-changes/src/file.h
   branches/format-changes/src/heartbeat.c
   branches/format-changes/src/inode.c
   branches/format-changes/src/journal.c
   branches/format-changes/src/lockres.c
   branches/format-changes/src/namei.c
   branches/format-changes/src/nm.c
   branches/format-changes/src/ocfs.h
   branches/format-changes/src/ocfs2_fs.h
   branches/format-changes/src/ocfs_buffer_head.h
   branches/format-changes/src/proc.c
   branches/format-changes/src/super.c
   branches/format-changes/src/sysfile.c
   branches/format-changes/src/sysfile.h
   branches/format-changes/src/volcfg.c
   branches/format-changes/src/vote.c
Log:
this is a very large commit to support the new disk format
all system files are now allocated by mkfs in a "system root dir"
this includes special inodes for autoconfig, publish, vote, etc.,
as well as node-local files for each node
in ocfs_initialize_osb we load each of the global inodes from disk,
(after doing a raw lookup for the name) and fill in fields on the osb
appropriately.  this means there is no longer any static information 
loaded from the superblock (what was the vol disk header).  everything
is dynamic, meaning that we can add new types of system files in the 
future very easily, and these files can be located anywhere on disk, not
just in the first few megabytes like before.
this all uses the new dinode and extent structures too.



Modified: branches/format-changes/src/alloc.c
===================================================================
--- branches/format-changes/src/alloc.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/alloc.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -42,6 +42,7 @@
 #include "inode.h"
 #include "util.h"
 #include "sysfile.h"
+#include "file.h"
 
 #include "ocfs_journal.h"
 #include "ocfs_buffer_head.h"
@@ -346,16 +347,16 @@
 
 	/* Get all the locks we need. do global bitmap last to
 	 * preserve lock ordering with extend/create */
-	lock_id = (OCFS_FILE_FILE_ALLOC_BITMAP * osb->sect_size) +
-		  osb->vol_layout.root_int_off;
-	for (i = 0; i < osb->max_nodes; i++, lock_id += osb->sect_size) {
+	for (i = 0; i < osb->max_nodes; i++) {
 		if (free_ext_node[i] != NULL) {
-			extnode_inode[i] = ocfs_iget(osb, lock_id);
+			extnode_inode[i] = 
+				ocfs_get_system_file_inode(osb, EXTENT_ALLOC_BITMAP_SYSTEM_INODE, i);
 			if (!extnode_inode[i]) {
 				status = -EINVAL;
 				LOG_ERROR_STATUS (status);
 				goto abort;
 			}
+			lock_id = GET_INODE_FEOFF(extnode_inode[i]);
 			down(&OCFS_I(extnode_inode[i])->ip_io_sem);
 
 			status = ocfs_acquire_lock (osb, 
@@ -379,7 +380,7 @@
 	}
 
 	if (free_vol_bits != NULL) {
-		vol_inode = igrab(osb->system_inodes[GLOBAL_BITMAP_SYSTEM_INODE]);
+		vol_inode = ocfs_get_system_file_inode(osb, GLOBAL_BITMAP_SYSTEM_INODE, -1);
 		if (!vol_inode) {
 			status = -EINVAL;
 			LOG_ERROR_STATUS (status);
@@ -457,9 +458,7 @@
 		}
 	}
 
-	lock_id = (OCFS_FILE_FILE_ALLOC_BITMAP * osb->sect_size) +
-		  osb->vol_layout.root_int_off;
-	for (i = 0; i < osb->max_nodes; i++, lock_id += osb->sect_size) {
+	for (i = 0; i < osb->max_nodes; i++) {
 		if (free_ext_node[i] != NULL) {
 			status = ocfs_release_lock (osb,
 						    OCFS_DLM_EXCLUSIVE_LOCK,
@@ -523,8 +522,8 @@
 
 	bitmapblocks = (OCFS_ALIGN(bitmap->validbits, OCFS_BITS_IN_CHUNK) / OCFS_BITS_IN_CHUNK);
 
-	status = ocfs_read_bhs(osb, osb->vol_layout.bitmap_off, 
-			       bitmapblocks * osb->sect_size, 
+	status = ocfs_read_bhs(osb, osb->bitmap_blkno << osb->sb->s_blocksize_bits, 
+			       bitmapblocks << osb->sb->s_blocksize_bits, 
 			       bitmap->chunk, 0, NULL);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
@@ -548,15 +547,15 @@
 {
 	int status = 0;
 	__u64 fileSize = 0;
-	__u64 offset = 0;
 	__u64 allocSize = 0;
 	__u32 foundBit = -1;
 	__u32 blockSize = 0, blockSizeBits = 0;
-	__u32 fileId = 0;
+	int file_type;
 	__u32 bitmapblocks = 0;
 	ocfs_alloc_bm AllocBitmap;
 	ocfs_alloc_bm *tmpbitmap = NULL;
 	__u32 i;
+	struct inode *inode = NULL;
 
 	LOG_ENTRY ();
 
@@ -569,20 +568,15 @@
 
 	switch (Type) {
 	    case DISK_ALLOC_EXTENT_NODE:
-		    fileId = OCFS_FILE_FILE_ALLOC_BITMAP + NodeNum;
-		    blockSize = (__u32) osb->vol_layout.file_node_size;
-		    blockSizeBits = osb->file_alloc_bits;
-	
-		    if (!IS_VALID_NODE_NUM (NodeNum)) {
-			    LOG_ERROR_STATUS(status = -EINVAL);
-			    goto leave;
-		    }
+		    file_type = EXTENT_ALLOC_BITMAP_SYSTEM_INODE;
+		    blockSize = osb->sb->s_blocksize;
+		    blockSizeBits = osb->sb->s_blocksize_bits;
 		    break;
 
 	    case DISK_ALLOC_INODE:
-		    fileId = OCFS_INODE_BITMAP + NodeNum;
-		    blockSize = osb->inode_size;
-		    blockSizeBits = osb->inode_alloc_bits;
+		    file_type = INODE_ALLOC_BITMAP_SYSTEM_INODE;
+		    blockSize = osb->sb->s_blocksize;
+		    blockSizeBits = osb->sb->s_blocksize_bits;
 		    break;
 
 	    case DISK_ALLOC_VOLUME:
@@ -599,21 +593,20 @@
 		goto leave;
 	}
 
-	/* Read in the bitmap file for the dir alloc and look
-	   for the required space, if found */
-	status = ocfs_get_system_file_size (osb, fileId, &fileSize, &allocSize);
-	if (status < 0) {
-		LOG_ERROR_STATUS (status);
+	inode = ocfs_get_system_file_inode(osb, file_type, NodeNum);
+	if (!inode) {
+		LOG_ERROR_STATUS (status = -EINVAL);
 		goto leave;
 	}
+	fileSize = inode->i_size;
+	allocSize = OCFS_I(inode)->alloc_size;
 
 	ocfs_initialize_bitmap(&AllocBitmap, fileSize * 8, allocSize * 8);
 	tmpbitmap = &AllocBitmap;
 	bitmapblocks = (OCFS_ALIGN(tmpbitmap->validbits, OCFS_BITS_IN_CHUNK) / OCFS_BITS_IN_CHUNK);
 
-	status = ocfs_read_system_file(osb, fileId, AllocBitmap.chunk,
-				       bitmapblocks * osb->sect_size, 
-				       offset);
+	status = ocfs_read_system_file(osb, file_type, NodeNum, AllocBitmap.chunk, 
+				       bitmapblocks << osb->sb->s_blocksize_bits);
 	if (status < 0) {
 		LOG_ERROR_STATUS (status);
 		goto leave;
@@ -633,7 +626,8 @@
 leave:
 	if (tmpbitmap)
 		ocfs_uninitialize_bitmap(tmpbitmap);
-
+	if (inode)
+		iput(inode);
 	LOG_EXIT_STATUS (status);
 	return status;
 }			/* ocfs_free_vol_block */
@@ -1578,7 +1572,6 @@
 	    numBitsAllocated = 0, bitmapOffset = 0, 
 	    firstfree = *freeExtent;
 	__u64 bytes, foff, doff, 
-	    dstart = osb->vol_layout.data_start_off, 
 	    diskOffsetTobeFreed, lengthTobeFreed = 0, 
 	    actualSize = 0, origLength = 0;
 
@@ -1601,7 +1594,7 @@
 					FirstTime = 0; 
 				} 
 				numBitsAllocated = ext->e_clusters; 
-				bitmapOffset = (__u32) ((doff - dstart) >> csize); 
+				bitmapOffset = (__u32) (doff >> csize); 
 				ext->e_clusters = ext->e_blkno =
 					ext->e_cpos = 0; 
 			} else { 
@@ -1619,7 +1612,7 @@
 				} 
 				numBitsAllocated = (__u32) (lengthTobeFreed >> csize); 
 				diskOffsetTobeFreed = doff + bytes; 
-				bitmapOffset = (__u32) ((diskOffsetTobeFreed - dstart) >> csize); 
+				bitmapOffset = (__u32) (diskOffsetTobeFreed >> csize); 
 			} 
 			status = ocfs_handle_add_commit_bits(handle, 
 							   numBitsAllocated, 
@@ -1666,7 +1659,6 @@
 	int status = -EFAIL;
 	int i;
 	__u32 victim;
-	__u64 dstart = osb->vol_layout.data_start_off;
 	__u64 tmp_off;
 	u32 num_clusters = 0;
 	__u32 bitmap_offset = 0;
@@ -1703,7 +1695,7 @@
 				ext = &cur_el->l_recs[i];
 				num_clusters = ext->e_clusters;
 				bitmap_offset =
-					(u32)(((ext->e_blkno << osb->sb->s_blocksize_bits) - dstart) >> osb->s_clustersize_bits);
+					(u32)((ext->e_blkno << osb->sb->s_blocksize_bits) >> osb->s_clustersize_bits);
 				status = ocfs_handle_add_commit_bits(handle, num_clusters, bitmap_offset, -1, DISK_ALLOC_VOLUME);
 				if (status < 0) {
 					LOG_ERROR_STATUS (status);
@@ -1860,7 +1852,6 @@
 	int tos = 0;
 	int i, victim;
 	__u64 bytes, doff, orig_bytes, tmp_off;
-	__u64 dstart = osb->vol_layout.data_start_off;
 	__u64 total_bytes;  /* FIXME needs to be clusters!!! */
 	__u32 num_clusters, bitmap_offset;
 	int done = 0;
@@ -2111,7 +2102,7 @@
 						total_bytes += (u64)rec->e_clusters << osb->s_clustersize_bits;
 
 						num_clusters = rec->e_clusters;
-						bitmap_offset = (u32)(((rec->e_blkno << osb->sb->s_blocksize_bits) - dstart) >> osb->s_clustersize_bits);
+						bitmap_offset = (u32)(((rec->e_blkno << osb->sb->s_blocksize_bits)) >> osb->s_clustersize_bits);
 						rec->e_cpos = 0;
 						rec->e_clusters = 0;
 						rec->e_blkno = 0;
@@ -2128,7 +2119,7 @@
 						rec->e_clusters = fe->i_clusters - rec->e_cpos;
 						bytes = (u64)rec->e_clusters << osb->s_clustersize_bits;
 						num_clusters -= rec->e_clusters;
-						bitmap_offset = (u32)(((doff + bytes) - dstart) >> osb->s_clustersize_bits);
+						bitmap_offset = (u32)((doff + bytes) >> osb->s_clustersize_bits);
 						/* we want to exit the
 						 * for loop now */
 						total_bytes += (orig_bytes - bytes);
@@ -2895,7 +2886,7 @@
 	__u32 bitmapblocks; /* we only care about the valid blocks */
 	int local_lock = 0;
 	int local_inode = 0;
-	__u32 five_percent;
+	__u32 five_percent, free_bits;
 
 	LOG_ENTRY ();
 
@@ -2905,7 +2896,7 @@
 		BUG();
 
 	if (!bitmap_inode) {
-		bitmap_inode = igrab(osb->system_inodes[GLOBAL_BITMAP_SYSTEM_INODE]);
+		bitmap_inode = ocfs_get_system_file_inode(osb, GLOBAL_BITMAP_SYSTEM_INODE, -1);
 		if (!bitmap_inode) {
 			status = -EINVAL;
 			LOG_ERROR_STR("Could not get bitmap inode!");
@@ -2941,7 +2932,7 @@
 
 	bm_lock = OCFS_BH_GET_DATA_WRITE(bh);
 
-	ClusterCount = (__u32) ((__u64) (file_size + (osb->vol_layout.cluster_size-1)) >> 
+	ClusterCount = (__u32) ((__u64) (file_size + (osb->s_clustersize-1)) >> 
 				osb->s_clustersize_bits);
 	if (ClusterCount == 0) {
 		LOG_ERROR_STR ("DISK_FULL?: ClusterCount==0");
@@ -2955,9 +2946,11 @@
 		goto leave;
 	}
 
-	if (sysfile ? (ClusterCount > osb->vol_layout.num_clusters) :
-	    (ClusterCount > (osb->vol_layout.num_clusters - 
-			     ((8 * ONE_MEGA_BYTE) >> osb->s_clustersize_bits)))){
+	free_bits = le32_to_cpu(bm_lock->id1.bitmap1.i_total) - 
+		le32_to_cpu(bm_lock->id1.bitmap1.i_used);
+	if ( (sysfile && ClusterCount > free_bits) || 
+	     (!sysfile && ClusterCount > 
+	         (free_bits - ((8 * ONE_MEGA_BYTE) >> osb->s_clustersize_bits))) ){
 		LOG_ERROR_STR ("Disk Full");
 		status = -ENOSPC;
 		goto leave;
@@ -2972,8 +2965,7 @@
 	/* allocation at 5%, so that small files stay in the beginning
 	 * as much as possible */
 
-	// ok because num_clusters should not even be a __u64
-	five_percent = ((__u32)osb->vol_layout.num_clusters) / 20;
+	five_percent = le32_to_cpu(bm_lock->id1.bitmap1.i_total) / 20;
 	if (ClusterCount > five_percent) {
 		LargeAlloc = 1;
 		LargeAllocOffset = five_percent;
@@ -2983,8 +2975,8 @@
 				   OCFS_BITS_IN_CHUNK) / OCFS_BITS_IN_CHUNK);
 	
 	/* Ok, somewhat lame, but we submit the whole bitmap for reading here*/
-	if (ocfs_read_bhs(osb, osb->vol_layout.bitmap_off, 
-			  bitmapblocks * osb->sect_size, 
+	if (ocfs_read_bhs(osb, osb->bitmap_blkno << osb->sb->s_blocksize_bits, 
+			  bitmapblocks << osb->sb->s_blocksize_bits,
 			  osb->cluster_bitmap.chunk, 0, NULL)) {
 		LOG_ERROR_STATUS(-EIO);
 		goto leave;
@@ -3009,8 +3001,8 @@
 		bitoffset = ocfs_find_clear_bits (osb, &osb->cluster_bitmap,
 						  ClusterCount, 0,
 						  sysfile ? 0 :
-						  ((8 * ONE_MEGA_BYTE) /
-						   osb->vol_layout.cluster_size));
+						  ((8 * ONE_MEGA_BYTE) >>
+						   osb->s_clustersize_bits));
 	}
 
 	/* It returns -1 on failure, otherwise bitoffset points at the */
@@ -3077,7 +3069,6 @@
 	int status = 0;
 	int startbh, numblocks;
 	__u64 fileSize = 0;
-	__u64 offset = 0;
 	__u64 numBytes = 0;
 	__u64 allocSize = 0;
 	__u64 prevFileSize = 0;
@@ -3088,31 +3079,30 @@
 	__u32 numBits = 0;
 	__u32 foundBit = -1;
 	__u32 blockSize = 0, blockSizeBits = 0;
-	__u32 bm_file = 0;
-	__u32 alloc_file = 0;
+	int bm_file = 0;
+	int alloc_file = 0;
 	struct buffer_head *bh = NULL;
 	ocfs2_dinode *fe = NULL;
 	int needs_uninit = 0;
 	int delay_lockrel = 0;
 	struct inode *inode = NULL; /* alloc bitmap file inode */
+	struct inode *alloc_inode = NULL; /* alloc file inode */
 
 	LOG_ENTRY_ARGS("(FileSize = (%llu), Type=%d)\n", FileSize,Type);
 
 	switch (Type) {
 		case DISK_ALLOC_EXTENT_NODE:
-			bm_file = OCFS_FILE_FILE_ALLOC_BITMAP + NodeNum;
-			alloc_file = OCFS_FILE_FILE_ALLOC + NodeNum;
-			blockSize = (__u32) osb->vol_layout.file_node_size;
-			blockSizeBits = osb->file_alloc_bits;
+			bm_file = EXTENT_ALLOC_BITMAP_SYSTEM_INODE;
+			alloc_file = EXTENT_ALLOC_SYSTEM_INODE;
+			blockSize = osb->sb->s_blocksize;
+			blockSizeBits = osb->sb->s_blocksize_bits;
 			atomic_inc(&osb->alloc_stats.ext_allocs);
-			inode = igrab(osb->system_inodes[EXTENT_ALLOC_BITMAP_SYSTEM_INODE]);
 			break;
 		case DISK_ALLOC_INODE:
-			bm_file = OCFS_INODE_BITMAP + NodeNum;
-			alloc_file = OCFS_INODE_FILE + NodeNum;
-			blockSize = osb->inode_size;
-			blockSizeBits = osb->inode_alloc_bits;
-			inode = igrab(osb->system_inodes[INODE_ALLOC_BITMAP_SYSTEM_INODE]);
+			bm_file = INODE_ALLOC_BITMAP_SYSTEM_INODE;
+			alloc_file = INODE_ALLOC_SYSTEM_INODE;
+			blockSize = osb->sb->s_blocksize;
+			blockSizeBits = osb->sb->s_blocksize_bits;
 			break;
 		default:
 			status = -EINVAL;
@@ -3120,11 +3110,16 @@
 			goto leave;
 	}
 
+	inode = ocfs_get_system_file_inode(osb, bm_file, NodeNum);
 	if (!inode) {
-		status = -EINVAL;
-		LOG_ERROR_STATUS(status);
+		LOG_ERROR_STATUS(status=-EINVAL);
 		goto leave;
 	}
+	alloc_inode = ocfs_get_system_file_inode(osb, alloc_file, NodeNum);
+	if (!alloc_inode) {
+		LOG_ERROR_STATUS(status=-EINVAL);
+		goto leave;
+	}
 
 	/* Allocate a block of size blocksize from the relevant file/bitmap */
 	OCFS_ASSERT (blockSize);
@@ -3168,8 +3163,8 @@
 		ocfs_initialize_bitmap (&bitmap, (__u32) fileSize * 8, (__u32) allocSize * 8);
 		needs_uninit = 1;
 
-		status = ocfs_read_system_file (osb, bm_file, bitmap.chunk, 
-						allocSize, offset);
+		status = ocfs_read_system_file (osb, bm_file, NodeNum,
+						bitmap.chunk, allocSize);
 		if (status < 0) {
 			LOG_ERROR_STATUS (status);
 			goto leave;
@@ -3190,22 +3185,17 @@
 		/* if not found add more allocation to the file and try again. */
 		extent = ( ((numBits * blockSize) + (ONE_MEGA_BYTE-1)) >> 20 ) << 20;
 		
-		status = ocfs_get_system_file_size (osb, alloc_file,
-						    &newFileSize, &allocSize);
-		if (status < 0) {
-			LOG_ERROR_STATUS (status);
-			goto leave;
-		}
-		
+		newFileSize = alloc_inode->i_size;
+		allocSize = OCFS_I(alloc_inode)->alloc_size;
+
 		/* This is for OUI optimzation to allocate more disk
 		 * space for directory allocations */
 		
 		if (allocSize > 0)
 			extent *= 2;
 		
-		status = ocfs_extend_system_file (osb, alloc_file,
-						  newFileSize + extent, NULL, 
-						  handle, 0);
+		status = ocfs_extend_file (osb, newFileSize + extent, GET_INODE_FEOFF(alloc_inode),
+					   handle, alloc_inode, NULL, 1, NULL);
 		if (status < 0) {
 			LOG_ERROR_STATUS (status);
 			goto leave;
@@ -3217,9 +3207,9 @@
 		/* Does this need the buffer_head? if so, we need to
 		 * do a put_data first! */
 		/* Calculate the new bitmap size */
-
-		status = ocfs_extend_system_file (osb, bm_file, bitMapSize, bh,
-						  handle, 1);
+		
+		status = ocfs_extend_file (osb, bitMapSize, GET_INODE_FEOFF(inode), 
+					   handle, inode, NULL, 1, bh);
 		if (status < 0) {
 			LOG_ERROR_STATUS (status);
 			goto leave;
@@ -3228,8 +3218,7 @@
 		/* we wrote it back out in ocfs_extend_system_file so
 		 * we can trust the sizes here */
 		fileSize = fe->i_size;
-		allocSize =
-			(u64)fe->i_clusters << osb->s_clustersize_bits;
+		allocSize = (u64)fe->i_clusters << osb->s_clustersize_bits;
 		OCFS_BH_PUT_DATA(bh);
 
 		if (needs_uninit)
@@ -3240,8 +3229,8 @@
 					       allocSize * 8);
 		needs_uninit = 1;
 
-		status = ocfs_read_system_file (osb, bm_file, bitmap.chunk, 
-						allocSize, offset);
+		status = ocfs_read_system_file (osb, bm_file, NodeNum, 
+						bitmap.chunk, allocSize);
 		if (status < 0) {
 			LOG_ERROR_STATUS (status);
 			goto leave;
@@ -3264,10 +3253,13 @@
 
 	LOG_TRACE_ARGS ("offset=%u, type=%x, blksz=%u, foundbit=%u, fileid=%u\n",
 			foundBit * blockSize, Type, blockSize, foundBit, alloc_file);
-	*DiskOffset = ocfs_file_to_disk_off (osb, (alloc_file),
-					(foundBit * blockSize));
-	if (*DiskOffset == 0) {
-		LOG_ERROR_STATUS(status = -EFAIL);
+
+	status = ocfs_lookup_file_allocation(osb, foundBit * blockSize, 
+					     DiskOffset, 1, NULL, alloc_inode);
+	if (status < 0 || *DiskOffset == 0) {
+		if (!status)
+			status = -EINVAL;
+		LOG_ERROR_STATUS(status);
 		goto leave;
 	}
 
@@ -3285,6 +3277,8 @@
 
 	if (inode)
 		iput(inode);
+	if (alloc_inode)
+		iput(alloc_inode);
 
 	if (bh != NULL)
 		brelse(bh);
@@ -3329,8 +3323,7 @@
 			numBitsAllocated = fel->l_recs[i].e_clusters;
 
 			bitmapOffset =
-			    (__u32)(((fel->l_recs[i].e_blkno << osb->sb->s_blocksize_bits) -
-				    osb->vol_layout.data_start_off) >>
+			    (__u32)(((fel->l_recs[i].e_blkno << osb->sb->s_blocksize_bits)) >>
 				   osb->s_clustersize_bits);
 
 			ocfs_handle_add_commit_bits(handle, numBitsAllocated, 
@@ -3403,7 +3396,7 @@
 {
 	int numbits;
 
-	switch (osb->vol_layout.cluster_size) {
+	switch (osb->s_clustersize) {
 	case (4*1024):
 		numbits = 1024;
 		break;
@@ -3750,7 +3743,7 @@
 		alloc = NULL;
 
 		if (!main_bm_inode)
-			main_bm_inode = igrab(osb->system_inodes[GLOBAL_BITMAP_SYSTEM_INODE]);
+			main_bm_inode = ocfs_get_system_file_inode(osb, GLOBAL_BITMAP_SYSTEM_INODE, -1);
 
 		if (!main_bm_inode) {
 			status = -EINVAL;
@@ -3875,7 +3868,7 @@
 	 * We *always* use global bitmap for clustersize > 128k,
 	 * file_size > 2mb, so force it under these conditions. */
 	if ( (handle && osb->have_local_alloc)
-	     && (osb->vol_layout.cluster_size <= OCFS_LOCAL_ALLOC_MAX_CSIZE)
+	     && (osb->s_clustersize <= OCFS_LOCAL_ALLOC_MAX_CSIZE)
 	     && (file_size <= OCFS_LOCAL_ALLOC_MAX_ALLOC) )
 		use_global = 0;
 
@@ -3931,20 +3924,24 @@
 	int status = 0;
 	ocfs2_local_alloc *alloc = NULL;
 	struct buffer_head *alloc_bh = NULL;
-	__u64 offset;
 	__u32 num_used;
+	struct inode *inode = NULL;
 
 	LOG_ENTRY();
 
 	/* read the alloc off disk */
-	offset = ((OCFS_LOCAL_ALLOC_FILE + osb->node_num) * osb->sect_size) + 
-		osb->vol_layout.root_int_off;
-	status = ocfs_read_bh(osb, offset, &alloc_bh, 0, NULL);
+	inode = ocfs_get_system_file_inode(osb, LOCAL_ALLOC_SYSTEM_INODE, osb->node_num);
+	if (!inode) {
+		LOG_ERROR_STATUS(status=-EINVAL);
+		goto bail;
+	}
+	status = ocfs_read_bh(osb, GET_INODE_FEOFF(inode), &alloc_bh, 0, inode);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
 		goto bail;
 	}
 
+#warning need to change this
 	alloc = OCFS_BH_GET_DATA_READ(alloc_bh);
 
 	/* do a little verification. */
@@ -3967,6 +3964,8 @@
 	if (status < 0)
 		if (alloc_bh)
 			brelse(alloc_bh);
+	if (inode)
+		iput(inode);
 
 	LOG_EXIT_STATUS(status);
 	return(status);
@@ -4016,6 +4015,7 @@
 		f = NULL;
 	}
 
+#warning need to change this
 	alloc = OCFS_BH_GET_DATA_WRITE(bh);
 	ocfs_clear_local_alloc(alloc);
 	OCFS_BH_PUT_DATA(bh);
@@ -4045,13 +4045,17 @@
 {
 	int status = 0;
 	struct buffer_head *alloc_bh = NULL;
-	__u64 offset;
+	struct inode *inode = NULL;
 
 	LOG_ENTRY_ARGS("(node_num = %d)\n", node_num);
 
-	offset = ((OCFS_LOCAL_ALLOC_FILE + node_num) * osb->sect_size) + 
-		osb->vol_layout.root_int_off;
-	status = ocfs_read_bh(osb, offset, &alloc_bh, 0, NULL);
+	inode = ocfs_get_system_file_inode(osb, LOCAL_ALLOC_SYSTEM_INODE, node_num);
+	if (!inode) {
+		LOG_ERROR_STATUS(status=-EINVAL);
+		goto bail;
+	}
+
+	status = ocfs_read_bh(osb, GET_INODE_FEOFF(inode), &alloc_bh, 0, inode);
 	if (status < 0) {
 		LOG_ERROR_STATUS(status);
 		goto bail;
@@ -4063,6 +4067,9 @@
 	if (alloc_bh)
 		brelse(alloc_bh);
 
+	if (inode)
+		iput(inode);
+
 	LOG_EXIT_STATUS(status);
 	return(status);
 } /* ocfs_recover_local_alloc */

Modified: branches/format-changes/src/buffer_head_io.c
===================================================================
--- branches/format-changes/src/buffer_head_io.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/buffer_head_io.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -236,14 +236,12 @@
 		goto bail;
 	}
 
-	if ((flags & OCFS_BH_COND_CACHED) && 
-	    (off >= osb->vol_layout.bitmap_off))
-			flags |= OCFS_BH_CACHED;
+	if ((flags & OCFS_BH_COND_CACHED) && !IS_SYSTEM_FILE_INODE(inode))
+		flags |= OCFS_BH_CACHED;
 
-	if (OCFS_NONCACHED(osb, off)) {
-		if (flags & OCFS_BH_CACHED)
-			LOG_TRACE_STR("hey bozo you are trying to write "
-				      "a system thingy cached!");
+	if ((flags & OCFS_BH_CACHED) && IS_SYSTEM_FILE_INODE(inode)) {
+		LOG_TRACE_STR("hey bozo you are trying to write "
+			      "a system thingy cached!");
 		flags &= ~OCFS_BH_CACHED;
 	}
 

Modified: branches/format-changes/src/dir.c
===================================================================
--- branches/format-changes/src/dir.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/dir.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -72,7 +72,7 @@
 	offset = filp->f_pos & (sb->s_blocksize - 1);
 
 	while (!error && !stored && filp->f_pos < inode->i_size) {
-		blk = (filp->f_pos) >> OCFS_SB(sb)->sect_size_bits;
+		blk = (filp->f_pos) >> sb->s_blocksize_bits;
 		bh = ocfs_bread (0, inode, blk, 0, &err, 0);
 		if (!bh) {
 			LOG_ERROR_ARGS ("directory #%llu contains a hole at offset %lu\n",
@@ -85,7 +85,7 @@
 		 * Do the readahead (8k)
 		 */
 		if (!offset) {
-			for (i = 16 >> (OCFS_SB(sb)->sect_size_bits - 9), num = 0;
+			for (i = 16 >> (sb->s_blocksize_bits - 9), num = 0;
 			     i > 0; i--) {
 				tmp = ocfs_bread (NULL, inode, ++blk, 0, &err, 1);
 				brelse (tmp);

Modified: branches/format-changes/src/dlm.c
===================================================================
--- branches/format-changes/src/dlm.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/dlm.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -116,9 +116,9 @@
 
 	ocfs_node_map_clear_bit(vote_map, osb->node_num);
 
-	offset = osb->vol_layout.publ_sect_off;
+	offset = osb->publish_blkno << osb->sb->s_blocksize_bits;
 	numnodes = osb->max_nodes;
-	size = (numnodes * osb->sect_size);
+	size = (numnodes << osb->sb->s_blocksize_bits);
 
 	/* take lock to prevent overwrites by vote_reset and nm thread */
 	down_with_flag (&(osb->publish_lock), publish_flag);
@@ -183,7 +183,7 @@
 	printk("ocfs_disk_request_vote: lockid = %llu\n",lock_id);
 #endif
 
-	pub_off = osb->vol_layout.publ_sect_off + (osb->node_num * osb->sect_size);
+	pub_off = (osb->publish_blkno + osb->node_num) << osb->sb->s_blocksize_bits;
 
 	status = ocfs_write_bh (osb, bhs[osb->node_num], 0, NULL);
 	if (status < 0) {
@@ -398,14 +398,15 @@
 	numnodes = osb->max_nodes;
 
 	/* Read the vote sectors of all the nodes */
-	length = numnodes * osb->sect_size;
+	length = numnodes << osb->sb->s_blocksize_bits;
 	bhs = ocfs_malloc(numnodes * sizeof(struct buffer_head *));
 	if (bhs == NULL) {
 		LOG_ERROR_STATUS (status = -ENOMEM);
 		goto finally;
 	}
 	memset(bhs, 0, numnodes * sizeof(struct buffer_head *));
-	status = ocfs_read_bhs (osb, osb->vol_layout.vote_sect_off, length, bhs, 0, NULL);
+	status = ocfs_read_bhs (osb, osb->vote_blkno << osb->sb->s_blocksize_bits, 
+				length, bhs, 0, NULL);
 	if (status < 0) {
 		LOG_ERROR_STATUS (status);
 		goto finally;
@@ -530,7 +531,7 @@
 	down (&(osb->publish_lock));
 
 	/* Read node's publish sector */
-	offset = osb->vol_layout.publ_sect_off + (osb->node_num * osb->sect_size);
+	offset = (osb->publish_blkno + osb->node_num) << osb->sb->s_blocksize_bits;
 
 	status = ocfs_read_bh (osb, offset, &bh, 0, NULL);
 	if (status < 0) {
@@ -1009,7 +1010,7 @@
 	ocfs2_dinode *fe = NULL;
 	struct buffer_head *tmpbh = NULL, **b = NULL;
 	__u32 curr_master;
-	int lockflags = (lock_id >= osb->vol_layout.bitmap_off ? OCFS_BH_CACHED : 0);
+	int lockflags = (IS_SYSTEM_FILE_INODE(inode) ? 0 : OCFS_BH_CACHED);
 	int clear_tmp = 0;
 	ocfs_lock_res *lockres = GET_INODE_LOCKRES(inode);
 

Modified: branches/format-changes/src/extmap.c
===================================================================
--- branches/format-changes/src/extmap.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/extmap.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -455,11 +455,11 @@
 
 	if ((ByteCount) && (ByteCount != 0xFFFFFFFF)) {
 		ByteCount--;
-		ByteCount >>= osb->sect_size_bits;
+		ByteCount >>= osb->sb->s_blocksize_bits;
 		ByteCount++;
 	}
 
-	Vbo >>= osb->sect_size_bits;
+	Vbo >>= osb->sb->s_blocksize_bits;
 
 	ocfs_extent_map_remove (Map, Vbo, (__s64) ByteCount);
 
@@ -516,15 +516,15 @@
 	Results = ocfs_extent_map_next_entry (Map, RunIndex, Vbo, Lbo,
 					  &LiSectorCount);
 
-	(*Vbo) <<= osb->sect_size_bits;
-	(*Lbo) <<= osb->sect_size_bits;
+	(*Vbo) <<= osb->sb->s_blocksize_bits;
+	(*Lbo) <<= osb->sb->s_blocksize_bits;
 
 	if (LiSectorCount > 0x00000000ffffffffLL) {
 		/* overflow */
 		Results = 0;
 		*SectorCount = 0xffffffffUL;
 	} else {
-		*SectorCount = ((__u32)(LiSectorCount & 0xFFFFFFFFULL)) << osb->sect_size_bits;
+		*SectorCount = ((__u32)(LiSectorCount & 0xFFFFFFFFULL)) << osb->sb->s_blocksize_bits;
 	}
 		
 	LOG_EXIT_INT (Results);
@@ -548,12 +548,12 @@
 	LOG_ENTRY ();
 
 	/* Sector Align the vbo */
-	remainder = Vbo & (osb->sect_size - 1);
+	remainder = Vbo & (osb->sb->s_blocksize - 1);
 
-	ret = ocfs_extent_map_lookup (Map, (Vbo >> osb->sect_size_bits), &LiLbo,
+	ret = ocfs_extent_map_lookup (Map, (Vbo >> osb->sb->s_blocksize_bits), &LiLbo,
 				   &LiSectorCount, Index);
 	if ((__u32) LiLbo != -1) {
-		*Lbo = (((__s64) LiLbo) << (__s64) osb->sect_size_bits);
+		*Lbo = (((__s64) LiLbo) << (__s64) osb->sb->s_blocksize_bits);
 		if (ret) {
 			*Lbo += remainder;
 		}
@@ -564,7 +564,7 @@
 
 	*SectorCount = LiSectorCount;
 	if (*SectorCount) {
-		*SectorCount <<= (__s64) osb->sect_size_bits;
+		*SectorCount <<= (__s64) osb->sb->s_blocksize_bits;
 		if (*SectorCount == 0) {
 			*SectorCount = (__u32) - 1;
 		}
@@ -702,13 +702,13 @@
 	if (ByteCount) {
 		/* Round up sectors */
 		ByteCount--;
-		ByteCount >>= osb->sect_size_bits;
+		ByteCount >>= osb->sb->s_blocksize_bits;
 		ByteCount++;
 	}
 
 	/* Make the ByteOffsets in to Sector numbers. */
-	Vbo >>= osb->sect_size_bits;
-	Lbo >>= osb->sect_size_bits;
+	Vbo >>= osb->sb->s_blocksize_bits;
+	Lbo >>= osb->sb->s_blocksize_bits;
 
 	ret = ocfs_extent_map_add (Map, ((__s64) Vbo), ((__s64) Lbo), ((__s64) ByteCount));
 	if (!ret)

Modified: branches/format-changes/src/file.c
===================================================================
--- branches/format-changes/src/file.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/file.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -38,6 +38,7 @@
 #include "dlm.h"
 #include "extmap.h"
 #include "file.h"
+#include "sysfile.h"
 #include "hash.h"
 #include "inode.h"
 #include "util.h"
@@ -802,7 +803,8 @@
 		    ("Will need more allocation: have=%llu, need=%llu\n",
 		     OCFS_I(inode)->alloc_size, newsize);
 		down(&OCFS_I(inode)->ip_io_sem);
-		status = ocfs_extend_file (osb, newsize, GET_INODE_FEOFF(inode), NULL, inode, NULL);
+		status = ocfs_extend_file (osb, newsize, GET_INODE_FEOFF(inode), NULL, inode, 
+					   NULL, 0, NULL);
 		up(&OCFS_I(inode)->ip_io_sem);
 		if (status < 0) {
 			if (status != -EINTR && status != -ENOSPC) {
@@ -1074,7 +1076,7 @@
 /* ocfs_extend_file()
  *
  */
-int ocfs_extend_file (ocfs_super * osb, __u64 file_size, __u64 file_off, ocfs_journal_handle *passed_handle, struct inode *inode, struct iattr *attr)
+int ocfs_extend_file (ocfs_super * osb, __u64 file_size, __u64 file_off, ocfs_journal_handle *passed_handle, struct inode *inode, struct iattr *attr, int system_file, struct buffer_head *fe_bh)
 {
 	int status = 0;
 	int tmpstat;
@@ -1102,10 +1104,14 @@
 	if (file_size == 0)
 		goto leave;
 
-	status = ocfs_read_bh (osb, file_off, &bh, OCFS_BH_CACHED, inode);
-	if (status < 0) {
-		LOG_ERROR_STATUS (status);
-		goto leave;
+	if (fe_bh)
+		bh = fe_bh;
+	else {
+		status = ocfs_read_bh (osb, file_off, &bh, OCFS_BH_CACHED, inode);
+		if (status < 0) {
+			LOG_ERROR_STATUS (status);
+			goto leave;
+		}
 	}
 
 	fe = OCFS_BH_GET_DATA_READ(bh);
@@ -1125,7 +1131,7 @@
 
 	if (passed_handle == NULL) {
 		credits = ocfs_calc_extend_credits(((__u32) alloc_size), 
-						   osb->vol_layout.cluster_size);
+						   osb->s_clustersize);
 
 		/* cannot call start_trans with a locked buffer head. */
 		handle = ocfs_start_trans(osb, OCFS_FILE_EXTEND_CREDITS);
@@ -1175,7 +1181,7 @@
 		/* we give a lot more disk space to the file than the alloc_size so */
 		/* in order to try to use the Extents of File Entry only and ofcourse */
 		/* the file will have more contigous disk space. */
-		{
+		if (!system_file) {
 			int one_percentish_bits = 7;
 			__u64 tempSize = current_alloc;
 
@@ -1205,9 +1211,7 @@
 			goto leave;
 		}
 
-		actualDiskOffset =
-		    (bitmapOffset << osb->s_clustersize_bits) +
-		    osb->vol_layout.data_start_off;
+		actualDiskOffset = bitmapOffset << osb->s_clustersize_bits;
 		actualLength = numClustersAlloc << osb->s_clustersize_bits;
 
 		OCFS_BH_PUT_DATA(bh);
@@ -1227,8 +1231,7 @@
 				brelse(alloc_bh);
 			}
 		}
-
-		ext_alloc_inode = igrab(osb->system_inodes[EXTENT_ALLOC_BITMAP_SYSTEM_INODE]);
+		ext_alloc_inode = ocfs_get_system_file_inode(osb, EXTENT_ALLOC_BITMAP_SYSTEM_INODE, osb->node_num);
 		if (!ext_alloc_inode) {
 			status = -EFAIL;
 			LOG_ERROR_STATUS(status);
@@ -1308,7 +1311,7 @@
 	if (bh != NULL)
 		LOG_TRACE_ARGS("bh->b_count = %d\n", 
 			       atomic_read(&(bh->b_count)));
-	if (bh != NULL)
+	if (bh != NULL && fe_bh == NULL)
 		brelse(bh);
 
 	if (ext_alloc_inode)
@@ -1408,7 +1411,7 @@
 						    inode);
 		else {
 			status = ocfs_extend_file(osb, newsize, fileOff, NULL, 
-						  inode, attr);
+						  inode, attr, 0, NULL);
 			extended = 1;
 		}
 		if (status < 0) {
@@ -1475,7 +1478,7 @@
 	generic_fillattr(inode, stat);
 
 	/* We set the blksize from the cluster size for performance */
-	stat->blksize = osb->vol_layout.cluster_size;
+	stat->blksize = osb->s_clustersize;
 
 bail:
 	LOG_EXIT_INT (err);

Modified: branches/format-changes/src/file.h
===================================================================
--- branches/format-changes/src/file.h	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/file.h	2004-06-12 21:05:20 UTC (rev 1069)
@@ -27,9 +27,10 @@
 #ifndef OCFS2_FILE_H
 #define OCFS2_FILE_H
 
-int ocfs_extend_file(ocfs_super *osb, __u64 file_size, __u64 file_off,
-		     ocfs_journal_handle *passed_handle,
-		     struct inode *inode, struct iattr *attr);
+int ocfs_extend_file (ocfs_super * osb, __u64 file_size, __u64 file_off, 
+		      ocfs_journal_handle *passed_handle, 
+		      struct inode *inode, struct iattr *attr, 
+		      int system_file, struct buffer_head *fe_bh);
 int ocfs_file_open(struct inode *inode, struct file *file);
 ssize_t ocfs_file_read(struct file *filp, char *buf, size_t count,
 		       loff_t * ppos);

Modified: branches/format-changes/src/heartbeat.c
===================================================================
--- branches/format-changes/src/heartbeat.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/heartbeat.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -64,8 +64,8 @@
 	int status = 0;
 	ocfs_publish *publish = NULL;
 	int publish_idx = OCFS_VOLCFG_NEWCFG_SECTORS + osb->node_num;
-	struct buffer_head **pub_bh = &osb->cfg_bhs[publish_idx];
-	__u64 node_publ_off = osb->vol_layout.publ_sect_off + (osb->node_num * osb->sect_size);
+	struct buffer_head **pub_bh = &osb->autoconfig_bhs[publish_idx];
+	__u64 node_publ_off = (osb->publish_blkno + osb->node_num) << osb->sb->s_blocksize_bits;
 
 	LOG_ENTRY_ARGS ("(0x%p, %u, %s)\n", osb, flag,
 			read_publish ? "true" : "false");

Modified: branches/format-changes/src/inode.c
===================================================================
--- branches/format-changes/src/inode.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/inode.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -224,13 +224,6 @@
 		/* If we fall through here, then it's mount time! */
 	}
 
-	/* This shouldn't happen anymore. */
-	if (osb->vol_layout.root_start_off == 0) {
-		LOG_ERROR_ARGS("root_start_off = 0! Skipping inode create for "
-		       "%llu\n", feoff);
-		goto bail;
-	}
-
 	/* Ok. By now we've either got the offsets passed to us by the
 	 * caller, or we just pulled them off the bh. Lets do some
 	 * sanity checks to make sure they're OK. */
@@ -239,10 +232,6 @@
 		goto bail;
 	}
 
-	/* try to detect whether this is a system file. */
-	if (feoff < osb->vol_layout.root_start_off)
-		flags |= OCFS_FIND_INODE_FLAG_SYSFILE;
-
 	args.feoff = feoff;
 	args.flags = flags;
 	args.ino = ino_from_off(sb, feoff);
@@ -401,7 +390,7 @@
 	inode->i_mode = fe->i_mode;
 	inode->i_uid = fe->i_uid;
 	inode->i_gid = fe->i_gid;
-	inode->i_blksize = (u32)osb->vol_layout.cluster_size;	// sb->s_blocksize;
+	inode->i_blksize = (u32)osb->s_clustersize;	// sb->s_blocksize;
 	inode->i_blocks = (fe->i_size + sb->s_blocksize) >> sb->s_blocksize_bits;
 	inode->i_mapping->a_ops = &ocfs_aops;
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
@@ -532,7 +521,6 @@
 	}
 
 	feoff = args->feoff;
-	sysfile = (args->flags & OCFS_FIND_INODE_FLAG_SYSFILE);
 
 	/* Read the FE off disk. This is safe because the kernel only
 	 * does one read_inode2 for a new inode, and if it doesn't
@@ -545,7 +533,7 @@
 	}
 
 	fe = OCFS_BH_GET_DATA_READ(bh);
-
+	sysfile = le32_to_cpu(fe->i_flags) & OCFS2_SYSTEM_FL;
 	if (S_ISCHR(fe->i_mode) || S_ISBLK(fe->i_mode))
     		inode->i_rdev = ocfs_decode_dev(le64_to_cpu(fe->id1.dev1.i_rdev));
 
@@ -1062,10 +1050,10 @@
 
 	/* ???: do we need priv_sem?  should have i_sem i think */
 	if (vbo >= OCFS_I(inode)->alloc_size) {
-		*err = ocfs_extend_file(osb,
-					vbo + 512LL,
+		*err = ocfs_extend_file(osb, 
+					vbo + 512LL, 
 					GET_INODE_FEOFF(inode),
-					handle, inode, NULL);
+				        handle, inode, NULL, 0, NULL);
 		if (*err < 0) {
 			*err = -ENOSPC;
 			return NULL;
@@ -1157,7 +1145,9 @@
 
 	if (!INODE_JOURNAL(inode) && vbo >= OCFS_I(inode)->alloc_size) {
 		LOG_TRACE_STR("Extending allocation");
-		err = ocfs_extend_file(osb, vbo + osb->sect_size, GET_INODE_FEOFF(inode), NULL, inode, NULL);
+		err = ocfs_extend_file(osb, vbo + osb->sb->s_blocksize, 
+				       GET_INODE_FEOFF(inode), NULL, inode, 
+				       NULL, 0, NULL);
 		if (err < 0) {
 			err = -ENOSPC;
 			LOG_ERROR_STATUS (err);
@@ -1409,7 +1399,7 @@
 	if (create && vbo_max > OCFS_I(inode)->alloc_size) {
 		/* WARNING: How much do we really want to extend the file? */
 		status = ocfs_extend_file(osb, vbo_max, GET_INODE_FEOFF(inode),
-					  NULL, inode, NULL);
+					  NULL, inode, NULL, 0, NULL);
 		if (status < 0) {
 			status = -ENOSPC;
 			LOG_ERROR_STR("ocfs_direct_IO_get_blocks: failed to extend the file!");
@@ -2022,11 +2012,11 @@
 printk("verifyupdate: setting nlink from %d to %d for %llu\n", inode->i_nlink, fe->i_links_count, GET_INODE_FEOFF(inode));
 		inode->i_nlink = fe->i_links_count;
 		OCFS_I(inode)->chng_seq_num = DISK_LOCK(fe)->dl_seq_num;
-		inode->i_blocks = (inode->i_size + osb->sect_size) >> osb->sect_size_bits;
+		inode->i_blocks = (inode->i_size + osb->sb->s_blocksize) >> osb->sb->s_blocksize_bits;
 		inode->i_uid = fe->i_uid;
 		inode->i_gid = fe->i_gid;
 		inode->i_mode = fe->i_mode;
-		inode->i_blksize = (__u32) osb->vol_layout.cluster_size;
+		inode->i_blksize = (__u32) osb->s_clustersize;
 		OCFS_SET_INODE_TIME(inode, i_ctime, fe->i_ctime);
 		OCFS_SET_INODE_TIME(inode, i_atime, fe->i_atime);
 		OCFS_SET_INODE_TIME(inode, i_mtime, fe->i_mtime);

Modified: branches/format-changes/src/journal.c
===================================================================
--- branches/format-changes/src/journal.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/journal.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -44,6 +44,7 @@
 #include "super.h"
 #include "util.h"
 #include "vote.h"
+#include "sysfile.h"
 
 #include "ocfs_journal.h"
 #include "ocfs_buffer_head.h"
@@ -320,21 +321,16 @@
 	
 	LOG_ENTRY_ARGS("(%llu)\n", lockid);
 
-	/* make sure that we have a root_start off     */
-	/* this can be called early in the first mount */
-	if (osb->vol_layout.root_start_off != 0 &&
-	    lockid >= osb->vol_layout.root_start_off) {
-		journal = osb->journal;
-		down(&journal->commit_sem);
-		list_for_each(p1, &(journal->commited)) {
-			handle = list_entry(p1, ocfs_journal_handle, h_list);
-			if (handle->new_file_lockid == lockid) {
-				status = 0;
-				break;
-			}
+	journal = osb->journal;
+	down(&journal->commit_sem);
+	list_for_each(p1, &(journal->commited)) {
+		handle = list_entry(p1, ocfs_journal_handle, h_list);
+		if (handle->new_file_lockid == lockid) {
+			status = 0;
+			break;
 		}
-		up(&journal->commit_sem);
 	}
+	up(&journal->commit_sem);
 
 	LOG_EXIT_STATUS(status);
 	return status;
@@ -543,7 +539,7 @@
 			LOG_ERROR_ARGS("block %lu was modified but never "
 				       "dirtied!\n", co->blocknr);
 			bh = getblk(OCFS_GET_BLOCKDEV(osb->sb), co->blocknr,
-				    osb->sect_size);
+				    osb->sb->s_blocksize);
 			if (bh == NULL)
 				BUG();
 
@@ -884,11 +880,8 @@
 	INIT_LIST_HEAD(&(osb->journal->commited));
 	init_MUTEX(&(osb->journal->commit_sem));
 
-	lock_id = ((OCFS_JOURNAL_FILE + osb->node_num) * osb->sect_size) +
-		  osb->vol_layout.root_int_off;
-
-	/* Ok, look up the inode for our journal */
-	inode = ocfs_iget(osb, lock_id);
+	/* already have the inode for our journal */
+	inode = ocfs_get_system_file_inode(osb, JOURNAL_SYSTEM_INODE, osb->node_num);
 	if (inode == NULL) {
 		LOG_ERROR_STR("access error");
 		status = -EACCES;
@@ -901,6 +894,7 @@
 		status = -EACCES;
 		goto done;
 	}
+	lock_id = GET_INODE_FEOFF(inode);
 
 	down(&OCFS_I(inode)->ip_io_sem);
 
@@ -1162,7 +1156,7 @@
 	struct buffer_head **bhs = NULL;
 
 	LOG_ENTRY();
-	totalblks = size >> osb->sect_size_bits;
+	totalblks = size >> osb->sb->s_blocksize_bits;
 
 	/* Ok, allocate the maximum number of blocks we'll possibly
 	 * need. This is heavy, but it doesn't happen often. If need
@@ -1207,7 +1201,7 @@
 			       "bytes\n", run, lbo, numbytes);
 
 		/* there are actually returned in bytes. need blocks. */
-		numblks = numbytes / osb->sect_size;
+		numblks = numbytes >> osb->sb->s_blocksize_bits;
 
 		status = ocfs_read_bhs(osb, lbo, numbytes, bhs, 0, NULL);
 		if (status < 0) {
@@ -1336,12 +1330,8 @@
 		goto done;
 	}
 
-	/* get the journal file fe and lock */
-	lock_id = ((OCFS_JOURNAL_FILE + node_num) * osb->sect_size) 
-		+ osb->vol_layout.root_int_off;
-
 	/* Ok, look up the inode for our journal */
-	inode = ocfs_iget(osb, lock_id);
+	inode = ocfs_get_system_file_inode(osb, JOURNAL_SYSTEM_INODE, node_num);
 	if (inode == NULL) {
 		LOG_ERROR_STR("access error");
 		status = -EACCES;
@@ -1354,6 +1344,7 @@
 		status = -EACCES;
 		goto done;
 	}
+	lock_id = GET_INODE_FEOFF(inode);
 
 	down(&OCFS_I(inode)->ip_io_sem);
 
@@ -1510,8 +1501,7 @@
 	down (&(osb->publish_lock));
 
 	/* Read the publish sector */
-	node_publ_off = osb->vol_layout.publ_sect_off +
-			(node_num * osb->sect_size);
+	node_publ_off = (osb->publish_blkno + node_num) << osb->sb->s_blocksize_bits;
 	status = ocfs_read_bh(osb, node_publ_off, &publish_bh, 
 			      OCFS_BH_COND_CACHED, NULL);
 	if (status < 0) {

Modified: branches/format-changes/src/lockres.c
===================================================================
--- branches/format-changes/src/lockres.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/lockres.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -73,8 +73,8 @@
 	b = (bh == NULL) ? &tmpbh : bh;
 
 	if (reread) {
-		flags = OCFS_NONCACHED(osb, lock_id) ? 0 : 
-		  	lockres->master_node_num == osb->node_num ? 
+		flags = (inode && OCFS_I(inode)->flags & OCFS_INODE_SYSTEM_FILE) ?
+			0 : lockres->master_node_num == osb->node_num ? 
 		    	OCFS_BH_CACHED : 0;	
 		status = ocfs_read_bh(osb, lock_id, b, flags, inode);
 		if (status < 0) {

Modified: branches/format-changes/src/namei.c
===================================================================
--- branches/format-changes/src/namei.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/namei.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -39,6 +39,7 @@
 #include "dir.h"
 #include "dlm.h"
 #include "file.h"
+#include "sysfile.h"
 #include "hash.h"
 #include "inode.h"
 #include "lockres.h"
@@ -372,7 +373,7 @@
 	ocfs_node_map_init(osb, &just_me);
 	ocfs_node_map_set_bit(&just_me, osb->node_num);
 
-	inode_alloc_inode = igrab(osb->system_inodes[INODE_ALLOC_BITMAP_SYSTEM_INODE]);
+	inode_alloc_inode = ocfs_get_system_file_inode(osb, INODE_ALLOC_BITMAP_SYSTEM_INODE, osb->node_num);
 	if (!inode_alloc_inode) {
 		status = -EFAIL;
 		LOG_ERROR_STATUS(status);
@@ -380,7 +381,7 @@
 	}
 
 	ocfs_handle_add_inode(handle, inode_alloc_inode);
-	status = ocfs_alloc_node_block(osb, osb->inode_size,
+	status = ocfs_alloc_node_block(osb, osb->sb->s_blocksize,
 			      	       &disk_off, &fileOffset, 
 			       	       osb->node_num, DISK_ALLOC_INODE, 
 		       		       handle);
@@ -1349,7 +1350,7 @@
 	OCFS_BH_PUT_DATA(new_fe_bh);
 	fe = NULL;
 
-	status = ocfs_extend_file (osb, newsize, file_off, handle, inode, NULL);
+	status = ocfs_extend_file (osb, newsize, file_off, handle, inode, NULL, 0, new_fe_bh);
 	if (status < 0) {
 		if (status != -ENOSPC && status != -EINTR) {
 			LOG_ERROR_ARGS ("Failed to extend file to %llu", newsize);
@@ -1696,7 +1697,7 @@
 	*res_dir = NULL;
 	sb = dir->i_sb;
 
-	nblocks = dir->i_size >> OCFS_SB(sb)->sect_size_bits;
+	nblocks = dir->i_size >> sb->s_blocksize_bits;
 	start = OCFS_I(dir)->i_dir_start_lookup;
 	if (start >= nblocks)
 		start = 0;
@@ -1740,7 +1741,7 @@
 			goto next;
 		}
 		i = search_dirblock(bh, dir, name, namelen,
-				    block << OCFS_SB(sb)->sect_size_bits, res_dir);
+				    block << sb->s_blocksize_bits, res_dir);
 		if (i == 1) {
 			OCFS_I(dir)->i_dir_start_lookup = block;
 			ret = bh;
@@ -1760,7 +1761,7 @@
 	 * search the last part of the directory before giving up.
 	 */
 	block = nblocks;
-	nblocks = dir->i_size >> OCFS_SB(sb)->sect_size_bits;
+	nblocks = dir->i_size >> sb->s_blocksize_bits;
 	if (block < nblocks) {
 		start = 0;
 		goto restart;

Modified: branches/format-changes/src/nm.c
===================================================================
--- branches/format-changes/src/nm.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/nm.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -227,7 +227,7 @@
 
 	ctxt = &sv->ctxt;
 	ctxt->u.publish = (ocfs_publish *) &sv->publish_sect;
-	memcpy(ctxt->u.publish, publish, osb->sect_size);
+	memcpy(ctxt->u.publish, publish, osb->sb->s_blocksize);
 	OCFS_BH_PUT_DATA(bh);
 
 	ctxt->request_method = DISK_VOTE;
@@ -275,7 +275,7 @@
 	__u32 i;
 	unsigned long j;
 	__u32 highest_vote_node;
-	__u64 offset = 0;
+	__u64 offset = 0, len = 0;
 	__u32 num_nodes = 0;
 	__u32 vote_node;
 	ocfs_node_config_hdr *node_cfg_hdr = NULL;
@@ -322,17 +322,18 @@
 		down (&(osb->publish_lock));
 
 		/* Get the Publish Sector start Offset */
-		offset = osb->vol_layout.new_cfg_off;
+		offset = osb->new_autoconfig_blkno << osb->sb->s_blocksize_bits;
+		len = osb->total_autoconfig_blocks << osb->sb->s_blocksize_bits;
 
-		/* Read disk for Publish Sectors of all nodes */
-		status = ocfs_read_bhs(osb, offset, osb->cfg_len, osb->cfg_bhs, 0, NULL);
+		/* Read disk for 4 autoconfig blocks + all nodes publish blocks */
+		status = ocfs_read_bhs(osb, offset, len, osb->autoconfig_bhs, 0, NULL);
 		if (status < 0) {
 			up (&(osb->publish_lock));
 			LOG_ERROR_STATUS (status);
 			goto finally;
 		}
 
-		bh = osb->cfg_bhs[OCFS_VOLCFG_NEWCFG_SECTORS + osb->node_num];
+		bh = osb->autoconfig_bhs[OCFS_VOLCFG_NEWCFG_SECTORS + osb->node_num];
 		publish = OCFS_BH_GET_DATA_READ(bh);
 		if ((osb->check_mounted) && (publish->mounted == 0)) {
 			printk("ocfs2: Heartbeat timed out, volume has been "
@@ -349,10 +350,10 @@
 		up (&(osb->publish_lock));
 
 		/* If another node was added to the config read and update the cfg */
-		node_cfg_hdr = OCFS_BH_GET_DATA_READ(osb->cfg_bhs[1]);
+		node_cfg_hdr = OCFS_BH_GET_DATA_READ(osb->autoconfig_bhs[1]);
 		num_nodes = node_cfg_hdr->num_nodes;
 		cfg_seq_num = node_cfg_hdr->cfg_seq_num;
-		OCFS_BH_PUT_DATA(osb->cfg_bhs[1]);
+		OCFS_BH_PUT_DATA(osb->autoconfig_bhs[1]);
 
 		if ((osb->cfg_seq_num != cfg_seq_num) ||
 		    (osb->num_cfg_nodes != num_nodes)) {
@@ -368,7 +369,7 @@
 		num_nodes = osb->max_nodes;
 
 		/* Refresh the publish map */
-		ocfs_update_publish_map (osb, &(osb->cfg_bhs[OCFS_VOLCFG_NEWCFG_SECTORS]), 0);
+		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) {
@@ -381,7 +382,7 @@
 		/* Check for the highest node looking for a vote, if anybody is looking */
 		for (i = 0, which = OCFS_VOLCFG_NEWCFG_SECTORS; i < num_nodes; i++, which++) {
 			ocfs_node_map vote_map;
-			publish = OCFS_BH_GET_DATA_READ(osb->cfg_bhs[which]);
+			publish = OCFS_BH_GET_DATA_READ(osb->autoconfig_bhs[which]);
 
 			if (publish->time == (__u64) 0)
 				goto loop;
@@ -403,7 +404,7 @@
 					       highest_vote_node)) {
 				vote_node = highest_vote_node;
 			} else {
-				OCFS_BH_PUT_DATA(osb->cfg_bhs[which]);
+				OCFS_BH_PUT_DATA(osb->autoconfig_bhs[which]);
 				publish = NULL;
 				/* I guess we don't even have to do
 				 * anything here... */
@@ -414,7 +415,7 @@
 			}
 loop:
 			publish = NULL;
-			OCFS_BH_PUT_DATA(osb->cfg_bhs[which]);
+			OCFS_BH_PUT_DATA(osb->autoconfig_bhs[which]);
 		}
 
 
@@ -423,7 +424,7 @@
 			__s32 voted;
 			LOG_TRACE_ARGS("vote_node = %d\n", vote_node);
 
-			bh = osb->cfg_bhs[OCFS_VOLCFG_NEWCFG_SECTORS 
+			bh = osb->autoconfig_bhs[OCFS_VOLCFG_NEWCFG_SECTORS 
 					  + osb->node_num];
 			down(&(osb->publish_lock));
 
@@ -446,7 +447,7 @@
 			up(&(osb->publish_lock));
 
 			which = vote_node + OCFS_VOLCFG_NEWCFG_SECTORS;
-			bh = osb->cfg_bhs[which];
+			bh = osb->autoconfig_bhs[which];
 
 			status= ocfs_schedule_process_vote(osb, bh, vote_node);
 			if (status < 0) {
@@ -671,13 +672,12 @@
 		lock_id = req_master->lock_id;
 		seq_num = req_master->lock_seq_num;
 	}
-	lockflags = (lock_id >= osb->vol_layout.bitmap_off ? OCFS_BH_CACHED : 0);
 	
 	LOG_TRACE_ARGS ("node=%u, id=%llu, seq=%llu\n", node_num,
 			lock_id, seq_num);
 
 	if (disk_vote) {
-		offset = osb->vol_layout.vote_sect_off + (osb->node_num * osb->sect_size);
+		offset = (osb->vote_blkno + osb->node_num) << osb->sb->s_blocksize_bits;
 		status = ocfs_read_bh(osb, offset, &vote_bh, 0, NULL);
 		if (status < 0) {
 			LOG_ERROR_STATUS (status);
@@ -728,6 +728,8 @@
 		}
 	}
 
+	lockflags = (IS_SYSTEM_FILE_INODE(inode) ? 0 : OCFS_BH_CACHED);
+
 	/* fail here if no inode, unless this is a delete/rename release */
 	vote_type = get_process_vote_action(osb, lockres, node_num, flags, 
 					    status, &master_alive, inode);

Modified: branches/format-changes/src/ocfs.h
===================================================================
--- branches/format-changes/src/ocfs.h	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/ocfs.h	2004-06-12 21:05:20 UTC (rev 1069)
@@ -148,9 +148,6 @@
 
 #define  MISS_COUNT_VALUE        30
 
-#define  OCFS_DEFAULT_FILE_NODE_SIZE (512)
-#define  OCFS_DEFAULT_INODE_SIZE     (512)
-
 /*
 ** The following flag values reflect the operation to be performed
 **   by ocfs_create_modify_file
@@ -778,7 +775,9 @@
 
 #define GET_INODE_CLEAN_SEQ(i)  (atomic_t *)(&(OCFS_I(i)->i_clean_buffer_seq))
 
+#define IS_SYSTEM_FILE_INODE(i)  ((i) && (OCFS_I(i)->flags & OCFS_INODE_SYSTEM_FILE))
 
+
 #define INODE_DELETED(i) (OCFS_I(i)->flags & OCFS_INODE_DELETED)
 #define SET_INODE_DELETED(i) (OCFS_I(i)->flags |= OCFS_INODE_DELETED)
 #define CLEAR_INODE_DELETED(i) (OCFS_I(i)->flags &= (~OCFS_INODE_DELETED))
@@ -810,36 +809,6 @@
 }
 ocfs_vol_state;
 
-typedef struct _ocfs_vol_layout
-{
-	__u64 start_off;
-	__u32 num_nodes;
-	__u32 cluster_size;
-	__u8 mount_point[MAX_MOUNT_POINT_LEN];
-	__u8 vol_id[MAX_VOL_ID_LENGTH];
-	__u8 label[MAX_VOL_LABEL_LEN];
-	__u32 label_len;
-	__u64 size;
-	__u64 root_start_off;
-	__u64 serial_num;
-	__u64 root_size;
-	__u64 publ_sect_off;
-	__u64 vote_sect_off;
-	__u64 root_bitmap_off;
-	__u64 root_bitmap_size;
-	__u64 data_start_off;
-	__u64 num_clusters;
-	__u64 root_int_off;
-	__u64 dir_node_size;
-	__u64 file_node_size;
-	__u64 bitmap_off;
-	__u64 node_cfg_off;
-	__u64 node_cfg_size;
-	__u64 new_cfg_off;
-	__u32 prot_bits;
-}
-ocfs_vol_layout;
-
 typedef struct _ocfs_vol_node_map
 {
 	__u64 time;
@@ -930,7 +899,26 @@
 	struct inode *root_inode;
 	struct inode *sys_root_inode;
 	struct inode *system_inodes[NUM_SYSTEM_INODES];
-	ocfs_vol_layout vol_layout;
+	
+	/* new */
+	__u64 num_clusters;
+	__u64 root_blkno;
+	__u64 system_dir_blkno;
+	__u64 bitmap_blkno;
+	__u64 bitmap_blocks;
+	__u64 publish_blkno;
+	__u64 publish_blocks;
+	__u64 vote_blkno;
+	__u64 vote_blocks;
+	__u64 autoconfig_blkno;
+	__u64 autoconfig_blocks;
+	__u64 new_autoconfig_blkno;
+	__u64 new_autoconfig_blocks;
+	__u64 total_autoconfig_blocks;
+	__u8 *uuid;
+	__u8 *vol_label;
+
+	
 	ocfs_vol_node_map *vol_node_map;
 	struct semaphore cfg_lock;
 	BARF_BARF_BARF **node_cfg_info;
@@ -938,16 +926,12 @@
 	int cfg_initialized;
 	__u32 max_nodes;
 	__u32 num_cfg_nodes;
+	__u32 num_nodes;
 	__u32 node_num;
 	int reclaim_id;		/* reclaim the original node number*/
 	__u32 hbt;
-	__u32 sect_size;
-	__u32 sect_size_bits;
 	unsigned long s_clustersize;
 	int s_clustersize_bits;
-	__u32 file_alloc_bits;
-	__u32 inode_alloc_bits;
-	__u32 inode_size;
 	int needs_flush;
 
 	ocfs_alloc_bm cluster_bitmap;
@@ -965,9 +949,7 @@
 	atomic_t nm_init;
 	wait_queue_head_t nm_init_event;
 	__u32 prealloc_lock;
-	struct buffer_head **cfg_bhs;
-	__u32 cfg_len;
-	__u32 cfg_numblocks;
+	struct buffer_head **autoconfig_bhs;
 	struct semaphore publish_lock;  /* protects r/w to publish sector */
 	atomic_t node_req_vote;         /* set when node's vote req pending */
 	int publish_dirty;
@@ -1099,6 +1081,73 @@
 	__u8 ov_pad[7]; 		// UNUSED
 } ocfs_vote;				// END CLASS
 
+#if 0
+/*
+ * On disk file entry (inode) for OCFS v2
+ */
+typedef struct _ocfs2_dinode {
+/*00*/	__u8 i_signature[8];		/* Signature for validation */
+	__u32 i_generation;		/* Generation number */
+	__u32 i_suballoc_node;		/* Node suballocater this inode
+					   belongs to */
+/*10*/	__u64 i_suballoc_blkno;		/* Node suballocator offset
+       					   (in blocks) */
+/*18*/	ocfs_disk_lock disk_lock;	/* Lock structure */
+/*38*/	__u32 i_uid;			/* Owner UID */
+	__u32 i_gid;			/* Owning GID */
+/*40*/	__u64 i_size;			/* Size in bytes */
+	__u16 i_mode;			/* File mode */
+	__u16 i_links_count;		/* Links count */
+	__u32 i_flags;			/* File flags */
+/*50*/	__u64 i_atime;			/* Access time */
+	__u64 i_ctime;			/* Creation time */
+/*60*/	__u64 i_mtime;			/* Modification time */
+	__u64 i_dtime;			/* Deletion time */
+/*70*/	__u64 i_blkno;			/* Offset on disk, in blocks */
+	__u32 i_clusters;		/* Cluster count */
+	__u32 i_reserved1;
+
+/*80*/	union {
+		__u64 fe_private;
+                __u64 i_rdev;
+		struct _bitinfo {
+			__u32 used_bits;
+			__u32 total_bits;
+		} bitinfo;
+	} u;
+/*98*/	__s16 i_tree_depth;		/* Extent tree depth
+					 * -1 means data extents hang
+					 * directly off of the
+					 * file_entry.
+					 */
+	__u16 i_next_free_ext;		/* Next unused extent slot */
+	__u32 i_reserved3;
+/*A0*/	__u64 last_ext_ptr;		/* Pointer to last extdat */
+
+/*A8*/  union {
+		struct _superinfo {
+			__u16 major_rev_level;
+			__u16 minor_rev_level;
+			__u16 mnt_count;
+			__s16 max_mnt_count;
+			__u16 state;                /* File system state */
+			__u16 errors;               /* Behaviour when detecting errors */
+			__u32 checkinterval;        /* max. time between checks */
+			__u64 lastcheck;            /* time of last check */
+			__u32 creator_os;  	    /* OS */
+			__u32 feature_compat;       /* compatible feature set */
+			__u32 feature_incompat;     /* incompatible feature set */
+			__u32 feature_ro_compat;    /* readonly-compatible feature set */
+			__u64 root_blkno;	    /* block offset to root directory dinode */
+			__u64 system_dir_blkno;	    /* block offset to system directory dinode */
+			__u8  label[64];	    /* label for mounting, etc. */
+			__u8  uuid[16];    	    /* was vol_id */
+		} super;
+		ocfs_extent_rec extents[OCFS_MAX_FILE_ENTRY_EXTENTS];  // EXTENT[OCFS_MAX_FILE_ENTRY_EXTENTS]
+	} u2;
+} ocfs2_dinode;
+#endif
+
 typedef struct _ocfs_dlm_msg_hdr
 {
 	__u64 lock_id;

Added: branches/format-changes/src/ocfs1.h
===================================================================
--- branches/format-changes/src/ocfs1.h	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/ocfs1.h	2004-06-12 21:05:20 UTC (rev 1069)
@@ -0,0 +1,83 @@
+#ifndef OCFS1_H
+#define OCFS1_H
+
+#define MAX_VOL_SIGNATURE_LEN_V1          128
+#define MAX_MOUNT_POINT_LEN_V1            128
+#define MAX_VOL_ID_LENGTH_V1               16
+#define MAX_VOL_LABEL_LEN_V1               64
+#define MAX_CLUSTER_NAME_LEN_V1            64
+
+#define OCFS1_MAJOR_VERSION              (2)
+#define OCFS1_MINOR_VERSION              (2)
+#define OCFS1_VOLUME_SIGNATURE		 "OracleCFS"
+
+typedef struct _ocfs_vol_disk_hdr_v1		   // CLASS
+{
+	__u32 minor_version;                       // NUMBER RANGE(0,UINT_MAX)
+	__u32 major_version;                       // NUMBER RANGE(0,UINT_MAX)
+	__u8 signature[MAX_VOL_SIGNATURE_LEN_V1];	 // CHAR[MAX_VOL_SIGNATURE_LEN]
+	__u8 mount_point[MAX_MOUNT_POINT_LEN_V1];	 // CHAR[MAX_MOUNT_POINT_LEN]
+	__u64 serial_num;                          // NUMBER RANGE(0,ULONG_LONG_MAX)
+	/* Size of the device in bytes */           
+	__u64 device_size;	                 // NUMBER RANGE(0,ULONG_LONG_MAX)
+	/* Start of the volume... typically 0 */    
+	__u64 start_off;		                 // NUMBER RANGE(0,ULONG_LONG_MAX)
+	/* Offset to Volume Bitmap... */            
+	__u64 bitmap_off;		                 // NUMBER RANGE(0,ULONG_LONG_MAX)
+	/* Offset to the Publish Sector */          
+	__u64 publ_off;		                 // NUMBER RANGE(0,ULONG_LONG_MAX)
+	/* Offset to the Vote Sector */             
+	__u64 vote_off;		                 // NUMBER RANGE(0,ULONG_LONG_MAX)
+	__u64 root_bitmap_off;                     // NUMBER RANGE(0,ULONG_LONG_MAX)
+	__u64 data_start_off;                      // NUMBER RANGE(0,ULONG_LONG_MAX)
+	__u64 root_bitmap_size;                    // NUMBER RANGE(0,ULONG_LONG_MAX)
+	__u64 root_off;                            // NUMBER RANGE(0,ULONG_LONG_MAX)
+	__u64 root_size;                           // NUMBER RANGE(0,ULONG_LONG_MAX)
+	/* Cluster size as specified during format */        
+	__u64 cluster_size;	                 // CLUSTERSIZE
+	/* Max number of nodes.... OCFS_MAXIMUM_NODES */
+	__u64 num_nodes;		                 // NUMBER RANGE(0,32)
+	/* Number of free clusters at format */
+	__u64 num_clusters;	                 // NUMBER RANGE(0,ULONG_LONG_MAX)
+	/* OCFS_DEFAULT_DIR_NODE_SIZE */
+	__u64 dir_node_size;	                 // NUMBER RANGE(0,ULONG_LONG_MAX)
+	/* OCFS_DEFAULT_FILE_NODE_SIZE */
+	__u64 file_node_size;	                 // NUMBER RANGE(0,ULONG_LONG_MAX)
+	__u64 internal_off;                        // NUMBER RANGE(0,ULONG_LONG_MAX)
+	/* Offset to Node Config */
+	__u64 node_cfg_off;	                 // NUMBER RANGE(0,ULONG_LONG_MAX)
+	/* Size of Node Config */
+	__u64 node_cfg_size;	                 // NUMBER RANGE(0,ULONG_LONG_MAX)
+	/* Offset to Node Config Lock */
+	__u64 new_cfg_off;	                 // NUMBER RANGE(0,ULONG_LONG_MAX)
+	__u32 prot_bits;                           // PERMS
+	__s32 excl_mount;                          // NODENUM
+}
+ocfs_vol_disk_hdr_v1;				   // END CLASS
+
+
+typedef struct _ocfs_disk_lock_v1
+{
+/*00*/	__u32 curr_master;	/* Node number of current master */
+	__u8 file_lock;		/* Lock level */
+	__u8 odl_pad[3];	/* Pad to u64 */
+	__u64 dlock_seq_num;	/* Lock transaction seqnum */
+/*10*/	__u32 oin_node_map[8];	/* Bitmap of interested nodes, was __u32 */ 
+/*30*/
+}
+ocfs_disk_lock_v1;
+
+typedef struct _ocfs_vol_label_v1			 // CLASS
+{
+	ocfs_disk_lock_v1 disk_lock;                // DISKLOCK
+	__u8 label[MAX_VOL_LABEL_LEN_V1];            // CHAR[MAX_VOL_LABEL_LEN]
+	__u16 label_len;                           // NUMBER RANGE(0,MAX_VOL_LABEL_LEN)
+	__u8 vol_id[MAX_VOL_ID_LENGTH_V1];           // HEX[MAX_VOL_ID_LENGTH]
+	__u16 vol_id_len;                          // NUMBER RANGE(0,MAX_VOL_ID_LENGTH)
+	__u8 cluster_name[MAX_CLUSTER_NAME_LEN_V1];  // CHAR[MAX_CLUSTER_NAME_LEN]
+	__u16 cluster_name_len;                    // NUMBER RANGE(0,MAX_CLUSTER_NAME_LEN)
+}
+ocfs_vol_label_v1;					  // END CLASS
+
+
+#endif /* OCFS1_H */

Modified: branches/format-changes/src/ocfs2_fs.h
===================================================================
--- branches/format-changes/src/ocfs2_fs.h	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/ocfs2_fs.h	2004-06-12 21:05:20 UTC (rev 1069)
@@ -77,9 +77,11 @@
 	INODE_ALLOC_SYSTEM_INODE,
 	INODE_ALLOC_BITMAP_SYSTEM_INODE,
 	JOURNAL_SYSTEM_INODE,
+	LOCAL_ALLOC_SYSTEM_INODE,
 	NUM_SYSTEM_INODES
 };
 
+
 /* Default size for the local alloc bitmap */
 #define OCFS2_LOCAL_BITMAP_DEFAULT_SIZE 256
 

Modified: branches/format-changes/src/ocfs_buffer_head.h
===================================================================
--- branches/format-changes/src/ocfs_buffer_head.h	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/ocfs_buffer_head.h	2004-06-12 21:05:20 UTC (rev 1069)
@@ -67,8 +67,6 @@
 #define OCFS_BH_READAHEAD         16	/* use this to pass READA down to submit_bh */
 
 
-#define OCFS_NONCACHED(osb,off)  ((off) < (osb)->vol_layout.data_start_off)
-
 #define BH_Modified 18
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)

Modified: branches/format-changes/src/proc.c
===================================================================
--- branches/format-changes/src/proc.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/proc.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -388,7 +388,8 @@
 	}
 
 	ProcList[0].data = (char *) osb;
-	ProcList[1].data = osb->vol_layout.mount_point;
+#warning fix proc mountpoint
+	ProcList[1].data = "unknown";
 	ProcList[2].data = (char *) osb;
 	ProcList[3].data = (char *) osb;
 	ProcList[4].data = (char *) osb;
@@ -478,14 +479,12 @@
 	int len;
 	char *pubmap = NULL;
 	ocfs_super *osb;
-	ocfs_vol_layout *vol;
 	int ret = 0, i;
 	char *ptr;
 
 	LOG_ENTRY ();
 
 	osb = data;
-	vol = &(osb->vol_layout);
 
 	pubmap = ocfs_malloc (100);
 	if (!pubmap) {
@@ -507,14 +506,13 @@
   "Number of nodes          : %u\n"		\
   "Cluster size             : %u\n"		\
   "Volume size              : %llu\n"		\
-  "File node size           : %llu\n"		\
   "Failed Large Allocs      : %u\n"		\
   "Retry Large Allocs       : %u\n"		\
   "Inode Hash Objects       : %u\n"
 
 	len = sprintf (page, PROC_STATS, osb->file_open_cnt, pubmap,
-		       vol->num_nodes, vol->cluster_size, vol->size,
-		       vol->file_node_size,
+		       osb->num_nodes, osb->s_clustersize, 
+		       osb->cluster_bitmap.validbits << osb->s_clustersize_bits,
 		       osb->cluster_bitmap.failed, 
 		       osb->cluster_bitmap.ok_retries, 
 		       osb->inode_hash.num_ents);

Modified: branches/format-changes/src/super.c
===================================================================
--- branches/format-changes/src/super.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/super.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -38,10 +38,14 @@
 #include <linux/statfs.h>
 #include <linux/moduleparam.h>
 #endif
+#include <linux/blkdev.h>
 
 #include "ocfs_log.h"
 #include "ocfs.h"
 
+// this should be the only file to include a version 1 header
+#include "ocfs1.h"
+
 #include "alloc.h"
 #include "bitmap.h"
 #include "hash.h"
@@ -181,10 +185,10 @@
 static int ocfs_publish_toggle_mounted(ocfs_super *osb, int node_num,
 				       int value);
 static int ocfs_check_volume(ocfs_super * osb);
-static int ocfs_verify_volume(ocfs_vol_disk_hdr *vdh);
-static int ocfs_initialize_osb(ocfs_super *osb, ocfs_vol_disk_hdr *vdh,
-			       ocfs_vol_label *vol_label,
-       			       __u32 sect_size);
+static int ocfs_verify_volume(ocfs2_dinode *di, struct buffer_head *bh,
+			      __u32 sectsize);
+static int ocfs_initialize_osb(ocfs_super *osb, struct buffer_head *bh);
+static int ocfs2_get_sector(struct super_block *sb, struct buffer_head **bh, int block, int sect_size);
 
 static struct super_operations ocfs_sops = {
 	.statfs = ocfs_statfs,
@@ -233,11 +237,18 @@
 
 	LOG_ENTRY();
 
-	new = ocfs_iget(osb, OCFS_SYS_ROOT_INODE_OFF(osb));
+	new = ocfs_iget(osb, osb->root_blkno << osb->sb->s_blocksize_bits);
 	if (!new) {
 		LOG_ERROR_STATUS(status = -EINVAL);
 		goto bail;
 	}
+	osb->root_inode = new;
+
+	new = ocfs_iget(osb, osb->system_dir_blkno << osb->sb->s_blocksize_bits);
+	if (!new) {
+		LOG_ERROR_STATUS(status = -EINVAL);
+		goto bail;
+	}
 	osb->sys_root_inode = new;
 
 	for (i = 0; i < NUM_SYSTEM_INODES; i++) {
@@ -703,11 +714,20 @@
 	int status;
 	ocfs2_dinode *bm_lock;
 	struct buffer_head *bh;
+	struct inode *inode = NULL;
 
 	LOG_ENTRY_ARGS ("(%p, %p)\n", sb, buf);
 
 	osb = OCFS_SB(sb);
- 
+
+#warning WRONG WRONG WRONG	
+
+	inode = ocfs_get_system_file_inode(osb, GLOBAL_BITMAP_SYSTEM_INODE, -1);
+	if (!inode) {
+		LOG_ERROR_STR("failed to get bitmap inode");
+		return -EIO;
+	}
+
 	status = ocfs_read_bh (osb, OCFS_BITMAP_LOCK_OFFSET(osb), &bh, 0, NULL);
 	if (status < 0) {
 		LOG_ERROR_STR("failed to read bitmap data");
@@ -732,20 +752,20 @@
 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
 	buf->f_blocks =
 		(unsigned long) ((unsigned long) (numbits) *
-				 (unsigned long) (osb->vol_layout.cluster_size >> osb->sect_size_bits) -
+				 (unsigned long) (osb->s_clustersize >> osb->sb->s_blocksize_bits) -
 				 reserved_bits);
 	buf->f_bfree =
-	    (unsigned long) (freebits * (osb->vol_layout.cluster_size >> osb->sect_size_bits));
+	    (unsigned long) (freebits * (osb->s_clustersize >> osb->sb->s_blocksize_bits));
 	buf->f_bavail = buf->f_bfree;
 	buf->f_files = (unsigned long) (numbits);
 	buf->f_ffree = (unsigned long) (numbits) - freebits;
 #else
 	buf->f_blocks =
 		(sector_t) ((unsigned long) (numbits) *
-			    (unsigned long) (osb->vol_layout.cluster_size >> osb->sect_size_bits) -
+			    (unsigned long) (osb->s_clustersize >> osb->sb->s_blocksize_bits) -
 			    reserved_bits);
 	buf->f_bfree =
-	    (sector_t) (freebits * (osb->vol_layout.cluster_size >> osb->sect_size_bits));
+	    (sector_t) (freebits * (osb->s_clustersize >> osb->sb->s_blocksize_bits));
 	buf->f_files = (sector_t) (numbits);
 	buf->f_ffree = (sector_t) (numbits) - freebits;
 #endif
@@ -797,55 +817,127 @@
 	OCFS_CLEAR_FLAG (OcfsGlobalCtxt.flags, OCFS_FLAG_MEM_LISTS_INITIALIZED);
 }				/* ocfs_free_mem_lists */
 
+#define MAGIC_SUPERBLOCK_BLOCK_NUMBER  2
 
-/*
- * ocfs_mount_volume()
- *
- */
-static int ocfs_mount_volume (struct super_block *sb, int reclaim_id, struct inode *root)
+static int ocfs2_sb_probe(struct super_block *sb, struct buffer_head **bh)
 {
-	int status;
-	ocfs_super *osb;
-	ocfs_vol_disk_hdr *vol_header = NULL;
-	ocfs_vol_label *vol_label = NULL;
-	int child_pid, i, sect_size;
-	struct buffer_head *bhs[] = { NULL, NULL };
-	struct inode *inode;
+	int status = 0, tmpstat;
+	ocfs_vol_disk_hdr_v1 *hdr;
+	ocfs2_dinode *di;
+	int hardsect, sectsize;
 
-	LOG_ENTRY ();
+	*bh = NULL;
 
-	/* Force 512B sector size for vol_header reads */
-	status = ocfs_set_blocksize(sb, 512, 9);
+	/* may be > 512 */
+	hardsect = get_hardsect_size(sb->s_dev);
+	if (hardsect > 4096) {
+		LOG_ERROR_ARGS("hardsect size too large: %d (max=4096)\n", hardsect);
+		status = -EINVAL;
+		goto bail;
+	}
+	
+	/* check block zero for old format */
+	status = ocfs2_get_sector(sb, bh, 0, hardsect);
 	if (status < 0) {
-		LOG_ERROR_STR("unable to set vol_header blocksize");
-		goto leave;
+		LOG_ERROR_STATUS(status);
+		goto bail;
 	}
+	hdr = (ocfs_vol_disk_hdr_v1 *) OCFS_BH_GET_DATA_READ(*bh);
+	if (hdr->major_version == OCFS1_MAJOR_VERSION) {
+		LOG_ERROR_ARGS("incompatible version: %u.%u\n",
+			       hdr->major_version, hdr->minor_version);
+		status = -EINVAL;
+	}
+	if (memcmp (hdr->signature, OCFS1_VOLUME_SIGNATURE,
+		    strlen (OCFS1_VOLUME_SIGNATURE)) == 0) {
+		LOG_ERROR_ARGS("incompatible volume signature: %8s\n",
+			       hdr->signature);
+		status = -EINVAL;
+	}
+	OCFS_BH_PUT_DATA(*bh);
+	brelse(*bh);
+	*bh = NULL;
+	if (status < 0) {
+		LOG_ERROR_STR("This is an ocfs v1 filesystem which must be upgraded "
+			      "before mounting with ocfs v2");
+		goto bail;
+	}
 
-	/* get first two blocks */
-	for (i = 0; i < 2; i++) {
-		bhs[i] = getblk (OCFS_GET_BLOCKDEV(sb), i, 512);
-		if (bhs[i] == NULL) {
-			LOG_ERROR_STATUS(status = -EIO);
-			goto leave;
+	/* now check at magic offset for 512, 1024, 2048, 4096 blocksizes */
+	status = -EINVAL;
+	for (sectsize=hardsect; sectsize<=4096; sectsize<<=1) {
+		int done = 0;
+		tmpstat = ocfs2_get_sector(sb, bh, 
+					   MAGIC_SUPERBLOCK_BLOCK_NUMBER, 
+					   sectsize);
+		if (tmpstat < 0) {
+			LOG_ERROR_STATUS(status = tmpstat);
+			goto bail;
 		}
+		di = (ocfs2_dinode *) OCFS_BH_GET_DATA_READ(*bh);
+		status = ocfs_verify_volume(di, *bh, sectsize);
+		OCFS_BH_PUT_DATA(*bh);
+		brelse(*bh);
+		*bh = NULL;
+		if (done)
+			break;
+	}
 
-		lock_buffer(bhs[i]);
-		if (!buffer_dirty(bhs[i]))
-			clear_buffer_uptodate(bhs[i]);
-		unlock_buffer(bhs[i]);
+bail:
+	return status;
+}
+
+static int ocfs2_get_sector(struct super_block *sb, struct buffer_head **bh, int block, int sect_size)
+{
+	int i, bits=0, status = 0;
+
+	for (i=32; i>=0; i--) {
+		if ((1 << i) == sect_size)
+			bits = i;
 	}
+	if (!bits) {
+		LOG_ERROR_STR("unable to get blocksize bits");
+		return -EINVAL;
+	}
+	
+	status = ocfs_set_blocksize(sb, sect_size, bits);
+	if (status < 0) {
+		LOG_ERROR_STR("unable to set blocksize");
+		return status;
+	}
 
-	ll_rw_block(READ, 2, bhs);
-	for (i = 0; i < 2; i++)
-		wait_on_buffer(bhs[i]);
+	*bh = getblk (OCFS_GET_BLOCKDEV(sb), block, sect_size);
+	if (!*bh) {
+		LOG_ERROR_STATUS(-EIO);
+		return -EIO;
+	}
+	lock_buffer(*bh);
+	if (!buffer_dirty(*bh))
+		clear_buffer_uptodate(*bh);
+	unlock_buffer(*bh);
+	ll_rw_block(READ, 1, bh);
+	wait_on_buffer(*bh);
+	return 0;
+}
 
-	vol_header = OCFS_BH_GET_DATA_READ(bhs[0]);
-	vol_label = OCFS_BH_GET_DATA_READ(bhs[1]);
 
-	LOG_TRACE_STR ("ocfs_verify_volume...");
-	status = ocfs_verify_volume (vol_header);
+/*
+ * ocfs_mount_volume()
+ *
+ */
+static int ocfs_mount_volume (struct super_block *sb, int reclaim_id, struct inode *root)
+{
+	int status;
+	ocfs_super *osb;
+	int child_pid;
+	struct buffer_head *bh = NULL;
+
+	LOG_ENTRY ();
+
+	/* probe for superblock */
+	status = ocfs2_sb_probe(sb, &bh);
 	if (status < 0) {
-		LOG_ERROR_STATUS (status);
+		LOG_ERROR_STR("superblock probe failed!");
 		goto leave;
 	}
 
@@ -861,28 +953,13 @@
 
 	osb->reclaim_id = reclaim_id;
 
-	/* FIXME: here it should use the actual blocksize */
-	sect_size = OCFS_SECTOR_SIZE;
-	status = ocfs_initialize_osb(osb, vol_header, vol_label,
-				     sect_size);
+	/* s_blocksize was set in the probe */
+	status = ocfs_initialize_osb(osb, bh);
 	if (status < 0) {
 		LOG_ERROR_STATUS (status);
 		goto leave;
 	}
 
-	/* Now set real blocksize */
-	status = ocfs_set_blocksize(sb, osb->sect_size,
-				    osb->sect_size_bits);
-	if (status < 0) {
-		LOG_ERROR_STR("unable to set final blocksize");
-		goto leave;
-	}
-
-	OCFS_BH_PUT_DATA(bhs[0]);
-	vol_header = NULL;
-	OCFS_BH_PUT_DATA(bhs[1]);
-	vol_label = NULL;
-
 	down(&(osb->osb_res));
 
 	/* Launch the NM thread for the mounted volume */
@@ -948,21 +1025,6 @@
 	osb->vol_state = VOLUME_ENABLED;
 	up (&(osb->osb_res));
 
-	inode = ocfs_iget(osb, OCFS_ROOT_INODE_FE_OFF(osb));
-	if (!inode) {
-		status = -EIO;
-		LOG_ERROR_STATUS (status);
-		goto leave;
-	}
-
-	osb->root_inode = inode;
-
-	status = ocfs_init_system_inodes(osb);
-	if (status < 0) {
-		LOG_ERROR_STATUS(status);
-		goto leave;
-	}
-
 	/* Read the publish sector for this node and cleanup dirent being */
 	/* modified when we crashed. */
 	LOG_TRACE_STR ("ocfs_check_volume...");
@@ -1001,16 +1063,8 @@
 	osb->vol_state = VOLUME_MOUNTED;
 
 leave:
-	if (bhs[0] != NULL) {
-		if (vol_header)
-			OCFS_BH_PUT_DATA(bhs[0]);
-		brelse(bhs[0]);
-	}
-	if (bhs[1] != NULL) {
-		if (vol_label)
-			OCFS_BH_PUT_DATA(bhs[1]);
-		brelse(bhs[1]);
-	}
+	if (bh != NULL)
+		brelse(bh);
 	LOG_EXIT_STATUS (status);
 	return status;
 }				/* ocfs_mount_volume */
@@ -1177,8 +1231,7 @@
 	LOG_ENTRY();
 
 	/* read it in */
-	offset = osb->vol_layout.publ_sect_off +
-		(node_num * osb->sect_size);
+	offset = (osb->publish_blkno + node_num) << osb->sb->s_blocksize_bits;
 	/* we may be called during mount in which case our publish
 	 * sector might be dirty. */
 	if (node_num == osb->node_num)
@@ -1212,8 +1265,7 @@
 	LOG_ENTRY_ARGS("(node_num=%d, value=%d)\n", node_num, value);
 
 	/* read it in */
-	offset = osb->vol_layout.publ_sect_off +
-		(node_num * osb->sect_size);
+	offset = (osb->publish_blkno + node_num) << osb->sb->s_blocksize_bits;
 	status = ocfs_read_bh(osb, offset, &publish_bh, 0, NULL);
 	if (status < 0) {
 		LOG_ERROR_STATUS (status);
@@ -1286,24 +1338,40 @@
  * ocfs_initialize_osb()
  *
  */
-static int ocfs_initialize_osb(ocfs_super *osb, ocfs_vol_disk_hdr *vdh,
-			       ocfs_vol_label *vol_label,
-			       __u32 sect_size)
+static int ocfs_initialize_osb(ocfs_super *osb, struct buffer_head *bh)
 {
 	int status = 0;
 	ocfs_publish *publish = NULL;
-	__u32 bitmap_bits, length;
-	__u64 offset;
-	ocfs_vol_layout *vol_layout;
+	__u32 length;
+	__u64 offset, ret;
 	struct buffer_head *publish_bh = NULL;  /* our own publish sector */
 	struct buffer_head **publish_bhs = NULL; /* all the publish sectors */
 	int i;
+	ocfs2_dinode *di = NULL;
+	struct inode *inode = NULL;
 
 	LOG_ENTRY ();
 
-	/* FIXME: before getting started, this MUST be set */
-	osb->max_nodes = 32;  // noNONONO!
 	
+	osb->vol_label = kmalloc(64, GFP_KERNEL);
+	if (!osb->vol_label) {
+		LOG_ERROR_STR("unable to alloc vol label");
+		status = -ENOMEM;
+		goto done_nojournal;
+	}
+	osb->uuid = kmalloc(MAX_VOL_ID_LENGTH, GFP_KERNEL);
+	if (!osb->uuid) {
+		LOG_ERROR_STR("unable to alloc uuid");
+		status = -ENOMEM;
+		goto done_nojournal;
+	}
+
+
+	/* this needs to be done before most other initializations */
+	di = OCFS_BH_GET_DATA_READ(bh);
+	osb->max_nodes = le32_to_cpu(di->id2.i_super.s_max_nodes);
+	OCFS_BH_PUT_DATA(bh);
+
 	/* FIXME
 	 * This should be done in ocfs_journal_init(), but unknown
 	 * ordering issues will cause the filesystem to crash.
@@ -1312,6 +1380,7 @@
 	 * be my guest.
 	 */
 	/* initialize our journal structure */
+
 	osb->journal = kmalloc(sizeof(ocfs_journal), GFP_KERNEL);
 	if (!osb->journal) {
 		LOG_ERROR_STR("unable to alloc journal");
@@ -1360,9 +1429,6 @@
 		
 	OCFS_CLEAR_FLAG (osb->osb_flags, OCFS_OSB_FLAGS_SHUTDOWN);
 
-	vol_layout = &(osb->vol_layout);
-
-	vol_layout->cluster_size = (__u32) (vdh->cluster_size);
 	osb->obj_id.type = OCFS_TYPE_OSB;
 	osb->obj_id.size = sizeof (ocfs_super);
 	INIT_LIST_HEAD (&(osb->osb_next));
@@ -1405,78 +1471,162 @@
 	for (i=0; i<osb->max_nodes; i++) {
 		INIT_LIST_HEAD(&(osb->lock_recovery_lists[i]));
 	}
-	osb->sect_size = sect_size;
-			
 	osb->node_num = OCFS_INVALID_NODE_NUM;
 
-	memcpy (vol_layout->mount_point, vdh->mount_point, strlen (vdh->mount_point));
-	vol_layout->serial_num = vdh->serial_num;
-	vol_layout->size = vdh->device_size;
-	vol_layout->start_off = vdh->start_off;
-	vol_layout->bitmap_off = vdh->bitmap_off;
-	vol_layout->publ_sect_off = vdh->publ_off;
-	vol_layout->vote_sect_off = vdh->vote_off;
-	vol_layout->root_bitmap_off = vdh->root_bitmap_off;
-	vol_layout->root_start_off = vdh->root_off;
-	vol_layout->root_int_off = vdh->internal_off;
-	vol_layout->root_size = vdh->root_size;
-	vol_layout->cluster_size = (__u32) vdh->cluster_size;
-	vol_layout->num_nodes = (__u32) vdh->num_nodes;
-	vol_layout->data_start_off = vdh->data_start_off;
-	vol_layout->root_bitmap_size = vdh->root_bitmap_size;
-	vol_layout->num_clusters = vdh->num_clusters;
-	vol_layout->file_node_size = vdh->file_node_size;
-	vol_layout->node_cfg_off = vdh->node_cfg_off;
-	vol_layout->node_cfg_size = vdh->node_cfg_size;
-	vol_layout->new_cfg_off = vdh->new_cfg_off;
-	vol_layout->prot_bits = vdh->prot_bits;
+	/* not using any of these sb fields yet */
+#if 0
+di->i_ctime = cpu_to_le64(format_time); // use this as s_wtime (write time)
+di->i_mtime = cpu_to_le64(format_time); // use this as s_mtime (mount time)
+di->i_blkno = cpu_to_le64(super_off >> blocksize_bits);
+di->id2.i_super.s_mnt_count = 0;
+di->id2.i_super.s_max_mnt_count = cpu_to_le16(OCFS2_DFL_MAX_MNT_COUNT);
+di->id2.i_super.s_state = 0;
+di->id2.i_super.s_errors = 0;
+di->id2.i_super.s_lastcheck = cpu_to_le64(format_time);
+di->id2.i_super.s_checkinterval = cpu_to_le32(OCFS2_DFL_CHECKINTERVAL);
+di->id2.i_super.s_creator_os = cpu_to_le32(OCFS2_OS_LINUX);
+#endif	
 
-	memcpy (vol_layout->vol_id, vol_label->vol_id, MAX_VOL_ID_LENGTH);
+	di = OCFS_BH_GET_DATA_READ(bh);
+	strncpy(osb->vol_label, di->id2.i_super.s_label, 63);
+	osb->vol_label[63] = '\0';
+	memcpy(osb->uuid, di->id2.i_super.s_uuid, MAX_VOL_ID_LENGTH);
+	osb->root_blkno = le64_to_cpu(di->id2.i_super.s_root_blkno);
+	osb->system_dir_blkno = le64_to_cpu(di->id2.i_super.s_system_dir_blkno);
+	OCFS_BH_PUT_DATA(bh);
 
-	if (vol_layout->file_node_size == 0) 
-		vol_layout->file_node_size = OCFS_DEFAULT_FILE_NODE_SIZE;
+	/* load root, system_dir, and all global and node-local system inodes */
+	status = ocfs_init_system_inodes(osb);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
 
-	osb->inode_size = OCFS_DEFAULT_INODE_SIZE;
+	/*
+	 * autoconfig
+	 */	
+	inode = ocfs_get_system_file_inode(osb, AUTOCONFIG_SYSTEM_INODE, -1);
+	if (!inode) {
+		LOG_ERROR_STATUS(status = -EINVAL);
+		goto bail;
+	}
+	status = ocfs_lookup_file_allocation (osb, 0ULL, &ret, 1, NULL, inode);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
+	osb->autoconfig_blkno = ret >> osb->sb->s_blocksize_bits;
+	osb->autoconfig_blocks = inode->i_size >> osb->sb->s_blocksize_bits;
+	printk("autoconfig: blkno=%llu, blocks=%llu\n", osb->autoconfig_blkno, osb->autoconfig_blocks);
+	if (osb->autoconfig_blocks != 2+osb->max_nodes+4) {
+		LOG_ERROR_ARGS("autoconfig size incorrect: "
+			       "found=%llu, expected=%u\n",
+			       osb->autoconfig_blocks,
+			       2+osb->max_nodes+4);
+		status = -EINVAL;
+		goto bail;
+	}
+	// "new" autoconfig steals 4 blocks from autoconfig_blocks
+	// TODO: this is just so dumb, do something about it
+	osb->autoconfig_blocks -= OCFS_VOLCFG_NEWCFG_SECTORS;
+	osb->new_autoconfig_blocks = OCFS_VOLCFG_NEWCFG_SECTORS;
+	osb->new_autoconfig_blkno = osb->autoconfig_blkno + osb->autoconfig_blocks;
+	osb->total_autoconfig_blocks = OCFS_VOLCFG_NEWCFG_SECTORS + osb->max_nodes;
+	osb->autoconfig_bhs = ocfs_malloc (osb->total_autoconfig_blocks
+				    * sizeof(struct buffer_head *));
+	if (!osb->autoconfig_bhs) {
+		LOG_ERROR_STATUS (status = -ENOMEM);
+		goto bail;
+	}
+	memset(osb->autoconfig_bhs, 0, 
+	       osb->total_autoconfig_blocks * sizeof(struct buffer_head *));
 
-	/* get some pseudo constants for >> bits */
-	osb->sect_size_bits = ocfs_get_right_shift_bits(sect_size);
-	osb->s_clustersize = vol_layout->cluster_size;
-	osb->s_clustersize_bits = ocfs_get_right_shift_bits(vol_layout->cluster_size);
-	osb->file_alloc_bits = ocfs_get_right_shift_bits(vol_layout->file_node_size);
-	osb->inode_alloc_bits = ocfs_get_right_shift_bits(osb->inode_size);
-	printk("sectbits=%d, clusterbits=%d, filebits=%d, inodebits=%d\n",
-	       osb->sect_size_bits, osb->s_clustersize_bits, 
-	       osb->file_alloc_bits, osb->inode_alloc_bits);
 	
-	OCFS_ASSERT(osb->sect_size_bits);
-	OCFS_ASSERT(osb->s_clustersize_bits);
-	OCFS_ASSERT(osb->file_alloc_bits);
-	OCFS_ASSERT(osb->inode_alloc_bits);
+	/*
+	 * publish
+	 */	
+	inode = ocfs_get_system_file_inode(osb, PUBLISH_SYSTEM_INODE, -1);
+	if (!inode) {
+		LOG_ERROR_STATUS(status = -EINVAL);
+		goto bail;
+	}
+	status = ocfs_lookup_file_allocation (osb, 0ULL, &ret, 1, NULL, inode);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
+	osb->publish_blkno = ret >> osb->sb->s_blocksize_bits;
+	osb->publish_blocks = inode->i_size >> osb->sb->s_blocksize_bits;
+	printk("publish: blkno=%llu, blocks=%llu\n", osb->publish_blkno, osb->publish_blocks);
 
+	/* we still require our autoconfig and publish to be contiguous */
+	if (osb->publish_blkno != osb->autoconfig_blkno + osb->autoconfig_blocks) {
+		LOG_ERROR_ARGS("autoconfig is NOT contiguous with publish! "
+			       "autoconfig: blkno=%llu, blocks=%llu, "
+			       "publish: blkno=%llu, blocks=%llu\n", 
+			       osb->autoconfig_blkno, osb->autoconfig_blocks,
+			       osb->publish_blkno, osb->publish_blocks);
+		status = -EINVAL;
+		goto bail;
+	}
+	iput(inode);
 
-	bitmap_bits = (__u32) vol_layout->num_clusters;
+	/*
+	 * vote
+	 */	
+	inode = ocfs_get_system_file_inode(osb, VOTE_SYSTEM_INODE, -1);
+	if (!inode) {
+		LOG_ERROR_STATUS(status = -EINVAL);
+		goto bail;
+	}
+	status = ocfs_lookup_file_allocation (osb, 0ULL, &ret, 1, NULL, inode);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
+	osb->vote_blkno = ret >> osb->sb->s_blocksize_bits;
+	osb->vote_blocks = inode->i_size >> osb->sb->s_blocksize_bits;
+	printk("vote: blkno=%llu, blocks=%llu\n", osb->vote_blkno, osb->vote_blocks);
+	iput(inode);
 
-	ocfs_initialize_bitmap (&osb->cluster_bitmap, bitmap_bits, ONE_MEGA_BYTE * 8);
+	
+	/* 
+	 * global bitmap 
+	 */	
+	inode = ocfs_get_system_file_inode(osb, GLOBAL_BITMAP_SYSTEM_INODE, -1);
+	if (!inode) {
+		LOG_ERROR_STATUS(status = -EINVAL);
+		goto bail;
+	}
+	status = ocfs_lookup_file_allocation (osb, 0ULL, &ret, 1, NULL, inode);
+	if (status < 0) {
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
+	/* for now, just one extent... but in the future... */
+	osb->bitmap_blkno = ret >> osb->sb->s_blocksize_bits;
+	osb->bitmap_blocks = OCFS_I(inode)->alloc_size >> osb->sb->s_blocksize_bits;
+	osb->num_clusters = OCFS_I(inode)->u.ip_bitinfo.total_bits;
+	
+	ocfs_initialize_bitmap (&osb->cluster_bitmap, osb->num_clusters, OCFS_I(inode)->alloc_size << 3);
 	/* read the whole cluster bitmap off disk, even though we only
 	 * need the beginning of it. */
-	status = ocfs_read_bhs(osb, vol_layout->bitmap_off, ONE_MEGA_BYTE, osb->cluster_bitmap.chunk, 0, NULL);
+	status = ocfs_read_bhs(osb, ret, OCFS_I(inode)->alloc_size, 
+			       osb->cluster_bitmap.chunk, 0, inode);
 	if (status < 0) {
 		LOG_ERROR_STATUS (status);
 		goto bail;
 	}
+	iput(inode);
 
+	/* get some pseudo constants for >> bits */
+	osb->s_clustersize_bits = le32_to_cpu(di->id2.i_super.s_clustersize_bits);
+	osb->s_clustersize = 1 << osb->s_clustersize_bits;
+	printk("clusterbits=%d\n", osb->s_clustersize_bits);
+	OCFS_ASSERT(osb->s_clustersize_bits);
+
 	osb->prealloc_lock = 0;
 
-	osb->cfg_numblocks = osb->max_nodes + OCFS_VOLCFG_NEWCFG_SECTORS;
-	osb->cfg_len = osb->cfg_numblocks * osb->sect_size;
-	osb->cfg_bhs = ocfs_malloc (osb->cfg_numblocks
-				    * sizeof(struct buffer_head *));
-	if (!osb->cfg_bhs) {
-		LOG_ERROR_STATUS (status = -ENOMEM);
-		goto bail;
-	}
-	memset(osb->cfg_bhs, 0, 
-	       osb->cfg_numblocks * sizeof(struct buffer_head *));
 
 	status = ocfs_get_config (osb);
 	if (status < 0) {
@@ -1485,7 +1635,7 @@
 	}
 
 	/* Read the Publish Sector of local Node */
-	offset = vol_layout->publ_sect_off + (osb->node_num * osb->sect_size);
+	offset = (osb->publish_blkno + osb->node_num) << osb->sb->s_blocksize_bits;
 	status = ocfs_read_bh(osb, offset, &publish_bh, 0, NULL);
 	if (status < 0) {
 		LOG_ERROR_STATUS (status);
@@ -1513,9 +1663,9 @@
 	brelse(publish_bh);
 
 	/*  Read disk for all Publish Sectors  */
-	length = osb->max_nodes * osb->sect_size;
-	status = ocfs_read_bhs(osb, vol_layout->publ_sect_off, length, 
-			       publish_bhs, 0, NULL);
+	length = osb->max_nodes << osb->sb->s_blocksize_bits;
+	offset = osb->publish_blkno << osb->sb->s_blocksize_bits;
+	status = ocfs_read_bhs(osb, offset, length, publish_bhs, 0, NULL);
 	if (status < 0) {
 		LOG_ERROR_STATUS (status);
 		goto finally;
@@ -1555,8 +1705,8 @@
 	goto finally;
 
 bail:
-	if (osb->cfg_bhs)
-		kfree(osb->cfg_bhs);
+	if (osb->autoconfig_bhs)
+		kfree(osb->autoconfig_bhs);
 	if (osb->vol_node_map)
 		kfree(osb->vol_node_map);
 	if (osb->lock_recovery_lists)
@@ -1586,53 +1736,59 @@
 
 /*
  * ocfs_verify_volume()
- *
+ * will return: -EAGAIN if it is ok to keep searching for superblocks
+ *              -EINVAL if there is a bad superblock
+ *              0 on success
  */
-static int ocfs_verify_volume(ocfs_vol_disk_hdr *vdh)
+static int ocfs_verify_volume(ocfs2_dinode *di, struct buffer_head *bh,
+			      __u32 sectsize)
 {
-	int status = 0;
+	int status = -EAGAIN;
 
 	LOG_ENTRY ();
 
-	if (vdh == NULL) {
-		LOG_ERROR_STATUS (status = -EFAIL);
-		goto bail;
-	}
-
-	/*  Compare the Signature with the one we read from disk  */
-	if (memcmp (vdh->signature, OCFS_VOLUME_SIGNATURE,
-		    strlen (OCFS_VOLUME_SIGNATURE)) != 0) {
-		LOG_ERROR_STR ("Invalid volume signature");
+	if (memcmp(di->i_signature, OCFS2_SUPER_BLOCK_SIGNATURE,
+		   strlen(OCFS2_SUPER_BLOCK_SIGNATURE)) == 0) {
 		status = -EINVAL;
-		goto bail;
+		if ((1 << le32_to_cpu(di->id2.i_super.s_blocksize_bits)) != sectsize) {
+			LOG_ERROR_ARGS("found superblock with incorrect sectorsize: "
+			       "found %u, should be %u\n", 
+			       1 << le32_to_cpu(di->id2.i_super.s_blocksize_bits),
+			       sectsize);
+		} else if (le16_to_cpu(di->id2.i_super.s_major_rev_level) !=
+			   OCFS2_MAJOR_REV_LEVEL ||
+			   le16_to_cpu(di->id2.i_super.s_minor_rev_level) !=
+			   OCFS2_MINOR_REV_LEVEL) {
+#warning dont know what is appropriate on minor rev difference and also need to check compat flags
+			LOG_ERROR_ARGS("found superblock with bad version: "
+				       "found %u.%u, should be %u.%u\n",
+				       le16_to_cpu(di->id2.i_super.s_major_rev_level),
+				       le16_to_cpu(di->id2.i_super.s_minor_rev_level),
+				       OCFS2_MAJOR_REV_LEVEL,
+				       OCFS2_MINOR_REV_LEVEL);
+		} else if (bh->b_blocknr != le64_to_cpu(di->i_blkno)) {
+			LOG_ERROR_ARGS("bad block number on superblock: "
+				       "found %llu, should be %lu\n",
+				       le64_to_cpu(di->i_blkno), bh->b_blocknr);
+		} else if (le32_to_cpu(di->id2.i_super.s_clustersize_bits) < 12 ||
+			    le32_to_cpu(di->id2.i_super.s_clustersize_bits) > 20) {
+			LOG_ERROR_ARGS("bad cluster size found: %u\n",
+			       1 << le32_to_cpu(di->id2.i_super.s_clustersize_bits));
+		} else if (!le64_to_cpu(di->id2.i_super.s_root_blkno)) {
+			LOG_ERROR_STR("bad root_blkno: 0");
+		} else if (!le64_to_cpu(di->id2.i_super.s_system_dir_blkno)) {
+			LOG_ERROR_STR("bad system_dir_blkno: 0");
+		} else if (le32_to_cpu(di->id2.i_super.s_max_nodes) > OCFS2_MAX_NODES) {
+			LOG_ERROR_ARGS("max_nodes found greater than maximum: "
+				       "found %u, max %u\n",
+				       le32_to_cpu(di->id2.i_super.s_max_nodes),
+				       OCFS2_MAX_NODES);
+		} else {
+			/* found it! */
+			status = 0;
+		}
 	}
 
-	/*  Check the Volume Length and the ClusterSize.  */
-	if (vdh->device_size == 0) {
-		LOG_ERROR_STR ("Device size cannot be zero");
-		status = -EINVAL;
-		goto bail;
-	}
-
-	if (vdh->cluster_size == 0) {
-		LOG_ERROR_STR ("Cluster size cannot be zero");
-		status = -EINVAL;
-		goto bail;
-	}
-
-	if (vdh->major_version != OCFS_MAJOR_VERSION) {
-		LOG_ERROR_ARGS ("Version number not compatible: %u.%u",
-				vdh->major_version, vdh->minor_version);
-		status = -EINVAL;
-		goto bail;
-	}
-
-	if (vdh->root_off == 0) {
-		LOG_ERROR_STR("No OCFS version 2 root directory found");
-		status = -EINVAL;
-		goto bail;
-	}
-bail:
 	LOG_EXIT_STATUS (status);
 	return status;
 }				/* ocfs_verify_volume */
@@ -1653,8 +1809,7 @@
 	LOG_ENTRY ();
 
 	/* Read the node's publish sector */
-	offset = osb->vol_layout.publ_sect_off + 
-		(osb->node_num * osb->sect_size);
+	offset = (osb->publish_blkno + osb->node_num) << osb->sb->s_blocksize_bits;
 	status = ocfs_read_bh(osb, offset, &publish_bh, 0, NULL);
 	if (status < 0) {
 		LOG_ERROR_STATUS (status);
@@ -1748,12 +1903,12 @@
 	for (i=0; i<osb->max_nodes; i++)
 		ocfs_recover_oin_locks(osb, i);
 
-	for(i = 0; i < osb->cfg_numblocks; i++)
-		if (osb->cfg_bhs[i])
-			brelse(osb->cfg_bhs[i]);
+	for(i = 0; i < osb->total_autoconfig_blocks; i++)
+		if (osb->autoconfig_bhs[i])
+			brelse(osb->autoconfig_bhs[i]);
 
-	if (osb->cfg_bhs)
-		kfree(osb->cfg_bhs);
+	if (osb->autoconfig_bhs)
+		kfree(osb->autoconfig_bhs);
 	if (osb->vol_node_map)
 		kfree(osb->vol_node_map);
 	if (osb->lock_recovery_lists)

Modified: branches/format-changes/src/sysfile.c
===================================================================
--- branches/format-changes/src/sysfile.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/sysfile.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -30,8 +30,6 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/highmem.h>
-#warning dont vmalloc
-#include <linux/vmalloc.h>
 
 #include "ocfs_log.h"
 #include "ocfs.h"
@@ -49,10 +47,8 @@
 /* Tracing */
 #define OCFS_DEBUG_CONTEXT    OCFS_DEBUG_CONTEXT_SYSFILE
 
-static int ocfs_find_extents_of_system_file (ocfs_super * osb, __u64 file_off, __u64 Length, ocfs2_dinode * fe, void **Buffer, __u32 * NumEntries);
+static struct inode * _ocfs_get_system_file_inode(ocfs_super *osb, int type, __u32 node);
 
-static struct inode * _ocfs_get_system_file_inode(ocfs_super *osb, int file_type, __u32 node);
-
 char *system_file_names[] = {
 	"global_bitmap",
 	"global_inode_alloc",
@@ -65,39 +61,63 @@
 	"extent_alloc_bitmap:%04d",
 	"inode_alloc:%04d",
 	"inode_alloc_bitmap:%04d",
-	"journal:%04d"
+	"journal:%04d",
+	"local_alloc:%04d"
 };
 
-struct inode * ocfs_get_system_file_inode(ocfs_super *osb, int file_type, __u32 node)
+static inline int is_global_system_inode(int type);
+static inline int is_in_system_inode_array(ocfs_super *osb, int type, __u32 node);
+
+static inline int is_global_system_inode(int type)
 {
-	struct inode *inode;
+	return (type >= GLOBAL_BITMAP_SYSTEM_INODE &&
+		type <= ORPHAN_DIR_SYSTEM_INODE);
+}
 
+static inline int is_in_system_inode_array(ocfs_super *osb, int type, __u32 node)
+{
+	return (node == osb->node_num || is_global_system_inode(type));
+}
+
+struct inode * ocfs_get_system_file_inode(ocfs_super *osb, int type, __u32 node)
+{
+	struct inode *inode = NULL;
+	struct inode **arr = NULL;
+
 	// avoid the lookup if cached in local system file array
-	if ((node == osb->node_num ||
-	    file_type == GLOBAL_BITMAP_SYSTEM_INODE) && 
-	    (inode = osb->system_inodes[file_type]) != NULL) {
+	if (is_in_system_inode_array(osb, type, node))
+		arr = &(osb->system_inodes[type]);
+
+	if ((inode = *arr) != NULL) {
 		// get a ref in addition to the array ref
 		igrab(inode);
 		return inode;
 	}
-	return _ocfs_get_system_file_inode(osb, file_type, node);
+	
+	// this gets one ref thru iget
+	inode = _ocfs_get_system_file_inode(osb, type, node);
+
+	// add one more if putting into array for first time
+	if (arr)
+		*arr = igrab(inode);
+	return inode;
 }
 
-static struct inode * _ocfs_get_system_file_inode(ocfs_super *osb, int file_type, __u32 node)
+static struct inode * _ocfs_get_system_file_inode(ocfs_super *osb, int type, __u32 node)
 {
 	char namebuf[40];
 	struct inode *inode = NULL;
 	__u64 fe_off = 0;
 	struct buffer_head *dirent_bh = NULL;
-	struct ocfs2_dir_entry *de;
-	int status;
+	struct ocfs2_dir_entry *de = NULL;
+	int status = 0;
 
-	if (file_type == GLOBAL_BITMAP_SYSTEM_INODE)
+	if (type <= ORPHAN_DIR_SYSTEM_INODE)
 		/* "There Can Be Only One!" */
-		sprintf(namebuf, system_file_names[file_type]);
+		sprintf(namebuf, system_file_names[type]);
 	else
-		sprintf(namebuf, system_file_names[file_type], node);
-
+		sprintf(namebuf, system_file_names[type], node);
+	
 	status = ocfs_find_files_on_disk(osb, namebuf, strlen(namebuf),
 					 &fe_off, osb->sys_root_inode, 
 					 1, &dirent_bh, &de);
@@ -125,574 +145,58 @@
  * after you're done with them!
  *
  */
-int ocfs_read_system_file (ocfs_super * osb, __u32 FileId, struct buffer_head *bhs[], __u64 Length, __u64 Offset)
+int ocfs_read_system_file (ocfs_super * osb, int type, __u32 node, struct buffer_head *bhs[], __u64 Length)
 {
-	int status;
-	ocfs2_dinode *fe = NULL;
-	void *extentBuffer = NULL;
-	__u32 numExts = 0, i, j, numblocks;
-	ocfs_io_runs *IoRuns;
-	__u64 tmplen, tmpoff;
-	struct buffer_head * fe_bh = NULL;
+	int status = 0, i;
+	__u64 ret = 0;
+	struct inode *inode = NULL;
+	__u32 blocks, contig_blocks;
+	__u64 off;
 
-	LOG_ENTRY_ARGS ("(FileId = %u, offset = (%llu), "
-			"Length = (%llu))\n", FileId, Offset, Length);
+	LOG_ENTRY_ARGS ("type=%d, node=%u, Length = %llu\n", type, node, Length);
 
-	status = ocfs_read_bh(osb, (FileId * osb->sect_size) + 
-			      osb->vol_layout.root_int_off, &fe_bh, OCFS_BH_CACHED, NULL);
-	if (status < 0) {
-		LOG_ERROR_STATUS (status);
+	inode = ocfs_get_system_file_inode(osb, type, node);
+	if (!inode) {
+		LOG_ERROR_STATUS(status=-EINVAL);
 		goto leave;
 	}
-
-	fe = OCFS_BH_GET_DATA_READ(fe_bh);
-
-	if (!IS_VALID_FILE_ENTRY (fe)) {
-		LOG_ERROR_STATUS(status = -EINVAL);
-		goto leave;
-	}
-
-	status = ocfs_find_extents_of_system_file (osb, Offset, Length,
-					  fe, &extentBuffer, &numExts);
-	if (status < 0) {
-		LOG_ERROR_STATUS (status);
-		goto leave;
-	}
-
-	OCFS_ASSERT (extentBuffer);
-
-	if (numExts < 1) {
-		LOG_ERROR_ARGS("numExts < 1  (= %d)\n", numExts);
-		goto leave;
-	}
-	IoRuns = extentBuffer;
-	tmpoff = 0;
-	tmplen = 0;
-	j = 0;
-	numblocks = 0;
-
-	for (i = 0; i < numExts; i++) {
-		//tempBuffer += tmplen;
-		/*  ?? need to align both the length and buffer and also */
-		/* offset ( atleast the starting one) */
-		tmpoff = IoRuns[i].disk_off;
-		tmplen = IoRuns[i].byte_cnt;
-
-		status = ocfs_read_bhs(osb, tmpoff, tmplen, &(bhs[j]), OCFS_BH_CACHED, NULL);
-		if (status < 0) {
-			LOG_ERROR_STATUS (status);
+	
+	off = 0;
+	i = 0;
+	blocks = Length >> osb->sb->s_blocksize_bits;
+	while (blocks > 0) {
+		contig_blocks = 0;
+		status = ocfs_lookup_file_allocation (osb, off, &ret, blocks, 
+						      &contig_blocks, inode);
+		if (status == 0) {
+			// found all remaining
+			OCFS_ASSERT(blocks == contig_blocks);
+		} else if (status == -EFAIL && contig_blocks > 0) {
+			// found some
+			OCFS_ASSERT(contig_blocks < blocks);
+		} else {
+			// failed
+			LOG_ERROR_STATUS(status = -EIO);
 			goto leave;
 		}
 
-		numblocks = tmplen >> osb->sect_size_bits;
-
-		j += numblocks;
-	}
-
-leave:
-	if (fe) {
-		OCFS_BH_PUT_DATA(fe_bh);
-		brelse(fe_bh);
-	}
-
-	if (extentBuffer)
-		vfree(extentBuffer);
-
-	LOG_EXIT_STATUS (status);
-	return status;
-}				/* ocfs_read_system_file */
-
-/*
- * ocfs_file_to_disk_off()
- *
- */
-__u64 ocfs_file_to_disk_off (ocfs_super * osb, __u32 FileId, __u64 Offset)
-{
-	int status;
-	__u64 StartOffset = 0;
-	void *Buffer = NULL;
-	ocfs2_dinode *fe = NULL;
-	ocfs_io_runs *IoRuns;
-	__u32 NumExts = 0;
-	struct buffer_head *fe_bh = NULL;
-
-	LOG_ENTRY_ARGS ("(FileId = %u)\n", FileId);
-
-	/*  Read the File Entry corresponding to File Id */
-	status = ocfs_read_bh (osb, (FileId * osb->sect_size) +
-			       osb->vol_layout.root_int_off, &fe_bh, OCFS_BH_CACHED, NULL);
-	if (status < 0) {
-		LOG_ERROR_STATUS (status);
-		goto leave;
-	}
-
-	fe = OCFS_BH_GET_DATA_READ(fe_bh);
-
-	if (!IS_VALID_FILE_ENTRY (fe)) {
-		LOG_ERROR_STATUS(status = -EINVAL);
-		goto leave;
-	}
-
-	status = ocfs_find_extents_of_system_file (osb, Offset, osb->sect_size,
-					  fe, &Buffer, &NumExts);
-	if (status < 0) {
-		LOG_ERROR_STATUS (status);
-		goto leave;
-	}
-
-	OCFS_ASSERT (Buffer);
-
-	IoRuns = Buffer;
-	/*  Return the disk offset of first run . */
-	StartOffset = (IoRuns[0].disk_off);
-
-leave:
-	if (fe_bh) {
-		OCFS_BH_PUT_DATA(fe_bh);
-		brelse(fe_bh);
-	}
-
-	if (Buffer)
-		vfree(Buffer);
-
-	LOG_EXIT_ARGS ("%llu", StartOffset);
-	return StartOffset;
-}				/* ocfs_file_to_disk_off */
-
-
-/*
- * ocfs_get_system_file_size()
- *
- */
-int ocfs_get_system_file_size (ocfs_super * osb, __u32 FileId, __u64 * Length, __u64 * AllocSize)
-{
-	int status;
-	ocfs2_dinode *fe = NULL;
-	__u64 offset;
-	struct buffer_head *fe_bh = NULL;
-
-	LOG_ENTRY_ARGS ("(FileId = %u)\n", FileId);
-
-	*AllocSize = *Length = 0;
-
-	offset = (FileId * osb->sect_size) + osb->vol_layout.root_int_off;
-
-	status = ocfs_read_bh (osb, offset, &fe_bh, 0, NULL);
-	if (status < 0) {
-		LOG_ERROR_STATUS (status);
-		goto leave;
-	}
-
-	fe = OCFS_BH_GET_DATA_READ(fe_bh);
-
-	if (!IS_VALID_FILE_ENTRY (fe)) {
-		LOG_ERROR_ARGS("offset=%llu", offset);
-		status = -EINVAL;
-		goto leave;
-	}
-
-	*Length = fe->i_size;
-	*AllocSize = (u64)fe->i_clusters << osb->s_clustersize_bits;
-
-leave:
-	if (fe) {
-		OCFS_BH_PUT_DATA(fe_bh);
-		brelse(fe_bh);
-	}
-
-	LOG_EXIT_STATUS (status);
-	return status;
-}				/* ocfs_get_system_file_size */
-
-#ifdef __KERNEL__
-/*
- * ocfs_extend_system_file()
- * 
- * fe_bh can be null and we'll just read it off disk.
- * of course, if you've already read it off disk, then give us fe_bh to avoid
- * an extra read. We always do the write out of the new fe.
- *
- * You need to be holding node_alloc_sem!
- */
-int ocfs_extend_system_file (ocfs_super * osb, __u32 FileId, __u64 FileSize, struct buffer_head *fe_bh, ocfs_journal_handle *handle, int zero)
-{
-	int status = 0;
-	__u64 actualDiskOffset = 0, actualLength = 0;
-	int local_fe = 0;
-	ocfs2_dinode *fe = NULL;
-	__u64 alloc_size;
-	int numbhs, i;
-	char *data;
-	struct buffer_head **bhs;
-	struct inode *ext_alloc_inode = NULL;
-
-	LOG_ENTRY_ARGS ("(FileId = %u, Size = %llu)\n", FileId, FileSize);
-
-	OCFS_ASSERT (osb);
-
-	if (!fe_bh) {
-		local_fe = 1;
-		status = ocfs_read_bh(osb, (FileId * osb->sect_size) + osb->vol_layout.root_int_off, &fe_bh, OCFS_BH_COND_CACHED, NULL);
+		status = ocfs_read_bhs(osb, ret, 
+				       contig_blocks << osb->sb->s_blocksize_bits, 
+				       &(bhs[i]), 
+				       OCFS_BH_CACHED, inode);
 		if (status < 0) {
 			LOG_ERROR_STATUS (status);
 			goto leave;
 		}
+		i += contig_blocks;
+		blocks -= contig_blocks;
+		off += (contig_blocks << osb->sb->s_blocksize_bits);
 	}
-	fe = OCFS_BH_GET_DATA_READ(fe_bh);
 
-	if (!IS_VALID_FILE_ENTRY (fe)) {
-		OCFS_BH_PUT_DATA(fe_bh);
-		LOG_ERROR_STATUS (status = -EINVAL);
-		goto leave;
-	}
-	alloc_size = (u64)fe->i_clusters << osb->s_clustersize_bits;
-	OCFS_BH_PUT_DATA(fe_bh);
-	fe = NULL;
-
-	status = ocfs_journal_access(handle, fe_bh, 
-				     OCFS_JOURNAL_ACCESS_WRITE);
-	if (status < 0) {
-		LOG_ERROR_STATUS (status);
-		goto leave;
-	}
-
-	if (FileSize > alloc_size) {
-		/*  We need to allocate from bitmap */
-		__u64 numClusterAlloc = 0, BitmapOffset = 0;
-
-		status =
-			ocfs_find_contiguous_space_from_bitmap (osb, handle,
-						   FileSize - alloc_size,
-						   &BitmapOffset,
-						   &numClusterAlloc, 1, 
-						   NULL, NULL);
-		if (status < 0) {
-			LOG_ERROR_STATUS (status);
-			goto leave;
-		}
-
-		actualDiskOffset =
-		    (BitmapOffset * osb->vol_layout.cluster_size) +
-		    osb->vol_layout.data_start_off;
-		actualLength = numClusterAlloc * osb->vol_layout.cluster_size;
-
-		ext_alloc_inode = igrab(osb->system_inodes[EXTENT_ALLOC_BITMAP_SYSTEM_INODE]);
-		if (!ext_alloc_inode) {
-			status = -EFAIL;
-			LOG_ERROR_STATUS(status);
-			goto leave;
-		}
-
-		ocfs_handle_add_inode(handle, ext_alloc_inode);
-		status = ocfs_allocate_extent(osb, fe_bh, handle,  
-					      actualDiskOffset >> osb->sb->s_blocksize_bits,
-					      actualLength >> osb->s_clustersize_bits,
-					      NULL);
-		if (status < 0) {
-			LOG_ERROR_STATUS (status);
-			goto leave;
-		}
-		
-		if (zero) {
-			/* I think at this point, this can be journalled too */
-			numbhs = (int)(actualLength >> osb->sb->s_blocksize_bits);
-
-			bhs = ocfs_malloc(numbhs * sizeof(struct buffer_head *));
-			if (!bhs) {
-				status = -ENOMEM;
-				LOG_ERROR_STATUS(status);
-				goto leave;
-			}
-			memset(bhs, 0, numbhs * sizeof(struct buffer_head *));
-
-			status = ocfs_read_bhs(osb, actualDiskOffset, 
-					       actualLength, bhs, 0, NULL);
-			if (status < 0) {
-				kfree(bhs);
-				LOG_ERROR_STATUS(status);
-				goto leave;
-			}
-
-			for(i = 0; i < numbhs; i++) {
-				data = OCFS_BH_GET_DATA_WRITE(bhs[i]);
-				memset(data, 0, osb->sect_size);
-				OCFS_BH_PUT_DATA(bhs[i]);
-			}
-
-			status = ocfs_write_bhs(osb, bhs, numbhs, 0, NULL);
-			for(i = 0; i < numbhs; i++)
-				brelse(bhs[i]);
-			kfree(bhs);
-			if (status < 0) {
-				LOG_ERROR_STATUS(status);
-				goto leave;
-			}
-		}
-
-		atomic_inc (&osb->alloc_stats.bitmap_meta);
-	} else
-		actualLength = 0;
-		
-	fe = OCFS_BH_GET_DATA_WRITE(fe_bh);
-	fe->i_clusters +=
-		(u32)(actualLength >> osb->s_clustersize_bits);
-	fe->i_size = FileSize;
-
-	DISK_LOCK(fe)->dl_master = osb->node_num;
-	DISK_LOCK(fe)->dl_level = OCFS_DLM_ENABLE_CACHE_LOCK;
-
-	OCFS_BH_PUT_DATA(fe_bh);
-	fe = NULL;
-
-	status = ocfs_journal_dirty(handle, fe_bh);
-	if (status < 0)
-		LOG_ERROR_STATUS (status);
-
 leave:
-	if (fe)
-		OCFS_BH_PUT_DATA(fe_bh);
-	if (local_fe)
-		brelse(fe_bh);
-	if (ext_alloc_inode)
-		iput(ext_alloc_inode);
+	if (inode)
+		iput(inode);
 
 	LOG_EXIT_STATUS (status);
 	return status;
-}				/* ocfs_extend_system_file */
-
-#endif				/* __KERNEL__ */
-
-/*
- * ocfs_find_extents_of_system_file()
- *
- * Searches for the extents in the file entry passed starting from
- * file offset up to the length specified.
- */
-static int ocfs_find_extents_of_system_file (ocfs_super * osb, __u64 file_off, __u64 Length, ocfs2_dinode * fe, void **Buffer, __u32 * NumEntries)
-{
-	int status = -EFAIL;
-	__u32 size;
-	__u32 k = 0, j;
-	__u32 Runs, Runoffset;
-	struct buffer_head *extent_bh = NULL;
-	ocfs2_extent_block *extent = NULL;
-	ocfs2_extent_list *fel;
-	ocfs_io_runs *IoRuns;
-	__u64 newOffset = 0, searchVbo, remainingLength = 0;
-
-
-	LOG_ENTRY ();
-
-	OCFS_ASSERT (osb);
-
-	if (!IS_VALID_FILE_ENTRY (fe)) {
-		LOG_ERROR_STATUS (status = -EFAIL);
-		goto leave;
-	}
-
-	fel = &fe->id2.i_list;
-
-	if (fel->l_tree_depth < 0)
-       	{
-		size = fel->l_count * sizeof(ocfs_io_runs);
-	}
-	else
-	{
-		int pow = fel->l_tree_depth + 1;
-		/* extent tree looks like
-		*             fe[0]        fe[1]    fe[2]
-		*        hdr[0]...hdr[n]   .....
-		* leaf[0]..leaf[n]
-		*
-		* tree_depth of fe is tree height
-		* so max runs (total of all leaves) is
-		* 3 x h_records ^ (tree_depth+1)
-		*
-		* g=2: 419904 bytes!
-		*/
-		size = 3;
-		while (pow)
-		{
-			size *= ocfs2_extent_recs_per_eb(osb->sb);
-			pow--;
-		}
-		size *= sizeof (ocfs_io_runs);
-	}
-	size = OCFS_SECTOR_ALIGN (size);
-	IoRuns = vmalloc(size);
-
-	if (IoRuns == NULL) {
-		LOG_ERROR_STATUS (status = -ENOMEM);
-		goto leave;
-	}
-
-	memset (IoRuns, 0, size);
-
-	remainingLength = Length;
-	Runs = 1;
-	Runoffset = 0;
-	newOffset = file_off;
-
-	if (fel->l_tree_depth < 0) {
-		for (j = 0; j < fel->l_count; j++) {
-			if (((u64)(fel->l_recs[j].e_cpos + fel->l_recs[j].e_clusters) << osb->s_clustersize_bits) > newOffset) {
-				IoRuns[Runoffset].disk_off =
-				    (fel->l_recs[j].e_blkno << osb->sb->s_blocksize_bits) +
-				    (newOffset - ((u64)fel->l_recs[j].e_cpos << osb->s_clustersize_bits));
-				IoRuns[Runoffset].byte_cnt =
-				    (__u32)(((u64)(fel->l_recs[j].e_cpos + fel->l_recs[j].e_clusters) << osb->s_clustersize_bits) - newOffset);
-				if (IoRuns[Runoffset].byte_cnt >=
-				    remainingLength) {
-					IoRuns[Runoffset].byte_cnt =
-					    (__u32) remainingLength;
-					status = 0;
-					break;
-				} else {
-					newOffset += IoRuns[Runoffset].byte_cnt;
-					remainingLength -=
-					    IoRuns[Runoffset].byte_cnt;
-					Runs++;
-					Runoffset++;
-				}
-			}
-		}
-
-		*NumEntries = Runs;
-		*Buffer = IoRuns;
-		goto leave;
-	} else {
-		/* Extents are branched and we are no longer using Local 
-		 *  Extents for this File Entry. */
-
-		while (1) {
-			/* Keep going downwards looking for the Entry, till 
-			 * we hit the last Data entry */
-			for (k = 0; k < fel->l_count; k++) {
-				if ((__s64)((u64)(fel->l_recs[k].e_cpos + fel->l_recs[k].e_clusters) << osb->s_clustersize_bits) > newOffset) {
-					break;
-				}
-			}
-
-			if (k == fel->l_count) {
-				LOG_ERROR_STR ("data extents maxed");
-			}
-
-			if (fel->l_recs[k].e_blkno == 0) {
-				LOG_ERROR_STR ("e_blkno=0");
-			}
-
-			status = ocfs_read_bh(osb,
-					      fel->l_recs[k].e_blkno << osb->sb->s_blocksize_bits,
-					      &extent_bh,
-					      OCFS_BH_COND_CACHED,
-					      NULL);
-			if (status < 0) {
-				LOG_ERROR_STATUS (status);
-				goto leave;
-			}
-
-			extent = OCFS_BH_GET_DATA_READ(extent_bh);
-			while (extent->h_list.l_tree_depth >= 0) {
-				__u64 diskoffset;
-
-				if (!IS_VALID_EXTENT_BLOCK(extent)) {
-					LOG_ERROR_STATUS(status = -EFAIL);
-					goto leave;
-				}
-
-				k = ocfs_extent_for_offset(osb->sb,
-						     	   extent,
-							   newOffset);
-				if (k == extent->h_list.l_count) {
-					LOG_ERROR_STR ("data extents maxed");
-				}
-
-				if (extent->h_list.l_recs[k].e_blkno == 0) {
-					LOG_ERROR_STR ("e_blkno=0");
-				}
-
-				diskoffset = extent->h_list.l_recs[k].e_blkno << osb->sb->s_blocksize_bits;
-
-				OCFS_BH_PUT_DATA(extent_bh);
-				brelse(extent_bh);
-				extent = NULL; extent_bh = NULL;
-
-				status = ocfs_read_bh(osb, diskoffset,
-						      &extent_bh, 
-						      OCFS_BH_CACHED, NULL);
-				if (status < 0) {
-					LOG_ERROR_STATUS (status);
-					goto leave;
-				}
-				extent = OCFS_BH_GET_DATA_READ(extent_bh);
-			}
-
-			searchVbo = newOffset;
-
-			OCFS_ASSERT(extent->h_list.l_tree_depth == -1);
-
-			if (!IS_VALID_EXTENT_BLOCK(extent)) {
-				LOG_ERROR_STATUS(status = -EFAIL);
-				goto leave;
-			}
-
-			for (j = 0; j < extent->h_list.l_count; j++) {
-				if (((u64)(extent->h_list.l_recs[j].e_cpos + extent->h_list.l_recs[j].e_clusters) << osb->s_clustersize_bits) > newOffset) {
-					IoRuns[Runoffset].disk_off =
-						(extent->h_list.l_recs[j].e_blkno << osb->sb->s_blocksize_bits) +
-						(newOffset -
-						 ((u64)extent->h_list.l_recs[j].e_cpos << osb->s_clustersize_bits));
-					IoRuns[Runoffset].byte_cnt =
-						(__u32) (((u64)(extent->h_list.l_recs[j].e_cpos + extent->h_list.l_recs[j].e_clusters) << osb->s_clustersize_bits) - newOffset);
-					
-					if (IoRuns[Runoffset].
-					    byte_cnt >=
-					    remainingLength) {
-						IoRuns[Runoffset].
-							byte_cnt = (__u32)
-							remainingLength;
-						status = 0;
-						break;
-					} else {
-						newOffset +=
-							IoRuns[Runoffset].
-							byte_cnt;
-						remainingLength -=
-							IoRuns[Runoffset].
-							byte_cnt;
-						Runs++;
-						Runoffset++;
-						if (Runs >=
-						    extent->h_list.l_count)
-						{
-							LOG_ERROR_ARGS ("Runs=%d", Runs);
-						}
-					}
-				}
-			}
-			
-			if (j == extent->h_list.l_count) {
-				OCFS_BH_PUT_DATA(extent_bh);
-				brelse(extent_bh);
-				extent = NULL; extent_bh = NULL;
-				continue;
-			} else {
-				*NumEntries = Runs;
-				*Buffer = IoRuns;
-				goto leave;
-			}
-		} /* while (1) */
-	}
-
-leave:
-	/* Don't free the IoRuns Memory here */
-	if (extent_bh) {
-		if (extent)
-			OCFS_BH_PUT_DATA(extent_bh);
-		brelse(extent_bh);
-	}
-
-	LOG_EXIT_STATUS (status);
-	return status;
-}				/* ocfs_find_extents_of_system_file */
-
+}				/* ocfs_read_system_file */

Modified: branches/format-changes/src/sysfile.h
===================================================================
--- branches/format-changes/src/sysfile.h	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/sysfile.h	2004-06-12 21:05:20 UTC (rev 1069)
@@ -27,16 +27,8 @@
 #ifndef OCFS2_SYSFILE_H
 #define OCFS2_SYSFILE_H
 
-struct inode * ocfs_get_system_file_inode(ocfs_super *osb, int file_type, __u32 node);
-int ocfs_extend_system_file(ocfs_super *osb, __u32 FileId,
-			    __u64 FileSize, struct buffer_head *fe_bh,
-			    ocfs_journal_handle *handle,int zero);
-__u64 ocfs_file_to_disk_off(ocfs_super *osb, __u32 FileId,
-			    __u64 Offset);
-int ocfs_get_system_file_size(ocfs_super *osb, __u32 FileId,
-			      __u64 *Length, __u64 *AllocSize);
-int ocfs_read_system_file (ocfs_super *osb, __u32 FileId,
-			   struct buffer_head *bhs[], __u64 Length,
-			   __u64 Offset);
+struct inode * ocfs_get_system_file_inode(ocfs_super *osb, int type, __u32 node);
+int ocfs_read_system_file (ocfs_super *osb, int type, __u32 node,
+			   struct buffer_head *bhs[], __u64 Length);
 
 #endif /* OCFS2_SYSFILE_H */

Modified: branches/format-changes/src/volcfg.c
===================================================================
--- branches/format-changes/src/volcfg.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/volcfg.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -79,7 +79,7 @@
 	/* Obtain the volume for which we need to reiterate the lock */
 	osb = cfg_task->osb;
 	bh = cfg_task->bh;
-	length = osb->sect_size;
+	length = osb->sb->s_blocksize;
 	offset = cfg_task->lock_off;
 
 	/* Write the sector back */
@@ -143,7 +143,6 @@
 	ocfs_node_config_info *disk_node = NULL;
 	char *buf;
 	__u32 node_num;
-	__u32 sect_size;
 	__u32 size;
 	struct buffer_head **cfg_bhs = NULL;
 	int done = 0;
@@ -157,12 +156,9 @@
 	}
 	memset(cfg_bhs, 0, osb->max_nodes * sizeof(struct buffer_head *));
 
-	sect_size = osb->sect_size;
-
 	/* Read the nodecfg info for all nodes from disk */
-	size = OCFS_VOLCFG_HDR_SECTORS * sect_size;
-	offset = osb->vol_layout.node_cfg_off + size;
-	size = osb->vol_layout.node_cfg_size - size;
+	offset = (osb->autoconfig_blkno + OCFS_VOLCFG_HDR_SECTORS) << osb->sb->s_blocksize_bits;
+	size = (osb->autoconfig_blocks - OCFS_VOLCFG_HDR_SECTORS) << osb->sb->s_blocksize_bits;
 
 	status = ocfs_read_bhs(osb, offset, size, cfg_bhs, 0, NULL);
 	if (status < 0) {
@@ -201,7 +197,7 @@
 
 	/* Copy the new nodecfg into the memory buffer */
 	buf = OCFS_BH_GET_DATA_WRITE(cfg_bhs[node_num]);
-	memcpy (buf, new_disk_node, sect_size);
+	memcpy (buf, new_disk_node, osb->sb->s_blocksize);
 	OCFS_BH_PUT_DATA(cfg_bhs[node_num]);
 
 	/* Write the new node details on disk */
@@ -245,14 +241,14 @@
 
 	node_cfg_bhs[0] = node_cfg_bhs[1] = NULL;
 	/* Read the nodecfg header */
-	offset = osb->vol_layout.node_cfg_off;
+	offset = osb->autoconfig_blkno << osb->sb->s_blocksize_bits;
 	status = ocfs_read_bh(osb, offset, &node_cfg_bhs[0], 0, NULL);
 	if (status < 0) {
 		LOG_ERROR_STATUS (status);
 		goto bail;
 	}
 
-	offset = osb->vol_layout.new_cfg_off + osb->sect_size;
+	offset = (osb->new_autoconfig_blkno + 1) << osb->sb->s_blocksize_bits;
 	status = ocfs_read_bh(osb, offset, &node_cfg_bhs[1], 0, NULL);
 	if (status < 0) {
 		LOG_ERROR_STATUS (status);
@@ -268,7 +264,7 @@
 	/* Increment the seq# to trigger other nodes to re-read node cfg */
 	hdr->cfg_seq_num++;
 
-	memcpy(hdr_copy, hdr, osb->sect_size);
+	memcpy(hdr_copy, hdr, osb->sb->s_blocksize);
 	OCFS_BH_PUT_DATA(node_cfg_bhs[0]);
 	OCFS_BH_PUT_DATA(node_cfg_bhs[1]);
 	/* Write the nodecfg header */
@@ -323,15 +319,12 @@
 	int bh_locked = 0;
 	ocfs2_disk_lock *disk_lock;
 	ocfs_cfg_task *cfg_task;
-	__u32 sect_size;
 	__u64 lock_node_num = OCFS_INVALID_NODE_NUM;
 	struct buffer_head *bh = NULL;
 	int i;
 
 	LOG_ENTRY ();
 
-	sect_size = osb->sect_size;
-
 	cfg_task = ocfs_malloc (sizeof (ocfs_cfg_task));
 	if (cfg_task == NULL)
 	{
@@ -381,11 +374,11 @@
 				LOG_TRACE_STR ("Lock node config");
 
 			/* Attempt to lock volcfg */
-			memcpy(disk_lock, cfg_buf, osb->sect_size);
+			memcpy(disk_lock, cfg_buf, osb->sb->s_blocksize);
 
 			disk_lock->dl_master = osb->node_num;
 			disk_lock->dl_level = 1;
-			memcpy(cfg_buf, disk_lock, osb->sect_size);
+			memcpy(cfg_buf, disk_lock, osb->sb->s_blocksize);
 		
 			/* Write into volcfg lock sector... */
 			OCFS_BH_PUT_DATA(bh);
@@ -414,8 +407,8 @@
 		lock_buf = OCFS_BH_GET_DATA_WRITE(bh);
 
 		/* If we tried to acquire and we still own it we take it... */
-		if ((tried_acq) && (memcmp (lock_buf, cfg_buf, sect_size) == 0)) {
-			memcpy (lock_buf, cfg_buf, sect_size);
+		if ((tried_acq) && (memcmp (lock_buf, cfg_buf, osb->sb->s_blocksize) == 0)) {
+			memcpy (lock_buf, cfg_buf, osb->sb->s_blocksize);
 			OCFS_BH_PUT_DATA(bh);
 
 			/* Set timer to reiterate lock every few jiffies */
@@ -485,7 +478,6 @@
 {
 	int status = 0;
 	__s8 *buffer = NULL;
-	__u32 sect_size = osb->sect_size;
 	struct buffer_head *bh = NULL;
 	struct super_block *sb;
 	__u64 blocknum;
@@ -494,12 +486,6 @@
 
 	sb = osb->sb;
 
-	if (sect_size != sb->s_blocksize) {
-		LOG_ERROR_STR("sector_size != sb->s_blocksize!");
-		status = -999;
-		goto finally;
-	}
-
 	blocknum = lock_off >> sb->s_blocksize_bits;
 	bh = getblk(OCFS_GET_BLOCKDEV(sb), blocknum, sb->s_blocksize);
 	if (bh == NULL) {
@@ -510,7 +496,7 @@
 	buffer = OCFS_BH_GET_DATA_WRITE(bh);
 
 	/* reset lock... */
-	memset (buffer, 0, sect_size);
+	memset (buffer, 0, osb->sb->s_blocksize);
 	OCFS_BH_PUT_DATA(bh);
 
 	/* Release the lock */
@@ -529,7 +515,7 @@
 
 	buffer = OCFS_BH_GET_DATA_WRITE(bh);
 	/* reset lock... */
-	memset (buffer, 0, sect_size);
+	memset (buffer, 0, osb->sb->s_blocksize);
 	OCFS_BH_PUT_DATA(bh);
 
 	/* Release the lock */
@@ -556,16 +542,15 @@
 	ocfs_node_config_info *disk;
 	void *buffer;
 	__u64 offset;
-	__u32 sect_size = osb->sect_size;
 
 	LOG_ENTRY ();
 
-	buffer = ocfs_malloc (sect_size);
+	buffer = ocfs_malloc (osb->sb->s_blocksize);
 	if (buffer == NULL) {
 		LOG_ERROR_STATUS (status = -ENOMEM);
 		goto bail;
 	}
-	memset (buffer, 0, sect_size);
+	memset (buffer, 0, osb->sb->s_blocksize);
 
 	disk = buffer;
 
@@ -573,7 +558,7 @@
 	ocfs_volcfg_gblctxt_to_disknode (disk);
 
 	/* Write this nodes config onto disk */
-	offset = osb->vol_layout.new_cfg_off;
+	offset = (osb->new_autoconfig_blkno << osb->sb->s_blocksize_bits);
 	status = ocfs_config_with_disk_lock (osb, offset, (__u8 *) disk,
 					     OcfsGlobalCtxt.pref_node_num,
 					     OCFS_VOLCFG_ADD);
@@ -638,7 +623,6 @@
 static int ocfs_update_disk_config (ocfs_super * osb, __u32 node_num, ocfs_node_config_info * disk)
 {
 	int status = 0;
-	__u64 offset;
 	__u32 blocknum;
 	struct buffer_head *bh = NULL;
 	struct super_block *sb = NULL;
@@ -648,9 +632,7 @@
 
 	sb = osb->sb;
 	/* Write the node details */
-	offset = osb->vol_layout.node_cfg_off +
-		((node_num + OCFS_VOLCFG_HDR_SECTORS) * osb->sect_size);
-	blocknum = offset >> sb->s_blocksize_bits;
+	blocknum = osb->autoconfig_blkno + OCFS_VOLCFG_HDR_SECTORS + node_num;
 
 	bh = getblk(OCFS_GET_BLOCKDEV(sb), blocknum, sb->s_blocksize);
 	if (bh == NULL) {
@@ -660,7 +642,7 @@
 	}
 
 	buf = OCFS_BH_GET_DATA_WRITE(bh);
-	memcpy(buf, disk, osb->sect_size);
+	memcpy(buf, disk, osb->sb->s_blocksize);
 	OCFS_BH_PUT_DATA(bh);
 
 	status = ocfs_write_bh(osb, bh, 0, NULL);
@@ -763,8 +745,8 @@
 	LOG_ENTRY ();
 
 	/* Read in the config on the disk */
-	offset = osb->vol_layout.node_cfg_off;
-	numblocks = osb->vol_layout.node_cfg_size >> sb->s_blocksize_bits;
+	offset = osb->autoconfig_blkno << sb->s_blocksize_bits;
+	numblocks = osb->autoconfig_blocks;
 
 	cfg_bhs = ocfs_malloc(numblocks * sizeof(*cfg_bhs));
 	if (cfg_bhs == NULL) {
@@ -774,7 +756,8 @@
 	}
 	memset(cfg_bhs, 0, numblocks * sizeof(*cfg_bhs));
 
-	status = ocfs_read_bhs(osb, offset, osb->vol_layout.node_cfg_size, cfg_bhs, 0, NULL);
+	status = ocfs_read_bhs(osb, offset, numblocks << sb->s_blocksize_bits,
+			       cfg_bhs, 0, NULL);
 	if (status < 0) {
 		LOG_ERROR_STATUS (status);
 		goto finally;
@@ -808,7 +791,7 @@
 
 	/* Read the nodecfg for all possible nodes as there may be holes */
 	/* i.e., node numbers need not be dolled out in sequence */
-	for (i = 0; i < osb->max_nodes; i++) {//, p += sect_size) {
+	for (i = 0; i < osb->max_nodes; i++) {
 		int which;
 		which = i + OCFS_VOLCFG_HDR_SECTORS;
 		disk = OCFS_BH_GET_DATA_READ(cfg_bhs[which]);
@@ -990,13 +973,13 @@
 
 	LOG_ENTRY ();
 
-	buffer = ocfs_malloc (osb->sect_size);
+	buffer = ocfs_malloc (osb->sb->s_blocksize);
 	if (buffer == NULL) {
 		LOG_ERROR_STATUS (status = -ENOMEM);
 		goto bail;
 	}
 
-	memset (buffer, 0, osb->sect_size);
+	memset (buffer, 0, osb->sb->s_blocksize);
 	disk = (ocfs_node_config_info *) buffer;
 
 	/* populate the nodecfg info in disk from global context */
@@ -1007,7 +990,7 @@
 	ocfs_volcfg_gblctxt_to_node (node);
 
 	/* Update the nodecfg on disk with the new info */
-	offset = osb->vol_layout.new_cfg_off;
+	offset = (osb->new_autoconfig_blkno << osb->sb->s_blocksize_bits);
 	status = ocfs_config_with_disk_lock (osb, offset, (__u8 *) disk,
 					     osb->node_num, OCFS_VOLCFG_UPD);
 	if (status < 0) {

Modified: branches/format-changes/src/vote.c
===================================================================
--- branches/format-changes/src/vote.c	2004-06-12 18:41:50 UTC (rev 1068)
+++ branches/format-changes/src/vote.c	2004-06-12 21:05:20 UTC (rev 1069)
@@ -663,7 +663,7 @@
 	down (&(OcfsGlobalCtxt.global_res));
 	list_for_each_safe (iter_osb, temp_iter, &(OcfsGlobalCtxt.osb_next)) {
 		osb = list_entry (iter_osb, ocfs_super, osb_next);
-		if (!memcmp (osb->vol_layout.vol_id, dlm_msg->vol_id,
+		if (!memcmp (osb->uuid, dlm_msg->vol_id,
 			     MAX_VOL_ID_LENGTH))
 			break;
 		osb = NULL;
@@ -791,7 +791,7 @@
 	dlm_msg->msg_len = msg_len;
 	dlm_msg->src_node = osb->node_num;
 	dlm_msg->msg_type = type;
-	memcpy (dlm_msg->vol_id, osb->vol_layout.vol_id, MAX_VOL_ID_LENGTH);
+	memcpy (dlm_msg->vol_id, osb->uuid, MAX_VOL_ID_LENGTH);
 
 	LOG_EXIT ();
 	return;



More information about the Ocfs2-commits mailing list