Compare commits

...

1 Commits

2 changed files with 39 additions and 3 deletions

6
debian/changelog vendored
View File

@@ -1,3 +1,9 @@
pve-qemu-kvm (5.2.0-11+vitastor5) buster; urgency=medium
* Clear QEMU eventfd handler to prevent crashes on attach/detach
-- Vitaliy Filippov <vitalif@yourcmc.ru> Sat, 22 Mar 2025 15:09:34 +0300
pve-qemu-kvm (5.2.0-11+vitastor4) buster; urgency=medium
* Fix truncation

View File

@@ -183,7 +183,7 @@ Index: a/block/vitastor.c
===================================================================
--- /dev/null
+++ a/block/vitastor.c
@@ -0,0 +1,1075 @@
@@ -0,0 +1,1105 @@
+// Copyright (c) Vitaliy Filippov, 2019+
+// License: VNPL-1.1 or GNU GPL-2.0+ (see README.md for details)
+
@@ -202,7 +202,6 @@ Index: a/block/vitastor.c
+#include "qapi/error.h"
+#include "qapi/qmp/qdict.h"
+#include "qapi/qmp/qerror.h"
+#include "qemu/uri.h"
+#include "qemu/error-report.h"
+#include "qemu/module.h"
+#include "qemu/option.h"
@@ -382,10 +381,11 @@ Index: a/block/vitastor.c
+ !strcmp(name, "rdma-gid-index") ||
+ !strcmp(name, "rdma-mtu"))
+ {
+ unsigned long long num_val;
+#if QEMU_VERSION_MAJOR < 8 || QEMU_VERSION_MAJOR == 8 && QEMU_VERSION_MINOR < 1
+ unsigned long long num_val;
+ if (parse_uint_full(value, &num_val, 0))
+#else
+ uint64_t num_val;
+ if (parse_uint_full(value, 0, &num_val))
+#endif
+ {
@@ -480,7 +480,9 @@ Index: a/block/vitastor.c
+
+ qemu_mutex_lock(&client->mutex);
+ vitastor_c_watch_inode(client->proxy, client->image, vitastor_co_generic_cb, task);
+#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
+ vitastor_schedule_uring_handler(client);
+#endif
+ qemu_mutex_unlock(&client->mutex);
+
+ while (!task->complete)
@@ -752,6 +754,22 @@ Index: a/block/vitastor.c
+static void vitastor_close(BlockDriverState *bs)
+{
+ VitastorClient *client = bs->opaque;
+ if (client->uring_eventfd >= 0)
+ {
+ // clear the eventfd handler
+ universal_aio_set_fd_handler(client->ctx, client->uring_eventfd, NULL, NULL, NULL);
+ int wait_bh = 0;
+ qemu_mutex_lock(&client->mutex);
+ // clear uring_eventfd itself to prevent future scheduling of new B/H
+ client->uring_eventfd = -1;
+ wait_bh = client->bh_uring_scheduled;
+ qemu_mutex_unlock(&client->mutex);
+ if (wait_bh)
+ {
+ // wait until existing scheduled B/H is ran
+ BDRV_POLL_WHILE(bs, client->bh_uring_scheduled);
+ }
+ }
+ vitastor_c_destroy(client->proxy);
+ if (client->fds)
+ {
@@ -935,7 +953,9 @@ Index: a/block/vitastor.c
+ uint64_t inode = client->watch ? vitastor_c_inode_get_num(client->watch) : client->inode;
+ qemu_mutex_lock(&client->mutex);
+ vitastor_c_read(client->proxy, inode, offset, bytes, iov->iov, iov->niov, vitastor_co_read_cb, &task);
+#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
+ vitastor_schedule_uring_handler(client);
+#endif
+ qemu_mutex_unlock(&client->mutex);
+
+ while (!task.complete)
@@ -969,7 +989,9 @@ Index: a/block/vitastor.c
+ uint64_t inode = client->watch ? vitastor_c_inode_get_num(client->watch) : client->inode;
+ qemu_mutex_lock(&client->mutex);
+ vitastor_c_write(client->proxy, inode, offset, bytes, 0, iov->iov, iov->niov, vitastor_co_generic_cb, &task);
+#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
+ vitastor_schedule_uring_handler(client);
+#endif
+ qemu_mutex_unlock(&client->mutex);
+
+ while (!task.complete)
@@ -1049,7 +1071,9 @@ Index: a/block/vitastor.c
+ task.bitmap = client->last_bitmap = NULL;
+ qemu_mutex_lock(&client->mutex);
+ vitastor_c_read_bitmap(client->proxy, task.inode, task.offset, task.len, !client->skip_parents, vitastor_co_read_bitmap_cb, &task);
+#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
+ vitastor_schedule_uring_handler(client);
+#endif
+ qemu_mutex_unlock(&client->mutex);
+ while (!task.complete)
+ {
@@ -1136,7 +1160,9 @@ Index: a/block/vitastor.c
+
+ qemu_mutex_lock(&client->mutex);
+ vitastor_c_sync(client->proxy, vitastor_co_generic_cb, &task);
+#if !defined VITASTOR_C_API_VERSION || VITASTOR_C_API_VERSION < 5
+ vitastor_schedule_uring_handler(client);
+#endif
+ qemu_mutex_unlock(&client->mutex);
+
+ while (!task.complete)
@@ -1206,7 +1232,11 @@ Index: a/block/vitastor.c
+ // FIXME: Implement it along with per-inode statistics
+ //.bdrv_get_allocated_file_size = vitastor_get_allocated_file_size,
+
+#if QEMU_VERSION_MAJOR > 9 || QEMU_VERSION_MAJOR == 9 && QEMU_VERSION_MINOR > 0
+ .bdrv_open = vitastor_file_open,
+#else
+ .bdrv_file_open = vitastor_file_open,
+#endif
+ .bdrv_close = vitastor_close,
+
+ // Option list for the create operation