Skip to contentSkip to conversation

master - Rework lock-override options and locking_type settings

PATCH David Teigland 1 participant 1 message Jun 7, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e6bb780d24246666fa05948ec449a8137280b443
Commit:        e6bb780d24246666fa05948ec449a8137280b443
Parent:        c7c7017f0c12ebab4e1aef9d9a9fabd4ec2adfe3
Author:        David Teigland <[email protected]>
AuthorDate:    Thu Jun 7 15:33:02 2018 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Thu Jun 7 16:47:15 2018 -0500

Rework lock-override options and locking_type settings

The last commit related to this was incomplete:
"Implement lock-override options without locking type"

This is further reworking and reduction of the locking.[ch] layer which handled all clustering, but is now only used for file locking. The "locking types" that this layer implemented were removed previously, leaving only the standard file locking. (Some cluster-related artifacts remain to be cleared out later.)

Command options to override or modify locking behavior are reimplemented here without using the locking types. Also, deprecated locking_type values are recognized, and implemented as if one of the equivalent override options was set.

Options that override file locking are:

. --nolocking disables all file locking.

. --readonly grants read lock requests without actually
taking a file lock, and refuses write lock requests.

. --ignorelockingfailure tries to set up file locks and
uses them normally if possible. When not possible, it behaves like --readonly, but allows activation.

. --sysinit is the same as ignorelockingfailure.

. global/metadata_read_only acquires actual read file
locks, and refuses write lock requests.

(Some of these options could probably be deprecated because they were added as workarounds to various locking_type behaviors that are now deprecated.)

The locking_type setting now has one valid value: 1 which refers to standard file locking. Configs that contain deprecated values are recognized and still work in largely the same way:

. 0 disabled all locking, now implemented like --nolocking
is set. Allow the nolocking option in all commands.

. 1 is the normal file locking setting and is unchanged.

. 2 was for external locking which was not used, and
reverts to normal file locking.

. 3 was for cluster/clvm. This reverts to normal file
locking, and prints messages about lvmlockd.

. 4 was equivalent to readonly, now implemented like
--readonly is set.

. 5 disabled all locking, now implemented like
--nolocking is set.

---
 lib/commands/toolcontext.h   |    1 +
 lib/config/config_settings.h |   43 +--------
 lib/locking/locking.c        |  216 ++++++++++++++++++++++++------------------
 lib/locking/locking.h        |    2 +-
 lib/misc/lvm-globals.c       |   11 --
 lib/misc/lvm-globals.h       |    4 -
 lib/misc/sharedlib.c         |    2 +-
 tools/command-lines.in       |    4 +-
 tools/lvmcmdline.c           |   53 ++++++-----
 9 files changed, 163 insertions(+), 173 deletions(-)
lib/commands/toolcontext.h +1 -0
index b46e301..fee35d4 100644
@@ -172,6 +172,7 @@ struct cmd_context {
 	unsigned can_use_one_scan:1;
 	unsigned is_clvmd:1;
 	unsigned use_full_md_check:1;
+	unsigned is_activating:1;
 
 	/*
 	 * Filtering.
lib/config/config_settings.h +4 -39

62 lines not on this page · raw message

lib/locking/locking.c +125 -91

278 lines not on this page · raw message

lib/locking/locking.h +1 -1
index 422f1d8..96f7d86 100644
@@ -21,7 +21,7 @@
 
 struct logical_volume;
 
-int init_locking(struct cmd_context *cmd, int suppress_messages, int only_read_locks);
+int init_locking(struct cmd_context *cmd, int file_locking_sysinit, int file_locking_readonly, int file_locking_ignorefail);
 void fin_locking(void);
 void reset_locking(void);
 int vg_write_lock_held(void);
lib/misc/lvm-globals.c +0 -11
index b76ddb9..9377588 100644
@@ -34,7 +34,6 @@ static int _trust_cache = 0; /* Don't scan when incomplete VGs encountered */
 static int _debug_level = 0;
 static int _debug_classes_logged = 0;
 static int _log_cmd_name = 0;
-static int _ignorelockingfailure = 0;
 static int _security_level = SECURITY_LEVEL;
 static char _cmd_name[30] = "";
 static int _mirror_in_sync = 0;
@@ -106,11 +105,6 @@ void init_trust_cache(int trustcache)
 	_trust_cache = trustcache;
 }
 
-void init_ignorelockingfailure(int level)
-{
-	_ignorelockingfailure = level;
-}
-
 void init_security_level(int level)
 {
 	_security_level = level;
@@ -267,11 +261,6 @@ int background_polling(void)
 	return _background_polling;
 }
 
-int ignorelockingfailure(void)
-{
-	return _ignorelockingfailure;
-}
-
 int security_level(void)
 {
 	return _security_level;
lib/misc/lvm-globals.h +0 -4
index b383891..55a9399 100644
@@ -35,8 +35,6 @@ void init_trust_cache(int trustcache);
 void init_debug(int level);
 void init_debug_classes_logged(int classes);
 void init_cmd_name(int status);
-void init_ignorelockingfailure(int level);
-void init_lockingfailed(int level);
 void init_security_level(int level);
 void init_mirror_in_sync(int in_sync);
 void init_dmeventd_monitor(int reg);
@@ -69,8 +67,6 @@ int verbose_level(void);
 int silent_mode(void);
 int debug_level(void);
 int debug_class_is_logged(int class);
-int ignorelockingfailure(void);
-int lockingfailed(void);
 int security_level(void);
 int mirror_in_sync(void);
 int background_polling(void);
lib/misc/sharedlib.c +1 -1
index d594470..4c2d5d9 100644
@@ -58,7 +58,7 @@ void *load_shared_library(struct cmd_context *cmd, const char *libname,
 	log_very_verbose("Opening shared %s library %s", desc, path);
 
 	if (!(library = dlopen(path, RTLD_LAZY | RTLD_GLOBAL))) {
-		if (silent && ignorelockingfailure())
+		if (silent)
 			log_verbose("Unable to open external %s library %s: %s",
 				    desc, path, dlerror());
 		else
tools/command-lines.in +2 -2
index 409f01c..ad710a4 100644
@@ -187,7 +187,7 @@
 # OO_ALL is included in every command automatically.
 #
 OO_ALL: --commandprofile String, --config String, --debug,
---driverloaded Bool, --help, --lockopt String, --longhelp, --profile String, --quiet,
+--driverloaded Bool, --help, --nolocking, --lockopt String, --longhelp, --profile String, --quiet,
 --verbose, --version, --yes, --test
 
 #
@@ -195,7 +195,7 @@ OO_ALL: --commandprofile String, --config String, --debug,
 #
 OO_REPORT: --aligned, --all, --binary, --configreport ConfigReport, --foreign,
 --ignorelockingfailure, --ignoreskippedcluster, --logonly,
---nameprefixes, --noheadings, --nolocking, --nosuffix,
+--nameprefixes, --noheadings, --nosuffix,
 --options String, --readonly, --reportformat ReportFmt, --rows,
 --select String, --separator String, --shared, --sort String,
 --trustcache, --unbuffered, --units Units, --unquoted
tools/lvmcmdline.c +29 -24

83 lines not on this page · raw message