public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 lib/locking/locking.c lib/locking/locking ...
@ 2009-07-15 5:49 mornfall
0 siblings, 0 replies; 3+ messages in thread
From: mornfall @ 2009-07-15 5:49 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: mornfall@sourceware.org 2009-07-15 05:49:48
Modified files:
lib/locking : locking.c locking_types.h no_locking.c
lib/metadata : metadata.c
lib/misc : lvm-globals.c
tools : lvchange.c vgchange.c
Log message:
Remove lockingfailed().
We provide a lock type that behaves like no_locking, but is not
clustered. Moreover, it also forbids any write locks. This magically (and
consistently) prevents use of clustered VGs, or changing local VGs with
--ignorelockingfailure. As a bonus, we can remove the special hacks in a few
places. Of course, people looking for trouble can always set their locking_type
to 0 to override.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking_types.h.diff?cvsroot=lvm2&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/no_locking.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.251&r2=1.252
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-globals.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.107&r2=1.108
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.81&r2=1.82
--- LVM2/lib/locking/locking.c 2009/07/14 11:01:26 1.61
+++ LVM2/lib/locking/locking.c 2009/07/15 05:49:47 1.62
@@ -215,8 +215,6 @@
*/
int init_locking(int type, struct cmd_context *cmd)
{
- init_lockingfailed(0);
-
if (type < 0)
type = find_config_tree_int(cmd, "global/locking_type", 1);
@@ -279,9 +277,7 @@
/* FIXME Ensure only read ops are permitted */
log_verbose("Locking disabled - only read operations permitted.");
-
- init_no_locking(&_locking, cmd);
- init_lockingfailed(1);
+ init_readonly_locking(&_locking, cmd);
return 1;
}
--- LVM2/lib/locking/locking_types.h 2009/05/21 03:04:53 1.17
+++ LVM2/lib/locking/locking_types.h 2009/07/15 05:49:48 1.18
@@ -40,6 +40,8 @@
*/
int init_no_locking(struct locking_type *locking, struct cmd_context *cmd);
+int init_boottime_locking(struct locking_type *locking, struct cmd_context *cmd);
+
int init_file_locking(struct locking_type *locking, struct cmd_context *cmd);
int init_external_locking(struct locking_type *locking, struct cmd_context *cmd);
--- LVM2/lib/locking/no_locking.c 2008/04/07 19:17:29 1.15
+++ LVM2/lib/locking/no_locking.c 2009/07/15 05:49:48 1.16
@@ -66,6 +66,17 @@
return 1;
}
+static int _readonly_lock_resource(struct cmd_context *cmd,
+ const char *resource,
+ uint32_t flags)
+{
+ if (flags & LCK_TYPE_MASK == LCK_WRITE) {
+ log_error("Write locks are prohibited with --ignorelockingfailure.");
+ return 0;
+ }
+ return _no_lock_resource(cmd, resource, flags);
+}
+
int init_no_locking(struct locking_type *locking, struct cmd_context *cmd __attribute((unused)))
{
locking->lock_resource = _no_lock_resource;
@@ -75,3 +86,13 @@
return 1;
}
+
+int init_readonly_locking(struct locking_type *locking, struct cmd_context *cmd __attribute((unused)))
+{
+ locking->lock_resource = _readonly_lock_resource;
+ locking->reset_locking = _no_reset_locking;
+ locking->fin_locking = _no_fin_locking;
+ locking->flags = 0;
+
+ return 1;
+}
--- LVM2/lib/metadata/metadata.c 2009/07/15 05:47:55 1.251
+++ LVM2/lib/metadata/metadata.c 2009/07/15 05:49:48 1.252
@@ -2772,8 +2772,7 @@
uint32_t failure = 0;
if ((status & CLUSTERED) &&
- (vg_is_clustered(vg)) && !locking_is_clustered() &&
- !lockingfailed()) {
+ (vg_is_clustered(vg)) && !locking_is_clustered()) {
log_error("Skipping clustered volume group %s", vg->name);
/* Return because other flags are considered undefined. */
return FAILED_CLUSTERED;
@@ -2922,8 +2921,7 @@
goto_bad;
}
- if (vg_is_clustered(vg) && !locking_is_clustered() &&
- !lockingfailed()) {
+ if (vg_is_clustered(vg) && !locking_is_clustered()) {
log_error("Skipping clustered volume group %s", vg->name);
failure |= FAILED_CLUSTERED;
goto_bad;
--- LVM2/lib/misc/lvm-globals.c 2008/12/18 05:27:18 1.2
+++ LVM2/lib/misc/lvm-globals.c 2009/07/15 05:49:48 1.3
@@ -31,7 +31,6 @@
static int _debug_level = 0;
static int _log_cmd_name = 0;
static int _ignorelockingfailure = 0;
-static int _lockingfailed = 0;
static int _security_level = SECURITY_LEVEL;
static char _cmd_name[30] = "";
static int _mirror_in_sync = 0;
@@ -77,11 +76,6 @@
_ignorelockingfailure = level;
}
-void init_lockingfailed(int level)
-{
- _lockingfailed = level;
-}
-
void init_security_level(int level)
{
_security_level = level;
@@ -161,11 +155,6 @@
return _trust_cache;
}
-int lockingfailed()
-{
- return _lockingfailed;
-}
-
int ignorelockingfailure()
{
return _ignorelockingfailure;
--- LVM2/tools/lvchange.c 2009/07/15 05:48:36 1.107
+++ LVM2/tools/lvchange.c 2009/07/15 05:49:48 1.108
@@ -119,12 +119,6 @@
if (!deactivate_lv(cmd, lv))
return_0;
} else {
- if (lockingfailed() && (vg_is_clustered(lv->vg))) {
- log_verbose("Locking failed: ignoring clustered "
- "logical volume %s", lv->name);
- return 0;
- }
-
if (lv_is_origin(lv) || (activate == CHANGE_AE)) {
log_verbose("Activating logical volume \"%s\" "
"exclusively", lv->name);
--- LVM2/tools/vgchange.c 2009/07/15 05:47:55 1.81
+++ LVM2/tools/vgchange.c 2009/07/15 05:49:48 1.82
@@ -144,14 +144,8 @@
return ECMD_FAILED;
}
- if (activate && lockingfailed() && (vg_is_clustered(vg))) {
- log_error("Locking inactive: ignoring clustered "
- "volume group %s", vg->name);
- return ECMD_FAILED;
- }
-
/* FIXME Move into library where clvmd can use it */
- if (activate && !lockingfailed())
+ if (activate)
check_current_backup(vg);
if (activate && (active = lvs_in_vg_activated(vg))) {
^ permalink raw reply [flat|nested] 3+ messages in thread
* LVM2 lib/locking/locking.c lib/locking/locking ...
@ 2007-11-15 21:30 agk
0 siblings, 0 replies; 3+ messages in thread
From: agk @ 2007-11-15 21:30 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2007-11-15 21:30:52
Modified files:
lib/locking : locking.c locking.h
tools : pvdisplay.c toollib.c vgreduce.c
Log message:
more vg_read lock fixes
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.36&r2=1.37
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvdisplay.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.116&r2=1.117
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.70&r2=1.71
--- LVM2/lib/locking/locking.c 2007/11/02 13:06:41 1.41
+++ LVM2/lib/locking/locking.c 2007/11/15 21:30:52 1.42
@@ -335,6 +335,11 @@
{
char resource[258] __attribute((aligned(8)));
+ if (flags == LCK_NONE) {
+ log_debug("Internal error: %s: LCK_NONE lock requested", vol);
+ return 1;
+ }
+
switch (flags & LCK_SCOPE_MASK) {
case LCK_VG:
/* Lock VG to change on-disk metadata. */
--- LVM2/lib/locking/locking.h 2007/11/15 02:55:22 1.36
+++ LVM2/lib/locking/locking.h 2007/11/15 21:30:52 1.37
@@ -86,7 +86,7 @@
/*
* Common combinations
*/
-#define LCK_NONE 0
+#define LCK_NONE (LCK_VG | LCK_NULL)
#define LCK_VG_READ (LCK_VG | LCK_READ | LCK_HOLD)
#define LCK_VG_WRITE (LCK_VG | LCK_WRITE | LCK_HOLD)
--- LVM2/tools/pvdisplay.c 2007/11/15 02:20:03 1.43
+++ LVM2/tools/pvdisplay.c 2007/11/15 21:30:52 1.44
@@ -31,6 +31,7 @@
if (!(vg = vg_lock_and_read(cmd, vg_name, (char *)&pv->vgid,
LCK_VG_READ, CLUSTERED, 0))) {
log_error("Skipping volume group %s", vg_name);
+ /* FIXME If CLUSTERED should return ECMD_PROCESSED here */
return ECMD_FAILED;
}
--- LVM2/tools/toollib.c 2007/11/15 02:20:03 1.116
+++ LVM2/tools/toollib.c 2007/11/15 21:30:52 1.117
@@ -443,10 +443,9 @@
if (ret > ret_max)
ret_max = ret;
if (sigint_caught())
- return ret_max;
+ break;
}
-out:
if (vg_name)
unlock_vg(cmd, vg_name);
@@ -747,8 +746,15 @@
if (sigint_caught())
return ret_max;
}
- if (!list_empty(&tags) && (vgnames = get_vgs(cmd, 0)) &&
- !list_empty(vgnames)) {
+ if (vg) {
+ ret = process_each_pv_in_vg(cmd, vg, &tags,
+ handle, process_single);
+ if (ret > ret_max)
+ ret_max = ret;
+ if (sigint_caught())
+ return ret_max;
+ } else if (!list_empty(&tags) && (vgnames = get_vgs(cmd, 0)) &&
+ !list_empty(vgnames)) {
list_iterate_items(sll, vgnames) {
if (!lock_vol(cmd, sll->str, lock_type)) {
log_error("Can't lock %s: skipping", sll->str);
--- LVM2/tools/vgreduce.c 2007/11/14 18:41:05 1.70
+++ LVM2/tools/vgreduce.c 2007/11/15 21:30:52 1.71
@@ -539,7 +539,7 @@
/* FIXME: Pass private struct through to all these functions */
/* and update in batch here? */
- ret = process_each_pv(cmd, argc, argv, vg, LCK_VG_WRITE, NULL,
+ ret = process_each_pv(cmd, argc, argv, vg, LCK_NONE, NULL,
_vgreduce_single);
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* LVM2 lib/locking/locking.c lib/locking/locking ...
@ 2007-06-15 20:46 agk
0 siblings, 0 replies; 3+ messages in thread
From: agk @ 2007-06-15 20:46 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2007-06-15 20:46:05
Modified files:
lib/locking : locking.c locking.h
man : vgcfgrestore.8 vgrename.8
Log message:
pre-release
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.31&r2=1.32
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/vgcfgrestore.8.diff?cvsroot=lvm2&r1=1.4&r2=1.5
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/vgrename.8.diff?cvsroot=lvm2&r1=1.3&r2=1.4
--- LVM2/lib/locking/locking.c 2007/06/15 10:11:14 1.36
+++ LVM2/lib/locking/locking.c 2007/06/15 20:46:04 1.37
@@ -44,46 +44,50 @@
_sigint_caught = 1;
}
-int sigint_caught() {
+int sigint_caught(void) {
return _sigint_caught;
}
-void sigint_clear()
+void sigint_clear(void)
{
_sigint_caught = 0;
}
-/* Temporarily allow keyboard interrupts to be intercepted and noted;
- saves interrupt handler state for sigint_restore(). Users should
- use the sigint_caught() predicate to check whether interrupt was
- requested and act appropriately. Interrupt flags are never
- automatically cleared by this code, but lvm_run_command() clears
- the flag before running any command. All other places where the
- flag needs to be cleared need to call sigint_clear(). */
+/*
+ * Temporarily allow keyboard interrupts to be intercepted and noted;
+ * saves interrupt handler state for sigint_restore(). Users should
+ * use the sigint_caught() predicate to check whether interrupt was
+ * requested and act appropriately. Interrupt flags are never
+ * cleared automatically by this code, but the tools clear the flag
+ * before running each command in lvm_run_command(). All other places
+ * where the flag needs to be cleared need to call sigint_clear().
+ */
-void sigint_allow()
+void sigint_allow(void)
{
struct sigaction handler;
sigset_t sigs;
- /* do not overwrite the backed up handler data with our
- override ones; we just increase nesting count */
+ /*
+ * Do not overwrite the backed-up handler data -
+ * just increase nesting count.
+ */
if (_handler_installed) {
_handler_installed++;
return;
}
- /* grab old sigaction for SIGINT; shall not fail */
+ /* Grab old sigaction for SIGINT: shall not fail. */
sigaction(SIGINT, NULL, &handler);
- handler.sa_flags &= ~SA_RESTART; /* clear restart flag */
+ handler.sa_flags &= ~SA_RESTART; /* Clear restart flag */
handler.sa_handler = _catch_sigint;
_handler_installed = 1;
- /* override the signal handler; shall not fail */
+ /* Override the signal handler: shall not fail. */
sigaction(SIGINT, &handler, &_oldhandler);
- /* unmask SIGINT, remember to mask it again on restore */
+ /* Unmask SIGINT. Remember to mask it again on restore. */
sigprocmask(0, NULL, &sigs);
if ((_oldmasked = sigismember(&sigs, SIGINT))) {
sigdelset(&sigs, SIGINT);
@@ -91,9 +95,8 @@
}
}
-void sigint_restore()
+void sigint_restore(void)
{
- /* extra call, ignore */
if (!_handler_installed)
return;
@@ -102,7 +105,7 @@
return;
}
- /* nesting count went down to 0 */
+ /* Nesting count went down to 0. */
_handler_installed = 0;
if (_oldmasked) {
--- LVM2/lib/locking/locking.h 2007/06/15 10:11:14 1.31
+++ LVM2/lib/locking/locking.h 2007/06/15 20:46:04 1.32
@@ -115,11 +115,10 @@
int resume_lvs(struct cmd_context *cmd, struct list *lvs);
int activate_lvs_excl(struct cmd_context *cmd, struct list *lvs);
-/* interrupt handling */
-
-void sigint_clear();
-void sigint_allow();
-void sigint_restore();
-int sigint_caught();
+/* Interrupt handling */
+void sigint_clear(void);
+void sigint_allow(void);
+void sigint_restore(void);
+int sigint_caught(void);
#endif
--- LVM2/man/vgcfgrestore.8 2007/06/15 16:05:57 1.4
+++ LVM2/man/vgcfgrestore.8 2007/06/15 20:46:04 1.5
@@ -14,10 +14,10 @@
.SH DESCRIPTION
.B vgcfgrestore
allows you to restore the metadata of \fIVolumeGroupName\fP from a text
-backup file produced by \fBvgcfgbackup\fP. You can specify a backup file to
-use with the \fP-f\fP option. If no backup file is specified, the latest
-backup file is used. A list of backup and archive files of
-\fIVolumeGroupName\fP may be listed with the \fB-l\fP option.
+backup file produced by \fBvgcfgbackup\fP. You can specify a backup file
+with \fP--file\fP. If no backup file is specified, the most recent
+one is used. Use \fB--list\fP for a list of the available
+backup and archive files of \fIVolumeGroupName\fP.
.SH OPTIONS
.TP
\fB-l | --list\fP \(em List files pertaining to \fIVolumeGroupName\fP
--- LVM2/man/vgrename.8 2007/05/22 02:51:33 1.3
+++ LVM2/man/vgrename.8 2007/06/15 20:46:04 1.4
@@ -25,7 +25,22 @@
.TP
"vgrename vg02 my_volume_group" does the same.
.TP
-"vgrename Zvlifi-Ep3t-e0Ng-U42h-o0ye-KHu1-nl7Ns4 VolGroup00_tmp" renames a volume group with UUID Zvlifi-Ep3t-e0Ng-U42h-o0ye-KHu1-nl7Ns4 to the volume group named "VolGroup00_tmp". Using the UUID option to name a volume group may be useful in cases where one machine has two physical volumes, each with the same volume group name, but a separate volume group UUID (this situation will cause error messages with lvm commands). One way duplicate volume group names occur is if an old disk with a root volume is moved to a new machine with its own root volume. In this case, both volume groups may have the same name (for example, "VolGroup00"), but different UUIDs.
+"vgrename Zvlifi-Ep3t-e0Ng-U42h-o0ye-KHu1-nl7Ns4 VolGroup00_tmp"
+changes the name of the Volume Group with UUID
+Zvlifi-Ep3t-e0Ng-U42h-o0ye-KHu1-nl7Ns4 to
+"VolGroup00_tmp".
+
+All the Volume Groups visible to a system need to have different
+names. Otherwise many LVM2 commands will refuse to run or give
+warning messages.
+
+This situation could arise when disks are moved between machines. If
+a disk is connected and it contains a Volume Group with the same name
+as the Volume Group containing your root filesystem the machine might
+not even boot correctly. However, the two Volume Groups should have
+different UUIDs (unless the disk was cloned) so you can rename
+one of the conflicting Volume Groups with
+\fBvgrename\fP.
.TP
.SH SEE ALSO
.BR lvm (8),
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2009-07-15 5:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-15 5:49 LVM2 lib/locking/locking.c lib/locking/locking mornfall
-- strict thread matches above, loose matches on Subject: below --
2007-11-15 21:30 agk
2007-06-15 20:46 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).