Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ext4 fixes (invalid extent error on boot) #28

Open
wants to merge 3 commits into
base: odroidxu3-v2012.07
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions fs/ext4/ext4_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1415,30 +1415,31 @@ static struct ext4_extent_header *ext4fs_get_extent_block
struct ext4_extent_idx *index;
unsigned long long block;
struct ext_filesystem *fs = get_fs();
int blksz = EXT2_BLOCK_SIZE(data);
int i;

while (1) {
index = (struct ext4_extent_idx *)(ext_block + 1);

if (le32_to_cpu(ext_block->eh_magic) != EXT4_EXT_MAGIC)
if (le16_to_cpu(ext_block->eh_magic) != EXT4_EXT_MAGIC)
return 0;

if (ext_block->eh_depth == 0)
return ext_block;
i = -1;
do {
i++;
if (i >= le32_to_cpu(ext_block->eh_entries))
if (i >= le16_to_cpu(ext_block->eh_entries))
break;
} while (fileblock > le32_to_cpu(index[i].ei_block));
} while (fileblock >= le32_to_cpu(index[i].ei_block));

if (--i < 0)
return 0;

block = le32_to_cpu(index[i].ei_leaf_hi);
block = le16_to_cpu(index[i].ei_leaf_hi);
block = (block << 32) + le32_to_cpu(index[i].ei_leaf_lo);

if (ext4fs_devread(block << log2_blksz, 0, fs->blksz, buf))
if (ext4fs_devread(block << log2_blksz, 0, blksz, buf))
ext_block = (struct ext4_extent_header *)buf;
else
return 0;
Expand Down Expand Up @@ -1529,7 +1530,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock)

do {
i++;
if (i >= le32_to_cpu(ext_block->eh_entries))
if (i >= le16_to_cpu(ext_block->eh_entries))
break;
} while (fileblock >= le32_to_cpu(extent[i].ee_block));
if (--i >= 0) {
Expand All @@ -1539,7 +1540,7 @@ long int read_allocated_block(struct ext2_inode *inode, int fileblock)
return 0;
}

start = le32_to_cpu(extent[i].ee_start_hi);
start = le16_to_cpu(extent[i].ee_start_hi);
start = (start << 32) +
le32_to_cpu(extent[i].ee_start_lo);
free(buf);
Expand Down