=================================================================== --- linux-2.6.16-cmm/fs/ext3/extents.c | 89 ++++++++++++++++------------- linux-2.6.16-cmm/include/linux/ext3_fs_i.h | 2 2 files changed, 53 insertions(+), 38 deletions(-) diff -puN fs/ext3/extents.c~48bit-extents fs/ext3/extents.c --- linux-2.6.16/fs/ext3/extents.c~48bit-extents 2006-05-23 17:11:30.000000000 -0700 +++ linux-2.6.16-cmm/fs/ext3/extents.c 2006-05-23 17:23:39.000000000 -0700 @@ -44,6 +44,27 @@ #include +/* this macro combines low and hi parts of phys. blocknr into sector_t */ +static inline sector_t ext_pblock(struct ext3_extent *ex) +{ + sector_t block; + + block = le32_to_cpu(ex->ee_start); +#ifdef CONFIG_LBD + block |= (sector_t) le16_to_cpu(ex->ee_start_hi) << 32; +#endif + return block; +} + +/* the routine stores large phys. blocknr into extent breaking it into parts */ +static inline void ext3_ext_store_pblock(struct ext3_extent *ex, sector_t pb) +{ + ex->ee_start = cpu_to_le32((unsigned long) (pb & 0xffffffff)); +#ifdef CONFIG_LBD + ex->ee_start_hi = cpu_to_le16((unsigned long) (pb >> 32) & 0xffff); +#endif +} + static int ext3_ext_check_header(struct ext3_extent_header *eh) { if (eh->eh_magic != EXT3_EXT_MAGIC) { @@ -116,7 +137,7 @@ static int ext3_ext_dirty(handle_t *hand static int ext3_ext_find_goal(struct inode *inode, struct ext3_ext_path *path, - unsigned long block) + sector_t block) { struct ext3_inode_info *ei = EXT3_I(inode); unsigned long bg_start; @@ -129,8 +150,7 @@ static int ext3_ext_find_goal(struct ino /* try to predict block placement */ if ((ex = path[depth].p_ext)) - return le32_to_cpu(ex->ee_start) - + (block - le32_to_cpu(ex->ee_block)); + return ext_pblock(ex)+(block-le32_to_cpu(ex->ee_block)); /* it looks index is empty * try to find starting from index itself */ @@ -223,10 +243,10 @@ static void ext3_ext_show_path(struct in ext_debug(" %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(" %d:%d:%d", + ext_debug(" %d:%d:%lld", le32_to_cpu(path->p_ext->ee_block), le16_to_cpu(path->p_ext->ee_len), - le32_to_cpu(path->p_ext->ee_start)); + ext_pblock(path->p_ext)); } else ext_debug(" []"); } @@ -247,9 +267,8 @@ static void ext3_ext_show_leaf(struct in ex = EXT_FIRST_EXTENT(eh); for (i = 0; i < le16_to_cpu(eh->eh_entries); i++, ex++) { - ext_debug("%d:%d:%d ", le32_to_cpu(ex->ee_block), - le16_to_cpu(ex->ee_len), - le32_to_cpu(ex->ee_start)); + ext_debug("%d:%d:%lld ", le32_to_cpu(ex->ee_block), + le16_to_cpu(ex->ee_len), ext_pblock(ex)); } ext_debug("\n"); } @@ -364,10 +383,10 @@ ext3_ext_binsearch(struct inode *inode, } path->p_ext = l - 1; - ext_debug(" -> %d:%d:%d ", + ext_debug(" -> %d:%lld:%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)); + ext_pblock(path->p_ext), + le16_to_cpu(path->p_ext->ee_len)); #ifdef CHECK_BINSEARCH { @@ -622,9 +641,9 @@ 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("move %d:%d:%d in new leaf %lu\n", + ext_debug("move %d:%lld:%d in new leaf %lu\n", le32_to_cpu(path[depth].p_ext->ee_block), - le32_to_cpu(path[depth].p_ext->ee_start), + ext_pblock(path[depth].p_ext), le16_to_cpu(path[depth].p_ext->ee_len), newblock); /*memmove(ex++, path[depth].p_ext++, @@ -1030,7 +1049,6 @@ static int inline ext3_can_extents_be_merged(struct inode *inode, struct ext3_extent *ex1, struct ext3_extent *ex2) { - /* FIXME: 48bit support */ if (le32_to_cpu(ex1->ee_block) + le16_to_cpu(ex1->ee_len) != le32_to_cpu(ex2->ee_block)) return 0; @@ -1040,8 +1058,7 @@ ext3_can_extents_be_merged(struct inode return 0; #endif - if (le32_to_cpu(ex1->ee_start) + le16_to_cpu(ex1->ee_len) - == le32_to_cpu(ex2->ee_start)) + if (ext_pblock(ex1) + le16_to_cpu(ex1->ee_len) == ext_pblock(ex2)) return 1; return 0; } @@ -1068,11 +1085,10 @@ int ext3_ext_insert_extent(handle_t *han /* try to insert block into found extent and return */ if (ex && ext3_can_extents_be_merged(inode, ex, newext)) { - ext_debug("append %d block to %d:%d (from %d)\n", + ext_debug("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), - le32_to_cpu(ex->ee_start)); + le16_to_cpu(ex->ee_len), ext_pblock(ex)); if ((err = ext3_ext_get_access(handle, inode, path + depth))) return err; ex->ee_len = cpu_to_le16(le16_to_cpu(ex->ee_len) @@ -1128,9 +1144,9 @@ has_space: if (!nearex) { /* there is no extent in this leaf, create first one */ - ext_debug("first extent in the leaf: %d:%d:%d\n", + ext_debug("first extent in the leaf: %d:%lld:%d\n", le32_to_cpu(newext->ee_block), - le32_to_cpu(newext->ee_start), + ext_pblock(newext), le16_to_cpu(newext->ee_len)); path[depth].p_ext = EXT_FIRST_EXTENT(eh); } else if (le32_to_cpu(newext->ee_block) @@ -1140,10 +1156,10 @@ has_space: len = EXT_MAX_EXTENT(eh) - nearex; len = (len - 1) * sizeof(struct ext3_extent); len = len < 0 ? 0 : len; - ext_debug("insert %d:%d:%d after: nearest 0x%p, " + ext_debug("insert %d:%lld:%d after: nearest 0x%p, " "move %d from 0x%p to 0x%p\n", le32_to_cpu(newext->ee_block), - le32_to_cpu(newext->ee_start), + ext_pblock(newext), le16_to_cpu(newext->ee_len), nearex, len, nearex + 1, nearex + 2); memmove(nearex + 2, nearex + 1, len); @@ -1153,10 +1169,10 @@ has_space: BUG_ON(newext->ee_block == nearex->ee_block); len = (EXT_MAX_EXTENT(eh) - nearex) * sizeof(struct ext3_extent); len = len < 0 ? 0 : len; - ext_debug("insert %d:%d:%d before: nearest 0x%p, " + ext_debug("insert %d:%lld:%d before: nearest 0x%p, " "move %d from 0x%p to 0x%p\n", le32_to_cpu(newext->ee_block), - le32_to_cpu(newext->ee_start), + ext_pblock(newext), le16_to_cpu(newext->ee_len), nearex, len, nearex + 1, nearex + 2); memmove(nearex + 1, nearex, len); @@ -1167,9 +1183,8 @@ has_space: nearex = path[depth].p_ext; nearex->ee_block = newext->ee_block; nearex->ee_start = newext->ee_start; + nearex->ee_start_hi = newext->ee_start_hi; nearex->ee_len = newext->ee_len; - /* FIXME: support for large fs */ - nearex->ee_start_hi = 0; merge: /* try to merge extents to the right */ @@ -1278,7 +1293,7 @@ int ext3_ext_walk_space(struct inode *in } else { 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_start = ext_pblock(ex); cbex.ec_type = EXT3_EXT_CACHE_EXTENT; } @@ -1387,7 +1402,7 @@ ext3_ext_in_cache(struct inode *inode, u 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_start = cpu_to_le32(cex->ec_start); + ext3_ext_store_pblock(ex, cex->ec_start); ex->ee_len = cpu_to_le16(cex->ec_len); ext_debug("%lu cached by %lu:%lu:%lu\n", (unsigned long) block, @@ -1508,7 +1523,7 @@ static int ext3_remove_blocks(handle_t * /* tail removal */ unsigned long num, start; 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; + start = ext_pblock(ex) + le16_to_cpu(ex->ee_len) - num; ext_debug("free last %lu blocks starting %lu\n", num, start); for (i = 0; i < num; i++) { bh = sb_find_get_block(inode->i_sb, start + i); @@ -1612,7 +1627,7 @@ ext3_ext_rm_leaf(handle_t *handle, struc if (num == 0) { /* this extent is removed entirely mark slot unused */ - ex->ee_start = 0; + ext3_ext_store_pblock(ex, 0); eh->eh_entries = cpu_to_le16(le16_to_cpu(eh->eh_entries)-1); } @@ -1623,8 +1638,8 @@ ext3_ext_rm_leaf(handle_t *handle, struc if (err) goto out; - ext_debug("new extent: %u:%u:%u\n", block, num, - le32_to_cpu(ex->ee_start)); + ext_debug("new extent: %u:%u:%llu\n", block, num, + ext_pblock(ex)); ex--; ex_ee_block = le32_to_cpu(ex->ee_block); ex_ee_len = le16_to_cpu(ex->ee_len); @@ -1857,7 +1872,7 @@ int ext3_ext_get_blocks(handle_t *handle /* block is already allocated */ newblock = iblock - le32_to_cpu(newex.ee_block) - + le32_to_cpu(newex.ee_start); + + ext_pblock(&newex); /* number of remain blocks in the extent */ allocated = le16_to_cpu(newex.ee_len) - (iblock - le32_to_cpu(newex.ee_block)); @@ -1886,7 +1901,7 @@ int ext3_ext_get_blocks(handle_t *handle 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 long ee_start = ext_pblock(ex); unsigned short ee_len = le16_to_cpu(ex->ee_len); /* if found exent covers block, simple return it */ if (iblock >= ee_block && iblock < ee_block + ee_len) { @@ -1922,7 +1937,7 @@ int ext3_ext_get_blocks(handle_t *handle /* try to insert new extent into found leaf and return */ newex.ee_block = cpu_to_le32(iblock); - newex.ee_start = cpu_to_le32(newblock); + ext3_ext_store_pblock(&newex, newblock); newex.ee_len = cpu_to_le16(allocated); err = ext3_ext_insert_extent(handle, inode, path, &newex); if (err) @@ -1932,7 +1947,7 @@ int ext3_ext_get_blocks(handle_t *handle EXT3_I(inode)->i_disksize = inode->i_size; /* previous routine could use block we allocated */ - newblock = le32_to_cpu(newex.ee_start); + newblock = ext_pblock(&newex); __set_bit(BH_New, &bh_result->b_state); ext3_ext_put_in_cache(inode, iblock, allocated, newblock, diff -puN include/linux/ext3_fs_i.h~48bit-extents include/linux/ext3_fs_i.h --- linux-2.6.16/include/linux/ext3_fs_i.h~48bit-extents 2006-05-23 17:11:30.000000000 -0700 +++ linux-2.6.16-cmm/include/linux/ext3_fs_i.h 2006-05-23 17:23:39.000000000 -0700 @@ -68,7 +68,7 @@ struct ext3_block_alloc_info { * storage for cached extent */ struct ext3_ext_cache { - __u32 ec_start; + sector_t ec_start; __u32 ec_block; __u32 ec_len; /* must be 32bit to return holes */ __u32 ec_type; _