1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Introduce VG_GLOBAL lock type for vgscan/pvscan to trigger clvmd -R.

This commit is contained in:
Alasdair Kergon 2007-08-23 15:02:26 +00:00
parent f608f30407
commit e935d21752
6 changed files with 31 additions and 4 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.28 -
================================
Introduce VG_GLOBAL lock type for vgscan/pvscan to trigger clvmd -R.
Fix clvmd -R, so it fully refreshes the caches.
Change lvconvert_mirrors to use mirror segtype not striped.
Fix lvconvert_mirrors detection of number of existing mirrors.

View File

@ -382,8 +382,10 @@ int lock_resource(struct cmd_context *cmd, const char *resource, uint32_t flags)
switch (flags & LCK_SCOPE_MASK) {
case LCK_VG:
/* If the VG name is empty then lock the unused PVs */
if (!*resource)
if (!*resource) /* FIXME Deprecated */
dm_snprintf(lockname, sizeof(lockname), "P_orphans");
else if (*resource == '#')
dm_snprintf(lockname, sizeof(lockname), "P_%s", resource + 1);
else
dm_snprintf(lockname, sizeof(lockname), "V_%s",
resource);

View File

@ -212,9 +212,12 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
switch (flags & LCK_SCOPE_MASK) {
case LCK_VG:
if (!*resource)
if (!*resource) /* FIXME Deprecated */
dm_snprintf(lockfile, sizeof(lockfile),
"%s/P_orphans", _lock_dir);
else if (*resource == '#')
dm_snprintf(lockfile, sizeof(lockfile),
"%s/P_%s", _lock_dir, resource + 1);
else
dm_snprintf(lockfile, sizeof(lockfile),
"%s/V_%s", _lock_dir, resource);

View File

@ -28,7 +28,7 @@ int locking_is_clustered(void);
/*
* LCK_VG:
* Lock/unlock on-disk volume group data
* Use "" to lock orphan PVs
* Use VG_ORPHANS to lock orphan PVs
* char *vol holds volume group name
*
* LCK_LV:
@ -77,6 +77,11 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
#define LCK_MIRROR_NOSYNC_MODE 0x00000002U /* Mirrors don't require sync */
#define LCK_DMEVENTD_MONITOR_MODE 0x00000004U /* Register with dmeventd */
/*
* Special cases of VG locks.
*/
#define VG_ORPHANS "#orphans"
#define VG_GLOBAL "#global"
/*
* Common combinations

View File

@ -124,12 +124,19 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
arg_count(cmd, exported_ARG) ?
"of exported volume group(s)" : "in no volume group");
if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE)) {
log_error("Unable to obtain global lock.");
return ECMD_FAILED;
}
persistent_filter_wipe(cmd->filter);
lvmcache_destroy();
log_verbose("Walking through all physical volumes");
if (!(pvslist = get_pvs(cmd)))
if (!(pvslist = get_pvs(cmd))) {
unlock_vg(cmd, VG_GLOBAL);
return ECMD_FAILED;
}
/* eliminate exported/new if required */
list_iterate_items(pvl, pvslist) {
@ -181,6 +188,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
if (!pvs_found) {
log_print("No matching physical volumes found");
unlock_vg(cmd, VG_GLOBAL);
return ECMD_PROCESSED;
}
@ -191,5 +199,7 @@ int pvscan(struct cmd_context *cmd, int argc __attribute((unused)),
display_size(cmd, (size_total - size_new)),
new_pvs_found, display_size(cmd, size_new));
unlock_vg(cmd, VG_GLOBAL);
return ECMD_PROCESSED;
}

View File

@ -51,6 +51,11 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE)) {
log_error("Unable to obtain global lock.");
return ECMD_FAILED;
}
persistent_filter_wipe(cmd->filter);
lvmcache_destroy();
@ -65,5 +70,6 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv)
maxret = ret;
}
unlock_vg(cmd, VG_GLOBAL);
return maxret;
}