Merge pull request #358 from arutk/req_queue_fix

Do not reference req after adding to queue list
This commit is contained in:
Robert Baldyga 2020-03-27 15:04:51 +01:00 committed by GitHub
commit 53dc4020e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -565,6 +565,11 @@ void ocf_engine_push_req_back(struct ocf_request *req, bool allow_sync)
ENV_BUG_ON(!req->io_queue); ENV_BUG_ON(!req->io_queue);
q = req->io_queue; q = req->io_queue;
if (!req->info.internal) {
env_atomic_set(&cache->last_access_ms,
env_ticks_to_msecs(env_get_tick_count()));
}
env_spinlock_lock_irqsave(&q->io_list_lock, lock_flags); env_spinlock_lock_irqsave(&q->io_list_lock, lock_flags);
list_add_tail(&req->list, &q->io_list); list_add_tail(&req->list, &q->io_list);
@ -572,10 +577,9 @@ void ocf_engine_push_req_back(struct ocf_request *req, bool allow_sync)
env_spinlock_unlock_irqrestore(&q->io_list_lock, lock_flags); env_spinlock_unlock_irqrestore(&q->io_list_lock, lock_flags);
if (!req->info.internal) { /* NOTE: do not dereference @req past this line, it might
env_atomic_set(&cache->last_access_ms, * be picked up by concurrent io thread and deallocated
env_ticks_to_msecs(env_get_tick_count())); * at this point */
}
ocf_queue_kick(q, allow_sync); ocf_queue_kick(q, allow_sync);
} }
@ -591,6 +595,11 @@ void ocf_engine_push_req_front(struct ocf_request *req, bool allow_sync)
q = req->io_queue; q = req->io_queue;
if (!req->info.internal) {
env_atomic_set(&cache->last_access_ms,
env_ticks_to_msecs(env_get_tick_count()));
}
env_spinlock_lock_irqsave(&q->io_list_lock, lock_flags); env_spinlock_lock_irqsave(&q->io_list_lock, lock_flags);
list_add(&req->list, &q->io_list); list_add(&req->list, &q->io_list);
@ -598,10 +607,9 @@ void ocf_engine_push_req_front(struct ocf_request *req, bool allow_sync)
env_spinlock_unlock_irqrestore(&q->io_list_lock, lock_flags); env_spinlock_unlock_irqrestore(&q->io_list_lock, lock_flags);
if (!req->info.internal) { /* NOTE: do not dereference @req past this line, it might
env_atomic_set(&cache->last_access_ms, * be picked up by concurrent io thread and deallocated
env_ticks_to_msecs(env_get_tick_count())); * at this point */
}
ocf_queue_kick(q, allow_sync); ocf_queue_kick(q, allow_sync);
} }