[Ocfs2-commits] jlbec commits r976 - in trunk: . src src/inc

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Wed Jun 2 16:52:46 CDT 2004


Author: jlbec
Date: 2004-06-02 15:52:44 -0500 (Wed, 02 Jun 2004)
New Revision: 976

Added:
   trunk/src/inc/io.h
   trunk/src/io.c
Removed:
   trunk/src/buffer_head_io.c
   trunk/src/inc/ocfs_buffer_head.h
   trunk/src/inc/ocfs_compat.h
Modified:
   trunk/Config.make.in
   trunk/configure.in
   trunk/src/Makefile
   trunk/src/alloc.c
   trunk/src/bitmap.c
   trunk/src/dcache.c
   trunk/src/dir.c
   trunk/src/dlm.c
   trunk/src/extmap.c
   trunk/src/file.c
   trunk/src/hash.c
   trunk/src/heartbeat.c
   trunk/src/inc/
   trunk/src/inc/ocfs.h
   trunk/src/inc/ocfs_journal.h
   trunk/src/inc/ocfs_log.h
   trunk/src/inode.c
   trunk/src/ioctl.c
   trunk/src/journal.c
   trunk/src/lockres.c
   trunk/src/namei.c
   trunk/src/nm.c
   trunk/src/proc.c
   trunk/src/super.c
   trunk/src/symlink.c
   trunk/src/sysfile.c
   trunk/src/util.c
   trunk/src/ver.c
   trunk/src/volcfg.c
   trunk/src/vote.c
Log:

o Revert things that break format.  Bad Joel.



Modified: trunk/Config.make.in
===================================================================
--- trunk/Config.make.in	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/Config.make.in	2004-06-02 20:52:44 UTC (rev 976)
@@ -60,6 +60,7 @@
 OCFS_LARGEIO = @OCFS_LARGEIO@
 OCFS_AIO = @OCFS_AIO@
 OCFS_MEMDEBUG = @OCFS_MEMDEBUG@
+OCFS_DBG_LOCKRES = @OCFS_DBG_LOCKRES@
 OCFS_TRACE = @OCFS_TRACE@
 OCFS_PROCESSOR = @OCFS_PROCESSOR@
 

Modified: trunk/configure.in
===================================================================
--- trunk/configure.in	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/configure.in	2004-06-02 20:52:44 UTC (rev 976)
@@ -110,6 +110,15 @@
 AC_SUBST(OCFS_MEMDEBUG)
 AC_MSG_RESULT($enable_memdebug)
 
+AC_MSG_CHECKING(for lockres debugging)
+AC_ARG_ENABLE(lockres-debug, [  --enable-lockres-debug=[yes/no]     Turn on lock resource debugging [default=no]],,enable_lockres_debug=no)
+OCFS_DBG_LOCKRES=
+if test "x$enable_lockres_debug" = "xyes"; then
+  OCFS_DBG_LOCKRES=yes
+fi
+AC_SUBST(OCFS_DBG_LOCKRES)
+AC_MSG_RESULT($enable_lockres_debug)
+
 AC_MSG_CHECKING(for tracing)
 AC_ARG_ENABLE(trace, [  --enable-trace=[yes/no]         Turn on tracing [default=yes]],,enable_trace=yes)
 OCFS_TRACE=

Modified: trunk/src/Makefile
===================================================================
--- trunk/src/Makefile	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/Makefile	2004-06-02 20:52:44 UTC (rev 976)
@@ -33,6 +33,10 @@
 GLOBAL_DEFINES += -DOCFS_LINUX_MEM_DEBUG -DDEBUG_SLAB_ALLOCS
 endif
 
+ifdef OCFS_DBG_LOCKRES
+GLOBAL_DEFINES += -DOCFS_DBG_LOCKRES
+endif
+
 ifdef OCFS_AIO
 GLOBAL_DEFINES += -DAIO_ENABLED
 endif
@@ -102,6 +106,7 @@
 endif
 
 ifeq ($(OCFS_PROCESSOR),ppc64)
+  GLOBAL_DEFINES += -D__LP64__
   MACH_CFLAGS += -m64 -fsigned-char -fno-builtin -msoft-float -mminimal-toc
   LDADD += -m elf64ppc
 endif
@@ -119,38 +124,37 @@
 
 DEFINES += $(BASE_DEFINES) $(GLOBAL_DEFINES)
 
-CFILES =			\
-	alloc.c			\
-	bitmap.c		\
-	dcache.c		\
-	dir.c			\
-	dlm.c			\
-	extmap.c		\
-	file.c			\
-	hash.c			\
-	heartbeat.c		\
-	inode.c			\
-	buffer_head_io.c	\
-	ioctl.c			\
-	journal.c		\
-	lockres.c		\
-	namei.c			\
-	nm.c			\
-	proc.c			\
-	super.c			\
-	symlink.c		\
-	sysfile.c		\
-	util.c			\
-	ver.c			\
-	volcfg.c		\
+CFILES =		\
+	alloc.c		\
+	bitmap.c	\
+	dcache.c	\
+	dir.c		\
+	dlm.c		\
+	extmap.c	\
+	file.c		\
+	hash.c		\
+	heartbeat.c	\
+	inode.c		\
+	io.c		\
+	ioctl.c		\
+	journal.c	\
+	lockres.c	\
+	namei.c		\
+	nm.c		\
+	proc.c		\
+	super.c		\
+	symlink.c	\
+	sysfile.c	\
+	util.c		\
+	ver.c		\
+	volcfg.c	\
 	vote.c
 
 HFILES = \
 	inc/ocfs.h		\
 	inc/ocfs_log.h		\
-	inc/ocfs_compat.h	\
 	inc/ocfs_journal.h	\
-	inc/ocfs_buffer_head.h	\
+	inc/io.h		\
 	inc/proto.h
 
 OBJS = $(subst .c,.o,$(CFILES))
@@ -166,9 +170,6 @@
 ifndef KERNEL_26
 # Building for a 2.4.x kernel
 
-# Make dependancies work
-$(OBJS): $(HFILES)
-
 ifneq ($(OCFS_PROCESSOR),x86_64)
 WARNINGS += -Wmissing-prototypes -Wmissing-declarations
 endif

Modified: trunk/src/alloc.c
===================================================================
--- trunk/src/alloc.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/alloc.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,17 +24,15 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
+#ifdef __KERNEL__
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
 #include "inc/ocfs_journal.h"
-#include "inc/ocfs_buffer_head.h"
+#else
+#include <debugocfs.h>
+#endif
 
 #ifndef USERSPACE_TOOL
 
@@ -823,7 +821,7 @@
 		for (i = 0; i < numSectorsAlloc; i++)
 			if (header_bhs[i])
 				brelse(header_bhs[i]);
-		kfree(header_bhs);
+		ocfs_free(header_bhs);
 	}
 	LOG_EXIT_STATUS (status);
 	return status;
@@ -919,6 +917,7 @@
 	OcfsExtent->alloc_file_off = fileOffset;
 	OcfsExtent->alloc_node = osb->node_num;
 	OcfsExtent->next_data_ext = 0;
+	fe->local_ext = 0;
 	fe->granularity++;
 
 	LOG_TRACE_ARGS ("Granularity is: %d\n", fe->granularity);
@@ -926,7 +925,8 @@
 	OCFS_BH_PUT_DATA(bhs[0]);
 	
 	/* If granularity is zero now, the for loop will not execute. */
-	/* First time a file is created, granularity = -1 */
+	/* First time a file is created ,granularity = -1 and local_ext flag */
+	/* is set to true */
 
 	upHeaderPtr = fe->this_sector;
 
@@ -1085,6 +1085,7 @@
 	}
 
 	/* Update the File Entry Extent */
+	fe->local_ext = 0;
 
 	LOG_TRACE_ARGS("fe->alloc_size = %llu\n", fe->alloc_size);
 	fe->extents[0].file_off = 0;
@@ -1132,7 +1133,7 @@
 		goto finally;
 	}
 
-	if (FileEntry->granularity < 0) {
+	if (FileEntry->local_ext) {
 		LOG_TRACE_STR("Using local extents");
 		/* We are still using the local extents of File Entry */
 		if (FileEntry->next_free_ext > OCFS_MAX_FILE_ENTRY_EXTENTS) {
@@ -1143,7 +1144,7 @@
 		k = FileEntry->next_free_ext - 1;
 		if (k >= 0 && OCFS_EXTENT_MERGEABLE (&FileEntry->extents[k], actualDiskOffset)) {
 			/* See if we can merge the extents and just increase the length */
-			LOG_TRACE_ARGS ("Using local extent for extent Entry = %u\n", k);
+			LOG_TRACE_ARGS ("Using local_ext for extent Entry = %u\n", k);
 			FileEntry->extents[k].num_bytes += actualLength;
 			goto finally;
 		}
@@ -1185,7 +1186,7 @@
 	}
 	
 	k = extent->next_free_ext - 1;
-	LOG_TRACE_ARGS ("Using local extent for extent Entry = %u\n", k);
+	LOG_TRACE_ARGS ("Using local_ext for extent Entry = %u\n", k);
 	if (extent->next_free_ext < 1)
 		LOG_ERROR_ARGS ("next_free_ext=%d", extent->next_free_ext);
 	
@@ -1634,7 +1635,7 @@
 			goto bail;
 		}
 		/* Pop one off the stack */
-		kfree(stack[tos]);
+		ocfs_free(stack[tos]);
 		stack[tos] = NULL;
 		cur_extent = NULL;
 		tos--;
@@ -1644,7 +1645,7 @@
 bail:
 	for(i = 0; i < OCFS_TREE_STACK_SIZE; i++)
 		if (stack[i])
-			kfree(stack[i]);
+			ocfs_free(stack[i]);
 
 	LOG_EXIT_STATUS (status);
 	return(status);
@@ -2299,7 +2300,7 @@
 	alloc_size = FileEntry->alloc_size;
 
 	/* local extents */
-	if (FileEntry->granularity < 0) {
+	if (FileEntry->local_ext) {
 		status = _squish_extent_entries(osb, FileEntry->extents, 
 						&FileEntry->next_free_ext, 
 						handle, alloc_size, 0, 
@@ -2370,6 +2371,7 @@
 	if (alloc_size == 0) {
 		FileEntry->last_ext_ptr = 0;
 		FileEntry->granularity = -1;
+		FileEntry->local_ext = 1;
 		updated_lep = 1;
 	}
 
@@ -2454,7 +2456,7 @@
 		goto finally;
 	}
 
-	if (fe->granularity < 0) {
+	if (fe->local_ext) {
 		status = ocfs_update_extent_map (osb, &OCFS_I(inode)->map, fe,
 						 NULL, NULL, LOCAL_EXT);
 		if (status < 0) {
@@ -3083,7 +3085,7 @@
 
 	fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(fe_bh); /* read */
 
-	if (fe->granularity < 0) {
+	if (fe->local_ext) {
 		for (i = 0; i < fe->next_free_ext; i++) {
 			numBitsAllocated = (__u32) (fe->extents[i].num_bytes >>
 						  osb->cluster_size_bits);

Modified: trunk/src/bitmap.c
===================================================================
--- trunk/src/bitmap.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/bitmap.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,17 +24,16 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
+#if defined(__KERNEL__)
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
 #include "inc/ocfs_journal.h"
-#include "inc/ocfs_buffer_head.h"
+#else
+#include  <asm/bitops.h>
+#include  <dummy.h>
+#endif
 
 /* Tracing */
 #define OCFS_DEBUG_CONTEXT  OCFS_DEBUG_CONTEXT_BITMAP
@@ -76,7 +75,7 @@
 		if (bitmap->chunk[i])
 			brelse(bitmap->chunk[i]);
 
-	kfree(bitmap->chunk);
+	ocfs_free(bitmap->chunk);
 	bitmap->chunk = NULL;
 	bitmap->numbh = 0;
 	bitmap->validbits = 0;
@@ -117,7 +116,7 @@
 
 	memcpy(newchunk, bitmap->chunk, (bitmap->numbh * sizeof(struct buffer_head *)));
 
-	kfree(bitmap->chunk);
+	ocfs_free(bitmap->chunk);
 
 	bitmap->numbh = newnumbh;
 	bitmap->chunk = newchunk;

Deleted: trunk/src/buffer_head_io.c
===================================================================
--- trunk/src/buffer_head_io.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/buffer_head_io.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -1,346 +0,0 @@
-/*
- * io.c
- *
- * Buffer cache handling
- *
- * Copyright (C) 2002, 2004 Oracle.  All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Mark Fasheh, Sunil Mushran, Wim Coekaerts,
- *	    Manish Singh, Neeraj Goyal, Suchit Kaura
- */
-
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
-#include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-
-#include "inc/ocfs_log.h"
-#include "inc/ocfs.h"
-#include "inc/ocfs_journal.h"
-#include "inc/ocfs_buffer_head.h"
-
-#define OCFS_DEBUG_CONTEXT    OCFS_DEBUG_CONTEXT_IO
-
-static void ocfs_end_buffer_io_sync(struct buffer_head *bh,
-                                    int uptodate)
-{
-//	LOG_ENTRY_ARGS("(bh->b_blocknr = %u, uptodate = %d)\n", bh->b_blocknr,
-//		       uptodate);
-
-	if (!uptodate)
-		LOG_ERROR_STATUS(-EIO);
-
-	if (uptodate)
-		set_buffer_uptodate(bh);
-	else
-		clear_buffer_uptodate(bh);
-	unlock_buffer(bh);
-
-//	LOG_EXIT();
-	return;
-}
-
-
-int ocfs_write_bhs (ocfs_super * osb, struct buffer_head *bhs[], 
-				  int nr, int flags, struct inode *inode)
-{
-	int status = 0;
-	int i;
-	struct super_block *sb;
-	ocfs_blockdev dev;
-	struct buffer_head *bh;
-
-#ifdef OCFS_DBG_TIMING
-	my_timing_t begin, end; 
-#endif
-	
-	LOG_ENTRY_ARGS("(bh[0]->b_blocknr = %lu, nr=%d, flags=%u, inode=%p)\n", 
-		       bhs[0]->b_blocknr, nr, flags, inode);
-#ifdef OCFS_DBG_TIMING
-	rdtsc (begin.lohi[0], begin.lohi[1]);
-#endif
-
-	if (osb == NULL || osb->sb == NULL || bhs == NULL) {
-		LOG_TRACE_STR("osb == NULL || osb->sb == NULL || bhs == "
-		       "NULL");
-		status = -EINVAL;
-		LOG_ERROR_STATUS(status);
-		goto bail;
-	}
-
-	if (nr > 256)
-		LOG_TRACE_ARGS ("Getting write for %d blocks\n", nr);
-
-	sb = osb->sb;
-	dev = OCFS_GET_BLOCKDEV(sb);
-
-	/* we don't ever want cached writes -- those should go to the
-	 * journal so we can control when they actually hit disk and
-	 * so we can make sure they never get overwritten by a
-	 * subsequent read. */
-	if ((flags & OCFS_BH_CACHED) || (flags & OCFS_BH_COND_CACHED)) {
-		LOG_TRACE_STR("asking for a cached write!");
-		status = -EINVAL;
-		LOG_ERROR_STATUS(status);
-		goto bail;
-	}
-
-	for (i = 0 ; i < nr ; i++) {
-		bh = bhs[i];
-		if (bh == NULL) {
-			LOG_TRACE_STR("bh == NULL");
-			status = -EIO;
-			LOG_ERROR_STATUS(status);
-			goto bail;
-		}
-
-		if (check_block_zero_write(bh) < 0) {
-			status = -EIO;	
-			LOG_ERROR_STATUS(status);
-			goto bail;
-		}
-
-		if (flags & OCFS_BH_CONCURRENT_WRITE)
-			goto skip_modified_check;
-
-		/* Make sure the buffer is locked for modify, and
-		 * we're the ones with the write lock on this
-		 * buffer. */
-		if (!buffer_modified(bh)) {
-			printk("ocfs2: modified bit is NOT set on buffer "
-			       "(bh->b_blocknr = %lu)!\n", bh->b_blocknr);
-			BUG();
-		}
-		if (ocfs_bh_sem_lock_modify(bh) == OCFS_BH_SEM_WAIT_ON_MODIFY){
-			printk("ocfs2: someone else owns this buffer"
-			       "(bh->b_blocknr = %lu)!\n", bh->b_blocknr);
-			BUG();
-		}
-		ocfs_bh_sem_unlock(bh);
-
-skip_modified_check:
-		if (!(flags & OCFS_BH_IGNORE_JBD) && buffer_jbd(bh)) {
-#ifdef VERBOSE_BH_JBD_TRACE
-			LOG_TRACE_ARGS("trying to write a jbd managed bh "
-				       "(blocknr = %lu), nr=%d\n", 
-				       bh->b_blocknr, nr);
-#endif
-			continue;
-		}
-
-		lock_buffer(bh);
-
-		set_buffer_uptodate(bh);
-		/* remove from dirty list before I/O. */
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)		
-		/*
-		 * mark_buffer_clean() doesn't exist in 2.6.x kernels.
-		 * Not many places actually used mark_buffer_clean, but
-		 * at least reiserfs uses clear_buffer_dirty() as
-		 * a replacment.
-		 */
-		clear_buffer_dirty(bh);
-#else
-		mark_buffer_clean(bh);
-#endif
-
-		bh->b_end_io = ocfs_end_buffer_io_sync;
-		submit_bh(WRITE, bh);
-	}
-
-	for (i = (nr-1) ; i >= 0; i--) {
-		bh = bhs[i];
-
-		wait_on_buffer(bh);
-
-		if (inode)
-			SET_BH_SEQNUM(inode, bh);
-		else
-			CLEAR_BH_SEQNUM(bh);
-
-		if (!(flags & OCFS_BH_CONCURRENT_WRITE) 
-		    && (!buffer_jbd(bh) || (flags & OCFS_BH_IGNORE_JBD)))
-			ocfs_clear_buffer_modified(bh);
-	}
-	
-bail:
-
-#ifdef OCFS_DBG_TIMING
-	IO_FUNC_TIMING_PRINT("ocfs_write_bhs", status);
-#endif
-
-	LOG_EXIT_STATUS(status);
-	return status;
-}
-
-/*
- * ocfs_read_bhs()
- *
- */
-int ocfs_read_bhs (ocfs_super * osb, __u64 off, __u64 len, 
-				 struct buffer_head *bhs[], int flags, 
-				 struct inode *inode)
-{
-	int status = 0;
-	struct super_block *sb;
-	int nr, i, ignore_cache = 0;
-	__u64 blocknum;
-	ocfs_blockdev dev;
-	struct buffer_head *bh;
-
-#ifdef OCFS_DBG_TIMING
-	my_timing_t begin, end; 
-#endif
-	LOG_ENTRY_ARGS("(off=(%llu), len=(%llu), flags=%d, inode=%p)\n", off, 
-		       len, flags, inode);
-#ifdef OCFS_DBG_TIMING
-	rdtsc (begin.lohi[0], begin.lohi[1]);
-#endif
-
-	if (len % 512) {
-		LOG_TRACE_ARGS("len %% 512 (len=%llu)\n", len);
-		status = -EINVAL;
-		LOG_ERROR_STATUS(status);
-		goto bail;
-	}
-
-	if (osb == NULL || osb->sb == NULL || bhs == NULL) {
-		LOG_TRACE_STR("osb == NULL || osb->sb == NULL || bhs == NULL "
-			      "|| num == NULL");
-		status = -EINVAL;
-		LOG_ERROR_STATUS(status);
-		goto bail;
-	}
-
-	if ((flags & OCFS_BH_COND_CACHED) && 
-	    (off >= osb->vol_layout.bitmap_off))
-			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!");
-		flags &= ~OCFS_BH_CACHED;
-	}
-
-	sb = osb->sb;
-	dev = OCFS_GET_BLOCKDEV(sb);
-	blocknum = off >> sb->s_blocksize_bits;
-
-	nr = (len + 511) >> 9;
-	if (nr == 0) {
-		LOG_TRACE_STR("No buffers will be read!!!");
-		LOG_TRACE_ARGS("Len=%llu Off=%llu numbuffers=%u "
-			       "blocknum=%llu\n", len, off, 
-			       nr, blocknum);
-		status = 0;
-		goto bail;
-	}
-
-	for (i = 0 ; i < nr ; i++) {
-		if (bhs[i] == NULL) {
-			bhs[i] = getblk (dev, blocknum++, sb->s_blocksize);
-			if (bhs[i] == NULL) {
-				LOG_TRACE_STR("bh == NULL");
-				status = -EIO;
-				LOG_ERROR_STATUS(status);
-				goto bail;
-			}
-		}
-		bh = bhs[i];
-		ignore_cache = 0;
-
-		/* Lock everyone else out of this bh */
-		OCFS_BH_GET_DATA_READ(bh);
-
-		if (flags & OCFS_BH_CACHED && inode && 
-		    !TEST_BH_SEQNUM(inode, bh)) {
-#ifdef VERBOSE_BH_SEQNUM_TRACE
-			LOG_TRACE_ARGS("(read) bh (%lu) seqnum (%lu) does not "
-				       "match inode (%u)\n", bh->b_blocknr, 
-				       (bh->b_state & STATE_BIT_MASK) >> 19,
-				       atomic_read(GET_INODE_CLEAN_SEQ(inode)));
-#endif
-			ignore_cache = 1;
-		}
-
-		if ((flags & OCFS_BH_CACHED) && (!buffer_uptodate(bh)))
-			ignore_cache = 1;
-
-		if (buffer_jbd(bh)) {
-#ifdef VERBOSE_BH_JBD_TRACE
-			if (!(flags & OCFS_BH_CACHED) || ignore_cache)
-				LOG_TRACE_ARGS("trying to sync read a jbd "
-					       "managed bh (blocknr = %lu)\n",
-					       bh->b_blocknr);
-#endif
-			continue;
-		}
-
-		if (!(flags & OCFS_BH_CACHED) || ignore_cache) {
-			if (buffer_dirty(bh)) {
-				/* This should probably be a BUG, or
-				 * at least return an error. */
-				LOG_TRACE_ARGS("asking me to sync read a "
-					      "dirty buffer! (blocknr = %lu)\n",
-					      bh->b_blocknr);
-				continue;
-			}
-
-			lock_buffer(bh);
-			clear_buffer_uptodate(bh);
-			bh->b_end_io = ocfs_end_buffer_io_sync;
-			if (flags & OCFS_BH_READAHEAD)
-				submit_bh(READA, bh);
-			else
-				submit_bh(READ, bh);
-			continue;
-		}
-	}
-
-	status = 0;
-
-	for (i = (nr-1); i >= 0; i--) {
-		bh = bhs[i];
-
-		wait_on_buffer(bh);
-
-		if (inode)
-			SET_BH_SEQNUM(inode, bh);
-		else
-			CLEAR_BH_SEQNUM(bh);
-
-		OCFS_BH_PUT_DATA(bh);
-	}
-	LOG_TRACE_ARGS("off=(%llu), len=(%llu), cached=%s\n", off, len, 
-		       (!(flags & OCFS_BH_CACHED) || ignore_cache) ? "no" : "yes");
-
-bail:
-
-#ifdef OCFS_DBG_TIMING
-	IO_FUNC_TIMING_PRINT("ocfs_read_bhs", status);
-#endif
-
-	LOG_EXIT_STATUS(status);
-	return status;
-}
-
-
-

Modified: trunk/src/dcache.c
===================================================================
--- trunk/src/dcache.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/dcache.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,14 +24,7 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#include <linux/namei.h>
-#endif
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"

Modified: trunk/src/dir.c
===================================================================
--- trunk/src/dir.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/dir.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,16 +24,10 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
-#include "inc/ocfs_buffer_head.h"
 
 #define OCFS_DEBUG_CONTEXT    OCFS_DEBUG_CONTEXT_DIR
 

Modified: trunk/src/dlm.c
===================================================================
--- trunk/src/dlm.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/dlm.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,18 +24,11 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-#include <linux/random.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
 #include "inc/ocfs_journal.h"
-#include "inc/ocfs_buffer_head.h"
 
 extern __u32 comm_voting;
 
@@ -219,8 +212,8 @@
 			goto finally;
 		}
 		fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(bh); /* read */
-		curr_master = DISK_LOCK(fe)->curr_master;
-		lock_level = DISK_LOCK(fe)->file_lock;
+		curr_master = DISK_LOCK_CURRENT_MASTER (fe);
+		lock_level = DISK_LOCK_FILE_LOCK (fe);
 		OCFS_BH_PUT_DATA(bh);
 
 		/* This will always be zero when the first Node comes up after reboot */
@@ -234,8 +227,8 @@
 			/* Reset the lock as not owned and return success?? */
 			/* This needs to be under some sort of cluster wide lock */
 			fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_WRITE(bh); /* write */
-			DISK_LOCK(fe)->curr_master = OCFS_INVALID_NODE_NUM;
-			DISK_LOCK(fe)->file_lock = OCFS_DLM_NO_LOCK;
+			DISK_LOCK_CURRENT_MASTER (fe) = OCFS_INVALID_NODE_NUM;
+			DISK_LOCK_FILE_LOCK (fe) = OCFS_DLM_NO_LOCK;
 			OCFS_BH_PUT_DATA(bh);
 			tmpstat = ocfs_write_bh (osb, bh, 0, NULL);
 			if (tmpstat < 0) {
@@ -293,8 +286,8 @@
 			goto finally;
 		}
 		fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(bh); /* read */
-		curr_master = DISK_LOCK(fe)->curr_master;
-		lock_level = DISK_LOCK(fe)->file_lock;
+		curr_master = DISK_LOCK_CURRENT_MASTER (fe);
+		lock_level = DISK_LOCK_FILE_LOCK (fe);
 		is_dir = (fe->attribs & OCFS_ATTRIB_DIRECTORY);
 		OCFS_BH_PUT_DATA(bh);
 
@@ -308,8 +301,8 @@
 			/* Reset the lock as not owned and return success?? */
 			/* This needs to be under some sort of cluster wide lock, */
 			fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_WRITE(bh); /* write */
-			DISK_LOCK(fe)->curr_master = OCFS_INVALID_NODE_NUM;
-			DISK_LOCK(fe)->file_lock = OCFS_DLM_NO_LOCK;
+			DISK_LOCK_CURRENT_MASTER (fe) = OCFS_INVALID_NODE_NUM;
+			DISK_LOCK_FILE_LOCK (fe) = OCFS_DLM_NO_LOCK;
 			OCFS_BH_PUT_DATA(bh);
 			tmpstat = ocfs_write_bh (osb, bh, 0, NULL);
 			if (tmpstat < 0) {
@@ -387,7 +380,7 @@
 				}
 				LOG_TRACE_ARGS("broke cache lock, setting to NO_LOCK\n");
 				fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_WRITE(bh); /* write */
-				DISK_LOCK(fe)->file_lock = OCFS_DLM_NO_LOCK;
+				DISK_LOCK_FILE_LOCK (fe) = OCFS_DLM_NO_LOCK;
 				lock_level = OCFS_DLM_NO_LOCK;
 				OCFS_BH_PUT_DATA(bh);
 				tmpstat = ocfs_write_bh (osb, bh, 0, inode);
@@ -647,46 +640,46 @@
 	fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(*bh); /* read */
 
 	if (flags & DLOCK_FLAG_MASTER && 
-	    DISK_LOCK(fe)->curr_master != lockres->master_node_num) {
+	    DISK_LOCK_CURRENT_MASTER (fe) != lockres->master_node_num) {
 		if (!changed) {
 			OCFS_BH_PUT_DATA(*bh);
 			fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_WRITE(*bh); /* write */
 		}
 		changed = 1;
-		DISK_LOCK(fe)->curr_master = lockres->master_node_num;
+		DISK_LOCK_CURRENT_MASTER (fe) = lockres->master_node_num;
 	}
 
 	if (flags & DLOCK_FLAG_LOCK &&
-	    DISK_LOCK(fe)->file_lock != lockres->lock_type) {
+	    DISK_LOCK_FILE_LOCK (fe) != lockres->lock_type) {
 		if (!changed) {
 			OCFS_BH_PUT_DATA(*bh);
 			fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_WRITE(*bh); /* write */
 		}
 		changed = 1;
-		DISK_LOCK(fe)->file_lock = lockres->lock_type;
+		DISK_LOCK_FILE_LOCK (fe) = lockres->lock_type;
 	}
 
 	if (flags & DLOCK_FLAG_OPEN_MAP) {
 	       if (flags & DLOCK_FLAG_ADD_SELF)
 		       lockres->oin_openmap |= (1ULL << osb->node_num);
-	       if (DISK_LOCK(fe)->oin_node_map != lockres->oin_openmap) {
+	       if (DISK_LOCK_OIN_MAP (fe) != lockres->oin_openmap) {
 			if (!changed) {
 				OCFS_BH_PUT_DATA(*bh);
 				fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_WRITE(*bh); /* write */
 			}
 			changed = 1;
-			DISK_LOCK(fe)->oin_node_map = lockres->oin_openmap;
+			DISK_LOCK_OIN_MAP (fe) = lockres->oin_openmap;
 	       }
 	}
 
 	if (flags & DLOCK_FLAG_SEQ_NUM &&
-	    DISK_LOCK(fe)->dlock_seq_num != lockres->last_upd_seq_num) {
+	    DISK_LOCK_SEQNUM (fe) != lockres->last_upd_seq_num) {
 		if (!changed) {
 			OCFS_BH_PUT_DATA(*bh);
 			fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_WRITE(*bh); /* write */
 		}
 		changed = 1;
-		DISK_LOCK(fe)->dlock_seq_num = lockres->last_upd_seq_num;
+		DISK_LOCK_SEQNUM (fe) = lockres->last_upd_seq_num;
 	}
 
 	OCFS_BH_PUT_DATA(*bh);
@@ -870,10 +863,10 @@
 			BUG();
 
 		if (lockres->master_node_num != osb->node_num || 
-		    lockres->master_node_num != DISK_LOCK(disklock)->curr_master) {
-			lockres->master_node_num = DISK_LOCK(disklock)->curr_master;
-			lockres->lock_type = DISK_LOCK(disklock)->file_lock;
-			lockres->oin_openmap = DISK_LOCK(disklock)->oin_node_map;	
+		    lockres->master_node_num != DISK_LOCK_CURRENT_MASTER (disklock)) {
+			lockres->master_node_num = DISK_LOCK_CURRENT_MASTER (disklock);
+			lockres->lock_type = DISK_LOCK_FILE_LOCK (disklock);
+			lockres->oin_openmap = DISK_LOCK_OIN_MAP (disklock);	
 		}
 		updated = 1;
 		OCFS_BH_PUT_DATA(*b);
@@ -1068,8 +1061,8 @@
 		}
 	}
 	fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(*b); /* read */
-	oin_node_map = DISK_LOCK(fe)->oin_node_map;
-	curr_master = DISK_LOCK(fe)->curr_master;
+	oin_node_map = DISK_LOCK_OIN_MAP (fe);
+	curr_master = DISK_LOCK_CURRENT_MASTER (fe);
 	OCFS_BH_PUT_DATA(*b);
 
 	if (!IS_VALID_NODE_NUM (curr_master)) {
@@ -1165,20 +1158,20 @@
 
 	LOG_TRACE_ARGS("writing lock now... releasemaster: %s, level: %d, master: %d\n",
 		       flags & FLAG_FILE_RELEASE_MASTER ? "yes" : "no", 
-		       DISK_LOCK(fe)->file_lock,
-		       DISK_LOCK(fe)->curr_master);
+		       DISK_LOCK_FILE_LOCK (fe),
+		       DISK_LOCK_CURRENT_MASTER (fe));
 	if (flags & FLAG_FILE_RELEASE_MASTER)
-		DISK_LOCK(fe)->curr_master = OCFS_INVALID_NODE_NUM;
+		DISK_LOCK_CURRENT_MASTER (fe) = OCFS_INVALID_NODE_NUM;
 
-	if ((DISK_LOCK(fe)->file_lock == OCFS_DLM_ENABLE_CACHE_LOCK) &&
-	    (DISK_LOCK(fe)->curr_master == osb->node_num)) {
+	if ((DISK_LOCK_FILE_LOCK (fe) == OCFS_DLM_ENABLE_CACHE_LOCK) &&
+	    (DISK_LOCK_CURRENT_MASTER (fe) == osb->node_num)) {
 		lockres->lock_type = OCFS_DLM_ENABLE_CACHE_LOCK; 
 		cachelock = 1;
 		LOG_TRACE_STR("keeping at CACHE_LOCK");
 	}
 	else {
 		LOG_TRACE_STR("setting to NO_LOCK");
-		DISK_LOCK(fe)->file_lock = OCFS_DLM_NO_LOCK;
+		DISK_LOCK_FILE_LOCK (fe) = OCFS_DLM_NO_LOCK;
 	}
 
 	OCFS_BH_PUT_DATA(*b);
@@ -1347,8 +1340,8 @@
 		if (bh) {
 			fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(bh); /* read */
 			/* may not need to rewrite the lock later if we already have a cachelock */
-			need_lock_write = (DISK_LOCK(fe)->curr_master != osb->node_num ||
-					DISK_LOCK(fe)->file_lock != OCFS_DLM_ENABLE_CACHE_LOCK);
+			need_lock_write = (DISK_LOCK_CURRENT_MASTER (fe) != osb->node_num ||
+					DISK_LOCK_FILE_LOCK (fe) != OCFS_DLM_ENABLE_CACHE_LOCK);
 			OCFS_BH_PUT_DATA(bh);
 		} else
 			need_lock_write = 0;
@@ -1456,7 +1449,7 @@
 	/* pick up any change to the open map */
 	if (bh) {
 		fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_READ(bh); /* read */
-		lockres->oin_openmap = DISK_LOCK(fe)->oin_node_map;
+		lockres->oin_openmap = DISK_LOCK_OIN_MAP (fe);
 		OCFS_BH_PUT_DATA(bh);
 	}
 bail:

Modified: trunk/src/extmap.c
===================================================================
--- trunk/src/extmap.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/extmap.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,11 +24,7 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
@@ -596,7 +592,7 @@
 	if (Flag == LOCAL_EXT) {
 		FileEntry = (ocfs_file_entry *) Buffer;
 
-		OCFS_ASSERT(FileEntry->granularity < 0);
+		OCFS_ASSERT (FileEntry->local_ext);
 
 		for (j = 0; j < FileEntry->next_free_ext; j++) {
 			tempVbo = FileEntry->extents[j].file_off;

Modified: trunk/src/file.c
===================================================================
--- trunk/src/file.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/file.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,17 +24,11 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
 #include "inc/ocfs_journal.h"
-#include "inc/ocfs_buffer_head.h"
 
 #define OCFS_DEBUG_CONTEXT    OCFS_DEBUG_CONTEXT_FILE
 
@@ -124,7 +118,7 @@
 
 	/* why do we update these here? */
 	OCFS_I(inode)->alloc_size = fe->alloc_size;
-	OCFS_I(inode)->chng_seq_num = DISK_LOCK(fe)->dlock_seq_num;
+	OCFS_I(inode)->chng_seq_num = DISK_LOCK_SEQNUM (fe);
 	if (fe->this_sector == 0)
 		LOG_ERROR_STR ("this_sector=0");
 
@@ -327,7 +321,7 @@
 	}
 
 	if (ret < 0)
-		ocfs_bh_sem_hash_cleanup_pid(current->pid);
+		ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
 
 	LOG_TRACE_ARGS
 	    ("exiting file_open: file=%p dentry=%p inode=%p kiovec=%d\n",
@@ -412,7 +406,7 @@
 	}
 
 bail:
-//	ocfs_bh_sem_hash_cleanup_pid(current->pid);
+//	ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
 
 	LOG_EXIT_INT (0);
 	return 0;
@@ -454,7 +448,7 @@
 	if (fe->attribs & OCFS_ATTRIB_DIRECTORY)
 		goto leave;
 
-	if (fe->granularity < 0) {
+	if (fe->local_ext) {
 		for (j = 0; j < fe->next_free_ext; j++) {
 			tempVbo = fe->extents[j].file_off;
 			tempLbo = fe->extents[j].disk_off;
@@ -621,8 +615,8 @@
 		goto leave;
 	}
 
-	if ((DISK_LOCK(fileEntry)->file_lock == OCFS_DLM_ENABLE_CACHE_LOCK) &&
-	    (DISK_LOCK(fileEntry)->curr_master == osb->node_num))
+	if ((DISK_LOCK_FILE_LOCK (fileEntry) == OCFS_DLM_ENABLE_CACHE_LOCK) &&
+	    (DISK_LOCK_CURRENT_MASTER (fileEntry) == osb->node_num))
 		locktype = OCFS_DLM_ENABLE_CACHE_LOCK;
 	else
 		locktype = OCFS_DLM_EXCLUSIVE_LOCK;
@@ -661,7 +655,7 @@
 
 	fileEntry->modify_time = OCFS_CURRENT_TIME;
 
-	DISK_LOCK(fileEntry)->dlock_seq_num = 0;
+	DISK_LOCK_SEQNUM (fileEntry) = 0;
 	OCFS_FE_SET_ATTRIBUTES(fileEntry, attr);
 
 	/* Set the valid bit here */
@@ -869,7 +863,7 @@
 #ifndef BH_SEM_LEAK_CHECKING	
 	if (ret < 0)
 #endif
-		ocfs_bh_sem_hash_cleanup_pid(current->pid);
+		ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
 
 	LOG_EXIT_INT (ret);
 	return ret;
@@ -997,8 +991,8 @@
 	lockId = fe->this_sector;
 	lockFlags = FLAG_FILE_TRUNCATE;
 
-	if ((DISK_LOCK(fe)->file_lock == OCFS_DLM_ENABLE_CACHE_LOCK)
-	    && (DISK_LOCK(fe)->curr_master == osb->node_num))
+	if ((DISK_LOCK_FILE_LOCK (fe) == OCFS_DLM_ENABLE_CACHE_LOCK)
+	    && (DISK_LOCK_CURRENT_MASTER (fe) == osb->node_num))
 		locktype = OCFS_DLM_ENABLE_CACHE_LOCK;
 	else 
 		locktype = OCFS_DLM_EXCLUSIVE_LOCK;
@@ -1052,7 +1046,7 @@
 		goto leave;
 	}
 
-	DISK_LOCK(fe)->dlock_seq_num = 0;
+	DISK_LOCK_SEQNUM (fe) = 0;
 	SET_VALID_BIT (fe->sync_flags);
 	fe->sync_flags &= ~(OCFS_SYNC_FLAG_CHANGE);
 	fe->modify_time = OCFS_CURRENT_TIME;
@@ -1282,7 +1276,7 @@
 		up (&(OCFS_I(inode)->priv_sem));
 
 		/* no need to do OCFS_SECTOR_ALIGN once the allocation size is correct. */
-		DISK_LOCK(fileEntry)->dlock_seq_num = 0;
+		DISK_LOCK_SEQNUM (fileEntry) = 0;
 	}
 
 	/* Update tha file size and add the new one to old one. */
@@ -1479,7 +1473,7 @@
 #ifndef BH_SEM_LEAK_CHECKING
 	if (error < 0)
 #endif
-		ocfs_bh_sem_hash_cleanup_pid(current->pid);
+		ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
 
 	LOG_EXIT_INT (error);
 	return error;

Modified: trunk/src/hash.c
===================================================================
--- trunk/src/hash.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/hash.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,18 +24,10 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/blkdev.h>
-#include <linux/highmem.h>
-#include <linux/random.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
-#include "inc/ocfs_buffer_head.h"
 
 
 /* Tracing */

Modified: trunk/src/heartbeat.c
===================================================================
--- trunk/src/heartbeat.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/heartbeat.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,18 +24,18 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
+#if !defined(USERSPACE_TOOL)
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
 #include "inc/ocfs_journal.h"
-#include "inc/ocfs_buffer_head.h"
+#endif
 
+#if defined(USERSPACE_TOOL)
+#include <format.h>
+#endif
+
 /* Tracing */
 #define OCFS_DEBUG_CONTEXT      OCFS_DEBUG_CONTEXT_HEARTBEAT
 
@@ -81,10 +81,7 @@
 			publish->dirty = 0; 
 		}
 		/* Write the current time in local node's publish sector */
-		publish->time = jiffies;
-		/* Dissallow 0 */
-		if (!publish->time)
-			publish->time = 1;
+		publish->time = ocfs_get_publish_time();
 		publish->hbm[osb->node_num] = osb->hbm;
 		spin_lock (&OcfsGlobalCtxt.comm_seq_lock);
 		publish->comm_seq_num = OcfsGlobalCtxt.comm_seq_num;


Property changes on: trunk/src/inc
___________________________________________________________________
Name: svn:ignore
   - .*.sw?


Copied: trunk/src/inc/io.h (from rev 963, trunk/src/inc/io.h)

Modified: trunk/src/inc/ocfs.h
===================================================================
--- trunk/src/inc/ocfs.h	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/inc/ocfs.h	2004-06-02 20:52:44 UTC (rev 976)
@@ -31,22 +31,77 @@
 ** System header files
 */
 #define   __KERNEL_SYSCALLS__
+#include  <linux/version.h>
+#include  <linux/types.h>
+#include  <linux/config.h>
 
-#include <linux/spinlock.h>
-#include <linux/sched.h>
-#include <linux/wait.h>
-#include <linux/list.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+#ifdef __ia64__
+extern inline void prefetch(const void *x);
+extern inline void prefetchw(const void *x);
+#else
+static inline void prefetch(const void *x);
+static inline void prefetchw(const void *x);
+#endif
+extern inline int generic_fls(int x);
+extern inline int get_bitmask_order(unsigned int count);
+/* XXX Hack to avoid warning */
+struct mem_dqinfo;
+extern inline void mark_info_dirty(struct mem_dqinfo *info);
+#else /* 2.4 kernel */
+#include <asm/processor.h>
+#endif /* 2.6 kernel */
+
+#include  <linux/module.h>
+#include  <linux/init.h>
+#include  <linux/kernel.h>
+#include  <asm/byteorder.h>
+#include  <linux/spinlock.h>
+#include  <linux/slab.h>
+#include  <linux/sched.h>
+#include  <linux/delay.h>
+#include  <linux/wait.h>
+#include  <linux/list.h>
+#include  <linux/fs.h>
+#include  <linux/pagemap.h>
+#include  <linux/random.h>
+#include  <linux/string.h>
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-# include <linux/workqueue.h>
+#include <linux/writeback.h>
 #else
-# include <linux/tqueue.h>
+#include  <linux/locks.h>
 #endif
+#include  <linux/hdreg.h>
+#include  <linux/file.h>
+#include  <linux/raw.h>
+#include  <linux/vmalloc.h>
+#include  <linux/proc_fs.h>
+#include  <linux/unistd.h>
+#include  <asm/uaccess.h>
+#include  <linux/net.h>
+#include  <net/sock.h>
+#include  <linux/ctype.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#include  <linux/workqueue.h>
+#else
+#include  <linux/tqueue.h>
+#endif
+#include  <linux/inet.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#include <linux/statfs.h>
+#include <linux/blkdev.h>
+#include <linux/in.h>
+#include <linux/buffer_head.h>
+#include <linux/namei.h>
+#endif
+#include <linux/smp_lock.h>
 
 
 #define OCFS_BITMAP_CHUNK   (512) /* size of a chunk, in bytes */
 #define OCFS_BITS_IN_CHUNK  (OCFS_BITMAP_CHUNK * 8)
+//#define OCFS_BITMAP_NUM_BH  (ONE_MEGA_BYTE / OCFS_BITMAP_CHUNK)
 /* Lovely convenience macros. If we move to a scheme where
- * OCFS_BITS_IN_CHUNK is not constant, this'll
+ * OCFS_BITS_IN_CHUNK or OCFS_BITMAP_NUM_BH are not constant, this'll
  * be nice. */
 #define OCFS_CHUNK_TO_GLOBAL_OFF(index, localoffset)                    \
 	((index) * OCFS_BITS_IN_CHUNK + (localoffset))
@@ -82,6 +137,16 @@
 
 #define OCFS_POINTER_SIZE   (sizeof(void *))
 
+#ifdef __LP64__
+#define OCFS_GCC_ATTR_PACKED	__attribute__ ((packed))
+#define OCFS_GCC_ATTR_ALIGNED	__attribute__ ((aligned(4)))
+#define OCFS_GCC_ATTR_PACKALGN	__attribute__ ((aligned(4), packed))
+#else
+#define OCFS_GCC_ATTR_PACKED
+#define OCFS_GCC_ATTR_ALIGNED
+#define OCFS_GCC_ATTR_PACKALGN
+#endif
+
 enum
 {
 	OCFS_VOTE_REQUEST = 1,
@@ -125,10 +190,17 @@
 #define ocfs_safefree(x)	\
 do {				\
 	if (x)			\
-		kfree(x);	\
+		ocfs_free(x);	\
 	(x) = NULL;		\
 } while (0)
 
+#define ocfs_safevfree(x)	\
+do {				\
+	if (x)			\
+		vfree(x);	\
+	(x) = NULL;		\
+} while (0)
+
 #define OCFS_ASSERT(x)             do { if (!(x)) BUG(); } while (0)
 
 
@@ -138,6 +210,11 @@
 			     - (((x)>>3)&0x11111111))
 
 
+#ifdef USERSPACE_TOOL
+#define list_for_each_safe(pos, n, head) \
+	for (pos = (head)->next, n = pos->next; pos != (head); pos = n, n = pos->next)
+#endif
+
 #ifndef list_for_each_prev_safe
 #define list_for_each_prev_safe(pos, n, head) \
 	for (pos = (head)->prev, n = pos->prev; pos != (head); \
@@ -145,7 +222,32 @@
 #endif
 
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#define OCFS_CURRENT_TIME   (CURRENT_TIME.tv_sec)
+#define OCFS_SET_INODE_TIME(i, x, y)   (i->x.tv_sec = (y))
+#else
+#define OCFS_CURRENT_TIME   (CURRENT_TIME)
+#define OCFS_SET_INODE_TIME(i, x, y)   i->x = (y)
+#endif
 
+static inline __u64 ocfs_get_publish_time(void)
+{
+	unsigned long ret = jiffies;
+	return (ret != 0 ? ret : 1);
+}
+
+#ifdef __KERNEL__
+#define ocfs_getpid()               current->pid
+#else
+#define ocfs_getpid()               getpid()
+#endif
+
+
+
+#define  OCFS_FILE_EXTENT_FILENAME         "ExtentFile"
+#define  OCFS_FILE_EXTENT_BITMAP_FILENAME  "ExtentBitMapFile"
+#define  OCFS_JOURNAL_FILENAME             "JournalFile"
+
 #define  ONE_MEGA_BYTE           (1 * 1024 * 1024)   /* in bytes */
 
 #define  MISS_COUNT_VALUE        30
@@ -225,6 +327,11 @@
 #define OCFS_INODE_BITMAP            (OCFS_INODE_BM_SYSFILE       * OCFS_MAXIMUM_NODES)
 
 
+#define SECTOR_BITS 9
+#define SECTOR_SIZE (1U << SECTOR_BITS)
+#define SECTOR_MASK (SECTOR_SIZE - 1)
+
+
 /* FIXME: Left about for now */
 #define  OCFS_SECTOR_SIZE            512
 
@@ -232,6 +339,7 @@
 #define  OCFS_MAX_FILENAME_LENGTH    255
 #define  OCFS_MAX_OSB_ID             65536
 
+#define  OCFS_VOLUME_LOCK_OFFSET     (OCFS_SECTOR_SIZE)
 /* change this to some other sector, change format TODO */
 #define  OCFS_BITMAP_LOCK_OFFSET     (OCFS_SECTOR_SIZE * 2)
 
@@ -276,6 +384,8 @@
 /*
 ** Structure signatures 
 */
+#define  OCFS_TYPE_OFILE            (0x02534643)
+#define  OCFS_TYPE_OIN            (0x03534643)
 #define  OCFS_TYPE_OSB            (0x05534643)
 #define  OCFS_TYPE_GLOBAL_DATA    (0x07534643)
 
@@ -317,7 +427,10 @@
 #define  DISK_HBEAT_NO_COMM           4		/* in the order of 1 sec */
 #define  DISK_HBEAT_INVALID           0		/* in the order of 100ms */
 
+#define OCFS_X_FOR_DEL_RETRIES  25
 
+#define OCFS_TRANS_FLUSH_LIMIT   (8 * ONE_MEGA_BYTE)
+
 /*
 ** Information on Vote sector of each node
 */
@@ -522,20 +635,55 @@
 
 #define TEST_NODE_IN_RECOVERY(osb, num)	((osb->recovery_map) & (0x1 << (num)))
 
-#define ocfs_malloc(size)						      \
+#if defined(OCFS_LINUX_MEM_DEBUG)
+void *ocfs_linux_dbg_alloc (int Size, char *file, int line);
+void ocfs_linux_dbg_free (const void *Buffer);
+# define ocfs_malloc(_s)					\
+({								\
+	void *m = ocfs_linux_dbg_alloc(_s, __FILE__, __LINE__); \
+	if (debug_level & OCFS_DEBUG_LEVEL_MALLOC)              \
+		printk("malloc(%s,%d) = %p\n", __FILE__,        \
+			__LINE__, m);				\
+	m;                                                      \
+})
+
+# define ocfs_free(x)\
+do {								\
+	if (debug_level & OCFS_DEBUG_LEVEL_MALLOC)		\
+		printk("free(%s,%d) = %p\n", __FILE__,		\
+			__LINE__, x);				\
+	ocfs_linux_dbg_free(x);					\
+} while (0)
+
+# define ocfs_vmalloc(size)						      \
+({ 									      \
+	void *p = vmalloc(size);					      \
+	if (!p)								      \
+		printk("ERROR: unable to allocate %u bytes of memory\n",      \
+			(size));					      \
+	else								      \
+		memset(p, 0, size);					      \
+	p;								      \
+})
+# define ocfs_vfree		vfree
+#elif !defined(OCFS_LINUX_MEM_DEBUG)
+# define ocfs_malloc(size)						      \
 ({									      \
 	void *__ptr = kmalloc((size_t)(size), GFP_KERNEL);		      \
 	if (__ptr)							      \
 		memset(__ptr, 0, size);					      \
 	__ptr;								      \
 })
-#define ocfs_vmalloc(size)						      \
+# define ocfs_free              kfree
+# define ocfs_vmalloc(size)						      \
 ({									      \
 	void *__ptr = vmalloc((size_t)(size));				      \
 	if (__ptr)							      \
 		memset(__ptr, 0, size);					      \
 	__ptr;								      \
 })
+# define ocfs_vfree		vfree
+#endif				/* ! defined(OCFS_MEM_DBG) */
 
 
 
@@ -565,13 +713,43 @@
 	__ret;								\
 })
 
+/* sorry about all the macros, but file and line are important */
+
+/* lockres macros */
+#ifdef OCFS_MEM_DBG
+#define ocfs_allocate_extent_entry()  (ocfs_extent *)ocfs_dbg_slab_alloc( \
+						    OcfsGlobalCtxt.extent_cache, \
+						    __FILE__, __LINE__)
+#define ocfs_free_extent_entry(ext)   ocfs_dbg_slab_free( \
+						    OcfsGlobalCtxt.extent_cache, ext)
+#else  /* !OCFS_MEM_DBG */
+
 #define ocfs_allocate_extent_entry()  (ocfs_extent *)kmem_cache_alloc ( \
 						    OcfsGlobalCtxt.extent_cache, GFP_NOFS)
 #define ocfs_free_extent_entry(ext)   kmem_cache_free(OcfsGlobalCtxt.extent_cache, ext)
 
+#endif
 
+
+/* file entry macros */
+#ifdef OCFS_MEM_DBG
 #define ocfs_allocate_file_entry()  ((ocfs_file_entry *)({ \
 	ocfs_file_entry *FileEntry = NULL; \
+	FileEntry = ocfs_dbg_slab_alloc (OcfsGlobalCtxt.fe_cache, __FILE__, __LINE__); \
+	if (FileEntry != NULL) \
+	  memset (FileEntry, 0, OCFS_SECTOR_SIZE); \
+	FileEntry; }))
+
+#define ocfs_release_file_entry(fe)					  \
+	do {								  \
+		if (fe) {						  \
+			ocfs_dbg_slab_free (OcfsGlobalCtxt.fe_cache, fe); \
+			fe = NULL;					  \
+		}							  \
+	} while (0)
+#else  /* !OCFS_MEM_DBG */
+#define ocfs_allocate_file_entry()  ((ocfs_file_entry *)({ \
+	ocfs_file_entry *FileEntry = NULL; \
 	FileEntry = kmem_cache_alloc (OcfsGlobalCtxt.fe_cache, GFP_NOFS); \
 	if (FileEntry != NULL) \
  	  memset (FileEntry, 0, OCFS_SECTOR_SIZE); \
@@ -584,6 +762,7 @@
 			fe = NULL;					\
 		}							\
 	} while (0)
+#endif
 
 #define  OCFS_NAME              "OCFS"
 
@@ -602,7 +781,21 @@
 	})
 #endif
 
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
+#include <linux/iobuf.h>
+#endif /* for 2.5 - no more kiovec, kiobuf structures - vfs handles
+	* this for us (direct i/o) */
+#include <linux/sysctl.h>
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#include <linux/moduleparam.h>
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,18)
+#define free_kiovec_sz(nr, buf, bh)     free_kiovec(nr, buf)
+#define alloc_kiovec_sz(nr, buf, bh)    alloc_kiovec(nr, buf)
+#endif
+
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 typedef struct block_device * ocfs_blockdev;
 typedef dev_t ocfs_dev;
 #define OCFS_NODEV     0
@@ -620,6 +813,11 @@
 #define getblk(dev, blk, sz)	__getblk(dev, blk, sz)
 #endif /* >= 2.6.0  */
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
+#define OCFS_GENERIC_SB_MEMBER(sb)  ((sb)->s_fs_info)
+#else
+#define OCFS_GENERIC_SB_MEMBER(sb)  ((sb)->u.generic_sbp)
+#endif
 #define OCFS_SB(sb)	    ((ocfs_super *)OCFS_GENERIC_SB_MEMBER(sb))
 
 
@@ -643,6 +841,15 @@
 				DLOCK_FLAG_LAST_UPDATE)
 
 
+#define DISK_LOCK_CURRENT_MASTER(x)   ( ((ocfs_disk_lock *)x)->curr_master )
+#define DISK_LOCK_OIN_MAP(x)          ( ((ocfs_disk_lock *)x)->oin_node_map )
+#define DISK_LOCK_FILE_LOCK(x)        ( ((ocfs_disk_lock *)x)->file_lock )
+#define DISK_LOCK_LAST_READ(x)        ( ((ocfs_disk_lock *)x)->last_read_time )
+#define DISK_LOCK_LAST_WRITE(x)       ( ((ocfs_disk_lock *)x)->last_write_time )
+#define DISK_LOCK_READER_NODE(x)      ( ((ocfs_disk_lock *)x)->reader_node_num )
+#define DISK_LOCK_SEQNUM(x)           ( ((ocfs_disk_lock *)x)->dlock_seq_num )
+#define DISK_LOCK_WRITER_NODE(x)      ( ((ocfs_disk_lock *)x)->writer_node_num )
+
 #define MAX_VOL_ID_LENGTH		16
 #define MAX_VOL_LABEL_LEN		64
 #define MAX_CLUSTER_NAME_LEN		64
@@ -739,18 +946,18 @@
 }
 ocfs_vol_disk_hdr;				   // END CLASS
 
-typedef struct _ocfs_disk_lock
+typedef struct _ocfs_disk_lock			// CLASS
 {
-/*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*/	__u64 oin_node_map;	/* Bitmap of interested nodes */
-	__u64 odl_reserved[3];	/* Space for larger node map */
-/*20*/
+	__u32 curr_master;			// NODENUM
+	__u8 file_lock;				// LOCKLEVEL
+	__u64 last_write_time;			// NUMBER RANGE(0,ULONG_LONG_MAX
+	__u64 last_read_time;			// NUMBER RANGE(0,ULONG_LONG_MAX
+	__u32 writer_node_num;			// NODENUM
+	__u32 reader_node_num;			// NODENUM
+	__u64 oin_node_map;			// NODEBITMAP
+	__u64 dlock_seq_num;			// NUMBER RANGE(0,ULONG_LONG_MAX)
 }
-ocfs_disk_lock;
-
+ocfs_disk_lock;					// END CLASS
 typedef struct _ocfs_vol_label			 // CLASS
 {
 	ocfs_disk_lock disk_lock;                // DISKLOCK
@@ -799,9 +1006,9 @@
 	__u32 version;					// NUMBER RANGE(0,ULONG_MAX)
 	__u32 num_nodes;				// NUMBER RANGE(0,32)
 	__u32 last_node;				// NUMBER RANGE(0,32)
-	__u32 onch_pad;                                 // UNUSED
 	__u64 cfg_seq_num;				// NUMBER RANGE(0,ULONG_LONG_MAX)
 }
+OCFS_GCC_ATTR_PACKALGN
 ocfs_node_config_hdr;					// END CLASS
 
 typedef struct _BARF_BARF_BARF
@@ -967,12 +1174,9 @@
 /* is this a system file? */
 #define OCFS_INODE_SYSTEM_FILE      0x00000008
 
-#define OCFS_I(i)        ((ocfs_inode_private *)(i->u.generic_ip))
-
-#define DISK_LOCK(x)	((ocfs_disk_lock *)&(x)->disk_lock)
-
 #define GET_INODE_CLEAN_SEQ(i)  (atomic_t *)(&(OCFS_I(i)->i_clean_buffer_seq))
 
+#define OCFS_I(i)        ((ocfs_inode_private *)(i->u.generic_ip))
 
 #define INODE_DELETED(i) (OCFS_I(i)->flags & OCFS_INODE_DELETED)
 #define SET_INODE_DELETED(i) (OCFS_I(i)->flags |= OCFS_INODE_DELETED)
@@ -989,7 +1193,19 @@
 
 #define GET_INODE_FEOFF(i) OCFS_I(i)->feoff
 
+static inline unsigned long ino_from_fe_off(struct inode *inode)
+{
+	return (unsigned long)((GET_INODE_FEOFF(inode) >> 
+				inode->i_sb->s_blocksize_bits) & (__u64)ULONG_MAX);
+}
 
+static inline unsigned long ino_from_off(struct super_block *sb, __u64 off)
+{
+	return (unsigned long)((off >> sb->s_blocksize_bits) & (__u64)ULONG_MAX);
+}
+
+
+
 #warning take this out when all the lockres stuff checks out
 #define GET_INODE_LOCKRES(i) ({ if (i==NULL) BUG(); (&(OCFS_I(i)->i_lockres)); })
 
@@ -1231,6 +1447,9 @@
 	__u8 hbm;
 	spinlock_t comm_seq_lock;	/* protects comm_seq_num */
 	__u64 comm_seq_num;		/* local node seq num used in ipcdlm */
+#ifdef OCFS_LINUX_MEM_DEBUG
+	struct list_head item_list;
+#endif
 	struct list_head *bh_sem_hash;
 	spinlock_t bh_sem_hash_lock;
 	int bh_sem_hash_sz;
@@ -1296,15 +1515,17 @@
 	__s32 vote;                     // BOOL
 	__u32 dirty;                     // BOOL
 	__u32 vote_type;                  // FILEFLAG
-	__u32 mounted;                   /* used for journaling */
-	__u8 hbm[OCFS_MAXIMUM_NODES];	// UNUSED my ass
 	__u64 vote_map;                   // NODEBITMAP
 	__u64 publ_seq_num;               // NUMBER RANGE(0,ULONG_LONG_MAX)
 	__u64 dir_ent;                    // NUMBER RANGE(0,ULONG_LONG_MAX)
+	__u8 hbm[OCFS_MAXIMUM_NODES];    // UNUSED
 	/* last seq num used in comm voting */
 	__u64 comm_seq_num;		// NUMBER RANGE(0,ULONG_LONG_MAX)
+	__u32 mounted;                   /* used for journaling */
 	__u64 fe_off;                   /* needed to create inodes. */
-} ocfs_publish;				// END CLASS
+}
+OCFS_GCC_ATTR_PACKALGN
+ocfs_publish;				// END CLASS
 
 typedef struct _ocfs_vote		// CLASS
 {
@@ -1312,8 +1533,9 @@
 	__u64 vote_seq_num;              // NUMBER RANGE(0,ULONG_LONG_MAX)
 	__u64 dir_ent;                   // NUMBER RANGE(0,ULONG_LONG_MAX)
 	__u8 open_handle;                // BOOL
-	__u8 ov_pad[7]; 		// UNUSED
-} ocfs_vote;				// END CLASS
+}
+OCFS_GCC_ATTR_PACKALGN
+ocfs_vote;				// END CLASS
 
 typedef struct _ocfs_local_alloc
 {
@@ -1333,6 +1555,7 @@
 {
 	ocfs_disk_lock disk_lock;       // DISKLOCK
 	__u8 signature[8];              // CHAR[8]
+	__u32 local_ext;	        // BOOL
 	__u8 next_free_ext;             // NUMBER RANGE(0,OCFS_MAX_FILE_ENTRY_EXTENTS) 
 	__s8 next_del;                  // DIRNODEINDEX
 	__s32 granularity;	        // NUMBER RANGE(-1,3)
@@ -1363,12 +1586,44 @@
 			__u32 total_bits;
 		} bitinfo;
 	} u;
-	__u64 alloc_file_off;             // NUMBER RANGE(0,ULONG_LONG_MAX)
-	__u32 alloc_node;                 // NUMBER RANGE(0,31)
+        __u64 alloc_file_off;             // NUMBER RANGE(0,ULONG_LONG_MAX)
+        __u32 alloc_node;                 // NUMBER RANGE(0,31)
 /* sizeof(fe) = 508 bytes */
 }
 ocfs_file_entry;			  // END CLASS
 
+/* not sizeof-safe across platforms */
+typedef struct _ocfs_index_node
+{
+	__u64 down_ptr;
+	__u64 file_ent_ptr;
+	__u8 name_len;
+	__u8 name[1];
+}
+OCFS_GCC_ATTR_PACKALGN
+ocfs_index_node;
+
+typedef struct _ocfs_index_hdr
+{
+	ocfs_disk_lock disk_lock;
+	__u64 signature;
+	__s64 up_tree_ptr;	/* Pointer to parent of this dnode */
+	__u64 node_disk_off;
+	__u8 state;		/* In recovery, needs recovery etc */
+	__u64 down_ptr	OCFS_GCC_ATTR_ALIGNED;
+	__u8 num_ents;;		/* Number of extents in this Node */
+	__u8 depth;		/* Depth of this Node from root of the btree */
+	__u8 num_ent_used;	/* Num of entries in the dir blk used up. */
+	__u8 dir_node_flags;	/* Flags */
+	__u8 sync_flags;		/* Flags */
+	__u8 index[256];
+	__u8 reserved[161];
+	__u8 file_ent[1];	/* 63 entries here with 32K DIR_NODE size */
+}
+OCFS_GCC_ATTR_PACKED
+ocfs_index_hdr;
+
+
 typedef struct _ocfs_extent_group			// CLASS
 {
 	__u8 signature[8];				// CHAR ARRAY[8]
@@ -1392,14 +1647,23 @@
 }
 ocfs_extent_group;					// END CLASS
 
+typedef struct _ocfs_bitmap_lock
+{
+    ocfs_disk_lock disk_lock;
+    __u32 used_bits;
+}
+OCFS_GCC_ATTR_PACKALGN
+ocfs_bitmap_lock;
+
 typedef struct _ocfs_dlm_msg_hdr
 {
 	__u64 lock_id;
+	__u32 flags;
 	__u64 lock_seq_num;
-	__u32 flags;
 	__u8 open_handle;
-	__u8 odmh_pad[3];
-} ocfs_dlm_msg_hdr;
+} 
+OCFS_GCC_ATTR_PACKALGN
+ocfs_dlm_msg_hdr;
 
 typedef ocfs_dlm_msg_hdr ocfs_dlm_req_master;
 typedef ocfs_dlm_msg_hdr ocfs_dlm_disk_vote_req;
@@ -1493,6 +1757,15 @@
 }
 ocfs_recv_ctxt;
 
+typedef struct _ocfs_offset_map
+{
+	__u32 length;
+	__u64 log_disk_off;
+	__u64 actual_disk_off;
+}
+OCFS_GCC_ATTR_PACKALGN
+ocfs_offset_map;
+
 typedef struct _ocfs_cfg_task
 {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
@@ -1575,7 +1848,143 @@
 } 
 ocfs_bitmap_free_head;
 
+static inline ocfs_bitmap_free_head * ocfs_alloc_bitmap_free_head(void)
+{
+	struct _ocfs_bitmap_free_head *f;
 
+	f = ocfs_malloc(sizeof(ocfs_bitmap_free_head));
+	if (f) {
+		f->num_logs = 0;
+		f->tail = NULL;
+		INIT_LIST_HEAD(&(f->free_logs));
+	}
+	return(f);
+}
+
+static inline void ocfs_free_bitmap_free_head(ocfs_bitmap_free_head *f)
+{
+	ocfs_free_rec *log;
+	struct list_head *p, *n;
+
+	if ((f) && ((f)->num_logs)) {
+		list_for_each_safe(p, n, &((f)->free_logs)) {
+			log = list_entry(p, ocfs_free_rec, log_list);
+			list_del(&(log->log_list));
+			ocfs_free(log);
+		}
+	}
+	ocfs_safefree((f));
+	return;
+}
+
+static inline unsigned int ocfs_clusters_for_bytes(struct super_block *sb,
+						   __u64 bytes)
+{
+	int cl_bits = OCFS_SB(sb)->cluster_size_bits;
+	unsigned int clusters;
+
+	bytes += OCFS_SB(sb)->vol_layout.cluster_size - 1;
+	/* OCFS2 just cannot have enough clusters to overflow this */
+	clusters = (unsigned int)(bytes >> cl_bits);
+
+	return clusters;
+}
+
+static inline __u64 ocfs_align_bytes_to_clusters(struct super_block *sb,
+						 __u64 bytes)
+{
+	int cl_bits = OCFS_SB(sb)->cluster_size_bits;
+	unsigned int clusters;
+
+	clusters = ocfs_clusters_for_bytes(sb, bytes);
+	return (__u64)clusters << cl_bits;
+}
+
+static inline int ocfs_inc_icount(struct inode *inode)
+{
+	struct dentry *dentry = NULL;
+	struct list_head *iter;
+
+	if (atomic_read(&inode->i_count) >= 1 &&
+	    !(inode->i_state & I_CLEAR)) {
+		atomic_inc(&inode->i_count);
+		return 0;
+	}
+
+	list_for_each (iter, &(inode->i_dentry)) {
+		dentry = list_entry (iter, struct dentry, d_alias);
+		// what the heck, take the first one ;-)
+		break;
+	}
+
+	if (dentry)
+		LOG_ERROR_ARGS("eek! i_count=%d, i_state=%lu, i_ino=%lu, name='%*s'\n",
+			       atomic_read(&inode->i_count), inode->i_state, inode->i_ino,
+			       dentry->d_name.len, dentry->d_name.name);
+	else
+		LOG_ERROR_ARGS("eek! i_count=%d, i_state=%lu, i_ino=%lu, no dentry\n",
+			       atomic_read(&inode->i_count), inode->i_state, inode->i_ino);
+
+	LOG_ERROR_ARGS("feoff=%llu, deleted=%u\n", 
+		       GET_INODE_FEOFF(inode),
+		       INODE_DELETED(inode));
+	return -EINVAL;
+}
+
+#define ocfs_check_inode(inode)  __ocfs_check_inode(inode, __LINE__)
+
+/* call this right before an atomic_dec or iput. */
+static inline void __ocfs_check_inode(struct inode *inode, unsigned int line)
+{
+	struct dentry *dentry = NULL;
+	struct list_head *iter;
+	int max_cnt = 1; /* one for the inode hash */
+	ocfs_super *osb = NULL;
+	int is_root = 0;
+
+	if (!inode)
+		return;
+
+	osb = OCFS_SB(inode->i_sb);
+	if (inode->i_ino == OCFS_ROOT_INODE_NUMBER)
+		is_root = 1;
+
+	if (INODE_DELETED(inode))
+		max_cnt--;
+
+	list_for_each (iter, &(inode->i_dentry)) {
+		dentry = list_entry (iter, struct dentry, d_alias);
+		// what the heck, take the first one ;-)
+		break;
+	}
+
+	/* add one for the dentrys ref... */
+	if (dentry)
+		max_cnt++;
+
+	/* +1 for the ref you're about to remove. */
+	if (atomic_read(&inode->i_count) >= (max_cnt+1))
+		return;
+
+
+	LOG_ERROR_ARGS("max_cnt = %d, line = %u, root=%u\n", max_cnt, line, 
+		       is_root);
+	if (dentry)
+		LOG_ERROR_ARGS("eek! i_count=%d, i_state=%lu, i_ino=%lu, name='%*s'\n",
+			       atomic_read(&inode->i_count), inode->i_state, inode->i_ino,
+			       dentry->d_name.len, dentry->d_name.name);
+	else
+		LOG_ERROR_ARGS("eek! i_count=%d, i_state=%lu, i_ino=%lu, no dentry\n",
+			       atomic_read(&inode->i_count), inode->i_state, inode->i_ino);
+
+	LOG_ERROR_ARGS("feoff=%llu, deleted=%u\n", 
+		       GET_INODE_FEOFF(inode),
+		       INODE_DELETED(inode));
+
+	BUG();
+}
+
+
 struct ocfs_ioc
 {
 	char name[255];		/* "OCFS" */
@@ -1630,14 +2039,20 @@
 	[S_IFLNK >> S_SHIFT]    OCFS_FT_SYMLINK,
 };
 
+static inline void ocfs_set_de_type(struct super_block *sb, struct ocfs2_dir_entry *de, umode_t mode) {
+	de->file_type = ocfs_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
+}
 
+
+
 typedef struct _ocfs_find_inode_args
 {
 	__u64 feoff;
 	struct buffer_head *fe_bh;
 	unsigned long ino;
 	__u32 flags;
-} ocfs_find_inode_args;
+}
+ocfs_find_inode_args;
 
 #define OCFS_FIND_INODE_FLAG_SYSFILE              0x00000002
 
@@ -1646,7 +2061,8 @@
 	struct timer_list	timer;
 	int			timed_out;
 	wait_queue_head_t	wait;
-} ocfs_timeout;
+}
+ocfs_timeout;
 
 #define NAMEI_RA_CHUNKS  2
 #define NAMEI_RA_BLOCKS  4
@@ -1711,173 +2127,14 @@
 #define OCFS_FE_CACHE_FLAGS(__osb, __fe)				  \
 ({									  \
 	int __ret = 0;							  \
-	if ((DISK_LOCK(__fe)->file_lock  == OCFS_DLM_ENABLE_CACHE_LOCK) && \
-	    (DISK_LOCK(__fe)->curr_master == osb->node_num) &&          \
+	if ((DISK_LOCK_FILE_LOCK(__fe)  == OCFS_DLM_ENABLE_CACHE_LOCK) && \
+	    (DISK_LOCK_CURRENT_MASTER(__fe) == osb->node_num) &&          \
 	    (__fe->this_sector >= __osb->vol_layout.bitmap_off))          \
 		__ret = OCFS_BH_CACHED;				  	  \
 	__ret;								  \
 })
 
-static inline unsigned long ino_from_fe_off(struct inode *inode)
-{
-	__u64 block_off = GET_INODE_FEOFF(inode) >> inode->i_sb->s_blocksize_bits;
 
-	return (unsigned long)(block_off & (__u64)ULONG_MAX);
-}
-
-static inline unsigned long ino_from_off(struct super_block *sb,
-					 __u64 off)
-{
-	__u64 block_off = off >> sb->s_blocksize_bits;
-
-	return (unsigned long)(block_off & (__u64)ULONG_MAX);
-}
-
-static inline void ocfs_set_de_type(struct super_block *sb,
-				    struct ocfs2_dir_entry *de,
-				    umode_t mode)
-{
-	de->file_type = ocfs_type_by_mode[(mode & S_IFMT)>>S_SHIFT];
-}
-
-static inline ocfs_bitmap_free_head * ocfs_alloc_bitmap_free_head(void)
-{
-	struct _ocfs_bitmap_free_head *f;
-
-	f = ocfs_malloc(sizeof(ocfs_bitmap_free_head));
-	if (f) {
-		f->num_logs = 0;
-		f->tail = NULL;
-		INIT_LIST_HEAD(&(f->free_logs));
-	}
-	return(f);
-}
-
-static inline void ocfs_free_bitmap_free_head(ocfs_bitmap_free_head *f)
-{
-	ocfs_free_rec *log;
-	struct list_head *p, *n;
-
-	if ((f) && ((f)->num_logs)) {
-		list_for_each_safe(p, n, &((f)->free_logs)) {
-			log = list_entry(p, ocfs_free_rec, log_list);
-			list_del(&(log->log_list));
-			kfree(log);
-		}
-	}
-	ocfs_safefree((f));
-	return;
-}
-
-static inline unsigned int ocfs_clusters_for_bytes(struct super_block *sb,
-						   __u64 bytes)
-{
-	int cl_bits = OCFS_SB(sb)->cluster_size_bits;
-	unsigned int clusters;
-
-	bytes += OCFS_SB(sb)->vol_layout.cluster_size - 1;
-	/* OCFS2 just cannot have enough clusters to overflow this */
-	clusters = (unsigned int)(bytes >> cl_bits);
-
-	return clusters;
-}
-
-static inline __u64 ocfs_align_bytes_to_clusters(struct super_block *sb,
-						 __u64 bytes)
-{
-	int cl_bits = OCFS_SB(sb)->cluster_size_bits;
-	unsigned int clusters;
-
-	clusters = ocfs_clusters_for_bytes(sb, bytes);
-	return (__u64)clusters << cl_bits;
-}
-
-static inline int ocfs_inc_icount(struct inode *inode)
-{
-	struct dentry *dentry = NULL;
-	struct list_head *iter;
-
-	if (atomic_read(&inode->i_count) >= 1 &&
-	    !(inode->i_state & I_CLEAR)) {
-		atomic_inc(&inode->i_count);
-		return 0;
-	}
-
-	list_for_each (iter, &(inode->i_dentry)) {
-		dentry = list_entry (iter, struct dentry, d_alias);
-#warning This cant be right in the land of hardlinks, can it?
-		// what the heck, take the first one ;-)
-		break;
-	}
-
-	if (dentry)
-		LOG_ERROR_ARGS("eek! i_count=%d, i_state=%lu, i_ino=%lu, name='%*s'\n",
-			       atomic_read(&inode->i_count), inode->i_state, inode->i_ino,
-			       dentry->d_name.len, dentry->d_name.name);
-	else
-		LOG_ERROR_ARGS("eek! i_count=%d, i_state=%lu, i_ino=%lu, no dentry\n",
-			       atomic_read(&inode->i_count), inode->i_state, inode->i_ino);
-
-	LOG_ERROR_ARGS("feoff=%llu, deleted=%u\n", 
-		       GET_INODE_FEOFF(inode),
-		       INODE_DELETED(inode));
-	return -EINVAL;
-}
-
-#define ocfs_check_inode(inode)  __ocfs_check_inode(inode, __LINE__)
-
-/* call this right before an atomic_dec or iput. */
-static inline void __ocfs_check_inode(struct inode *inode, unsigned int line)
-{
-	struct dentry *dentry = NULL;
-	struct list_head *iter;
-	int max_cnt = 1; /* one for the inode hash */
-	ocfs_super *osb = NULL;
-	int is_root = 0;
-
-	if (!inode)
-		return;
-
-	osb = OCFS_SB(inode->i_sb);
-	if (inode->i_ino == OCFS_ROOT_INODE_NUMBER)
-		is_root = 1;
-
-	if (INODE_DELETED(inode))
-		max_cnt--;
-
-	list_for_each (iter, &(inode->i_dentry)) {
-		dentry = list_entry (iter, struct dentry, d_alias);
-		// what the heck, take the first one ;-)
-		break;
-	}
-
-	/* add one for the dentrys ref... */
-	if (dentry)
-		max_cnt++;
-
-	/* +1 for the ref you're about to remove. */
-	if (atomic_read(&inode->i_count) >= (max_cnt+1))
-		return;
-
-
-	LOG_ERROR_ARGS("max_cnt = %d, line = %u, root=%u\n", max_cnt, line, 
-		       is_root);
-	if (dentry)
-		LOG_ERROR_ARGS("eek! i_count=%d, i_state=%lu, i_ino=%lu, name='%*s'\n",
-			       atomic_read(&inode->i_count), inode->i_state, inode->i_ino,
-			       dentry->d_name.len, dentry->d_name.name);
-	else
-		LOG_ERROR_ARGS("eek! i_count=%d, i_state=%lu, i_ino=%lu, no dentry\n",
-			       atomic_read(&inode->i_count), inode->i_state, inode->i_ino);
-
-	LOG_ERROR_ARGS("feoff=%llu, deleted=%u\n", 
-		       GET_INODE_FEOFF(inode),
-		       INODE_DELETED(inode));
-
-	BUG();
-}
-
-
 static inline int ocfs_is_local_cache_lock(ocfs_super *osb, struct inode *inode)
 {
 	ocfs_lock_res *lockres = GET_INODE_LOCKRES(inode);
@@ -1921,5 +2178,6 @@
 typedef struct _ocfs_journal_handle ocfs_journal_handle;
 
 #include "proto.h"
+#include "io.h"
 
 #endif /* !OCFS_H */

Deleted: trunk/src/inc/ocfs_buffer_head.h
===================================================================
--- trunk/src/inc/ocfs_buffer_head.h	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/inc/ocfs_buffer_head.h	2004-06-02 20:52:44 UTC (rev 976)
@@ -1,370 +0,0 @@
-/*
- * ocfs_buffer_head.h
- *
- * Buffer cache handling functions defined
- *
- * Copyright (C) 2002, 2004 Oracle.  All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Mark Fasheh, Sunil Mushran, Wim Coekaerts,
- *	    Manish Singh
- */
-
-#ifndef OCFSIO_H
-#define OCFSIO_H
-
-#include <linux/compiler.h>
-
-/* UGLY place to put it, but it is for the best */
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-# include <linux/locks.h>
-#else
-# include <linux/buffer_head.h>
-#endif
-
-/* Yosh made me do it. */
-static inline int ocfs_write_bh  (ocfs_super          *osb, 
-				  struct buffer_head  *bh, 
-				  int                  flags, 
-				  struct inode        *inode);
-static inline int ocfs_read_bh   (ocfs_super          *osb, 
-				  __u64                off, 
-				  struct buffer_head **bh, 
-				  int                  flags, 
-				  struct inode        *inode);
-
-int ocfs_write_bhs (ocfs_super          *osb,
-		    struct buffer_head  *bh[], 
-		    int                  nr, 
-		    int                  flags, 
-		    struct inode        *inode);
-int ocfs_read_bhs  (ocfs_super          *osb, 
-		    __u64                off,
-		    __u64                len, 
-		    struct buffer_head  *bhs[], 
-		    int                  flags, 
-		    struct inode         *inode);
-
-
-#define OCFS_BH_CACHED            1
-#define OCFS_BH_COND_CACHED       2
-#define OCFS_BH_CONCURRENT_WRITE  4     /* This should only be used by ocfs_worker */
-#define OCFS_BH_IGNORE_JBD        8     /* This should only be used by ocfs_checkpoint_handle! */
-#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)
-/* 
- * BUFFER_FNS is the new marcro magic intruduced in 2.5.x kernel for defining
- * set_buffer_XXX, clear_buffer_XXX, and buffer_XXX functions
- */
-BUFFER_FNS(Modified, modified)
-
-#else /* 2.4.x kernel */
-
-/*
- * Copied right out of the 2.6.2 kernel's buffer_head.h:
- * macro tricks to expand the set_buffer_foo(), clear_buffer_foo()
- * and buffer_foo() functions.
- */
-#define BUFFER_FNS(bit, name)						\
-static inline void set_buffer_##name(struct buffer_head *bh)		\
-{									\
-	set_bit(BH_##bit, &(bh)->b_state);				\
-}									\
-static inline void clear_buffer_##name(struct buffer_head *bh)		\
-{									\
-	clear_bit(BH_##bit, &(bh)->b_state);				\
-}									\
-static inline int buffer_##name(struct buffer_head *bh)			\
-{									\
-	return test_bit(BH_##bit, &(bh)->b_state);			\
-}
-
-#undef buffer_uptodate
-#undef buffer_dirty
-BUFFER_FNS(Uptodate, uptodate)
-BUFFER_FNS(Modified, modified)
-BUFFER_FNS(Dirty, dirty)
-
-#endif /* 2.4.x kernel */
-
-static inline void * OCFS_BH_GET_DATA_READ(struct buffer_head *bh)
-{
-	unsigned char *kaddr;
-	
-	OCFS_ASSERT(bh);
-
-	if (!bh->b_blocknr) {
-		printk("%d: warning trying to OCFS_BH_GET_DATA_READ block zero!\n", current->pid);
-		ocfs_show_stack(NULL);
-	}		
-
-	while (1) {
-		if (ocfs_bh_sem_lock(bh) == OCFS_BH_SEM_WAIT_ON_MODIFY) {
-			ocfs_bh_sem_unlock(bh);
-			wait_on_buffer_modified(bh);
-		} else {
-			break;
-		}
-	}
-
-	kaddr = kmap(bh->b_page);
-	kaddr += ((unsigned long)bh->b_data & ~PAGE_MASK);
-
-	return kaddr;
-}
-
-
-/* BH_SEM_DEBUG needs these to be macros to get at __LINE__ and such */
-
-#ifdef BH_SEM_DEBUG
-#define OCFS_BH_GET_DATA_WRITE(bh) ({ \
-	unsigned char *kaddr; \
-	while (1) { \
-		if (ocfs_bh_sem_lock_modify(bh) == OCFS_BH_SEM_WAIT_ON_MODIFY) { \
-			ocfs_bh_sem_unlock(bh); \
-			wait_on_buffer_modified(bh); \
-		} else \
-			break; \
-	} \
-	kaddr = (kmap((bh)->b_page)) + ((unsigned long)(bh)->b_data & ~PAGE_MASK); \
-	kaddr; \
-})
-
-#define OCFS_BH_GET_DATA_WRITE_TRYLOCK(bh)  \
-({  \
-	unsigned char *kaddr;  \
-	if (ocfs_bh_sem_lock_modify(bh) == OCFS_BH_SEM_WAIT_ON_MODIFY) {  \
-		ocfs_bh_sem_unlock(bh);  \
-		return NULL;  \
-	}  \
-	kaddr = kmap((bh)->b_page);  \
-	kaddr += ((unsigned long)(bh)->b_data & ~PAGE_MASK);  \
-	kaddr;  \
-})
-#else
-static inline void * OCFS_BH_GET_DATA_WRITE(struct buffer_head *bh)
-{
-	unsigned char *kaddr;
-
-	OCFS_ASSERT(bh);
-
-	if (!bh->b_blocknr) {
-		printk("%d: trying to OCFS_BH_GET_DATA_WRITE block zero!\n", current->pid);
-		BUG();
-	}		
-
-	while (1) {
-		if (ocfs_bh_sem_lock_modify(bh) == OCFS_BH_SEM_WAIT_ON_MODIFY) {
-#ifdef VERBOSE_BH_SEM
-			printk("ocfs2: called getdata for write but "
-			       "this process is not the lock "
-			       "holder!\n");
-#endif
-			ocfs_bh_sem_unlock(bh);
-			wait_on_buffer_modified(bh);
-		} else {
-			break;
-		}
-	}
-
-	kaddr = kmap(bh->b_page);
-	kaddr += ((unsigned long)bh->b_data & ~PAGE_MASK);
-
-	return kaddr;
-}
-
-static inline void * OCFS_BH_GET_DATA_WRITE_TRYLOCK(struct buffer_head *bh)
-{
-	unsigned char *kaddr;
-
-	OCFS_ASSERT(bh);
-
-	if (!bh->b_blocknr) {
-		printk("%d: trying to OCFS_BH_GET_DATA_WRITE_TRYLOCK block zero!\n", current->pid);
-		BUG();
-	}		
-
-	if (ocfs_bh_sem_lock_modify(bh) == OCFS_BH_SEM_WAIT_ON_MODIFY) {
-#ifdef VERBOSE_BH_SEM
-		printk("ocfs2: called getdata for write but "
-		       "this process is not the lock "
-		       "holder!\n");
-#endif
-		ocfs_bh_sem_unlock(bh);
-		return NULL;
-	}
-
-	kaddr = kmap(bh->b_page);
-	kaddr += ((unsigned long)bh->b_data & ~PAGE_MASK);
-
-	return kaddr;
-}
-
-#endif
-
-
-
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#define BH_GET_DEVICE(bh) ((bh->b_bdev)->bd_dev)
-#else
-#define BH_GET_DEVICE(bh) (bh->b_dev)
-#endif
-
-static inline void OCFS_BH_PUT_DATA(struct buffer_head *bh)
-{
-	OCFS_ASSERT(bh);
-
-	kunmap(bh->b_page);
-	ocfs_bh_sem_unlock(bh);
-}
-
-#define STATE_BH_BITS	8
-#define USED_BH_BITS	23 /* Number of BH bits used up through JBD */
-
-#define STATE_BIT_MAX           (1 << STATE_BH_BITS)
-#define STATE_BIT_MAX_MASK      ((1 << STATE_BH_BITS)-1)
-#define STATE_BIT_MASK		((~0UL) << USED_BH_BITS)
-
-
-static inline void CLEAR_BH_SEQNUM(struct buffer_head *bh)
-{
-	unsigned int prev = bh->b_state & STATE_BIT_MASK;
-	bh->b_state &= ~prev;
-}
-
-static inline void SET_BH_SEQNUM(struct inode *inode, struct buffer_head *bh)
-{
-	unsigned int seq = (atomic_read(GET_INODE_CLEAN_SEQ(inode)) & 
-			    STATE_BIT_MAX_MASK) << USED_BH_BITS;
-
-	CLEAR_BH_SEQNUM(bh);
-	bh->b_state |= seq;
-}
-
-static inline int TEST_BH_SEQNUM(struct inode *inode, struct buffer_head *bh)
-{
-	int ret;
-	unsigned int seq =
-		(bh->b_state & STATE_BIT_MASK) >> USED_BH_BITS;
-
-	ret = (seq == atomic_read(GET_INODE_CLEAN_SEQ(inode)));
-	return ret;
-}
-
-static inline int check_block_zero_write(struct buffer_head *bh)
-{
-	if (unlikely(bh->b_blocknr == 0)) {
-		ocfs_vol_disk_hdr *hdr = OCFS_BH_GET_DATA_READ(bh);
-
-		if (hdr == NULL) {
-			printk ("ocfs2: failed to map bh page!!!\n");
-			return -EIO;
-		}
-
-		if (memcmp(hdr->signature, 
-			   OCFS_VOLUME_SIGNATURE, 
-			   strlen(OCFS_VOLUME_SIGNATURE)) != 0) {
-			printk("ocfs2: WARNING! attempting to write non "
-			       "volume header to block 0\n");
-			OCFS_BH_PUT_DATA(bh);
-			return -EIO;
-		}
-
-		OCFS_BH_PUT_DATA(bh);
-	}
-
-	return 0;
-}
-
-#define OCFS_PRINT_FE_SIZE(bh)						      \
-do {									      \
-	if (bh) {							      \
-		ocfs_file_entry *__fe = bh->b_data;			      \
-		if (IS_VALID_FILE_ENTRY(__fe)) {			      \
-			printk("ocfs2: %s:%d fe_check: file_size = (%llu), "  \
-				"this_sector = (%llu)\n",		      \
-				__FUNCTION__, __LINE__, 		      \
-				__fe->file_size,			      \
-				__fe->this_sector);			      \
-		}							      \
-	}								      \
-} while(0)
-
-/* check the 1st five bytes. */
-static inline int ocfs_poison(struct buffer_head *bh)
-{
-	int i;
-	for(i = 0; i < 512; i++)
-		if ((bh)->b_data[i] != 'P')
-			return(0);
-	return(1);
-}
-
-#define OCFS_DO_HEX_DUMP(bh)						      \
-do {									      \
-	printk("bh->b_blocknr = %lu, bh->b_data:\n", bh->b_blocknr);	      \
-	for(i = 0; i < 512; i++) {					      \
-		printk("%03x ", bh->b_data[i]);				      \
-		if ( ((i+1) % 16) == 0 )				      \
-		printk("\n");						      \
-	}								      \
-	printk("\n");							      \
-} while (0)
-
-static inline int ocfs_write_bh (ocfs_super * osb, struct buffer_head *bh, 
-				 int flags, struct inode *inode)
-{
-	int status;
-	
-	IO_FUNC_TIMING_DECL
-
-	status = ocfs_write_bhs (osb, &bh, 1, flags, inode);
-
-	IO_FUNC_TIMING_PRINT("ocfs_write_bh", status);
-
-	return status;
-}
-
-static inline int ocfs_read_bh (ocfs_super * osb, __u64 off, 
-				struct buffer_head **bh, int flags, 
-				struct inode *inode)
-{
-	int status = 0;
-
-	IO_FUNC_TIMING_DECL
-
-	if (bh == NULL) {
-		printk("ocfs2: bh == NULL\n");
-		status = -EINVAL;
-		goto bail;
-	}
-	
-	status = ocfs_read_bhs(osb, off, 512, bh, flags, inode);
-
-bail:
-	IO_FUNC_TIMING_PRINT("ocfs_read_bh", status);
-
-	return status;
-}
-
-#endif /* OCFSIO_H */

Deleted: trunk/src/inc/ocfs_compat.h
===================================================================
--- trunk/src/inc/ocfs_compat.h	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/inc/ocfs_compat.h	2004-06-02 20:52:44 UTC (rev 976)
@@ -1,62 +0,0 @@
-/*
- * ocfs_compat.h
- *
- * Compatibility stuff for 2.4
- *
- * Copyright (C) 2004 Oracle.  All rights reserved.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public
- * License as published by the Free Software Foundation, version
- * 2 of the License.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 021110-1307, USA.
- *
- * Authors: Kurt Hackel, Mark Fasheh, Sunil Mushran, Wim Coekaerts,
- *	    Manish Singh, Neeraj Goyal, Suchit Kaura
- */
-
-#ifndef OCFS_COMPAT_H
-#define OCFS_COMPAT_H
-
-#include <linux/version.h>
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-
-#ifdef __ia64__
-extern inline void prefetch(const void *x);
-extern inline void prefetchw(const void *x);
-#else
-static inline void prefetch(const void *x);
-static inline void prefetchw(const void *x);
-#endif
-extern inline int generic_fls(int x);
-extern inline int get_bitmask_order(unsigned int count);
-/* XXX Hack to avoid warning */
-struct mem_dqinfo;
-extern inline void mark_info_dirty(struct mem_dqinfo *info);
-
-#define OCFS_GENERIC_SB_MEMBER(sb)  ((sb)->u.generic_sbp)
-
-#define OCFS_CURRENT_TIME   (CURRENT_TIME)
-#define OCFS_SET_INODE_TIME(i, x, y)   i->x = (y)
-
-#else /* LINUX_VERSION_CODE < 2.6 */
-
-#define OCFS_GENERIC_SB_MEMBER(sb)  ((sb)->s_fs_info)
-
-#define OCFS_CURRENT_TIME   (CURRENT_TIME.tv_sec)
-#define OCFS_SET_INODE_TIME(i, x, y)   (i->x.tv_sec = (y))
-
-#endif  /* LINUX_VERSION_CODE < 2.6 */
-
-#endif  /* OCFS_COMPAT_H */
-

Modified: trunk/src/inc/ocfs_journal.h
===================================================================
--- trunk/src/inc/ocfs_journal.h	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/inc/ocfs_journal.h	2004-06-02 20:52:44 UTC (rev 976)
@@ -166,9 +166,9 @@
 	while (handle->num_co) {
 		handle->num_co--;
 		if (handle->co_buffs[handle->num_co].data)
-			kfree(handle->co_buffs[handle->num_co].data);
+			ocfs_free(handle->co_buffs[handle->num_co].data);
 	}
-	kfree(handle->co_buffs);
+	ocfs_free(handle->co_buffs);
 	handle->co_buffs = NULL;
 }
 

Modified: trunk/src/inc/ocfs_log.h
===================================================================
--- trunk/src/inc/ocfs_log.h	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/inc/ocfs_log.h	2004-06-02 20:52:44 UTC (rev 976)
@@ -89,7 +89,7 @@
 		rdtsc (end.lohi[0], end.lohi[1]);			      \
 		IF_LEVEL_NO_CONTEXT(OCFS_DEBUG_LEVEL_TIMING)		      \
 			printk("(%d) EXIT : %s() = %d  => [%llu]\n",	      \
-				current->pid, _fn, _ret,		      \
+				ocfs_getpid(), _fn, _ret,		      \
 				end.q-begin.q);			      \
 	} while(0)		      
 #else
@@ -102,12 +102,12 @@
 #define DECL_U8_ARRAY(__t, __s)
 #define INIT_U8_ARRAY(__s)
 #define PRINT_STRING(__t)		printk("\n");
-#define PRINT_ENTRY(__t)		printk("(%d) ENTRY: %s", current->pid, __FUNCTION__)
+#define PRINT_ENTRY(__t)		printk("(%d) ENTRY: %s", ocfs_getpid (), __FUNCTION__)
 #else
 #define DECL_U8_ARRAY(__t, __s)		__u8 (__t)[(__s)]
 #define INIT_U8_ARRAY(__s)		*(__s) = '\0'
 #define PRINT_STRING(__t)		printk("%s\n", (__t))
-#define PRINT_ENTRY(__t)		printk("(%d) %sENTRY: %s", current->pid, (__t), __FUNCTION__)
+#define PRINT_ENTRY(__t)		printk("(%d) %sENTRY: %s", ocfs_getpid (), (__t), __FUNCTION__)
 #endif
 
 
@@ -127,9 +127,9 @@
 /* privately used macros */
 # define IF_LEVEL(level)	\
 	if ((debug_context & OCFS_DEBUG_CONTEXT) && (debug_level & level) && \
-	    current->pid!=debug_exclude)
+	    ocfs_getpid()!=debug_exclude)
 # define IF_LEVEL_NO_CONTEXT(level)	\
-	if ((debug_level & level) &&  current->pid!=debug_exclude)
+	if ((debug_level & level) &&  ocfs_getpid()!=debug_exclude)
 	
 #ifndef OCFS_DBG_TIMING
 # define ENTRY_TIMING_DECLS
@@ -164,7 +164,7 @@
 
 #define IF_LEVEL_PID()						\
 	if ((debug_level & OCFS_DEBUG_LEVEL_PRINTK) && 		\
-	    (current->pid!=debug_exclude))
+	    (ocfs_getpid()!=debug_exclude))
 
 static inline void eat_value_int(int val)
 {
@@ -218,7 +218,7 @@
 #define LOG_PID_PRINTK(fmt, arg...) 					\
 	do {								\
 		IF_LEVEL_PID() {					\
-			printk("(%d) %s(): ", current->pid, 		\
+			printk("(%d) %s(): ", ocfs_getpid(), 		\
 			       __FUNCTION__); 				\
 			printk(fmt, ## arg);				\
 		}							\
@@ -259,7 +259,7 @@
 			INIT_U8_ARRAY(_t);				\
 			GET_TIMING(_t, _HI, _LO);			\
 			printk("(%d) EXIT : %s() %s", 			\
-			       current->pid, __FUNCTION__, 		\
+			       ocfs_getpid (), __FUNCTION__, 		\
 			       (*fmt == '\n' ? "" : "= "));		\
 			if (*fmt != '\n')					\
 				printk(fmt, ## arg);			\
@@ -284,7 +284,7 @@
 #define LOG_TRACE_ARGS(fmt, arg...)					\
 	do {								\
 		IF_LEVEL(OCFS_DEBUG_LEVEL_TRACE) {			\
-			printk("(%d) TRACE: %s() ", current->pid,	\
+			printk("(%d) TRACE: %s() ", ocfs_getpid (),	\
 			       __FUNCTION__);				\
 			printk(fmt, ## arg);				\
 		}							\
@@ -304,7 +304,7 @@
  */
 #define LOG_ERROR_ARGS(fmt, arg...)					\
 	do {								\
-		printk(KERN_ERR "(%d) ERROR at %s, %d: ", current->pid, __FILE__, __LINE__);        \
+		printk(KERN_ERR "(%d) ERROR at %s, %d: ", ocfs_getpid (), __FILE__, __LINE__);        \
 		printk(fmt, ## arg);					\
 	} while (0)
 

Modified: trunk/src/inode.c
===================================================================
--- trunk/src/inode.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/inode.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,31 +24,14 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-#include <linux/pagemap.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
 #include "inc/ocfs_journal.h"
-#include "inc/ocfs_buffer_head.h"
 
 #define OCFS_DEBUG_CONTEXT    OCFS_DEBUG_CONTEXT_INODE
 
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
-# include <linux/iobuf.h>
-# if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,18)
-#  define free_kiovec_sz(nr, buf, bh)     free_kiovec(nr, buf)
-#  define alloc_kiovec_sz(nr, buf, bh)    alloc_kiovec(nr, buf)
-# endif
-#endif /* for 2.6 - no more kiovec, kiobuf structures - vfs handles
-	* this for us (direct i/o) */
-
-
 extern struct semaphore recovery_list_sem;
 
 static int ocfs_readpage (struct file *file, struct page *page);
@@ -413,7 +396,7 @@
 
 	OCFS_I(inode)->alloc_size = fe->alloc_size;
 	OCFS_I(inode)->inode = inode;
-	OCFS_I(inode)->chng_seq_num = DISK_LOCK(fe)->dlock_seq_num;
+	OCFS_I(inode)->chng_seq_num = DISK_LOCK_SEQNUM (fe);
 	OCFS_I(inode)->u.fe_private = fe->u.fe_private;
 
 	if (fe->attribs & OCFS_ATTRIB_DIRECTORY)
@@ -1844,7 +1827,7 @@
 
 	if ((OCFS_I(inode)->alloc_size != (__s64) fe->alloc_size) ||
 	    (inode->i_size != (__s64) fe->file_size) ||
-	    (OCFS_I(inode)->chng_seq_num != DISK_LOCK(fe)->dlock_seq_num) ||
+	    (OCFS_I(inode)->chng_seq_num != DISK_LOCK_SEQNUM (fe)) ||
 	    inode->i_uid != fe->uid ||
 	    inode->i_gid != fe->gid || 
 	    inode->i_mode != fe->prot_bits ||
@@ -1860,7 +1843,7 @@
 		inode->i_size = fe->file_size;
 printk("verifyupdate: setting nlink from %d to %d for %llu\n", inode->i_nlink, fe->link_cnt, GET_INODE_FEOFF(inode));
 		inode->i_nlink = fe->link_cnt;
-		OCFS_I(inode)->chng_seq_num = DISK_LOCK(fe)->dlock_seq_num;
+		OCFS_I(inode)->chng_seq_num = DISK_LOCK_SEQNUM (fe);
 		inode->i_blocks = (inode->i_size + osb->sect_size) >> osb->sect_size_bits;
 		inode->i_uid = fe->uid;
 		inode->i_gid = fe->gid;
@@ -1872,7 +1855,7 @@
 		if (!S_ISDIR (inode->i_mode) &&
 		    (OCFS_I(inode)->alloc_size != (__s64) fe->alloc_size ||
 		     inode->i_size != (__s64) fe->file_size ||
-		     OCFS_I(inode)->chng_seq_num != DISK_LOCK(fe)->dlock_seq_num)) {
+		     OCFS_I(inode)->chng_seq_num != DISK_LOCK_SEQNUM (fe))) {
 			*needs_trunc = 1;
 		}
 
@@ -1926,7 +1909,7 @@
 			break;
 		}
 
-		if (fe->granularity < 0) {
+		if (fe->local_ext) {
 			__s64 tempVbo;
 			__s64 tempLbo;
 			__u64 tempSize;

Copied: trunk/src/io.c (from rev 963, trunk/src/io.c)
===================================================================
--- trunk/src/io.c	2004-06-01 23:13:15 UTC (rev 963)
+++ trunk/src/io.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -0,0 +1,340 @@
+/*
+ * io.c
+ *
+ * Buffer cache handling
+ *
+ * Copyright (C) 2002, 2004 Oracle.  All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 021110-1307, USA.
+ *
+ * Authors: Kurt Hackel, Mark Fasheh, Sunil Mushran, Wim Coekaerts,
+ *	    Manish Singh, Neeraj Goyal, Suchit Kaura
+ */
+
+#include <linux/types.h>
+
+#include "inc/ocfs_log.h"
+#include "inc/ocfs.h"
+#include "inc/ocfs_journal.h"
+
+#define OCFS_DEBUG_CONTEXT    OCFS_DEBUG_CONTEXT_IO
+
+static void ocfs_end_buffer_io_sync(struct buffer_head *bh,
+                                    int uptodate)
+{
+//	LOG_ENTRY_ARGS("(bh->b_blocknr = %u, uptodate = %d)\n", bh->b_blocknr,
+//		       uptodate);
+
+	if (!uptodate)
+		LOG_ERROR_STATUS(-EIO);
+
+	if (uptodate)
+		set_buffer_uptodate(bh);
+	else
+		clear_buffer_uptodate(bh);
+	unlock_buffer(bh);
+
+//	LOG_EXIT();
+	return;
+}
+
+
+int ocfs_write_bhs (ocfs_super * osb, struct buffer_head *bhs[], 
+				  int nr, int flags, struct inode *inode)
+{
+	int status = 0;
+	int i;
+	struct super_block *sb;
+	ocfs_blockdev dev;
+	struct buffer_head *bh;
+
+#ifdef OCFS_DBG_TIMING
+	my_timing_t begin, end; 
+#endif
+	
+	LOG_ENTRY_ARGS("(bh[0]->b_blocknr = %lu, nr=%d, flags=%u, inode=%p)\n", 
+		       bhs[0]->b_blocknr, nr, flags, inode);
+#ifdef OCFS_DBG_TIMING
+	rdtsc (begin.lohi[0], begin.lohi[1]);
+#endif
+
+	if (osb == NULL || osb->sb == NULL || bhs == NULL) {
+		LOG_TRACE_STR("osb == NULL || osb->sb == NULL || bhs == "
+		       "NULL");
+		status = -EINVAL;
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
+
+	if (nr > 256)
+		LOG_TRACE_ARGS ("Getting write for %d blocks\n", nr);
+
+	sb = osb->sb;
+	dev = OCFS_GET_BLOCKDEV(sb);
+
+	/* we don't ever want cached writes -- those should go to the
+	 * journal so we can control when they actually hit disk and
+	 * so we can make sure they never get overwritten by a
+	 * subsequent read. */
+	if ((flags & OCFS_BH_CACHED) || (flags & OCFS_BH_COND_CACHED)) {
+		LOG_TRACE_STR("asking for a cached write!");
+		status = -EINVAL;
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
+
+	for (i = 0 ; i < nr ; i++) {
+		bh = bhs[i];
+		if (bh == NULL) {
+			LOG_TRACE_STR("bh == NULL");
+			status = -EIO;
+			LOG_ERROR_STATUS(status);
+			goto bail;
+		}
+
+		if (check_block_zero_write(bh) < 0) {
+			status = -EIO;	
+			LOG_ERROR_STATUS(status);
+			goto bail;
+		}
+
+		if (flags & OCFS_BH_CONCURRENT_WRITE)
+			goto skip_modified_check;
+
+		/* Make sure the buffer is locked for modify, and
+		 * we're the ones with the write lock on this
+		 * buffer. */
+		if (!buffer_modified(bh)) {
+			printk("ocfs2: modified bit is NOT set on buffer "
+			       "(bh->b_blocknr = %lu)!\n", bh->b_blocknr);
+			BUG();
+		}
+		if (ocfs_bh_sem_lock_modify(bh) == OCFS_BH_SEM_WAIT_ON_MODIFY){
+			printk("ocfs2: someone else owns this buffer"
+			       "(bh->b_blocknr = %lu)!\n", bh->b_blocknr);
+			BUG();
+		}
+		ocfs_bh_sem_unlock(bh);
+
+skip_modified_check:
+		if (!(flags & OCFS_BH_IGNORE_JBD) && buffer_jbd(bh)) {
+#ifdef VERBOSE_BH_JBD_TRACE
+			LOG_TRACE_ARGS("trying to write a jbd managed bh "
+				       "(blocknr = %lu), nr=%d\n", 
+				       bh->b_blocknr, nr);
+#endif
+			continue;
+		}
+
+		lock_buffer(bh);
+
+		set_buffer_uptodate(bh);
+		/* remove from dirty list before I/O. */
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)		
+		/*
+		 * mark_buffer_clean() doesn't exist in 2.6.x kernels.
+		 * Not many places actually used mark_buffer_clean, but
+		 * at least reiserfs uses clear_buffer_dirty() as
+		 * a replacment.
+		 */
+		clear_buffer_dirty(bh);
+#else
+		mark_buffer_clean(bh);
+#endif
+
+		bh->b_end_io = ocfs_end_buffer_io_sync;
+		submit_bh(WRITE, bh);
+	}
+
+	for (i = (nr-1) ; i >= 0; i--) {
+		bh = bhs[i];
+
+		wait_on_buffer(bh);
+
+		if (inode)
+			SET_BH_SEQNUM(inode, bh);
+		else
+			CLEAR_BH_SEQNUM(bh);
+
+		if (!(flags & OCFS_BH_CONCURRENT_WRITE) 
+		    && (!buffer_jbd(bh) || (flags & OCFS_BH_IGNORE_JBD)))
+			ocfs_clear_buffer_modified(bh);
+	}
+	
+bail:
+
+#ifdef OCFS_DBG_TIMING
+	IO_FUNC_TIMING_PRINT("ocfs_write_bhs", status);
+#endif
+
+	LOG_EXIT_STATUS(status);
+	return status;
+}
+
+/*
+ * ocfs_read_bhs()
+ *
+ */
+int ocfs_read_bhs (ocfs_super * osb, __u64 off, __u64 len, 
+				 struct buffer_head *bhs[], int flags, 
+				 struct inode *inode)
+{
+	int status = 0;
+	struct super_block *sb;
+	int nr, i, ignore_cache = 0;
+	__u64 blocknum;
+	ocfs_blockdev dev;
+	struct buffer_head *bh;
+
+#ifdef OCFS_DBG_TIMING
+	my_timing_t begin, end; 
+#endif
+	LOG_ENTRY_ARGS("(off=(%llu), len=(%llu), flags=%d, inode=%p)\n", off, 
+		       len, flags, inode);
+#ifdef OCFS_DBG_TIMING
+	rdtsc (begin.lohi[0], begin.lohi[1]);
+#endif
+
+	if (len % 512) {
+		LOG_TRACE_ARGS("len %% 512 (len=%llu)\n", len);
+		status = -EINVAL;
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
+
+	if (osb == NULL || osb->sb == NULL || bhs == NULL) {
+		LOG_TRACE_STR("osb == NULL || osb->sb == NULL || bhs == NULL "
+			      "|| num == NULL");
+		status = -EINVAL;
+		LOG_ERROR_STATUS(status);
+		goto bail;
+	}
+
+	if ((flags & OCFS_BH_COND_CACHED) && 
+	    (off >= osb->vol_layout.bitmap_off))
+			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!");
+		flags &= ~OCFS_BH_CACHED;
+	}
+
+	sb = osb->sb;
+	dev = OCFS_GET_BLOCKDEV(sb);
+	blocknum = off >> sb->s_blocksize_bits;
+
+	nr = (len + 511) >> 9;
+	if (nr == 0) {
+		LOG_TRACE_STR("No buffers will be read!!!");
+		LOG_TRACE_ARGS("Len=%llu Off=%llu numbuffers=%u "
+			       "blocknum=%llu\n", len, off, 
+			       nr, blocknum);
+		status = 0;
+		goto bail;
+	}
+
+	for (i = 0 ; i < nr ; i++) {
+		if (bhs[i] == NULL) {
+			bhs[i] = getblk (dev, blocknum++, sb->s_blocksize);
+			if (bhs[i] == NULL) {
+				LOG_TRACE_STR("bh == NULL");
+				status = -EIO;
+				LOG_ERROR_STATUS(status);
+				goto bail;
+			}
+		}
+		bh = bhs[i];
+		ignore_cache = 0;
+
+		/* Lock everyone else out of this bh */
+		OCFS_BH_GET_DATA_READ(bh);
+
+		if (flags & OCFS_BH_CACHED && inode && 
+		    !TEST_BH_SEQNUM(inode, bh)) {
+#ifdef VERBOSE_BH_SEQNUM_TRACE
+			LOG_TRACE_ARGS("(read) bh (%lu) seqnum (%lu) does not "
+				       "match inode (%u)\n", bh->b_blocknr, 
+				       (bh->b_state & STATE_BIT_MASK) >> 19,
+				       atomic_read(GET_INODE_CLEAN_SEQ(inode)));
+#endif
+			ignore_cache = 1;
+		}
+
+		if ((flags & OCFS_BH_CACHED) && (!buffer_uptodate(bh)))
+			ignore_cache = 1;
+
+		if (buffer_jbd(bh)) {
+#ifdef VERBOSE_BH_JBD_TRACE
+			if (!(flags & OCFS_BH_CACHED) || ignore_cache)
+				LOG_TRACE_ARGS("trying to sync read a jbd "
+					       "managed bh (blocknr = %lu)\n",
+					       bh->b_blocknr);
+#endif
+			continue;
+		}
+
+		if (!(flags & OCFS_BH_CACHED) || ignore_cache) {
+			if (buffer_dirty(bh)) {
+				/* This should probably be a BUG, or
+				 * at least return an error. */
+				LOG_TRACE_ARGS("asking me to sync read a "
+					      "dirty buffer! (blocknr = %lu)\n",
+					      bh->b_blocknr);
+				continue;
+			}
+
+			lock_buffer(bh);
+			clear_buffer_uptodate(bh);
+			bh->b_end_io = ocfs_end_buffer_io_sync;
+			if (flags & OCFS_BH_READAHEAD)
+				submit_bh(READA, bh);
+			else
+				submit_bh(READ, bh);
+			continue;
+		}
+	}
+
+	status = 0;
+
+	for (i = (nr-1); i >= 0; i--) {
+		bh = bhs[i];
+
+		wait_on_buffer(bh);
+
+		if (inode)
+			SET_BH_SEQNUM(inode, bh);
+		else
+			CLEAR_BH_SEQNUM(bh);
+
+		OCFS_BH_PUT_DATA(bh);
+	}
+	LOG_TRACE_ARGS("off=(%llu), len=(%llu), cached=%s\n", off, len, 
+		       (!(flags & OCFS_BH_CACHED) || ignore_cache) ? "no" : "yes");
+
+bail:
+
+#ifdef OCFS_DBG_TIMING
+	IO_FUNC_TIMING_PRINT("ocfs_read_bhs", status);
+#endif
+
+	LOG_EXIT_STATUS(status);
+	return status;
+}
+
+
+

Modified: trunk/src/ioctl.c
===================================================================
--- trunk/src/ioctl.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/ioctl.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,14 +24,8 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
 
-#include <asm/uaccess.h>
-
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
 

Modified: trunk/src/journal.c
===================================================================
--- trunk/src/journal.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/journal.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,17 +24,11 @@
  *	    Manish Singh, Joel Becker
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
 #include "inc/ocfs_journal.h"
-#include "inc/ocfs_buffer_head.h"
 
 #define OCFS_DEBUG_CONTEXT    OCFS_DEBUG_CONTEXT_JOURNAL
 
@@ -346,7 +340,7 @@
 			iput(lock->inode);
 		list_del(&(lock->lock_list));
 		handle->num_locks--;
-		kfree(lock);
+		ocfs_free(lock);
 	}
 
 	LOG_EXIT_STATUS(status);
@@ -504,7 +498,7 @@
 
 	/* we don't free the kernel handle because jbd has freed it. */
 	if (handle->buffs) {
-		kfree(handle->buffs);
+		ocfs_free(handle->buffs);
 		handle->buffs = NULL;
 	}
 
@@ -528,7 +522,7 @@
 	ocfs_free_bitmap_free_head(commit_head);
 
 	if (checkpoint)
-		kfree(handle);
+		ocfs_free(handle);
 
 	LOG_EXIT();
 
@@ -684,8 +678,8 @@
 	ocfs_free_bitmap_free_head(handle->commit_bits);
 
 	if (handle->buffs)
-		kfree(handle->buffs);
-	kfree(handle);
+		ocfs_free(handle->buffs);
+	ocfs_free(handle);
 
 	LOG_EXIT();
 	return;
@@ -1082,7 +1076,7 @@
 		send_sig (SIGINT, osb->commit->c_task, 0);
 		wait_for_completion(&osb->commit->c_complete);
 		osb->commit->c_task = NULL;
-		kfree(osb->commit);
+		ocfs_free(osb->commit);
 	}
 	
 	/* Shutdown the kernel journal system */
@@ -1248,7 +1242,7 @@
 		for(i = 0; i < totalblks; i++)
 			if (bhs[i])
 				brelse(bhs[i]);
-		kfree(bhs);
+		ocfs_free(bhs);
 	}
 	LOG_EXIT_STATUS(status);
 	return(status);
@@ -1290,7 +1284,7 @@
 
 	LOG_EXIT_STATUS(status);
 
-	kfree(arg);
+	ocfs_free(arg);
 	return status;
 }
 
@@ -1737,7 +1731,7 @@
 		if (tmpstat < 0)
 			LOG_ERROR_STATUS((status = tmpstat));
 		list_del(&(handle->h_list));
-		kfree(handle);
+		ocfs_free(handle);
 	}
 	up(&commit->c_lock);
 

Modified: trunk/src/lockres.c
===================================================================
--- trunk/src/lockres.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/lockres.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,16 +24,10 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
-#include "inc/ocfs_buffer_head.h"
 
 /* Tracing */
 #define OCFS_DEBUG_CONTEXT      OCFS_DEBUG_CONTEXT_LOCKRES
@@ -89,9 +83,9 @@
 		if (!IS_VALID_FILE_ENTRY(fe))
 			BUG();
 
-		lockres->lock_type = DISK_LOCK(fe)->file_lock;
-		lockres->master_node_num = DISK_LOCK(fe)->curr_master;
-		lockres->oin_openmap = DISK_LOCK(fe)->oin_node_map;
+		lockres->lock_type = DISK_LOCK_FILE_LOCK (fe);
+		lockres->master_node_num = DISK_LOCK_CURRENT_MASTER (fe);
+		lockres->oin_openmap = DISK_LOCK_OIN_MAP (fe);
 
 		if (lockres->readonly_node != OCFS_INVALID_NODE_NUM &&
     	    	    lockres->readonly_node != lockres->master_node_num) {
@@ -142,7 +136,7 @@
 
 	OCFS_ASSERT(lockres);
 
-	mypid = current->pid;
+	mypid = ocfs_getpid ();
 
 	if (timeout)
 		jif = jiffies + (timeout * HZ / 1000);

Modified: trunk/src/namei.c
===================================================================
--- trunk/src/namei.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/namei.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,17 +24,11 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
 #include "inc/ocfs_journal.h"
-#include "inc/ocfs_buffer_head.h"
 
 #define OCFS_DEBUG_CONTEXT    OCFS_DEBUG_CONTEXT_NAMEI
 
@@ -301,7 +295,7 @@
 #ifndef BH_SEM_LEAK_CHECKING
 	if (status < 0)
 #endif
-		ocfs_bh_sem_hash_cleanup_pid(current->pid);
+		ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
 
 	LOG_EXIT_STATUS(status);
 	return(status);
@@ -396,16 +390,19 @@
 	else
 		fe->link_cnt = 1;
 
+	fe->local_ext = 1;
 	fe->granularity = -1;
 	fe->next_free_ext = 0;
 	fe->last_ext_ptr = 0;
 	strcpy (fe->signature, OCFS_FILE_ENTRY_SIGNATURE);
 	SET_VALID_BIT (fe->sync_flags);
 	fe->sync_flags &= ~(OCFS_SYNC_FLAG_CHANGE);
-	DISK_LOCK(fe)->dlock_seq_num = 0;
-	DISK_LOCK(fe)->curr_master = osb->node_num;
-	DISK_LOCK(fe)->file_lock = OCFS_DLM_ENABLE_CACHE_LOCK;
-	DISK_LOCK(fe)->oin_node_map = (1 << osb->node_num);
+	DISK_LOCK_SEQNUM (fe) = 0;
+	DISK_LOCK_CURRENT_MASTER (fe) = osb->node_num;
+	DISK_LOCK_FILE_LOCK (fe) = OCFS_DLM_ENABLE_CACHE_LOCK;
+	DISK_LOCK_READER_NODE (fe) = osb->node_num;
+	DISK_LOCK_WRITER_NODE (fe) = osb->node_num;
+	DISK_LOCK_OIN_MAP(fe) = (1 << osb->node_num);
 	fe->create_time = fe->modify_time = OCFS_CURRENT_TIME;
 	fe->dir_node_ptr = GET_INODE_FEOFF(dir);
 	OCFS_BH_PUT_DATA(*new_fe_bh);
@@ -526,7 +523,7 @@
 
 	status = -EBUSY;
 
-	if (S_ISDIR (inode->i_mode) && !empty_dir(inode)) {
+	if (!empty_dir(inode)) {
 		LOG_TRACE_STR ("dentry is not empty, cannot delete");
 		goto bail;
 	} else if (OCFS_I(inode)->open_hndl_cnt > 0) {
@@ -743,7 +740,7 @@
 #ifndef BH_SEM_LEAK_CHECKING
 	if (retval < 0)
 #endif
-		ocfs_bh_sem_hash_cleanup_pid(current->pid);
+		ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
 
 
 	LOG_EXIT_INT (retval);
@@ -1265,7 +1262,7 @@
 #ifndef BH_SEM_LEAK_CHECKING
 	if (status < 0)
 #endif
-		ocfs_bh_sem_hash_cleanup_pid(current->pid);
+		ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
 
 	LOG_EXIT_STATUS(status);
 	return status;
@@ -1412,7 +1409,7 @@
 #ifndef BH_SEM_LEAK_CHECKING
 	if (status < 0)
 #endif
-		ocfs_bh_sem_hash_cleanup_pid(current->pid);
+		ocfs_bh_sem_hash_cleanup_pid(ocfs_getpid());
 
 	LOG_EXIT_STATUS (status);
 	return status;

Modified: trunk/src/nm.c
===================================================================
--- trunk/src/nm.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/nm.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,19 +24,11 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-#include <linux/bitops.h>
-#include <linux/net.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
 #include "inc/ocfs_journal.h"
-#include "inc/ocfs_buffer_head.h"
 
 /* Tracing */
 #define OCFS_DEBUG_CONTEXT      OCFS_DEBUG_CONTEXT_NM
@@ -172,7 +164,7 @@
 	ocfs_process_vote(osb, &(sv->ctxt));
 
 	/* we should free this when done. */
-	kfree(sv);
+	ocfs_free(sv);
 
 	LOG_EXIT();
 	return;
@@ -234,8 +226,8 @@
 	/* if no error, then the workqueue should clear it? */
 	if ((status < 0) && ctxt) {
 		if (ctxt->u.publish)
-			kfree(ctxt->u.publish);
-		kfree(ctxt);
+			ocfs_free(ctxt->u.publish);
+		ocfs_free(ctxt);
 	}
 
 	LOG_EXIT_STATUS(status);
@@ -727,7 +719,7 @@
 					    status, &master_alive, inode);
 
 #ifdef VERBOSE_PROCESS_VOTE
-	printk("(%u) ocfs_process_vote: %s request for lockid: %llu, action: (%u) %s, type: %s\n", current->pid,
+	printk("(%u) ocfs_process_vote: %s request for lockid: %llu, action: (%u) %s, type: %s\n", ocfs_getpid(),
 	       flags & FLAG_RELEASE_LOCK ? "RELEASE" : 
 	       (flags & FLAG_ACQUIRE_LOCK ? "ACQUIRE" : "MODIFY"), lock_id,
  	       vote_type, process_vote_strings[vote_type], disk_vote ? "disk vote" : "net vote" );
@@ -874,7 +866,7 @@
 					LOG_ERROR_STATUS (status);
 				if (status >= 0) {
 					fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_WRITE(fe_bh); /* write */
-					DISK_LOCK(fe)->curr_master = node_num;
+					DISK_LOCK_CURRENT_MASTER (fe) = node_num;
 					OCFS_BH_PUT_DATA(fe_bh);
 					status = ocfs_write_bh(osb, fe_bh, 0, inode);
 					if (status < 0)
@@ -995,13 +987,13 @@
 	
 			fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_READ(fe_bh); /* read */
 			is_dir = fe->attribs & OCFS_ATTRIB_DIRECTORY;
-			is_locked = DISK_LOCK(fe)->file_lock > OCFS_DLM_NO_LOCK;
+			is_locked = DISK_LOCK_FILE_LOCK (fe) > OCFS_DLM_NO_LOCK;
 			if (vote_type == CHANGE_MASTER) {
 				OCFS_BH_PUT_DATA(fe_bh);
 				fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_WRITE(fe_bh); /* write */
 				if (inode && OCFS_I(inode)->open_hndl_cnt)
-					DISK_LOCK(fe)->oin_node_map |= (1 << osb->node_num);
-				DISK_LOCK(fe)->curr_master = node_num;
+					DISK_LOCK_OIN_MAP (fe) |= (1 << osb->node_num);
+				DISK_LOCK_CURRENT_MASTER (fe) = node_num;
 			}
 			OCFS_BH_PUT_DATA(fe_bh);
 
@@ -1013,7 +1005,7 @@
 				if (vote_type == RELEASE_CACHE) {
 					LOG_TRACE_STR("release cache vote, setting to NO_LOCK");
 					fe = (ocfs_file_entry *) OCFS_BH_GET_DATA_WRITE(fe_bh); /* write */
-					DISK_LOCK(fe)->file_lock = OCFS_DLM_NO_LOCK;
+					DISK_LOCK_FILE_LOCK (fe) = OCFS_DLM_NO_LOCK;
 					OCFS_BH_PUT_DATA(fe_bh);
 				}
 				status = ocfs_write_bh(osb, fe_bh, 0, inode);
@@ -1055,8 +1047,8 @@
 			
 				OCFS_BH_PUT_DATA(fe_bh);
 				fe = (ocfs_file_entry *)OCFS_BH_GET_DATA_WRITE(fe_bh); /* write */
-				DISK_LOCK(fe)->oin_node_map |= (1 << node_num);
-				tmpmap = DISK_LOCK(fe)->oin_node_map;
+				DISK_LOCK_OIN_MAP (fe) |= (1 << node_num);
+				tmpmap = DISK_LOCK_OIN_MAP (fe);
 				OCFS_BH_PUT_DATA(fe_bh);
 
 				/* Write new map on the disk */
@@ -1209,7 +1201,7 @@
 	}
 
 #ifdef VERBOSE_PROCESS_VOTE
-	printk("(%u) vote: lockid=%llu, node=%d, seqnum=%llu, response=%d, open_handle=%s\n",current->pid, lock_id, node_num, seq_num, vote_response, open_handle?"yes":"no");
+	printk("(%u) vote: lockid=%llu, node=%d, seqnum=%llu, response=%d, open_handle=%s\n",ocfs_getpid(), lock_id, node_num, seq_num, vote_response, open_handle?"yes":"no");
 #endif
 		       
 	if (status < 0)

Modified: trunk/src/proc.c
===================================================================
--- trunk/src/proc.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/proc.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -26,12 +26,7 @@
 
 #define OCFSPROC_PRIVATE_DECLS
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/proc_fs.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
@@ -52,6 +47,9 @@
 static int ocfs_proc_device (char *page, char **start, off_t off, int count, int *eof, void *data);
 static int ocfs_proc_nodes (char *page, char **start, off_t off, int count, int *eof, void *data);
 static int ocfs_proc_net_vote_obj (char *page, char **start, off_t off, int count, int *eof, void *data);
+#ifdef OCFS_LINUX_MEM_DEBUG
+static int ocfs_proc_memallocs (char *page, char **start, off_t off, int count, int *eof, void *data);
+#endif
 static int ocfs_proc_alloc_stat(char *page, char **start, off_t off,
 				int count, int *eof, void *data);
 
@@ -73,6 +71,9 @@
 		{ OCFS2_PROC_BASENAME "/nodename", NULL, ocfs_proc_nodename },
 		{ OCFS2_PROC_BASENAME "/globalctxt", NULL, ocfs_proc_globalctxt },
 		{ OCFS2_PROC_BASENAME "/lockstat", NULL, ocfs_proc_dlm_stats },
+#ifdef OCFS_LINUX_MEM_DEBUG
+		{ OCFS2_PROC_BASENAME "/memallocs", NULL, ocfs_proc_memallocs },
+#endif
 		{ NULL, }
 	};
 
@@ -100,6 +101,9 @@
 	remove_proc_entry (OCFS2_PROC_BASENAME "/nodename", NULL);
 	remove_proc_entry (OCFS2_PROC_BASENAME "/globalctxt", NULL);
 	remove_proc_entry (OCFS2_PROC_BASENAME "/lockstat", NULL);
+#ifdef OCFS_LINUX_MEM_DEBUG
+	remove_proc_entry (OCFS2_PROC_BASENAME "/memallocs", NULL);
+#endif
 	remove_proc_entry (OCFS2_PROC_BASENAME, NULL);
 
 	LOG_EXIT ();
@@ -132,7 +136,89 @@
 	return len;
 }				/* ocfs_proc_calc_metrics */
 
+#ifdef OCFS_LINUX_MEM_DEBUG
+/*
+ * ocfs_proc_memallocs()
+ *
+ */
+static int ocfs_proc_memallocs (char *page, char **start, off_t off,
+				int count, int *eof, void *data)
+{
+	int ret = 0;
+	int proc_overflow = 0;
+	struct list_head *iter;
+	struct list_head *temp_iter;
+	alloc_item *item;
+	int len = 0;
+	char *slabname;
+	char *tmpstr = NULL;
 
+	LOG_ENTRY ();
+
+#define	MEMDBG_LEN		255
+	tmpstr = ocfs_malloc(MEMDBG_LEN);
+	if (!tmpstr) {
+		LOG_ERROR_STATUS (-ENOMEM);
+		goto bail;
+	}
+
+	sprintf (tmpstr, "%-8s  %-9s  %s\n", "Pointer", "Size/Slab", "Line:File");
+	printk("%s", tmpstr);
+	ret = sprintf ((char *) (page + len), "%s", tmpstr);
+	len += ret;
+
+	list_for_each_safe (iter, temp_iter, &OcfsGlobalCtxt.item_list) {
+		if (len >= 4096)
+			proc_overflow = 1;
+		item = list_entry (iter, alloc_item, list);
+		switch (item->type) {
+		    case SLAB_ITEM:
+			if (item->u.slab == OcfsGlobalCtxt.fe_cache)
+				slabname = "fe";
+			else
+				slabname = "unknown";
+
+			sprintf(tmpstr, "%08x  %9s  %-40s\n", item->address,
+				       	slabname, item->tag);
+
+			printk("%s", tmpstr);
+			if (!proc_overflow) {
+				ret = snprintf ((char *) (page + len),
+					       	(4096 - len), "%s", tmpstr);
+				len += ret;
+			}
+			break;
+		    case KMALLOC_ITEM: 
+		    case VMALLOC_ITEM:
+		    default:
+			sprintf(tmpstr, "%08x  %9d  %s\n", item->address,
+			       	item->u.length, item->tag);
+			printk("%s", tmpstr);
+			if (!proc_overflow) {
+				ret = snprintf ((char *) (page + len),
+					       	(4096 - len), "%s", tmpstr);
+				len += ret;
+			}
+
+			break;
+		}
+		if (ret < 0)
+			proc_overflow = 1;
+	}
+
+
+	if (proc_overflow)
+		LOG_ERROR_STR ("proc output truncated");
+
+	ret = ocfs_proc_calc_metrics (page, start, off, count, eof, len);
+
+bail:
+	ocfs_safefree (tmpstr);
+	LOG_EXIT_LONG (ret);
+	return ret;
+}				/* ocfs_proc_memallocs */
+#endif
+
 /*
  * ocfs_proc_globalctxt()
  *

Modified: trunk/src/super.c
===================================================================
--- trunk/src/super.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/super.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,25 +24,12 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/module.h>
-#include <linux/fs.h>
+#include <linux/utsname.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-#include <linux/utsname.h>
-#include <linux/init.h>
-#include <linux/sysctl.h>
-#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
-#include <linux/statfs.h>
-#include <linux/moduleparam.h>
-#endif
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
 #include "inc/ocfs_journal.h"
-#include "inc/ocfs_buffer_head.h"
 
 #define OCFS_DEBUG_CONTEXT  OCFS_DEBUG_CONTEXT_SUPER
 
@@ -492,6 +479,9 @@
 	memset (&OcfsGlobalCtxt, 0, sizeof (ocfs_global_ctxt));
 	memset (&OcfsIpcCtxt, 0, sizeof (ocfs_ipc_ctxt));
 
+#ifdef OCFS_LINUX_MEM_DEBUG
+	INIT_LIST_HEAD (&(OcfsGlobalCtxt.item_list));
+#endif
 	INIT_LIST_HEAD (&(OcfsGlobalCtxt.osb_next));
 	INIT_LIST_HEAD (&(OcfsGlobalCtxt.osb_next));
 
@@ -641,7 +631,49 @@
 }				/* ocfs_read_params */
 
 
+#ifdef OCFS_LINUX_MEM_DEBUG
 /*
+ * ocfs_memcheck()
+ *
+ */
+static void ocfs_memcheck (void)
+{
+	struct list_head *iter;
+	struct list_head *temp_iter;
+	alloc_item *item;
+	char *memtype;
+	char sizeinfo[20];
+
+	list_for_each_safe (iter, temp_iter, &OcfsGlobalCtxt.item_list) {
+		item = list_entry (iter, alloc_item, list);
+		switch (item->type)
+		{
+		    case SLAB_ITEM:
+			/* TODO: use the actual slab name */
+			memtype = "SLAB";
+			snprintf(sizeinfo, 20, "slab=%p", item->u.slab);
+			break;
+		    case KMALLOC_ITEM:
+			memtype = "KMALLOC";
+			snprintf(sizeinfo, 20, "size=%d", item->u.length);
+			break;
+		    case VMALLOC_ITEM:
+			memtype = "VMALLOC";
+			snprintf(sizeinfo, 20, "size=%d", item->u.length);
+			break;
+		    default:
+			memtype = "UNKNOWN";
+			snprintf(sizeinfo, 20, "size=%d", item->u.length);
+			break;
+		}
+		LOG_ERROR_ARGS ("unfreed %s mem %x: %s tag='%s'", memtype, 
+				item->address, sizeinfo, item->tag);
+	}
+}  /* ocfs_memcheck */
+
+#endif				/* OCFS_LINUX_MEM_DEBUG */
+
+/*
  * ocfs_driver_exit()
  *
  * Called on rmmod
@@ -671,6 +703,10 @@
 
 	unregister_filesystem (&ocfs_fs_type);
 
+#ifdef OCFS_LINUX_MEM_DEBUG
+	ocfs_memcheck ();
+#endif
+
 	printk("Unloaded OCFS Driver module\n");
 	LOG_EXIT ();
 	return;
@@ -1484,14 +1520,7 @@
 	}
 	publish = (ocfs_publish *) OCFS_BH_GET_DATA_WRITE(publish_bh); /* write */
 
-        /* 
-         * FIXME: This really ought to be something exported by the
-         * identical code in heartbeat.c
-         */
-	publish->time = jiffies;
-        /* Disallow 0 */
-        if (!publish->time)
-            publish->time = 1;
+	publish->time = ocfs_get_publish_time();
 
 	OCFS_BH_PUT_DATA(publish_bh);
 	publish = NULL;

Modified: trunk/src/symlink.c
===================================================================
--- trunk/src/symlink.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/symlink.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -30,12 +30,7 @@
  *  for CDSL support
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/pagemap.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"

Modified: trunk/src/sysfile.c
===================================================================
--- trunk/src/sysfile.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/sysfile.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,19 +24,16 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
+#ifdef __KERNEL__
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
-#warning dont vmalloc
-#include <linux/vmalloc.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
 #include "inc/ocfs_journal.h"
-#include "inc/ocfs_buffer_head.h"
+#else
+#include <dummy.h>
+#include <ocfsmalloc.h>
+#endif
 
 /* Tracing */
 #define OCFS_DEBUG_CONTEXT    OCFS_DEBUG_CONTEXT_SYSFILE
@@ -326,7 +323,7 @@
 			status = ocfs_read_bhs(osb, actualDiskOffset, 
 					       actualLength, bhs, 0, NULL);
 			if (status < 0) {
-				kfree(bhs);
+				ocfs_free(bhs);
 				LOG_ERROR_STATUS(status);
 				goto leave;
 			}
@@ -340,7 +337,7 @@
 			status = ocfs_write_bhs(osb, bhs, numbhs, 0, NULL);
 			for(i = 0; i < numbhs; i++)
 				brelse(bhs[i]);
-			kfree(bhs);
+			ocfs_free(bhs);
 			if (status < 0) {
 				LOG_ERROR_STATUS(status);
 				goto leave;
@@ -355,8 +352,8 @@
 	fe->alloc_size += actualLength;
 	fe->file_size = FileSize;
 
-	DISK_LOCK(fe)->curr_master = osb->node_num;
-	DISK_LOCK(fe)->file_lock = OCFS_DLM_ENABLE_CACHE_LOCK;
+	DISK_LOCK_CURRENT_MASTER (fe) = osb->node_num;
+	DISK_LOCK_FILE_LOCK (fe) = OCFS_DLM_ENABLE_CACHE_LOCK;
 
 	OCFS_BH_PUT_DATA(fe_bh);
 	fe = NULL;
@@ -403,7 +400,7 @@
 		goto leave;
 	}
 
-	if (fe->granularity < 0)
+	if (fe->local_ext)
        	{
 		size = OCFS_MAX_FILE_ENTRY_EXTENTS * sizeof (ocfs_io_runs);
 	}
@@ -447,7 +444,7 @@
 	Runoffset = 0;
 	newOffset = file_off;
 
-	if (fe->granularity < 0) {
+	if (fe->local_ext) {
 		for (j = 0; j < OCFS_MAX_FILE_ENTRY_EXTENTS; j++) {
 			if ((fe->extents[j].file_off +
 			     fe->extents[j].num_bytes) > newOffset) {

Modified: trunk/src/util.c
===================================================================
--- trunk/src/util.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/util.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,15 +24,14 @@
  *	    Manish Singh
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
+#ifdef __KERNEL__
 #include <linux/types.h>
-#include <linux/mm.h>
-#include <linux/slab.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
+#else
+#include <debugocfs.h>
+#endif
 
 /* Tracing */
 #define OCFS_DEBUG_CONTEXT  OCFS_DEBUG_CONTEXT_UTIL
@@ -120,6 +119,10 @@
 	return 0;
 }				/* ocfs_sleep */
 
+#ifdef OCFS_LINUX_MEM_DEBUG
+#define SUPER_VERBOSE_MEM_DEBUG  1
+#endif
+
 /*
  * ocfs_dbg_slab_alloc()
  *
@@ -128,10 +131,23 @@
 {
     void *m;
     m = kmem_cache_alloc(slab, GFP_NOFS);
-#if 0 /* FIXME: Should we check? */
-    if (m == NULL)
+#ifdef OCFS_LINUX_MEM_DEBUG
+    if (m == NULL) {
 	LOG_ERROR_ARGS("failed to alloc from slab = %p", slab);
+    } else {
+		alloc_item *new;
+		new = kmalloc (sizeof (alloc_item), GFP_NOFS);
+		new->type = SLAB_ITEM;
+		new->address = m;
+		new->u.slab = slab;
+		snprintf (new->tag, 30, "%d:%s", line, file);
+		new->tag[29] = '\0';
+		list_add (&new->list, &OcfsGlobalCtxt.item_list);
+#ifdef SUPER_VERBOSE_MEM_DEBUG
+		LOG_TRACE_ARGS (" + %x (%p, '%s')\n", m, slab, new->tag);
 #endif
+    }
+#endif
     return m;
 }                               /* ocfs_dbg_slab_alloc */
 
@@ -141,10 +157,105 @@
  */
 void ocfs_dbg_slab_free (kmem_cache_t *slab, void *m)
 {
+
+#ifdef OCFS_LINUX_MEM_DEBUG
+	struct list_head *iter, *tmpiter;
+	alloc_item *item = NULL;
+	int do_free = 0;
+
+	list_for_each_safe (iter, tmpiter, &OcfsGlobalCtxt.item_list) {
+		item = list_entry (iter, alloc_item, list);
+
+		if (item->address == m && item->type == SLAB_ITEM) {
+#ifdef SUPER_VERBOSE_MEM_DEBUG
+			LOG_TRACE_ARGS (" - %x (%p, '%s')\n", m, item->u.slab, item->tag);
+#endif
+			list_del (&item->list);
+			do_free = 1;
+			break;
+		}
+	}
+
+	if (do_free) {
+		kmem_cache_free(slab, m);
+		kfree (item);
+		return;
+	}
+	LOG_ERROR_ARGS ("tried to free mem never allocated: %x", m);
+#endif
+#ifndef OCFS_LINUX_MEM_DEBUG
 	kmem_cache_free(slab, m);
+#endif
 }				/* ocfs_dbg_slab_free */
 
 
+
+/*
+ * ocfs_linux_dbg_alloc()
+ *
+ */
+void *ocfs_linux_dbg_alloc (int Size, char *file, int line)
+{
+	void *m;
+
+	m = kmalloc (Size, GFP_NOFS);
+#ifdef OCFS_LINUX_MEM_DEBUG
+	if (m == NULL) {
+		LOG_ERROR_ARGS ("failed! (size=%d)", Size);
+	} else {
+		alloc_item *new;
+		new = kmalloc (sizeof (alloc_item), GFP_NOFS);
+		new->type = KMALLOC_ITEM;
+		new->address = m;
+		new->u.length = Size;
+		snprintf (new->tag, 30, "%d:%s", line, file);
+		new->tag[29] = '\0';
+		list_add (&new->list, &OcfsGlobalCtxt.item_list);
+#ifdef SUPER_VERBOSE_MEM_DEBUG
+		LOG_TRACE_ARGS (" + %x (%d, '%s')\n", m, Size, new->tag);
+#endif
+	}
+#endif
+	return m;
+}				/* ocfs_linux_dbg_alloc */
+
+/*
+ * ocfs_linux_dbg_free()
+ *
+ */
+void ocfs_linux_dbg_free (const void *Buffer)
+{
+
+#ifdef OCFS_LINUX_MEM_DEBUG
+	struct list_head *iter, *tmpiter;
+	alloc_item *item = NULL;
+	int do_free = 0;
+
+	list_for_each_safe (iter, tmpiter, &OcfsGlobalCtxt.item_list) {
+		item = list_entry (iter, alloc_item, list);
+
+		if (item->address == Buffer && item->type == KMALLOC_ITEM) {
+#ifdef SUPER_VERBOSE_MEM_DEBUG
+			LOG_TRACE_ARGS (" - %x (%d, '%s')\n", Buffer,
+					item->u.length, item->tag);
+#endif
+			list_del (&item->list);
+			do_free = 1;
+			break;
+		}
+	}
+	if (do_free) {
+		kfree (Buffer);
+		kfree (item);
+		return;
+	}
+	LOG_ERROR_ARGS ("tried to free mem never allocated: %x", Buffer);
+#endif
+#ifndef OCFS_LINUX_MEM_DEBUG
+	kfree (Buffer);
+#endif
+}				/* ocfs_linux_dbg_free */
+
 /* prefetch has been declared to allow to build in debug mode */
 #ifdef DEBUG
 #ifndef ARCH_HAS_PREFETCH

Modified: trunk/src/ver.c
===================================================================
--- trunk/src/ver.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/ver.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,17 +24,13 @@
  *	    Manish Singh
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/module.h>
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/kernel.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
+#include <linux/kernel.h>
 
+#include <linux/module.h>
 
 MODULE_DESCRIPTION("The Oracle Cluster Filesystem (version "
 		   OCFS_BUILD_VERSION

Modified: trunk/src/volcfg.c
===================================================================
--- trunk/src/volcfg.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/volcfg.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,16 +24,10 @@
  *	    Manish Singh, Neeraj Goyal, Suchit Kaura
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/highmem.h>
 
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
-#include "inc/ocfs_buffer_head.h"
 
 /* Tracing */
 #define  OCFS_DEBUG_CONTEXT  OCFS_DEBUG_CONTEXT_VOLCFG
@@ -363,10 +357,10 @@
 		
 
 		disk_lock = (ocfs_disk_lock *) lock_buf;
-		lock_node_num = disk_lock->curr_master;
+		lock_node_num = DISK_LOCK_CURRENT_MASTER(disk_lock);
 
-		if (disk_lock->file_lock == 0 || break_lock) {
-			if (disk_lock->file_lock != 0)
+		if (DISK_LOCK_FILE_LOCK (disk_lock) == 0 || break_lock) {
+			if (DISK_LOCK_FILE_LOCK (disk_lock) != 0)
 				LOG_TRACE_STR ("Try to break node config lock");
 			else
 				LOG_TRACE_STR ("Lock node config");
@@ -374,8 +368,8 @@
 			/* Attempt to lock volcfg */
 			memcpy(disk_lock, cfg_buf, osb->sect_size);
 
-			disk_lock->curr_master = osb->node_num;
-			disk_lock->file_lock = 1;
+			DISK_LOCK_CURRENT_MASTER (disk_lock) = osb->node_num;
+			DISK_LOCK_FILE_LOCK (disk_lock) = 1;
 			memcpy(cfg_buf, disk_lock, osb->sect_size);
 		
 			/* Write into volcfg lock sector... */
@@ -421,9 +415,9 @@
 
 			/* Write the config info into the disk */
 			disk_lock = (ocfs_disk_lock *) cfg_buf;
-			disk_lock->curr_master =
+			DISK_LOCK_CURRENT_MASTER (disk_lock) =
 							OCFS_INVALID_NODE_NUM;
-			disk_lock->file_lock = 0;
+			DISK_LOCK_FILE_LOCK (disk_lock) = 0;
 
 			if (op == OCFS_VOLCFG_ADD)
 				status = ocfs_add_to_disk_config (osb, node_num,
@@ -440,11 +434,11 @@
 			break;
 		} else {
 			disk_lock = (ocfs_disk_lock *) lock_buf;
-			if (disk_lock->curr_master == lock_node_num)
+			if (DISK_LOCK_CURRENT_MASTER (disk_lock) == lock_node_num)
 				break_lock = 1;
 			else {
 				LOG_TRACE_ARGS ("Node config locked by node: %d\n",
-					disk_lock->curr_master);
+					DISK_LOCK_CURRENT_MASTER (disk_lock));
 				ocfs_sleep (OCFS_VOLCFG_LOCK_TIME);
 			}
 			OCFS_BH_PUT_DATA(bh);

Modified: trunk/src/vote.c
===================================================================
--- trunk/src/vote.c	2004-06-02 20:20:39 UTC (rev 975)
+++ trunk/src/vote.c	2004-06-02 20:52:44 UTC (rev 976)
@@ -24,17 +24,8 @@
  *	    Manish Singh
  */
 
-#include "inc/ocfs_compat.h"
-
-#include <linux/fs.h>
 #include <linux/types.h>
-#include <linux/slab.h>
-#include <linux/inet.h>
-#include <linux/net.h>
-#include <linux/in.h>
 
-#include <asm/uaccess.h>
-
 #include "inc/ocfs_log.h"
 #include "inc/ocfs.h"
 
@@ -792,7 +783,7 @@
 	obj->seq_num = 0ULL;
 	obj->req_lock_type = reqlock;
 	obj->vote_status = 0;
-	obj->pid = current->pid;
+	obj->pid = ocfs_getpid();
 	
 	return obj;
 }



More information about the Ocfs2-commits mailing list