xdelta3-blkcache.h (xdelta3-3.0.10) | : | xdelta3-blkcache.h (xdelta3-3.0.11) | ||
---|---|---|---|---|
skipping to change at line 183 | skipping to change at line 183 | |||
xd3_mainerror (ret)); | xd3_mainerror (ret)); | |||
return ret; | return ret; | |||
} | } | |||
source->onblk = lru[0].size; /* xd3 sets onblk */ | source->onblk = lru[0].size; /* xd3 sets onblk */ | |||
/* If the file is smaller than a block, size is known. */ | /* If the file is smaller than a block, size is known. */ | |||
if (!sfile->size_known && source->onblk < blksize) | if (!sfile->size_known && source->onblk < blksize) | |||
{ | { | |||
source_size = source->onblk; | source_size = source->onblk; | |||
source->onlastblk = source_size; | ||||
sfile->size_known = 1; | sfile->size_known = 1; | |||
} | } | |||
/* If the size is not known or is greater than the buffer size, we | /* If the size is not known or is greater than the buffer size, we | |||
* split the buffer across MAX_LRU_SIZE blocks (already allocated in | * split the buffer across MAX_LRU_SIZE blocks (already allocated in | |||
* "lru"). */ | * "lru"). */ | |||
if (!sfile->size_known || source_size > option_srcwinsz) | if (!sfile->size_known || source_size > option_srcwinsz) | |||
{ | { | |||
/* Modify block 0, change blocksize. */ | /* Modify block 0, change blocksize. */ | |||
blksize = option_srcwinsz / MAX_LRU_SIZE; | blksize = option_srcwinsz / MAX_LRU_SIZE; | |||
source->blksize = blksize; | source->blksize = blksize; | |||
source->onblk = blksize; /* xd3 sets onblk */ | source->onblk = blksize; | |||
/* Note: source->max_winsize is unchanged. */ | source->onlastblk = blksize; | |||
source->max_blkno = MAX_LRU_SIZE - 1; | ||||
lru[0].size = blksize; | lru[0].size = blksize; | |||
lru_size = MAX_LRU_SIZE; | lru_size = MAX_LRU_SIZE; | |||
/* Setup rest of blocks. */ | /* Setup rest of blocks. */ | |||
for (i = 1; i < lru_size; i += 1) | for (i = 1; i < lru_size; i += 1) | |||
{ | { | |||
lru[i].blk = lru[0].blk + (blksize * i); | lru[i].blk = lru[0].blk + (blksize * i); | |||
lru[i].blkno = i; | lru[i].blkno = i; | |||
lru[i].size = blksize; | lru[i].size = blksize; | |||
main_blklru_list_push_back (& lru_list, & lru[i]); | main_blklru_list_push_back (& lru_list, & lru[i]); | |||
skipping to change at line 309 | skipping to change at line 312 | |||
{ | { | |||
/* Sequential search through LRU. */ | /* Sequential search through LRU. */ | |||
for (i = 0; i < lru_size; i += 1) | for (i = 0; i < lru_size; i += 1) | |||
{ | { | |||
blru = & lru[i]; | blru = & lru[i]; | |||
if (blru->blkno == blkno) | if (blru->blkno == blkno) | |||
{ | { | |||
main_blklru_list_remove (blru); | main_blklru_list_remove (blru); | |||
main_blklru_list_push_back (& lru_list, blru); | main_blklru_list_push_back (& lru_list, blru); | |||
(*blrup) = blru; | (*blrup) = blru; | |||
IF_DEBUG1 (DP(RINT "[getblk_lru] HIT blkno = %"Z"u lru_size=%d\n", | ||||
blkno, lru_size)); | ||||
return 0; | return 0; | |||
} | } | |||
} | } | |||
IF_DEBUG1 (DP(RINT "[getblk_lru] MISS blkno = %"Z"u lru_size=%d\n", | ||||
blkno, lru_size)); | ||||
} | } | |||
if (do_src_fifo) | if (do_src_fifo) | |||
{ | { | |||
int idx = blkno % lru_size; | int idx = blkno % lru_size; | |||
blru = & lru[idx]; | blru = & lru[idx]; | |||
} | } | |||
else | else | |||
{ | { | |||
XD3_ASSERT (! main_blklru_list_empty (& lru_list)); | XD3_ASSERT (! main_blklru_list_empty (& lru_list)); | |||
skipping to change at line 467 | skipping to change at line 474 | |||
static int | static int | |||
main_getblk_func (xd3_stream *stream, | main_getblk_func (xd3_stream *stream, | |||
xd3_source *source, | xd3_source *source, | |||
xoff_t blkno) | xoff_t blkno) | |||
{ | { | |||
int ret = 0; | int ret = 0; | |||
xoff_t pos = blkno * source->blksize; | xoff_t pos = blkno * source->blksize; | |||
main_file *sfile = (main_file*) source->ioh; | main_file *sfile = (main_file*) source->ioh; | |||
main_blklru *blru; | main_blklru *blru; | |||
int is_new; | int is_new; | |||
int did_seek = 0; | ||||
size_t nread = 0; | size_t nread = 0; | |||
if (allow_fake_source) | if (allow_fake_source) | |||
{ | { | |||
source->curblkno = blkno; | source->curblkno = blkno; | |||
source->onblk = 0; | source->onblk = 0; | |||
source->curblk = lru[0].blk; | source->curblk = lru[0].blk; | |||
lru[0].size = 0; | lru[0].size = 0; | |||
return 0; | return 0; | |||
} | } | |||
skipping to change at line 504 | skipping to change at line 510 | |||
if (pos != sfile->source_position) | if (pos != sfile->source_position) | |||
{ | { | |||
/* Only try to seek when the position is wrong. This means the | /* Only try to seek when the position is wrong. This means the | |||
* decoder will fail when the source buffer is too small, but | * decoder will fail when the source buffer is too small, but | |||
* only when the input is non-seekable. */ | * only when the input is non-seekable. */ | |||
if ((ret = main_read_seek_source (stream, source, blkno))) | if ((ret = main_read_seek_source (stream, source, blkno))) | |||
{ | { | |||
return ret; | return ret; | |||
} | } | |||
/* Indicates that another call to main_getblk_lru() may be | ||||
* needed */ | ||||
did_seek = 1; | ||||
} | } | |||
XD3_ASSERT (sfile->source_position == pos); | XD3_ASSERT (sfile->source_position == pos); | |||
if (did_seek && | ||||
(ret = main_getblk_lru (source, blkno, & blru, & is_new))) | ||||
{ | ||||
return ret; | ||||
} | ||||
if ((ret = main_read_primary_input (sfile, | if ((ret = main_read_primary_input (sfile, | |||
(uint8_t*) blru->blk, | (uint8_t*) blru->blk, | |||
source->blksize, | source->blksize, | |||
& nread))) | & nread))) | |||
{ | { | |||
return ret; | return ret; | |||
} | } | |||
/* Save the last block read, used to handle non-seekable files. */ | /* Save the last block read, used to handle non-seekable files. */ | |||
sfile->source_position = pos + nread; | sfile->source_position = pos + nread; | |||
End of changes. 7 change blocks. | ||||
13 lines changed or deleted | 9 lines changed or added |