Pull request
v2: * Drop block/nfs patch since it exposes an unfinished QAPI interface [kwolf] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAABAgAGBQJVm9RLAAoJEJykq7OBq3PIpzcH/3PPHjCcBIvokfdUK5v+ZKwl Ng450lHrJI0aIB9oFYlXeEbYQeE6DU7jfLAKGxnzC5YlIfqo73d+u8dEBFc13sCo td/unU57tujxYj4zhzd47D9CiAPvSLWEuET9EfBEQsd/2Aus8ncJTh+RJ7ff9J2B bTYrrcd+34gGzlUUHHyD25qXuMJP5KVu5JxlcFvgoOi0CHd1gcKe/xT4GV0bM2CZ Spk+Q2F01Y6ERRS54Tx8PO066Tlj/chlnl5dnplHo3PjPuTWHg4cP5cZCsevMwqf RjmlYzwUa/B0qI7GZYbF9L4e86Z1U77IGmVa45lZ2vXQNxjsAD5s9+Wb2DBWswI= =gaXG -----END PGP SIGNATURE----- Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging Pull request v2: * Drop block/nfs patch since it exposes an unfinished QAPI interface [kwolf] # gpg: Signature made Tue Jul 7 14:29:47 2015 BST using RSA key ID 81AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" * remotes/stefanha/tags/block-pull-request: blockjob: add block_job_release function block/raw-posix: Don't think /dev/fd/<NN> is a floppy drive. block: Use bdrv_drain to replace uncessary bdrv_drain_all block: Initialize local_err in bdrv_append_temp_snapshot block: update bdrv_drain_all()/bdrv_drain() comments qcow2: remove unnecessary check Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
commit
30c6672aa4
8
block.c
8
block.c
@ -1271,7 +1271,7 @@ int bdrv_append_temp_snapshot(BlockDriverState *bs, int flags, Error **errp)
|
||||
QemuOpts *opts = NULL;
|
||||
QDict *snapshot_options;
|
||||
BlockDriverState *bs_snapshot;
|
||||
Error *local_err;
|
||||
Error *local_err = NULL;
|
||||
int ret;
|
||||
|
||||
/* if snapshot, we create a temporary backing file and open it
|
||||
@ -1841,9 +1841,9 @@ void bdrv_close(BlockDriverState *bs)
|
||||
if (bs->job) {
|
||||
block_job_cancel_sync(bs->job);
|
||||
}
|
||||
bdrv_drain_all(); /* complete I/O */
|
||||
bdrv_drain(bs); /* complete I/O */
|
||||
bdrv_flush(bs);
|
||||
bdrv_drain_all(); /* in case flush left pending I/O */
|
||||
bdrv_drain(bs); /* in case flush left pending I/O */
|
||||
notifier_list_notify(&bs->close_notifiers, bs);
|
||||
|
||||
if (bs->drv) {
|
||||
@ -3906,7 +3906,7 @@ void bdrv_attach_aio_context(BlockDriverState *bs,
|
||||
|
||||
void bdrv_set_aio_context(BlockDriverState *bs, AioContext *new_context)
|
||||
{
|
||||
bdrv_drain_all(); /* ensure there are no in-flight requests */
|
||||
bdrv_drain(bs); /* ensure there are no in-flight requests */
|
||||
|
||||
bdrv_detach_aio_context(bs);
|
||||
|
||||
|
20
block/io.c
20
block/io.c
@ -236,12 +236,12 @@ static bool bdrv_requests_pending(BlockDriverState *bs)
|
||||
/*
|
||||
* Wait for pending requests to complete on a single BlockDriverState subtree
|
||||
*
|
||||
* See the warning in bdrv_drain_all(). This function can only be called if
|
||||
* you are sure nothing can generate I/O because you have op blockers
|
||||
* installed.
|
||||
*
|
||||
* Note that unlike bdrv_drain_all(), the caller must hold the BlockDriverState
|
||||
* AioContext.
|
||||
*
|
||||
* Only this BlockDriverState's AioContext is run, so in-flight requests must
|
||||
* not depend on events in other AioContexts. In that case, use
|
||||
* bdrv_drain_all() instead.
|
||||
*/
|
||||
void bdrv_drain(BlockDriverState *bs)
|
||||
{
|
||||
@ -260,12 +260,6 @@ void bdrv_drain(BlockDriverState *bs)
|
||||
*
|
||||
* This function does not flush data to disk, use bdrv_flush_all() for that
|
||||
* after calling this function.
|
||||
*
|
||||
* Note that completion of an asynchronous I/O operation can trigger any
|
||||
* number of other I/O operations on other devices---for example a coroutine
|
||||
* can be arbitrarily complex and a constant flow of I/O can come until the
|
||||
* coroutine is complete. Because of this, it is not possible to have a
|
||||
* function to drain a single device's I/O queue.
|
||||
*/
|
||||
void bdrv_drain_all(void)
|
||||
{
|
||||
@ -288,6 +282,12 @@ void bdrv_drain_all(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Note that completion of an asynchronous I/O operation can trigger any
|
||||
* number of other I/O operations on other devices---for example a
|
||||
* coroutine can submit an I/O request to another device in response to
|
||||
* request completion. Therefore we must keep looping until there was no
|
||||
* more activity rather than simply draining each device independently.
|
||||
*/
|
||||
while (busy) {
|
||||
busy = false;
|
||||
|
||||
|
@ -708,6 +708,8 @@ static void mirror_start_job(BlockDriverState *bs, BlockDriverState *target,
|
||||
|
||||
s->dirty_bitmap = bdrv_create_dirty_bitmap(bs, granularity, NULL, errp);
|
||||
if (!s->dirty_bitmap) {
|
||||
g_free(s->replaces);
|
||||
block_job_release(bs);
|
||||
return;
|
||||
}
|
||||
bdrv_set_enable_write_cache(s->target, true);
|
||||
|
@ -281,9 +281,6 @@ static int qcow2_cache_do_get(BlockDriverState *bs, Qcow2Cache *c,
|
||||
i = min_lru_index;
|
||||
trace_qcow2_cache_get_replace_entry(qemu_coroutine_self(),
|
||||
c == s->l2_table_cache, i);
|
||||
if (i < 0) {
|
||||
return i;
|
||||
}
|
||||
|
||||
ret = qcow2_cache_entry_flush(bs, c, i);
|
||||
if (ret < 0) {
|
||||
|
@ -2430,7 +2430,8 @@ static int floppy_probe_device(const char *filename)
|
||||
struct stat st;
|
||||
|
||||
if (strstart(filename, "/dev/fd", NULL) &&
|
||||
!strstart(filename, "/dev/fdset/", NULL)) {
|
||||
!strstart(filename, "/dev/fdset/", NULL) &&
|
||||
!strstart(filename, "/dev/fd/", NULL)) {
|
||||
prio = 50;
|
||||
}
|
||||
|
||||
|
@ -239,7 +239,7 @@ int bdrv_snapshot_delete(BlockDriverState *bs,
|
||||
}
|
||||
|
||||
/* drain all pending i/o before deleting snapshot */
|
||||
bdrv_drain_all();
|
||||
bdrv_drain(bs);
|
||||
|
||||
if (drv->bdrv_snapshot_delete) {
|
||||
return drv->bdrv_snapshot_delete(bs, snapshot_id, name, errp);
|
||||
|
20
blockjob.c
20
blockjob.c
@ -66,10 +66,7 @@ void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
|
||||
|
||||
block_job_set_speed(job, speed, &local_err);
|
||||
if (local_err) {
|
||||
bs->job = NULL;
|
||||
bdrv_op_unblock_all(bs, job->blocker);
|
||||
error_free(job->blocker);
|
||||
g_free(job);
|
||||
block_job_release(bs);
|
||||
error_propagate(errp, local_err);
|
||||
return NULL;
|
||||
}
|
||||
@ -77,16 +74,23 @@ void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
|
||||
return job;
|
||||
}
|
||||
|
||||
void block_job_release(BlockDriverState *bs)
|
||||
{
|
||||
BlockJob *job = bs->job;
|
||||
|
||||
bs->job = NULL;
|
||||
bdrv_op_unblock_all(bs, job->blocker);
|
||||
error_free(job->blocker);
|
||||
g_free(job);
|
||||
}
|
||||
|
||||
void block_job_completed(BlockJob *job, int ret)
|
||||
{
|
||||
BlockDriverState *bs = job->bs;
|
||||
|
||||
assert(bs->job == job);
|
||||
job->cb(job->opaque, ret);
|
||||
bs->job = NULL;
|
||||
bdrv_op_unblock_all(bs, job->blocker);
|
||||
error_free(job->blocker);
|
||||
g_free(job);
|
||||
block_job_release(bs);
|
||||
}
|
||||
|
||||
void block_job_set_speed(BlockJob *job, int64_t speed, Error **errp)
|
||||
|
@ -165,6 +165,14 @@ void block_job_sleep_ns(BlockJob *job, QEMUClockType type, int64_t ns);
|
||||
*/
|
||||
void block_job_yield(BlockJob *job);
|
||||
|
||||
/**
|
||||
* block_job_release:
|
||||
* @bs: The block device.
|
||||
*
|
||||
* Release job resources when an error occurred or job completed.
|
||||
*/
|
||||
void block_job_release(BlockDriverState *bs);
|
||||
|
||||
/**
|
||||
* block_job_completed:
|
||||
* @job: The job being completed.
|
||||
|
@ -457,7 +457,7 @@ static int mig_save_device_dirty(QEMUFile *f, BlkMigDevState *bmds,
|
||||
blk_mig_lock();
|
||||
if (bmds_aio_inflight(bmds, sector)) {
|
||||
blk_mig_unlock();
|
||||
bdrv_drain_all();
|
||||
bdrv_drain(bmds->bs);
|
||||
} else {
|
||||
blk_mig_unlock();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user