diff mbox

[v14,04/14] block: Move op_blocker check from block_job_create to its caller

Message ID 1392817351-22148-5-git-send-email-famz@redhat.com
State New
Headers show

Commit Message

Fam Zheng Feb. 19, 2014, 1:42 p.m. UTC
It makes no sense to check for "any" blocker on bs, we are here only
because of the mechanical conversion from in_use to op_blockers. Remove
it now, and let the callers check specific operation types. Backup and
mirror already have it, add checker to stream and commit.

Signed-off-by: Fam Zheng <famz@redhat.com>
---
 blockdev.c | 8 ++++++++
 blockjob.c | 2 +-
 2 files changed, 9 insertions(+), 1 deletion(-)

Comments

Benoît Canet Feb. 19, 2014, 3:28 p.m. UTC | #1
The Wednesday 19 Feb 2014 à 21:42:21 (+0800), Fam Zheng wrote :
> It makes no sense to check for "any" blocker on bs, we are here only
> because of the mechanical conversion from in_use to op_blockers. Remove
> it now, and let the callers check specific operation types. Backup and
> mirror already have it, add checker to stream and commit.
> 
> Signed-off-by: Fam Zheng <famz@redhat.com>
> ---
>  blockdev.c | 8 ++++++++
>  blockjob.c | 2 +-
>  2 files changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/blockdev.c b/blockdev.c
> index 53dce70..306aad5 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1840,6 +1840,10 @@ void qmp_block_stream(const char *device, bool has_base,
>          return;
>      }
>  
> +    if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_STREAM, errp)) {
> +        return;
> +    }
> +
>      if (base) {
>          base_bs = bdrv_find_backing_image(bs, base);
>          if (base_bs == NULL) {
> @@ -1880,6 +1884,10 @@ void qmp_block_commit(const char *device,
>          return;
>      }
>  
> +    if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_COMMIT, errp)) {
> +        return;
> +    }
> +
>      /* default top_bs is the active layer */
>      top_bs = bs;
>  
> diff --git a/blockjob.c b/blockjob.c
> index f1ff036..21e21c0 100644
> --- a/blockjob.c
> +++ b/blockjob.c
> @@ -41,7 +41,7 @@ void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
>  {
>      BlockJob *job;
>  
> -    if (bs->job || !bdrv_op_blocker_is_empty(bs)) {
> +    if (bs->job) {
>          error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs));
>          return NULL;
>      }
> -- 
> 1.8.5.4
> 
> 
Reviewed-by: Benoit Canet <benoit@irqsave.net>
diff mbox

Patch

diff --git a/blockdev.c b/blockdev.c
index 53dce70..306aad5 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1840,6 +1840,10 @@  void qmp_block_stream(const char *device, bool has_base,
         return;
     }
 
+    if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_STREAM, errp)) {
+        return;
+    }
+
     if (base) {
         base_bs = bdrv_find_backing_image(bs, base);
         if (base_bs == NULL) {
@@ -1880,6 +1884,10 @@  void qmp_block_commit(const char *device,
         return;
     }
 
+    if (bdrv_op_is_blocked(bs, BLOCK_OP_TYPE_COMMIT, errp)) {
+        return;
+    }
+
     /* default top_bs is the active layer */
     top_bs = bs;
 
diff --git a/blockjob.c b/blockjob.c
index f1ff036..21e21c0 100644
--- a/blockjob.c
+++ b/blockjob.c
@@ -41,7 +41,7 @@  void *block_job_create(const BlockJobDriver *driver, BlockDriverState *bs,
 {
     BlockJob *job;
 
-    if (bs->job || !bdrv_op_blocker_is_empty(bs)) {
+    if (bs->job) {
         error_set(errp, QERR_DEVICE_IN_USE, bdrv_get_device_name(bs));
         return NULL;
     }