qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH v2 02/14] job.h: categorize fields in struct Job


From: Emanuele Giuseppe Esposito
Subject: Re: [RFC PATCH v2 02/14] job.h: categorize fields in struct Job
Date: Tue, 21 Dec 2021 15:23:27 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0



On 16/12/2021 17:21, Stefan Hajnoczi wrote:
On Thu, Nov 04, 2021 at 10:53:22AM -0400, Emanuele Giuseppe Esposito wrote:
Categorize the fields in struct Job to understand which ones
need to be protected by the job mutex and which don't.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
  include/qemu/job.h | 57 +++++++++++++++++++++++++++-------------------
  1 file changed, 34 insertions(+), 23 deletions(-)

diff --git a/include/qemu/job.h b/include/qemu/job.h
index ccf7826426..f7036ac6b3 100644
--- a/include/qemu/job.h
+++ b/include/qemu/job.h
@@ -40,27 +40,52 @@ typedef struct JobTxn JobTxn;
   * Long-running operation.
   */
  typedef struct Job {
+
+    /* Fields set at initialization (job_create), and never modified */
+
      /** The ID of the job. May be NULL for internal jobs. */
      char *id;
- /** The type of this job. */
+    /**
+     * The type of this job.
+     * All callbacks are called with job_mutex *not* held.
+     */
      const JobDriver *driver;
- /** Reference count of the block job */
-    int refcnt;
-
-    /** Current state; See @JobStatus for details. */
-    JobStatus status;
-
      /** AioContext to run the job coroutine in */
      AioContext *aio_context;

"Fields set at initialization (job_create), and never modified" does not
apply here. blockjob.c:child_job_set_aio_ctx() changes it at runtime.


Right. aio_context can theoretically avoid also the job_mutex, if we make sure that all klass->set_aio_ctx() are under BQL (they are) and under drains (work in progress). For now I will protect it with job_lock().

Thank you,
Emanuele




reply via email to

[Prev in Thread] Current Thread [Next in Thread]