Skip to contentSkip to conversation

block: for jobs, do not clear user_paused until after the resume

PATCH Superseded Jeff Cody 3 participants 5 messages Aug 15, 2018

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jeff Cody

author
#0 lore raw

PATCH 1/1 block: for jobs, do not clear user_paused until after the resume

The function job_cancel_async() will always cause an assert for blockjob user resume. We set job->user_paused to false, and then call job->driver->user_resume(). In the case of blockjobs, this is the block_job_user_resume() function.

In that function, we assert that job.user_paused is set to true. Unfortunately, right before calling this function, it has explicitly been set to false.

The fix is pretty simple: set job->user_paused to false only after the job user_resume() function has been called.

---
 job.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
job.c +1 -1
index fa671b431a..e36ebaafd8 100644
@@ -732,10 +732,10 @@ static void job_cancel_async(Job *job, bool force)
 {
     if (job->user_paused) {
         /* Do not call job_enter here, the caller will handle it.  */
-        job->user_paused = false;
         if (job->driver->user_resume) {
             job->driver->user_resume(job);
         }
+        job->user_paused = false;
         assert(job->pause_count > 0);
         job->pause_count--;
     }
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 24 lines · Jeff Cody

The function job_cancel_async() will always cause an assert for blockjob user resume. We set job->user_paused to false, and then call job->driver->user_resume(). In the case of blockjobs, this is the block_job_user_resume() function.

In that function, we assert that job.user_paused is set to true. Unfortunately, right before calling this function, it has explicitly been set to false.

The fix is pretty simple: set job->user_paused to false only after the job user_resume() function has been called.

---
 job.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
job.c +0 -0
index fa671b431a..e36ebaafd8 100644
@@ -732,10 +732,10 @@ static void job_cancel_async(Job *job, bool force)
 {

job.c static void job_cancel_async(Job *job, bool force) · line 741

Quoted 10 lines
job.c +1 -1
     if (job->user_paused) {
         /* Do not call job_enter here, the caller will handle it.  */
-        job->user_paused = false;
         if (job->driver->user_resume) {
             job->driver->user_resume(job);
         }
+        job->user_paused = false;
         assert(job->pause_count > 0);
         job->pause_count--;
     }

Looks right to me; are you going to make good on your threat of a v2 with a unit test?

author
#2 lore raw
Quoted 32 lines · John Snow
Quoted 29 lines · Jeff Cody

The function job_cancel_async() will always cause an assert for blockjob user resume. We set job->user_paused to false, and then call job->driver->user_resume(). In the case of blockjobs, this is the block_job_user_resume() function.

In that function, we assert that job.user_paused is set to true. Unfortunately, right before calling this function, it has explicitly been set to false.

The fix is pretty simple: set job->user_paused to false only after the job user_resume() function has been called.

---
 job.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
job.c +0 -1
index fa671b431a..e36ebaafd8 100644
@@ -732,10 +732,10 @@ static void job_cancel_async(Job *job, bool force)
 {
     if (job->user_paused) {
         /* Do not call job_enter here, the caller will handle it.  */
-        job->user_paused = false;
         if (job->driver->user_resume) {
             job->driver->user_resume(job);
         }
Quoted 9 lines

job.c static void job_cancel_async(Job *job, bool force) · line 741

Quoted 5 lines
job.c +1 -0
+        job->user_paused = false;
         assert(job->pause_count > 0);
         job->pause_count--;
     }

Looks right to me; are you going to make good on your threat of a v2 with a unit test?

Yep!

Quoted 1 line

Thanks

-Jeff

Reviewed-by on v1 1/1
#3 lore raw
In reply to Jeff Cody
Quoted 9 lines · Jeff Cody

The function job_cancel_async() will always cause an assert for blockjob user resume. We set job->user_paused to false, and then call job->driver->user_resume(). In the case of blockjobs, this is the block_job_user_resume() function.

In that function, we assert that job.user_paused is set to true. Unfortunately, right before calling this function, it has explicitly been set to false.

Quoted 8 lines

The fix is pretty simple: set job->user_paused to false only after the job user_resume() function has been called.

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

Does this need to CC qemu-stable?

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
author
#4 lore raw
Quoted 13 lines · Eric Blake
Quoted 12 lines · Jeff Cody

The function job_cancel_async() will always cause an assert for blockjob user resume. We set job->user_paused to false, and then call job->driver->user_resume(). In the case of blockjobs, this is the block_job_user_resume() function.

In that function, we assert that job.user_paused is set to true. Unfortunately, right before calling this function, it has explicitly been set to false.

The fix is pretty simple: set job->user_paused to false only after the job user_resume() function has been called.

Quoted 8 lines
Quoted 5 lines
---
 job.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Does this need to CC qemu-stable?

Good point, yes. I'm going to do a v2 with an iotest, and I'll CC qemu-stable on that one.

Quoted 2 lines

Thanks

-Jeff