mirror of
https://xff.cz/git/u-boot/
synced 2025-09-01 00:32:04 +02:00
fs: ext4: cache extent data
When a file contains extents, U-Boot currently reads extent-related data for each block in the file, even if that data is located in the same block each time. This significantly slows down loading of files that use extents. Implement a very dumb cache to prevent repeatedly reading the same block. Files with extents now load as fast as files without. Note: There are many cases where read_allocated_block() is called. This patch only addresses one of those places; all others still read redundant data in any case they did before. This is a minimal patch to fix the load command; other cases aren't fixed. Signed-off-by: Stephen Warren <swarren@nvidia.com>
This commit is contained in:
@@ -347,7 +347,7 @@ void recover_transaction(int prev_desc_logical_no)
|
||||
ext4fs_read_inode(ext4fs_root, EXT2_JOURNAL_INO,
|
||||
(struct ext2_inode *)&inode_journal);
|
||||
blknr = read_allocated_block((struct ext2_inode *)
|
||||
&inode_journal, i);
|
||||
&inode_journal, i, NULL);
|
||||
ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, 0, fs->blksz,
|
||||
temp_buff);
|
||||
p_jdb = (char *)temp_buff;
|
||||
@@ -372,7 +372,7 @@ void recover_transaction(int prev_desc_logical_no)
|
||||
be32_to_cpu(jdb->h_sequence)) == 0)
|
||||
continue;
|
||||
}
|
||||
blknr = read_allocated_block(&inode_journal, i);
|
||||
blknr = read_allocated_block(&inode_journal, i, NULL);
|
||||
ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, 0,
|
||||
fs->blksz, metadata_buff);
|
||||
put_ext4((uint64_t)((uint64_t)be32_to_cpu(tag->block) * (uint64_t)fs->blksz),
|
||||
@@ -419,7 +419,8 @@ int ext4fs_check_journal_state(int recovery_flag)
|
||||
}
|
||||
|
||||
ext4fs_read_inode(ext4fs_root, EXT2_JOURNAL_INO, &inode_journal);
|
||||
blknr = read_allocated_block(&inode_journal, EXT2_JOURNAL_SUPERBLOCK);
|
||||
blknr = read_allocated_block(&inode_journal, EXT2_JOURNAL_SUPERBLOCK,
|
||||
NULL);
|
||||
ext4fs_devread((lbaint_t)blknr * fs->sect_perblk, 0, fs->blksz,
|
||||
temp_buff);
|
||||
jsb = (struct journal_superblock_t *) temp_buff;
|
||||
@@ -443,7 +444,7 @@ int ext4fs_check_journal_state(int recovery_flag)
|
||||
|
||||
i = be32_to_cpu(jsb->s_first);
|
||||
while (1) {
|
||||
blknr = read_allocated_block(&inode_journal, i);
|
||||
blknr = read_allocated_block(&inode_journal, i, NULL);
|
||||
memset(temp_buff1, '\0', fs->blksz);
|
||||
ext4fs_devread((lbaint_t)blknr * fs->sect_perblk,
|
||||
0, fs->blksz, temp_buff1);
|
||||
@@ -537,7 +538,7 @@ end:
|
||||
ext4_read_superblock((char *)fs->sb);
|
||||
|
||||
blknr = read_allocated_block(&inode_journal,
|
||||
EXT2_JOURNAL_SUPERBLOCK);
|
||||
EXT2_JOURNAL_SUPERBLOCK, NULL);
|
||||
put_ext4((uint64_t) ((uint64_t)blknr * (uint64_t)fs->blksz),
|
||||
(struct journal_superblock_t *)temp_buff,
|
||||
(uint32_t) fs->blksz);
|
||||
@@ -566,7 +567,7 @@ static void update_descriptor_block(long int blknr)
|
||||
|
||||
ext4fs_read_inode(ext4fs_root, EXT2_JOURNAL_INO, &inode_journal);
|
||||
jsb_blknr = read_allocated_block(&inode_journal,
|
||||
EXT2_JOURNAL_SUPERBLOCK);
|
||||
EXT2_JOURNAL_SUPERBLOCK, NULL);
|
||||
ext4fs_devread((lbaint_t)jsb_blknr * fs->sect_perblk, 0, fs->blksz,
|
||||
temp_buff);
|
||||
jsb = (struct journal_superblock_t *) temp_buff;
|
||||
@@ -618,7 +619,7 @@ static void update_commit_block(long int blknr)
|
||||
ext4fs_read_inode(ext4fs_root, EXT2_JOURNAL_INO,
|
||||
&inode_journal);
|
||||
jsb_blknr = read_allocated_block(&inode_journal,
|
||||
EXT2_JOURNAL_SUPERBLOCK);
|
||||
EXT2_JOURNAL_SUPERBLOCK, NULL);
|
||||
ext4fs_devread((lbaint_t)jsb_blknr * fs->sect_perblk, 0, fs->blksz,
|
||||
temp_buff);
|
||||
jsb = (struct journal_superblock_t *) temp_buff;
|
||||
@@ -645,16 +646,17 @@ void ext4fs_update_journal(void)
|
||||
long int blknr;
|
||||
int i;
|
||||
ext4fs_read_inode(ext4fs_root, EXT2_JOURNAL_INO, &inode_journal);
|
||||
blknr = read_allocated_block(&inode_journal, jrnl_blk_idx++);
|
||||
blknr = read_allocated_block(&inode_journal, jrnl_blk_idx++, NULL);
|
||||
update_descriptor_block(blknr);
|
||||
for (i = 0; i < MAX_JOURNAL_ENTRIES; i++) {
|
||||
if (journal_ptr[i]->blknr == -1)
|
||||
break;
|
||||
blknr = read_allocated_block(&inode_journal, jrnl_blk_idx++);
|
||||
blknr = read_allocated_block(&inode_journal, jrnl_blk_idx++,
|
||||
NULL);
|
||||
put_ext4((uint64_t) ((uint64_t)blknr * (uint64_t)fs->blksz),
|
||||
journal_ptr[i]->buf, fs->blksz);
|
||||
}
|
||||
blknr = read_allocated_block(&inode_journal, jrnl_blk_idx++);
|
||||
blknr = read_allocated_block(&inode_journal, jrnl_blk_idx++, NULL);
|
||||
update_commit_block(blknr);
|
||||
printf("update journal finished\n");
|
||||
}
|
||||
|
Reference in New Issue
Block a user