public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/lock ...
@ 2010-05-19 2:08 agk
0 siblings, 0 replies; 4+ messages in thread
From: agk @ 2010-05-19 2:08 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2010-05-19 02:08:51
Modified files:
. : WHATS_NEW
lib/cache : lvmcache.c
lib/locking : locking.c
lib/metadata : metadata-exported.h metadata.c
Log message:
Validate orphan and VG_GLOBAL lock order too.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1564&r2=1.1565
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.88&r2=1.89
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.82&r2=1.83
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.144&r2=1.145
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.340&r2=1.341
--- LVM2/WHATS_NEW 2010/05/19 01:16:40 1.1564
+++ LVM2/WHATS_NEW 2010/05/19 02:08:50 1.1565
@@ -1,5 +1,6 @@
Version 2.02.66 -
===============================
+ Validate orphan and VG_GLOBAL lock order too.
Accept orphan VG names as parameters to lock_vol() and related functions.
Use is_orphan_vg in place of hard-coded prefix tests.
--- LVM2/lib/cache/lvmcache.c 2010/05/19 01:16:40 1.88
+++ LVM2/lib/cache/lvmcache.c 2010/05/19 02:08:50 1.89
@@ -224,11 +224,21 @@
/*
* Ensure vgname2 comes after vgname1 alphabetically.
- * Orphans don't count.
+ * Orphan locks come last.
+ * VG_GLOBAL comes first.
*/
static int _vgname_order_correct(const char *vgname1, const char *vgname2)
{
- if (is_orphan_vg(vgname1) || is_orphan_vg(vgname2))
+ if (is_global_vg(vgname1))
+ return 1;
+
+ if (is_global_vg(vgname2))
+ return 0;
+
+ if (is_orphan_vg(vgname1))
+ return 0;
+
+ if (is_orphan_vg(vgname2))
return 1;
if (strcmp(vgname1, vgname2) < 0)
--- LVM2/lib/locking/locking.c 2010/05/19 01:16:41 1.82
+++ LVM2/lib/locking/locking.c 2010/05/19 02:08:51 1.83
@@ -424,7 +424,7 @@
if (is_orphan_vg(vol))
vol = VG_ORPHANS;
/* VG locks alphabetical, ORPHAN lock last */
- else if (((flags & LCK_TYPE_MASK) != LCK_UNLOCK) &&
+ if (((flags & LCK_TYPE_MASK) != LCK_UNLOCK) &&
!(flags & LCK_CACHE) &&
!lvmcache_verify_lock_order(vol))
return 0;
--- LVM2/lib/metadata/metadata-exported.h 2010/05/14 15:19:43 1.144
+++ LVM2/lib/metadata/metadata-exported.h 2010/05/19 02:08:51 1.145
@@ -423,6 +423,7 @@
int move_pvs_used_by_lv(struct volume_group *vg_from,
struct volume_group *vg_to,
const char *lv_name);
+int is_global_vg(const char *vg_name);
int is_orphan_vg(const char *vg_name);
int is_orphan(const struct physical_volume *pv);
int is_missing_pv(const struct physical_volume *pv);
--- LVM2/lib/metadata/metadata.c 2010/05/19 01:16:41 1.340
+++ LVM2/lib/metadata/metadata.c 2010/05/19 02:08:51 1.341
@@ -3326,6 +3326,11 @@
return 1;
}
+int is_global_vg(const char *vg_name)
+{
+ return (vg_name && !strcmp(vg_name, VG_GLOBAL)) ? 1 : 0;
+}
+
/**
* is_orphan_vg - Determine whether a vg_name is an orphan
* @vg_name: pointer to the vg_name
^ permalink raw reply [flat|nested] 4+ messages in thread
* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/lock ...
@ 2010-05-19 1:16 agk
0 siblings, 0 replies; 4+ messages in thread
From: agk @ 2010-05-19 1:16 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2010-05-19 01:16:41
Modified files:
. : WHATS_NEW
lib/cache : lvmcache.c
lib/locking : locking.c
lib/metadata : metadata.c
tools : pvresize.c
Log message:
Accept orphan VG names as parameters to lock_vol() and related functions.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1563&r2=1.1564
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.87&r2=1.88
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.81&r2=1.82
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.339&r2=1.340
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35
--- LVM2/WHATS_NEW 2010/05/19 00:52:55 1.1563
+++ LVM2/WHATS_NEW 2010/05/19 01:16:40 1.1564
@@ -1,5 +1,6 @@
Version 2.02.66 -
===============================
+ Accept orphan VG names as parameters to lock_vol() and related functions.
Use is_orphan_vg in place of hard-coded prefix tests.
Version 2.02.65 - 17th May 2010
--- LVM2/lib/cache/lvmcache.c 2010/05/19 00:52:55 1.87
+++ LVM2/lib/cache/lvmcache.c 2010/05/19 01:16:40 1.88
@@ -290,7 +290,7 @@
if (!_lock_hash)
return 0;
- return dm_hash_lookup(_lock_hash, vgname) ? 1 : 0;
+ return dm_hash_lookup(_lock_hash, is_orphan_vg(vgname) ? VG_ORPHANS : vgname) ? 1 : 0;
}
void lvmcache_unlock_vgname(const char *vgname)
--- LVM2/lib/locking/locking.c 2010/05/19 00:52:55 1.81
+++ LVM2/lib/locking/locking.c 2010/05/19 01:16:41 1.82
@@ -417,16 +417,16 @@
switch (flags & LCK_SCOPE_MASK) {
case LCK_VG:
- /*
- * VG locks alphabetical, ORPHAN lock last
- */
if (!_blocking_supported)
flags |= LCK_NONBLOCK;
- if (!is_orphan_vg(vol) &&
- ((flags & LCK_TYPE_MASK) != LCK_UNLOCK) &&
- (!(flags & LCK_CACHE)) &&
- !lvmcache_verify_lock_order(vol))
+ /* Global VG_ORPHANS lock covers all orphan formats. */
+ if (is_orphan_vg(vol))
+ vol = VG_ORPHANS;
+ /* VG locks alphabetical, ORPHAN lock last */
+ else if (((flags & LCK_TYPE_MASK) != LCK_UNLOCK) &&
+ !(flags & LCK_CACHE) &&
+ !lvmcache_verify_lock_order(vol))
return 0;
/* Lock VG to change on-disk metadata. */
--- LVM2/lib/metadata/metadata.c 2010/05/14 15:19:43 1.339
+++ LVM2/lib/metadata/metadata.c 2010/05/19 01:16:41 1.340
@@ -3459,7 +3459,7 @@
return !_vg_bad_status_bits(vg, status);
}
-static struct volume_group *_recover_vg(struct cmd_context *cmd, const char *lock_name,
+static struct volume_group *_recover_vg(struct cmd_context *cmd,
const char *vg_name, const char *vgid,
uint32_t lock_flags)
{
@@ -3469,11 +3469,11 @@
lock_flags &= ~LCK_TYPE_MASK;
lock_flags |= LCK_WRITE;
- unlock_vg(cmd, lock_name);
+ unlock_vg(cmd, vg_name);
dev_close_all();
- if (!lock_vol(cmd, lock_name, lock_flags))
+ if (!lock_vol(cmd, vg_name, lock_flags))
return_NULL;
if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent)))
@@ -3503,7 +3503,6 @@
uint64_t status_flags, uint32_t misc_flags)
{
struct volume_group *vg = NULL;
- const char *lock_name;
int consistent = 1;
int consistent_in;
uint32_t failure = 0;
@@ -3518,11 +3517,10 @@
return NULL;
}
- lock_name = is_orphan_vg(vg_name) ? VG_ORPHANS : vg_name;
- already_locked = vgname_is_locked(lock_name);
+ already_locked = vgname_is_locked(vg_name);
if (!already_locked && !(misc_flags & READ_WITHOUT_LOCK) &&
- !lock_vol(cmd, lock_name, lock_flags)) {
+ !lock_vol(cmd, vg_name, lock_flags)) {
log_error("Can't get lock for %s", vg_name);
return _vg_make_handle(cmd, vg, FAILED_LOCKING);
}
@@ -3555,7 +3553,7 @@
/* consistent == 0 when VG is not found, but failed == FAILED_NOTFOUND */
if (!consistent && !failure) {
vg_release(vg);
- if (!(vg = _recover_vg(cmd, lock_name, vg_name, vgid, lock_flags))) {
+ if (!(vg = _recover_vg(cmd, vg_name, vgid, lock_flags))) {
log_error("Recovery of volume group \"%s\" failed.",
vg_name);
failure |= FAILED_INCONSISTENT;
@@ -3592,7 +3590,7 @@
bad:
if (!already_locked && !(misc_flags & READ_WITHOUT_LOCK))
- unlock_vg(cmd, lock_name);
+ unlock_vg(cmd, vg_name);
return _vg_make_handle(cmd, vg, failure);
}
--- LVM2/tools/pvresize.c 2009/12/11 13:11:56 1.34
+++ LVM2/tools/pvresize.c 2010/05/19 01:16:41 1.35
@@ -34,15 +34,14 @@
int r = 0;
struct dm_list mdas;
const char *pv_name = pv_dev_name(pv);
- const char *vg_name;
+ const char *vg_name = pv_vg_name(pv);
struct lvmcache_info *info;
int mda_count = 0;
struct volume_group *old_vg = vg;
dm_list_init(&mdas);
- if (is_orphan_vg(pv_vg_name(pv))) {
- vg_name = VG_ORPHANS;
+ if (is_orphan_vg(vg_name)) {
if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) {
log_error("Can't get lock for orphans");
return 0;
@@ -56,8 +55,6 @@
mda_count = dm_list_size(&mdas);
} else {
- vg_name = pv_vg_name(pv);
-
vg = vg_read_for_update(cmd, vg_name, NULL, 0);
if (vg_read_error(vg)) {
@@ -70,7 +67,7 @@
if (!(pvl = find_pv_in_vg(vg, pv_name))) {
log_error("Unable to find \"%s\" in volume group \"%s\"",
pv_name, vg->name);
- goto bad;
+ goto out;
}
pv = pvl->pv;
@@ -78,31 +75,31 @@
if (!(info = info_from_pvid(pv->dev->pvid, 0))) {
log_error("Can't get info for PV %s in volume group %s",
pv_name, vg->name);
- goto bad;
+ goto out;
}
mda_count = dm_list_size(&info->mdas);
if (!archive(vg))
- goto bad;
+ goto out;
}
/* FIXME Create function to test compatibility properly */
if (mda_count > 1) {
log_error("%s: too many metadata areas for pvresize", pv_name);
- goto bad;
+ goto out;
}
if (!(pv->fmt->features & FMT_RESIZE_PV)) {
log_error("Physical volume %s format does not support resizing.",
pv_name);
- goto bad;
+ goto out;
}
/* Get new size */
if (!dev_get_size(pv_dev(pv), &size)) {
log_error("%s: Couldn't get size.", pv_name);
- goto bad;
+ goto out;
}
if (new_size) {
@@ -117,13 +114,13 @@
if (size < PV_MIN_SIZE) {
log_error("%s: Size must exceed minimum of %ld sectors.",
pv_name, PV_MIN_SIZE);
- goto bad;
+ goto out;
}
if (size < pv_pe_start(pv)) {
log_error("%s: Size must exceed physical extent start of "
"%" PRIu64 " sectors.", pv_name, pv_pe_start(pv));
- goto bad;
+ goto out;
}
pv->size = size;
@@ -137,34 +134,34 @@
"least one physical extent of "
"%" PRIu32 " sectors.", pv_name,
pv_pe_size(pv));
- goto bad;
+ goto out;
}
if (!pv_resize(pv, vg, new_pe_count))
- goto_bad;
+ goto_out;
}
log_verbose("Resizing volume \"%s\" to %" PRIu64 " sectors.",
pv_name, pv_size(pv));
log_verbose("Updating physical volume \"%s\"", pv_name);
- if (!is_orphan_vg(pv_vg_name(pv))) {
+ if (!is_orphan_vg(vg_name)) {
if (!vg_write(vg) || !vg_commit(vg)) {
log_error("Failed to store physical volume \"%s\" in "
"volume group \"%s\"", pv_name, vg->name);
- goto bad;
+ goto out;
}
backup(vg);
} else if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) {
log_error("Failed to store physical volume \"%s\"",
pv_name);
- goto bad;;
+ goto out;
}
log_print("Physical volume \"%s\" changed", pv_name);
r = 1;
-bad:
+out:
unlock_vg(cmd, vg_name);
if (!old_vg)
vg_release(vg);
^ permalink raw reply [flat|nested] 4+ messages in thread
* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/lock ...
@ 2010-05-19 0:52 agk
0 siblings, 0 replies; 4+ messages in thread
From: agk @ 2010-05-19 0:52 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2010-05-19 00:52:56
Modified files:
. : WHATS_NEW
lib/cache : lvmcache.c
lib/locking : cluster_locking.c file_locking.c locking.c
Log message:
Use is_orphan_vg in place of hard-coded prefix tests.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1562&r2=1.1563
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.86&r2=1.87
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.80&r2=1.81
--- LVM2/WHATS_NEW 2010/05/17 20:18:13 1.1562
+++ LVM2/WHATS_NEW 2010/05/19 00:52:55 1.1563
@@ -1,5 +1,6 @@
Version 2.02.66 -
===============================
+ Use is_orphan_vg in place of hard-coded prefix tests.
Version 2.02.65 - 17th May 2010
===============================
--- LVM2/lib/cache/lvmcache.c 2010/05/13 13:04:05 1.86
+++ LVM2/lib/cache/lvmcache.c 2010/05/19 00:52:55 1.87
@@ -224,11 +224,11 @@
/*
* Ensure vgname2 comes after vgname1 alphabetically.
- * Special VG names beginning with '#' don't count.
+ * Orphans don't count.
*/
static int _vgname_order_correct(const char *vgname1, const char *vgname2)
{
- if ((*vgname1 == '#') || (*vgname2 == '#'))
+ if (is_orphan_vg(vgname1) || is_orphan_vg(vgname2))
return 1;
if (strcmp(vgname1, vgname2) < 0)
--- LVM2/lib/locking/cluster_locking.c 2010/04/13 14:36:25 1.42
+++ LVM2/lib/locking/cluster_locking.c 2010/05/19 00:52:55 1.43
@@ -406,7 +406,7 @@
}
/* If the VG name is empty then lock the unused PVs */
- if (*resource == '#' || (flags & LCK_CACHE))
+ if (is_orphan_vg(resource) || (flags & LCK_CACHE))
dm_snprintf(lockname, sizeof(lockname), "P_%s",
resource);
else
--- LVM2/lib/locking/file_locking.c 2010/01/05 16:06:43 1.44
+++ LVM2/lib/locking/file_locking.c 2010/05/19 00:52:55 1.45
@@ -265,7 +265,7 @@
if (flags & LCK_CACHE)
break;
- if (*resource == '#')
+ if (is_orphan_vg(resource))
dm_snprintf(lockfile, sizeof(lockfile),
"%s/P_%s", _lock_dir, resource + 1);
else
--- LVM2/lib/locking/locking.c 2010/05/06 11:15:55 1.80
+++ LVM2/lib/locking/locking.c 2010/05/19 00:52:55 1.81
@@ -369,7 +369,7 @@
return 0;
}
- if (*resource == '#' && (flags & LCK_CACHE)) {
+ if (is_orphan_vg(resource) && (flags & LCK_CACHE)) {
log_error(INTERNAL_ERROR "P_%s referenced", resource);
return 0;
}
@@ -423,7 +423,7 @@
if (!_blocking_supported)
flags |= LCK_NONBLOCK;
- if (vol[0] != '#' &&
+ if (!is_orphan_vg(vol) &&
((flags & LCK_TYPE_MASK) != LCK_UNLOCK) &&
(!(flags & LCK_CACHE)) &&
!lvmcache_verify_lock_order(vol))
^ permalink raw reply [flat|nested] 4+ messages in thread
* LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/lock ...
@ 2008-04-03 18:56 agk
0 siblings, 0 replies; 4+ messages in thread
From: agk @ 2008-04-03 18:56 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2008-04-03 18:56:40
Modified files:
. : WHATS_NEW
lib/cache : lvmcache.c
lib/locking : file_locking.c
Log message:
Add some basic internal VG lock validation.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.821&r2=1.822
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35
--- LVM2/WHATS_NEW 2008/04/03 14:40:34 1.821
+++ LVM2/WHATS_NEW 2008/04/03 18:56:39 1.822
@@ -1,5 +1,6 @@
Version 2.02.34 -
===================================
+ Add some basic internal VG lock validation.
Add per-command flags to control which commands use the VG metadata cache.
Fix vgsplit locking of new VG (2.02.30).
Avoid erroneous vgsplit error message for new VG. (2.02.29)
--- LVM2/lib/cache/lvmcache.c 2008/04/02 21:23:39 1.41
+++ LVM2/lib/cache/lvmcache.c 2008/04/03 18:56:40 1.42
@@ -17,6 +17,7 @@
#include "lvmcache.h"
#include "toolcontext.h"
#include "dev-cache.h"
+#include "locking.h"
#include "metadata.h"
#include "filter.h"
#include "memlock.h"
@@ -29,6 +30,7 @@
static struct list _vginfos;
static int _has_scanned = 0;
static int _vgs_locked = 0;
+static int _vg_global_lock_held = 0; /* Global lock held when cache wiped? */
int lvmcache_init(void)
{
@@ -46,6 +48,9 @@
if (!(_lock_hash = dm_hash_create(128)))
return 0;
+ if (_vg_global_lock_held)
+ lvmcache_lock_vgname(VG_GLOBAL, 0);
+
return 1;
}
@@ -134,6 +139,10 @@
return;
}
+ if (dm_hash_lookup(_lock_hash, vgname))
+ log_error("Internal error: Nested locking attempted on VG %s.",
+ vgname);
+
if (!dm_hash_insert(_lock_hash, vgname, (void *) 1))
log_error("Cache locking failure for %s", vgname);
@@ -152,6 +161,10 @@
void lvmcache_unlock_vgname(const char *vgname)
{
+ if (!dm_hash_lookup(_lock_hash, vgname))
+ log_error("Internal error: Attempt to unlock unlocked VG %s.",
+ vgname);
+
_update_cache_lock_state(vgname, 0);
dm_hash_remove(_lock_hash, vgname);
@@ -1007,13 +1020,25 @@
} while ((vginfo = next));
}
-static void _lvmcache_destroy_lockname(int present __attribute((unused)))
+static void _lvmcache_destroy_lockname(struct dm_hash_node *n)
{
- /* Nothing to do */
+ char *vgname;
+
+ if (!dm_hash_get_data(_lock_hash, n))
+ return;
+
+ vgname = dm_hash_get_key(_lock_hash, n);
+
+ if (!strcmp(vgname, VG_GLOBAL))
+ _vg_global_lock_held = 1;
+ else
+ log_error("Internal error: Volume Group %s was not unlocked",
+ dm_hash_get_key(_lock_hash, n));
}
void lvmcache_destroy(void)
{
+ struct dm_hash_node *n;
log_verbose("Wiping internal VG cache");
_has_scanned = 0;
@@ -1037,7 +1062,8 @@
}
if (_lock_hash) {
- dm_hash_iter(_lock_hash, (dm_hash_iterate_fn) _lvmcache_destroy_lockname);
+ dm_hash_iterate(n, _lock_hash)
+ _lvmcache_destroy_lockname(n);
dm_hash_destroy(_lock_hash);
_lock_hash = NULL;
}
--- LVM2/lib/locking/file_locking.c 2008/01/30 13:59:59 1.34
+++ LVM2/lib/locking/file_locking.c 2008/04/03 18:56:40 1.35
@@ -221,7 +221,7 @@
"%s/V_%s", _lock_dir, resource);
if (!_lock_file(lockfile, flags))
- return 0;
+ return_0;
switch (flags & LCK_TYPE_MASK) {
case LCK_UNLOCK:
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-05-19 2:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-05-19 2:08 LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/lock agk
-- strict thread matches above, loose matches on Subject: below --
2010-05-19 1:16 agk
2010-05-19 0:52 agk
2008-04-03 18:56 agk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).