[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/3] blockjob: Don't sleep meaninglessly short
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [PATCH 1/3] blockjob: Don't sleep meaninglessly short |
Date: |
Fri, 3 Apr 2015 18:39:00 +0800 |
A timer that will immediately wake the job up spoils the point to call
block_job_sleep_ns in the first place - bdrv_drain_all has to return.
Let's sleep longer to let aio_poll return, before the job resumes and
submitts more IO requests.
Signed-off-by: Fam Zheng <address@hidden>
---
blockjob.c | 3 ++-
include/block/blockjob.h | 6 +++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/blockjob.c b/blockjob.c
index ba2255d..f04a16c 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -232,7 +232,8 @@ void block_job_sleep_ns(BlockJob *job, QEMUClockType type,
int64_t ns)
if (block_job_is_paused(job)) {
qemu_coroutine_yield();
} else {
- co_aio_sleep_ns(bdrv_get_aio_context(job->bs), type, ns);
+ co_aio_sleep_ns(bdrv_get_aio_context(job->bs), type,
+ MAX(ns, BLOCK_JOB_SLEEP_MIN));
}
job->busy = true;
}
diff --git a/include/block/blockjob.h b/include/block/blockjob.h
index b6d4ebb..97835aa 100644
--- a/include/block/blockjob.h
+++ b/include/block/blockjob.h
@@ -140,11 +140,15 @@ void *block_job_create(const BlockJobDriver *driver,
BlockDriverState *bs,
int64_t speed, BlockCompletionFunc *cb,
void *opaque, Error **errp);
+#define BLOCK_JOB_SLEEP_MIN 100000LL
/**
* block_job_sleep_ns:
* @job: The job that calls the function.
* @clock: The clock to sleep on.
- * @ns: How many nanoseconds to stop for.
+ * @ns: How many nanoseconds to stop for. It would be meaningless if it is
+ * very short, because the timer to wake up the job could fire right very
+ * quickly even before anything else is done. Hence, a minimum,
+ * BLOCK_JOB_SLEEP_MIN, is defined.
*
* Put the job to sleep (assuming that it wasn't canceled) for @ns
* nanoseconds. Canceling the job will interrupt the wait immediately.
--
2.1.0