diff options
-rw-r--r-- | fs/ext4/extents.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index 11ce15d91acc..750c46f7d893 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -376,7 +376,7 @@ ext4_ext_binsearch_idx(struct inode *inode, struct ext4_ext_path *path, int bloc | |||
376 | ext_debug("binsearch for %d(idx): ", block); | 376 | ext_debug("binsearch for %d(idx): ", block); |
377 | 377 | ||
378 | l = EXT_FIRST_INDEX(eh) + 1; | 378 | l = EXT_FIRST_INDEX(eh) + 1; |
379 | r = EXT_FIRST_INDEX(eh) + le16_to_cpu(eh->eh_entries) - 1; | 379 | r = EXT_LAST_INDEX(eh); |
380 | while (l <= r) { | 380 | while (l <= r) { |
381 | m = l + (r - l) / 2; | 381 | m = l + (r - l) / 2; |
382 | if (block < le32_to_cpu(m->ei_block)) | 382 | if (block < le32_to_cpu(m->ei_block)) |
@@ -441,7 +441,7 @@ ext4_ext_binsearch(struct inode *inode, struct ext4_ext_path *path, int block) | |||
441 | ext_debug("binsearch for %d: ", block); | 441 | ext_debug("binsearch for %d: ", block); |
442 | 442 | ||
443 | l = EXT_FIRST_EXTENT(eh) + 1; | 443 | l = EXT_FIRST_EXTENT(eh) + 1; |
444 | r = EXT_FIRST_EXTENT(eh) + le16_to_cpu(eh->eh_entries) - 1; | 444 | r = EXT_LAST_EXTENT(eh); |
445 | 445 | ||
446 | while (l <= r) { | 446 | while (l <= r) { |
447 | m = l + (r - l) / 2; | 447 | m = l + (r - l) / 2; |
@@ -924,8 +924,13 @@ static int ext4_ext_grow_indepth(handle_t *handle, struct inode *inode, | |||
924 | curp->p_hdr->eh_max = cpu_to_le16(ext4_ext_space_root_idx(inode)); | 924 | curp->p_hdr->eh_max = cpu_to_le16(ext4_ext_space_root_idx(inode)); |
925 | curp->p_hdr->eh_entries = cpu_to_le16(1); | 925 | curp->p_hdr->eh_entries = cpu_to_le16(1); |
926 | curp->p_idx = EXT_FIRST_INDEX(curp->p_hdr); | 926 | curp->p_idx = EXT_FIRST_INDEX(curp->p_hdr); |
927 | /* FIXME: it works, but actually path[0] can be index */ | 927 | |
928 | curp->p_idx->ei_block = EXT_FIRST_EXTENT(path[0].p_hdr)->ee_block; | 928 | if (path[0].p_hdr->eh_depth) |
929 | curp->p_idx->ei_block = | ||
930 | EXT_FIRST_INDEX(path[0].p_hdr)->ei_block; | ||
931 | else | ||
932 | curp->p_idx->ei_block = | ||
933 | EXT_FIRST_EXTENT(path[0].p_hdr)->ee_block; | ||
929 | ext4_idx_store_pblock(curp->p_idx, newblock); | 934 | ext4_idx_store_pblock(curp->p_idx, newblock); |
930 | 935 | ||
931 | neh = ext_inode_hdr(inode); | 936 | neh = ext_inode_hdr(inode); |