Skip to contentSkip to conversation

blockjob: Remove the job from the list earlier in block_job_unref()

PATCH Applied Alberto Garcia 2 participants 3 messages Nov 28, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 blockjob: Remove the job from the list earlier in block_job_unref()

When destroying a block job in block_job_unref() we should remove it from the job list before calling block_job_remove_all_bdrv().

This is because removing the BDSs can trigger an aio_poll() and wake up other jobs that might attempt to use the block job list. If that happens the job we're currently destroying should not be in that list anymore.

---
 blockjob.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
blockjob.c +1 -1
index ff9a614531..2f0cc1528b 100644
@@ -152,6 +152,7 @@ void block_job_unref(BlockJob *job)
 {
     if (--job->refcnt == 0) {
         BlockDriverState *bs = blk_bs(job->blk);
+        QLIST_REMOVE(job, job_list);
         bs->job = NULL;
         block_job_remove_all_bdrv(job);
         blk_remove_aio_context_notifier(job->blk,
@@ -160,7 +161,6 @@ void block_job_unref(BlockJob *job)
         blk_unref(job->blk);
         error_free(job->blocker);
         g_free(job->id);
-        QLIST_REMOVE(job, job_list);
         g_free(job);
     }
 }
Signature · 1 line
2.11.0
#1 lore raw
Quoted 10 lines · Alberto Garcia

When destroying a block job in block_job_unref() we should remove it from the job list before calling block_job_remove_all_bdrv().

This is because removing the BDSs can trigger an aio_poll() and wake up other jobs that might attempt to use the block job list. If that happens the job we're currently destroying should not be in that list anymore.

---
 blockjob.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

I forgot this

Berto

Applied
#2 lore raw

Am 28.11.2017 um 16:53 hat Alberto Garcia geschrieben:

Quoted 12 lines · Alberto Garcia
Quoted 10 lines

When destroying a block job in block_job_unref() we should remove it from the job list before calling block_job_remove_all_bdrv().

This is because removing the BDSs can trigger an aio_poll() and wake up other jobs that might attempt to use the block job list. If that happens the job we're currently destroying should not be in that list anymore.

---
 blockjob.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 3 lines

I forgot this

Thanks, applied to the block branch.

Kevin