[RFC PATCH 08/15] job.c: minor adjustments in preparation to job-driver

Emanuele Giuseppe Esposito posted 15 patches 4 years, 3 months ago
Maintainers: John Snow <jsnow@redhat.com>, Kevin Wolf <kwolf@redhat.com>, Xie Changlong <xiechanglong.d@gmail.com>, Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>, Fam Zheng <fam@euphon.net>, Markus Armbruster <armbru@redhat.com>, Wen Congyang <wencongyang2@huawei.com>, Stefan Hajnoczi <stefanha@redhat.com>, Hanna Reitz <hreitz@redhat.com>
There is a newer version of this series
[RFC PATCH 08/15] job.c: minor adjustments in preparation to job-driver
Posted by Emanuele Giuseppe Esposito 4 years, 3 months ago
job_event_* functions can be all static, as they are not used
outside job.c

Add also missing notifier initialization for the on_idle
list in job_create().

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
 job.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/job.c b/job.c
index db7ad79745..88d911f2d7 100644
--- a/job.c
+++ b/job.c
@@ -464,6 +464,7 @@ void *job_create(const char *job_id, const JobDriver *driver, JobTxn *txn,
     notifier_list_init(&job->on_finalize_completed);
     notifier_list_init(&job->on_pending);
     notifier_list_init(&job->on_ready);
+    notifier_list_init(&job->on_idle);
 
     job_state_transition(job, JOB_STATUS_CREATED);
     aio_timer_init(qemu_get_aio_context(), &job->sleep_timer,
@@ -527,12 +528,20 @@ void job_progress_increase_remaining(Job *job, uint64_t delta)
     progress_increase_remaining(&job->progress, delta);
 }
 
-void job_event_cancelled(Job *job)
+/**
+ * To be called when a cancelled job is finalised.
+ * Called with job_mutex held.
+ */
+static void job_event_cancelled(Job *job)
 {
     notifier_list_notify(&job->on_finalize_cancelled, job);
 }
 
-void job_event_completed(Job *job)
+/**
+ * To be called when a successfully completed job is finalised.
+ * Called with job_mutex held.
+ */
+static void job_event_completed(Job *job)
 {
     notifier_list_notify(&job->on_finalize_completed, job);
 }
-- 
2.27.0


Re: [RFC PATCH 08/15] job.c: minor adjustments in preparation to job-driver
Posted by Vladimir Sementsov-Ogievskiy 4 years, 3 months ago
29.10.2021 19:39, Emanuele Giuseppe Esposito wrote:
> job_event_* functions can be all static, as they are not used
> outside job.c
> 
> Add also missing notifier initialization for the on_idle
> list in job_create().
> 
> Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
> ---
>   job.c | 13 +++++++++++--
>   1 file changed, 11 insertions(+), 2 deletions(-)
> 
> diff --git a/job.c b/job.c
> index db7ad79745..88d911f2d7 100644
> --- a/job.c
> +++ b/job.c
> @@ -464,6 +464,7 @@ void *job_create(const char *job_id, const JobDriver *driver, JobTxn *txn,
>       notifier_list_init(&job->on_finalize_completed);
>       notifier_list_init(&job->on_pending);
>       notifier_list_init(&job->on_ready);
> +    notifier_list_init(&job->on_idle);

Is that a bug fix? I think it worth small separate patch.

>   
>       job_state_transition(job, JOB_STATUS_CREATED);
>       aio_timer_init(qemu_get_aio_context(), &job->sleep_timer,
> @@ -527,12 +528,20 @@ void job_progress_increase_remaining(Job *job, uint64_t delta)
>       progress_increase_remaining(&job->progress, delta);
>   }
>   
> -void job_event_cancelled(Job *job)
> +/**
> + * To be called when a cancelled job is finalised.
> + * Called with job_mutex held.
> + */
> +static void job_event_cancelled(Job *job)
>   {
>       notifier_list_notify(&job->on_finalize_cancelled, job);
>   }
>   
> -void job_event_completed(Job *job)
> +/**
> + * To be called when a successfully completed job is finalised.
> + * Called with job_mutex held.
> + */
> +static void job_event_completed(Job *job)
>   {
>       notifier_list_notify(&job->on_finalize_completed, job);
>   }
> 


-- 
Best regards,
Vladimir