Patchwork [32/47] block: forward bdrv_iostatus_reset to block job

login
register
mail settings
Submitter Paolo Bonzini
Date July 24, 2012, 11:04 a.m.
Message ID <1343127865-16608-33-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/172881/
State New
Headers show

Comments

Paolo Bonzini - July 24, 2012, 11:04 a.m.
This will be needed for mirroring, where the source and target have
different iostatuses.  The source iostatus is reported normally
in "query-block", while the target iostatus is accessible via
"query-block-jobs".

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block.c    |    3 +++
 blockjob.c |    7 +++++++
 blockjob.h |   12 ++++++++++++
 3 files changed, 22 insertions(+)

Patch

diff --git a/block.c b/block.c
index 81c2bc5..65d9bed 100644
--- a/block.c
+++ b/block.c
@@ -3931,6 +3931,9 @@  void bdrv_iostatus_reset(BlockDriverState *bs)
 {
     if (bdrv_iostatus_is_enabled(bs)) {
         bs->iostatus = BLOCK_DEVICE_IO_STATUS_OK;
+        if (bs->job) {
+            block_job_iostatus_reset(bs->job);
+        }
     }
 }
 
diff --git a/blockjob.c b/blockjob.c
index 42485bf..1770a02 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -139,6 +139,13 @@  bool block_job_is_cancelled(BlockJob *job)
     return job->cancelled;
 }
 
+void block_job_iostatus_reset(BlockJob *job)
+{
+    if (job->job_type->iostatus_reset) {
+        job->job_type->iostatus_reset(job);
+    }
+}
+
 struct BlockCancelData {
     BlockJob *job;
     BlockDriverCompletionFunc *cb;
diff --git a/blockjob.h b/blockjob.h
index 0d29fdf..a1fae9d 100644
--- a/blockjob.h
+++ b/blockjob.h
@@ -42,6 +42,9 @@  typedef struct BlockJobType {
     /** Optional callback for job types that support setting a speed limit */
     void (*set_speed)(BlockJob *job, int64_t speed, Error **errp);
 
+    /** Optional callback for job types that need to forward I/O status reset */
+    void (*iostatus_reset)(BlockJob *job);
+
     /**
      * Optional callback for job types that can fill the target member
      * of BlockJobInfo.
@@ -257,6 +260,15 @@  bool block_job_is_paused(BlockJob *job);
 int block_job_cancel_sync(BlockJob *job);
 
 /**
+ * block_job_iostatus_reset:
+ * @job: The job whose I/O status should be reset.
+ *
+ * Reset I/O status on BlockDriverState objects used by @job, other
+ * than job->bs.
+ */
+void block_job_iostatus_reset(BlockJob *job);
+
+/**
  * block_job_error_action:
  * @job: The job to signal an error for.
  * @bs: The block device on which to set an I/O error.