[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 08/14] fsdev: Use ThrottleDirection instread of bool is_write
From: |
Hanna Czenczek |
Subject: |
[PULL 08/14] fsdev: Use ThrottleDirection instread of bool is_write |
Date: |
Fri, 1 Sep 2023 10:18:03 +0200 |
From: zhenwei pi <pizhenwei@bytedance.com>
'bool is_write' style is obsolete from throttle framework, adapt
fsdev to the new style.
Cc: Greg Kurz <groug@kaod.org>
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>
Message-Id: <20230728022006.1098509-9-pizhenwei@bytedance.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
Signed-off-by: Hanna Czenczek <hreitz@redhat.com>
---
fsdev/qemu-fsdev-throttle.h | 4 ++--
fsdev/qemu-fsdev-throttle.c | 14 +++++++-------
hw/9pfs/cofile.c | 4 ++--
3 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/fsdev/qemu-fsdev-throttle.h b/fsdev/qemu-fsdev-throttle.h
index a21aecddc7..daa8ca2494 100644
--- a/fsdev/qemu-fsdev-throttle.h
+++ b/fsdev/qemu-fsdev-throttle.h
@@ -23,14 +23,14 @@ typedef struct FsThrottle {
ThrottleState ts;
ThrottleTimers tt;
ThrottleConfig cfg;
- CoQueue throttled_reqs[2];
+ CoQueue throttled_reqs[THROTTLE_MAX];
} FsThrottle;
int fsdev_throttle_parse_opts(QemuOpts *, FsThrottle *, Error **);
void fsdev_throttle_init(FsThrottle *);
-void coroutine_fn fsdev_co_throttle_request(FsThrottle *, bool ,
+void coroutine_fn fsdev_co_throttle_request(FsThrottle *, ThrottleDirection ,
struct iovec *, int);
void fsdev_throttle_cleanup(FsThrottle *);
diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c
index 1c137d6f0f..d912da906d 100644
--- a/fsdev/qemu-fsdev-throttle.c
+++ b/fsdev/qemu-fsdev-throttle.c
@@ -94,22 +94,22 @@ void fsdev_throttle_init(FsThrottle *fst)
}
}
-void coroutine_fn fsdev_co_throttle_request(FsThrottle *fst, bool is_write,
+void coroutine_fn fsdev_co_throttle_request(FsThrottle *fst,
+ ThrottleDirection direction,
struct iovec *iov, int iovcnt)
{
- ThrottleDirection direction = is_write ? THROTTLE_WRITE : THROTTLE_READ;
-
+ assert(direction < THROTTLE_MAX);
if (throttle_enabled(&fst->cfg)) {
if (throttle_schedule_timer(&fst->ts, &fst->tt, direction) ||
- !qemu_co_queue_empty(&fst->throttled_reqs[is_write])) {
- qemu_co_queue_wait(&fst->throttled_reqs[is_write], NULL);
+ !qemu_co_queue_empty(&fst->throttled_reqs[direction])) {
+ qemu_co_queue_wait(&fst->throttled_reqs[direction], NULL);
}
throttle_account(&fst->ts, direction, iov_size(iov, iovcnt));
- if (!qemu_co_queue_empty(&fst->throttled_reqs[is_write]) &&
+ if (!qemu_co_queue_empty(&fst->throttled_reqs[direction]) &&
!throttle_schedule_timer(&fst->ts, &fst->tt, direction)) {
- qemu_co_queue_next(&fst->throttled_reqs[is_write]);
+ qemu_co_queue_next(&fst->throttled_reqs[direction]);
}
}
}
diff --git a/hw/9pfs/cofile.c b/hw/9pfs/cofile.c
index 9c5344039e..71174c3e4a 100644
--- a/hw/9pfs/cofile.c
+++ b/hw/9pfs/cofile.c
@@ -252,7 +252,7 @@ int coroutine_fn v9fs_co_pwritev(V9fsPDU *pdu, V9fsFidState
*fidp,
if (v9fs_request_cancelled(pdu)) {
return -EINTR;
}
- fsdev_co_throttle_request(s->ctx.fst, true, iov, iovcnt);
+ fsdev_co_throttle_request(s->ctx.fst, THROTTLE_WRITE, iov, iovcnt);
v9fs_co_run_in_worker(
{
err = s->ops->pwritev(&s->ctx, &fidp->fs, iov, iovcnt, offset);
@@ -272,7 +272,7 @@ int coroutine_fn v9fs_co_preadv(V9fsPDU *pdu, V9fsFidState
*fidp,
if (v9fs_request_cancelled(pdu)) {
return -EINTR;
}
- fsdev_co_throttle_request(s->ctx.fst, false, iov, iovcnt);
+ fsdev_co_throttle_request(s->ctx.fst, THROTTLE_READ, iov, iovcnt);
v9fs_co_run_in_worker(
{
err = s->ops->preadv(&s->ctx, &fidp->fs, iov, iovcnt, offset);
--
2.41.0
- [PULL 00/14] Block patches, Hanna Czenczek, 2023/09/01
- [PULL 02/14] test-throttle: use enum ThrottleDirection, Hanna Czenczek, 2023/09/01
- [PULL 03/14] throttle: support read-only and write-only, Hanna Czenczek, 2023/09/01
- [PULL 01/14] throttle: introduce enum ThrottleDirection, Hanna Czenczek, 2023/09/01
- [PULL 04/14] test-throttle: test read only and write only, Hanna Czenczek, 2023/09/01
- [PULL 06/14] throttle: use enum ThrottleDirection instead of bool is_write, Hanna Czenczek, 2023/09/01
- [PULL 07/14] throttle: use THROTTLE_MAX/ARRAY_SIZE for hard code, Hanna Czenczek, 2023/09/01
- [PULL 05/14] cryptodev: use NULL throttle timer cb for read direction, Hanna Czenczek, 2023/09/01
- [PULL 08/14] fsdev: Use ThrottleDirection instread of bool is_write,
Hanna Czenczek <=
- [PULL 10/14] file-posix: Clear bs->bl.zoned on error, Hanna Czenczek, 2023/09/01
- [PULL 11/14] file-posix: Check bs->bl.zoned for zone info, Hanna Czenczek, 2023/09/01
- [PULL 13/14] file-posix: Simplify raw_co_prw's 'out' zone code, Hanna Czenczek, 2023/09/01
- [PULL 12/14] file-posix: Fix zone update in I/O error path, Hanna Czenczek, 2023/09/01
- [PULL 14/14] tests/file-io-error: New test, Hanna Czenczek, 2023/09/01
- [PULL 09/14] block/throttle-groups: Use ThrottleDirection instread of bool is_write, Hanna Czenczek, 2023/09/01
- Re: [PULL 00/14] Block patches, Stefan Hajnoczi, 2023/09/06