mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lvmlockd: enable lockopt nodelay for lockstart
Avoid the sanlock add_lockspace delay in vgchange --lockstart by adding --lockopt nodelay. This is for testing, and is not safe to use in general.
This commit is contained in:
parent
77332669d0
commit
875012fb5d
@ -1062,14 +1062,14 @@ static int lm_prepare_lockspace(struct lockspace *ls, struct action *act)
|
||||
return rv;
|
||||
}
|
||||
|
||||
static int lm_add_lockspace(struct lockspace *ls, struct action *act, int adopt_only, int adopt_ok)
|
||||
static int lm_add_lockspace(struct lockspace *ls, struct action *act, int adopt_only, int adopt_ok, int nodelay)
|
||||
{
|
||||
int rv;
|
||||
|
||||
if (ls->lm_type == LD_LM_DLM)
|
||||
rv = lm_add_lockspace_dlm(ls, adopt_only, adopt_ok);
|
||||
else if (ls->lm_type == LD_LM_SANLOCK)
|
||||
rv = lm_add_lockspace_sanlock(ls, adopt_only, adopt_ok);
|
||||
rv = lm_add_lockspace_sanlock(ls, adopt_only, adopt_ok, nodelay);
|
||||
else if (ls->lm_type == LD_LM_IDM)
|
||||
rv = lm_add_lockspace_idm(ls, adopt_only, adopt_ok);
|
||||
else
|
||||
@ -2495,6 +2495,7 @@ static void *lockspace_thread_main(void *arg_in)
|
||||
int adopt_only = 0;
|
||||
int adopt_ok = 0;
|
||||
int wait_flag = 0;
|
||||
int nodelay = 0;
|
||||
int retry;
|
||||
int rv;
|
||||
|
||||
@ -2517,6 +2518,8 @@ static void *lockspace_thread_main(void *arg_in)
|
||||
adopt_only = 1;
|
||||
if (add_act->flags & LD_AF_ADOPT)
|
||||
adopt_ok = 1;
|
||||
if (add_act->flags & LD_AF_NODELAY)
|
||||
nodelay = 1;
|
||||
}
|
||||
}
|
||||
pthread_mutex_unlock(&ls->mutex);
|
||||
@ -2546,7 +2549,7 @@ static void *lockspace_thread_main(void *arg_in)
|
||||
* The actual lockspace join can take a while.
|
||||
*/
|
||||
if (!error) {
|
||||
error = lm_add_lockspace(ls, add_act, adopt_only, adopt_ok);
|
||||
error = lm_add_lockspace(ls, add_act, adopt_only, adopt_ok, nodelay);
|
||||
|
||||
log_debug("S %s lm_add_lockspace done %d", ls->name, error);
|
||||
|
||||
@ -4545,6 +4548,8 @@ static uint32_t str_to_opts(const char *str)
|
||||
flags |= LD_AF_ENABLE;
|
||||
if (strstr(str, "disable"))
|
||||
flags |= LD_AF_DISABLE;
|
||||
if (strstr(str, "nodelay"))
|
||||
flags |= LD_AF_NODELAY;
|
||||
|
||||
/* FIXME: parse the flag values properly */
|
||||
if (strstr(str, "adopt_only"))
|
||||
|
@ -113,6 +113,7 @@ struct client {
|
||||
#define LD_AF_LV_UNLOCK 0x00080000
|
||||
#define LD_AF_SH_EXISTS 0x00100000
|
||||
#define LD_AF_ADOPT_ONLY 0x00200000 /* adopt orphan or fail */
|
||||
#define LD_AF_NODELAY 0x00400000
|
||||
|
||||
/*
|
||||
* Number of times to repeat a lock request after
|
||||
@ -510,7 +511,7 @@ int lm_init_lv_sanlock(struct lockspace *ls, char *lv_name, char *vg_args, char
|
||||
int lm_free_lv_sanlock(struct lockspace *ls, struct resource *r);
|
||||
int lm_rename_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_args);
|
||||
int lm_prepare_lockspace_sanlock(struct lockspace *ls);
|
||||
int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt_only, int adopt_ok);
|
||||
int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt_only, int adopt_ok, int nodelay);
|
||||
int lm_rem_lockspace_sanlock(struct lockspace *ls, int free_vg);
|
||||
int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, int *retry,
|
||||
@ -561,7 +562,7 @@ static inline int lm_prepare_lockspace_sanlock(struct lockspace *ls)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt_only, int adopt_ok)
|
||||
static inline int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt_only, int adopt_ok, int nodelay)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -24,6 +24,9 @@
|
||||
#include "sanlock_admin.h"
|
||||
#include "sanlock_resource.h"
|
||||
|
||||
/* FIXME: copied from sanlock header until the sanlock update is more widespread */
|
||||
#define SANLK_ADD_NODELAY 0x00000002
|
||||
|
||||
#include <stddef.h>
|
||||
#include <poll.h>
|
||||
#include <errno.h>
|
||||
@ -1594,9 +1597,10 @@ fail:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt_only, int adopt_ok)
|
||||
int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt_only, int adopt_ok, int nodelay)
|
||||
{
|
||||
struct lm_sanlock *lms = (struct lm_sanlock *)ls->lm_data;
|
||||
uint32_t flags = 0;
|
||||
int rv;
|
||||
|
||||
if (daemon_test) {
|
||||
@ -1604,7 +1608,10 @@ int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt_only, int adopt_ok)
|
||||
goto out;
|
||||
}
|
||||
|
||||
rv = sanlock_add_lockspace_timeout(&lms->ss, 0, sanlock_io_timeout);
|
||||
if (nodelay)
|
||||
flags |= SANLK_ADD_NODELAY;
|
||||
|
||||
rv = sanlock_add_lockspace_timeout(&lms->ss, flags, sanlock_io_timeout);
|
||||
if (rv == -EEXIST && (adopt_ok || adopt_only)) {
|
||||
/* We could alternatively just skip the sanlock call for adopt. */
|
||||
log_debug("S %s add_lockspace_san adopt found ls", ls->name);
|
||||
|
@ -1407,6 +1407,7 @@ int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg, int *exists
|
||||
{
|
||||
char uuid[64] __attribute__((aligned(8)));
|
||||
const char *opts = NULL;
|
||||
char opt_buf[64] = {};
|
||||
daemon_reply reply;
|
||||
uint32_t lockd_flags = 0;
|
||||
int host_id = 0;
|
||||
@ -1428,10 +1429,15 @@ int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg, int *exists
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (cmd->lockopt & LOCKOPT_ADOPTLS)
|
||||
opts = "adopt_only";
|
||||
else if (cmd->lockopt & LOCKOPT_ADOPT)
|
||||
opts = "adopt";
|
||||
if ((cmd->lockopt & LOCKOPT_NODELAY) ||
|
||||
(cmd->lockopt & LOCKOPT_ADOPTLS) ||
|
||||
(cmd->lockopt & LOCKOPT_ADOPT)) {
|
||||
dm_snprintf(opt_buf, sizeof(opt_buf), "%s%s%s",
|
||||
(cmd->lockopt & LOCKOPT_NODELAY) ? "nodelay," : "",
|
||||
(cmd->lockopt & LOCKOPT_ADOPTLS) ? "adopt_only" : "",
|
||||
(cmd->lockopt & LOCKOPT_ADOPT) ? "adopt" : "");
|
||||
opts = opt_buf;
|
||||
}
|
||||
|
||||
log_debug("lockd start VG %s lock_type %s",
|
||||
vg->name, vg->lock_type ? vg->lock_type : "empty");
|
||||
@ -3797,6 +3803,8 @@ void lockd_lockopt_get_flags(const char *str, uint32_t *flags)
|
||||
*flags |= LOCKOPT_ADOPTLV;
|
||||
else if (!strcmp(argv[i], "adopt"))
|
||||
*flags |= LOCKOPT_ADOPT;
|
||||
else if (!strcmp(argv[i], "nodelay"))
|
||||
*flags |= LOCKOPT_NODELAY;
|
||||
else
|
||||
log_warn("Ignoring unknown lockopt value: %s", argv[i]);
|
||||
}
|
||||
|
@ -54,6 +54,7 @@
|
||||
#define LOCKOPT_ADOPTVG 0x00000800
|
||||
#define LOCKOPT_ADOPTLV 0x00001000
|
||||
#define LOCKOPT_ADOPT 0x00002000
|
||||
#define LOCKOPT_NODELAY 0x00004000
|
||||
|
||||
#ifdef LVMLOCKD_SUPPORT
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user