Index: linux-2.6.11.7/fs/ext3/extents.c
===================================================================
--- linux-2.6.11.7.orig/fs/ext3/extents.c
+++ linux-2.6.11.7/fs/ext3/extents.c
@@ -240,12 +240,12 @@ static void ext3_ext_show_path(struct ex
 	ext_debug(tree, "path:");
 	for (k = 0; k <= l; k++, path++) {
 		if (path->p_idx) {
-		  ext_debug(tree, "  %d->%lld", le32_to_cpu(path->p_idx->ei_block),
+		  ext_debug(tree, "  %lld->%lld", le64_to_cpu(path->p_idx->ei_block),
 			    le64_to_cpu(path->p_idx->ei_leaf));
 		} else if (path->p_ext) {
-			ext_debug(tree, "  %d:%d:%lld",
-				  le32_to_cpu(path->p_ext->ee_block),
-				  le16_to_cpu(path->p_ext->ee_len),
+			ext_debug(tree, "  %lld:%d:%lld",
+				  le64_to_cpu(path->p_ext->ee_block),
+				  le32_to_cpu(path->p_ext->ee_len),
 				  le64_to_cpu(path->p_ext->ee_start));
 		} else
 			ext_debug(tree, "  []");
@@ -270,9 +270,9 @@ static void ext3_ext_show_leaf(struct ex
 	ex = EXT_FIRST_EXTENT(eh);
 
 	for (i = 0; i < le16_to_cpu(eh->eh_entries); i++, ex++) {
-		ext_debug(tree, "%d:%d:%lld ",
-				  le32_to_cpu(ex->ee_block),
-				  le16_to_cpu(ex->ee_len),
+		ext_debug(tree, "%lld:%d:%lld ",
+				  le64_to_cpu(ex->ee_block),
+				  le32_to_cpu(ex->ee_len),
 				  le64_to_cpu(ex->ee_start));
 	}
 	ext_debug(tree, "\n");
@@ -296,7 +296,7 @@ static void ext3_ext_drop_refs(struct ex
  */
 static inline void
 ext3_ext_binsearch_idx(struct ext3_extents_tree *tree,
-			struct ext3_ext_path *path, int block)
+			struct ext3_ext_path *path, unsigned long long block)
 {
 	struct ext3_extent_header *eh = path->p_hdr;
 	struct ext3_extent_idx *ix;
@@ -306,14 +306,14 @@ ext3_ext_binsearch_idx(struct ext3_exten
 	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);
+	ext_debug(tree, "binsearch for %lld(idx):  ", block);
 
 	path->p_idx = ix = EXT_FIRST_INDEX(eh);
 
 	r = k = le16_to_cpu(eh->eh_entries);
 	while (k > 1) {
 		k = (r - l) / 2;
-		if (block < le32_to_cpu(ix[l + k].ei_block))
+		if (block < le64_to_cpu(ix[l + k].ei_block))
 			r -= k;
 		else
 			l += k;
@@ -322,16 +322,16 @@ ext3_ext_binsearch_idx(struct ext3_exten
 
 	ix += l;
 	path->p_idx = ix;
-	ext_debug(tree, "  -> %d->%lld ",
-		  le32_to_cpu(path->p_idx->ei_block),
+	ext_debug(tree, "  -> %lld->%lld ",
+		  le64_to_cpu(path->p_idx->ei_block),
 		  le64_to_cpu(path->p_idx->ei_leaf));
 
 	while (l++ < r) {
-	  if (block < le32_to_cpu(ix->ei_block)) 
+	  if (block < le64_to_cpu(ix->ei_block))
 			break;
 		path->p_idx = ix++;
 	}
-	ext_debug(tree, "  -> %d->%lld\n", le32_to_cpu(path->p_idx->ei_block),
+	ext_debug(tree, "  -> %lld->%lld\n", le64_to_cpu(path->p_idx->ei_block),
 		  le64_to_cpu(path->p_idx->ei_leaf));
 
 #ifdef CHECK_BINSEARCH 
@@ -341,17 +341,17 @@ ext3_ext_binsearch_idx(struct ext3_exten
 		chix = ix = EXT_FIRST_INDEX(eh);
 		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)) {
+		      le64_to_cpu(ix->ei_block) <= le64_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",
-				       le32_to_cpu(ix->ei_block),
-				       le32_to_cpu(ix[-1].ei_block));
+				printk("%llu <= %llu\n",
+				       le64_to_cpu(ix->ei_block),
+				       le64_to_cpu(ix[-1].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)) 
+				   le64_to_cpu(ix->ei_block)
+				           > le64_to_cpu(ix[-1].ei_block));
+			if (block < le64_to_cpu(ix->ei_block))
 				break;
 			chix = ix;
 		}
@@ -366,7 +366,7 @@ ext3_ext_binsearch_idx(struct ext3_exten
  */
 static inline void
 ext3_ext_binsearch(struct ext3_extents_tree *tree,
-			struct ext3_ext_path *path, int block)
+			struct ext3_ext_path *path, long long block)
 {
 	struct ext3_extent_header *eh = path->p_hdr;
 	struct ext3_extent *ex;
@@ -390,7 +390,7 @@ ext3_ext_binsearch(struct ext3_extents_t
 	r = k = le16_to_cpu(eh->eh_entries);
 	while (k > 1) {
 		k = (r - l) / 2;
-		if (block < le32_to_cpu(ex[l + k].ee_block))
+		if (block < le64_to_cpu(ex[l + k].ee_block))
 			r -= k;
 		else
 			l += k;
@@ -399,20 +399,20 @@ ext3_ext_binsearch(struct ext3_extents_t
 
 	ex += l;
 	path->p_ext = ex;
-	ext_debug(tree, "  -> %d:%lld:%d ",
-		        le32_to_cpu(path->p_ext->ee_block),
+	ext_debug(tree, "  -> %lld:%lld:%d ",
+		        le64_to_cpu(path->p_ext->ee_block),
 		        le64_to_cpu(path->p_ext->ee_start),
-		        le16_to_cpu(path->p_ext->ee_len));
+		        le32_to_cpu(path->p_ext->ee_len));
 
 	while (l++ < r) {
-	        if (block < le32_to_cpu(ex->ee_block)) 
+	        if (block < le64_to_cpu(ex->ee_block))
 			break;
 		path->p_ext = ex++;
 	}
-	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));
+	ext_debug(tree, "  -> %lld:%lld:%d\n",
+		        le64_to_cpu(path->p_ext->ee_block),
+		        le64_to_cpu(path->p_ext->ee_start),
+		        le32_to_cpu(path->p_ext->ee_len));
 
 #ifdef CHECK_BINSEARCH 
 	{
@@ -421,9 +421,9 @@ ext3_ext_binsearch(struct ext3_extents_t
 		chex = ex = EXT_FIRST_EXTENT(eh);
 		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)) 
+				   le64_to_cpu(ex->ee_block)
+				          > le64_to_cpu(ex[-1].ee_block));
+			if (block < le64_to_cpu(ex->ee_block))
 				break;
 			chex = ex;
 		}
@@ -450,7 +450,7 @@ int ext3_extent_tree_init(handle_t *hand
 }
 
 struct ext3_ext_path *
-ext3_ext_find_extent(struct ext3_extents_tree *tree, int block,
+ext3_ext_find_extent(struct ext3_extents_tree *tree, unsigned long long block,
 			struct ext3_ext_path *path)
 {
 	struct ext3_extent_header *eh;
@@ -483,7 +483,8 @@ ext3_ext_find_extent(struct ext3_extents
 	/* walk through the tree */
 	while (i) {
 		ext_debug(tree, "depth %d: num %d, max %d\n",
-			  ppos, le16_to_cpu(eh->eh_entries), le16_to_cpu(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 = le64_to_cpu(path[ppos].p_idx->ei_leaf);
 		path[ppos].p_depth = i;
@@ -533,7 +534,7 @@ err:
 static int ext3_ext_insert_index(handle_t *handle,
 				struct ext3_extents_tree *tree,
 				struct ext3_ext_path *curp,
-				int logical, long long ptr)
+				unsigned long long logical, long long ptr)
 {
 	struct ext3_extent_idx *ix;
 	int len, err;
@@ -541,14 +542,14 @@ static int ext3_ext_insert_index(handle_
 	if ((err = ext3_ext_get_access(handle, tree, curp)))
 		return err;
 
-	EXT_ASSERT(logical != le32_to_cpu(curp->p_idx->ei_block));
+	EXT_ASSERT(logical != le64_to_cpu(curp->p_idx->ei_block));
 	len = EXT_MAX_INDEX(curp->p_hdr) - curp->p_idx;
-	if (logical > le32_to_cpu(curp->p_idx->ei_block)) {
+	if (logical > le64_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);
 			len = len < 0 ? 0 : len;
-			ext_debug(tree, "insert new index %d after: %lld. "
+			ext_debug(tree, "insert new index %lld after: %lld. "
 					"move %d from 0x%p to 0x%p\n",
 					logical, ptr, len,
 					(curp->p_idx + 1), (curp->p_idx + 2));
@@ -559,7 +560,7 @@ static int ext3_ext_insert_index(handle_
 		/* insert before */
 		len = len * sizeof(struct ext3_extent_idx);
 		len = len < 0 ? 0 : len;
-		ext_debug(tree, "insert new index %d before: %lld. "
+		ext_debug(tree, "insert new index %lld before: %lld. "
 				"move %d from 0x%p to 0x%p\n",
 				logical, ptr, len,
 				curp->p_idx, (curp->p_idx + 1));
@@ -567,7 +568,7 @@ static int ext3_ext_insert_index(handle_
 		ix = curp->p_idx;
 	}
 
-	ix->ei_block = cpu_to_le32(logical);
+	ix->ei_block = cpu_to_le64(logical);
 	ix->ei_leaf = cpu_to_le64(ptr);
 	curp->p_hdr->eh_entries = cpu_to_le16(le16_to_cpu(curp->p_hdr->eh_entries)+1);
 
@@ -601,7 +602,7 @@ static int ext3_ext_split(handle_t *hand
 	struct ext3_extent *ex;
 	int i = at, k, m, a;
 	unsigned long long newblock, oldblock;
-	__le32 border;
+	__le64 border;
 	unsigned long long *ablocks = NULL; /* array of allocated blocks */
 	int err = 0;
 
@@ -614,13 +615,13 @@ static int ext3_ext_split(handle_t *hand
 	if (path[depth].p_ext != EXT_MAX_EXTENT(path[depth].p_hdr)) {
 		border = path[depth].p_ext[1].ee_block;
 		ext_debug(tree, "leaf will be splitted."
-				" next leaf starts at %d\n",
-			          le32_to_cpu(border));
+				" next leaf starts at %lld\n",
+			          le64_to_cpu(border));
 	} else {
 		border = newext->ee_block;
 		ext_debug(tree, "leaf will be added."
-				" next leaf starts at %d\n",
-			        le32_to_cpu(border));
+				" next leaf starts at %lld\n",
+			        le64_to_cpu(border));
 	}
 
 	/* 
@@ -677,10 +678,10 @@ static int ext3_ext_split(handle_t *hand
 	path[depth].p_ext++;
 	while (path[depth].p_ext <=
 			EXT_MAX_EXTENT(path[depth].p_hdr)) {
-		ext_debug(tree, "move %d:%lld:%d in new leaf %llu\n",
-			        le32_to_cpu(path[depth].p_ext->ee_block),
+		ext_debug(tree, "move %lld:%lld:%d in new leaf %llu\n",
+			        le64_to_cpu(path[depth].p_ext->ee_block),
 			        le64_to_cpu(path[depth].p_ext->ee_start),
-			        le16_to_cpu(path[depth].p_ext->ee_len),
+			        le32_to_cpu(path[depth].p_ext->ee_len),
 				newblock);
 		/*memmove(ex++, path[depth].p_ext++,
 				sizeof(struct ext3_extent));
@@ -743,8 +744,8 @@ static int ext3_ext_split(handle_t *hand
 		fidx->ei_block = border;
 		fidx->ei_leaf = cpu_to_le64(oldblock);
 
-		ext_debug(tree,	"int.index at %d (block %llu): %lu -> %llu\n",
-			  i, newblock, le32_to_cpu(border), oldblock);
+		ext_debug(tree,	"int.index at %d (block %llu): %llu -> %llu\n",
+			  i, newblock, le64_to_cpu(border), oldblock);
 		/* copy indexes */
 		m = 0;
 		path[i].p_idx++;
@@ -754,9 +755,9 @@ static int ext3_ext_split(handle_t *hand
 		EXT_ASSERT(EXT_MAX_INDEX(path[i].p_hdr) ==
 				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:%lld in new index %llu\n",
+			ext_debug(tree, "%d: move %lld:%lld in new index %llu\n",
 					i,
-				        le32_to_cpu(path[i].p_idx->ei_block),
+				        le64_to_cpu(path[i].p_idx->ei_block),
 				        le64_to_cpu(path[i].p_idx->ei_leaf),
 				        newblock);
 			/*memmove(++fidx, path[i].p_idx++,
@@ -795,7 +796,7 @@ static int ext3_ext_split(handle_t *hand
 	/* insert new index */
 	if (!err)
 		err = ext3_ext_insert_index(handle, tree, path + at,
-					    le32_to_cpu(border), newblock);
+					    le64_to_cpu(border), newblock);
 
 cleanup:
 	if (bh) {
@@ -885,9 +886,9 @@ static int ext3_ext_grow_indepth(handle_
 
 	neh = EXT_ROOT_HDR(tree);
 	fidx = EXT_FIRST_INDEX(neh);
-	ext_debug(tree, "new root: num %d(%d), lblock %d, ptr %lld\n",
+	ext_debug(tree, "new root: num %d(%d), lblock %lld, ptr %lld\n",
 		  le16_to_cpu(neh->eh_entries), le16_to_cpu(neh->eh_max),
-		  le32_to_cpu(fidx->ei_block), le64_to_cpu(fidx->ei_leaf));
+		  le64_to_cpu(fidx->ei_block), le64_to_cpu(fidx->ei_leaf));
 
 	neh->eh_depth = cpu_to_le16(path->p_depth + 1);
 	err = ext3_ext_dirty(handle, tree, curp);
@@ -929,7 +930,7 @@ repeat:
 		/* refill path */
 		ext3_ext_drop_refs(path);
 		path = ext3_ext_find_extent(tree,
-					    le32_to_cpu(newext->ee_block),
+					    le64_to_cpu(newext->ee_block),
 					    path);
 		if (IS_ERR(path))
 			err = PTR_ERR(path);
@@ -940,7 +941,7 @@ repeat:
 		/* refill path */
 		ext3_ext_drop_refs(path);
 		path = ext3_ext_find_extent(tree,
-					    le32_to_cpu(newext->ee_block),
+					    le64_to_cpu(newext->ee_block),
 					    path);
 		if (IS_ERR(path))
 			err = PTR_ERR(path);
@@ -968,7 +969,7 @@ repeat:
  * allocated block. thus, index entries have to be consistent
  * with leafs
  */
-static unsigned long
+static unsigned long long
 ext3_ext_next_allocated_block(struct ext3_ext_path *path)
 {
 	int depth;
@@ -985,12 +986,12 @@ ext3_ext_next_allocated_block(struct ext
 			/* leaf */
 			if (path[depth].p_ext !=
 					EXT_LAST_EXTENT(path[depth].p_hdr))
-			  return le32_to_cpu(path[depth].p_ext[1].ee_block);
+			  return le64_to_cpu(path[depth].p_ext[1].ee_block);
 		} else {
 			/* index */
 			if (path[depth].p_idx !=
 					EXT_LAST_INDEX(path[depth].p_hdr))
-			  return le32_to_cpu(path[depth].p_idx[1].ei_block);
+			  return le64_to_cpu(path[depth].p_idx[1].ei_block);
 		}
 		depth--;        
 	}
@@ -1001,8 +1002,9 @@ ext3_ext_next_allocated_block(struct ext
 /*
  * returns first allocated block from next leaf or EXT_MAX_BLOCK
  */
-static unsigned ext3_ext_next_leaf_block(struct ext3_extents_tree *tree,
-                                               struct ext3_ext_path *path)
+static unsigned long long
+ext3_ext_next_leaf_block(struct ext3_extents_tree *tree,
+			 struct ext3_ext_path *path)
 {
 	int depth;
 
@@ -1019,7 +1021,7 @@ static unsigned ext3_ext_next_leaf_block
 	while (depth >= 0) {
 		if (path[depth].p_idx !=
 				EXT_LAST_INDEX(path[depth].p_hdr))
-		  return le32_to_cpu(path[depth].p_idx[1].ei_block);
+		  return le64_to_cpu(path[depth].p_idx[1].ei_block);
 		depth--;        
 	}
 
@@ -1037,7 +1039,7 @@ int ext3_ext_correct_indexes(handle_t *h
 	struct ext3_extent_header *eh;
 	int depth = EXT_DEPTH(tree);	
 	struct ext3_extent *ex;
-	__le32 border;
+	__le64 border;
 	int k, err = 0;
 	
 	eh = path[depth].p_hdr;
@@ -1085,12 +1087,12 @@ ext3_can_extents_be_merged(struct ext3_e
 				struct ext3_extent *ex1,
 				struct ext3_extent *ex2)
 {
-        if (le32_to_cpu(ex1->ee_block) + le16_to_cpu(ex1->ee_len)
-	    != le32_to_cpu(ex2->ee_block))
+        if (le64_to_cpu(ex1->ee_block) + le32_to_cpu(ex1->ee_len)
+	    != le64_to_cpu(ex2->ee_block))
 		return 0;
 
 #ifdef AGRESSIVE_TEST
-	if (le16_to_cpu(ex1->ee_len) >= 4)
+	if (le32_to_cpu(ex1->ee_len) >= 4)
 		return 0;
 #endif
 
@@ -1113,7 +1115,8 @@ int ext3_ext_insert_extent(handle_t *han
 	struct ext3_extent *ex, *fex;
 	struct ext3_extent *nearex; /* nearest extent */
 	struct ext3_ext_path *npath = NULL;
-	int depth, len, err, next;
+	int depth, len, err;
+	unsigned long long next;
 
 	EXT_ASSERT(newext->ee_len > 0);
 	depth = EXT_DEPTH(tree);
@@ -1122,15 +1125,15 @@ int ext3_ext_insert_extent(handle_t *han
 
 	/* 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 %lld)\n",
-			        le16_to_cpu(newext->ee_len),
-			        le32_to_cpu(ex->ee_block),
-			        le16_to_cpu(ex->ee_len),
+		ext_debug(tree, "append %d block to %lld:%d (from %lld)\n",
+			        le32_to_cpu(newext->ee_len),
+			        le64_to_cpu(ex->ee_block),
+			        le32_to_cpu(ex->ee_len),
 			        le64_to_cpu(ex->ee_start));
 		if ((err = ext3_ext_get_access(handle, tree, path + depth)))
 			return err;
-		ex->ee_len = cpu_to_le16(le16_to_cpu(ex->ee_len)
-					 + le16_to_cpu(newext->ee_len));
+		ex->ee_len = cpu_to_le32(le32_to_cpu(ex->ee_len)
+					 + le32_to_cpu(newext->ee_len));
 		eh = path[depth].p_hdr;
 		nearex = ex;
 		goto merge;
@@ -1145,9 +1148,9 @@ repeat:
 	/* probably next leaf has space for us? */
 	fex = EXT_LAST_EXTENT(eh);
 	next = ext3_ext_next_leaf_block(tree, path);
-	if (le32_to_cpu(newext->ee_block) > le32_to_cpu(fex->ee_block)
+	if (le64_to_cpu(newext->ee_block) > le64_to_cpu(fex->ee_block)
 	    && next != EXT_MAX_BLOCK) {
-		ext_debug(tree, "next leaf block - %d\n", next);
+		ext_debug(tree, "next leaf block - %lld\n", next);
 		EXT_ASSERT(!npath);
 		npath = ext3_ext_find_extent(tree, next, NULL);
 		if (IS_ERR(npath))
@@ -1182,23 +1185,23 @@ has_space:
 
 	if (!nearex) {
 		/* there is no extent in this leaf, create first one */
-		ext_debug(tree, "first extent in the leaf: %d:%lld:%d\n",
-			        le32_to_cpu(newext->ee_block),
+		ext_debug(tree, "first extent in the leaf: %lld:%lld:%d\n",
+			        le64_to_cpu(newext->ee_block),
 			        le64_to_cpu(newext->ee_start),
-			        le16_to_cpu(newext->ee_len));
+			        le32_to_cpu(newext->ee_len));
 		path[depth].p_ext = EXT_FIRST_EXTENT(eh);
-	} else if (le32_to_cpu(newext->ee_block)
-		           > le32_to_cpu(nearex->ee_block)) {
+	} else if (le64_to_cpu(newext->ee_block)
+		           > le64_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:%lld:%d after: nearest 0x%p, "
+			ext_debug(tree, "insert %lld:%lld:%d after: nearest 0x%p, "
 					"move %d from 0x%p to 0x%p\n",
-				        le32_to_cpu(newext->ee_block),
+				        le64_to_cpu(newext->ee_block),
 				        le64_to_cpu(newext->ee_start),
-				        le16_to_cpu(newext->ee_len),
+				        le32_to_cpu(newext->ee_len),
 					nearex, len, nearex + 1, nearex + 2);
 			memmove(nearex + 2, nearex + 1, len);
 		}
@@ -1207,11 +1210,11 @@ has_space:
  		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:%lld:%d before: nearest 0x%p, "
+		ext_debug(tree, "insert %lld:%lld:%d before: nearest 0x%p, "
 				"move %d from 0x%p to 0x%p\n",
-				le32_to_cpu(newext->ee_block),
+				le64_to_cpu(newext->ee_block),
 				le64_to_cpu(newext->ee_start),
-				le16_to_cpu(newext->ee_len),
+				le32_to_cpu(newext->ee_len),
 				nearex, len, nearex + 1, nearex + 2);
 		memmove(nearex + 1, nearex, len);
 		path[depth].p_ext = nearex;
@@ -1229,8 +1232,8 @@ merge:
 		if (!ext3_can_extents_be_merged(tree, nearex, nearex + 1))
 			break;
 		/* merge with next extent! */
-		nearex->ee_len = cpu_to_le16(le16_to_cpu(nearex->ee_len)
-					     + le16_to_cpu(nearex[1].ee_len));
+		nearex->ee_len = cpu_to_le32(le32_to_cpu(nearex->ee_len)
+					     + le32_to_cpu(nearex[1].ee_len));
 		if (nearex + 1 < EXT_LAST_EXTENT(eh)) {
 			len = (EXT_LAST_EXTENT(eh) - nearex - 1)
 					* sizeof(struct ext3_extent);
@@ -1259,14 +1262,14 @@ cleanup:
 	return err;
 }
 
-int ext3_ext_walk_space(struct ext3_extents_tree *tree, unsigned long block,
-			unsigned long num, ext_prepare_callback func)
+int ext3_ext_walk_space(struct ext3_extents_tree *tree, unsigned long long block,
+			unsigned long long num, ext_prepare_callback func)
 {
 	struct ext3_ext_path *path = NULL;
 	struct ext3_ext_cache cbex;
 	struct ext3_extent *ex;
-	unsigned long next, start = 0, end = 0;
-	unsigned long last = block + num;
+	unsigned long long next, start = 0, end = 0;
+	unsigned long long last = block + num;
 	int depth, exists, err = 0;
 
 	EXT_ASSERT(tree);
@@ -1295,26 +1298,26 @@ int ext3_ext_walk_space(struct ext3_exte
 			 * all requested space */
 			start = block;
 			end = block + num;
-		} else if (le32_to_cpu(ex->ee_block) > block) {
+		} else if (le64_to_cpu(ex->ee_block) > block) {
 			/* need to allocate space before found extent */
 			start = block;
-			end = le32_to_cpu(ex->ee_block);
+			end = le64_to_cpu(ex->ee_block);
 			if (block + num < end)
 				end = block + num;
 		} else if (block >=
-			     le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len)) {
+			     le64_to_cpu(ex->ee_block) + le32_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 >= le32_to_cpu(ex->ee_block)) {
+		} else if (block >= le64_to_cpu(ex->ee_block)) {
 			/* 
 			 * some part of requested space is covered
 			 * by found extent
 			 */
 			start = block;
-			end = le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len);
+			end = le64_to_cpu(ex->ee_block) + le32_to_cpu(ex->ee_len);
 			if (block + num < end)
 				end = block + num;
 			exists = 1;
@@ -1329,8 +1332,8 @@ int ext3_ext_walk_space(struct ext3_exte
 			cbex.ec_start = 0;
 			cbex.ec_type = EXT3_EXT_CACHE_GAP;
 		} else {
-		        cbex.ec_block = le32_to_cpu(ex->ee_block);
-		        cbex.ec_len = le16_to_cpu(ex->ee_len);
+		        cbex.ec_block = le64_to_cpu(ex->ee_block);
+		        cbex.ec_len = le32_to_cpu(ex->ee_len);
 		        cbex.ec_start = le64_to_cpu(ex->ee_start);
 			cbex.ec_type = EXT3_EXT_CACHE_EXTENT;
 		}
@@ -1367,7 +1370,7 @@ int ext3_ext_walk_space(struct ext3_exte
 }
 
 static inline void
-ext3_ext_put_in_cache(struct ext3_extents_tree *tree, __u32 block,
+ext3_ext_put_in_cache(struct ext3_extents_tree *tree, __u64 block,
 			__u32 len, __u64 start, int type)
 {
 	EXT_ASSERT(len > 0);
@@ -1386,10 +1389,10 @@ ext3_ext_put_in_cache(struct ext3_extent
 static inline void
 ext3_ext_put_gap_in_cache(struct ext3_extents_tree *tree,
 				struct ext3_ext_path *path,
-				unsigned long block)
+				unsigned long long block)
 {
 	int depth = EXT_DEPTH(tree);
-	unsigned long lblock, len;
+	unsigned long long lblock, len;
 	struct ext3_extent *ex;
 
 	if (!tree->cex)
@@ -1401,22 +1404,22 @@ ext3_ext_put_gap_in_cache(struct ext3_ex
 		lblock = 0;
 		len = EXT_MAX_BLOCK;
 		ext_debug(tree, "cache gap(whole file):");
-	} else if (block < le32_to_cpu(ex->ee_block)) {
+	} else if (block < le64_to_cpu(ex->ee_block)) {
 		lblock = block;
-		len = le32_to_cpu(ex->ee_block) - block;
-		ext_debug(tree, "cache gap(before): %lu [%lu:%lu]",
-				(unsigned long) block,
-			        (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 = le64_to_cpu(ex->ee_block) - block;
+		ext_debug(tree, "cache gap(before): %llu [%llu:%lu]",
+				block,
+			        le64_to_cpu(ex->ee_block),
+			        (unsigned long) le32_to_cpu(ex->ee_len));
+	} else if (block >= le64_to_cpu(ex->ee_block)
+		            + le32_to_cpu(ex->ee_len)) {
+	        lblock = le64_to_cpu(ex->ee_block)
+		         + le32_to_cpu(ex->ee_len);
 		len = ext3_ext_next_allocated_block(path);
-		ext_debug(tree, "cache gap(after): [%lu:%lu] %lu",
-			        (unsigned long) le32_to_cpu(ex->ee_block),
-			        (unsigned long) le16_to_cpu(ex->ee_len),
-				(unsigned long) block);
+		ext_debug(tree, "cache gap(after): [%llu:%lu] %llu",
+			        le64_to_cpu(ex->ee_block),
+			        (unsigned long) le32_to_cpu(ex->ee_len),
+				block);
 		EXT_ASSERT(len > lblock);
 		len = len - lblock;
 	} else {
@@ -1424,12 +1427,12 @@ ext3_ext_put_gap_in_cache(struct ext3_ex
 		BUG();
 	}
 
-	ext_debug(tree, " -> %lu:%lu\n", (unsigned long) lblock, len);
-	ext3_ext_put_in_cache(tree, lblock, len, 0, EXT3_EXT_CACHE_GAP);
+	ext_debug(tree, " -> %llu:%lu\n", lblock, (unsigned long)len);
+	ext3_ext_put_in_cache(tree, lblock, (int)len, 0, EXT3_EXT_CACHE_GAP);
 }
 
 static inline int
-ext3_ext_in_cache(struct ext3_extents_tree *tree, unsigned long block,
+ext3_ext_in_cache(struct ext3_extents_tree *tree, unsigned long long block,
 			struct ext3_extent *ex)
 {
 	struct ext3_ext_cache *cex = tree->cex;
@@ -1445,14 +1448,14 @@ ext3_ext_in_cache(struct ext3_extents_tr
 	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 = cpu_to_le32(cex->ec_block);
+	        ex->ee_block = cpu_to_le64(cex->ec_block);
 	        ex->ee_start = cpu_to_le64(cex->ec_start);
-	        ex->ee_len = cpu_to_le16(cex->ec_len);
-		ext_debug(tree, "%lu cached by %lu:%lu:%llu\n",
-				(unsigned long) block,
-				(unsigned long) cex->ec_block,
-				(unsigned long) cex->ec_len,
-				(unsigned long long) cex->ec_start);
+	        ex->ee_len = cpu_to_le32(cex->ec_len);
+		ext_debug(tree, "%llu cached by %llu:%lu:%llu\n",
+				block,
+				cex->ec_block,
+				cex->ec_len,
+				cex->ec_start);
 		return cex->ec_type;
 	}
 
@@ -1528,8 +1531,8 @@ int ext3_ext_calc_credits_for_insert(str
 
 static int
 ext3_ext_split_for_rm(handle_t *handle, struct ext3_extents_tree *tree,
-			struct ext3_ext_path *path, unsigned long start,
-			unsigned long end)
+			struct ext3_ext_path *path, unsigned long long start,
+			unsigned long long end)
 {
 	struct ext3_extent *ex, tex;
 	struct ext3_ext_path *npath;
@@ -1538,16 +1541,16 @@ ext3_ext_split_for_rm(handle_t *handle, 
 	depth = EXT_DEPTH(tree);
 	ex = path[depth].p_ext;
 	EXT_ASSERT(ex);
-	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);
+	EXT_ASSERT(end < le64_to_cpu(ex->ee_block) + le32_to_cpu(ex->ee_len) - 1);
+	EXT_ASSERT(le64_to_cpu(ex->ee_block) < start);
 
 	/* calculate tail extent */
-	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));
+	tex.ee_block = cpu_to_le64(end + 1);
+	EXT_ASSERT(le64_to_cpu(tex.ee_block) <
+		           le64_to_cpu(ex->ee_block) + le32_to_cpu(ex->ee_len));
+	tex.ee_len = cpu_to_le32(le64_to_cpu(ex->ee_block)
+				 + le32_to_cpu(ex->ee_len)
+				 - le64_to_cpu(tex.ee_block));
 
 	creds = ext3_ext_calc_credits_for_insert(tree, path);
 	handle = ext3_ext_journal_restart(handle, creds);
@@ -1558,21 +1561,21 @@ ext3_ext_split_for_rm(handle_t *handle, 
 	err = ext3_ext_get_access(handle, tree, path + depth);
 	if (err)
 		return err;
-	ex->ee_len = cpu_to_le16(start
-				 - le32_to_cpu(ex->ee_block));
+	ex->ee_len = cpu_to_le32(start
+				 - le64_to_cpu(ex->ee_block));
 	err = ext3_ext_dirty(handle, tree, path + depth);
 	if (err)
 		return err;
 
 	/* FIXME: some callback to free underlying resource
 	 * and correct ee_start? */
-	ext_debug(tree, "split extent: head %u:%u, tail %u:%u\n",
-		        le32_to_cpu(ex->ee_block),
-		        le16_to_cpu(ex->ee_len),
-		        le32_to_cpu(tex.ee_block),
-		        le16_to_cpu(tex.ee_len));
+	ext_debug(tree, "split extent: head %llu:%u, tail %llu:%u\n",
+		        le64_to_cpu(ex->ee_block),
+		        le32_to_cpu(ex->ee_len),
+		        le64_to_cpu(tex.ee_block),
+		        le32_to_cpu(tex.ee_len));
 
-	npath = ext3_ext_find_extent(tree, le32_to_cpu(ex->ee_block), NULL);
+	npath = ext3_ext_find_extent(tree, le64_to_cpu(ex->ee_block), NULL);
 	if (IS_ERR(npath))
 		return PTR_ERR(npath);
 	depth = EXT_DEPTH(tree);
@@ -1589,18 +1592,19 @@ ext3_ext_split_for_rm(handle_t *handle, 
 
 static int
 ext3_ext_rm_leaf(handle_t *handle, struct ext3_extents_tree *tree,
-			struct ext3_ext_path *path, unsigned long start,
-			unsigned long end)
+			struct ext3_ext_path *path, unsigned long long start,
+			unsigned long long end)
 {
 	struct ext3_extent *ex, *fu = NULL, *lu, *le;
 	int err = 0, correct_index = 0;
 	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;
+	unsigned long long a, b, block;
+	unsigned num;
+	unsigned long long ex_ee_block;
+	unsigned int ex_ee_len;
 
-	ext_debug(tree, "remove [%lu:%lu] in leaf\n", start, end);
+	ext_debug(tree, "remove [%llu:%llu] 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;
@@ -1612,13 +1616,13 @@ ext3_ext_rm_leaf(handle_t *handle, struc
 	le = ex = EXT_LAST_EXTENT(eh);
 
 	while (ex != EXT_FIRST_EXTENT(eh)) {
-	        if (le32_to_cpu(ex->ee_block) <= end)
+	        if (le64_to_cpu(ex->ee_block) <= end)
 			break;
 		ex--;
 	}
 
-	ex_ee_block = le32_to_cpu(ex->ee_block);
-	ex_ee_len = le16_to_cpu(ex->ee_len);
+	ex_ee_block = le64_to_cpu(ex->ee_block);
+	ex_ee_len = le32_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
@@ -1631,14 +1635,14 @@ ext3_ext_rm_leaf(handle_t *handle, struc
 	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);
+		ext_debug(tree, "remove ext %llu:%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;
 		
-		ext_debug(tree, "  border %u:%u\n", a, b);
+		ext_debug(tree, "  border %llu:%llu\n", a, b);
 
 		if (a != ex_ee_block && b != ex_ee_block + ex_ee_len - 1) {
 			block = 0;
@@ -1691,8 +1695,8 @@ ext3_ext_rm_leaf(handle_t *handle, struc
 			fu = ex;
 		}
 
-		ex->ee_block = cpu_to_le32(block);
-		ex->ee_len = cpu_to_le16(num);
+		ex->ee_block = cpu_to_le64(block);
+		ex->ee_len = cpu_to_le32(num);
 
 		err = ext3_ext_dirty(handle, tree, path + depth);
 		if (err)
@@ -1701,8 +1705,8 @@ ext3_ext_rm_leaf(handle_t *handle, struc
 		ext_debug(tree, "new extent: %u:%u:%llu\n",
 			        block, num, le64_to_cpu(ex->ee_start));
 		ex--;
-		ex_ee_block = le32_to_cpu(ex->ee_block);
-		ex_ee_len = le16_to_cpu(ex->ee_len);
+		ex_ee_block = le64_to_cpu(ex->ee_block);
+		ex_ee_len = le32_to_cpu(ex->ee_len);
 	}
 
 	if (fu) {
@@ -1731,13 +1735,13 @@ out:
 
 
 static struct ext3_extent_idx *
-ext3_ext_last_covered(struct ext3_extent_header *hdr, unsigned long block)
+ext3_ext_last_covered(struct ext3_extent_header *hdr, unsigned long long block)
 {
 	struct ext3_extent_idx *ix;
 	
 	ix = EXT_LAST_INDEX(hdr);
 	while (ix != EXT_FIRST_INDEX(hdr)) {
-	        if (le32_to_cpu(ix->ei_block) <= block)
+	        if (le64_to_cpu(ix->ei_block) <= block)
 			break;
 		ix--;
 	}
@@ -1765,7 +1769,8 @@ ext3_ext_more_to_rm(struct ext3_ext_path
 }
 
 int ext3_ext_remove_space(struct ext3_extents_tree *tree,
-				unsigned long start, unsigned long end)
+			  unsigned long long start,
+			  unsigned long long end)
 {
 	struct inode *inode = tree->inode;
 	struct super_block *sb = inode->i_sb;
@@ -1774,7 +1779,7 @@ int ext3_ext_remove_space(struct ext3_ex
 	handle_t *handle;
 	int i = 0, err = 0;
 
-	ext_debug(tree, "space to be removed: %lu:%lu\n", start, end);
+	ext_debug(tree, "space to be removed: %llu:%llu\n", start, end);
 
 	/* probably first extent we're gonna free will be last in block */
 	handle = ext3_journal_start(inode, depth + 1);
@@ -1985,7 +1990,7 @@ static int ext3_ext_mergable(struct ext3
 				struct ext3_extent *ex2)
 {
 	/* FIXME: support for large fs */
-        if (le64_to_cpu(ex1->ee_start) + le16_to_cpu(ex1->ee_len)
+        if (le64_to_cpu(ex1->ee_start) + le32_to_cpu(ex1->ee_len)
 	    == le64_to_cpu(ex2->ee_start))
 		return 1;
 	return 0;
@@ -1993,8 +1998,9 @@ static int ext3_ext_mergable(struct ext3
 
 static int
 ext3_remove_blocks_credits(struct ext3_extents_tree *tree,
-				struct ext3_extent *ex,
-				unsigned long from, unsigned long to)
+			   struct ext3_extent *ex,
+			   unsigned long long from,
+			   unsigned long long to)
 {
 	int needed;
 	
@@ -2009,8 +2015,9 @@ ext3_remove_blocks_credits(struct ext3_e
 
 static int
 ext3_remove_blocks(struct ext3_extents_tree *tree,
-				struct ext3_extent *ex,
-				unsigned long from, unsigned long to)
+		   struct ext3_extent *ex,
+		   unsigned long long from,
+		   unsigned long long to)
 {
 	int needed = ext3_remove_blocks_credits(tree, ex, from, to);
 	handle_t *handle = ext3_journal_start(tree->inode, needed);
@@ -2022,7 +2029,7 @@ ext3_remove_blocks(struct ext3_extents_t
 #ifdef EXTENTS_STATS
 	{
 		struct ext3_sb_info *sbi = EXT3_SB(tree->inode->i_sb);
-		unsigned short ee_len =  le16_to_cpu(ex->ee_len);
+		unsigned int ee_len =  le32_to_cpu(ex->ee_len);
 		spin_lock(&sbi->s_ext_stats_lock);
 		sbi->s_ext_blocks += ee_len;
 		sbi->s_ext_extents++;
@@ -2035,13 +2042,13 @@ ext3_remove_blocks(struct ext3_extents_t
 		spin_unlock(&sbi->s_ext_stats_lock);
 	}
 #endif
-	if (from >= le32_to_cpu(ex->ee_block)
-	    && to == le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len) - 1) {
+	if (from >= le64_to_cpu(ex->ee_block)
+	    && to == le64_to_cpu(ex->ee_block) + le32_to_cpu(ex->ee_len) - 1) {
 		/* tail removal */
 	        unsigned long num;
 		unsigned long long start;
-		num = le32_to_cpu(ex->ee_block) + le16_to_cpu(ex->ee_len) - from;
-		start = le64_to_cpu(ex->ee_start) + le16_to_cpu(ex->ee_len) - num;
+		num = le64_to_cpu(ex->ee_block) + le32_to_cpu(ex->ee_len) - from;
+		start = le64_to_cpu(ex->ee_start) + le32_to_cpu(ex->ee_len) - num;
 		ext_debug(tree, "free last %lu blocks starting %llu\n",
 				num, start);
 		for (i = 0; i < num; i++) {
@@ -2049,20 +2056,20 @@ ext3_remove_blocks(struct ext3_extents_t
 			ext3_forget(handle, 0, tree->inode, bh, start + i);
 		}
 		ext3_free_blocks(handle, tree->inode, start, num);
-	} 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, le32_to_cpu(ex->ee_block), le16_to_cpu(ex->ee_len));
+	} else if (from == le64_to_cpu(ex->ee_block)
+		   && to <= le64_to_cpu(ex->ee_block) + le32_to_cpu(ex->ee_len) - 1) {
+		printk("strange request: removal %llu-%llu from %llu:%u\n",
+		       from, to, le64_to_cpu(ex->ee_block), le32_to_cpu(ex->ee_len));
 	} else {
-		printk("strange request: removal(2) %lu-%lu from %u:%u\n",
-		       from, to, le32_to_cpu(ex->ee_block), le16_to_cpu(ex->ee_len));
+		printk("strange request: removal(2) %llu-%llu from %llu:%u\n",
+		       from, to, le64_to_cpu(ex->ee_block), le32_to_cpu(ex->ee_len));
 	}
 	ext3_journal_stop(handle);
 	return 0;
 }
 
 static long long ext3_ext_find_goal(struct inode *inode,
-				struct ext3_ext_path *path, unsigned long block)
+				struct ext3_ext_path *path, unsigned long long block)
 {
 	struct ext3_inode_info *ei = EXT3_I(inode);
 	unsigned long bg_start;
@@ -2076,7 +2083,7 @@ static long long ext3_ext_find_goal(stru
 		/* try to predict block placement */
 		if ((ex = path[depth].p_ext))
 		        return le64_to_cpu(ex->ee_start)
-			       + (block - le32_to_cpu(ex->ee_block));
+			       + (block - le64_to_cpu(ex->ee_block));
 
 		/* it looks index is empty
 		 * try to find starting from index itself */
@@ -2098,7 +2105,7 @@ static long long ext3_new_block_cb(handl
 {
 	struct inode *inode = tree->inode;
 	long long newblock, goal;
-	unsigned short len;
+	unsigned int len;
 	
 	EXT_ASSERT(path);
 	EXT_ASSERT(ex);
@@ -2107,10 +2114,10 @@ static long long ext3_new_block_cb(handl
 	
 	/* reuse block from the extent to order data/metadata */
 	newblock = le64_to_cpu(ex->ee_start);
-	len = le16_to_cpu(ex->ee_len) - 1;
+	len = le32_to_cpu(ex->ee_len) - 1;
 	if (len == 0) {
 		/* allocate new block for the extent */
-		goal = ext3_ext_find_goal(inode, path, le32_to_cpu(ex->ee_block));
+		goal = ext3_ext_find_goal(inode, path, le64_to_cpu(ex->ee_block));
 		ex->ee_start = cpu_to_le64(ext3_new_block(handle, inode, goal, err));
 		if (ex->ee_start == 0) {
 			/* error occured: restore old extent */
@@ -2120,7 +2127,7 @@ static long long ext3_new_block_cb(handl
 	}
 	else {
 	  ex->ee_start = cpu_to_le64(newblock+1);
-	  ex->ee_len = cpu_to_le16(len);
+	  ex->ee_len = cpu_to_le32(len);
 	}
 	return newblock;
 }
@@ -2146,7 +2153,7 @@ void ext3_init_tree_desc(struct ext3_ext
 }
 
 int ext3_ext_get_block(handle_t *handle, struct inode *inode,
-			long iblock, struct buffer_head *bh_result,
+			long long iblock, struct buffer_head *bh_result,
 			int create, int extend_disksize)
 {
 	struct ext3_ext_path *path = NULL;
@@ -2158,8 +2165,8 @@ int ext3_ext_get_block(handle_t *handle,
 
 	__clear_bit(BH_New, &bh_result->b_state);
 	ext3_init_tree_desc(&tree, inode);
-	ext_debug(&tree, "block %d requested for inode %u\n",
-			(int) iblock, (unsigned) inode->i_ino);
+	ext_debug(&tree, "block %lld requested for inode %u\n",
+		          iblock, (unsigned) inode->i_ino);
 	down(&EXT3_I(inode)->truncate_sem);
 
 	/* check in cache */
@@ -2174,7 +2181,7 @@ int ext3_ext_get_block(handle_t *handle,
 		} else if (goal == EXT3_EXT_CACHE_EXTENT) {
 			/* block is already allocated */
 		        newblock = iblock
-		                   - le32_to_cpu(newex.ee_block)
+		                   - le64_to_cpu(newex.ee_block)
 			           + le64_to_cpu(newex.ee_start);
 			goto out;
 		} else {
@@ -2200,15 +2207,15 @@ int ext3_ext_get_block(handle_t *handle,
 	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 long ee_block = le64_to_cpu(ex->ee_block);
 		unsigned long long ee_start = le64_to_cpu(ex->ee_start);
-		unsigned short ee_len  = le16_to_cpu(ex->ee_len);
+		unsigned int ee_len  = le32_to_cpu(ex->ee_len);
 		/* if found exent covers block, simple return it */
 	        if (iblock >= ee_block
 		    && iblock < ee_block + ee_len) {
 			newblock = iblock - ee_block + ee_start;
-			ext_debug(&tree, "%d fit into %d:%d -> %lld\n",
-					(int) iblock, ee_block, ee_len,
+			ext_debug(&tree, "%lld fit into %lld:%d -> %lld\n",
+					iblock, ee_block, ee_len,
 					newblock);
 			ext3_ext_put_in_cache(&tree, ee_block,
 						ee_len, ee_start,
@@ -2236,9 +2243,9 @@ int ext3_ext_get_block(handle_t *handle,
 			goal, newblock);
 
 	/* try to insert new extent into found leaf and return */
-	newex.ee_block = cpu_to_le32(iblock);
+	newex.ee_block = cpu_to_le64(iblock);
 	newex.ee_start = cpu_to_le64(newblock);
-	newex.ee_len = cpu_to_le16(1);
+	newex.ee_len = cpu_to_le32(1);
 	err = ext3_ext_insert_extent(handle, &tree, path, &newex);
 	if (err)
 		goto out2;
@@ -2272,7 +2279,7 @@ void ext3_ext_truncate(struct inode * in
 	struct address_space *mapping = inode->i_mapping;
 	struct super_block *sb = inode->i_sb;
 	struct ext3_extents_tree tree;
-	unsigned long last_block;
+	unsigned long long last_block;
 	handle_t *handle;
 	int err = 0;
 
Index: linux-2.6.11.7/include/linux/ext3_extents.h
===================================================================
--- linux-2.6.11.7.orig/include/linux/ext3_extents.h
+++ linux-2.6.11.7/include/linux/ext3_extents.h
@@ -76,9 +76,10 @@ do {							\
  * it's used at the bottom of the tree
  */
 struct ext3_extent {
-	__le32	ee_block;	/* first logical block extent covers */
-	__le16	ee_len;		/* number of blocks covered by extent */
+	__le64	ee_block;	/* first logical block extent covers */
 	__le64	ee_start;	/* physical block */
+	__le32	ee_len;		/* number of blocks covered by extent */
+        __u32   ee_unused;
 };
 
 /*
@@ -86,7 +87,7 @@ struct ext3_extent {
  * it's used at all the levels, but the bottom
  */
 struct ext3_extent_idx {
-	__le32	ei_block;	/* index covers logical blocks from 'block' */
+	__le64	ei_block;	/* index covers logical blocks from 'block' */
 	__le64	ei_leaf;	/* pointer to the physical block of the next *
 				 * level. leaf or next index could bet here */
 
@@ -128,7 +129,7 @@ struct ext3_ext_path {
  */
 struct ext3_ext_cache {
 	__u64	ec_start;
-	__u32	ec_block;
+	__u64	ec_block;
 	__u32	ec_len;
 	__u32	ec_type;
 };
@@ -157,11 +158,13 @@ struct ext3_extents_helpers {
 	int (*mark_buffer_dirty)(handle_t *h, void *buffer);
 	int (*mergable)(struct ext3_extent *ex1, struct ext3_extent *ex2);
 	int (*remove_extent_credits)(struct ext3_extents_tree *,
-					struct ext3_extent *, unsigned long,
-					unsigned long);
+				     struct ext3_extent *,
+				     unsigned long long,
+				     unsigned long long);
 	int (*remove_extent)(struct ext3_extents_tree *,
-				struct ext3_extent *, unsigned long,
-				unsigned long);
+			     struct ext3_extent *,
+			     unsigned long long,
+			     unsigned long long);
 	long long (*new_block)(handle_t *, struct ext3_extents_tree *,
 				struct ext3_ext_path *, struct ext3_extent *,
 				int *);
@@ -182,7 +185,7 @@ typedef int (*ext_prepare_callback)(stru
 #define EXT_REPEAT	2
 
 
-#define EXT_MAX_BLOCK	0xffffffff
+#define EXT_MAX_BLOCK	0xffffffffffffffffULL
 
 
 #define EXT_FIRST_EXTENT(__hdr__) \
@@ -234,7 +237,7 @@ typedef int (*ext_prepare_callback)(stru
  * this structure is used to gather extents from the tree via ioctl
  */
 struct ext3_extent_buf {
-	unsigned long start;
+	unsigned long long start;
 	int buflen;
 	void *buffer;
 	void *cur;
@@ -253,9 +256,9 @@ struct ext3_extent_tree_stats {
 extern int ext3_extent_tree_init(handle_t *, struct ext3_extents_tree *);
 extern int ext3_ext_calc_credits_for_insert(struct ext3_extents_tree *, struct ext3_ext_path *);
 extern int ext3_ext_insert_extent(handle_t *, struct ext3_extents_tree *, struct ext3_ext_path *, struct ext3_extent *);
-extern int ext3_ext_walk_space(struct ext3_extents_tree *, unsigned long, unsigned long, ext_prepare_callback);
-extern int ext3_ext_remove_space(struct ext3_extents_tree *, unsigned long, unsigned long);
-extern struct ext3_ext_path * ext3_ext_find_extent(struct ext3_extents_tree *, int, struct ext3_ext_path *);
+extern int ext3_ext_walk_space(struct ext3_extents_tree *, unsigned long long, unsigned long long, ext_prepare_callback);
+extern int ext3_ext_remove_space(struct ext3_extents_tree *, unsigned long long, unsigned long long);
+extern struct ext3_ext_path * ext3_ext_find_extent(struct ext3_extents_tree *, unsigned long long, struct ext3_ext_path *);
 extern void ext3_init_tree_desc(struct ext3_extents_tree *, struct inode *);
 extern int ext3_ext_calc_blockmap_metadata(struct inode *, int);
 
Index: linux-2.6.11.7/include/linux/ext3_fs.h
===================================================================
--- linux-2.6.11.7.orig/include/linux/ext3_fs.h
+++ linux-2.6.11.7/include/linux/ext3_fs.h
@@ -835,7 +835,7 @@ extern struct inode_operations ext3_fast
 
 /* extents.c */
 extern int ext3_ext_writepage_trans_blocks(struct inode *, int);
-extern int ext3_ext_get_block(handle_t *, struct inode *, long,
+extern int ext3_ext_get_block(handle_t *, struct inode *, long long,
 				struct buffer_head *, int, int);
 extern void ext3_ext_truncate(struct inode *, struct page *);
 extern void ext3_ext_init(struct super_block *);

