forked from Imagelibrary/rtems
dosfs: Use peek support
This speeds up reading fragmented files. Fix #3689
This commit is contained in:
@@ -200,6 +200,16 @@ _fat_block_read(
|
|||||||
return cmpltd;
|
return cmpltd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
fat_block_peek(
|
||||||
|
fat_fs_info_t *fs_info,
|
||||||
|
const uint32_t blk,
|
||||||
|
const uint32_t blk_cnt
|
||||||
|
)
|
||||||
|
{
|
||||||
|
rtems_bdbuf_peek(fs_info->vol.dd, blk, blk_cnt);
|
||||||
|
}
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
fat_block_write(
|
fat_block_write(
|
||||||
fat_fs_info_t *fs_info,
|
fat_fs_info_t *fs_info,
|
||||||
|
|||||||
@@ -499,6 +499,11 @@ _fat_block_read(fat_fs_info_t *fs_info,
|
|||||||
uint32_t count,
|
uint32_t count,
|
||||||
void *buff);
|
void *buff);
|
||||||
|
|
||||||
|
void
|
||||||
|
fat_block_peek(fat_fs_info_t *fs_info,
|
||||||
|
const uint32_t blk,
|
||||||
|
const uint32_t blk_cnt);
|
||||||
|
|
||||||
ssize_t
|
ssize_t
|
||||||
fat_cluster_write(fat_fs_info_t *fs_info,
|
fat_cluster_write(fat_fs_info_t *fs_info,
|
||||||
uint32_t start_cln,
|
uint32_t start_cln,
|
||||||
|
|||||||
@@ -301,8 +301,11 @@ fat_file_read(
|
|||||||
uint32_t ofs = 0;
|
uint32_t ofs = 0;
|
||||||
uint32_t save_ofs;
|
uint32_t save_ofs;
|
||||||
uint32_t sec = 0;
|
uint32_t sec = 0;
|
||||||
|
uint32_t sec_peek = 0;
|
||||||
uint32_t byte = 0;
|
uint32_t byte = 0;
|
||||||
uint32_t c = 0;
|
uint32_t c = 0;
|
||||||
|
uint32_t blk = 0;
|
||||||
|
uint32_t blk_cnt = 0;
|
||||||
|
|
||||||
/* it couldn't be removed - otherwise cache update will be broken */
|
/* it couldn't be removed - otherwise cache update will be broken */
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
@@ -345,19 +348,27 @@ fat_file_read(
|
|||||||
c = MIN(count, (fs_info->vol.bpc - ofs));
|
c = MIN(count, (fs_info->vol.bpc - ofs));
|
||||||
|
|
||||||
sec = fat_cluster_num_to_sector_num(fs_info, cur_cln);
|
sec = fat_cluster_num_to_sector_num(fs_info, cur_cln);
|
||||||
|
|
||||||
|
save_cln = cur_cln;
|
||||||
|
rc = fat_get_fat_cluster(fs_info, cur_cln, &cur_cln);
|
||||||
|
if ( rc != RC_OK )
|
||||||
|
return rc;
|
||||||
|
|
||||||
|
sec_peek = fat_cluster_num_to_sector_num(fs_info, cur_cln);
|
||||||
|
blk = fat_sector_num_to_block_num (fs_info, sec_peek);
|
||||||
|
blk_cnt = fs_info->vol.bpc >> fs_info->vol.bytes_per_block_log2;
|
||||||
|
if (blk_cnt == 0)
|
||||||
|
blk_cnt = 1;
|
||||||
|
fat_block_peek(fs_info, blk, blk_cnt);
|
||||||
|
|
||||||
sec += (ofs >> fs_info->vol.sec_log2);
|
sec += (ofs >> fs_info->vol.sec_log2);
|
||||||
byte = ofs & (fs_info->vol.bps - 1);
|
byte = ofs & (fs_info->vol.bps - 1);
|
||||||
|
|
||||||
ret = _fat_block_read(fs_info, sec, byte, c, buf + cmpltd);
|
ret = _fat_block_read(fs_info, sec, byte, c, buf + cmpltd);
|
||||||
if ( ret < 0 )
|
if ( ret < 0 )
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
count -= c;
|
count -= c;
|
||||||
cmpltd += c;
|
cmpltd += c;
|
||||||
save_cln = cur_cln;
|
|
||||||
rc = fat_get_fat_cluster(fs_info, cur_cln, &cur_cln);
|
|
||||||
if ( rc != RC_OK )
|
|
||||||
return rc;
|
|
||||||
|
|
||||||
ofs = 0;
|
ofs = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user