diff -Naur linux-2.6.11.ext/fs/ext3/extents.c linux-2.6.11.ext-le/fs/ext3/extents.c
--- linux-2.6.11.ext/fs/ext3/extents.c	2005-08-24 15:17:55.000000000 +0200
+++ linux-2.6.11.ext-le/fs/ext3/extents.c	2005-08-24 15:54:13.000000000 +0200
@@ -2,6 +2,10 @@
  * Copyright (c) 2003, Cluster File Systems, Inc, info@clusterfs.com
  * Written by Alex Tomas <alex@clusterfs.com>
  *
+ * Architecture independence:
+ *   Copyright (c) 2005, Bull S.A.
+ *   Written by Pierre Peiffer <pierre.peiffer@bull.net>
+ *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
@@ -25,8 +29,6 @@
  *   - ext3*_error() should be used in some situations
  *   - find_goal() [to be tested and improved]
  *   - smart tree reduction
- *   - arch-independence
- *     common on-disk format for big/little-endian arch
  */
 
 #include <linux/module.h>
@@ -56,9 +58,9 @@
 				(unsigned) eh->eh_max);
 		return -EIO;
 	}
-	if (eh->eh_entries > eh->eh_max) {
+	if (le16_to_cpu(eh->eh_entries) > le16_to_cpu(eh->eh_max)) {
 		printk(KERN_ERR "EXT3-fs: invalid eh_entries = %u\n",
-				(unsigned) eh->eh_entries);
+		       (unsigned) le16_to_cpu(eh->eh_entries));
 		return -EIO;
 	}
 	return 0;
@@ -173,7 +175,7 @@
 {
 	struct ext3_extent_header *neh;
 	neh = EXT_ROOT_HDR(tree);
-	neh->eh_generation++;
+	neh->eh_generation = cpu_to_le32(le32_to_cpu(neh->eh_generation)+1);
 }
 
 static inline int ext3_ext_space_block(struct ext3_extents_tree *tree)
@@ -236,13 +238,13 @@
 	ext_debug(tree, "path:");
 	for (k = 0; k <= l; k++, path++) {
 		if (path->p_idx) {
-			ext_debug(tree, "  %d->%d", path->p_idx->ei_block,
-					path->p_idx->ei_leaf);
+		  ext_debug(tree, "  %d->%d", le32_to_cpu(path->p_idx->ei_block),
+			    le32_to_cpu(path->p_idx->ei_leaf));
 		} else if (path->p_ext) {
 			ext_debug(tree, "  %d:%d:%d",
-					path->p_ext->ee_block,
-					path->p_ext->ee_len,
-					path->p_ext->ee_start);
+				  le32_to_cpu(path->p_ext->ee_block),
+				  le16_to_cpu(path->p_ext->ee_len),
+				  le32_to_cpu(path->p_ext->ee_start));
 		} else
 			ext_debug(tree, "  []");
 	}
@@ -265,9 +267,11 @@
 	eh = path[depth].p_hdr;
 	ex = EXT_FIRST_EXTENT(eh);
 
-	for (i = 0; i < eh->eh_entries; i++, ex++) {
+	for (i = 0; i < le16_to_cpu(eh->eh_entries); i++, ex++) {
 		ext_debug(tree, "%d:%d:%d ",
-				ex->ee_block, ex->ee_len, ex->ee_start);
+				  le32_to_cpu(ex->ee_block),
+				  le16_to_cpu(ex->ee_len),
+				  le32_to_cpu(ex->ee_start));
 	}
 	ext_debug(tree, "\n");
 #endif
@@ -297,17 +301,17 @@
 	int l = 0, k, r;
 
 	EXT_ASSERT(eh->eh_magic == EXT3_EXT_MAGIC);
-	EXT_ASSERT(eh->eh_entries <= eh->eh_max);
-	EXT_ASSERT(eh->eh_entries > 0);
+	EXT_ASSERT(le16_to_cpu(eh->eh_entries) <= le16_to_cpu(eh->eh_max));
+	EXT_ASSERT(le16_to_cpu(eh->eh_entries) > 0);
 
 	ext_debug(tree, "binsearch for %d(idx):  ", block);
 
 	path->p_idx = ix = EXT_FIRST_INDEX(eh);
 
-	r = k = eh->eh_entries;
+	r = k = le16_to_cpu(eh->eh_entries);
 	while (k > 1) {
 		k = (r - l) / 2;
-		if (block < ix[l + k].ei_block)
+		if (block < le32_to_cpu(ix[l + k].ei_block))
 			r -= k;
 		else
 			l += k;
@@ -316,30 +320,36 @@
 
 	ix += l;
 	path->p_idx = ix;
-	ext_debug(tree, "  -> %d->%d ", path->p_idx->ei_block, path->p_idx->ei_leaf);
+	ext_debug(tree, "  -> %d->%d ",
+		  le32_to_cpu(path->p_idx->ei_block),
+		  le32_to_cpu(path->p_idx->ei_leaf));
 
 	while (l++ < r) {
-		if (block < ix->ei_block) 
+	  if (block < le32_to_cpu(ix->ei_block)) 
 			break;
 		path->p_idx = ix++;
 	}
-	ext_debug(tree, "  -> %d->%d\n", path->p_idx->ei_block,
-			path->p_idx->ei_leaf);
+	ext_debug(tree, "  -> %d->%d\n", le32_to_cpu(path->p_idx->ei_block),
+		  le32_to_cpu(path->p_idx->ei_leaf));
 
 #ifdef CHECK_BINSEARCH 
 	{
 		struct ext3_extent_idx *chix;
 
 		chix = ix = EXT_FIRST_INDEX(eh);
-		for (k = 0; k < eh->eh_entries; k++, ix++) {
-			if (k != 0 && ix->ei_block <= ix[-1].ei_block) {
+		for (k = 0; k < le16_to_cpu(eh->eh_entries); k++, ix++) {
+		  if (k != 0 && 
+		      le32_to_cpu(ix->ei_block) <= le32_to_cpu(ix[-1].ei_block)) {
 				printk("k=%d, ix=0x%p, first=0x%p\n", k,
 					ix, EXT_FIRST_INDEX(eh));
 				printk("%u <= %u\n",
-					ix->ei_block,ix[-1].ei_block);
+				       le32_to_cpu(ix->ei_block),
+				       le32_to_cpu(ix[-1].ei_block));
 			}
-			EXT_ASSERT(k == 0 || ix->ei_block > ix[-1].ei_block);
-			if (block < ix->ei_block) 
+			EXT_ASSERT(k == 0 || 
+				   le32_to_cpu(ix->ei_block) 
+				           > le32_to_cpu(ix[-1].ei_block));
+			if (block < le32_to_cpu(ix->ei_block)) 
 				break;
 			chix = ix;
 		}
@@ -361,7 +371,7 @@
 	int l = 0, k, r;
 
 	EXT_ASSERT(eh->eh_magic == EXT3_EXT_MAGIC);
-	EXT_ASSERT(eh->eh_entries <= eh->eh_max);
+	EXT_ASSERT(le16_to_cpu(eh->eh_entries) <= le16_to_cpu(eh->eh_max));
 
 	if (eh->eh_entries == 0) {
 		/*
@@ -375,10 +385,10 @@
 
 	path->p_ext = ex = EXT_FIRST_EXTENT(eh);
 
-	r = k = eh->eh_entries;
+	r = k = le16_to_cpu(eh->eh_entries);
 	while (k > 1) {
 		k = (r - l) / 2;
-		if (block < ex[l + k].ee_block)
+		if (block < le32_to_cpu(ex[l + k].ee_block))
 			r -= k;
 		else
 			l += k;
@@ -387,25 +397,31 @@
 
 	ex += l;
 	path->p_ext = ex;
-	ext_debug(tree, "  -> %d:%d:%d ", path->p_ext->ee_block,
-			path->p_ext->ee_start, path->p_ext->ee_len);
+	ext_debug(tree, "  -> %d:%d:%d ",
+		        le32_to_cpu(path->p_ext->ee_block),
+		        le32_to_cpu(path->p_ext->ee_start),
+		        le16_to_cpu(path->p_ext->ee_len));
 
 	while (l++ < r) {
-		if (block < ex->ee_block) 
+	        if (block < le32_to_cpu(ex->ee_block)) 
 			break;
 		path->p_ext = ex++;
 	}
-	ext_debug(tree, "  -> %d:%d:%d\n", path->p_ext->ee_block,
-			path->p_ext->ee_start, path->p_ext->ee_len);
+	ext_debug(tree, "  -> %d:%d:%d\n",
+		        le32_to_cpu(path->p_ext->ee_block),
+		        le32_to_cpu(path->p_ext->ee_start),
+		        le16_to_cpu(path->p_ext->ee_len));
 
 #ifdef CHECK_BINSEARCH 
 	{
 		struct ext3_extent *chex;
 
 		chex = ex = EXT_FIRST_EXTENT(eh);
-		for (k = 0; k < eh->eh_entries; k++, ex++) {
-			EXT_ASSERT(k == 0 || ex->ee_block > ex[-1].ee_block);
-			if (block < ex->ee_block) 
+		for (k = 0; k < le16_to_cpu(eh->eh_entries); k++, ex++) {
+			EXT_ASSERT(k == 0 ||
+				   le32_to_cpu(ex->ee_block)
+				          > le32_to_cpu(ex[-1].ee_block));
+			if (block < le32_to_cpu(ex->ee_block)) 
 				break;
 			chex = ex;
 		}
@@ -425,7 +441,7 @@
 	eh->eh_depth = 0;
 	eh->eh_entries = 0;
 	eh->eh_magic = EXT3_EXT_MAGIC;
-	eh->eh_max = ext3_ext_space_root(tree);
+	eh->eh_max = cpu_to_le16(ext3_ext_space_root(tree));
 	ext3_ext_mark_root_dirty(handle, tree);
 	ext3_ext_invalidate_cache(tree);
 	return 0;
@@ -465,9 +481,9 @@
 	/* walk through the tree */
 	while (i) {
 		ext_debug(tree, "depth %d: num %d, max %d\n",
-				ppos, eh->eh_entries, eh->eh_max);
+			  ppos, le16_to_cpu(eh->eh_entries), le16_to_cpu(eh->eh_max));
 		ext3_ext_binsearch_idx(tree, path + ppos, block);
-		path[ppos].p_block = path[ppos].p_idx->ei_leaf;
+		path[ppos].p_block = le32_to_cpu(path[ppos].p_idx->ei_leaf);
 		path[ppos].p_depth = i;
 		path[ppos].p_ext = NULL;
 
@@ -523,9 +539,9 @@
 	if ((err = ext3_ext_get_access(handle, tree, curp)))
 		return err;
 
-	EXT_ASSERT(logical != curp->p_idx->ei_block);
+	EXT_ASSERT(logical != le32_to_cpu(curp->p_idx->ei_block));
 	len = EXT_MAX_INDEX(curp->p_hdr) - curp->p_idx;
-	if (logical > curp->p_idx->ei_block) {
+	if (logical > le32_to_cpu(curp->p_idx->ei_block)) {
 		/* insert after */
 		if (curp->p_idx != EXT_LAST_INDEX(curp->p_hdr)) {
 			len = (len - 1) * sizeof(struct ext3_extent_idx);
@@ -549,11 +565,12 @@
 		ix = curp->p_idx;
 	}
 
-	ix->ei_block = logical;
-	ix->ei_leaf = ptr;
-	curp->p_hdr->eh_entries++;
+	ix->ei_block = cpu_to_le32(logical);
+	ix->ei_leaf = cpu_to_le32(ptr);
+	curp->p_hdr->eh_entries = cpu_to_le16(le16_to_cpu(curp->p_hdr->eh_entries)+1);
 
-	EXT_ASSERT(curp->p_hdr->eh_entries <= curp->p_hdr->eh_max);
+	EXT_ASSERT(le16_to_cpu(curp->p_hdr->eh_entries)
+		                     <= le16_to_cpu(curp->p_hdr->eh_max));
 	EXT_ASSERT(ix <= EXT_LAST_INDEX(curp->p_hdr));
 
 	err = ext3_ext_dirty(handle, tree, curp);
@@ -581,7 +598,8 @@
 	struct ext3_extent_idx *fidx;
 	struct ext3_extent *ex;
 	int i = at, k, m, a;
-	unsigned long newblock, oldblock, border;
+	unsigned long newblock, oldblock;
+	__le32 border;
 	int *ablocks = NULL; /* array of allocated blocks */
 	int err = 0;
 
@@ -595,12 +613,12 @@
 		border = path[depth].p_ext[1].ee_block;
 		ext_debug(tree, "leaf will be splitted."
 				" next leaf starts at %d\n",
-				(int)border);
+			          le32_to_cpu(border));
 	} else {
 		border = newext->ee_block;
 		ext_debug(tree, "leaf will be added."
 				" next leaf starts at %d\n",
-				(int)border);
+			        le32_to_cpu(border));
 	}
 
 	/* 
@@ -644,7 +662,7 @@
 
 	neh = EXT_BLOCK_HDR(bh);
 	neh->eh_entries = 0;
-	neh->eh_max = ext3_ext_space_block(tree);
+	neh->eh_max = cpu_to_le16(ext3_ext_space_block(tree));
 	neh->eh_magic = EXT3_EXT_MAGIC;
 	neh->eh_depth = 0;
 	ex = EXT_FIRST_EXTENT(neh);
@@ -658,15 +676,22 @@
 	while (path[depth].p_ext <=
 			EXT_MAX_EXTENT(path[depth].p_hdr)) {
 		ext_debug(tree, "move %d:%d:%d in new leaf %lu\n",
-				path[depth].p_ext->ee_block,
-				path[depth].p_ext->ee_start,
-				path[depth].p_ext->ee_len,
+			        le32_to_cpu(path[depth].p_ext->ee_block),
+			        le32_to_cpu(path[depth].p_ext->ee_start),
+			        le16_to_cpu(path[depth].p_ext->ee_len),
 				newblock);
-		memmove(ex++, path[depth].p_ext++,
+		/*memmove(ex++, path[depth].p_ext++,
 				sizeof(struct ext3_extent));
-		neh->eh_entries++;
+		neh->eh_entries++;*/
+		path[depth].p_ext++;
 		m++;
 	}
+	if (m) {
+	  memmove(ex, path[depth].p_ext-m,
+				sizeof(struct ext3_extent)*m);
+	  neh->eh_entries = cpu_to_le16(le16_to_cpu(neh->eh_entries)+m);
+	}
+	
 	set_buffer_uptodate(bh);
 	unlock_buffer(bh);
 
@@ -679,7 +704,8 @@
 	if (m) {
 		if ((err = ext3_ext_get_access(handle, tree, path + depth)))
 			goto cleanup;
-		path[depth].p_hdr->eh_entries -= m;
+		path[depth].p_hdr->eh_entries = 
+		     cpu_to_le16(le16_to_cpu(path[depth].p_hdr->eh_entries)-m);
 		if ((err = ext3_ext_dirty(handle, tree, path + depth)))
 			goto cleanup;
 		
@@ -707,16 +733,16 @@
 			goto cleanup;
 
 		neh = EXT_BLOCK_HDR(bh);
-		neh->eh_entries = 1;
+		neh->eh_entries = cpu_to_le16(1);
 		neh->eh_magic = EXT3_EXT_MAGIC;
-		neh->eh_max = ext3_ext_space_block_idx(tree);
-		neh->eh_depth = depth - i; 
+		neh->eh_max = cpu_to_le16(ext3_ext_space_block_idx(tree));
+		neh->eh_depth = cpu_to_le16(depth - i); 
 		fidx = EXT_FIRST_INDEX(neh);
 		fidx->ei_block = border;
-		fidx->ei_leaf = oldblock;
+		fidx->ei_leaf = cpu_to_le32(oldblock);
 
 		ext_debug(tree,	"int.index at %d (block %lu): %lu -> %lu\n",
-				i, newblock, border, oldblock);
+			  i, newblock, le32_to_cpu(border), oldblock);
 		/* copy indexes */
 		m = 0;
 		path[i].p_idx++;
@@ -727,14 +753,21 @@
 				EXT_LAST_INDEX(path[i].p_hdr));
 		while (path[i].p_idx <= EXT_MAX_INDEX(path[i].p_hdr)) {
 			ext_debug(tree, "%d: move %d:%d in new index %lu\n",
-					i, path[i].p_idx->ei_block,
-					path[i].p_idx->ei_leaf, newblock);
-			memmove(++fidx, path[i].p_idx++,
+					i,
+				        le32_to_cpu(path[i].p_idx->ei_block),
+				        le32_to_cpu(path[i].p_idx->ei_leaf),
+				        newblock);
+			/*memmove(++fidx, path[i].p_idx++,
 					sizeof(struct ext3_extent_idx));
 			neh->eh_entries++;
-			EXT_ASSERT(neh->eh_entries <= neh->eh_max);
+			EXT_ASSERT(neh->eh_entries <= neh->eh_max);*/
+			path[i].p_idx++;
 			m++;
 		}
+		if (m) {
+		  memmove(++fidx, path[i].p_idx-m, sizeof(struct ext3_extent_idx)*m);
+		  neh->eh_entries = cpu_to_le16(le16_to_cpu(neh->eh_entries)+m);
+		}
 		set_buffer_uptodate(bh);
 		unlock_buffer(bh);
 
@@ -748,7 +781,7 @@
 			err = ext3_ext_get_access(handle, tree, path + i);
 			if (err)
 				goto cleanup;
-			path[i].p_hdr->eh_entries -= m;
+			path[i].p_hdr->eh_entries = cpu_to_le16(le16_to_cpu(path[i].p_hdr->eh_entries)-m);
 			err = ext3_ext_dirty(handle, tree, path + i);
 			if (err)
 				goto cleanup;
@@ -760,7 +793,7 @@
 	/* insert new index */
 	if (!err)
 		err = ext3_ext_insert_index(handle, tree, path + at,
-						border, newblock);
+					    le32_to_cpu(border), newblock);
 
 cleanup:
 	if (bh) {
@@ -826,9 +859,9 @@
 	/* old root could have indexes or leaves
 	 * so calculate e_max right way */
 	if (EXT_DEPTH(tree))
-		neh->eh_max = ext3_ext_space_block_idx(tree);
+	  neh->eh_max = cpu_to_le16(ext3_ext_space_block_idx(tree));
 	else
-		neh->eh_max = ext3_ext_space_block(tree);
+	  neh->eh_max = cpu_to_le16(ext3_ext_space_block(tree));
 	neh->eh_magic = EXT3_EXT_MAGIC;
 	set_buffer_uptodate(bh);
 	unlock_buffer(bh);
@@ -841,19 +874,20 @@
 		goto out;
 
 	curp->p_hdr->eh_magic = EXT3_EXT_MAGIC;
-	curp->p_hdr->eh_max = ext3_ext_space_root_idx(tree);
-	curp->p_hdr->eh_entries = 1;
+	curp->p_hdr->eh_max = cpu_to_le16(ext3_ext_space_root_idx(tree));
+	curp->p_hdr->eh_entries = cpu_to_le16(1);
 	curp->p_idx = EXT_FIRST_INDEX(curp->p_hdr);
 	/* FIXME: it works, but actually path[0] can be index */
 	curp->p_idx->ei_block = EXT_FIRST_EXTENT(path[0].p_hdr)->ee_block;
-	curp->p_idx->ei_leaf = newblock;
+	curp->p_idx->ei_leaf = cpu_to_le32(newblock);
 
 	neh = EXT_ROOT_HDR(tree);
 	fidx = EXT_FIRST_INDEX(neh);
 	ext_debug(tree, "new root: num %d(%d), lblock %d, ptr %d\n",
-			neh->eh_entries, neh->eh_max, fidx->ei_block, fidx->ei_leaf); 
+		  le16_to_cpu(neh->eh_entries), le16_to_cpu(neh->eh_max),
+		  le32_to_cpu(fidx->ei_block), le32_to_cpu(fidx->ei_leaf)); 
 
-	neh->eh_depth = path->p_depth + 1;
+	neh->eh_depth = cpu_to_le16(path->p_depth + 1);
 	err = ext3_ext_dirty(handle, tree, curp);
 out:
 	brelse(bh);
@@ -892,7 +926,9 @@
 
 		/* refill path */
 		ext3_ext_drop_refs(path);
-		path = ext3_ext_find_extent(tree, newext->ee_block, path);
+		path = ext3_ext_find_extent(tree,
+					    le32_to_cpu(newext->ee_block),
+					    path);
 		if (IS_ERR(path))
 			err = PTR_ERR(path);
 	} else {
@@ -901,7 +937,9 @@
 
 		/* refill path */
 		ext3_ext_drop_refs(path);
-		path = ext3_ext_find_extent(tree, newext->ee_block, path);
+		path = ext3_ext_find_extent(tree,
+					    le32_to_cpu(newext->ee_block),
+					    path);
 		if (IS_ERR(path))
 			err = PTR_ERR(path);
 
@@ -945,12 +983,12 @@
 			/* leaf */
 			if (path[depth].p_ext !=
 					EXT_LAST_EXTENT(path[depth].p_hdr))
-				return path[depth].p_ext[1].ee_block;
+			  return le32_to_cpu(path[depth].p_ext[1].ee_block);
 		} else {
 			/* index */
 			if (path[depth].p_idx !=
 					EXT_LAST_INDEX(path[depth].p_hdr))
-				return path[depth].p_idx[1].ei_block;
+			  return le32_to_cpu(path[depth].p_idx[1].ei_block);
 		}
 		depth--;        
 	}
@@ -979,7 +1017,7 @@
 	while (depth >= 0) {
 		if (path[depth].p_idx !=
 				EXT_LAST_INDEX(path[depth].p_hdr))
-			return path[depth].p_idx[1].ei_block;
+		  return le32_to_cpu(path[depth].p_idx[1].ei_block);
 		depth--;        
 	}
 
@@ -997,7 +1035,7 @@
 	struct ext3_extent_header *eh;
 	int depth = EXT_DEPTH(tree);	
 	struct ext3_extent *ex;
-	unsigned long border;
+	__le32 border;
 	int k, err = 0;
 	
 	eh = path[depth].p_hdr;
@@ -1045,11 +1083,12 @@
 				struct ext3_extent *ex1,
 				struct ext3_extent *ex2)
 {
-	if (ex1->ee_block + ex1->ee_len != ex2->ee_block)
+        if (le32_to_cpu(ex1->ee_block) + le16_to_cpu(ex1->ee_len)
+	    != le32_to_cpu(ex2->ee_block))
 		return 0;
 
 #ifdef AGRESSIVE_TEST
-	if (ex1->ee_len >= 4)
+	if (le16_to_cpu(ex1->ee_len) >= 4)
 		return 0;
 #endif
 
@@ -1082,11 +1121,14 @@
 	/* try to insert block into found extent and return */
 	if (ex && ext3_can_extents_be_merged(tree, ex, newext)) {
 		ext_debug(tree, "append %d block to %d:%d (from %d)\n",
-				newext->ee_len, ex->ee_block, ex->ee_len,
-				ex->ee_start);
+			        le16_to_cpu(newext->ee_len),
+			        le32_to_cpu(ex->ee_block),
+			        le16_to_cpu(ex->ee_len),
+			        le32_to_cpu(ex->ee_start));
 		if ((err = ext3_ext_get_access(handle, tree, path + depth)))
 			return err;
-		ex->ee_len += newext->ee_len;
+		ex->ee_len = cpu_to_le16(le16_to_cpu(ex->ee_len)
+					 + le16_to_cpu(newext->ee_len));
 		eh = path[depth].p_hdr;
 		nearex = ex;
 		goto merge;
@@ -1095,13 +1137,14 @@
 repeat:
 	depth = EXT_DEPTH(tree);
 	eh = path[depth].p_hdr;
-	if (eh->eh_entries < eh->eh_max)
+	if (le16_to_cpu(eh->eh_entries) < le16_to_cpu(eh->eh_max))
 		goto has_space;
 
 	/* probably next leaf has space for us? */
 	fex = EXT_LAST_EXTENT(eh);
 	next = ext3_ext_next_leaf_block(tree, path);
-	if (newext->ee_block > fex->ee_block && next != EXT_MAX_BLOCK) {
+	if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block)
+	    && next != EXT_MAX_BLOCK) {
 		ext_debug(tree, "next leaf block - %d\n", next);
 		EXT_ASSERT(!npath);
 		npath = ext3_ext_find_extent(tree, next, NULL);
@@ -1109,14 +1152,14 @@
 			return PTR_ERR(npath);
 		EXT_ASSERT(npath->p_depth == path->p_depth);
 		eh = npath[depth].p_hdr;
-		if (eh->eh_entries < eh->eh_max) {
+		if (le16_to_cpu(eh->eh_entries) < le16_to_cpu(eh->eh_max)) {
 			ext_debug(tree,	"next leaf isnt full(%d)\n",
-					eh->eh_entries);
+				  le16_to_cpu(eh->eh_entries));
 			path = npath;
 			goto repeat;
 		}
 		ext_debug(tree, "next leaf hasno free space(%d,%d)\n",
-				eh->eh_entries, eh->eh_max);
+			  le16_to_cpu(eh->eh_entries), le16_to_cpu(eh->eh_max));
 	}
 
 	/*
@@ -1138,36 +1181,41 @@
 	if (!nearex) {
 		/* there is no extent in this leaf, create first one */
 		ext_debug(tree, "first extent in the leaf: %d:%d:%d\n",
-				newext->ee_block, newext->ee_start,
-				newext->ee_len);
+			        le32_to_cpu(newext->ee_block),
+			        le32_to_cpu(newext->ee_start),
+			        le16_to_cpu(newext->ee_len));
 		path[depth].p_ext = EXT_FIRST_EXTENT(eh);
-	} else if (newext->ee_block > nearex->ee_block) {
-		EXT_ASSERT(newext->ee_block != nearex->ee_block);
+	} else if (le32_to_cpu(newext->ee_block)
+		           > le32_to_cpu(nearex->ee_block)) {
+/* 		EXT_ASSERT(newext->ee_block != nearex->ee_block); */
 		if (nearex != EXT_LAST_EXTENT(eh)) {
 			len = EXT_MAX_EXTENT(eh) - nearex;
 			len = (len - 1) * sizeof(struct ext3_extent);
 			len = len < 0 ? 0 : len;
 			ext_debug(tree, "insert %d:%d:%d after: nearest 0x%p, "
 					"move %d from 0x%p to 0x%p\n",
-					newext->ee_block, newext->ee_start,
-					newext->ee_len,
+				        le32_to_cpu(newext->ee_block),
+				        le32_to_cpu(newext->ee_start),
+				        le16_to_cpu(newext->ee_len),
 					nearex, len, nearex + 1, nearex + 2);
 			memmove(nearex + 2, nearex + 1, len);
 		}
 		path[depth].p_ext = nearex + 1;
 	} else {
-		EXT_ASSERT(newext->ee_block != nearex->ee_block);
+ 		EXT_ASSERT(newext->ee_block != nearex->ee_block);
 		len = (EXT_MAX_EXTENT(eh) - nearex) * sizeof(struct ext3_extent);
 		len = len < 0 ? 0 : len;
 		ext_debug(tree, "insert %d:%d:%d before: nearest 0x%p, "
 				"move %d from 0x%p to 0x%p\n",
-				newext->ee_block, newext->ee_start, newext->ee_len,
+				le32_to_cpu(newext->ee_block),
+				le32_to_cpu(newext->ee_start),
+				le16_to_cpu(newext->ee_len),
 				nearex, len, nearex + 1, nearex + 2);
 		memmove(nearex + 1, nearex, len);
 		path[depth].p_ext = nearex;
 	}
 
-	eh->eh_entries++;
+	eh->eh_entries = cpu_to_le16(le16_to_cpu(eh->eh_entries)+1);
 	nearex = path[depth].p_ext;
 	nearex->ee_block = newext->ee_block;
 	nearex->ee_start = newext->ee_start;
@@ -1181,13 +1229,14 @@
 		if (!ext3_can_extents_be_merged(tree, nearex, nearex + 1))
 			break;
 		/* merge with next extent! */
-		nearex->ee_len += nearex[1].ee_len;
+		nearex->ee_len = cpu_to_le16(le16_to_cpu(nearex->ee_len)
+					     + le16_to_cpu(nearex[1].ee_len));
 		if (nearex + 1 < EXT_LAST_EXTENT(eh)) {
 			len = (EXT_LAST_EXTENT(eh) - nearex - 1)
 					* sizeof(struct ext3_extent);
 			memmove(nearex + 1, nearex + 2, len);
 		}
-		eh->eh_entries--;
+		eh->eh_entries = cpu_to_le16(le16_to_cpu(eh->eh_entries)-1);
 		EXT_ASSERT(eh->eh_entries > 0);
 	}
 
@@ -1246,25 +1295,26 @@
 			 * all requested space */
 			start = block;
 			end = block + num;
-		} else if (ex->ee_block > block) {
+		} else if (le32_to_cpu(ex->ee_block) > block) {
 			/* need to allocate space before found extent */
 			start = block;
-			end = ex->ee_block;
+			end = le32_to_cpu(ex->ee_block);
 			if (block + num < end)
 				end = block + num;
-		} else if (block >= ex->ee_block + ex->ee_len) {
+		} else if (block >=
+			     le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len)) {
 			/* need to allocate space after found extent */
 			start = block;
 			end = block + num;
 			if (end >= next)
 				end = next;
-		} else if (block >= ex->ee_block) {
+		} else if (block >= le32_to_cpu(ex->ee_block)) {
 			/* 
 			 * some part of requested space is covered
 			 * by found extent
 			 */
 			start = block;
-			end = ex->ee_block + ex->ee_len;
+			end = le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len);
 			if (block + num < end)
 				end = block + num;
 			exists = 1;
@@ -1279,9 +1329,9 @@
 			cbex.ec_start = 0;
 			cbex.ec_type = EXT3_EXT_CACHE_GAP;
 		} else {
-			cbex.ec_block = ex->ee_block;
-			cbex.ec_len = ex->ee_len;
-			cbex.ec_start = ex->ee_start;
+		        cbex.ec_block = le32_to_cpu(ex->ee_block);
+		        cbex.ec_len = le16_to_cpu(ex->ee_len);
+		        cbex.ec_start = le32_to_cpu(ex->ee_start);
 			cbex.ec_type = EXT3_EXT_CACHE_EXTENT;
 		}
 
@@ -1351,19 +1401,21 @@
 		lblock = 0;
 		len = EXT_MAX_BLOCK;
 		ext_debug(tree, "cache gap(whole file):");
-	} else if (block < ex->ee_block) {
+	} else if (block < le32_to_cpu(ex->ee_block)) {
 		lblock = block;
-		len = ex->ee_block - block;
+		len = le32_to_cpu(ex->ee_block) - block;
 		ext_debug(tree, "cache gap(before): %lu [%lu:%lu]",
 				(unsigned long) block,
-				(unsigned long) ex->ee_block,
-				(unsigned long) ex->ee_len);
-	} else if (block >= ex->ee_block + ex->ee_len) {
-		lblock = ex->ee_block + ex->ee_len;
+			        (unsigned long) le32_to_cpu(ex->ee_block),
+			        (unsigned long) le16_to_cpu(ex->ee_len));
+	} else if (block >= le32_to_cpu(ex->ee_block)
+		            + le16_to_cpu(ex->ee_len)) {
+	        lblock = le32_to_cpu(ex->ee_block)
+		         + le16_to_cpu(ex->ee_len);
 		len = ext3_ext_next_allocated_block(path);
 		ext_debug(tree, "cache gap(after): [%lu:%lu] %lu",
-				(unsigned long) ex->ee_block,
-				(unsigned long) ex->ee_len,
+			        (unsigned long) le32_to_cpu(ex->ee_block),
+			        (unsigned long) le16_to_cpu(ex->ee_len),
 				(unsigned long) block);
 		EXT_ASSERT(len > lblock);
 		len = len - lblock;
@@ -1393,14 +1445,14 @@
 	EXT_ASSERT(cex->ec_type == EXT3_EXT_CACHE_GAP ||
 			cex->ec_type == EXT3_EXT_CACHE_EXTENT);
 	if (block >= cex->ec_block && block < cex->ec_block + cex->ec_len) {
-		ex->ee_block = cex->ec_block;
-		ex->ee_start = cex->ec_start;
-		ex->ee_len = cex->ec_len;
+	        ex->ee_block = cpu_to_le32(cex->ec_block);
+	        ex->ee_start = cpu_to_le32(cex->ec_start);
+	        ex->ee_len = cpu_to_le16(cex->ec_len);
 		ext_debug(tree, "%lu cached by %lu:%lu:%lu\n",
 				(unsigned long) block,
-				(unsigned long) ex->ee_block,
-				(unsigned long) ex->ee_len,
-				(unsigned long) ex->ee_start);
+				(unsigned long) cex->ec_block,
+				(unsigned long) cex->ec_len,
+				(unsigned long) cex->ec_start);
 		return cex->ec_type;
 	}
 
@@ -1418,20 +1470,22 @@
 {
 	struct buffer_head *bh;
 	int err;
+	unsigned long leaf;
 	
 	/* free index block */
 	path--;
+	leaf = le32_to_cpu(path->p_idx->ei_leaf);
 	EXT_ASSERT(path->p_hdr->eh_entries);
 	if ((err = ext3_ext_get_access(handle, tree, path)))
 		return err;
-	path->p_hdr->eh_entries--;
+	path->p_hdr->eh_entries = cpu_to_le16(le16_to_cpu(path->p_hdr->eh_entries)-1);
 	if ((err = ext3_ext_dirty(handle, tree, path)))
 		return err;
 	ext_debug(tree, "index is empty, remove it, free block %d\n",
-			path->p_idx->ei_leaf);
-	bh = sb_find_get_block(tree->inode->i_sb, path->p_idx->ei_leaf);
-	ext3_forget(handle, 1, tree->inode, bh, path->p_idx->ei_leaf);
-	ext3_free_blocks(handle, tree->inode, path->p_idx->ei_leaf, 1);
+		        leaf);
+	bh = sb_find_get_block(tree->inode->i_sb, leaf);
+	ext3_forget(handle, 1, tree->inode, bh, leaf);
+	ext3_free_blocks(handle, tree->inode, leaf, 1);
 	return err;
 }
 
@@ -1443,7 +1497,8 @@
 
 	if (path) {
 		/* probably there is space in leaf? */
-		if (path[depth].p_hdr->eh_entries < path[depth].p_hdr->eh_max)
+	  if (le16_to_cpu(path[depth].p_hdr->eh_entries)
+	      < le16_to_cpu(path[depth].p_hdr->eh_max))
 			return 1;
 	}
 	
@@ -1483,13 +1538,16 @@
 	depth = EXT_DEPTH(tree);
 	ex = path[depth].p_ext;
 	EXT_ASSERT(ex);
-	EXT_ASSERT(end < ex->ee_block + ex->ee_len - 1);
-	EXT_ASSERT(ex->ee_block < start);
+	EXT_ASSERT(end < le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len) - 1);
+	EXT_ASSERT(le32_to_cpu(ex->ee_block) < start);
 
 	/* calculate tail extent */
-	tex.ee_block = end + 1;
-	EXT_ASSERT(tex.ee_block < ex->ee_block + ex->ee_len);
-	tex.ee_len = ex->ee_block + ex->ee_len - tex.ee_block;
+	tex.ee_block = cpu_to_le32(end + 1);
+	EXT_ASSERT(le32_to_cpu(tex.ee_block) <
+		           le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len));
+	tex.ee_len = cpu_to_le16(le32_to_cpu(ex->ee_block)
+				 + le16_to_cpu(ex->ee_len)
+				 - le32_to_cpu(tex.ee_block));
 
 	creds = ext3_ext_calc_credits_for_insert(tree, path);
 	handle = ext3_ext_journal_restart(handle, creds);
@@ -1500,7 +1558,8 @@
 	err = ext3_ext_get_access(handle, tree, path + depth);
 	if (err)
 		return err;
-	ex->ee_len = start - ex->ee_block;
+	ex->ee_len = cpu_to_le16(start
+				 - le32_to_cpu(ex->ee_block));
 	err = ext3_ext_dirty(handle, tree, path + depth);
 	if (err)
 		return err;
@@ -1508,9 +1567,12 @@
 	/* FIXME: some callback to free underlying resource
 	 * and correct ee_start? */
 	ext_debug(tree, "split extent: head %u:%u, tail %u:%u\n",
-			ex->ee_block, ex->ee_len, tex.ee_block, tex.ee_len);
+		        le32_to_cpu(ex->ee_block),
+		        le16_to_cpu(ex->ee_len),
+		        le32_to_cpu(tex.ee_block),
+		        le16_to_cpu(tex.ee_len));
 
-	npath = ext3_ext_find_extent(tree, ex->ee_block, NULL);
+	npath = ext3_ext_find_extent(tree, le32_to_cpu(ex->ee_block), NULL);
 	if (IS_ERR(npath))
 		return PTR_ERR(npath);
 	depth = EXT_DEPTH(tree);
@@ -1535,24 +1597,30 @@
 	int depth = EXT_DEPTH(tree), credits;
 	struct ext3_extent_header *eh;
 	unsigned a, b, block, num;
+	unsigned long ex_ee_block;
+	unsigned short ex_ee_len;
 
 	ext_debug(tree, "remove [%lu:%lu] in leaf\n", start, end);
 	if (!path[depth].p_hdr)
 		path[depth].p_hdr = EXT_BLOCK_HDR(path[depth].p_bh);
 	eh = path[depth].p_hdr;
 	EXT_ASSERT(eh);
-	EXT_ASSERT(eh->eh_entries <= eh->eh_max);
+	EXT_ASSERT(le16_to_cpu(eh->eh_entries) <= le16_to_cpu(eh->eh_max));
 	EXT_ASSERT(eh->eh_magic == EXT3_EXT_MAGIC);
 	
 	/* find where to start removing */
 	le = ex = EXT_LAST_EXTENT(eh);
+
 	while (ex != EXT_FIRST_EXTENT(eh)) {
-		if (ex->ee_block <= end)
+	        if (le32_to_cpu(ex->ee_block) <= end)
 			break;
 		ex--;
 	}
 
-	if (start > ex->ee_block && end < ex->ee_block + ex->ee_len - 1) {
+	ex_ee_block = le32_to_cpu(ex->ee_block);
+	ex_ee_len = le16_to_cpu(ex->ee_len);
+
+	if (start > ex_ee_block && end < ex_ee_block + ex_ee_len - 1) {
 		/* removal of internal part of the extent requested
 		 * tail and head must be placed in different extent
 		 * so, we have to insert one more extent */
@@ -1562,34 +1630,34 @@
 	
 	lu = ex;
 	while (ex >= EXT_FIRST_EXTENT(eh) &&
-			ex->ee_block + ex->ee_len > start) {
-		ext_debug(tree, "remove ext %u:%u\n", ex->ee_block, ex->ee_len);
+			ex_ee_block + ex_ee_len > start) {
+		ext_debug(tree, "remove ext %u:%u\n", ex_ee_block, ex_ee_len);
 		path[depth].p_ext = ex;
 	
-		a = ex->ee_block > start ? ex->ee_block : start;
-		b = ex->ee_block + ex->ee_len - 1 < end ?
-			ex->ee_block + ex->ee_len - 1 : end;
+		a = ex_ee_block > start ? ex_ee_block : start;
+		b = ex_ee_block + ex_ee_len - 1 < end ?
+			ex_ee_block + ex_ee_len - 1 : end;
 		
 		ext_debug(tree, "  border %u:%u\n", a, b);
 
-		if (a != ex->ee_block && b != ex->ee_block + ex->ee_len - 1) {
+		if (a != ex_ee_block && b != ex_ee_block + ex_ee_len - 1) {
 			block = 0;
 			num = 0;
 			BUG();
-		} else if (a != ex->ee_block) {
+		} else if (a != ex_ee_block) {
 			/* remove tail of the extent */
-			block = ex->ee_block;
+			block = ex_ee_block;
 			num = a - block;
-		} else if (b != ex->ee_block + ex->ee_len - 1) {
+		} else if (b != ex_ee_block + ex_ee_len - 1) {
 			/* remove head of the extent */
 			block = a;
 			num = b - a;
 		} else {
 			/* remove whole extent: excelent! */
-			block = ex->ee_block; 
+			block = ex_ee_block; 
 			num = 0;
-			EXT_ASSERT(a == ex->ee_block &&
-					b == ex->ee_block + ex->ee_len - 1);
+			EXT_ASSERT(a == ex_ee_block &&
+					b == ex_ee_block + ex_ee_len - 1);
 		}
 
 		if (ex == EXT_FIRST_EXTENT(eh))
@@ -1619,20 +1687,22 @@
 		if (num == 0) {
 			/* this extent is removed entirely mark slot unused */
 			ex->ee_start = 0;
-			eh->eh_entries--;
+			eh->eh_entries = cpu_to_le16(le16_to_cpu(eh->eh_entries)-1);
 			fu = ex;
 		}
 
-		ex->ee_block = block;
-		ex->ee_len = num;
+		ex->ee_block = cpu_to_le32(block);
+		ex->ee_len = cpu_to_le16(num);
 
 		err = ext3_ext_dirty(handle, tree, path + depth);
 		if (err)
 			goto out;
 
 		ext_debug(tree, "new extent: %u:%u:%u\n",
-				ex->ee_block, ex->ee_len, ex->ee_start);
+			        block, num, le32_to_cpu(ex->ee_start));
 		ex--;
+		ex_ee_block = le32_to_cpu(ex->ee_block);
+		ex_ee_len = le16_to_cpu(ex->ee_len);
 	}
 
 	if (fu) {
@@ -1667,7 +1737,7 @@
 	
 	ix = EXT_LAST_INDEX(hdr);
 	while (ix != EXT_FIRST_INDEX(hdr)) {
-		if (ix->ei_block <= block)
+	        if (le32_to_cpu(ix->ei_block) <= block)
 			break;
 		ix--;
 	}
@@ -1689,7 +1759,7 @@
 	 * if truncate on deeper level happened it it wasn't partial
 	 * so we have to consider current index for truncation
 	 */
-	if (path->p_hdr->eh_entries == path->p_block)
+	if (le16_to_cpu(path->p_hdr->eh_entries) == path->p_block)
 		return 0;
 	return 1;
 }
@@ -1743,16 +1813,18 @@
 			path[i].p_hdr = EXT_BLOCK_HDR(path[i].p_bh);
 		}
 
-		EXT_ASSERT(path[i].p_hdr->eh_entries <= path[i].p_hdr->eh_max);
+		EXT_ASSERT(le16_to_cpu(path[i].p_hdr->eh_entries)
+			   <= le16_to_cpu(path[i].p_hdr->eh_max));
 		EXT_ASSERT(path[i].p_hdr->eh_magic == EXT3_EXT_MAGIC);
 		
 		if (!path[i].p_idx) {
 			/* this level hasn't touched yet */
 			path[i].p_idx =
 				ext3_ext_last_covered(path[i].p_hdr, end);
-			path[i].p_block = path[i].p_hdr->eh_entries + 1;
+			path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries)+1;
 			ext_debug(tree, "init index ptr: hdr 0x%p, num %d\n",
-					path[i].p_hdr, path[i].p_hdr->eh_entries);
+				  path[i].p_hdr,
+				  le16_to_cpu(path[i].p_hdr->eh_entries));
 		} else {
 			/* we've already was here, see at next index */
 			path[i].p_idx--;
@@ -1764,9 +1836,10 @@
 		if (ext3_ext_more_to_rm(path + i)) {
 			/* go to the next level */
 			ext_debug(tree, "move to level %d (block %d)\n",
-					i + 1, path[i].p_idx->ei_leaf);
+				  i + 1, le32_to_cpu(path[i].p_idx->ei_leaf));
 			memset(path + i + 1, 0, sizeof(*path));
-			path[i+1].p_bh = sb_bread(sb, path[i].p_idx->ei_leaf);
+			path[i+1].p_bh =
+			  sb_bread(sb, le32_to_cpu(path[i].p_idx->ei_leaf));
 			if (!path[i+1].p_bh) {
 				/* should we reset i_size? */
 				err = -EIO;
@@ -1774,7 +1847,7 @@
 			}
 			/* put actual number of indexes to know is this
 			 * number got changed at the next iteration */
-			path[i].p_block = path[i].p_hdr->eh_entries;
+			path[i].p_block = le16_to_cpu(path[i].p_hdr->eh_entries);
 			i++;
 		} else {
 			/* we finish processing this index, go up */
@@ -1800,7 +1873,8 @@
 		err = ext3_ext_get_access(handle, tree, path);
 		if (err == 0) {
 			EXT_ROOT_HDR(tree)->eh_depth = 0;
-			EXT_ROOT_HDR(tree)->eh_max = ext3_ext_space_root(tree);
+			EXT_ROOT_HDR(tree)->eh_max = 
+			  cpu_to_le16(ext3_ext_space_root(tree));
 			err = ext3_ext_dirty(handle, tree, path);
 		}
 	}
@@ -1911,7 +1985,8 @@
 				struct ext3_extent *ex2)
 {
 	/* FIXME: support for large fs */
-	if (ex1->ee_start + ex1->ee_len == ex2->ee_start)
+        if (le32_to_cpu(ex1->ee_start) + le16_to_cpu(ex1->ee_len)
+	    == le32_to_cpu(ex2->ee_start))
 		return 1;
 	return 0;
 }
@@ -1947,23 +2022,25 @@
 #ifdef EXTENTS_STATS
 	{
 		struct ext3_sb_info *sbi = EXT3_SB(tree->inode->i_sb);
+		unsigned short ee_len =  le16_to_cpu(ex->ee_len);
 		spin_lock(&sbi->s_ext_stats_lock);
-		sbi->s_ext_blocks += ex->ee_len;
+		sbi->s_ext_blocks += ee_len;
 		sbi->s_ext_extents++;
-		if (ex->ee_len < sbi->s_ext_min)
-			sbi->s_ext_min = ex->ee_len;
-		if (ex->ee_len > sbi->s_ext_max)
-			sbi->s_ext_max = ex->ee_len;
+		if (ee_len < sbi->s_ext_min)
+			sbi->s_ext_min = ee_len;
+		if (ee_len > sbi->s_ext_max)
+			sbi->s_ext_max = ee_len;
 		if (EXT_DEPTH(tree) > sbi->s_depth_max)
 			sbi->s_depth_max = EXT_DEPTH(tree);
 		spin_unlock(&sbi->s_ext_stats_lock);
 	}
 #endif
-	if (from >= ex->ee_block && to == ex->ee_block + ex->ee_len - 1) {
+	if (from >= le32_to_cpu(ex->ee_block)
+	    && to == le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len) - 1) {
 		/* tail removal */
 		unsigned long num, start;
-		num = ex->ee_block + ex->ee_len - from;
-		start = ex->ee_start + ex->ee_len - num;
+		num = le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len) - from;
+		start = le32_to_cpu(ex->ee_start) + le16_to_cpu(ex->ee_len) - num;
 		ext_debug(tree, "free last %lu blocks starting %lu\n",
 				num, start);
 		for (i = 0; i < num; i++) {
@@ -1971,12 +2048,13 @@
 			ext3_forget(handle, 0, tree->inode, bh, start + i);
 		}
 		ext3_free_blocks(handle, tree->inode, start, num);
-	} else if (from == ex->ee_block && to <= ex->ee_block + ex->ee_len - 1) {
+	} else if (from == le32_to_cpu(ex->ee_block)
+		   && to <= le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len) - 1) {
 		printk("strange request: removal %lu-%lu from %u:%u\n",
-			from, to, ex->ee_block, ex->ee_len);
+		       from, to, le32_to_cpu(ex->ee_block), le16_to_cpu(ex->ee_len));
 	} else {
 		printk("strange request: removal(2) %lu-%lu from %u:%u\n",
-			from, to, ex->ee_block, ex->ee_len);
+		       from, to, le32_to_cpu(ex->ee_block), le16_to_cpu(ex->ee_len));
 	}
 	ext3_journal_stop(handle);
 	return 0;
@@ -1996,7 +2074,8 @@
 		
 		/* try to predict block placement */
 		if ((ex = path[depth].p_ext))
-			return ex->ee_start + (block - ex->ee_block);
+		        return le32_to_cpu(ex->ee_start)
+			       + (block - le32_to_cpu(ex->ee_block));
 
 		/* it looks index is empty
 		 * try to find starting from index itself */
@@ -2018,6 +2097,7 @@
 {
 	struct inode *inode = tree->inode;
 	int newblock, goal;
+	unsigned short len;
 	
 	EXT_ASSERT(path);
 	EXT_ASSERT(ex);
@@ -2025,19 +2105,22 @@
 	EXT_ASSERT(ex->ee_len);
 	
 	/* reuse block from the extent to order data/metadata */
-	newblock = ex->ee_start++;
-	ex->ee_len--;
-	if (ex->ee_len == 0) {
-		ex->ee_len = 1;
+	newblock = le32_to_cpu(ex->ee_start);
+	len = le16_to_cpu(ex->ee_len) - 1;
+	if (len == 0) {
 		/* allocate new block for the extent */
-		goal = ext3_ext_find_goal(inode, path, ex->ee_block);
-		ex->ee_start = ext3_new_block(handle, inode, goal, err);
+		goal = ext3_ext_find_goal(inode, path, le32_to_cpu(ex->ee_block));
+		ex->ee_start = cpu_to_le32(ext3_new_block(handle, inode, goal, err));
 		if (ex->ee_start == 0) {
 			/* error occured: restore old extent */
-			ex->ee_start = newblock;
+		        ex->ee_start = cpu_to_le32(newblock);
 			return 0;
 		}
 	}
+	else {
+	  ex->ee_start = cpu_to_le32(newblock+1);
+	  ex->ee_len = cpu_to_le16(len);
+	}
 	return newblock;
 }
 
@@ -2088,7 +2171,9 @@
 			/* we should allocate requested block */
 		} else if (goal == EXT3_EXT_CACHE_EXTENT) {
 			/* block is already allocated */
-			newblock = iblock - newex.ee_block + newex.ee_start;
+		        newblock = iblock
+		                   - le32_to_cpu(newex.ee_block)
+			           + le32_to_cpu(newex.ee_start);
 			goto out;
 		} else {
 			EXT_ASSERT(0);
@@ -2113,14 +2198,18 @@
 	EXT_ASSERT(path[depth].p_ext != NULL || depth == 0);
 
 	if ((ex = path[depth].p_ext)) {
+	        unsigned long ee_block = le32_to_cpu(ex->ee_block);
+		unsigned long ee_start = le32_to_cpu(ex->ee_start);
+		unsigned short ee_len  = le16_to_cpu(ex->ee_len);
 		/* if found exent covers block, simple return it */
-		if (iblock >= ex->ee_block && iblock < ex->ee_block + ex->ee_len) {
-			newblock = iblock - ex->ee_block + ex->ee_start;
+	        if (iblock >= ee_block
+		    && iblock < ee_block + ee_len) {
+			newblock = iblock - ee_block + ee_start;
 			ext_debug(&tree, "%d fit into %d:%d -> %d\n",
-					(int) iblock, ex->ee_block, ex->ee_len,
+					(int) iblock, ee_block, ee_len,
 					newblock);
-			ext3_ext_put_in_cache(&tree, ex->ee_block,
-						ex->ee_len, ex->ee_start,
+			ext3_ext_put_in_cache(&tree, ee_block,
+						ee_len, ee_start,
 						EXT3_EXT_CACHE_EXTENT);
 			goto out;
 		}
@@ -2145,9 +2234,9 @@
 			goal, newblock);
 
 	/* try to insert new extent into found leaf and return */
-	newex.ee_block = iblock;
-	newex.ee_start = newblock;
-	newex.ee_len = 1;
+	newex.ee_block = cpu_to_le32(iblock);
+	newex.ee_start = cpu_to_le32(newblock);
+	newex.ee_len = cpu_to_le16(1);
 	err = ext3_ext_insert_extent(handle, &tree, path, &newex);
 	if (err)
 		goto out2;
@@ -2156,11 +2245,11 @@
 		EXT3_I(inode)->i_disksize = inode->i_size;
 
 	/* previous routine could use block we allocated */
-	newblock = newex.ee_start;
+	newblock = le32_to_cpu(newex.ee_start);
 	__set_bit(BH_New, &bh_result->b_state);
 
-	ext3_ext_put_in_cache(&tree, newex.ee_block, newex.ee_len,
-				newex.ee_start, EXT3_EXT_CACHE_EXTENT);
+	ext3_ext_put_in_cache(&tree, iblock, 1,
+				newblock, EXT3_EXT_CACHE_EXTENT);
 out:
 	ext3_ext_show_leaf(&tree, path);
 	__set_bit(BH_Mapped, &bh_result->b_state);
diff -Naur linux-2.6.11.ext/include/linux/ext3_extents.h linux-2.6.11.ext-le/include/linux/ext3_extents.h
--- linux-2.6.11.ext/include/linux/ext3_extents.h	2005-08-24 15:17:55.000000000 +0200
+++ linux-2.6.11.ext-le/include/linux/ext3_extents.h	2005-08-24 15:18:11.000000000 +0200
@@ -76,10 +76,10 @@
  * it's used at the bottom of the tree
  */
 struct ext3_extent {
-	__u32	ee_block;	/* first logical block extent covers */
-	__u16	ee_len;		/* number of blocks covered by extent */
-	__u16	ee_start_hi;	/* high 16 bits of physical block */
-	__u32	ee_start;	/* low 32 bigs of physical block */
+	__le32	ee_block;	/* first logical block extent covers */
+	__le16	ee_len;		/* number of blocks covered by extent */
+	__le16	ee_start_hi;	/* high 16 bits of physical block */
+	__le32	ee_start;	/* low 32 bigs of physical block */
 };
 
 /*
@@ -87,10 +87,10 @@
  * it's used at all the levels, but the bottom
  */
 struct ext3_extent_idx {
-	__u32	ei_block;	/* index covers logical blocks from 'block' */
-	__u32	ei_leaf;	/* pointer to the physical block of the next *
+	__le32	ei_block;	/* index covers logical blocks from 'block' */
+	__le32	ei_leaf;	/* pointer to the physical block of the next *
 				 * level. leaf or next index could bet here */
-	__u16	ei_leaf_hi;	/* high 16 bits of physical block */
+	__le16	ei_leaf_hi;	/* high 16 bits of physical block */
 	__u16	ei_unused;
 };
 
@@ -98,14 +98,14 @@
  * each block (leaves and indexes), even inode-stored has header
  */
 struct ext3_extent_header {	
-	__u16	eh_magic;	/* probably will support different formats */	
-	__u16	eh_entries;	/* number of valid entries */
-	__u16	eh_max;		/* capacity of store in entries */
-	__u16	eh_depth;	/* has tree real underlaying blocks? */
-	__u32	eh_generation;	/* generation of the tree */
+	__le16	eh_magic;	/* probably will support different formats */	
+	__le16	eh_entries;	/* number of valid entries */
+	__le16	eh_max;		/* capacity of store in entries */
+	__le16	eh_depth;	/* has tree real underlaying blocks? */
+	__le32	eh_generation;	/* generation of the tree */
 };
 
-#define EXT3_EXT_MAGIC		0xf30a
+#define EXT3_EXT_MAGIC		cpu_to_le16(0xf30a)
 
 /*
  * array of ext3_ext_path contains path to some extent
@@ -194,24 +194,25 @@
 	((struct ext3_extent_idx *) (((char *) (__hdr__)) +	\
 				     sizeof(struct ext3_extent_header)))
 #define EXT_HAS_FREE_INDEX(__path__) \
-	((__path__)->p_hdr->eh_entries < (__path__)->p_hdr->eh_max)
+        (le16_to_cpu((__path__)->p_hdr->eh_entries) \
+	                             < le16_to_cpu((__path__)->p_hdr->eh_max))
 #define EXT_LAST_EXTENT(__hdr__) \
-	(EXT_FIRST_EXTENT((__hdr__)) + (__hdr__)->eh_entries - 1)
+	(EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_entries) - 1)
 #define EXT_LAST_INDEX(__hdr__) \
-	(EXT_FIRST_INDEX((__hdr__)) + (__hdr__)->eh_entries - 1)
+	(EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_entries) - 1)
 #define EXT_MAX_EXTENT(__hdr__) \
-	(EXT_FIRST_EXTENT((__hdr__)) + (__hdr__)->eh_max - 1)
+	(EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)
 #define EXT_MAX_INDEX(__hdr__) \
-	(EXT_FIRST_INDEX((__hdr__)) + (__hdr__)->eh_max - 1)
+	(EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)
 
 #define EXT_ROOT_HDR(tree) \
 	((struct ext3_extent_header *) (tree)->root)
 #define EXT_BLOCK_HDR(bh) \
 	((struct ext3_extent_header *) (bh)->b_data)
 #define EXT_DEPTH(_t_)	\
-	(((struct ext3_extent_header *)((_t_)->root))->eh_depth)
+	(le16_to_cpu((((struct ext3_extent_header *)((_t_)->root))->eh_depth)))
 #define EXT_GENERATION(_t_)	\
-	(((struct ext3_extent_header *)((_t_)->root))->eh_generation)
+	(le32_to_cpu(((struct ext3_extent_header *)((_t_)->root))->eh_generation))
 
 
 #define EXT_ASSERT(__x__) if (!(__x__)) BUG();
