From: Kevin Wolf <kwolf@redhat.com>
To: qemu-block@nongnu.org
Cc: kwolf@redhat.com, mreitz@redhat.com, berto@igalia.com,
jcody@redhat.com, jsnow@redhat.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH v2 01/14] block: keep a list of block jobs
Date: Tue, 24 May 2016 15:47:21 +0200 [thread overview]
Message-ID: <1464097654-12977-2-git-send-email-kwolf@redhat.com> (raw)
In-Reply-To: <1464097654-12977-1-git-send-email-kwolf@redhat.com>
From: Alberto Garcia <berto@igalia.com>
The current way to obtain the list of existing block jobs is to
iterate over all root nodes and check which ones own a job.
Since we want to be able to support block jobs in other nodes as well,
this patch keeps a list of jobs that is updated every time one is
created or destroyed.
Signed-off-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
---
blockjob.c | 13 +++++++++++++
include/block/blockjob.h | 14 ++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/blockjob.c b/blockjob.c
index 5b840a7..0f1bc77 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -50,6 +50,16 @@ struct BlockJobTxn {
int refcnt;
};
+static QLIST_HEAD(, BlockJob) block_jobs = QLIST_HEAD_INITIALIZER(block_jobs);
+
+BlockJob *block_job_next(BlockJob *job)
+{
+ if (!job) {
+ return QLIST_FIRST(&block_jobs);
+ }
+ return QLIST_NEXT(job, job_list);
+}
+
void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
int64_t speed, BlockCompletionFunc *cb,
void *opaque, Error **errp)
@@ -76,6 +86,8 @@ void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
job->refcnt = 1;
bs->job = job;
+ QLIST_INSERT_HEAD(&block_jobs, job, job_list);
+
/* Only set speed when necessary to avoid NotSupported error */
if (speed != 0) {
Error *local_err = NULL;
@@ -103,6 +115,7 @@ void block_job_unref(BlockJob *job)
bdrv_unref(job->bs);
error_free(job->blocker);
g_free(job->id);
+ QLIST_REMOVE(job, job_list);
g_free(job);
}
}
diff --git a/include/block/blockjob.h b/include/block/blockjob.h
index 073a433..30bb2c6 100644
--- a/include/block/blockjob.h
+++ b/include/block/blockjob.h
@@ -135,6 +135,9 @@ struct BlockJob {
*/
bool deferred_to_main_loop;
+ /** Element of the list of block jobs */
+ QLIST_ENTRY(BlockJob) job_list;
+
/** Status that is published by the query-block-jobs QMP API */
BlockDeviceIoStatus iostatus;
@@ -173,6 +176,17 @@ struct BlockJob {
};
/**
+ * block_job_next:
+ * @job: A block job, or %NULL.
+ *
+ * Get the next element from the list of block jobs after @job, or the
+ * first one if @job is %NULL.
+ *
+ * Returns the requested job, or %NULL if there are no more jobs left.
+ */
+BlockJob *block_job_next(BlockJob *job);
+
+/**
* block_job_create:
* @job_type: The class object for the newly-created job.
* @bs: The block
--
1.8.3.1
next prev parent reply other threads:[~2016-05-24 13:48 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-24 13:47 [Qemu-devel] [PATCH v2 00/14] block jobs: Convert I/O to BlockBackend Kevin Wolf
2016-05-24 13:47 ` Kevin Wolf [this message]
2016-05-24 13:47 ` [Qemu-devel] [PATCH v2 02/14] block: Cancel jobs first in bdrv_close_all() Kevin Wolf
2016-05-24 22:29 ` Eric Blake
2016-05-25 11:31 ` Alberto Garcia
2016-05-24 13:47 ` [Qemu-devel] [PATCH v2 03/14] block: Default to enabled write cache in blk_new() Kevin Wolf
2016-05-25 11:32 ` Alberto Garcia
2016-05-24 13:47 ` [Qemu-devel] [PATCH v2 04/14] block: Convert block job core to BlockBackend Kevin Wolf
2016-05-25 0:17 ` Eric Blake
2016-05-25 3:50 ` Changlong Xie
2016-05-25 11:40 ` Alberto Garcia
2016-05-24 13:47 ` [Qemu-devel] [PATCH v2 05/14] block: Make blk_co_preadv/pwritev() public Kevin Wolf
2016-05-25 0:24 ` Eric Blake
2016-05-25 9:07 ` Kevin Wolf
2016-05-24 13:47 ` [Qemu-devel] [PATCH v2 06/14] stream: Use BlockBackend for I/O Kevin Wolf
2016-05-25 0:27 ` Eric Blake
2016-05-25 11:59 ` Alberto Garcia
2016-05-24 13:47 ` [Qemu-devel] [PATCH v2 07/14] mirror: Allow target that already has a BlockBackend Kevin Wolf
2016-05-24 13:47 ` [Qemu-devel] [PATCH v2 08/14] mirror: Use BlockBackend for I/O Kevin Wolf
2016-05-25 1:48 ` Eric Blake
2016-05-25 3:51 ` Changlong Xie
2016-05-25 4:01 ` Eric Blake
2016-05-25 4:12 ` Changlong Xie
2016-05-24 13:47 ` [Qemu-devel] [PATCH v2 09/14] backup: Don't leak BackupBlockJob in error path Kevin Wolf
2016-05-24 13:47 ` [Qemu-devel] [PATCH v2 10/14] backup: Pack Notifier within BackupBlockJob Kevin Wolf
2016-05-24 13:47 ` [Qemu-devel] [PATCH v2 11/14] backup: Remove bs parameter from backup_do_cow() Kevin Wolf
2016-05-25 12:05 ` Alberto Garcia
2016-05-24 13:47 ` [Qemu-devel] [PATCH v2 12/14] backup: Use BlockBackend for I/O Kevin Wolf
2016-05-25 1:53 ` Eric Blake
2016-05-25 3:51 ` Changlong Xie
2016-05-24 13:47 ` [Qemu-devel] [PATCH v2 13/14] commit: " Kevin Wolf
2016-05-25 1:56 ` Eric Blake
2016-05-25 3:51 ` Changlong Xie
2016-05-25 4:04 ` Eric Blake
2016-05-24 13:47 ` [Qemu-devel] [PATCH v2 14/14] blockjob: Remove BlockJob.bs Kevin Wolf
2016-05-25 6:29 ` Changlong Xie
2016-05-25 11:10 ` Kevin Wolf
2016-05-25 12:05 ` Alberto Garcia
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=1464097654-12977-2-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=berto@igalia.com \
--cc=jcody@redhat.com \
--cc=jsnow@redhat.com \
--cc=mreitz@redhat.com \
--cc=qemu-block@nongnu.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).