qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] block: Remove unused callback function *bdrv_aio_pdiscard
@ 2025-04-21 18:21 Sunny Zhu
  2025-04-22  7:09 ` Philippe Mathieu-Daudé
  2025-04-25 15:12 ` Kevin Wolf
  0 siblings, 2 replies; 3+ messages in thread
From: Sunny Zhu @ 2025-04-21 18:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: eblake, hreitz, kwolf, qemu-block, sunnyzhyy

The bytes type in *bdrv_aio_pdiscard should be int64_t rather than int.

There are no drivers implementing the *bdrv_aio_pdiscard() callback,
it appears to be an unused function. Therefore, we'll simply remove it
instead of fixing it.

Additionally, coroutine-based callbacks are preferred. If someone needs
to implement bdrv_aio_pdiscard, a coroutine-based version would be
straightforward to implement.

Signed-off-by: Sunny Zhu <sunnyzhyy@qq.com>
---
 block/io.c                       | 22 +++-------------------
 include/block/block_int-common.h |  4 ----
 2 files changed, 3 insertions(+), 23 deletions(-)

diff --git a/block/io.c b/block/io.c
index 1ba8d1aeea..cfddeb4756 100644
--- a/block/io.c
+++ b/block/io.c
@@ -3102,7 +3102,7 @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset,
         return 0;
     }
 
-    if (!bs->drv->bdrv_co_pdiscard && !bs->drv->bdrv_aio_pdiscard) {
+    if (!bs->drv->bdrv_co_pdiscard) {
         return 0;
     }
 
@@ -3161,24 +3161,8 @@ int coroutine_fn bdrv_co_pdiscard(BdrvChild *child, int64_t offset,
             ret = -ENOMEDIUM;
             goto out;
         }
-        if (bs->drv->bdrv_co_pdiscard) {
-            ret = bs->drv->bdrv_co_pdiscard(bs, offset, num);
-        } else {
-            BlockAIOCB *acb;
-            CoroutineIOCompletion co = {
-                .coroutine = qemu_coroutine_self(),
-            };
-
-            acb = bs->drv->bdrv_aio_pdiscard(bs, offset, num,
-                                             bdrv_co_io_em_complete, &co);
-            if (acb == NULL) {
-                ret = -EIO;
-                goto out;
-            } else {
-                qemu_coroutine_yield();
-                ret = co.ret;
-            }
-        }
+
+        ret = bs->drv->bdrv_co_pdiscard(bs, offset, num);
         if (ret && ret != -ENOTSUP) {
             goto out;
         }
diff --git a/include/block/block_int-common.h b/include/block/block_int-common.h
index ebb4e56a50..0d8187f656 100644
--- a/include/block/block_int-common.h
+++ b/include/block/block_int-common.h
@@ -506,10 +506,6 @@ struct BlockDriver {
     BlockAIOCB * GRAPH_RDLOCK_PTR (*bdrv_aio_flush)(
         BlockDriverState *bs, BlockCompletionFunc *cb, void *opaque);
 
-    BlockAIOCB * GRAPH_RDLOCK_PTR (*bdrv_aio_pdiscard)(
-        BlockDriverState *bs, int64_t offset, int bytes,
-        BlockCompletionFunc *cb, void *opaque);
-
     int coroutine_fn GRAPH_RDLOCK_PTR (*bdrv_co_readv)(BlockDriverState *bs,
         int64_t sector_num, int nb_sectors, QEMUIOVector *qiov);
 
-- 
2.43.0



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

* Re: [PATCH v2] block: Remove unused callback function *bdrv_aio_pdiscard
  2025-04-21 18:21 [PATCH v2] block: Remove unused callback function *bdrv_aio_pdiscard Sunny Zhu
@ 2025-04-22  7:09 ` Philippe Mathieu-Daudé
  2025-04-25 15:12 ` Kevin Wolf
  1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-04-22  7:09 UTC (permalink / raw)
  To: Sunny Zhu, qemu-devel; +Cc: eblake, hreitz, kwolf, qemu-block

On 21/4/25 20:21, Sunny Zhu wrote:
> The bytes type in *bdrv_aio_pdiscard should be int64_t rather than int.
> 
> There are no drivers implementing the *bdrv_aio_pdiscard() callback,
> it appears to be an unused function. Therefore, we'll simply remove it
> instead of fixing it.
> 
> Additionally, coroutine-based callbacks are preferred. If someone needs
> to implement bdrv_aio_pdiscard, a coroutine-based version would be
> straightforward to implement.
> 
> Signed-off-by: Sunny Zhu <sunnyzhyy@qq.com>
> ---
>   block/io.c                       | 22 +++-------------------
>   include/block/block_int-common.h |  4 ----
>   2 files changed, 3 insertions(+), 23 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>



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

* Re: [PATCH v2] block: Remove unused callback function *bdrv_aio_pdiscard
  2025-04-21 18:21 [PATCH v2] block: Remove unused callback function *bdrv_aio_pdiscard Sunny Zhu
  2025-04-22  7:09 ` Philippe Mathieu-Daudé
@ 2025-04-25 15:12 ` Kevin Wolf
  1 sibling, 0 replies; 3+ messages in thread
From: Kevin Wolf @ 2025-04-25 15:12 UTC (permalink / raw)
  To: Sunny Zhu; +Cc: qemu-devel, eblake, hreitz, qemu-block

Am 21.04.2025 um 20:21 hat Sunny Zhu geschrieben:
> The bytes type in *bdrv_aio_pdiscard should be int64_t rather than int.
> 
> There are no drivers implementing the *bdrv_aio_pdiscard() callback,
> it appears to be an unused function. Therefore, we'll simply remove it
> instead of fixing it.
> 
> Additionally, coroutine-based callbacks are preferred. If someone needs
> to implement bdrv_aio_pdiscard, a coroutine-based version would be
> straightforward to implement.
> 
> Signed-off-by: Sunny Zhu <sunnyzhyy@qq.com>

Thanks, applied to the block branch.

Kevin



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

end of thread, other threads:[~2025-04-25 15:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-21 18:21 [PATCH v2] block: Remove unused callback function *bdrv_aio_pdiscard Sunny Zhu
2025-04-22  7:09 ` Philippe Mathieu-Daudé
2025-04-25 15:12 ` Kevin Wolf

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).