Ignore image resize events after disconnect in vitastor-nbd and vitastor-ublk #156

Merged
vitalif merged 3 commits from koolkhel/vitastor:nbd-resize-after-disc into master 2026-11-25 14:42:35 +03:00
2 changed files with 12 additions and 2 deletions

View File

@@ -759,6 +759,12 @@ help:
ringloop->loop();
ringloop->wait();
}
if (watch && nbd_fd < 0)
{
// The device is disconnected and may already be mapped by someone else
cli->st_cli->close_watch(watch);
watch = NULL;
}
cli->flush();
}

View File

@@ -87,6 +87,7 @@ protected:
cluster_client_t *cli = NULL;
inode_watch_t *watch = NULL;
bool size_changed = false;
bool started = false;
std::string logfile = "/dev/null";
std::string pidfile;
@@ -361,12 +362,14 @@ help:
}
consumer.loop = [this]()
{
if (size_changed)
// Not before START_DEV or after stop: UPDATE_SIZE on a device without a disk crashes unpatched 6.16-6.19 kernels
if (size_changed && started && !stop)
try_resize();
submit_postponed();
};
ringloop->register_consumer(&consumer);
start_device(recover);
started = true;
if (pidfile != "")
write_pid();
if (bg)
@@ -700,7 +703,7 @@ protected:
{
return;
}
size_changed = true;
size_changed = false;
ring_data_t* data = ((ring_data_t*)sqe->user_data);
data->callback = [this, size = device_size](ring_data_t *data)
{
@@ -709,6 +712,7 @@ protected:
fprintf(stderr, "Failed to update size of /dev/ublkb%d to %ju bytes: %s (code %d)\n", ublk_dev.dev_id, size, strerror(-data->res), data->res);
}
};
ringloop->submit();
}
void map_ublk_queue()