mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
Move orphan lock obtain/release inside vg_extend().
With this change we now have vgcreate/vgextend liblvm functions. Note that this changes the lock order of the following functions as the orphan lock is now obtained first. With our policy of non-blocking second locks, this should not be a problem. Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
This commit is contained in:
parent
03660b3045
commit
7fa91ec044
@ -437,6 +437,12 @@ int vg_extend(struct volume_group *vg, int pv_count, char **pv_names)
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
struct physical_volume *pv;
|
struct physical_volume *pv;
|
||||||
|
struct cmd_context *cmd = vg->cmd;
|
||||||
|
|
||||||
|
if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
|
||||||
|
log_error("Can't get lock for orphan PVs");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* attach each pv */
|
/* attach each pv */
|
||||||
for (i = 0; i < pv_count; i++) {
|
for (i = 0; i < pv_count; i++) {
|
||||||
@ -445,18 +451,19 @@ int vg_extend(struct volume_group *vg, int pv_count, char **pv_names)
|
|||||||
"physical volume", pv_names[i]);
|
"physical volume", pv_names[i]);
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!add_pv_to_vg(vg, pv_names[i], pv))
|
if (!add_pv_to_vg(vg, pv_names[i], pv))
|
||||||
goto bad;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME Decide whether to initialise and add new mdahs to format instance */
|
/* FIXME Decide whether to initialise and add new mdahs to format instance */
|
||||||
|
|
||||||
|
unlock_vg(cmd, VG_ORPHANS);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
log_error("Unable to add physical volume '%s' to "
|
log_error("Unable to add physical volume '%s' to "
|
||||||
"volume group '%s'.", pv_names[i], vg->name);
|
"volume group '%s'.", pv_names[i], vg->name);
|
||||||
|
unlock_vg(cmd, VG_ORPHANS);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,12 +46,6 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
if (validate_vg_create_params(cmd, &vp_new))
|
if (validate_vg_create_params(cmd, &vp_new))
|
||||||
return EINVALID_CMD_LINE;
|
return EINVALID_CMD_LINE;
|
||||||
|
|
||||||
/* FIXME: orphan lock needs tied to vg handle or inside library call */
|
|
||||||
if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
|
|
||||||
log_error("Can't get lock for orphan PVs");
|
|
||||||
return ECMD_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create the new VG */
|
/* Create the new VG */
|
||||||
vg = vg_create(cmd, vp_new.vg_name);
|
vg = vg_create(cmd, vp_new.vg_name);
|
||||||
if (vg_read_error(vg))
|
if (vg_read_error(vg))
|
||||||
@ -113,7 +107,6 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
}
|
}
|
||||||
|
|
||||||
unlock_vg(cmd, vp_new.vg_name);
|
unlock_vg(cmd, vp_new.vg_name);
|
||||||
unlock_vg(cmd, VG_ORPHANS);
|
|
||||||
|
|
||||||
backup(vg);
|
backup(vg);
|
||||||
|
|
||||||
@ -126,6 +119,5 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
bad:
|
bad:
|
||||||
vg_release(vg);
|
vg_release(vg);
|
||||||
unlock_vg(cmd, vp_new.vg_name);
|
unlock_vg(cmd, vp_new.vg_name);
|
||||||
unlock_vg(cmd, VG_ORPHANS);
|
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
|
@ -36,17 +36,11 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
argc--;
|
argc--;
|
||||||
argv++;
|
argv++;
|
||||||
|
|
||||||
if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) {
|
|
||||||
log_error("Can't get lock for orphan PVs");
|
|
||||||
return ECMD_FAILED;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_verbose("Checking for volume group \"%s\"", vg_name);
|
log_verbose("Checking for volume group \"%s\"", vg_name);
|
||||||
vg = vg_read_for_update(cmd, vg_name, NULL,
|
vg = vg_read_for_update(cmd, vg_name, NULL,
|
||||||
READ_REQUIRE_RESIZEABLE);
|
READ_REQUIRE_RESIZEABLE);
|
||||||
if (vg_read_error(vg)) {
|
if (vg_read_error(vg)) {
|
||||||
vg_release(vg);
|
vg_release(vg);
|
||||||
unlock_vg(cmd, VG_ORPHANS);
|
|
||||||
return ECMD_FAILED;
|
return ECMD_FAILED;
|
||||||
}
|
}
|
||||||
/********** FIXME
|
/********** FIXME
|
||||||
@ -77,6 +71,5 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
|
|||||||
|
|
||||||
error:
|
error:
|
||||||
unlock_and_release_vg(cmd, vg, vg_name);
|
unlock_and_release_vg(cmd, vg, vg_name);
|
||||||
unlock_vg(cmd, VG_ORPHANS);
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user