mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-10 12:51:34 +00:00
vfs/cbe_trust_anchor: sync hashfile-handle close
Closing the hashfile handle after a write operation wasn't synchronised to the actual end of the write operation. Issuing a write operation at the back end returns successfull as soon as the back end has acknowledged that it will execute the operation. However, the actual writing of the data might still be in progress at this point. But the plugin used to close the file handle and declare the operation finished at this point which led to warnings about acks on unknown file handles and leaking resources. Now, the plugin issues a sync operation directly after the write operation and waits for the sync to complete. This ensures that the plugin doesn't declare the operation finished too early. Ref #4032
This commit is contained in:
parent
1b4a80ffae
commit
df7de17435
@ -285,6 +285,7 @@ namespace Util {
|
||||
|
||||
bool completed() const { return _complete; }
|
||||
bool succeeded() const { return _success; }
|
||||
Operation op() const { return _op; }
|
||||
|
||||
void print(Genode::Output &out) const
|
||||
{
|
||||
|
@ -105,7 +105,7 @@ class Trust_anchor
|
||||
};
|
||||
Job _job { Job::NONE };
|
||||
|
||||
enum class Job_state { NONE, PENDING, IN_PROGRESS, COMPLETE };
|
||||
enum class Job_state { NONE, PENDING, IN_PROGRESS, FINAL_SYNC, COMPLETE };
|
||||
Job_state _job_state { Job_state::NONE };
|
||||
|
||||
bool _job_success { false };
|
||||
@ -351,7 +351,18 @@ class Trust_anchor
|
||||
}
|
||||
[[fallthrough]];
|
||||
case Job_state::IN_PROGRESS:
|
||||
if (!_write_hash_file_finished()) {
|
||||
if (!_write_op_on_hash_file_is_in_final_sync_step()) {
|
||||
break;
|
||||
}
|
||||
|
||||
_job_state = Job_state::FINAL_SYNC;
|
||||
_job_success = true;
|
||||
|
||||
progress |= true;
|
||||
[[fallthrough]];
|
||||
case Job_state::FINAL_SYNC:
|
||||
|
||||
if (!_final_sync_of_write_op_on_hash_file_finished()) {
|
||||
break;
|
||||
}
|
||||
|
||||
@ -610,9 +621,6 @@ class Trust_anchor
|
||||
if (!_hash_io_job.constructed()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// XXX trigger sync
|
||||
|
||||
bool const progress = _hash_io_job->execute();
|
||||
bool const completed = _hash_io_job->completed();
|
||||
if (completed) {
|
||||
@ -624,6 +632,12 @@ class Trust_anchor
|
||||
return progress && completed;
|
||||
}
|
||||
|
||||
void _start_sync_at_hash_io_job()
|
||||
{
|
||||
_hash_io_job.construct(*_hash_handle, Util::Io_job::Operation::SYNC,
|
||||
_hash_io_job_buffer, 0);
|
||||
}
|
||||
|
||||
void _close_hash_handle()
|
||||
{
|
||||
_vfs_env.root_dir().close(_hash_handle);
|
||||
@ -665,25 +679,34 @@ class Trust_anchor
|
||||
_hash_io_job_buffer, 0);
|
||||
|
||||
if (_hash_io_job->execute() && _hash_io_job->completed()) {
|
||||
_close_hash_handle();
|
||||
_start_sync_at_hash_io_job();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool _write_hash_file_finished()
|
||||
bool _write_op_on_hash_file_is_in_final_sync_step()
|
||||
{
|
||||
if (_hash_io_job->op() == Util::Io_job::Operation::SYNC) {
|
||||
return true;
|
||||
}
|
||||
bool const progress = _hash_io_job->execute();
|
||||
bool const completed = _hash_io_job->completed();
|
||||
if (completed) {
|
||||
_start_sync_at_hash_io_job();
|
||||
}
|
||||
return progress && completed;
|
||||
}
|
||||
|
||||
bool _final_sync_of_write_op_on_hash_file_finished()
|
||||
{
|
||||
if (!_hash_io_job.constructed()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// XXX trigger sync
|
||||
|
||||
bool const progress = _hash_io_job->execute();
|
||||
bool const completed = _hash_io_job->completed();
|
||||
if (completed) {
|
||||
_close_hash_handle();
|
||||
}
|
||||
|
||||
return progress && completed;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user