qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] block: Use BDRV_O_NO_BACKING where appropriate
@ 2013-11-28 11:02 Kevin Wolf
  2013-11-29  1:14 ` Fam Zheng
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Kevin Wolf @ 2013-11-28 11:02 UTC (permalink / raw)
  To: qemu-devel; +Cc: kwolf, stefanha, mreitz

If you open an image temporarily just because you want to check its size
or get it flushed, there's no real reason to open the whole backing file
chain.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c       | 3 ++-
 block/qcow2.c | 3 ++-
 block/vmdk.c  | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/block.c b/block.c
index 03e45fc..e2745a5 100644
--- a/block.c
+++ b/block.c
@@ -1061,7 +1061,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
         /* Get the required size from the image */
         bs1 = bdrv_new("");
         QINCREF(options);
-        ret = bdrv_open(bs1, filename, options, 0, drv, &local_err);
+        ret = bdrv_open(bs1, filename, options, BDRV_O_NO_BACKING,
+                        drv, &local_err);
         if (ret < 0) {
             bdrv_unref(bs1);
             goto fail;
diff --git a/block/qcow2.c b/block/qcow2.c
index 2fe37ed..8e2b6c7 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1588,7 +1588,8 @@ static int qcow2_create2(const char *filename, int64_t total_size,
 
     /* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning */
     ret = bdrv_open(bs, filename, NULL,
-                    BDRV_O_RDWR | BDRV_O_CACHE_WB, drv, &local_err);
+                    BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_BACKING,
+                    drv, &local_err);
     if (error_is_set(&local_err)) {
         error_propagate(errp, local_err);
         goto out;
diff --git a/block/vmdk.c b/block/vmdk.c
index 6555663..5fb6c81 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -1690,7 +1690,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
     }
     if (backing_file) {
         BlockDriverState *bs = bdrv_new("");
-        ret = bdrv_open(bs, backing_file, NULL, 0, NULL, errp);
+        ret = bdrv_open(bs, backing_file, NULL, BDRV_O_NO_BACKING, NULL, errp);
         if (ret != 0) {
             bdrv_unref(bs);
             return ret;
-- 
1.8.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] block: Use BDRV_O_NO_BACKING where appropriate
  2013-11-28 11:02 [Qemu-devel] [PATCH] block: Use BDRV_O_NO_BACKING where appropriate Kevin Wolf
@ 2013-11-29  1:14 ` Fam Zheng
  2013-11-29 15:36 ` Benoît Canet
  2013-12-02  3:39 ` Wenchao Xia
  2 siblings, 0 replies; 4+ messages in thread
From: Fam Zheng @ 2013-11-29  1:14 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel; +Cc: stefanha, mreitz

On 2013年11月28日 19:02, Kevin Wolf wrote:
> If you open an image temporarily just because you want to check its size
> or get it flushed, there's no real reason to open the whole backing file
> chain.
>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>   block.c       | 3 ++-
>   block/qcow2.c | 3 ++-
>   block/vmdk.c  | 2 +-
>   3 files changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/block.c b/block.c
> index 03e45fc..e2745a5 100644
> --- a/block.c
> +++ b/block.c
> @@ -1061,7 +1061,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
>           /* Get the required size from the image */
>           bs1 = bdrv_new("");
>           QINCREF(options);
> -        ret = bdrv_open(bs1, filename, options, 0, drv, &local_err);
> +        ret = bdrv_open(bs1, filename, options, BDRV_O_NO_BACKING,
> +                        drv, &local_err);
>           if (ret < 0) {
>               bdrv_unref(bs1);
>               goto fail;
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 2fe37ed..8e2b6c7 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -1588,7 +1588,8 @@ static int qcow2_create2(const char *filename, int64_t total_size,
>
>       /* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning */
>       ret = bdrv_open(bs, filename, NULL,
> -                    BDRV_O_RDWR | BDRV_O_CACHE_WB, drv, &local_err);
> +                    BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_BACKING,
> +                    drv, &local_err);
>       if (error_is_set(&local_err)) {
>           error_propagate(errp, local_err);
>           goto out;
> diff --git a/block/vmdk.c b/block/vmdk.c
> index 6555663..5fb6c81 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -1690,7 +1690,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
>       }
>       if (backing_file) {
>           BlockDriverState *bs = bdrv_new("");
> -        ret = bdrv_open(bs, backing_file, NULL, 0, NULL, errp);
> +        ret = bdrv_open(bs, backing_file, NULL, BDRV_O_NO_BACKING, NULL, errp);
>           if (ret != 0) {
>               bdrv_unref(bs);
>               return ret;
>

Reviewed-by: Fam Zheng <famz@redhat.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] block: Use BDRV_O_NO_BACKING where appropriate
  2013-11-28 11:02 [Qemu-devel] [PATCH] block: Use BDRV_O_NO_BACKING where appropriate Kevin Wolf
  2013-11-29  1:14 ` Fam Zheng
@ 2013-11-29 15:36 ` Benoît Canet
  2013-12-02  3:39 ` Wenchao Xia
  2 siblings, 0 replies; 4+ messages in thread
From: Benoît Canet @ 2013-11-29 15:36 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-devel, stefanha, mreitz

Le Thursday 28 Nov 2013 à 12:02:27 (+0100), Kevin Wolf a écrit :
> If you open an image temporarily just because you want to check its size
> or get it flushed, there's no real reason to open the whole backing file
> chain.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block.c       | 3 ++-
>  block/qcow2.c | 3 ++-
>  block/vmdk.c  | 2 +-
>  3 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/block.c b/block.c
> index 03e45fc..e2745a5 100644
> --- a/block.c
> +++ b/block.c
> @@ -1061,7 +1061,8 @@ int bdrv_open(BlockDriverState *bs, const char *filename, QDict *options,
>          /* Get the required size from the image */
>          bs1 = bdrv_new("");
>          QINCREF(options);
> -        ret = bdrv_open(bs1, filename, options, 0, drv, &local_err);
> +        ret = bdrv_open(bs1, filename, options, BDRV_O_NO_BACKING,
> +                        drv, &local_err);
>          if (ret < 0) {
>              bdrv_unref(bs1);
>              goto fail;
> diff --git a/block/qcow2.c b/block/qcow2.c
> index 2fe37ed..8e2b6c7 100644
> --- a/block/qcow2.c
> +++ b/block/qcow2.c
> @@ -1588,7 +1588,8 @@ static int qcow2_create2(const char *filename, int64_t total_size,
>  
>      /* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning */
>      ret = bdrv_open(bs, filename, NULL,
> -                    BDRV_O_RDWR | BDRV_O_CACHE_WB, drv, &local_err);
> +                    BDRV_O_RDWR | BDRV_O_CACHE_WB | BDRV_O_NO_BACKING,
> +                    drv, &local_err);
>      if (error_is_set(&local_err)) {
>          error_propagate(errp, local_err);
>          goto out;
> diff --git a/block/vmdk.c b/block/vmdk.c
> index 6555663..5fb6c81 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -1690,7 +1690,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options,
>      }
>      if (backing_file) {
>          BlockDriverState *bs = bdrv_new("");
> -        ret = bdrv_open(bs, backing_file, NULL, 0, NULL, errp);
> +        ret = bdrv_open(bs, backing_file, NULL, BDRV_O_NO_BACKING, NULL, errp);
>          if (ret != 0) {
>              bdrv_unref(bs);
>              return ret;
> -- 
> 1.8.1.4
> 
> 

Reviewed-by: Benoit Canet <benoit@irqsave.net>

No Tested-By as it doesn't apply to kevin/master yet.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PATCH] block: Use BDRV_O_NO_BACKING where appropriate
  2013-11-28 11:02 [Qemu-devel] [PATCH] block: Use BDRV_O_NO_BACKING where appropriate Kevin Wolf
  2013-11-29  1:14 ` Fam Zheng
  2013-11-29 15:36 ` Benoît Canet
@ 2013-12-02  3:39 ` Wenchao Xia
  2 siblings, 0 replies; 4+ messages in thread
From: Wenchao Xia @ 2013-12-02  3:39 UTC (permalink / raw)
  To: Kevin Wolf, qemu-devel; +Cc: stefanha, mreitz

Reviewed-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-02  3:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-28 11:02 [Qemu-devel] [PATCH] block: Use BDRV_O_NO_BACKING where appropriate Kevin Wolf
2013-11-29  1:14 ` Fam Zheng
2013-11-29 15:36 ` Benoît Canet
2013-12-02  3:39 ` Wenchao Xia

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).