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

More P_ and V_ lock cleanup.

This commit is contained in:
Alasdair Kergon 2008-05-09 18:45:15 +00:00
parent 3d6af3e35e
commit 98fd1ce332
7 changed files with 27 additions and 16 deletions

View File

@ -6,6 +6,7 @@ Version 2.02.38 -
Version 2.02.37 - Version 2.02.37 -
================================= =================================
Add assertions to trap deprecated P_ and V_ lock usage.
Add missing mutex around clvmd lvmcache_drop_metadata library call. Add missing mutex around clvmd lvmcache_drop_metadata library call.
Fix uninitialised mutex in clvmd if all daemons are not running at startup. Fix uninitialised mutex in clvmd if all daemons are not running at startup.
Avoid using DLM locks with LCK_CACHE type P_ lock requests. Avoid using DLM locks with LCK_CACHE type P_ lock requests.

View File

@ -118,10 +118,10 @@ int do_command(struct local_client *client, struct clvm_header *msg, int msglen,
lockname = &args[2]; lockname = &args[2];
/* Check to see if the VG is in use by LVM1 */ /* Check to see if the VG is in use by LVM1 */
status = do_check_lvm1(lockname); status = do_check_lvm1(lockname);
/* P_#global causes a cache refresh */ /* P_#global causes a full cache refresh */
if (strcmp(lockname, "P_#global") == 0) if (!strcmp(lockname, "P_#global"))
do_refresh_cache(); do_refresh_cache();
else if (strncmp(lockname, "P_", 2) == 0) else
drop_metadata(lockname + 2); drop_metadata(lockname + 2);
break; break;
@ -254,9 +254,9 @@ int do_pre_command(struct local_client *client)
case CLVMD_CMD_LOCK_VG: case CLVMD_CMD_LOCK_VG:
lockname = &args[2]; lockname = &args[2];
/* Do not use lock for cache related commands */ /* We take out a real lock unless LCK_CACHE was set */
if (!strncmp(lockname, "V_", 2) || if (!strncmp(lockname, "V_", 2) ||
!strcmp(lockname, "P_#global")) !strncmp(lockname, "P_#", 3))
status = lock_vg(client); status = lock_vg(client);
break; break;

View File

@ -472,7 +472,8 @@ static void drop_vg_locks()
popen popen
("lvm pvs --config 'log{command_names=0 prefix=\"\"}' --nolocking --noheadings -o vg_name", "r"); ("lvm pvs --config 'log{command_names=0 prefix=\"\"}' --nolocking --noheadings -o vg_name", "r");
sync_unlock("P_orphans", LCK_EXCL); sync_unlock("P_#orphans", LCK_EXCL);
sync_unlock("P_#global", LCK_EXCL);
if (!vgs) if (!vgs)
return; return;

View File

@ -162,6 +162,9 @@ void lvmcache_drop_metadata(const char *vgname)
_drop_metadata(FMT_TEXT_ORPHAN_VG_NAME); _drop_metadata(FMT_TEXT_ORPHAN_VG_NAME);
_drop_metadata(FMT_LVM1_ORPHAN_VG_NAME); _drop_metadata(FMT_LVM1_ORPHAN_VG_NAME);
_drop_metadata(FMT_POOL_ORPHAN_VG_NAME); _drop_metadata(FMT_POOL_ORPHAN_VG_NAME);
/* Indicate that PVs could now be missing from the cache */
init_full_scan_done(0);
} else } else
_drop_metadata(vgname); _drop_metadata(vgname);
} }

View File

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

View File

@ -214,10 +214,7 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
lvmcache_drop_metadata(resource); lvmcache_drop_metadata(resource);
break; break;
} }
if (!*resource) /* FIXME Deprecated */ if (*resource == '#')
dm_snprintf(lockfile, sizeof(lockfile),
"%s/P_orphans", _lock_dir);
else if (*resource == '#')
dm_snprintf(lockfile, sizeof(lockfile), dm_snprintf(lockfile, sizeof(lockfile),
"%s/P_%s", _lock_dir, resource + 1); "%s/P_%s", _lock_dir, resource + 1);
else else

View File

@ -323,6 +323,16 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource, uint32_t fla
assert(resource); assert(resource);
if (!*resource) {
log_error("Internal error: Use of P_orphans is deprecated.");
return 0;
}
if (*resource == '#' && (flags & LCK_CACHE)) {
log_error("Internal error: P_%s referenced", resource);
return 0;
}
if ((ret = _locking.lock_resource(cmd, resource, flags))) { if ((ret = _locking.lock_resource(cmd, resource, flags))) {
if ((flags & LCK_SCOPE_MASK) == LCK_VG && if ((flags & LCK_SCOPE_MASK) == LCK_VG &&
!(flags & LCK_CACHE)) { !(flags & LCK_CACHE)) {