Received: from eggs.gnu.org ([2001:4830:134:3::10]:39480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCVJS-0001nN-0q for qemu-devel@nongnu.org; Mon, 13 Jun 2016 13:06:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCVJQ-000204-TJ for qemu-devel@nongnu.org; Mon, 13 Jun 2016 13:06:09 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55673) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCVJQ-0001zr-Nb for qemu-devel@nongnu.org; Mon, 13 Jun 2016 13:06:08 -0400 From: Stefan Hajnoczi Date: Mon, 13 Jun 2016 18:05:33 +0100 Message-Id: <1465837535-30067-14-git-send-email-stefanha@redhat.com> In-Reply-To: <1465837535-30067-1-git-send-email-stefanha@redhat.com> References: <1465837535-30067-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH v3 13/15] blockjob: add pause points List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , jjherne@linux.vnet.ibm.com, Fam Zheng , Paolo Bonzini , Jeff Cody , mreitz@redhat.com, Stefan Hajnoczi Block jobs are coroutines that usually perform I/O but sometimes also sleep or yield. Currently only sleeping or yielded block jobs can be paused. This means jobs that do not sleep or yield (using block_job_yield()) are unaffected by block_job_pause(). Add block_job_pause_point() so that block jobs can mark quiescent points that are suitable for pausing. This solves the problem that is can take a block job a long time to pause if it is performing a long series of I/O operations. Signed-off-by: Stefan Hajnoczi --- blockjob.c | 7 +++++++ include/block/blockjob.h | 12 ++++++++++++ 2 files changed, 19 insertions(+) diff --git a/blockjob.c b/blockjob.c index 463bccf..b810d73 100644 --- a/blockjob.c +++ b/blockjob.c @@ -247,6 +247,13 @@ void block_job_complete(BlockJob *job, Error **errp) job->driver->complete(job, errp); } +void block_job_pause_point(BlockJob *job) +{ + if (block_job_is_paused(job)) { + block_job_yield(job); + } +} + void block_job_pause(BlockJob *job) { job->pause_count++; diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 00ac418..f83a4f0 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -299,6 +299,18 @@ bool block_job_is_cancelled(BlockJob *job); BlockJobInfo *block_job_query(BlockJob *job); /** + * block_job_pause_point: + * @job: The job that is ready to pause. + * + * Pause now if block_job_pause() has been called. Block jobs that perform + * lots of I/O must call this between requests so that the job can be paused. + * + * There must be no I/O in flight when this function is called. There must be + * no I/O or event loop activity until after this function returns. + */ +void coroutine_fn block_job_pause_point(BlockJob *job); + +/** * block_job_pause: * @job: The job to be paused. * -- 2.5.5