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:
Vladimir Sementsov-Ogievskiy
2019-06-06 18:41:31 +03:00
committed by Kevin Wolf
parent 68d00e4293
commit 8164102ffe
3 changed files with 31 additions and 9 deletions

View File

@@ -140,22 +140,21 @@ void override_max_devs(BlockInterfaceType type, int max_devs)
void blockdev_mark_auto_del(BlockBackend *blk)
{
DriveInfo *dinfo = blk_legacy_dinfo(blk);
BlockDriverState *bs = blk_bs(blk);
AioContext *aio_context;
BlockJob *job;
if (!dinfo) {
return;
}
if (bs) {
aio_context = bdrv_get_aio_context(bs);
aio_context_acquire(aio_context);
for (job = block_job_next(NULL); job; job = block_job_next(job)) {
if (block_job_has_bdrv(job, blk_bs(blk))) {
AioContext *aio_context = job->job.aio_context;
aio_context_acquire(aio_context);
if (bs->job) {
job_cancel(&bs->job->job, false);
job_cancel(&job->job, false);
aio_context_release(aio_context);
}
aio_context_release(aio_context);
}
dinfo->auto_del = 1;