Skip to contentSkip to conversation

master - Implement lock-override options without locking type

PATCH David Teigland 1 participant 1 message Jun 6, 2018

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f2ff06d6756bb31779d16915c64361393054cfe7
Commit:        f2ff06d6756bb31779d16915c64361393054cfe7
Parent:        55521be2cbe28b0580fafafff6151cf4b6a219ea
Author:        David Teigland <[email protected]>
AuthorDate:    Wed Jun 6 16:31:59 2018 -0500
Committer:     David Teigland <[email protected]>
CommitterDate: Wed Jun 6 16:31:59 2018 -0500

Implement lock-override options without locking type

The options: --nolocking, --readonly, --sysinit override, or make exceptions to, the normal file locking behavior. Implement these by just checking for the options in the file locking path instead of using special locking types.

---
 lib/locking/file_locking.c  |    2 +-
 lib/locking/locking.c       |   58 +++++++++++++++++++++++++++++++++---------
 lib/locking/locking.h       |    2 +-
 lib/locking/locking_types.h |   18 +------------
 tools/lvmcmdline.c          |   52 +++++++++++++++++++-------------------
 5 files changed, 75 insertions(+), 57 deletions(-)
lib/locking/file_locking.c +1 -1
index a60a3e5..0bded0e 100644
@@ -92,7 +92,7 @@ int init_file_locking(struct locking_type *locking, struct cmd_context *cmd,
 	locking->lock_resource = _file_lock_resource;
 	locking->reset_locking = _reset_file_locking;
 	locking->fin_locking = _fin_file_locking;
-	locking->flags = 0;
+	locking->flags = LCK_FLOCK;
 
 	/* Get lockfile directory from config file */
 	locking_dir = find_config_tree_str(cmd, global_locking_dir_CFG, NULL);
lib/locking/locking.c +45 -13

107 lines not on this page · raw message

lib/locking/locking.h +1 -1
index 6d7d8e8..422f1d8 100644
@@ -21,7 +21,7 @@
 
 struct logical_volume;
 
-int init_locking(int type, struct cmd_context *cmd, int suppress_messages);
+int init_locking(struct cmd_context *cmd, int suppress_messages, int only_read_locks);
 void fin_locking(void);
 void reset_locking(void);
 int vg_write_lock_held(void);
lib/locking/locking_types.h +2 -16
index 99aa964..5bb4fe4 100644
@@ -23,12 +23,10 @@ typedef int (*query_resource_fn) (const char *resource, const char *node, int *m
 typedef void (*fin_lock_fn) (void);
 typedef void (*reset_lock_fn) (void);
 
-#define LCK_PRE_MEMLOCK			0x00000001	/* Is memlock() needed before calls? */
-#define LCK_CLUSTERED			0x00000002
-#define LCK_SUPPORTS_REMOTE_QUERIES	0x00000004
+#define LCK_FLOCK			0x00000001
 
 struct locking_type {
-	uint32_t flags;
+	uint32_t flags;   /* 0 means file locking is disabled */
 	lock_resource_fn lock_resource;
 	query_resource_fn query_resource;
 
@@ -36,17 +34,5 @@ struct locking_type {
 	fin_lock_fn fin_locking;
 };
 
-/*
- * Locking types
- */
-void init_no_locking(struct locking_type *locking, struct cmd_context *cmd,
-		     int suppress_messages);
-
-void init_dummy_locking(struct locking_type *locking, struct cmd_context *cmd,
-			int suppress_messages);
-
-int init_readonly_locking(struct locking_type *locking, struct cmd_context *cmd,
-			  int suppress_messages);
-
 int init_file_locking(struct locking_type *locking, struct cmd_context *cmd,
 		      int suppress_messages);
tools/lvmcmdline.c +26 -26

66 lines not on this page · raw message