mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-21 06:33:31 +00:00
blk_cache: don't try to sync 'zero' chunks
Invalid cache entries called 'zero chunks' shouldn't be synced. Fix #1249
This commit is contained in:
parent
41b62e50bb
commit
53a7b4ca66
@ -52,6 +52,7 @@ namespace Cache {
|
|||||||
offset_t const _base_offset;
|
offset_t const _base_offset;
|
||||||
size_t _num_entries; /* corresponds to last used entry */
|
size_t _num_entries; /* corresponds to last used entry */
|
||||||
Chunk_base *_parent;
|
Chunk_base *_parent;
|
||||||
|
bool const _zero; /* marks zero chunk */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test if specified range lies within the chunk
|
* Test if specified range lies within the chunk
|
||||||
@ -67,12 +68,14 @@ namespace Cache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Chunk_base(offset_t base_offset, Chunk_base *p)
|
Chunk_base(offset_t base_offset, Chunk_base *p)
|
||||||
: _base_offset(base_offset), _num_entries(0), _parent(p) { }
|
: _base_offset(base_offset), _num_entries(0), _parent(p),
|
||||||
|
_zero(false) { }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct zero chunk
|
* Construct zero chunk
|
||||||
*/
|
*/
|
||||||
Chunk_base() : _base_offset(0), _num_entries(0), _parent(0) { }
|
Chunk_base()
|
||||||
|
: _base_offset(0), _num_entries(0), _parent(0), _zero(true) { }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -86,6 +89,11 @@ namespace Cache {
|
|||||||
*/
|
*/
|
||||||
bool empty() const { return _num_entries == 0; }
|
bool empty() const { return _num_entries == 0; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if this is an unused 'zero' chunk
|
||||||
|
*/
|
||||||
|
bool zero() const { return _zero; }
|
||||||
|
|
||||||
virtual void free(size_t, offset_t) = 0;
|
virtual void free(size_t, offset_t) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -513,6 +521,7 @@ namespace Cache {
|
|||||||
* Synchronize chunk when dirty
|
* Synchronize chunk when dirty
|
||||||
*/
|
*/
|
||||||
void sync(size_t len, offset_t seek_offset) const {
|
void sync(size_t len, offset_t seek_offset) const {
|
||||||
|
if (zero()) return;
|
||||||
_range_op(*this, (char*)0, len, seek_offset, Sync_func()); }
|
_range_op(*this, (char*)0, len, seek_offset, Sync_func()); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user