From b76e4458b1eb3c32e9824fe6aa51f67d2b251748 Mon Sep 17 00:00:00 2001 From: Liang Li Date: Tue, 13 Mar 2018 08:12:16 -0400 Subject: block/mirror: change the semantic of 'force' of block-job-cancel When doing drive mirror to a low speed shared storage, if there was heavy BLK IO write workload in VM after the 'ready' event, drive mirror block job can't be canceled immediately, it would keep running until the heavy BLK IO workload stopped in the VM. Libvirt depends on the current block-job-cancel semantics, which is that when used without a flag after the 'ready' event, the command blocks until data is in sync. However, these semantics are awkward in other situations, for example, people may use drive mirror for realtime backups while still wanting to use block live migration. Libvirt cannot start a block live migration while another drive mirror is in progress, but the user would rather abandon the backup attempt as broken and proceed with the live migration than be stuck waiting for the current drive mirror backup to finish. The drive-mirror command already includes a 'force' flag, which libvirt does not use, although it documented the flag as only being useful to quit a job which is paused. However, since quitting a paused job has the same effect as abandoning a backup in a non-paused job (namely, the destination file is not in sync, and the command completes immediately), we can just improve the documentation to make the force flag obviously useful. Cc: Paolo Bonzini Cc: Jeff Cody Cc: Kevin Wolf Cc: Max Reitz Cc: Eric Blake Cc: John Snow Reported-by: Huaitong Han Signed-off-by: Huaitong Han Signed-off-by: Liang Li Signed-off-by: Jeff Cody Signed-off-by: Kevin Wolf --- include/block/blockjob.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'include/block/blockjob.h') diff --git a/include/block/blockjob.h b/include/block/blockjob.h index 978274e..fc645da 100644 --- a/include/block/blockjob.h +++ b/include/block/blockjob.h @@ -63,6 +63,12 @@ typedef struct BlockJob { bool cancelled; /** + * Set to true if the job should abort immediately without waiting + * for data to be in sync. + */ + bool force; + + /** * Counter for pause request. If non-zero, the block job is either paused, * or if busy == true will pause itself as soon as possible. */ @@ -230,10 +236,11 @@ void block_job_start(BlockJob *job); /** * block_job_cancel: * @job: The job to be canceled. + * @force: Quit a job without waiting for data to be in sync. * * Asynchronously cancel the specified job. */ -void block_job_cancel(BlockJob *job); +void block_job_cancel(BlockJob *job, bool force); /** * block_job_complete: @@ -307,11 +314,12 @@ void block_job_user_resume(BlockJob *job, Error **errp); /** * block_job_user_cancel: * @job: The job to be cancelled. + * @force: Quit a job without waiting for data to be in sync. * * Cancels the specified job, but may refuse to do so if the * operation isn't currently meaningful. */ -void block_job_user_cancel(BlockJob *job, Error **errp); +void block_job_user_cancel(BlockJob *job, bool force, Error **errp); /** * block_job_cancel_sync: -- cgit v1.1