Skip to content

Commit

Permalink
job: move and update comments from blockjob.c
Browse files Browse the repository at this point in the history
This comment applies more on job, it was left in blockjob as in the past
the whole job logic was implemented there.

Note: at this stage, job_{lock/unlock} and job lock guard macros
are *nop*.

No functional change intended.

Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
Reviewed-by: Vladimir Sementsov-Ogievskiy <[email protected]>
Reviewed-by: Stefan Hajnoczi <[email protected]>
Message-Id: <[email protected]>
Reviewed-by: Kevin Wolf <[email protected]>
Signed-off-by: Kevin Wolf <[email protected]>
  • Loading branch information
esposem authored and kevmw committed Oct 7, 2022
1 parent afe1e8a commit bf61c58
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
20 changes: 0 additions & 20 deletions blockjob.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,6 @@
#include "qemu/main-loop.h"
#include "qemu/timer.h"

/*
* The block job API is composed of two categories of functions.
*
* The first includes functions used by the monitor. The monitor is
* peculiar in that it accesses the block job list with block_job_get, and
* therefore needs consistency across block_job_get and the actual operation
* (e.g. block_job_set_speed). The consistency is achieved with
* aio_context_acquire/release. These functions are declared in blockjob.h.
*
* The second includes functions used by the block job drivers and sometimes
* by the core block layer. These do not care about locking, because the
* whole coroutine runs under the AioContext lock, and are declared in
* blockjob_int.h.
*/

static bool is_block_job(Job *job)
{
return job_type(job) == JOB_TYPE_BACKUP ||
Expand Down Expand Up @@ -433,11 +418,6 @@ static void block_job_event_ready(Notifier *n, void *opaque)
}


/*
* API for block job drivers and the block layer. These functions are
* declared in blockjob_int.h.
*/

void *block_job_create(const char *job_id, const BlockJobDriver *driver,
JobTxn *txn, BlockDriverState *bs, uint64_t perm,
uint64_t shared_perm, int64_t speed, int flags,
Expand Down
16 changes: 16 additions & 0 deletions job.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,22 @@
#include "trace/trace-root.h"
#include "qapi/qapi-events-job.h"

/*
* The job API is composed of two categories of functions.
*
* The first includes functions used by the monitor. The monitor is
* peculiar in that it accesses the job list with job_get, and
* therefore needs consistency across job_get and the actual operation
* (e.g. job_user_cancel). To achieve this consistency, the caller
* calls job_lock/job_unlock itself around the whole operation.
*
*
* The second includes functions used by the job drivers and sometimes
* by the core block layer. These delegate the locking to the callee instead.
*
* TODO Actually make this true
*/

/*
* job_mutex protects the jobs list, but also makes the
* struct job fields thread-safe.
Expand Down

0 comments on commit bf61c58

Please sign in to comment.