[Ocfs2-tools-commits] manish commits r1043 - in trunk: debugfs.ocfs2 debugfs.ocfs2/include extras fsck.ocfs2 libocfs2 libocfs2/include mkfs.ocfs2 tunefs.ocfs2

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Fri Aug 12 18:32:48 CDT 2005


Author: manish
Date: 2005-08-12 18:32:43 -0500 (Fri, 12 Aug 2005)
New Revision: 1043

Added:
   trunk/libocfs2/include/jbd.h
   trunk/libocfs2/slot_map.c
Removed:
   trunk/debugfs.ocfs2/include/jbd.h
   trunk/libocfs2/include/jfs_compat.h
   trunk/libocfs2/include/jfs_user.h
   trunk/libocfs2/include/kernel-jbd.h
Modified:
   trunk/debugfs.ocfs2/Makefile
   trunk/debugfs.ocfs2/commands.c
   trunk/debugfs.ocfs2/dump.c
   trunk/debugfs.ocfs2/include/dump.h
   trunk/extras/find_dup_extents.c
   trunk/fsck.ocfs2/journal.c
   trunk/fsck.ocfs2/pass1.c
   trunk/libocfs2/Makefile
   trunk/libocfs2/alloc.c
   trunk/libocfs2/bitops.c
   trunk/libocfs2/chain.c
   trunk/libocfs2/checkhb.c
   trunk/libocfs2/dirblock.c
   trunk/libocfs2/extents.c
   trunk/libocfs2/heartbeat.c
   trunk/libocfs2/include/bitops.h
   trunk/libocfs2/include/byteorder.h
   trunk/libocfs2/include/ocfs2.h
   trunk/libocfs2/inode.c
   trunk/libocfs2/inode_scan.c
   trunk/libocfs2/mkjournal.c
   trunk/libocfs2/openfs.c
   trunk/mkfs.ocfs2/mkfs.c
   trunk/mkfs.ocfs2/mkfs.h
   trunk/tunefs.ocfs2/tunefs.c
Log:
Merged endian-safe branch to trunk, r1017:1042


Modified: trunk/debugfs.ocfs2/Makefile
===================================================================
--- trunk/debugfs.ocfs2/Makefile	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/debugfs.ocfs2/Makefile	2005-08-12 23:32:43 UTC (rev 1043)
@@ -24,12 +24,12 @@
 	include/commands.h	\
 	include/dump.h		\
 	include/utils.h		\
-	include/jbd.h		\
 	include/journal.h
 
 OBJS = $(subst .c,.o,$(CFILES))
 
 LIBOCFS2_LIBS = -L$(TOPDIR)/libocfs2 -locfs2
+LIBO2CB_LIBS = -L$(TOPDIR)/libo2cb -lo2cb
 
 MANS = debugfs.ocfs2.8
 
@@ -41,6 +41,6 @@
 	$(TOPDIR)/mkinstalldirs $(DIST_DIR)/include
 
 debugfs.ocfs2: $(OBJS)
-	$(LINK) $(GLIB_LIBS) $(LIBOCFS2_LIBS) $(COM_ERR_LIBS) -lreadline -lncurses
+	$(LINK) $(GLIB_LIBS) $(LIBOCFS2_LIBS) $(LIBO2CB_LIBS) $(COM_ERR_LIBS) -lreadline -lncurses
 
 include $(TOPDIR)/Postamble.make

Modified: trunk/debugfs.ocfs2/commands.c
===================================================================
--- trunk/debugfs.ocfs2/commands.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/debugfs.ocfs2/commands.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -47,6 +47,7 @@
 static void do_ls (char **args);
 static void do_quit (char **args);
 static void do_help (char **args);
+static void do_hb (char **args);
 static void do_dump (char **args);
 static void do_rdump (char **args);
 static void do_cat (char **args);
@@ -72,6 +73,7 @@
 	{ "extent",	do_extent },
 	{ "group",	do_group },
 	{ "help",	do_help },
+	{ "hb",		do_hb },
 	{ "?",		do_help },
 	{ "lcd",	do_lcd },
 	{ "logdump",	do_logdump },
@@ -714,7 +716,6 @@
 
 	return ;
 }
-#if 0
 /*
  * do_hb()
  *
@@ -725,21 +726,18 @@
 	FILE *out;
 	int len;
 	errcode_t ret;
-	void (*dump_func) (FILE *out, char *buf);
 
 	if (check_device_open())
 		return ;
 
-	DBGFS_FATAL("internal");
-
 	ret = ocfs2_read_whole_file(gbls.fs, gbls.hb_blkno, &hbbuf, &len);
 	if (ret) {
 		com_err(args[0], ret, " ");
 		goto bail;
 	}
 
-	out = open_pager();
-	dump_func(out, hbbuf);
+	out = open_pager(gbls.interactive);
+	dump_hb(out, hbbuf, len);
 	close_pager(out);
 
 bail:
@@ -748,7 +746,6 @@
 
 	return ;
 }
-#endif
 
 /*
  * do_dump()

Modified: trunk/debugfs.ocfs2/dump.c
===================================================================
--- trunk/debugfs.ocfs2/dump.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/debugfs.ocfs2/dump.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -24,6 +24,7 @@
  */
 
 #include <main.h>
+#include <stdint.h>
 
 extern dbgfs_gbls gbls;
 
@@ -92,15 +93,15 @@
 	int i;
 
 	fprintf(out, "\tTotal Records: %u   Used: %u\n",
-		le16_to_cpu(tl->tl_count), le16_to_cpu(tl->tl_used));
+		tl->tl_count, tl->tl_used);
 
 	fprintf(out, "\t##   %-10s   %-10s\n", "Start Cluster",
 		"Num Clusters");
 
-	for(i = 0; i < le16_to_cpu(tl->tl_used); i++)
+	for(i = 0; i < tl->tl_used; i++)
 		fprintf(out, "\t%-2d   %-10u   %-10u\n",
-			i, le32_to_cpu(tl->tl_recs[i].t_start),
-			le32_to_cpu(tl->tl_recs[i].t_clusters));
+			i, tl->tl_recs[i].t_start,
+			tl->tl_recs[i].t_clusters);
 
 	return ;
 }
@@ -199,12 +200,12 @@
 	str = ctime((time_t*)&in->i_dtime);
 	fprintf(out, "\tdtime: 0x%"PRIx64" -- %s", in->i_dtime, str);
 
-	fprintf(out, "\tctime_nsec: 0x%x -- %u\n",
-		le32_to_cpu(in->i_ctime_nsec), le32_to_cpu(in->i_ctime));
-	fprintf(out, "\tatime_nsec: 0x%x -- %u\n",
-		le32_to_cpu(in->i_atime_nsec), le32_to_cpu(in->i_atime_nsec));
-	fprintf(out, "\tmtime_nsec: 0x%x -- %u\n",
-		le32_to_cpu(in->i_mtime_nsec), le32_to_cpu(in->i_mtime_nsec));
+	fprintf(out, "\tctime_nsec: 0x%08"PRIx32" -- %u\n",
+		in->i_ctime_nsec, in->i_ctime_nsec);
+	fprintf(out, "\tatime_nsec: 0x%08"PRIx32" -- %u\n",
+		in->i_atime_nsec, in->i_atime_nsec);
+	fprintf(out, "\tmtime_nsec: 0x%08"PRIx32" -- %u\n",
+		in->i_mtime_nsec, in->i_mtime_nsec);
 
 	fprintf(out, "\tLast Extblk: %"PRIu64"\n", in->i_last_eb_blk);
 	if (in->i_suballoc_slot == OCFS2_INVALID_SLOT)
@@ -400,10 +401,11 @@
 
 	fprintf (out, "\tError: %d\n", ntohl(jsb->s_errno));
 
-	/* XXX not sure what to do about swabbing these */
-	fprintf (out, "\tFeatures Compat: %u   Incompat: %u   RO Compat: %u\n",
-		 jsb->s_feature_compat, jsb->s_feature_incompat,
-		 jsb->s_feature_ro_compat);
+	fprintf (out, "\tFeatures Compat: 0x%"PRIx32"   "
+		 "Incompat: 0x%"PRIx32"   RO Compat: 0x%"PRIx32"\n",
+		 ntohl(jsb->s_feature_compat),
+		 ntohl(jsb->s_feature_incompat),
+		 ntohl(jsb->s_feature_ro_compat));
 
 	fprintf (out, "\tJournal UUID: ");
 	for(i = 0; i < 16; i++)
@@ -560,10 +562,32 @@
 	fprintf (out, "\t%5s   %5s\n", "Slot#", "Node#");
 	
 	for (i = 0; i < num_slots; ++i) {
-		if (slots[i] != -1)
-			fprintf (out, "\t%5d   %5d\n",
-				 i, slots[i]);
+		uint16_t slot = le16_to_cpu(slots[i]);
+		if (slot == (uint16_t)OCFS2_INVALID_SLOT)
+			continue;
+
+		fprintf (out, "\t%5d   %5u\n", i, slot);
 	}
 
 	return ;
 }
+
+void dump_hb (FILE *out, char *buf, uint32_t len)
+{
+	uint32_t i;
+	struct o2hb_disk_heartbeat_block *hb;
+
+	fprintf (out, "\t%4s: %4s %16s %16s %8s\n",
+		 "node", "node", "seq", "generation", "checksum");
+	
+	for (i = 0; i < 255 && ((i + 1) * 512 < len); ++i) {
+		hb = (struct o2hb_disk_heartbeat_block *)(buf + (i * 512));
+		ocfs2_swap_disk_heartbeat_block(hb);
+		fprintf (out, "\t%4u: %4u %016"PRIx64" %016"PRIx64" "
+			 "%08"PRIx32"\n", i,
+			 hb->hb_node, hb->hb_seq, hb->hb_generation,
+			 hb->hb_cksum);
+	}
+
+	return ;
+}

Modified: trunk/debugfs.ocfs2/include/dump.h
===================================================================
--- trunk/debugfs.ocfs2/include/dump.h	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/debugfs.ocfs2/include/dump.h	2005-08-12 23:32:43 UTC (rev 1043)
@@ -50,5 +50,6 @@
 void dump_jbd_unknown (FILE *out, uint64_t start, uint64_t end);
 void dump_slots (FILE *out, char *buf, uint32_t len);
 void dump_fast_symlink (FILE *out, char *link);
+void dump_hb (FILE *out, char *buf, uint32_t len);
 
 #endif		/* __DUMP_H__ */

Deleted: trunk/debugfs.ocfs2/include/jbd.h
===================================================================
--- trunk/debugfs.ocfs2/include/jbd.h	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/debugfs.ocfs2/include/jbd.h	2005-08-12 23:32:43 UTC (rev 1043)
@@ -1,124 +0,0 @@
-/*
- * jbd.h
- *
- * header file extracted from linux/include/linux/jbd.h
- *
- * Originally written by Stephen C. Tweedie <sct at redhat.com>
- *
- * Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved
- *
- * This file is part of the Linux kernel and is made available under
- * the terms of the GNU General Public License, version 2, or at your
- * option, any later version, incorporated herein by reference.
- *
- * Definitions for transaction data structures for the buffer cache
- * filesystem journaling support.
- */
-
-#ifndef _JBD_H_
-#define _JBD_H_
-
-/*
- * Internal structures used by the logging mechanism:
- */
-
-#define JFS_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
-
-/*
- * On-disk structures
- */
-
-/* 
- * Descriptor block types:
- */
-
-#define JFS_DESCRIPTOR_BLOCK	1
-#define JFS_COMMIT_BLOCK	2
-#define JFS_SUPERBLOCK_V1	3
-#define JFS_SUPERBLOCK_V2	4
-#define JFS_REVOKE_BLOCK	5
-
-/*
- * Standard header for all descriptor blocks:
- */
-typedef struct journal_header_s
-{
-	__u32		h_magic;
-	__u32		h_blocktype;
-	__u32		h_sequence;
-} journal_header_t;
-
-/* 
- * The block tag: used to describe a single buffer in the journal 
- */
-typedef struct journal_block_tag_s
-{
-	__u32		t_blocknr;	/* The on-disk block number */
-	__u32		t_flags;	/* See below */
-} journal_block_tag_t;
-
-/* 
- * The revoke descriptor: used on disk to describe a series of blocks to
- * be revoked from the log 
- */
-typedef struct journal_revoke_header_s
-{
-	journal_header_t r_header;
-	int		 r_count;	/* Count of bytes used in the block */
-} journal_revoke_header_t;
-
-/* Definitions for the journal tag flags word: */
-#define JFS_FLAG_ESCAPE		1	/* on-disk block is escaped */
-#define JFS_FLAG_SAME_UUID	2	/* block has same uuid as previous */
-#define JFS_FLAG_DELETED	4	/* block deleted by this transaction */
-#define JFS_FLAG_LAST_TAG	8	/* last tag in this descriptor block */
-
-/*
- * The journal superblock.  All fields are in big-endian byte order.
- */
-typedef struct journal_superblock_s
-{
-/* 0x0000 */
-	journal_header_t s_header;
-
-/* 0x000C */
-	/* Static information describing the journal */
-	__u32	s_blocksize;		/* journal device blocksize */
-	__u32	s_maxlen;		/* total blocks in journal file */
-	__u32	s_first;		/* first block of log information */
-	
-/* 0x0018 */
-	/* Dynamic information describing the current state of the log */
-	__u32	s_sequence;		/* first commit ID expected in log */
-	__u32	s_start;		/* blocknr of start of log */
-
-/* 0x0020 */
-	/* Error value, as set by journal_abort(). */
-	__s32	s_errno;
-
-/* 0x0024 */
-	/* Remaining fields are only valid in a version-2 superblock */
-	__u32	s_feature_compat; 	/* compatible feature set */
-	__u32	s_feature_incompat; 	/* incompatible feature set */
-	__u32	s_feature_ro_compat; 	/* readonly-compatible feature set */
-/* 0x0030 */
-	__u8	s_uuid[16];		/* 128-bit uuid for journal */
-
-/* 0x0040 */
-	__u32	s_nr_users;		/* Nr of filesystems sharing log */
-	
-	__u32	s_dynsuper;		/* Blocknr of dynamic superblock copy*/
-	
-/* 0x0048 */
-	__u32	s_max_transaction;	/* Limit of journal blocks per trans.*/
-	__u32	s_max_trans_data;	/* Limit of data blocks per trans. */
-
-/* 0x0050 */
-	__u32	s_padding[44];
-
-/* 0x0100 */
-	__u8	s_users[16*48];		/* ids of all fs'es sharing the log */
-/* 0x0400 */
-} journal_superblock_t;
-
-#endif		/* _JBD_H_ */

Modified: trunk/extras/find_dup_extents.c
===================================================================
--- trunk/extras/find_dup_extents.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/extras/find_dup_extents.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -184,6 +184,8 @@
 				   strlen(OCFS2_INODE_SIGNATURE)))
 				continue;
 
+			ocfs2_swap_inode_to_cpu(di);
+
 			if (!(di->i_flags & OCFS2_VALID_FL))
 				continue;
 

Modified: trunk/fsck.ocfs2/journal.c
===================================================================
--- trunk/fsck.ocfs2/journal.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/fsck.ocfs2/journal.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -41,12 +41,10 @@
 #include <string.h>
 #include <inttypes.h>
 
+#include "byteorder.h"
 #include "fsck.h"
 #include "journal.h"
-/* jfs_compat.h defines these */
-#undef cpu_to_be32
-#undef be32_to_cpu
-#include "jfs_user.h"
+#include "jbd.h"
 #include "ocfs2.h"
 #include "pass1.h"
 #include "problem.h"

Modified: trunk/fsck.ocfs2/pass1.c
===================================================================
--- trunk/fsck.ocfs2/pass1.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/fsck.ocfs2/pass1.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -129,10 +129,13 @@
 		 * write back the new map */
 		if (oldval != val && !ost->ost_write_inode_alloc_asked) {
 			yn = prompt(ost, PY, PR_INODE_ALLOC_REPAIR,
-				    "fsck found an inode whose "
-				    "allocation does not match the chain "
-				    "allocators.  Fix the allocation of this "
-				    "and all future inodes?");
+				    "Inode %"PRIu64" is marked as %s but its "
+				    "position in the inode allocator is "
+				    "marked as %s.  Fix the allocation of this "
+				    "and all future inodes?", blkno,
+				    val ? "valid" : "invalid",
+				    oldval ? "in use" : "free");
+
 			ost->ost_write_inode_alloc_asked = 1;
 			ost->ost_write_inode_alloc = !!yn;
 			if (!ost->ost_write_inode_alloc)
@@ -149,8 +152,8 @@
 		goto out;
 	}
 
-	verbosef("updated inode %"PRIu64" alloc to %d in slot %"PRId16"\n",
-		 blkno, val, slot);
+	verbosef("updated inode %"PRIu64" alloc to %d from %d in slot "
+		  "%"PRId16"\n", blkno, val, oldval, slot);
 
 	/* make sure the inode's fields are consistent if it's allocated */
 	if (val == 1 && slot != di->i_suballoc_slot &&
@@ -1148,24 +1151,29 @@
 
 		valid = 0;
 
-		/* we never consider inodes who don't have a signature.
-		 * We only consider inodes whose generations don't match
-		 * if the user has asked us to */
+		/* we never consider inodes who don't have a signature */
 		if (!memcmp(di->i_signature, OCFS2_INODE_SIGNATURE,
-			    strlen(OCFS2_INODE_SIGNATURE)) &&
-		    (ost->ost_fix_fs_gen ||
-		    (di->i_fs_generation == ost->ost_fs_generation))) {
+			    strlen(OCFS2_INODE_SIGNATURE))) {
 
-			if (di->i_flags & OCFS2_VALID_FL)
-				o2fsck_verify_inode_fields(fs, ost, blkno, di);
+			ocfs2_swap_inode_to_cpu(di);
 
-			if (di->i_flags & OCFS2_VALID_FL) {
-				ret = o2fsck_check_blocks(fs, ost, blkno, di);
-				if (ret)
-					goto out;
+			 /* We only consider inodes whose generations don't
+			  * match if the user has asked us to */
+			if ((ost->ost_fix_fs_gen ||
+			    (di->i_fs_generation == ost->ost_fs_generation))) {
+
+				if (di->i_flags & OCFS2_VALID_FL)
+					o2fsck_verify_inode_fields(fs, ost,
+								   blkno, di);
+				if (di->i_flags & OCFS2_VALID_FL) {
+					ret = o2fsck_check_blocks(fs, ost,
+								  blkno, di);
+					if (ret)
+						goto out;
+				}
+
+				valid = di->i_flags & OCFS2_VALID_FL;
 			}
-
-			valid = di->i_flags & OCFS2_VALID_FL;
 		}
 
 		update_inode_alloc(ost, di, blkno, valid);

Modified: trunk/libocfs2/Makefile
===================================================================
--- trunk/libocfs2/Makefile	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/Makefile	2005-08-12 23:32:43 UTC (rev 1043)
@@ -75,6 +75,7 @@
 	namei.c		\
 	newdir.c	\
 	openfs.c	\
+	slot_map.c	\
 	sysfile.c	\
 	truncate.c	\
 	unix_io.c	\
@@ -87,9 +88,7 @@
 	include/dir_iterate.h		\
 	include/dir_util.h		\
 	include/extent_map.h		\
-	include/jfs_compat.h		\
-	include/jfs_user.h		\
-	include/kernel-jbd.h		\
+	include/jbd.h			\
 	include/kernel-list.h		\
 	include/kernel-rbtree.h		\
 	include/ocfs1_fs_compat.h	\

Modified: trunk/libocfs2/alloc.c
===================================================================
--- trunk/libocfs2/alloc.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/alloc.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -163,7 +163,7 @@
 
 	if (flags & OCFS2_DEALLOC_FL) {
 		tl_recs = ocfs2_truncate_recs_per_inode(fs->fs_blocksize);
-		di->id2.i_dealloc.tl_count = cpu_to_le16(tl_recs);
+		di->id2.i_dealloc.tl_count = tl_recs;
 		return ;
 	}
 

Modified: trunk/libocfs2/bitops.c
===================================================================
--- trunk/libocfs2/bitops.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/bitops.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -27,19 +27,12 @@
  */
 
 #include <stdio.h>
+#include <strings.h>
 #include <sys/types.h>
 
 #include "bitops.h"
 
 /*
- * XXX: We're not endian safe at all, and have just hacked in big endian
- * bitops for the arches we want to test on (ppc32 and s390x userland).
- * Post-1.0, we have to revisit this.
- */
-
-#ifndef _OCFS2_HAVE_ASM_BITOPS_
-
-/*
  * For the benefit of those who are trying to port Linux to another
  * architecture, here are some C-language equivalents.  You should
  * recode these in the native assmebly language, if at all possible.
@@ -49,29 +42,8 @@
  * systems, as well as non-32 bit systems.
  */
 
-#if defined(__powerpc__)
 int ocfs2_set_bit(int nr,void * addr)
 {
-	unsigned long mask = 1 << (nr & 0x1f);
-	unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
-	unsigned long old = *p;
-
-	*p = old | mask;
-	return (old & mask) != 0;
-}
-#elif defined(__s390x__)
-int ocfs2_set_bit(int nr,void * addr)
-{
-	unsigned long mask = 1UL << (nr & 0x3f);
-	unsigned long *p = ((unsigned long *)addr) + (nr >> 6);
-	unsigned long old = *p;
-
-	*p = old | mask;
-	return (old & mask) != 0;
-}
-#else
-int ocfs2_set_bit(int nr,void * addr)
-{
 	int		mask, retval;
 	unsigned char	*ADDR = (unsigned char *) addr;
 
@@ -81,31 +53,9 @@
 	*ADDR |= mask;
 	return retval;
 }
-#endif
 
-#if defined(__powerpc__)
 int ocfs2_clear_bit(int nr, void * addr)
 {
-	unsigned long mask = 1 << (nr & 0x1f);
-	unsigned long *p = ((unsigned long *)addr) + (nr >> 5);
-	unsigned long old = *p;
-
-	*p = old & ~mask;
-	return (old & mask) != 0;
-}
-#elif defined(__s390x__)
-int ocfs2_clear_bit(int nr, void * addr)
-{
-	unsigned long mask = 1UL << (nr & 0x3f);
-	unsigned long *p = ((unsigned long *)addr) + (nr >> 6);
-	unsigned long old = *p;
-
-	*p = old & ~mask;
-	return (old & mask) != 0;
-}
-#else
-int ocfs2_clear_bit(int nr, void * addr)
-{
 	int		mask, retval;
 	unsigned char	*ADDR = (unsigned char *) addr;
 
@@ -115,25 +65,9 @@
 	*ADDR &= ~mask;
 	return retval;
 }
-#endif
 
-#if defined(__powerpc__)
 int ocfs2_test_bit(int nr, const void * addr)
 {
-	const unsigned int *p = (const unsigned int *) addr;
-
-	return ((p[nr >> 5] >> (nr & 0x1f)) & 1) != 0;
-}
-#elif defined(__s390x__)
-int ocfs2_test_bit(int nr, const void * addr)
-{
-	const unsigned long *p = (const unsigned long *) addr;
-
-	return ((p[nr >> 6] >> (nr & 0x3f)) & 1UL) != 0;
-}
-#else
-int ocfs2_test_bit(int nr, const void * addr)
-{
 	int			mask;
 	const unsigned char	*ADDR = (const unsigned char *) addr;
 
@@ -141,112 +75,7 @@
 	mask = 1 << (nr & 0x07);
 	return ((mask & *ADDR) != 0);
 }
-#endif
 
-#endif	/* !_OCFS2_HAVE_ASM_BITOPS_ */
-
-#if !defined(_OCFS2_HAVE_ASM_FINDBIT_)
-#include <strings.h>
-
-#if defined(__powerpc__)
-static inline int __ilog2(unsigned long x)
-{
-        int lz;
-                                                                                                                                                         
-        asm ("cntlzw %0,%1" : "=r" (lz) : "r" (x));
-        return 31 - lz;
-}
-
-static inline int ffz(unsigned int x)
-{
-        if ((x = ~x) == 0)
-                return 32;
-        return __ilog2(x & -x);
-}
-
-static inline int __ffs(unsigned long x)
-{
-	return __ilog2(x & -x);
-}
-#elif defined(__s390x__)
-
-static const char _zb_findmap[] = {
-	0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
-	0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
-	0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
-	0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,
-	0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
-	0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
-	0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
-	0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,7,
-	0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
-	0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
-	0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
-	0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,6,
-	0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
-	0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,5,
-	0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,4,
-	0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,8
-};
-
-static const char _sb_findmap[] = {
-	8,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
-	4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
-	5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
-	4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
-	6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
-	4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
-	5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
-	4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
-	7,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
-	4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
-	5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
-	4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
-	6,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
-	4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
-	5,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0,
-	4,0,1,0,2,0,1,0,3,0,1,0,2,0,1,0
-};
-
-static inline int ffz(unsigned long word)
-{
-	int bit = 0;
-
-	if ((word & 0xffffffff) == 0xffffffff) {
-		word >>= 32;
-		bit += 32;
-	}
-	if ((word & 0xffff) == 0xffff) {
-		word >>= 16;
-		bit += 16;
-	}
-	if ((word & 0xff) == 0xff) {
-		word >>= 8;
-		bit += 8;
-	}
-	return bit + _zb_findmap[word & 0xff];
-}
-
-static inline int __ffs(unsigned long word)
-{
-	int bit = 0;
-
-	if ((word & 0xffffffff) == 0) {
-		word >>= 32;
-		bit += 32;
-	}
-	if ((word & 0xffff) == 0) {
-		word >>= 16;
-		bit += 16;
-	}
-	if ((word & 0xff) == 0) {
-		word >>= 8;
-		bit += 8;
-	}
-	return bit + _sb_findmap[word & 0xff];
-}
-#endif
-
 int ocfs2_find_first_bit_set(void *addr, int size)
 {
 	return ocfs2_find_next_bit_set(addr, size, 0);
@@ -257,85 +86,8 @@
 	return ocfs2_find_next_bit_clear(addr, size, 0);
 }
 
-#if defined(__powerpc__)
 int ocfs2_find_next_bit_set(void *addr, int size, int offset)
 {
-	unsigned int *p = ((unsigned int *) addr) + (offset >> 5);
-	unsigned int result = offset & ~31UL;
-	unsigned int tmp;
-
-	if (offset >= size)
-		return size;
-	size -= result;
-	offset &= 31UL;
-	if (offset) {
-		tmp = *p++;
-		tmp &= ~0UL << offset;
-		if (size < 32)
-			goto found_first;
-		if (tmp)
-			goto found_middle;
-		size -= 32;
-		result += 32;
-	}
-	while (size >= 32) {
-		if ((tmp = *p++) != 0)
-			goto found_middle;
-		result += 32;
-		size -= 32;
-	}
-	if (!size)
-		return result;
-	tmp = *p;
-
-found_first:
-	tmp &= ~0UL >> (32 - size);
-	if (tmp == 0UL)        /* Are any bits set? */
-		return result + size; /* Nope. */
-found_middle:
-	return result + __ffs(tmp);
-}
-#elif defined(__s390x__)
-int ocfs2_find_next_bit_set(void *addr, int size, int offset)
-{
-	unsigned long *p = ((unsigned long *) addr) + (offset >> 6);
-	unsigned long result = offset & ~63UL;
-	unsigned long tmp;
-
-	if (offset >= size)
-		return size;
-	size -= result;
-	offset &= 63UL;
-	if (offset) {
-		tmp = *p++;
-		tmp &= ~0UL << offset;
-		if (size < 64)
-			goto found_first;
-		if (tmp)
-			goto found_middle;
-		size -= 64;
-		result += 64;
-	}
-	while (size & ~63UL) {
-		if ((tmp = *p++) != 0)
-			goto found_middle;
-		result += 64;
-		size -= 64;
-	}
-	if (!size)
-		return result;
-	tmp = *p;
-
-found_first:
-	tmp &= ~0UL >> (64 - size);
-	if (tmp == 0UL)        /* Are any bits set? */
-		return result + size; /* Nope. */
-found_middle:
-	return result + __ffs(tmp);
-}
-#else
-int ocfs2_find_next_bit_set(void *addr, int size, int offset)
-{
 	unsigned char * p;
 	int set = 0, d0;
 	unsigned int	bit = offset & 7, res = 0;
@@ -371,85 +123,9 @@
 
 	return (res + d0 - 1);
 }
-#endif
 
-#if defined(__powerpc__)
 int ocfs2_find_next_bit_clear(void *addr, int size, int offset)
 {
-	unsigned int * p = ((unsigned int *) addr) + (offset >> 5);
-	unsigned int result = offset & ~31UL;
-	unsigned int tmp;
-
-	if (offset >= size)
-		return size;
-	size -= result;
-	offset &= 31UL;
-	if (offset) {
-		tmp = *p++;
-		tmp |= ~0UL >> (32-offset);
-		if (size < 32)
-			goto found_first;
-		if (tmp != ~0U)
-			goto found_middle;
-		size -= 32;
-		result += 32;
-	}
-	while (size >= 32) {
-		if ((tmp = *p++) != ~0U)
-			goto found_middle;
-		result += 32;
-		size -= 32;
-	}
-	if (!size)
-		return result;
-	tmp = *p;
-found_first:
-	tmp |= ~0UL << size;
-	if (tmp == ~0UL)        /* Are any bits zero? */
-		return result + size; /* Nope. */
-found_middle:
-	return result + ffz(tmp);
-}
-#elif defined(__s390x__)
-int ocfs2_find_next_bit_clear(void *addr, int size, int offset)
-{
-	unsigned long * p = ((unsigned long *) addr) + (offset >> 6);
-	unsigned long result = offset & ~63UL;
-	unsigned long tmp;
-
-	if (offset >= size)
-		return size;
-	size -= result;
-	offset &= 63UL;
-	if (offset) {
-		tmp = *p++;
-		tmp |= ~0UL >> (64-offset);
-		if (size < 64)
-			goto found_first;
-		if (~tmp)
-			goto found_middle;
-		size -= 64;
-		result += 64;
-	}
-	while (size & ~63UL) {
-		if (~(tmp = *p++))
-			goto found_middle;
-		result += 64;
-		size -= 64;
-	}
-	if (!size)
-		return result;
-	tmp = *p;
-found_first:
-	tmp |= ~0UL << size;
-	if (tmp == ~0UL)        /* Are any bits zero? */
-		return result + size; /* Nope. */
-found_middle:
-	return result + ffz(tmp);
-}
-#else
-int ocfs2_find_next_bit_clear(void *addr, int size, int offset)
-{
 	unsigned char * p;
 	int set = 0, d0;
 	unsigned int	bit = offset & 7, res = 0;
@@ -484,11 +160,7 @@
 
 	return (res + d0 - 1);
 }
-#endif
 
-#endif	
-
-
 #ifdef DEBUG_EXE
 #include <stdio.h>
 #include <stdlib.h>

Modified: trunk/libocfs2/chain.c
===================================================================
--- trunk/libocfs2/chain.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/chain.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -29,14 +29,19 @@
 
 #include "ocfs2.h"
 
-static void ocfs2_group_desc_to_cpu(ocfs2_group_desc *gd)
+void ocfs2_swap_group_desc(ocfs2_group_desc *gd)
 {
-	gd->bg_generation = le32_to_cpu(gd->bg_generation);
-}
+	if (cpu_is_little_endian)
+		return;
 
-static void ocfs2_group_desc_to_le(ocfs2_group_desc *gd)
-{
-	gd->bg_generation = cpu_to_le32(gd->bg_generation);
+	gd->bg_size = bswap_16(gd->bg_size);
+	gd->bg_bits = bswap_16(gd->bg_bits);
+	gd->bg_free_bits_count = bswap_16(gd->bg_free_bits_count);
+	gd->bg_chain = bswap_16(gd->bg_chain);
+	gd->bg_generation = bswap_32(gd->bg_generation);
+	gd->bg_next_group = bswap_64(gd->bg_next_group);
+	gd->bg_parent_dinode = bswap_64(gd->bg_parent_dinode);
+	gd->bg_blkno = bswap_64(gd->bg_blkno);
 }
 
 errcode_t ocfs2_read_group_desc(ocfs2_filesys *fs, uint64_t blkno,
@@ -68,7 +73,7 @@
 	memcpy(gd_buf, blk, fs->fs_blocksize);
 
 	gd = (ocfs2_group_desc *)gd_buf;
-	ocfs2_group_desc_to_cpu(gd);
+	ocfs2_swap_group_desc(gd);
 
 	ret = 0;
 out:
@@ -98,7 +103,7 @@
 	memcpy(blk, gd_buf, fs->fs_blocksize);
 
 	gd = (ocfs2_group_desc *)blk;
-	ocfs2_group_desc_to_le(gd);
+	ocfs2_swap_group_desc(gd);
 
 	ret = io_write_block(fs->fs_io, blkno, 1, blk);
 	if (ret)

Modified: trunk/libocfs2/checkhb.c
===================================================================
--- trunk/libocfs2/checkhb.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/checkhb.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -63,8 +63,8 @@
 	if (!ret) {
 		slots = (int16_t *)slotbuf;
 		for (i = 0, j = 0; i < num_nodes; ++i)
-			if (slots[i] != -1)
-				node_nums[j++] = (uint8_t)slots[i];
+			if (le16_to_cpu(slots[i]) != (uint16_t)OCFS2_INVALID_SLOT)
+				node_nums[j++] = le16_to_cpu(slots[i]);
 	}
 
 	if (slotbuf)

Modified: trunk/libocfs2/dirblock.c
===================================================================
--- trunk/libocfs2/dirblock.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/dirblock.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -32,35 +32,41 @@
 
 #include "ocfs2.h"
 
+static void ocfs2_swap_dir_entry(struct ocfs2_dir_entry *dirent)
+{
+	if (cpu_is_little_endian)
+		return;
 
-errcode_t ocfs2_read_dir_block(ocfs2_filesys *fs, uint64_t block,
-                               void *buf)
+	dirent->inode = bswap_64(dirent->inode);
+	dirent->rec_len = bswap_16(dirent->rec_len);
+}
+
+static errcode_t ocfs2_swap_dir_entries_direction(void *buf, uint64_t bytes,
+						  int to_cpu)
 {
-	errcode_t	retval;
 	char		*p, *end;
 	struct ocfs2_dir_entry *dirent;
 	unsigned int	name_len, rec_len;
+	errcode_t retval = 0;
 
- 	retval = io_read_block(fs->fs_io, block, 1, buf);
-	if (retval)
-		return retval;
-
 	p = (char *) buf;
-	end = (char *) buf + fs->fs_blocksize;
+	end = (char *) buf + bytes;
 	while (p < end-12) {
 		dirent = (struct ocfs2_dir_entry *) p;
 
-		dirent->inode = le64_to_cpu(dirent->inode);
-		dirent->rec_len = le16_to_cpu(dirent->rec_len);
+		if (to_cpu)
+			ocfs2_swap_dir_entry(dirent);
 		name_len = dirent->name_len;
 		rec_len = dirent->rec_len;
+		if (!to_cpu)
+			ocfs2_swap_dir_entry(dirent);
 
 		if ((rec_len < 12) || (rec_len % 4)) {
 			rec_len = 12;
 			retval = OCFS2_ET_DIR_CORRUPTED;
 		}
 
-		if (((name_len & 0xFF) + 12) > dirent->rec_len)
+		if (((name_len & 0xFF) + 12) > rec_len)
 			retval = OCFS2_ET_DIR_CORRUPTED;
 
 		p += rec_len;
@@ -68,13 +74,32 @@
 	return retval;
 }
 
+errcode_t ocfs2_swap_dir_entries_from_cpu(void *buf, uint64_t bytes)
+{
+	return ocfs2_swap_dir_entries_direction(buf, bytes, 0);
+}
+errcode_t ocfs2_swap_dir_entries_to_cpu(void *buf, uint64_t bytes)
+{
+	return ocfs2_swap_dir_entries_direction(buf, bytes, 1);
+}
+
+errcode_t ocfs2_read_dir_block(ocfs2_filesys *fs, uint64_t block,
+                               void *buf)
+{
+	errcode_t	retval;
+
+ 	retval = io_read_block(fs->fs_io, block, 1, buf);
+	if (retval)
+		return retval;
+
+	return ocfs2_swap_dir_entries_to_cpu(buf, fs->fs_blocksize);
+}
+
 errcode_t ocfs2_write_dir_block(ocfs2_filesys *fs, uint64_t block,
                                 void *inbuf)
 {
 	errcode_t	retval;
-	char		*p, *end;
 	char		*buf = NULL;
-	struct ocfs2_dir_entry *dirent;
 
 	retval = ocfs2_malloc_block(fs->fs_io, &buf);
 	if (retval)
@@ -82,24 +107,12 @@
 
 	memcpy(buf, inbuf, fs->fs_blocksize);
 
-	p = buf;
-	end = buf + fs->fs_blocksize;
-	while (p < end-12) {
-		dirent = (struct ocfs2_dir_entry *) p;
-
-		if ((dirent->rec_len < 12) ||
-		    (dirent->rec_len % 4)) {
-			ocfs2_free(&buf);
-			return OCFS2_ET_DIR_CORRUPTED;
-		}
-
-		p += dirent->rec_len;
-
-		dirent->inode = cpu_to_le64(dirent->inode);
-		dirent->rec_len = cpu_to_le16(dirent->rec_len);
-	}
-
+	retval = ocfs2_swap_dir_entries_from_cpu(buf, fs->fs_blocksize);
+	if (retval)
+		goto out;
+	
  	retval = io_write_block(fs->fs_io, block, 1, buf);
+out:
 	ocfs2_free(&buf);
 	return retval;
 }

Modified: trunk/libocfs2/extents.c
===================================================================
--- trunk/libocfs2/extents.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/extents.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -34,20 +34,70 @@
 
 #include "ocfs2.h"
 
-static void ocfs2_swap_extent_block_to_cpu(ocfs2_extent_block *eb)
+static void ocfs2_swap_extent_list_primary(ocfs2_extent_list *el)
 {
-	eb->h_blkno         = le64_to_cpu(eb->h_blkno);
-	eb->h_suballoc_slot = le16_to_cpu(eb->h_suballoc_slot);
-	eb->h_suballoc_bit  = le16_to_cpu(eb->h_suballoc_bit);
+	el->l_tree_depth = bswap_16(el->l_tree_depth);
+	el->l_count = bswap_16(el->l_count);
+	el->l_next_free_rec = bswap_16(el->l_next_free_rec);
 }
 
-static void ocfs2_swap_extent_block_to_le(ocfs2_extent_block *eb)
+static void ocfs2_swap_extent_list_secondary(ocfs2_extent_list *el)
 {
-	eb->h_blkno         = cpu_to_le64(eb->h_blkno);
-	eb->h_suballoc_slot = cpu_to_le16(eb->h_suballoc_slot);
-	eb->h_suballoc_bit  = cpu_to_le16(eb->h_suballoc_bit);
+	uint16_t i;
+
+	for(i = 0; i < el->l_next_free_rec; i++) {
+		ocfs2_extent_rec *rec = &el->l_recs[i];
+
+		rec->e_cpos = bswap_32(rec->e_cpos);
+		rec->e_clusters = bswap_32(rec->e_clusters);
+		rec->e_blkno = bswap_64(rec->e_blkno);
+	}
 }
 
+void ocfs2_swap_extent_list_from_cpu(ocfs2_extent_list *el)
+{
+	if (cpu_is_little_endian)
+		return;
+
+	ocfs2_swap_extent_list_secondary(el);
+	ocfs2_swap_extent_list_primary(el);
+}
+void ocfs2_swap_extent_list_to_cpu(ocfs2_extent_list *el)
+{
+	if (cpu_is_little_endian)
+		return;
+
+	ocfs2_swap_extent_list_primary(el);
+	ocfs2_swap_extent_list_secondary(el);
+}
+
+static void ocfs2_swap_extent_block_header(ocfs2_extent_block *eb)
+{
+
+	eb->h_suballoc_slot = bswap_16(eb->h_suballoc_slot);
+	eb->h_suballoc_bit  = bswap_16(eb->h_suballoc_bit);
+	eb->h_fs_generation = bswap_32(eb->h_fs_generation);
+	eb->h_blkno         = bswap_64(eb->h_blkno);
+	eb->h_next_leaf_blk = bswap_64(eb->h_next_leaf_blk);
+}
+
+static void ocfs2_swap_extent_block_from_cpu(ocfs2_extent_block *eb)
+{
+	if (cpu_is_little_endian)
+		return;
+
+	ocfs2_swap_extent_block_header(eb);
+	ocfs2_swap_extent_list_from_cpu(&eb->h_list);
+}
+static void ocfs2_swap_extent_block_to_cpu(ocfs2_extent_block *eb)
+{
+	if (cpu_is_little_endian)
+		return;
+
+	ocfs2_swap_extent_block_header(eb);
+	ocfs2_swap_extent_list_to_cpu(&eb->h_list);
+}
+
 errcode_t ocfs2_read_extent_block_nocheck(ocfs2_filesys *fs, uint64_t blkno,
 					  char *eb_buf)
 {
@@ -121,7 +171,7 @@
 	memcpy(blk, eb_buf, fs->fs_blocksize);
 
 	eb = (ocfs2_extent_block *) blk;
-	ocfs2_swap_extent_block_to_le(eb);
+	ocfs2_swap_extent_block_from_cpu(eb);
 
 	ret = io_write_block(fs->fs_io, blkno, 1, blk);
 	if (ret)

Modified: trunk/libocfs2/heartbeat.c
===================================================================
--- trunk/libocfs2/heartbeat.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/heartbeat.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -30,6 +30,16 @@
 
 #include "ocfs2.h"
 
+void ocfs2_swap_disk_heartbeat_block(struct o2hb_disk_heartbeat_block *hb)
+{
+	if (cpu_is_little_endian)
+		return;
+
+	hb->hb_seq        = bswap_64(hb->hb_seq);
+	hb->hb_cksum      = bswap_32(hb->hb_cksum);
+	hb->hb_generation = bswap_64(hb->hb_generation);
+}
+
 errcode_t ocfs2_fill_heartbeat_desc(ocfs2_filesys *fs,
 				    struct o2cb_region_desc *desc)
 {

Modified: trunk/libocfs2/include/bitops.h
===================================================================
--- trunk/libocfs2/include/bitops.h	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/include/bitops.h	2005-08-12 23:32:43 UTC (rev 1043)
@@ -3,8 +3,7 @@
  *
  * bitops.h
  *
- * Bitmap frobbing routines for the OCFS2 userspace library.  These
- * are the inlined versions.
+ * Bitmap frobbing routines for the OCFS2 userspace library.
  *
  * Copyright (C) 2004 Oracle.  All rights reserved.
  *
@@ -26,251 +25,18 @@
  *
  *  This code is a port of e2fsprogs/lib/ext2fs/bitops.h
  *  Copyright (C) 1993, 1994, 1995, 1996 Theodore Ts'o.
- *
- *  i386 bitops operations taken from <asm/bitops.h>, Copyright 1992,
- *  Linus Torvalds.
  */
 
+#ifndef _BITOPS_H
+#define _BITOPS_H
 
-
-/*
- * OCFS2 bitmap manipulation routines.
- */
-
-#if ((defined __GNUC__) && \
-     (defined(__i386__) || defined(__i486__) || defined(__i586__)))
-
-#define _OCFS2_HAVE_ASM_BITOPS_
-
-/*
- * These are done by inline assembly for speed reasons.....
- *
- * All bitoperations return 0 if the bit was cleared before the
- * operation and != 0 if it was not.  Bit 0 is the LSB of addr; bit 32
- * is the LSB of (addr+1).
- */
-
-/*
- * Some hacks to defeat gcc over-optimizations..
- */
-struct __dummy_h { unsigned long a[100]; };
-#define OCFS2_ADDR (*(struct __dummy_h *) addr)
-#define OCFS2_CONST_ADDR (*(const struct __dummy_h *) addr)	
-
-static inline int ocfs2_set_bit(int nr, void * addr)
-{
-	int oldbit;
-
-	__asm__ __volatile__("btsl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit),"=m" (OCFS2_ADDR)
-		:"r" (nr));
-	return oldbit;
-}
-
-static inline int ocfs2_clear_bit(int nr, void * addr)
-{
-	int oldbit;
-
-	__asm__ __volatile__("btrl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit),"=m" (OCFS2_ADDR)
-		:"r" (nr));
-	return oldbit;
-}
-
-static inline int ocfs2_test_bit(int nr, const void * addr)
-{
-	int oldbit;
-
-	__asm__ __volatile__("btl %2,%1\n\tsbbl %0,%0"
-		:"=r" (oldbit)
-		:"m" (OCFS2_CONST_ADDR),"r" (nr));
-	return oldbit;
-}
-
-#if 0
-#define _OCFS2_HAVE_ASM_FINDBIT_
-
-_INLINE_ int ext2fs_find_first_bit_set(void * addr, unsigned size)
-{
-	int d0, d1, d2;
-	int res;
-
-	if (!size)
-		return 0;
-	/* This looks at memory. Mark it volatile to tell gcc not to move it around */
-	__asm__ __volatile__(
-		"cld\n\t"			     
-		"xorl %%eax,%%eax\n\t"
-		"xorl %%edx,%%edx\n\t"
-		"repe; scasl\n\t"
-		"je 1f\n\t"
-		"movl -4(%%edi),%%eax\n\t"
-		"subl $4,%%edi\n\t"
-		"bsfl %%eax,%%edx\n"
-		"1:\tsubl %%esi,%%edi\n\t"
-		"shll $3,%%edi\n\t"
-		"addl %%edi,%%edx"
-		:"=d" (res), "=&c" (d0), "=&D" (d1), "=&a" (d2)
-		:"1" ((size + 31) >> 5), "2" (addr), "S" (addr));
-	return res;
-}
-
-_INLINE_ int ext2fs_find_next_bit_set (void * addr, int size, int offset)
-{
-	unsigned long * p = ((unsigned long *) addr) + (offset >> 5);
-	int set = 0, bit = offset & 31, res;
-	
-	if (bit) {
-		/*
-		 * Look for zero in first byte
-		 */
-		__asm__("bsfl %1,%0\n\t"
-			"jne 1f\n\t"
-			"movl $32, %0\n"
-			"1:"
-			: "=r" (set)
-			: "r" (*p >> bit));
-		if (set < (32 - bit))
-			return set + offset;
-		set = 32 - bit;
-		p++;
-	}
-	/*
-	 * No bit found yet, search remaining full bytes for a bit
-	 */
-	res = ext2fs_find_first_bit_set(p, size - 32 * (p - (unsigned long *) addr));
-	return (offset + set + res);
-}
-#endif
-
-#undef OCFS2_ADDR
-
-#endif	/* i386 */
-
-#ifdef __mc68000__
-
-#define _OCFS2_HAVE_ASM_BITOPS_
-
-static inline int ocfs2_set_bit(int nr,void * addr)
-{
-	char retval;
-
-	__asm__ __volatile__ ("bfset %2@{%1:#1}; sne %0"
-	     : "=d" (retval) : "d" (nr^7), "a" (addr));
-
-	return retval;
-}
-
-static inline int ocfs2_clear_bit(int nr, void * addr)
-{
-	char retval;
-
-	__asm__ __volatile__ ("bfclr %2@{%1:#1}; sne %0"
-	     : "=d" (retval) : "d" (nr^7), "a" (addr));
-
-	return retval;
-}
-
-static inline int ocfs2_test_bit(int nr, const void * addr)
-{
-	char retval;
-
-	__asm__ __volatile__ ("bftst %2@{%1:#1}; sne %0"
-	     : "=d" (retval) : "d" (nr^7), "a" (addr));
-
-	return retval;
-}
-
-#endif /* __mc68000__ */
-
-#ifdef __sparc__
-
-#define _OCFS2_HAVE_ASM_BITOPS_
-
-/*
- * Do the bitops so that we are compatible with the standard i386
- * convention.
- */
-
-static inline int ocfs2_set_bit(int nr,void * addr)
-{
-#if 1
-	int		mask;
-	unsigned char	*ADDR = (unsigned char *) addr;
-
-	ADDR += nr >> 3;
-	mask = 1 << (nr & 0x07);
-	__asm__ __volatile__("ldub	[%0], %%g6\n\t"
-			     "or	%%g6, %2, %%g5\n\t"
-			     "stb	%%g5, [%0]\n\t"
-			     "and	%%g6, %2, %0\n"
-	: "=&r" (ADDR)
-	: "0" (ADDR), "r" (mask)
-	: "g5", "g6");
-	return (int) ADDR;
-#else
-	int		mask, retval;
-	unsigned char	*ADDR = (unsigned char *) addr;
-
-	ADDR += nr >> 3;
-	mask = 1 << (nr & 0x07);
-	retval = (mask & *ADDR) != 0;
-	*ADDR |= mask;
-	return retval;
-#endif
-}
-
-static inline int ocfs2_clear_bit(int nr, void * addr)
-{
-#if 1
-	int		mask;
-	unsigned char	*ADDR = (unsigned char *) addr;
-
-	ADDR += nr >> 3;
-	mask = 1 << (nr & 0x07);
-	__asm__ __volatile__("ldub	[%0], %%g6\n\t"
-			     "andn	%%g6, %2, %%g5\n\t"
-			     "stb	%%g5, [%0]\n\t"
-			     "and	%%g6, %2, %0\n"
-	: "=&r" (ADDR)
-	: "0" (ADDR), "r" (mask)
-	: "g5", "g6");
-	return (int) ADDR;
-	
-#else
-	int		mask, retval;
-	unsigned char	*ADDR = (unsigned char *) addr;
-
-	ADDR += nr >> 3;
-	mask = 1 << (nr & 0x07);
-	retval = (mask & *ADDR) != 0;
-	*ADDR &= ~mask;
-	return retval;
-#endif
-}
-
-static inline int ocfs2_test_bit(int nr, const void * addr)
-{
-	int			mask;
-	const unsigned char	*ADDR = (const unsigned char *) addr;
-
-	ADDR += nr >> 3;
-	mask = 1 << (nr & 0x07);
-	return ((mask & *ADDR) != 0);
-}
-
-#endif /* __sparc__ */
-
-#ifndef _OCFS2_HAVE_ASM_BITOPS_
 extern int ocfs2_set_bit(int nr,void * addr);
 extern int ocfs2_clear_bit(int nr, void * addr);
 extern int ocfs2_test_bit(int nr, const void * addr);
-#endif
 
-#if !defined(_OCFS2_HAVE_ASM_FINDBIT_)
 extern int ocfs2_find_first_bit_set(void *addr, int size);
 extern int ocfs2_find_first_bit_clear(void *addr, int size);
 extern int ocfs2_find_next_bit_set(void *addr, int size, int offset);
 extern int ocfs2_find_next_bit_clear(void *addr, int size, int offset);
-#endif	
 
+#endif

Modified: trunk/libocfs2/include/byteorder.h
===================================================================
--- trunk/libocfs2/include/byteorder.h	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/include/byteorder.h	2005-08-12 23:32:43 UTC (rev 1043)
@@ -33,13 +33,12 @@
 #include <stdint.h>
 
 /*
- * All OCFS2 on-disk values are in little endian, except for the
- * autoconfig areas and the journal areas.  The journal code has the
- * right bits for itself, and the autoconfig areas use htonl(), so
- * they are OK.
+ * All OCFS2 on-disk values are in little endian, except for jbd's journal
+ * fields which it takes care of itself.
  */
 
 #if __BYTE_ORDER == __LITTLE_ENDIAN
+#define cpu_is_little_endian	1
 # ifndef cpu_to_le16
 #  define cpu_to_le16(x) ((uint16_t)(x))
 # endif
@@ -77,6 +76,7 @@
 #  define be64_to_cpu(x) ((uint64_t)bswap_64(x))
 # endif
 #elif __BYTE_ORDER == __BIG_ENDIAN
+#define cpu_is_little_endian	0
 # ifndef cpu_to_le16
 #  define cpu_to_le16(x) ((uint16_t)bswap_16(x))
 # endif
@@ -117,4 +117,6 @@
 # error Invalid byte order __BYTE_ORDER
 #endif  /* __BYTE_ORDER */
 
+#define cpu_is_big_endian	(!cpu_is_little_endian)
+
 #endif  /* _BYTEORDER_H */

Copied: trunk/libocfs2/include/jbd.h (from rev 1042, branches/endian-safe/libocfs2/include/jbd.h)

Deleted: trunk/libocfs2/include/jfs_compat.h
===================================================================
--- trunk/libocfs2/include/jfs_compat.h	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/include/jfs_compat.h	2005-08-12 23:32:43 UTC (rev 1043)
@@ -1,67 +0,0 @@
-
-#ifndef _JFS_COMPAT_H
-#define _JFS_COMPAT_H
-
-#include "kernel-list.h"
-#include <errno.h>
-#include <netinet/in.h>
-
-// libocfs.h has these
-//#define printk printf
-//#define KERN_ERR ""
-#define KERN_DEBUG ""
-#define KERN_EMERG ""
-
-#define READ 0
-#define WRITE 1
-
-#define cpu_to_be32(n) htonl(n)
-#define be32_to_cpu(n) ntohl(n)
-
-typedef unsigned int tid_t;
-typedef struct journal_s journal_t;
-
-struct buffer_head;
-struct inode;
-
-struct journal_s
-{
-	unsigned long		j_flags;
-	int			j_errno;
-	struct buffer_head *	j_sb_buffer;
-	struct journal_superblock_s *j_superblock;
-	int			j_format_version;
-	unsigned long		j_head;
-	unsigned long		j_tail;
-	unsigned long		j_free;
-	unsigned long		j_first, j_last;
-	kdev_t			j_dev;
-	kdev_t			j_fs_dev;
-	int			j_blocksize;
-	unsigned int		j_blk_offset;
-	unsigned int		j_maxlen;
-	struct inode *		j_inode;
-	tid_t			j_tail_sequence;
-	tid_t			j_transaction_sequence;
-	__u8			j_uuid[16];
-	struct jbd_revoke_table_s *j_revoke;
-};
-
-#define J_ASSERT(assert)						\
-	do { if (!(assert)) {						\
-		printf ("Assertion failure in %s() at %s line %d: "	\
-			"\"%s\"\n",					\
-			__FUNCTION__, __FILE__, __LINE__, # assert);	\
-		fatal_error(e2fsck_global_ctx, 0);			\
-	} } while (0)
-
-#define is_journal_abort(x) 0
-
-#define BUFFER_TRACE(bh, info)	do {} while (0)
-
-/* Need this so we can compile with configure --enable-gcc-wall */
-#ifdef NO_INLINE_FUNCS
-#define inline
-#endif
-
-#endif /* _JFS_COMPAT_H */

Deleted: trunk/libocfs2/include/jfs_user.h
===================================================================
--- trunk/libocfs2/include/jfs_user.h	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/include/jfs_user.h	2005-08-12 23:32:43 UTC (rev 1043)
@@ -1,8 +0,0 @@
-#ifndef _JFS_USER_H
-#define _JFS_USER_H
-
-typedef unsigned short kdev_t;
-
-#include "kernel-jbd.h"
-
-#endif /* _JFS_USER_H */

Deleted: trunk/libocfs2/include/kernel-jbd.h
===================================================================
--- trunk/libocfs2/include/kernel-jbd.h	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/include/kernel-jbd.h	2005-08-12 23:32:43 UTC (rev 1043)
@@ -1,910 +0,0 @@
-/*
- * linux/include/linux/jbd.h
- * 
- * Written by Stephen C. Tweedie <sct at redhat.com>
- *
- * Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved
- *
- * This file is part of the Linux kernel and is made available under
- * the terms of the GNU General Public License, version 2, or at your
- * option, any later version, incorporated herein by reference.
- *
- * Definitions for transaction data structures for the buffer cache
- * filesystem journaling support.
- */
-
-#ifndef _LINUX_JBD_H
-#define _LINUX_JBD_H
-
-#if defined(CONFIG_JBD) || defined(CONFIG_JBD_MODULE) || !defined(__KERNEL__)
-
-/* Allow this file to be included directly into e2fsprogs */
-#ifndef __KERNEL__
-#include "jfs_compat.h"
-#define JFS_DEBUG
-#define jfs_debug jbd_debug
-#else
-
-#include <linux/journal-head.h>
-#include <linux/stddef.h>
-#include <asm/semaphore.h>
-#endif
-
-#ifndef __GNUC__
-#define __FUNCTION__ ""
-#endif
-
-#define journal_oom_retry 1
-
-#ifdef __STDC__
-#ifdef CONFIG_JBD_DEBUG
-/*
- * Define JBD_EXPENSIVE_CHECKING to enable more expensive internal
- * consistency checks.  By default we don't do this unless
- * CONFIG_JBD_DEBUG is on.
- */
-#define JBD_EXPENSIVE_CHECKING
-extern int journal_enable_debug;
-
-#define jbd_debug(n, f, a...)						\
-	do {								\
-		if ((n) <= journal_enable_debug) {			\
-			printk (KERN_DEBUG "(%s, %d): %s: ",		\
-				__FILE__, __LINE__, __FUNCTION__);	\
-		  	printk (f, ## a);				\
-		}							\
-	} while (0)
-#else
-#ifdef __GNUC__
-#define jbd_debug(f, a...)	/**/
-#else
-#define jbd_debug(f, ...)	/**/
-#endif	
-#endif
-#else
-#define jbd_debug(x)		/* AIX doesn't do STDC */
-#endif
-
-extern void * __jbd_kmalloc (char *where, size_t size, int flags, int retry);
-#define jbd_kmalloc(size, flags) \
-	__jbd_kmalloc(__FUNCTION__, (size), (flags), journal_oom_retry)
-#define jbd_rep_kmalloc(size, flags) \
-	__jbd_kmalloc(__FUNCTION__, (size), (flags), 1)
-
-#define JFS_MIN_JOURNAL_BLOCKS 1024
-
-#ifdef __KERNEL__
-typedef struct handle_s		handle_t;	/* Atomic operation type */
-typedef struct journal_s	journal_t;	/* Journal control structure */
-#endif
-
-/*
- * Internal structures used by the logging mechanism:
- */
-
-#define JFS_MAGIC_NUMBER 0xc03b3998U /* The first 4 bytes of /dev/random! */
-
-/*
- * On-disk structures
- */
-
-/* 
- * Descriptor block types:
- */
-
-#define JFS_DESCRIPTOR_BLOCK	1
-#define JFS_COMMIT_BLOCK	2
-#define JFS_SUPERBLOCK_V1	3
-#define JFS_SUPERBLOCK_V2	4
-#define JFS_REVOKE_BLOCK	5
-
-/*
- * Standard header for all descriptor blocks:
- */
-typedef struct journal_header_s
-{
-	__u32		h_magic;
-	__u32		h_blocktype;
-	__u32		h_sequence;
-} journal_header_t;
-
-
-/* 
- * The block tag: used to describe a single buffer in the journal 
- */
-typedef struct journal_block_tag_s
-{
-	__u32		t_blocknr;	/* The on-disk block number */
-	__u32		t_flags;	/* See below */
-} journal_block_tag_t;
-
-/* 
- * The revoke descriptor: used on disk to describe a series of blocks to
- * be revoked from the log 
- */
-typedef struct journal_revoke_header_s
-{
-	journal_header_t r_header;
-	int		 r_count;	/* Count of bytes used in the block */
-} journal_revoke_header_t;
-
-
-/* Definitions for the journal tag flags word: */
-#define JFS_FLAG_ESCAPE		1	/* on-disk block is escaped */
-#define JFS_FLAG_SAME_UUID	2	/* block has same uuid as previous */
-#define JFS_FLAG_DELETED	4	/* block deleted by this transaction */
-#define JFS_FLAG_LAST_TAG	8	/* last tag in this descriptor block */
-
-
-/*
- * The journal superblock.  All fields are in big-endian byte order.
- */
-typedef struct journal_superblock_s
-{
-/* 0x0000 */
-	journal_header_t s_header;
-
-/* 0x000C */
-	/* Static information describing the journal */
-	__u32	s_blocksize;		/* journal device blocksize */
-	__u32	s_maxlen;		/* total blocks in journal file */
-	__u32	s_first;		/* first block of log information */
-	
-/* 0x0018 */
-	/* Dynamic information describing the current state of the log */
-	__u32	s_sequence;		/* first commit ID expected in log */
-	__u32	s_start;		/* blocknr of start of log */
-
-/* 0x0020 */
-	/* Error value, as set by journal_abort(). */
-	__s32	s_errno;
-
-/* 0x0024 */
-	/* Remaining fields are only valid in a version-2 superblock */
-	__u32	s_feature_compat; 	/* compatible feature set */
-	__u32	s_feature_incompat; 	/* incompatible feature set */
-	__u32	s_feature_ro_compat; 	/* readonly-compatible feature set */
-/* 0x0030 */
-	__u8	s_uuid[16];		/* 128-bit uuid for journal */
-
-/* 0x0040 */
-	__u32	s_nr_users;		/* Nr of filesystems sharing log */
-	
-	__u32	s_dynsuper;		/* Blocknr of dynamic superblock copy*/
-	
-/* 0x0048 */
-	__u32	s_max_transaction;	/* Limit of journal blocks per trans.*/
-	__u32	s_max_trans_data;	/* Limit of data blocks per trans. */
-
-/* 0x0050 */
-	__u32	s_padding[44];
-
-/* 0x0100 */
-	__u8	s_users[16*48];		/* ids of all fs'es sharing the log */
-/* 0x0400 */
-} journal_superblock_t;
-
-#define JFS_HAS_COMPAT_FEATURE(j,mask)					\
-	((j)->j_format_version >= 2 &&					\
-	 ((j)->j_superblock->s_feature_compat & cpu_to_be32((mask))))
-#define JFS_HAS_RO_COMPAT_FEATURE(j,mask)				\
-	((j)->j_format_version >= 2 &&					\
-	 ((j)->j_superblock->s_feature_ro_compat & cpu_to_be32((mask))))
-#define JFS_HAS_INCOMPAT_FEATURE(j,mask)				\
-	((j)->j_format_version >= 2 &&					\
-	 ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask))))
-
-#define JFS_FEATURE_INCOMPAT_REVOKE	0x00000001
-
-/* Features known to this kernel version: */
-#define JFS_KNOWN_COMPAT_FEATURES	0
-#define JFS_KNOWN_ROCOMPAT_FEATURES	0
-#define JFS_KNOWN_INCOMPAT_FEATURES	JFS_FEATURE_INCOMPAT_REVOKE
-
-#ifdef __KERNEL__
-
-#include <linux/fs.h>
-#include <linux/sched.h>
-
-#define JBD_ASSERTIONS
-#ifdef JBD_ASSERTIONS
-#define J_ASSERT(assert)						\
-do {									\
-	if (!(assert)) {						\
-		printk (KERN_EMERG					\
-			"Assertion failure in %s() at %s:%d: \"%s\"\n",	\
-			__FUNCTION__, __FILE__, __LINE__, # assert);	\
-		BUG();							\
-	}								\
-} while (0)
-
-#if defined(CONFIG_BUFFER_DEBUG)
-void buffer_assertion_failure(struct buffer_head *bh);
-#define J_ASSERT_BH(bh, expr)						\
-	do {								\
-		if (!(expr))						\
-			buffer_assertion_failure(bh);			\
-		J_ASSERT(expr);						\
-	} while (0)
-#define J_ASSERT_JH(jh, expr)	J_ASSERT_BH(jh2bh(jh), expr)
-#else
-#define J_ASSERT_BH(bh, expr)	J_ASSERT(expr)
-#define J_ASSERT_JH(jh, expr)	J_ASSERT(expr)
-#endif
-
-#else
-#define J_ASSERT(assert)
-#endif		/* JBD_ASSERTIONS */
-
-enum jbd_state_bits {
-	BH_JWrite
-	  = BH_PrivateStart,	/* 1 if being written to log (@@@ DEBUGGING) */
-	BH_Freed,		/* 1 if buffer has been freed (truncated) */
-	BH_Revoked,		/* 1 if buffer has been revoked from the log */
-	BH_RevokeValid,		/* 1 if buffer revoked flag is valid */
-	BH_JBDDirty,		/* 1 if buffer is dirty but journaled */
-};
-
-/* Return true if the buffer is one which JBD is managing */
-static inline int buffer_jbd(struct buffer_head *bh)
-{
-	return __buffer_state(bh, JBD);
-}
-
-static inline struct buffer_head *jh2bh(struct journal_head *jh)
-{
-	return jh->b_bh;
-}
-
-static inline struct journal_head *bh2jh(struct buffer_head *bh)
-{
-	return bh->b_private;
-}
-
-struct jbd_revoke_table_s;
-
-/* The handle_t type represents a single atomic update being performed
- * by some process.  All filesystem modifications made by the process go
- * through this handle.  Recursive operations (such as quota operations)
- * are gathered into a single update.
- *
- * The buffer credits field is used to account for journaled buffers
- * being modified by the running process.  To ensure that there is
- * enough log space for all outstanding operations, we need to limit the
- * number of outstanding buffers possible at any time.  When the
- * operation completes, any buffer credits not used are credited back to
- * the transaction, so that at all times we know how many buffers the
- * outstanding updates on a transaction might possibly touch. */
-
-struct handle_s 
-{
-	/* Which compound transaction is this update a part of? */
-	transaction_t	      * h_transaction;
-
-	/* Number of remaining buffers we are allowed to dirty: */
-	int			h_buffer_credits;
-
-	/* Reference count on this handle */
-	int			h_ref;
-
-	/* Field for caller's use to track errors through large fs
-	   operations */
-	int			h_err;
-
-	/* Flags */
-	unsigned int	h_sync:		1;	/* sync-on-close */
-	unsigned int	h_jdata:	1;	/* force data journaling */
-	unsigned int	h_aborted:	1;	/* fatal error on handle */
-};
-
-
-/* The transaction_t type is the guts of the journaling mechanism.  It
- * tracks a compound transaction through its various states:
- *
- * RUNNING:	accepting new updates
- * LOCKED:	Updates still running but we don't accept new ones
- * RUNDOWN:	Updates are tidying up but have finished requesting
- *		new buffers to modify (state not used for now)
- * FLUSH:       All updates complete, but we are still writing to disk
- * COMMIT:      All data on disk, writing commit record
- * FINISHED:	We still have to keep the transaction for checkpointing.
- *
- * The transaction keeps track of all of the buffers modified by a
- * running transaction, and all of the buffers committed but not yet
- * flushed to home for finished transactions.
- */
-
-struct transaction_s 
-{
-	/* Pointer to the journal for this transaction. */
-	journal_t *		t_journal;
-	
-	/* Sequence number for this transaction */
-	tid_t			t_tid;
-	
-	/* Transaction's current state */
-	enum {
-		T_RUNNING,
-		T_LOCKED,
-		T_RUNDOWN,
-		T_FLUSH,
-		T_COMMIT,
-		T_FINISHED 
-	}			t_state;
-
-	/* Where in the log does this transaction's commit start? */
-	unsigned long		t_log_start;
-	
-	/* Doubly-linked circular list of all inodes owned by this
-           transaction */	/* AKPM: unused */
-	struct inode *		t_ilist;
-	
-	/* Number of buffers on the t_buffers list */
-	int			t_nr_buffers;
-	
-	/* Doubly-linked circular list of all buffers reserved but not
-           yet modified by this transaction */
-	struct journal_head *	t_reserved_list;
-	
-	/* Doubly-linked circular list of all metadata buffers owned by this
-           transaction */
-	struct journal_head *	t_buffers;
-	
-	/*
-	 * Doubly-linked circular list of all data buffers still to be
-	 * flushed before this transaction can be committed.
-	 * Protected by journal_datalist_lock.
-	 */
-	struct journal_head *	t_sync_datalist;
-	
-	/*
-	 * Doubly-linked circular list of all writepage data buffers
-	 * still to be written before this transaction can be committed.
-	 * Protected by journal_datalist_lock.
-	 */
-	struct journal_head *	t_async_datalist;
-	
-	/* Doubly-linked circular list of all forget buffers (superceded
-           buffers which we can un-checkpoint once this transaction
-           commits) */
-	struct journal_head *	t_forget;
-	
-	/*
-	 * Doubly-linked circular list of all buffers still to be
-	 * flushed before this transaction can be checkpointed.
-	 */
-	/* Protected by journal_datalist_lock */
-	struct journal_head *	t_checkpoint_list;
-	
-	/* Doubly-linked circular list of temporary buffers currently
-           undergoing IO in the log */
-	struct journal_head *	t_iobuf_list;
-	
-	/* Doubly-linked circular list of metadata buffers being
-           shadowed by log IO.  The IO buffers on the iobuf list and the
-           shadow buffers on this list match each other one for one at
-           all times. */
-	struct journal_head *	t_shadow_list;
-	
-	/* Doubly-linked circular list of control buffers being written
-           to the log. */
-	struct journal_head *	t_log_list;
-	
-	/* Number of outstanding updates running on this transaction */
-	int			t_updates;
-
-	/* Number of buffers reserved for use by all handles in this
-	 * transaction handle but not yet modified. */
-	int			t_outstanding_credits;
-	
-	/*
-	 * Forward and backward links for the circular list of all
-	 * transactions awaiting checkpoint.
-	 */
-	/* Protected by journal_datalist_lock */
-	transaction_t		*t_cpnext, *t_cpprev;
-
-	/* When will the transaction expire (become due for commit), in
-	 * jiffies ? */
-	unsigned long		t_expires;
-
-	/* How many handles used this transaction? */
-	int t_handle_count;
-};
-
-
-/* The journal_t maintains all of the journaling state information for a
- * single filesystem.  It is linked to from the fs superblock structure.
- * 
- * We use the journal_t to keep track of all outstanding transaction
- * activity on the filesystem, and to manage the state of the log
- * writing process. */
-
-struct journal_s
-{
-	/* General journaling state flags */
-	unsigned long		j_flags;
-
-	/* Is there an outstanding uncleared error on the journal (from
-	 * a prior abort)? */
-	int			j_errno;
-	
-	/* The superblock buffer */
-	struct buffer_head *	j_sb_buffer;
-	journal_superblock_t *	j_superblock;
-
-	/* Version of the superblock format */
-	int			j_format_version;
-
-	/* Number of processes waiting to create a barrier lock */
-	int			j_barrier_count;
-	
-	/* The barrier lock itself */
-	struct semaphore	j_barrier;
-	
-	/* Transactions: The current running transaction... */
-	transaction_t *		j_running_transaction;
-	
-	/* ... the transaction we are pushing to disk ... */
-	transaction_t *		j_committing_transaction;
-	
-	/* ... and a linked circular list of all transactions waiting
-	 * for checkpointing. */
-	/* Protected by journal_datalist_lock */
-	transaction_t *		j_checkpoint_transactions;
-
-	/* Wait queue for waiting for a locked transaction to start
-           committing, or for a barrier lock to be released */
-	wait_queue_head_t	j_wait_transaction_locked;
-	
-	/* Wait queue for waiting for checkpointing to complete */
-	wait_queue_head_t	j_wait_logspace;
-	
-	/* Wait queue for waiting for commit to complete */
-	wait_queue_head_t	j_wait_done_commit;
-	
-	/* Wait queue to trigger checkpointing */
-	wait_queue_head_t	j_wait_checkpoint;
-	
-	/* Wait queue to trigger commit */
-	wait_queue_head_t	j_wait_commit;
-	
-	/* Wait queue to wait for updates to complete */
-	wait_queue_head_t	j_wait_updates;
-
-	/* Semaphore for locking against concurrent checkpoints */
-	struct semaphore 	j_checkpoint_sem;
-
-	/* The main journal lock, used by lock_journal() */
-	struct semaphore	j_sem;
-		
-	/* Journal head: identifies the first unused block in the journal. */
-	unsigned long		j_head;
-	
-	/* Journal tail: identifies the oldest still-used block in the
-	 * journal. */
-	unsigned long		j_tail;
-
-	/* Journal free: how many free blocks are there in the journal? */
-	unsigned long		j_free;
-
-	/* Journal start and end: the block numbers of the first usable
-	 * block and one beyond the last usable block in the journal. */
-	unsigned long		j_first, j_last;
-
-	/* Device, blocksize and starting block offset for the location
-	 * where we store the journal. */
-	kdev_t			j_dev;
-	int			j_blocksize;
-	unsigned int		j_blk_offset;
-
-	/* Device which holds the client fs.  For internal journal this
-	 * will be equal to j_dev. */
-	kdev_t			j_fs_dev;
-
-	/* Total maximum capacity of the journal region on disk. */
-	unsigned int		j_maxlen;
-
-	/* Optional inode where we store the journal.  If present, all
-	 * journal block numbers are mapped into this inode via
-	 * bmap(). */
-	struct inode *		j_inode;
-
-	/* Sequence number of the oldest transaction in the log */
-	tid_t			j_tail_sequence;
-	/* Sequence number of the next transaction to grant */
-	tid_t			j_transaction_sequence;
-	/* Sequence number of the most recently committed transaction */
-	tid_t			j_commit_sequence;
-	/* Sequence number of the most recent transaction wanting commit */
-	tid_t			j_commit_request;
-
-	/* Journal uuid: identifies the object (filesystem, LVM volume
-	 * etc) backed by this journal.  This will eventually be
-	 * replaced by an array of uuids, allowing us to index multiple
-	 * devices within a single journal and to perform atomic updates
-	 * across them.  */
-
-	__u8			j_uuid[16];
-
-	/* Pointer to the current commit thread for this journal */
-	struct task_struct *	j_task;
-
-	/* Maximum number of metadata buffers to allow in a single
-	 * compound commit transaction */
-	int			j_max_transaction_buffers;
-
-	/* What is the maximum transaction lifetime before we begin a
-	 * commit? */
-	unsigned long		j_commit_interval;
-
-	/* The timer used to wakeup the commit thread: */
-	struct timer_list *	j_commit_timer;
-	int			j_commit_timer_active;
-
-	/* Link all journals together - system-wide */
-	struct list_head	j_all_journals;
-
-	/* The revoke table: maintains the list of revoked blocks in the
-           current transaction. */
-	struct jbd_revoke_table_s *j_revoke;
-};
-
-/* 
- * Journal flag definitions 
- */
-#define JFS_UNMOUNT	0x001	/* Journal thread is being destroyed */
-#define JFS_ABORT	0x002	/* Journaling has been aborted for errors. */
-#define JFS_ACK_ERR	0x004	/* The errno in the sb has been acked */
-#define JFS_FLUSHED	0x008	/* The journal superblock has been flushed */
-#define JFS_LOADED	0x010	/* The journal superblock has been loaded */
-
-/* 
- * Function declarations for the journaling transaction and buffer
- * management
- */
-
-/* Filing buffers */
-extern void __journal_unfile_buffer(struct journal_head *);
-extern void journal_unfile_buffer(struct journal_head *);
-extern void __journal_refile_buffer(struct journal_head *);
-extern void journal_refile_buffer(struct journal_head *);
-extern void __journal_file_buffer(struct journal_head *, transaction_t *, int);
-extern void __journal_free_buffer(struct journal_head *bh);
-extern void journal_file_buffer(struct journal_head *, transaction_t *, int);
-extern void __journal_clean_data_list(transaction_t *transaction);
-
-/* Log buffer allocation */
-extern struct journal_head * journal_get_descriptor_buffer(journal_t *);
-extern unsigned long journal_next_log_block(journal_t *);
-
-/* Commit management */
-extern void journal_commit_transaction(journal_t *);
-
-/* Checkpoint list management */
-int __journal_clean_checkpoint_list(journal_t *journal);
-extern void journal_remove_checkpoint(struct journal_head *);
-extern void __journal_remove_checkpoint(struct journal_head *);
-extern void journal_insert_checkpoint(struct journal_head *, transaction_t *);
-extern void __journal_insert_checkpoint(struct journal_head *,transaction_t *);
-
-/* Buffer IO */
-extern int 
-journal_write_metadata_buffer(transaction_t	  *transaction,
-			      struct journal_head  *jh_in,
-			      struct journal_head **jh_out,
-			      int		   blocknr);
-
-/* Transaction locking */
-extern void		__wait_on_journal (journal_t *);
-
-/*
- * Journal locking.
- *
- * We need to lock the journal during transaction state changes so that
- * nobody ever tries to take a handle on the running transaction while
- * we are in the middle of moving it to the commit phase.  
- *
- * Note that the locking is completely interrupt unsafe.  We never touch
- * journal structures from interrupts.
- *
- * In 2.2, the BKL was required for lock_journal.  This is no longer
- * the case.
- */
-
-static inline void lock_journal(journal_t *journal)
-{
-	down(&journal->j_sem);
-}
-
-/* This returns zero if we acquired the semaphore */
-static inline int try_lock_journal(journal_t * journal)
-{
-	return down_trylock(&journal->j_sem);
-}
-
-static inline void unlock_journal(journal_t * journal)
-{
-	up(&journal->j_sem);
-}
-
-
-static inline handle_t *journal_current_handle(void)
-{
-	return current->journal_info;
-}
-
-/* The journaling code user interface:
- *
- * Create and destroy handles
- * Register buffer modifications against the current transaction. 
- */
-
-extern handle_t *journal_start(journal_t *, int nblocks);
-extern handle_t *journal_try_start(journal_t *, int nblocks);
-extern int	 journal_restart (handle_t *, int nblocks);
-extern int	 journal_extend (handle_t *, int nblocks);
-extern int	 journal_get_write_access (handle_t *, struct buffer_head *);
-extern int	 journal_get_create_access (handle_t *, struct buffer_head *);
-extern int	 journal_get_undo_access (handle_t *, struct buffer_head *);
-extern int	 journal_dirty_data (handle_t *,
-				struct buffer_head *, int async);
-extern int	 journal_dirty_metadata (handle_t *, struct buffer_head *);
-extern void	 journal_release_buffer (handle_t *, struct buffer_head *);
-extern void	 journal_forget (handle_t *, struct buffer_head *);
-extern void	 journal_sync_buffer (struct buffer_head *);
-extern int	 journal_flushpage(journal_t *, struct page *, unsigned long);
-extern int	 journal_try_to_free_buffers(journal_t *, struct page *, int);
-extern int	 journal_stop(handle_t *);
-extern int	 journal_flush (journal_t *);
-
-extern void	 journal_lock_updates (journal_t *);
-extern void	 journal_unlock_updates (journal_t *);
-
-extern journal_t * journal_init_dev(kdev_t dev, kdev_t fs_dev,
-				int start, int len, int bsize);
-extern journal_t * journal_init_inode (struct inode *);
-extern int	   journal_update_format (journal_t *);
-extern int	   journal_check_used_features 
-		   (journal_t *, unsigned long, unsigned long, unsigned long);
-extern int	   journal_check_available_features 
-		   (journal_t *, unsigned long, unsigned long, unsigned long);
-extern int	   journal_set_features 
-		   (journal_t *, unsigned long, unsigned long, unsigned long);
-extern int	   journal_create     (journal_t *);
-extern int	   journal_load       (journal_t *journal);
-extern void	   journal_destroy    (journal_t *);
-extern int	   journal_recover    (journal_t *journal);
-extern int	   journal_wipe       (journal_t *, int);
-extern int	   journal_skip_recovery (journal_t *);
-extern void	   journal_update_superblock (journal_t *, int);
-extern void	   __journal_abort      (journal_t *);
-extern void	   journal_abort      (journal_t *, int);
-extern int	   journal_errno      (journal_t *);
-extern void	   journal_ack_err    (journal_t *);
-extern int	   journal_clear_err  (journal_t *);
-extern unsigned long journal_bmap(journal_t *journal, unsigned long blocknr);
-extern int	    journal_force_commit(journal_t *journal);
-
-/*
- * journal_head management
- */
-extern struct journal_head
-		*journal_add_journal_head(struct buffer_head *bh);
-extern void	journal_remove_journal_head(struct buffer_head *bh);
-extern void	__journal_remove_journal_head(struct buffer_head *bh);
-extern void	journal_unlock_journal_head(struct journal_head *jh);
-
-/* Primary revoke support */
-#define JOURNAL_REVOKE_DEFAULT_HASH 256
-extern int	   journal_init_revoke(journal_t *, int);
-extern void	   journal_destroy_revoke_caches(void);
-extern int	   journal_init_revoke_caches(void);
-
-extern void	   journal_destroy_revoke(journal_t *);
-extern int	   journal_revoke (handle_t *,
-				unsigned long, struct buffer_head *);
-extern int	   journal_cancel_revoke(handle_t *, struct journal_head *);
-extern void	   journal_write_revoke_records(journal_t *, transaction_t *);
-
-/* Recovery revoke support */
-extern int	   journal_set_revoke(journal_t *, unsigned long, tid_t);
-extern int	   journal_test_revoke(journal_t *, unsigned long, tid_t);
-extern void	   journal_clear_revoke(journal_t *);
-extern void	   journal_brelse_array(struct buffer_head *b[], int n);
-
-/* The log thread user interface:
- *
- * Request space in the current transaction, and force transaction commit
- * transitions on demand.
- */
-
-extern int	log_space_left (journal_t *); /* Called with journal locked */
-extern tid_t	log_start_commit (journal_t *, transaction_t *);
-extern void	log_wait_commit (journal_t *, tid_t);
-extern int	log_do_checkpoint (journal_t *, int);
-
-extern void	log_wait_for_space(journal_t *, int nblocks);
-extern void	__journal_drop_transaction(journal_t *, transaction_t *);
-extern int	cleanup_journal_tail(journal_t *);
-
-/* Reduce journal memory usage by flushing */
-extern void shrink_journal_memory(void);
-
-/* Debugging code only: */
-
-#define jbd_ENOSYS() \
-do {								      \
-	printk (KERN_ERR "JBD unimplemented function " __FUNCTION__); \
-	current->state = TASK_UNINTERRUPTIBLE;			      \
-	schedule();						      \
-} while (1)
-
-/*
- * is_journal_abort
- *
- * Simple test wrapper function to test the JFS_ABORT state flag.  This
- * bit, when set, indicates that we have had a fatal error somewhere,
- * either inside the journaling layer or indicated to us by the client
- * (eg. ext3), and that we and should not commit any further
- * transactions.  
- */
-
-static inline int is_journal_aborted(journal_t *journal)
-{
-	return journal->j_flags & JFS_ABORT;
-}
-
-static inline int is_handle_aborted(handle_t *handle)
-{
-	if (handle->h_aborted)
-		return 1;
-	return is_journal_aborted(handle->h_transaction->t_journal);
-}
-
-static inline void journal_abort_handle(handle_t *handle)
-{
-	handle->h_aborted = 1;
-}
-
-/* Not all architectures define BUG() */
-#ifndef BUG
-#define BUG() do { \
-        printk("kernel BUG at %s:%d!\n", __FILE__, __LINE__); \
-	* ((char *) 0) = 0; \
- } while (0)
-#endif /* BUG */
-
-#else
-
-extern int	   journal_recover    (journal_t *journal);
-extern int	   journal_skip_recovery (journal_t *);
-
-/* Primary revoke support */
-extern int	   journal_init_revoke(journal_t *, int);
-extern void	   journal_destroy_revoke_caches(void);
-extern int	   journal_init_revoke_caches(void);
-
-/* Recovery revoke support */
-extern int	   journal_set_revoke(journal_t *, unsigned long, tid_t);
-extern int	   journal_test_revoke(journal_t *, unsigned long, tid_t);
-extern void	   journal_clear_revoke(journal_t *);
-extern void	   journal_brelse_array(struct buffer_head *b[], int n);
-
-extern void	   journal_destroy_revoke(journal_t *);
-#endif /* __KERNEL__   */
-
-/* Comparison functions for transaction IDs: perform comparisons using
- * modulo arithmetic so that they work over sequence number wraps. */
-
-static inline int tid_gt(tid_t x, tid_t y)
-{
-	int difference = (x - y);
-	return (difference > 0);
-}
-
-static inline int tid_geq(tid_t x, tid_t y)
-{
-	int difference = (x - y);
-	return (difference >= 0);
-}
-
-extern int journal_blocks_per_page(struct inode *inode);
-
-/*
- * Definitions which augment the buffer_head layer
- */
-
-/* journaling buffer types */
-#define BJ_None		0	/* Not journaled */
-#define BJ_SyncData	1	/* Normal data: flush before commit */
-#define BJ_AsyncData	2	/* writepage data: wait on it before commit */
-#define BJ_Metadata	3	/* Normal journaled metadata */
-#define BJ_Forget	4	/* Buffer superceded by this transaction */
-#define BJ_IO		5	/* Buffer is for temporary IO use */
-#define BJ_Shadow	6	/* Buffer contents being shadowed to the log */
-#define BJ_LogCtl	7	/* Buffer contains log descriptors */
-#define BJ_Reserved	8	/* Buffer is reserved for access by journal */
-#define BJ_Types	9
- 
-extern int jbd_blocks_per_page(struct inode *inode);
-
-#ifdef __KERNEL__
-
-extern spinlock_t jh_splice_lock;
-/*
- * Once `expr1' has been found true, take jh_splice_lock
- * and then reevaluate everything.
- */
-#define SPLICE_LOCK(expr1, expr2)				\
-	({							\
-		int ret = (expr1);				\
-		if (ret) {					\
-			spin_lock(&jh_splice_lock);		\
-			ret = (expr1) && (expr2);		\
-			spin_unlock(&jh_splice_lock);		\
-		}						\
-		ret;						\
-	})
-
-/*
- * A number of buffer state predicates.  They test for
- * buffer_jbd() because they are used in core kernel code.
- *
- * These will be racy on SMP unless we're *sure* that the
- * buffer won't be detached from the journalling system
- * in parallel.
- */
-
-/* Return true if the buffer is on journal list `list' */
-static inline int buffer_jlist_eq(struct buffer_head *bh, int list)
-{
-	return SPLICE_LOCK(buffer_jbd(bh), bh2jh(bh)->b_jlist == list);
-}
-
-/* Return true if this bufer is dirty wrt the journal */
-static inline int buffer_jdirty(struct buffer_head *bh)
-{
-	return buffer_jbd(bh) && __buffer_state(bh, JBDDirty);
-}
-
-/* Return true if it's a data buffer which journalling is managing */
-static inline int buffer_jbd_data(struct buffer_head *bh)
-{
-	return SPLICE_LOCK(buffer_jbd(bh),
-			bh2jh(bh)->b_jlist == BJ_SyncData ||
-			bh2jh(bh)->b_jlist == BJ_AsyncData);
-}
-
-#ifdef CONFIG_SMP
-#define assert_spin_locked(lock)	J_ASSERT(spin_is_locked(lock))
-#else
-#define assert_spin_locked(lock)	do {} while(0)
-#endif
-
-#define buffer_trace_init(bh)	do {} while (0)
-#define print_buffer_fields(bh)	do {} while (0)
-#define print_buffer_trace(bh)	do {} while (0)
-#define BUFFER_TRACE(bh, info)	do {} while (0)
-#define BUFFER_TRACE2(bh, bh2, info)	do {} while (0)
-#define JBUFFER_TRACE(jh, info)	do {} while (0)
-
-#endif	/* __KERNEL__ */
-
-#endif	/* CONFIG_JBD || CONFIG_JBD_MODULE || !__KERNEL__ */
-
-/*
- * Compatibility no-ops which allow the kernel to compile without CONFIG_JBD
- * go here.
- */
-
-#if defined(__KERNEL__) && !(defined(CONFIG_JBD) || defined(CONFIG_JBD_MODULE))
-
-#define J_ASSERT(expr)			do {} while (0)
-#define J_ASSERT_BH(bh, expr)		do {} while (0)
-#define buffer_jbd(bh)			0
-#define buffer_jlist_eq(bh, val)	0
-#define journal_buffer_journal_lru(bh)	0
-
-#endif	/* defined(__KERNEL__) && !defined(CONFIG_JBD) */
-#endif	/* _LINUX_JBD_H */

Modified: trunk/libocfs2/include/ocfs2.h
===================================================================
--- trunk/libocfs2/include/ocfs2.h	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/include/ocfs2.h	2005-08-12 23:32:43 UTC (rev 1043)
@@ -52,12 +52,12 @@
 
 #if OCFS2_FLAT_INCLUDES
 #include "ocfs2_err.h"
-
 #include "ocfs2_fs.h"
+#include "jbd.h"
 #else
 #include <ocfs2/ocfs2_err.h>
-
 #include <ocfs2/ocfs2_fs.h>
+#include <ocfs2/jbd.h>
 #endif
 
 #include <o2dlm.h>
@@ -253,8 +253,8 @@
 errcode_t ocfs2_close(ocfs2_filesys *fs);
 void ocfs2_freefs(ocfs2_filesys *fs);
 
+void ocfs2_swap_inode_from_cpu(ocfs2_dinode *di);
 void ocfs2_swap_inode_to_cpu(ocfs2_dinode *di);
-void ocfs2_swap_inode_to_le(ocfs2_dinode *di);
 errcode_t ocfs2_read_inode(ocfs2_filesys *fs, uint64_t blkno,
 			   char *inode_buf);
 errcode_t ocfs2_write_inode(ocfs2_filesys *fs, uint64_t blkno,
@@ -268,6 +268,8 @@
 errcode_t ocfs2_free_cached_inode(ocfs2_filesys *fs,
 				  ocfs2_cached_inode *cinode);
 
+void ocfs2_swap_extent_list_from_cpu(ocfs2_extent_list *el);
+void ocfs2_swap_extent_list_to_cpu(ocfs2_extent_list *el);
 errcode_t ocfs2_extent_map_init(ocfs2_filesys *fs,
 				ocfs2_cached_inode *cinode);
 void ocfs2_extent_map_free(ocfs2_cached_inode *cinode);
@@ -292,9 +294,9 @@
 errcode_t ocfs2_load_extent_map(ocfs2_filesys *fs,
 				ocfs2_cached_inode *cinode);
 
+void ocfs2_swap_journal_superblock(journal_superblock_t *jsb);
 errcode_t ocfs2_init_journal_superblock(ocfs2_filesys *fs, char *buf,
 					int buflen, uint32_t jrnl_size);
-
 errcode_t ocfs2_create_journal_superblock(ocfs2_filesys *fs,
 					  uint32_t size, int flags,
 					  char **ret_jsb);
@@ -350,6 +352,8 @@
 						void *priv_data),
 				    void *priv_data);
 
+errcode_t ocfs2_swap_dir_entries_from_cpu(void *buf, uint64_t bytes);
+errcode_t ocfs2_swap_dir_entries_to_cpu(void *buf, uint64_t bytes);
 errcode_t ocfs2_read_dir_block(ocfs2_filesys *fs, uint64_t block,
 			       void *buf);
 errcode_t ocfs2_write_dir_block(ocfs2_filesys *fs, uint64_t block,
@@ -440,6 +444,7 @@
 errcode_t ocfs2_read_whole_file(ocfs2_filesys *fs, uint64_t blkno,
 				char **buf, int *len);
 
+void ocfs2_swap_disk_heartbeat_block(struct o2hb_disk_heartbeat_block *hb);
 errcode_t ocfs2_check_heartbeat(char *device, int *mount_flags,
 				struct list_head *nodes_list);
 
@@ -448,6 +453,7 @@
 errcode_t ocfs2_get_ocfs1_label(char *device, uint8_t *label, uint16_t label_len,
 				uint8_t *uuid, uint16_t uuid_len);
 
+void ocfs2_swap_group_desc(ocfs2_group_desc *gd);
 errcode_t ocfs2_read_group_desc(ocfs2_filesys *fs, uint64_t blkno,
 				char *gd_buf);
 
@@ -569,6 +575,8 @@
 
 errcode_t ocfs2_meta_unlock(ocfs2_filesys *fs, ocfs2_cached_inode *ci);
 
+void ocfs2_swap_slot_map(int16_t *map, loff_t num_slots);
+
 /* 
  * ${foo}_to_${bar} is a floor function.  blocks_to_clusters will
  * returns the cluster that contains a block, not the number of clusters

Modified: trunk/libocfs2/inode.c
===================================================================
--- trunk/libocfs2/inode.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/inode.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -62,48 +62,151 @@
 	return ret;
 }
 
-
-/* FIXME swap rest of inode as kernel is updated */
-void ocfs2_swap_inode_to_cpu(ocfs2_dinode *di)
+static void ocfs2_swap_inode_third(ocfs2_dinode *di)
 {
-	di->i_generation    = le32_to_cpu(di->i_generation);
-	di->i_suballoc_slot = le16_to_cpu(di->i_suballoc_slot);
-	di->i_suballoc_bit  = le16_to_cpu(di->i_suballoc_bit);
-	di->i_fs_generation = le32_to_cpu(di->i_fs_generation);
 
-	if (S_ISCHR(di->i_mode) || S_ISBLK(di->i_mode))
-		di->id1.dev1.i_rdev = le64_to_cpu(di->id1.dev1.i_rdev);
-	else if (di->i_flags & OCFS2_JOURNAL_FL)
-		di->id1.journal1.ij_flags =
-			le32_to_cpu(di->id1.journal1.ij_flags);
-	else if (di->i_flags & OCFS2_BITMAP_FL) {
-		di->id1.bitmap1.i_total = 
-			le32_to_cpu(di->id1.bitmap1.i_total);
-		di->id1.bitmap1.i_used = 
-			le32_to_cpu(di->id1.bitmap1.i_used);
-	} 
+	if (di->i_flags & OCFS2_CHAIN_FL) {
+		ocfs2_chain_list *cl = &di->id2.i_chain;
+		uint16_t i;
+
+		for (i = 0; i < cl->cl_next_free_rec; i++) {
+			ocfs2_chain_rec *rec = &cl->cl_recs[i];
+
+			rec->c_free  = bswap_32(rec->c_free);
+			rec->c_total = bswap_32(rec->c_total);
+			rec->c_blkno = bswap_64(rec->c_blkno);
+		}
+
+	} else if (di->i_flags & OCFS2_DEALLOC_FL) {
+		ocfs2_truncate_log *tl = &di->id2.i_dealloc;
+		uint16_t i;
+
+		for(i = 0; i < tl->tl_count; i++) {
+			ocfs2_truncate_rec *rec = &tl->tl_recs[i];
+
+			rec->t_start    = bswap_32(rec->t_start);
+			rec->t_clusters = bswap_32(rec->t_clusters);
+		}
+	}
 }
 
-void ocfs2_swap_inode_to_le(ocfs2_dinode *di)
+static void ocfs2_swap_inode_second(ocfs2_dinode *di)
 {
-	di->i_generation    = cpu_to_le32(di->i_generation);
-	di->i_suballoc_slot = cpu_to_le16(di->i_suballoc_slot);
-	di->i_suballoc_bit  = cpu_to_le16(di->i_suballoc_bit);
-	di->i_fs_generation = cpu_to_le32(di->i_fs_generation);
-
 	if (S_ISCHR(di->i_mode) || S_ISBLK(di->i_mode))
-		di->id1.dev1.i_rdev = cpu_to_le64(di->id1.dev1.i_rdev);
-	else if (di->i_flags & OCFS2_JOURNAL_FL)
-		di->id1.journal1.ij_flags =
-			cpu_to_le32(di->id1.journal1.ij_flags);
+		di->id1.dev1.i_rdev = bswap_64(di->id1.dev1.i_rdev);
 	else if (di->i_flags & OCFS2_BITMAP_FL) {
-		di->id1.bitmap1.i_total = 
-			cpu_to_le32(di->id1.bitmap1.i_total);
-		di->id1.bitmap1.i_used = 
-			cpu_to_le32(di->id1.bitmap1.i_used);
+		di->id1.bitmap1.i_used = bswap_32(di->id1.bitmap1.i_used);
+		di->id1.bitmap1.i_total = bswap_32(di->id1.bitmap1.i_total);
+	} else if (di->i_flags & OCFS2_JOURNAL_FL)
+		di->id1.journal1.ij_flags = bswap_32(di->id1.journal1.ij_flags);
+
+	/* we need to be careful to swap the union member that is in use.
+	 * first the ones that are explicitly marked with flags.. */ 
+	if (di->i_flags & OCFS2_SUPER_BLOCK_FL) {
+		ocfs2_super_block *sb = &di->id2.i_super;
+
+		sb->s_major_rev_level     = bswap_16(sb->s_major_rev_level);
+		sb->s_minor_rev_level     = bswap_16(sb->s_minor_rev_level);
+		sb->s_mnt_count           = bswap_16(sb->s_mnt_count);
+		sb->s_max_mnt_count       = bswap_16(sb->s_max_mnt_count);
+		sb->s_state               = bswap_16(sb->s_state);
+		sb->s_errors              = bswap_16(sb->s_errors);
+		sb->s_checkinterval       = bswap_32(sb->s_checkinterval);
+		sb->s_lastcheck           = bswap_64(sb->s_lastcheck);
+		sb->s_creator_os          = bswap_32(sb->s_creator_os);
+		sb->s_feature_compat      = bswap_32(sb->s_feature_compat);
+		sb->s_feature_ro_compat   = bswap_32(sb->s_feature_ro_compat);
+		sb->s_feature_incompat    = bswap_32(sb->s_feature_incompat);
+		sb->s_root_blkno          = bswap_64(sb->s_root_blkno);
+		sb->s_system_dir_blkno    = bswap_64(sb->s_system_dir_blkno);
+		sb->s_blocksize_bits      = bswap_32(sb->s_blocksize_bits);
+		sb->s_clustersize_bits    = bswap_32(sb->s_clustersize_bits);
+		sb->s_max_slots           = bswap_16(sb->s_max_slots);
+		sb->s_first_cluster_group = bswap_64(sb->s_first_cluster_group);
+
+	} else if (di->i_flags & OCFS2_LOCAL_ALLOC_FL) {
+		ocfs2_local_alloc *la = &di->id2.i_lab;
+
+		la->la_bm_off = bswap_32(la->la_bm_off);
+		la->la_size   = bswap_16(la->la_size);
+
+	} else if (di->i_flags & OCFS2_CHAIN_FL) {
+		ocfs2_chain_list *cl = &di->id2.i_chain;
+
+		cl->cl_cpg           = bswap_16(cl->cl_cpg);
+		cl->cl_bpc           = bswap_16(cl->cl_bpc);
+		cl->cl_count         = bswap_16(cl->cl_count);
+		cl->cl_next_free_rec = bswap_16(cl->cl_next_free_rec);
+
+	} else if (di->i_flags & OCFS2_DEALLOC_FL) {
+		ocfs2_truncate_log *tl = &di->id2.i_dealloc;
+
+		tl->tl_count = bswap_16(tl->tl_count);
+		tl->tl_used  = bswap_16(tl->tl_used);
 	}
 }
 
+static void ocfs2_swap_inode_first(ocfs2_dinode *di)
+{
+	di->i_generation    = bswap_32(di->i_generation);
+	di->i_suballoc_slot = bswap_16(di->i_suballoc_slot);
+	di->i_suballoc_bit  = bswap_16(di->i_suballoc_bit);
+	di->i_clusters      = bswap_32(di->i_clusters);
+	di->i_uid           = bswap_32(di->i_uid);
+	di->i_gid           = bswap_32(di->i_gid);
+	di->i_size          = bswap_64(di->i_size);
+	di->i_mode          = bswap_16(di->i_mode);
+	di->i_links_count   = bswap_16(di->i_links_count);
+	di->i_flags         = bswap_32(di->i_flags);
+	di->i_atime         = bswap_64(di->i_atime);
+	di->i_ctime         = bswap_64(di->i_ctime);
+	di->i_mtime         = bswap_64(di->i_mtime);
+	di->i_dtime         = bswap_64(di->i_dtime);
+	di->i_blkno         = bswap_64(di->i_blkno);
+	di->i_last_eb_blk   = bswap_64(di->i_last_eb_blk);
+	di->i_fs_generation = bswap_32(di->i_fs_generation);
+	di->i_atime_nsec    = bswap_32(di->i_atime_nsec);
+	di->i_ctime_nsec    = bswap_32(di->i_ctime_nsec);
+	di->i_mtime_nsec    = bswap_32(di->i_mtime_nsec);
+}
+
+static int has_extents(ocfs2_dinode *di)
+{
+	/* inodes flagged with other stuff in id2 */
+	if (di->i_flags & (OCFS2_SUPER_BLOCK_FL | OCFS2_LOCAL_ALLOC_FL |
+			   OCFS2_CHAIN_FL | OCFS2_DEALLOC_FL))
+		return 0;
+	/* i_flags doesn't indicate when id2 is a fast symlink */
+	if (S_ISLNK(di->i_mode) && di->i_size && di->i_clusters == 0)
+		return 0;
+
+	return 1;
+}
+
+void ocfs2_swap_inode_from_cpu(ocfs2_dinode *di)
+{
+	if (cpu_is_little_endian)
+		return;
+
+	if (has_extents(di))
+		ocfs2_swap_extent_list_from_cpu(&di->id2.i_list);
+	ocfs2_swap_inode_third(di);
+	ocfs2_swap_inode_second(di);
+	ocfs2_swap_inode_first(di);
+}
+
+void ocfs2_swap_inode_to_cpu(ocfs2_dinode *di)
+{
+	if (cpu_is_little_endian)
+		return;
+
+	ocfs2_swap_inode_first(di);
+	ocfs2_swap_inode_second(di);
+	ocfs2_swap_inode_third(di);
+	if (has_extents(di))
+		ocfs2_swap_extent_list_to_cpu(&di->id2.i_list);
+}
+
 errcode_t ocfs2_read_inode(ocfs2_filesys *fs, uint64_t blkno,
 			   char *inode_buf)
 {
@@ -163,7 +266,7 @@
 	memcpy(blk, inode_buf, fs->fs_blocksize);
 
 	di = (ocfs2_dinode *)blk;
-	ocfs2_swap_inode_to_le(di);
+	ocfs2_swap_inode_from_cpu(di);
 
 	ret = io_write_block(fs->fs_io, blkno, 1, blk);
 	if (ret)

Modified: trunk/libocfs2/inode_scan.c
===================================================================
--- trunk/libocfs2/inode_scan.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/inode_scan.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -86,8 +86,8 @@
 	if (!scan->cur_blkno)
 		abort();
 
-	ret = io_read_block(scan->fs->fs_io, scan->cur_blkno, 1,
-			    (char *)scan->cur_desc);
+	ret = ocfs2_read_group_desc(scan->fs, scan->cur_blkno,
+				    (char *)scan->cur_desc);
 	if (ret)
 		return (ret);
 
@@ -175,10 +175,10 @@
 	if (num_blocks > scan->buffer_blocks)
 		num_blocks = scan->buffer_blocks;
 
-	ret = io_read_block(scan->fs->fs_io,
-			    scan->cur_blkno,
-			    num_blocks,
-			    scan->group_buffer);
+       ret = io_read_block(scan->fs->fs_io,
+			   scan->cur_blkno,
+			   num_blocks,
+			   scan->group_buffer);
 	if (ret)
 		return ret;
 
@@ -239,7 +239,7 @@
 			return ret;
 	}
 	
-	/* FIXME: Should swap the inode */
+	/* the caller swap after verifying the inode's signature */
 	memcpy(inode, scan->cur_block, scan->fs->fs_blocksize);
 
 	scan->cur_block += scan->fs->fs_blocksize;

Modified: trunk/libocfs2/mkjournal.c
===================================================================
--- trunk/libocfs2/mkjournal.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/mkjournal.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -32,13 +32,32 @@
 #include <netinet/in.h>
 
 #include "ocfs2.h"
+#include "jbd.h"
 
-/* jfs_compat.h defines these */
-#undef cpu_to_be32
-#undef be32_to_cpu
-#include "jfs_user.h"
+void ocfs2_swap_journal_superblock(journal_superblock_t *jsb)
+{
+	if (cpu_is_big_endian)
+		return;
 
+	jsb->s_header.h_magic     = bswap_32(jsb->s_header.h_magic);
+	jsb->s_header.h_blocktype = bswap_32(jsb->s_header.h_blocktype);
+	jsb->s_header.h_sequence  = bswap_32(jsb->s_header.h_sequence);
 
+	jsb->s_blocksize         = bswap_32(jsb->s_blocksize);
+	jsb->s_maxlen            = bswap_32(jsb->s_maxlen);
+	jsb->s_first             = bswap_32(jsb->s_first);
+	jsb->s_sequence          = bswap_32(jsb->s_sequence);
+	jsb->s_start             = bswap_32(jsb->s_start);
+	jsb->s_errno             = bswap_32(jsb->s_errno);
+	jsb->s_feature_compat    = bswap_32(jsb->s_feature_compat);
+	jsb->s_feature_incompat  = bswap_32(jsb->s_feature_incompat);
+	jsb->s_feature_ro_compat = bswap_32(jsb->s_feature_ro_compat);
+	jsb->s_nr_users          = bswap_32(jsb->s_nr_users);
+	jsb->s_dynsuper          = bswap_32(jsb->s_dynsuper);
+	jsb->s_max_transaction   = bswap_32(jsb->s_max_transaction);
+	jsb->s_max_trans_data    = bswap_32(jsb->s_max_trans_data);
+}
+
 /*
  * The code to init a journal superblock is also in
  * mkfs.ocfs2/mkfs.c:replacement_journal_create().
@@ -56,21 +75,21 @@
 		return OCFS2_ET_JOURNAL_TOO_SMALL;
 
 	memset(buf, 0, buflen);
-	jsb->s_header.h_magic     = htonl(JFS_MAGIC_NUMBER);
-	jsb->s_header.h_blocktype = htonl(JFS_SUPERBLOCK_V2);
+	jsb->s_header.h_magic     = JFS_MAGIC_NUMBER;
+	jsb->s_header.h_blocktype = JFS_SUPERBLOCK_V2;
 
-	jsb->s_blocksize = cpu_to_be32(fs->fs_blocksize);
-	jsb->s_maxlen    = cpu_to_be32(jrnl_size_in_blks);
+	jsb->s_blocksize = fs->fs_blocksize;
+	jsb->s_maxlen    = jrnl_size_in_blks;
 
 	if (fs->fs_blocksize == 512)
-		jsb->s_first = htonl(2);
+		jsb->s_first = 2;
 	else
-		jsb->s_first = htonl(1);
+		jsb->s_first = 1;
 
-	jsb->s_start    = htonl(1);
-	jsb->s_sequence = htonl(1);
-	jsb->s_errno    = htonl(0);
-	jsb->s_nr_users = htonl(1);
+	jsb->s_start    = 1;
+	jsb->s_sequence = 1;
+	jsb->s_errno    = 0;
+	jsb->s_nr_users = 1;
 
 	memcpy(jsb->s_uuid, OCFS2_RAW_SB(fs->fs_super)->s_uuid,
 	       sizeof(jsb->s_uuid));
@@ -107,9 +126,9 @@
 	    EXT3_FEATURE_INCOMPAT_JOURNAL_DEV) {
 		jsb->s_nr_users = 0;
 		if (fs->blocksize == 1024)
-			jsb->s_first = htonl(3);
+			jsb->s_first = 3;
 		else
-			jsb->s_first = htonl(2);
+			jsb->s_first = 2;
 	}
 #endif
 
@@ -149,18 +168,8 @@
 	}
 
 	memcpy(jsb_buf, blk, fs->fs_blocksize);
+	ocfs2_swap_journal_superblock(jsb);
 
-	/* XXX incomplete */
-	jsb->s_header.h_magic = be32_to_cpu(disk->s_header.h_magic);
-	jsb->s_header.h_blocktype = be32_to_cpu(disk->s_header.h_blocktype);
-
-	jsb->s_blocksize = be32_to_cpu(disk->s_blocksize);
-	jsb->s_maxlen = be32_to_cpu(disk->s_maxlen);
-	jsb->s_first = be32_to_cpu(disk->s_first);
-	jsb->s_start = be32_to_cpu(disk->s_start);
-	jsb->s_sequence = be32_to_cpu(disk->s_sequence);
-	jsb->s_errno = be32_to_cpu(disk->s_errno);
-
 	ret = 0;
 out:
 	ocfs2_free(&blk);
@@ -190,18 +199,8 @@
 	jsb = (journal_superblock_t *)jsb_buf;
 
 	memcpy(blk, jsb_buf, fs->fs_blocksize);
+	ocfs2_swap_journal_superblock(disk);
 
-	/* XXX incomplete */
-	disk->s_header.h_magic = cpu_to_be32(jsb->s_header.h_magic);
-	disk->s_header.h_blocktype = cpu_to_be32(jsb->s_header.h_blocktype);
-
-	disk->s_blocksize = cpu_to_be32(jsb->s_blocksize);
-	disk->s_maxlen = cpu_to_be32(jsb->s_maxlen);
-	disk->s_first = cpu_to_be32(jsb->s_first);
-	disk->s_start = cpu_to_be32(jsb->s_start);
-	disk->s_sequence = cpu_to_be32(jsb->s_sequence);
-	disk->s_errno = cpu_to_be32(jsb->s_errno);
-
 	ret = io_write_block(fs->fs_io, blkno, 1, blk);
 	if (ret)
 		goto out;

Modified: trunk/libocfs2/openfs.c
===================================================================
--- trunk/libocfs2/openfs.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/libocfs2/openfs.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -71,58 +71,6 @@
 	return ret;
 }
 
-static void ocfs2_swap_super_to_cpu(ocfs2_dinode *di)
-{
-	ocfs2_super_block *sb;
-
-	ocfs2_swap_inode_to_cpu(di);
-
-	sb = &di->id2.i_super;
-	sb->s_major_rev_level     = le16_to_cpu(sb->s_major_rev_level);
-	sb->s_minor_rev_level     = le16_to_cpu(sb->s_minor_rev_level);
-	sb->s_mnt_count           = le16_to_cpu(sb->s_mnt_count);
-	sb->s_max_mnt_count       = le16_to_cpu(sb->s_max_mnt_count);
-	sb->s_state               = le16_to_cpu(sb->s_state);
-	sb->s_checkinterval       = le32_to_cpu(sb->s_checkinterval);
-	sb->s_lastcheck           = le64_to_cpu(sb->s_lastcheck);
-	sb->s_creator_os          = le32_to_cpu(sb->s_creator_os);
-	sb->s_feature_compat      = le32_to_cpu(sb->s_feature_compat);
-	sb->s_feature_ro_compat   = le32_to_cpu(sb->s_feature_ro_compat);
-	sb->s_feature_incompat    = le32_to_cpu(sb->s_feature_incompat);
-	sb->s_root_blkno          = le64_to_cpu(sb->s_root_blkno);
-	sb->s_system_dir_blkno    = le64_to_cpu(sb->s_system_dir_blkno);
-	sb->s_blocksize_bits      = le32_to_cpu(sb->s_blocksize_bits);
-	sb->s_clustersize_bits    = le32_to_cpu(sb->s_clustersize_bits);
-	sb->s_max_slots           = le16_to_cpu(sb->s_max_slots);
-	sb->s_first_cluster_group = le64_to_cpu(sb->s_first_cluster_group);
-}
-
-static void ocfs2_swap_super_to_le(ocfs2_dinode *di)
-{
-	ocfs2_super_block *sb;
-
-	ocfs2_swap_inode_to_le(di);
-
-	sb = &di->id2.i_super;
-	sb->s_major_rev_level     = cpu_to_le16(sb->s_major_rev_level);
-	sb->s_minor_rev_level     = cpu_to_le16(sb->s_minor_rev_level);
-	sb->s_mnt_count           = cpu_to_le16(sb->s_mnt_count);
-	sb->s_max_mnt_count       = cpu_to_le16(sb->s_max_mnt_count);
-	sb->s_state               = cpu_to_le16(sb->s_state);
-	sb->s_checkinterval       = cpu_to_le32(sb->s_checkinterval);
-	sb->s_lastcheck           = cpu_to_le64(sb->s_lastcheck);
-	sb->s_creator_os          = cpu_to_le32(sb->s_creator_os);
-	sb->s_feature_compat      = cpu_to_le32(sb->s_feature_compat);
-	sb->s_feature_ro_compat   = cpu_to_le32(sb->s_feature_ro_compat);
-	sb->s_feature_incompat    = cpu_to_le32(sb->s_feature_incompat);
-	sb->s_root_blkno          = cpu_to_le64(sb->s_root_blkno);
-	sb->s_system_dir_blkno    = cpu_to_le64(sb->s_system_dir_blkno);
-	sb->s_blocksize_bits      = cpu_to_le32(sb->s_blocksize_bits);
-	sb->s_clustersize_bits    = cpu_to_le32(sb->s_clustersize_bits);
-	sb->s_max_slots           = cpu_to_le16(sb->s_max_slots);
-	sb->s_first_cluster_group = cpu_to_le64(sb->s_first_cluster_group);
-}
-
 static errcode_t ocfs2_read_super(ocfs2_filesys *fs, int superblock)
 {
 	errcode_t ret;
@@ -143,8 +91,7 @@
 		   strlen(OCFS2_SUPER_BLOCK_SIGNATURE)))
 		goto out_blk;
 
-	ocfs2_swap_super_to_cpu(di);
-
+	ocfs2_swap_inode_to_cpu(di);
 	fs->fs_super = di;
 
 	return 0;
@@ -172,9 +119,7 @@
 		   strlen(OCFS2_SUPER_BLOCK_SIGNATURE)))
 		goto out_blk;
 
-	ocfs2_swap_super_to_le(di);
-	ret = io_write_block(fs->fs_io, OCFS2_SUPER_BLOCK_BLKNO, 1, blk);
-	ocfs2_swap_super_to_cpu(di);
+	ret = ocfs2_write_inode(fs, OCFS2_SUPER_BLOCK_BLKNO, blk);
 	if (ret)
 		goto out_blk;
 

Copied: trunk/libocfs2/slot_map.c (from rev 1042, branches/endian-safe/libocfs2/slot_map.c)

Modified: trunk/mkfs.ocfs2/mkfs.c
===================================================================
--- trunk/mkfs.ocfs2/mkfs.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/mkfs.ocfs2/mkfs.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -1077,7 +1077,7 @@
 	memset(group->gd, 0, s->blocksize);
 
 	strcpy(group->gd->bg_signature, OCFS2_GROUP_DESC_SIGNATURE);
-	group->gd->bg_generation = cpu_to_le32(s->vol_generation);
+	group->gd->bg_generation = s->vol_generation;
 	group->gd->bg_size = (uint32_t)ocfs2_group_bitmap_size(s->blocksize);
 	group->gd->bg_bits = cpg * bpc;
 	group->gd->bg_chain = chain;
@@ -1396,15 +1396,15 @@
 
 	if (dir->buf) {
 		de = (struct ocfs2_dir_entry *)(dir->buf + dir->last_off);
-		rec_len = le16_to_cpu(de->rec_len);
+		rec_len = de->rec_len;
 		real_len = OCFS2_DIR_REC_LEN(de->name_len);
 
-		if ((le64_to_cpu(de->inode) == 0 && rec_len >= new_rec_len) ||
+		if ((de->inode == 0 && rec_len >= new_rec_len) ||
 		    (rec_len >= real_len + new_rec_len)) {
-			if (le64_to_cpu(de->inode)) {
+			if (de->inode) {
 				de1 =(struct ocfs2_dir_entry *) ((char *) de + real_len);
-				de1->rec_len = cpu_to_le16(le16_to_cpu(de->rec_len) - real_len);
-				de->rec_len = cpu_to_le16(real_len);
+				de1->rec_len = de->rec_len - real_len;
+				de->rec_len = real_len;
 				de = de1;
 			}
 
@@ -1438,12 +1438,12 @@
 
 	de = (struct ocfs2_dir_entry *)p;
 	de->inode = 0;
-	de->rec_len = cpu_to_le16(s->blocksize);
+	de->rec_len = s->blocksize;
 
 got_it:
 	de->name_len = strlen(name);
 
-	de->inode = cpu_to_le64(byte_off >> s->blocksize_bits);
+	de->inode = byte_off >> s->blocksize_bits;
 
 	de->file_type = type;
 
@@ -1554,10 +1554,10 @@
 	memset(di, 0, s->blocksize);
 
 	strcpy(di->i_signature, OCFS2_SUPER_BLOCK_SIGNATURE);
-	di->i_suballoc_slot = cpu_to_le16((__u16)OCFS2_INVALID_SLOT);
-	di->i_suballoc_bit = cpu_to_le16((__u16)-1);
-	di->i_generation = cpu_to_le32(s->vol_generation);
-	di->i_fs_generation = cpu_to_le32(s->vol_generation);
+	di->i_suballoc_slot = (__u16)OCFS2_INVALID_SLOT;
+	di->i_suballoc_bit = (__u16)-1;
+	di->i_generation = s->vol_generation;
+	di->i_fs_generation = s->vol_generation;
 
 	di->i_atime = 0;
 	di->i_ctime = s->format_time;
@@ -1565,31 +1565,32 @@
 	di->i_blkno = super_off >> s->blocksize_bits;
 	di->i_flags = OCFS2_VALID_FL | OCFS2_SYSTEM_FL | OCFS2_SUPER_BLOCK_FL;
 	di->i_clusters = s->volume_size_in_clusters;
-	di->id2.i_super.s_major_rev_level = cpu_to_le16(OCFS2_MAJOR_REV_LEVEL);
-	di->id2.i_super.s_minor_rev_level = cpu_to_le16(OCFS2_MINOR_REV_LEVEL);
-	di->id2.i_super.s_root_blkno = cpu_to_le64(root_rec->fe_off >> s->blocksize_bits);
-	di->id2.i_super.s_system_dir_blkno = cpu_to_le64(sys_rec->fe_off >> s->blocksize_bits);
+	di->id2.i_super.s_major_rev_level = OCFS2_MAJOR_REV_LEVEL;
+	di->id2.i_super.s_minor_rev_level = OCFS2_MINOR_REV_LEVEL;
+	di->id2.i_super.s_root_blkno = root_rec->fe_off >> s->blocksize_bits;
+	di->id2.i_super.s_system_dir_blkno = sys_rec->fe_off >> s->blocksize_bits;
 	di->id2.i_super.s_mnt_count = 0;
-	di->id2.i_super.s_max_mnt_count = cpu_to_le16(OCFS2_DFL_MAX_MNT_COUNT);
+	di->id2.i_super.s_max_mnt_count = OCFS2_DFL_MAX_MNT_COUNT;
 	di->id2.i_super.s_state = 0;
 	di->id2.i_super.s_errors = 0;
-	di->id2.i_super.s_lastcheck = cpu_to_le64(s->format_time);
-	di->id2.i_super.s_checkinterval = cpu_to_le32(OCFS2_DFL_CHECKINTERVAL);
-	di->id2.i_super.s_creator_os = cpu_to_le32(OCFS2_OS_LINUX);
-	di->id2.i_super.s_blocksize_bits = cpu_to_le32(s->blocksize_bits);
-	di->id2.i_super.s_clustersize_bits = cpu_to_le32(s->cluster_size_bits);
-	di->id2.i_super.s_max_slots = cpu_to_le16(s->initial_slots);
-	di->id2.i_super.s_first_cluster_group = cpu_to_le64(s->first_cluster_group_blkno);
+	di->id2.i_super.s_lastcheck = s->format_time;
+	di->id2.i_super.s_checkinterval = OCFS2_DFL_CHECKINTERVAL;
+	di->id2.i_super.s_creator_os = OCFS2_OS_LINUX;
+	di->id2.i_super.s_blocksize_bits = s->blocksize_bits;
+	di->id2.i_super.s_clustersize_bits = s->cluster_size_bits;
+	di->id2.i_super.s_max_slots = s->initial_slots;
+	di->id2.i_super.s_first_cluster_group = s->first_cluster_group_blkno;
 
 	incompat = 0;
 	if (s->hb_dev)
 		incompat |= OCFS2_FEATURE_INCOMPAT_HEARTBEAT_DEV;
 
-	di->id2.i_super.s_feature_incompat = cpu_to_le32(incompat);
+	di->id2.i_super.s_feature_incompat = incompat;
 
 	strcpy(di->id2.i_super.s_label, s->vol_label);
 	memcpy(di->id2.i_super.s_uuid, s->uuid, 16);
 
+	ocfs2_swap_inode_from_cpu(di);
 	do_pwrite(s, di, s->blocksize, super_off);
 	free(di);
 }
@@ -1637,10 +1638,10 @@
 	memset(di, 0, s->blocksize);
 
 	strcpy(di->i_signature, OCFS2_INODE_SIGNATURE);
-	di->i_generation = cpu_to_le32(s->vol_generation);
-	di->i_fs_generation = cpu_to_le32(s->vol_generation);
-	di->i_suballoc_slot = cpu_to_le16((__u16)OCFS2_INVALID_SLOT);
-        di->i_suballoc_bit = cpu_to_le16(rec->suballoc_bit);
+	di->i_generation = s->vol_generation;
+	di->i_fs_generation = s->vol_generation;
+	di->i_suballoc_slot = (__u16)OCFS2_INVALID_SLOT;
+        di->i_suballoc_bit = rec->suballoc_bit;
 	di->i_blkno = rec->fe_off >> s->blocksize_bits;
 	di->i_uid = 0;
 	di->i_gid = 0;
@@ -1660,13 +1661,13 @@
 
 	if (rec->flags & OCFS2_DEALLOC_FL) {
 		di->id2.i_dealloc.tl_count =
-			cpu_to_le16(ocfs2_truncate_recs_per_inode(s->blocksize));
+			ocfs2_truncate_recs_per_inode(s->blocksize);
 		goto write_out;
 	}
 
 	if (rec->flags & OCFS2_BITMAP_FL) {
-		di->id1.bitmap1.i_used = cpu_to_le32(rec->bi.used_bits);
-		di->id1.bitmap1.i_total = cpu_to_le32(rec->bi.total_bits);
+		di->id1.bitmap1.i_used = rec->bi.used_bits;
+		di->id1.bitmap1.i_total = rec->bi.total_bits;
 	}
 
 	if (rec->cluster_bitmap) {
@@ -1732,6 +1733,7 @@
 	}
 
 write_out:
+	ocfs2_swap_inode_from_cpu(di);
 	do_pwrite(s, di, s->blocksize, rec->fe_off);
 	free(di);
 }
@@ -1774,6 +1776,7 @@
 		 * blkno until now. */
 		gd->bg_parent_dinode = parent_blkno;
 		memcpy(buf, gd, s->blocksize);
+		ocfs2_swap_group_desc((ocfs2_group_desc *)buf);
 		do_pwrite(s, buf, s->cluster_size,
 			  gd->bg_blkno << s->blocksize_bits);
 	}
@@ -1783,14 +1786,22 @@
 static void
 write_group_data(State *s, AllocGroup *group)
 {
-	do_pwrite(s, group->gd, s->blocksize,
-		  group->gd->bg_blkno << s->blocksize_bits);
+	uint64_t blkno = group->gd->bg_blkno;
+	ocfs2_swap_group_desc(group->gd);
+	do_pwrite(s, group->gd, s->blocksize, blkno << s->blocksize_bits);
+	ocfs2_swap_group_desc(group->gd);
 }
 
 static void
 write_directory_data(State *s, DirData *dir)
 {
+	if (dir->buf)
+		ocfs2_swap_dir_entries_from_cpu(dir->buf,
+						dir->record->file_size);
 	write_metadata(s, dir->record, dir->buf);
+	if (dir->buf)
+		ocfs2_swap_dir_entries_to_cpu(dir->buf,
+					      dir->record->file_size);
 }
 
 static void
@@ -1807,8 +1818,9 @@
 	memset(slot_map, 0, slot_map_rec->extent_len);
 
 	for(i = 0; i < num; i++)
-		slot_map[i] = cpu_to_le16(-1);
+		slot_map[i] = -1;
 
+	ocfs2_swap_slot_map(slot_map, num);
 	do_pwrite(s, slot_map, slot_map_rec->extent_len,
 		  slot_map_rec->extent_off);
 
@@ -1858,25 +1870,25 @@
 
 	sb = buf;
 
-	sb->s_header.h_magic     = htonl(JFS_MAGIC_NUMBER);
-	sb->s_header.h_blocktype = htonl(JFS_SUPERBLOCK_V2);
+	sb->s_header.h_magic     = JFS_MAGIC_NUMBER;
+	sb->s_header.h_blocktype = JFS_SUPERBLOCK_V2;
 
-	sb->s_blocksize = cpu_to_be32(s->blocksize);
-	sb->s_maxlen =
-		cpu_to_be32(s->journal_size_in_bytes >> s->blocksize_bits);
+	sb->s_blocksize = s->blocksize;
+	sb->s_maxlen = s->journal_size_in_bytes >> s->blocksize_bits;
 
 	if (s->blocksize == 512)
-		sb->s_first = htonl(2);
+		sb->s_first = 2;
 	else
-		sb->s_first = htonl(1);
+		sb->s_first = 1;
 
-	sb->s_start    = htonl(1);
-	sb->s_sequence = htonl(1);
-	sb->s_errno    = htonl(0);
-	sb->s_nr_users = htonl(1);
+	sb->s_start    = 1;
+	sb->s_sequence = 1;
+	sb->s_errno    = 0;
+	sb->s_nr_users = 1;
 
 	memcpy(sb->s_uuid, s->uuid, sizeof(sb->s_uuid));
 
+	ocfs2_swap_journal_superblock(sb);
 	do_pwrite(s, buf, s->journal_size_in_bytes, journal_off);
 	free(buf);
 }

Modified: trunk/mkfs.ocfs2/mkfs.h
===================================================================
--- trunk/mkfs.ocfs2/mkfs.h	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/mkfs.ocfs2/mkfs.h	2005-08-12 23:32:43 UTC (rev 1043)
@@ -52,12 +52,10 @@
 
 #include "ocfs1_fs_compat.h"
 
-typedef unsigned short kdev_t;
-
 #include <signal.h>
 #include <libgen.h>
 
-#include "kernel-jbd.h"
+#include "jbd.h"
 
 
 #ifndef MAX

Modified: trunk/tunefs.ocfs2/tunefs.c
===================================================================
--- trunk/tunefs.ocfs2/tunefs.c	2005-08-12 22:35:24 UTC (rev 1042)
+++ trunk/tunefs.ocfs2/tunefs.c	2005-08-12 23:32:43 UTC (rev 1043)
@@ -49,11 +49,7 @@
 #include <ocfs2_fs.h>
 #include <ocfs1_fs_compat.h>
 
-/* jfs_compat.h defines these */
-#undef cpu_to_be32
-#undef be32_to_cpu
-typedef unsigned short kdev_t;
-#include <kernel-jbd.h>
+#include <jbd.h>
 
 #include <kernel-list.h>
 



More information about the Ocfs2-tools-commits mailing list