]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - fs/ext4/extents.c
Merge branch 'sg' of git://git.kernel.dk/linux-2.6-block
[linux-2.6-omap-h63xx.git] / fs / ext4 / extents.c
index 96264b2ef0a386208b69935013f2b22eac9d7c68..85287742f2ae487562be3a8ac39e40774a5de9d3 100644 (file)
@@ -33,7 +33,7 @@
 #include <linux/fs.h>
 #include <linux/time.h>
 #include <linux/ext4_jbd2.h>
-#include <linux/jbd.h>
+#include <linux/jbd2.h>
 #include <linux/highuid.h>
 #include <linux/pagemap.h>
 #include <linux/quotaops.h>
@@ -52,7 +52,7 @@ static ext4_fsblk_t ext_pblock(struct ext4_extent *ex)
 {
        ext4_fsblk_t block;
 
-       block = le32_to_cpu(ex->ee_start);
+       block = le32_to_cpu(ex->ee_start_lo);
        block |= ((ext4_fsblk_t) le16_to_cpu(ex->ee_start_hi) << 31) << 1;
        return block;
 }
@@ -65,7 +65,7 @@ static ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix)
 {
        ext4_fsblk_t block;
 
-       block = le32_to_cpu(ix->ei_leaf);
+       block = le32_to_cpu(ix->ei_leaf_lo);
        block |= ((ext4_fsblk_t) le16_to_cpu(ix->ei_leaf_hi) << 31) << 1;
        return block;
 }
@@ -77,7 +77,7 @@ static ext4_fsblk_t idx_pblock(struct ext4_extent_idx *ix)
  */
 static void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)
 {
-       ex->ee_start = cpu_to_le32((unsigned long) (pb & 0xffffffff));
+       ex->ee_start_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff));
        ex->ee_start_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
 }
 
@@ -88,7 +88,7 @@ static void ext4_ext_store_pblock(struct ext4_extent *ex, ext4_fsblk_t pb)
  */
 static void ext4_idx_store_pblock(struct ext4_extent_idx *ix, ext4_fsblk_t pb)
 {
-       ix->ei_leaf = cpu_to_le32((unsigned long) (pb & 0xffffffff));
+       ix->ei_leaf_lo = cpu_to_le32((unsigned long) (pb & 0xffffffff));
        ix->ei_leaf_hi = cpu_to_le16((unsigned long) ((pb >> 31) >> 1) & 0xffff);
 }
 
@@ -376,20 +376,21 @@ ext4_ext_binsearch_idx(struct inode *inode, struct ext4_ext_path *path, int bloc
        ext_debug("binsearch for %d(idx):  ", block);
 
        l = EXT_FIRST_INDEX(eh) + 1;
-       r = EXT_FIRST_INDEX(eh) + le16_to_cpu(eh->eh_entries) - 1;
+       r = EXT_LAST_INDEX(eh);
        while (l <= r) {
                m = l + (r - l) / 2;
                if (block < le32_to_cpu(m->ei_block))
                        r = m - 1;
                else
                        l = m + 1;
-               ext_debug("%p(%u):%p(%u):%p(%u) ", l, l->ei_block,
-                               m, m->ei_block, r, r->ei_block);
+               ext_debug("%p(%u):%p(%u):%p(%u) ", l, le32_to_cpu(l->ei_block),
+                               m, le32_to_cpu(m->ei_block),
+                               r, le32_to_cpu(r->ei_block));
        }
 
        path->p_idx = l - 1;
        ext_debug("  -> %d->%lld ", le32_to_cpu(path->p_idx->ei_block),
-                 idx_block(path->p_idx));
+                 idx_pblock(path->p_idx));
 
 #ifdef CHECK_BINSEARCH
        {
@@ -440,7 +441,7 @@ ext4_ext_binsearch(struct inode *inode, struct ext4_ext_path *path, int block)
        ext_debug("binsearch for %d:  ", block);
 
        l = EXT_FIRST_EXTENT(eh) + 1;
-       r = EXT_FIRST_EXTENT(eh) + le16_to_cpu(eh->eh_entries) - 1;
+       r = EXT_LAST_EXTENT(eh);
 
        while (l <= r) {
                m = l + (r - l) / 2;
@@ -448,8 +449,9 @@ ext4_ext_binsearch(struct inode *inode, struct ext4_ext_path *path, int block)
                        r = m - 1;
                else
                        l = m + 1;
-               ext_debug("%p(%u):%p(%u):%p(%u) ", l, l->ee_block,
-                               m, m->ee_block, r, r->ee_block);
+               ext_debug("%p(%u):%p(%u):%p(%u) ", l, le32_to_cpu(l->ee_block),
+                               m, le32_to_cpu(m->ee_block),
+                               r, le32_to_cpu(r->ee_block));
        }
 
        path->p_ext = l - 1;
@@ -582,7 +584,7 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
                if (curp->p_idx != EXT_LAST_INDEX(curp->p_hdr)) {
                        len = (len - 1) * sizeof(struct ext4_extent_idx);
                        len = len < 0 ? 0 : len;
-                       ext_debug("insert new index %d after: %d. "
+                       ext_debug("insert new index %d after: %llu. "
                                        "move %d from 0x%p to 0x%p\n",
                                        logical, ptr, len,
                                        (curp->p_idx + 1), (curp->p_idx + 2));
@@ -593,7 +595,7 @@ static int ext4_ext_insert_index(handle_t *handle, struct inode *inode,
                /* insert before */
                len = len * sizeof(struct ext4_extent_idx);
                len = len < 0 ? 0 : len;
-               ext_debug("insert new index %d before: %d. "
+               ext_debug("insert new index %d before: %llu. "
                                "move %d from 0x%p to 0x%p\n",
                                logical, ptr, len,
                                curp->p_idx, (curp->p_idx + 1));
@@ -793,7 +795,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode,
                BUG_ON(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("%d: move %d:%d in new index %llu\n", i,
+                       ext_debug("%d: move %d:%llu in new index %llu\n", i,
                                        le32_to_cpu(path[i].p_idx->ei_block),
                                        idx_pblock(path[i].p_idx),
                                        newblock);
@@ -922,8 +924,13 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode,
        curp->p_hdr->eh_max = cpu_to_le16(ext4_ext_space_root_idx(inode));
        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;
+
+       if (path[0].p_hdr->eh_depth)
+               curp->p_idx->ei_block =
+                       EXT_FIRST_INDEX(path[0].p_hdr)->ei_block;
+       else
+               curp->p_idx->ei_block =
+                       EXT_FIRST_EXTENT(path[0].p_hdr)->ee_block;
        ext4_idx_store_pblock(curp->p_idx, newblock);
 
        neh = ext_inode_hdr(inode);
@@ -1402,8 +1409,7 @@ has_space:
        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;
-       nearex->ee_start_hi = newext->ee_start_hi;
+       ext4_ext_store_pblock(nearex, ext_pblock(newext));
        nearex->ee_len = newext->ee_len;
 
 merge:
@@ -1537,7 +1543,7 @@ int ext4_ext_walk_space(struct inode *inode, unsigned long block,
 
 static void
 ext4_ext_put_in_cache(struct inode *inode, __u32 block,
-                       __u32 len, __u32 start, int type)
+                       __u32 len, ext4_fsblk_t start, int type)
 {
        struct ext4_ext_cache *cex;
        BUG_ON(len == 0);
@@ -2170,7 +2176,6 @@ int ext4_ext_convert_to_initialized(handle_t *handle, struct inode *inode,
        }
        /* ex2: iblock to iblock + maxblocks-1 : initialised */
        ex2->ee_block = cpu_to_le32(iblock);
-       ex2->ee_start = cpu_to_le32(newblock);
        ext4_ext_store_pblock(ex2, newblock);
        ex2->ee_len = cpu_to_le16(allocated);
        if (ex2 != ex)