Пример #1
0
void disk_engine::start_io(aio_task_ptr& aio_tsk)
{
    auto aio = aio_tsk->aio();
    aio->engine = this;
    
    {
        auto_lock<::dsn::utils::ex_lock_nr> l(_lock);
        if (!_is_running)
        {
            aio_tsk->enqueue(ERR_SERVICE_NOT_FOUND, 0, _node);
            return;
        }
       
        _request_count++;
    }

    // TODO: profiling, throttling here 

    if (aio_tsk->spec().on_aio_call.execute(task::get_current_task(), aio_tsk.get(), true))
    {
        aio_tsk->add_ref();
        return _provider->aio(aio_tsk); 
    }
    else
    {
        aio_tsk->enqueue(ERR_FILE_OPERATION_FAILED, 0, _node);
    }
}
Пример #2
0
void disk_engine::complete_io(aio_task_ptr& aio, error_code err, uint32_t bytes, int delay_milliseconds)
{
    // TODO: failure injection, profiling, throttling

    if (err != ERR_OK)
    {
        dwarn(
                    "disk operation failure with code %s, err = 0x%x, aio task id = %llx",
                    aio->spec().name,
                    err.get(),
                    aio->id()
                    );
    }
    
    {
        auto_lock<::dsn::utils::ex_lock_nr> l(_lock);
        _request_count--;
    }
    
    aio->enqueue(err, bytes, _node);
    aio->release_ref();
}