mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
sanlock: Properly init io_timeout
https://bugzilla.redhat.com/show_bug.cgi?id=1292984
Hold on to your hats, because this is gonna be wild.
In bd3e16a3
I've tried to expose sanlock io_timeout. What I had
not realized (because there is like no documentation for sanlock
at all) was very unusual way their APIs work. Basically, what we
do currently is:
sanlock_add_lockspace_timeout(&ls, io_timeout);
which adds a lockspace to sanlock daemon. One would expect that
io_timeout sets the io_timeout for it. Nah! That's where you are
completely off the tracks. It sets timeout for next lockspace you
will probably add later. Therefore:
sanlock_add_lockspace_timeout(&ls, io_timeout = 10);
/* adds new lockspace with default io_timeout */
sanlock_add_lockspace_timeout(&ls, io_timeout = 20);
/* adds new lockspace with io_timeout = 10 */
sanlock_add_lockspace_timeout(&ls, io_timeout = 40);
/* adds new lockspace with io_timeout = 20 */
And so on. You get the picture.
Fortunately, we don't allow setting io_timeout per domain or per
domain disk. So we just need to set the default used in the very
first step and hope for the best (as all the io_timeout-s used
later will have the same value).
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
2bca7cec0b
commit
5fe66ea3bf
@ -158,6 +158,29 @@ virLockManagerSanlockLoadConfig(virLockManagerSanlockDriverPtr driver,
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int
|
||||
virLockManagerSanlockInitLockspace(virLockManagerSanlockDriverPtr driver,
|
||||
struct sanlk_lockspace *ls)
|
||||
{
|
||||
int ret;
|
||||
|
||||
#ifdef HAVE_SANLOCK_IO_TIMEOUT
|
||||
const int max_hosts = 0; /* defaults used in sanlock_init() implementation */
|
||||
const unsigned int lockspaceFlags = 0;
|
||||
|
||||
ret = sanlock_write_lockspace(ls, max_hosts, lockspaceFlags, driver->io_timeout);
|
||||
#else
|
||||
if (driver->io_timeout) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("unable to use io_timeout with this version of sanlock"));
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
ret = sanlock_init(ls, NULL, 0, 0);
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* How much ms sleep before retrying to add a lockspace? */
|
||||
#define LOCKSPACE_SLEEP 100
|
||||
/* How many times try adding a lockspace? */
|
||||
@ -268,7 +291,7 @@ virLockManagerSanlockSetupLockspace(virLockManagerSanlockDriverPtr driver)
|
||||
goto error_unlink;
|
||||
}
|
||||
|
||||
if ((rv = sanlock_init(&ls, NULL, 0, 0)) < 0) {
|
||||
if ((rv = virLockManagerSanlockInitLockspace(driver, &ls) < 0)) {
|
||||
if (rv <= -200)
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Unable to initialize lockspace %s: error %d"),
|
||||
|
Loading…
Reference in New Issue
Block a user