qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@redhat.com>
To: zoudongjie <zoudongjie@huawei.com>
Cc: zhuyangyang14@huawei.com, qemu-devel@nongnu.org, fam@euphon.net,
	hreitz@redhat.com, qemu-block@nongnu.org, qemu-stable@nongnu.org,
	luolongmin@huawei.com, suxiaodong1@huawei.com,
	wangyan122@huawei.com, yebiaoxiang@huawei.com,
	wangjian161@huawei.com, mujinsheng@huawei.com,
	alex.chen@huawei.com, eric.fangyi@huawei.com,
	chenjianfei3@huawei.com, renxuming@huawei.com
Subject: Re: [PATCH 2/2] qapi: Fix qmp_block_set_io_throttle blocked for too long
Date: Thu, 13 Mar 2025 12:25:08 +0800	[thread overview]
Message-ID: <20250313042508.GD1074020@fedora> (raw)
In-Reply-To: <20250308101618.721954-3-zoudongjie@huawei.com>

[-- Attachment #1: Type: text/plain, Size: 3708 bytes --]

On Sat, Mar 08, 2025 at 06:16:18PM +0800, zoudongjie wrote:
> From: Zhu Yangyang <zhuyangyang14@huawei.com>
> 
> bdrv_drained_begin() is blocked for a long time when network storage is used
> and the network link has just failed.
> Therefore, the timeout period is set here.
> 
> Signed-off-by: Zhu Yangyang <zhuyangyang14@huawei.com>
> ---
>  block/block-backend.c                       | 14 +++++++++++++-
>  block/qapi-system.c                         |  7 ++++++-
>  include/system/block-backend-global-state.h |  1 +
>  3 files changed, 20 insertions(+), 2 deletions(-)
> 
> diff --git a/block/block-backend.c b/block/block-backend.c
> index 9288f7e1c6..409d4559c3 100644
> --- a/block/block-backend.c
> +++ b/block/block-backend.c
> @@ -2691,20 +2691,32 @@ void blk_set_io_limits(BlockBackend *blk, ThrottleConfig *cfg)
>  }
>  
>  void blk_io_limits_disable(BlockBackend *blk)
> +{
> +    blk_io_limits_disable_timeout(blk, -1);
> +}
> +
> +int blk_io_limits_disable_timeout(BlockBackend *blk, int64_t timeout_ms)
>  {
>      BlockDriverState *bs = blk_bs(blk);
>      ThrottleGroupMember *tgm = &blk->public.throttle_group_member;
> +    int ret = 0;
> +
>      assert(tgm->throttle_state);
>      GLOBAL_STATE_CODE();
>      if (bs) {
>          bdrv_ref(bs);
> -        bdrv_drained_begin(bs);
> +        ret = bdrv_drained_begin_timeout(bs, timeout_ms);
> +        if (ret < 0) {
> +            goto out;
> +        }
>      }
>      throttle_group_unregister_tgm(tgm);
> +out:
>      if (bs) {
>          bdrv_drained_end(bs);
>          bdrv_unref(bs);
>      }
> +    return ret;
>  }
>  
>  /* should be called before blk_set_io_limits if a limit is set */
> diff --git a/block/qapi-system.c b/block/qapi-system.c
> index 54b7409b2b..96fa8e5e51 100644
> --- a/block/qapi-system.c
> +++ b/block/qapi-system.c
> @@ -39,6 +39,8 @@
>  #include "system/block-backend.h"
>  #include "system/blockdev.h"
>  
> +#define QMP_BLOCKING_TIMEOUT 5000 /* ms */
> +
>  static BlockBackend *qmp_get_blk(const char *blk_name, const char *qdev_id,
>                                   Error **errp)
>  {
> @@ -502,7 +504,10 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)
>          blk_set_io_limits(blk, &cfg);
>      } else if (blk_get_public(blk)->throttle_group_member.throttle_state) {
>          /* If all throttling settings are set to 0, disable I/O limits */
> -        blk_io_limits_disable(blk);
> +        if (blk_io_limits_disable_timeout(blk, QMP_BLOCKING_TIMEOUT) < 0) {

Please add a timeout parameter to the QMP command instead of hardcoding
the timeout. It should also support an infinite timeout and that should
be the default (so that existing users aren't surprised with a new error
they don't handle).

> +            error_setg(errp, "Blk io limits disable timeout");
> +            return;
> +        }
>      }
>  }
>  
> diff --git a/include/system/block-backend-global-state.h b/include/system/block-backend-global-state.h
> index 9cc9b008ec..e55ea9dc64 100644
> --- a/include/system/block-backend-global-state.h
> +++ b/include/system/block-backend-global-state.h
> @@ -111,6 +111,7 @@ int blk_probe_geometry(BlockBackend *blk, HDGeometry *geo);
>  
>  void blk_set_io_limits(BlockBackend *blk, ThrottleConfig *cfg);
>  void blk_io_limits_disable(BlockBackend *blk);
> +int blk_io_limits_disable_timeout(BlockBackend *blk, int64_t timeout_ms);
>  void blk_io_limits_enable(BlockBackend *blk, const char *group);
>  void blk_io_limits_update_group(BlockBackend *blk, const char *group);
>  void blk_set_force_allow_inactivate(BlockBackend *blk);
> -- 
> 2.33.0
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2025-03-13  7:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-08 10:16 [PATCH 0/2] qapi: Fix qmp_block_set_io_throttle blocked for too long zoudongjie via
2025-03-08 10:16 ` [PATCH 1/2] io/block: Refactoring the bdrv_drained_begin() function and implement a timeout mechanism zoudongjie via
2025-03-13  4:09   ` Stefan Hajnoczi
2025-03-17 12:18     ` zoudongjie via
2025-03-17 14:57       ` Stefan Hajnoczi
2025-03-13  4:22   ` Stefan Hajnoczi
2025-03-08 10:16 ` [PATCH 2/2] qapi: Fix qmp_block_set_io_throttle blocked for too long zoudongjie via
2025-03-13  4:25   ` Stefan Hajnoczi [this message]
2025-03-17 12:59     ` zoudongjie via
2025-03-11  3:24 ` [PATCH 0/2] " zoudongjie via
2025-03-13  4:27 ` Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250313042508.GD1074020@fedora \
    --to=stefanha@redhat.com \
    --cc=alex.chen@huawei.com \
    --cc=chenjianfei3@huawei.com \
    --cc=eric.fangyi@huawei.com \
    --cc=fam@euphon.net \
    --cc=hreitz@redhat.com \
    --cc=luolongmin@huawei.com \
    --cc=mujinsheng@huawei.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=renxuming@huawei.com \
    --cc=suxiaodong1@huawei.com \
    --cc=wangjian161@huawei.com \
    --cc=wangyan122@huawei.com \
    --cc=yebiaoxiang@huawei.com \
    --cc=zhuyangyang14@huawei.com \
    --cc=zoudongjie@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).