1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

lockd: add start_init arg to lockd_start_vg

Add a new arg to lockd_start_vg() that indicates
it is being called for a new lockd VG, so that
lvmlockd knows the lockspace being started is new.
(Will be used by a following commit.)
This commit is contained in:
David Teigland 2015-09-09 13:20:37 -05:00
parent 30e489db5e
commit 36d16fed1f
4 changed files with 14 additions and 9 deletions

View File

@ -921,9 +921,13 @@ void lockd_free_vg_final(struct cmd_context *cmd, struct volume_group *vg)
* for starting the lockspace. To use the vg after starting * for starting the lockspace. To use the vg after starting
* the lockspace, follow the standard method which is: * the lockspace, follow the standard method which is:
* lock the vg, read/use/write the vg, unlock the vg. * lock the vg, read/use/write the vg, unlock the vg.
*
* start_init is 1 when the VG is being started after the
* command has done lockd_init_vg(). This tells lvmlockd
* that the VG lockspace being started is new.
*/ */
int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg) int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg, int start_init)
{ {
char uuid[64] __attribute__((aligned(8))); char uuid[64] __attribute__((aligned(8)));
daemon_reply reply; daemon_reply reply;
@ -945,8 +949,8 @@ int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg)
return 0; return 0;
} }
log_debug("lockd start VG %s lock_type %s", log_debug("lockd start VG %s lock_type %s init %d",
vg->name, vg->lock_type ? vg->lock_type : "empty"); vg->name, vg->lock_type ? vg->lock_type : "empty", start_init);
if (!id_write_format(&vg->id, uuid, sizeof(uuid))) if (!id_write_format(&vg->id, uuid, sizeof(uuid)))
return_0; return_0;
@ -973,6 +977,7 @@ int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg)
"vg_uuid = %s", uuid[0] ? uuid : "none", "vg_uuid = %s", uuid[0] ? uuid : "none",
"version = %d", (int64_t)vg->seqno, "version = %d", (int64_t)vg->seqno,
"host_id = %d", host_id, "host_id = %d", host_id,
"opts = %s", start_init ? "start_init" : "none",
NULL); NULL);
if (!_lockd_result(reply, &result, NULL)) { if (!_lockd_result(reply, &result, NULL)) {
@ -2461,7 +2466,7 @@ int lockd_rename_vg_final(struct cmd_context *cmd, struct volume_group *vg, int
* Depending on the problem that caused the rename to * Depending on the problem that caused the rename to
* fail, it may make sense to not restart the VG here. * fail, it may make sense to not restart the VG here.
*/ */
if (!lockd_start_vg(cmd, vg)) if (!lockd_start_vg(cmd, vg, 0))
log_error("Failed to restart VG %s lockspace.", vg->name); log_error("Failed to restart VG %s lockspace.", vg->name);
return 1; return 1;
} }
@ -2501,7 +2506,7 @@ int lockd_rename_vg_final(struct cmd_context *cmd, struct volume_group *vg, int
} }
} }
if (!lockd_start_vg(cmd, vg)) if (!lockd_start_vg(cmd, vg, 1))
log_error("Failed to start VG %s lockspace.", vg->name); log_error("Failed to start VG %s lockspace.", vg->name);
return 1; return 1;

View File

@ -62,7 +62,7 @@ int lockd_rename_vg_final(struct cmd_context *cmd, struct volume_group *vg, int
/* start and stop the lockspace for a vg */ /* start and stop the lockspace for a vg */
int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg); int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg, int start_init);
int lockd_stop_vg(struct cmd_context *cmd, struct volume_group *vg); int lockd_stop_vg(struct cmd_context *cmd, struct volume_group *vg);
int lockd_start_wait(struct cmd_context *cmd); int lockd_start_wait(struct cmd_context *cmd);
@ -147,7 +147,7 @@ static inline int lockd_rename_vg_final(struct cmd_context *cmd, struct volume_g
return 1; return 1;
} }
static inline int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg) static inline int lockd_start_vg(struct cmd_context *cmd, struct volume_group *vg, int start_init)
{ {
return 0; return 0;
} }

View File

@ -878,7 +878,7 @@ static int _vgchange_lock_start(struct cmd_context *cmd, struct volume_group *vg
} }
do_start: do_start:
return lockd_start_vg(cmd, vg); return lockd_start_vg(cmd, vg, 0);
} }
static int _vgchange_lock_stop(struct cmd_context *cmd, struct volume_group *vg) static int _vgchange_lock_stop(struct cmd_context *cmd, struct volume_group *vg)

View File

@ -157,7 +157,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
if (is_lockd_type(vg->lock_type)) { if (is_lockd_type(vg->lock_type)) {
const char *start_opt = arg_str_value(cmd, lockopt_ARG, NULL); const char *start_opt = arg_str_value(cmd, lockopt_ARG, NULL);
if (!lockd_start_vg(cmd, vg)) { if (!lockd_start_vg(cmd, vg, 1)) {
log_error("Failed to start locking"); log_error("Failed to start locking");
goto out; goto out;
} }