[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-block] [PULL 05/14] block: drop bs->job
From: |
Kevin Wolf |
Subject: |
[Qemu-block] [PULL 05/14] block: drop bs->job |
Date: |
Tue, 18 Jun 2019 17:23:09 +0200 |
From: Vladimir Sementsov-Ogievskiy <address@hidden>
Drop remaining users of bs->job:
1. assertions actually duplicated by assert(!bs->refcnt)
2. trace-point seems not enough reason to change stream_start to return
BlockJob pointer
3. Restricting creation of two jobs based on same bs is bad idea, as
3.1 Some jobs creates filters to be their main node, so, this check
don't actually prevent creating second job on same real node (which
will create another filter node) (but I hope it is restricted by
other mechanisms)
3.2 Even without bs->job we have two systems of permissions:
op-blockers and BLK_PERM
3.3 We may want to run several jobs on one node one day
And finally, drop bs->job pointer itself. Hurrah!
Suggested-by: Kevin Wolf <address@hidden>
Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
include/block/block_int.h | 3 ---
block.c | 2 --
blockdev.c | 2 +-
blockjob.c | 8 --------
tests/test-blockjob.c | 5 +++--
block/trace-events | 2 +-
6 files changed, 5 insertions(+), 17 deletions(-)
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 8bb1cfb80a..a498c2670b 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -812,9 +812,6 @@ struct BlockDriverState {
/* operation blockers */
QLIST_HEAD(, BdrvOpBlocker) op_blockers[BLOCK_OP_TYPE_MAX];
- /* long-running background operation */
- BlockJob *job;
-
/* The node that this node inherited default options from (and a reopen on
* which can affect this node by changing these defaults). This is always a
* parent node of this node. */
diff --git a/block.c b/block.c
index e3e77feee0..ceb2ea23c5 100644
--- a/block.c
+++ b/block.c
@@ -3905,7 +3905,6 @@ static void bdrv_close(BlockDriverState *bs)
BdrvAioNotifier *ban, *ban_next;
BdrvChild *child, *next;
- assert(!bs->job);
assert(!bs->refcnt);
bdrv_drained_begin(bs); /* complete I/O */
@@ -4146,7 +4145,6 @@ out:
static void bdrv_delete(BlockDriverState *bs)
{
- assert(!bs->job);
assert(bdrv_op_blocker_is_empty(bs));
assert(!bs->refcnt);
diff --git a/blockdev.c b/blockdev.c
index a9dd73eafc..5d6a13dea9 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -3260,7 +3260,7 @@ void qmp_block_stream(bool has_job_id, const char
*job_id, const char *device,
goto out;
}
- trace_qmp_block_stream(bs, bs->job);
+ trace_qmp_block_stream(bs);
out:
aio_context_release(aio_context);
diff --git a/blockjob.c b/blockjob.c
index c3620ec544..458ae76f51 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -83,9 +83,7 @@ BlockJob *block_job_get(const char *id)
void block_job_free(Job *job)
{
BlockJob *bjob = container_of(job, BlockJob, job);
- BlockDriverState *bs = blk_bs(bjob->blk);
- bs->job = NULL;
block_job_remove_all_bdrv(bjob);
blk_unref(bjob->blk);
error_free(bjob->blocker);
@@ -402,11 +400,6 @@ void *block_job_create(const char *job_id, const
BlockJobDriver *driver,
BlockJob *job;
int ret;
- if (bs->job) {
- error_setg(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs));
- return NULL;
- }
-
if (job_id == NULL && !(flags & JOB_INTERNAL)) {
job_id = bdrv_get_device_name(bs);
}
@@ -449,7 +442,6 @@ void *block_job_create(const char *job_id, const
BlockJobDriver *driver,
error_setg(&job->blocker, "block device is in use by block job: %s",
job_type_str(&job->job));
block_job_add_bdrv(job, "main node", bs, 0, BLK_PERM_ALL, &error_abort);
- bs->job = job;
bdrv_op_unblock(bs, BLOCK_OP_TYPE_DATAPLANE, job->blocker);
diff --git a/tests/test-blockjob.c b/tests/test-blockjob.c
index 8c91980c70..b33f899873 100644
--- a/tests/test-blockjob.c
+++ b/tests/test-blockjob.c
@@ -122,8 +122,9 @@ static void test_job_ids(void)
/* This one is valid */
job[0] = do_test_id(blk[0], "id0", true);
- /* We cannot have two jobs in the same BDS */
- do_test_id(blk[0], "id1", false);
+ /* We can have two jobs in the same BDS */
+ job[1] = do_test_id(blk[0], "id1", true);
+ job_early_fail(&job[1]->job);
/* Duplicate job IDs are not allowed */
job[1] = do_test_id(blk[1], "id0", false);
diff --git a/block/trace-events b/block/trace-events
index f6e43ee023..9ccea755da 100644
--- a/block/trace-events
+++ b/block/trace-events
@@ -53,7 +53,7 @@ qmp_block_job_resume(void *job) "job %p"
qmp_block_job_complete(void *job) "job %p"
qmp_block_job_finalize(void *job) "job %p"
qmp_block_job_dismiss(void *job) "job %p"
-qmp_block_stream(void *bs, void *job) "bs %p job %p"
+qmp_block_stream(void *bs) "bs %p"
# file-posix.c
# file-win32.c
--
2.20.1
- [Qemu-block] [PULL 00/14] Block layer patches, Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 01/14] iotests: Hide timestamps for skipped tests, Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 03/14] block/block-backend: blk_iostatus_reset: drop usage of bs->job, Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 02/14] block/replication: drop usage of bs->job, Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 09/14] block/commit: Drop bdrv_child_try_set_perm(), Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 08/14] block/mirror: Fix child permissions, Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 05/14] block: drop bs->job,
Kevin Wolf <=
- [Qemu-block] [PULL 06/14] file-posix: Update open_flags in raw_set_perm(), Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 07/14] block: Add bdrv_child_refresh_perms(), Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 11/14] block: Add *tighten_restrictions to *check*_perm(), Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 04/14] blockdev: blockdev_mark_auto_del: drop usage of bs->job, Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 13/14] iotests: Test failure to loosen restrictions, Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 12/14] block: Ignore loosening perm restrictions failures, Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 10/14] block: Fix order in bdrv_replace_child(), Kevin Wolf, 2019/06/18
- [Qemu-block] [PULL 14/14] block/null: Expose read-zeroes option in QAPI schema, Kevin Wolf, 2019/06/18
- Re: [Qemu-block] [Qemu-devel] [PULL 00/14] Block layer patches, Peter Maydell, 2019/06/18