diff mbox series

[v2,10/15] block/export: Don't ignore image activation error in blk_exp_add()

Message ID 20250131095051.49708-1-kwolf@redhat.com (mailing list archive)
State New
Headers show
Series block: Managing inactive nodes (QSD migration) | expand

Commit Message

Kevin Wolf Jan. 31, 2025, 9:50 a.m. UTC
Currently, block jobs can't handle inactive images correctly. Incoming
write requests would run into assertion failures. Make sure that we
return an error when creating an export can't activate the image.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block/export/export.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Eric Blake Feb. 3, 2025, 4:30 p.m. UTC | #1
On Fri, Jan 31, 2025 at 10:50:46AM +0100, Kevin Wolf wrote:
> Currently, block jobs can't handle inactive images correctly. Incoming
> write requests would run into assertion failures. Make sure that we
> return an error when creating an export can't activate the image.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/export/export.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>
Stefan Hajnoczi Feb. 3, 2025, 6:58 p.m. UTC | #2
On Fri, Jan 31, 2025 at 10:50:46AM +0100, Kevin Wolf wrote:
> Currently, block jobs can't handle inactive images correctly. Incoming

Did you mean "block exports" instead of "block jobs"? If it's really
"block jobs", please give an example scenario of the iteraction between
jobs and exports.

Otherwise:
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>

> write requests would run into assertion failures. Make sure that we
> return an error when creating an export can't activate the image.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block/export/export.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/block/export/export.c b/block/export/export.c
> index 79c71ee245..bac42b8608 100644
> --- a/block/export/export.c
> +++ b/block/export/export.c
> @@ -145,7 +145,11 @@ BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp)
>       * ctx was acquired in the caller.
>       */
>      bdrv_graph_rdlock_main_loop();
> -    bdrv_activate(bs, NULL);
> +    ret = bdrv_activate(bs, errp);
> +    if (ret < 0) {
> +        bdrv_graph_rdunlock_main_loop();
> +        goto fail;
> +    }
>      bdrv_graph_rdunlock_main_loop();
>  
>      perm = BLK_PERM_CONSISTENT_READ;
> -- 
> 2.48.1
>
Kevin Wolf Feb. 4, 2025, 3:54 p.m. UTC | #3
Am 03.02.2025 um 19:58 hat Stefan Hajnoczi geschrieben:
> On Fri, Jan 31, 2025 at 10:50:46AM +0100, Kevin Wolf wrote:
> > Currently, block jobs can't handle inactive images correctly. Incoming
> 
> Did you mean "block exports" instead of "block jobs"? If it's really
> "block jobs", please give an example scenario of the iteraction between
> jobs and exports.

Yes, just a typo, it should be "block exports". Will fix.

Kevin
diff mbox series

Patch

diff --git a/block/export/export.c b/block/export/export.c
index 79c71ee245..bac42b8608 100644
--- a/block/export/export.c
+++ b/block/export/export.c
@@ -145,7 +145,11 @@  BlockExport *blk_exp_add(BlockExportOptions *export, Error **errp)
      * ctx was acquired in the caller.
      */
     bdrv_graph_rdlock_main_loop();
-    bdrv_activate(bs, NULL);
+    ret = bdrv_activate(bs, errp);
+    if (ret < 0) {
+        bdrv_graph_rdunlock_main_loop();
+        goto fail;
+    }
     bdrv_graph_rdunlock_main_loop();
 
     perm = BLK_PERM_CONSISTENT_READ;