forked from vitalif/vitastor
Avoid repeated qemu_uring_handlers, add 2.0-2.7 compatibility
parent
3de7929fe5
commit
2348d39cf4
|
@ -79,6 +79,7 @@ typedef struct VitastorClient
|
||||||
AioContext *ctx;
|
AioContext *ctx;
|
||||||
VitastorFdData **fds;
|
VitastorFdData **fds;
|
||||||
int fd_count, fd_alloc;
|
int fd_count, fd_alloc;
|
||||||
|
int bh_uring_scheduled;
|
||||||
|
|
||||||
uint64_t last_bitmap_inode, last_bitmap_offset, last_bitmap_len;
|
uint64_t last_bitmap_inode, last_bitmap_offset, last_bitmap_len;
|
||||||
uint32_t last_bitmap_granularity;
|
uint32_t last_bitmap_granularity;
|
||||||
|
@ -108,6 +109,14 @@ typedef struct VitastorRPC
|
||||||
#endif
|
#endif
|
||||||
} VitastorRPC;
|
} VitastorRPC;
|
||||||
|
|
||||||
|
#if QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR < 8
|
||||||
|
typedef struct VitastorBH
|
||||||
|
{
|
||||||
|
VitastorClient *cli;
|
||||||
|
QEMUBH *bh;
|
||||||
|
} VitastorBH;
|
||||||
|
#endif
|
||||||
|
|
||||||
static void vitastor_co_init_task(BlockDriverState *bs, VitastorRPC *task);
|
static void vitastor_co_init_task(BlockDriverState *bs, VitastorRPC *task);
|
||||||
static void vitastor_co_generic_cb(void *opaque, long retval);
|
static void vitastor_co_generic_cb(void *opaque, long retval);
|
||||||
static void vitastor_co_read_cb(void *opaque, long retval, uint64_t version);
|
static void vitastor_co_read_cb(void *opaque, long retval, uint64_t version);
|
||||||
|
@ -225,18 +234,11 @@ out:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vitastor_unlocked_uring_handler(VitastorClient *client)
|
|
||||||
{
|
|
||||||
do
|
|
||||||
{
|
|
||||||
vitastor_c_uring_handle_events(client->proxy);
|
|
||||||
} while (vitastor_c_uring_has_work(client->proxy));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vitastor_uring_handler(void *opaque)
|
static void vitastor_uring_handler(void *opaque)
|
||||||
{
|
{
|
||||||
VitastorClient *client = (VitastorClient*)opaque;
|
VitastorClient *client = (VitastorClient*)opaque;
|
||||||
qemu_mutex_lock(&client->mutex);
|
qemu_mutex_lock(&client->mutex);
|
||||||
|
client->bh_uring_scheduled = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
vitastor_c_uring_handle_events(client->proxy);
|
vitastor_c_uring_handle_events(client->proxy);
|
||||||
|
@ -244,20 +246,40 @@ static void vitastor_uring_handler(void *opaque)
|
||||||
qemu_mutex_unlock(&client->mutex);
|
qemu_mutex_unlock(&client->mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR < 8
|
||||||
|
static void vitastor_bh_uring_handler(void *opaque)
|
||||||
|
{
|
||||||
|
VitastorBH *vbh = opaque;
|
||||||
|
vitastor_bh_handler(vbh->cli);
|
||||||
|
qemu_bh_delete(vbh->bh);
|
||||||
|
free(vbh);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static void vitastor_schedule_uring_handler(VitastorClient *client)
|
static void vitastor_schedule_uring_handler(VitastorClient *client)
|
||||||
{
|
{
|
||||||
void *opaque = client;
|
void *opaque = client;
|
||||||
|
if (!client->bh_uring_scheduled)
|
||||||
|
{
|
||||||
|
client->bh_uring_scheduled = 1;
|
||||||
#if QEMU_VERSION_MAJOR > 4 || QEMU_VERSION_MAJOR == 4 && QEMU_VERSION_MINOR >= 2
|
#if QEMU_VERSION_MAJOR > 4 || QEMU_VERSION_MAJOR == 4 && QEMU_VERSION_MINOR >= 2
|
||||||
replay_bh_schedule_oneshot_event(client->ctx, vitastor_uring_handler, opaque);
|
replay_bh_schedule_oneshot_event(client->ctx, vitastor_uring_handler, opaque);
|
||||||
#elif QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR >= 8
|
#elif QEMU_VERSION_MAJOR >= 3 || QEMU_VERSION_MAJOR == 2 && QEMU_VERSION_MINOR >= 8
|
||||||
aio_bh_schedule_oneshot(client->ctx, vitastor_uring_handler, opaque);
|
aio_bh_schedule_oneshot(client->ctx, vitastor_uring_handler, opaque);
|
||||||
#elif QEMU_VERSION_MAJOR >= 2
|
#elif QEMU_VERSION_MAJOR >= 2
|
||||||
// task->bh = aio_bh_new(bdrv_get_aio_context(task->bs), vitastor_co_generic_bh_cb, opaque);
|
VitastorBH *vbh = (VitastorBH*)malloc(sizeof(VitastorBH));
|
||||||
// qemu_bh_schedule(task->bh);
|
vbh->cli = client;
|
||||||
|
vbh->bh = aio_bh_new(bdrv_get_aio_context(task->bs), vitastor_bh_uring_handler, vbh);
|
||||||
|
qemu_bh_schedule(vbh->bh);
|
||||||
#else
|
#else
|
||||||
// vitastor_co_generic_bh_cb(opaque);
|
client->bh_uring_scheduled = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
vitastor_c_uring_handle_events(client->proxy);
|
||||||
|
} while (vitastor_c_uring_has_work(client->proxy));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void coroutine_fn vitastor_co_get_metadata(VitastorRPC *task)
|
static void coroutine_fn vitastor_co_get_metadata(VitastorRPC *task)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue