blockdev: blockdev_mark_auto_del: drop usage of bs->job
We are going to remove bs->job pointer. Drop it's usage in blockdev_mark_auto_del: instead of looking at bs->job let's check all jobs for references to bs. Suggested-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
68d00e4293
commit
8164102ffe
13
blockdev.c
13
blockdev.c
@ -140,23 +140,22 @@ void override_max_devs(BlockInterfaceType type, int max_devs)
|
|||||||
void blockdev_mark_auto_del(BlockBackend *blk)
|
void blockdev_mark_auto_del(BlockBackend *blk)
|
||||||
{
|
{
|
||||||
DriveInfo *dinfo = blk_legacy_dinfo(blk);
|
DriveInfo *dinfo = blk_legacy_dinfo(blk);
|
||||||
BlockDriverState *bs = blk_bs(blk);
|
BlockJob *job;
|
||||||
AioContext *aio_context;
|
|
||||||
|
|
||||||
if (!dinfo) {
|
if (!dinfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bs) {
|
for (job = block_job_next(NULL); job; job = block_job_next(job)) {
|
||||||
aio_context = bdrv_get_aio_context(bs);
|
if (block_job_has_bdrv(job, blk_bs(blk))) {
|
||||||
|
AioContext *aio_context = job->job.aio_context;
|
||||||
aio_context_acquire(aio_context);
|
aio_context_acquire(aio_context);
|
||||||
|
|
||||||
if (bs->job) {
|
job_cancel(&job->job, false);
|
||||||
job_cancel(&bs->job->job, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
aio_context_release(aio_context);
|
aio_context_release(aio_context);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dinfo->auto_del = 1;
|
dinfo->auto_del = 1;
|
||||||
}
|
}
|
||||||
|
14
blockjob.c
14
blockjob.c
@ -198,6 +198,20 @@ void block_job_remove_all_bdrv(BlockJob *job)
|
|||||||
job->nodes = NULL;
|
job->nodes = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool block_job_has_bdrv(BlockJob *job, BlockDriverState *bs)
|
||||||
|
{
|
||||||
|
GSList *el;
|
||||||
|
|
||||||
|
for (el = job->nodes; el; el = el->next) {
|
||||||
|
BdrvChild *c = el->data;
|
||||||
|
if (c->bs == bs) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
int block_job_add_bdrv(BlockJob *job, const char *name, BlockDriverState *bs,
|
int block_job_add_bdrv(BlockJob *job, const char *name, BlockDriverState *bs,
|
||||||
uint64_t perm, uint64_t shared_perm, Error **errp)
|
uint64_t perm, uint64_t shared_perm, Error **errp)
|
||||||
{
|
{
|
||||||
|
@ -121,6 +121,15 @@ int block_job_add_bdrv(BlockJob *job, const char *name, BlockDriverState *bs,
|
|||||||
*/
|
*/
|
||||||
void block_job_remove_all_bdrv(BlockJob *job);
|
void block_job_remove_all_bdrv(BlockJob *job);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* block_job_has_bdrv:
|
||||||
|
* @job: The block job
|
||||||
|
*
|
||||||
|
* Searches for @bs in the list of nodes that are involved in the
|
||||||
|
* job.
|
||||||
|
*/
|
||||||
|
bool block_job_has_bdrv(BlockJob *job, BlockDriverState *bs);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* block_job_set_speed:
|
* block_job_set_speed:
|
||||||
* @job: The job to set the speed for.
|
* @job: The job to set the speed for.
|
||||||
|
Loading…
Reference in New Issue
Block a user