All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: John Snow <jsnow@redhat.com>, qemu-devel@nongnu.org
Cc: jcody@redhat.com
Subject: Re: [Qemu-devel] [PATCH 09/10] blockjob: reorganize block_job_completed_txn_abort
Date: Tue, 11 Apr 2017 12:11:08 +0800	[thread overview]
Message-ID: <7fdbf44b-24af-aa94-d1b7-c8d7e82af1c4@redhat.com> (raw)
In-Reply-To: <9a383fa0-040f-c90e-23ca-df32636786b3@redhat.com>



On 11/04/2017 03:17, John Snow wrote:
> One thing that I wonder about a little is the push-down of whether or
> not to reset iostatus falling to block_job_cancel_async; it seemed to me
> as if txn_abort really had the best knowledge as to whether or not we
> wanted to reset iostatus, but as it stands it doesn't really make a
> difference.

Actually, there was no iostatus reset in txn_abort; it was done in
block_job_cancel only.  But the BLOCK_JOB_CANCELLED event doesn't
publish the iostatus actually, so I could have also done the opposite:
remove the reset in block_job_cancel---it shouldn't make a difference in
theory.

On the other hand, I like respecting the invariant then the coroutine
always runs with BLOCK_DEVICE_IO_STATUS_OK iostatus, so I think that
it's right for cancel_async to reset the iostatus.  Speaking about
iostatus and invariants, probably we should also set "job->user_paused =
false" in block_job_cancel_async.

> ACK for now, because it's still not perfectly obvious to me how this
> will wind up helping, though I do believe you :)

It just helps me making sure that the locking is correct later.  Maybe
it will help you too!

Paolo

>>  static void block_job_completed_txn_success(BlockJob *job)
>> @@ -502,37 +577,6 @@ void block_job_cancel(BlockJob *job)
>>      }
>>  }
>>  
>> -static int block_job_finish_sync(BlockJob *job,
>> -                                 void (*finish)(BlockJob *, Error **errp),
>> -                                 Error **errp)
>> -{
>> -    Error *local_err = NULL;
>> -    int ret;
>> -
>> -    assert(blk_bs(job->blk)->job == job);
>> -
>> -    block_job_ref(job);
>> -
>> -    finish(job, &local_err);
>> -    if (local_err) {
>> -        error_propagate(errp, local_err);
>> -        block_job_unref(job);
>> -        return -EBUSY;
>> -    }
>> -    /* block_job_drain calls block_job_enter, and it should be enough to
>> -     * induce progress until the job completes or moves to the main thread.
>> -    */
>> -    while (!job->deferred_to_main_loop && !job->completed) {
>> -        block_job_drain(job);
>> -    }
>> -    while (!job->completed) {
>> -        aio_poll(qemu_get_aio_context(), true);
>> -    }
>> -    ret = (job->cancelled && job->ret == 0) ? -ECANCELED : job->ret;
>> -    block_job_unref(job);
>> -    return ret;
>> -}
>> -
>>  /* A wrapper around block_job_cancel() taking an Error ** parameter so it may be
>>   * used with block_job_finish_sync() without the need for (rather nasty)
>>   * function pointer casts there. */
>> @@ -856,36 +900,3 @@ void block_job_defer_to_main_loop(BlockJob *job,
>>      aio_bh_schedule_oneshot(qemu_get_aio_context(),
>>                              block_job_defer_to_main_loop_bh, data);
>>  }
> 
> And everything following is pure movement.
> 
>> -
>> -BlockJobTxn *block_job_txn_new(void)
>> -{
>> -    BlockJobTxn *txn = g_new0(BlockJobTxn, 1);
>> -    QLIST_INIT(&txn->jobs);
>> -    txn->refcnt = 1;
>> -    return txn;
>> -}
>> -
>> -static void block_job_txn_ref(BlockJobTxn *txn)
>> -{
>> -    txn->refcnt++;
>> -}
>> -
>> -void block_job_txn_unref(BlockJobTxn *txn)
>> -{
>> -    if (txn && --txn->refcnt == 0) {
>> -        g_free(txn);
>> -    }
>> -}
>> -
>> -void block_job_txn_add_job(BlockJobTxn *txn, BlockJob *job)
>> -{
>> -    if (!txn) {
>> -        return;
>> -    }
>> -
>> -    assert(!job->txn);
>> -    job->txn = txn;
>> -
>> -    QLIST_INSERT_HEAD(&txn->jobs, job, txn_list);
>> -    block_job_txn_ref(txn);
>> -}
>>

  reply	other threads:[~2017-04-11  8:57 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-23 17:39 [Qemu-devel] [PATCH for-2.10 00/10] Preparation for block job mutex Paolo Bonzini
2017-03-23 17:39 ` [Qemu-devel] [PATCH 01/10] blockjob: remove unnecessary check Paolo Bonzini
2017-04-07 22:30   ` John Snow
2017-04-07 22:54   ` Philippe Mathieu-Daudé
2017-04-07 23:16     ` John Snow
2017-04-10  9:27   ` Stefan Hajnoczi
2017-03-23 17:39 ` [Qemu-devel] [PATCH 02/10] blockjob: remove iostatus_reset callback Paolo Bonzini
2017-04-07 23:12   ` John Snow
2017-04-08  0:18     ` Philippe Mathieu-Daudé
2017-04-10  9:27   ` Stefan Hajnoczi
2017-03-23 17:39 ` [Qemu-devel] [PATCH 03/10] blockjob: introduce block_job_fail Paolo Bonzini
2017-04-07 23:24   ` John Snow
2017-04-10  9:22   ` Stefan Hajnoczi
2017-04-11  4:00     ` Paolo Bonzini
2017-03-23 17:39 ` [Qemu-devel] [PATCH 04/10] blockjob: introduce block_job_pause/resume_all Paolo Bonzini
2017-04-07 23:37   ` John Snow
2017-04-10  9:26   ` Stefan Hajnoczi
2017-03-23 17:39 ` [Qemu-devel] [PATCH 05/10] blockjob: separate monitor and blockjob APIs Paolo Bonzini
2017-04-08  0:03   ` John Snow
2017-04-08  9:52     ` Paolo Bonzini
2017-04-10 16:05       ` John Snow
2017-04-11  4:57         ` Paolo Bonzini
2017-04-11 16:19           ` John Snow
2017-04-10  9:30   ` Stefan Hajnoczi
2017-03-23 17:39 ` [Qemu-devel] [PATCH 06/10] blockjob: move iostatus reset inside block_job_user_resume Paolo Bonzini
2017-04-08  0:28   ` John Snow
2017-04-10  9:33   ` Stefan Hajnoczi
2017-03-23 17:39 ` [Qemu-devel] [PATCH 07/10] blockjob: strengthen a bit test-blockjob-txn Paolo Bonzini
2017-04-08  0:37   ` John Snow
2017-04-10  9:35   ` Stefan Hajnoczi
2017-03-23 17:39 ` [Qemu-devel] [PATCH 08/10] blockjob: introduce block_job_cancel_async Paolo Bonzini
2017-04-08  1:13   ` John Snow
2017-04-08  9:54     ` Paolo Bonzini
2017-04-10  9:36   ` Stefan Hajnoczi
2017-03-23 17:39 ` [Qemu-devel] [PATCH 09/10] blockjob: reorganize block_job_completed_txn_abort Paolo Bonzini
2017-04-08  1:15   ` John Snow
2017-04-08 10:03     ` Paolo Bonzini
2017-04-10  9:44   ` Stefan Hajnoczi
2017-04-10 19:17   ` John Snow
2017-04-11  4:11     ` Paolo Bonzini [this message]
2017-03-23 17:39 ` [Qemu-devel] [PATCH 10/10] blockjob: use deferred_to_main_loop to indicate the coroutine has ended Paolo Bonzini
2017-04-08  1:32   ` John Snow
2017-04-08  9:56     ` Paolo Bonzini
2017-04-10  9:46   ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7fdbf44b-24af-aa94-d1b7-c8d7e82af1c4@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=jcody@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.