diff options
author | Alasdair G Kergon <agk@redhat.com> | 2016-01-19 21:42:22 +0000 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2016-01-19 21:42:22 +0000 |
commit | c812c2dbc7ced09a715e5689f941ba255821f0bc (patch) | |
tree | a78d6d001472a5c8dba3e81afd12a57f3bc61c5e | |
parent | 7f6a1e6bbac41bb5d0e18876c23a7442c8c0d263 (diff) | |
download | lvm2-c812c2dbc7ced09a715e5689f941ba255821f0bc.tar.gz |
locking: Add node parameter to query_resource.
-rw-r--r-- | daemons/clvmd/clvm.h | 8 | ||||
-rw-r--r-- | lib/activate/activate.c | 2 | ||||
-rw-r--r-- | lib/locking/cluster_locking.c | 7 | ||||
-rw-r--r-- | lib/locking/locking.c | 4 | ||||
-rw-r--r-- | lib/locking/locking.h | 7 | ||||
-rw-r--r-- | lib/locking/locking_types.h | 2 | ||||
-rw-r--r-- | lib/locking/no_locking.c | 2 |
7 files changed, 19 insertions, 13 deletions
diff --git a/daemons/clvmd/clvm.h b/daemons/clvmd/clvm.h index 716af4027..10ef852fc 100644 --- a/daemons/clvmd/clvm.h +++ b/daemons/clvmd/clvm.h @@ -76,8 +76,10 @@ static const char CLVMD_SOCKNAME[]= DEFAULT_RUN_DIR "/clvmd.sock"; #define CLVMD_CMD_SYNC_NAMES 45 /* Used internally by some callers, but not part of the protocol.*/ -#define NODE_ALL "*" -#define NODE_LOCAL "." -#define NODE_REMOTE "^" +#ifndef NODE_ALL +# define NODE_ALL "*" +# define NODE_LOCAL "." +# define NODE_REMOTE "^" +#endif #endif diff --git a/lib/activate/activate.c b/lib/activate/activate.c index 8f5b72b19..4cd268eaf 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -1371,7 +1371,7 @@ static int _lv_is_active(const struct logical_volume *lv, if (l && !exclusive) goto out; - if ((r = remote_lock_held(lv->lvid.s, &e)) >= 0) + if ((r = cluster_lock_held(lv->lvid.s, "", &e)) >= 0) goto out; /* diff --git a/lib/locking/cluster_locking.c b/lib/locking/cluster_locking.c index 800f33d3e..517d09c89 100644 --- a/lib/locking/cluster_locking.c +++ b/lib/locking/cluster_locking.c @@ -34,7 +34,7 @@ #ifndef CLUSTER_LOCKING_INTERNAL int lock_resource(struct cmd_context *cmd, const char *resource, uint32_t flags, const struct logical_volume *lv __attribute__((unused))); -int query_resource(const char *resource, int *mode); +int query_resource(const char *resource, const char *node, int *mode); void locking_end(void); int locking_init(int type, struct dm_config_tree *cf, uint32_t *flags); #endif @@ -530,13 +530,12 @@ static int decode_lock_type(const char *response) } #ifdef CLUSTER_LOCKING_INTERNAL -static int _query_resource(const char *resource, int *mode) +static int _query_resource(const char *resource, const char *node, int *mode) #else -int query_resource(const char *resource, int *mode) +int query_resource(const char *resource, const char *node, int *mode) #endif { int i, status, len, num_responses, saved_errno; - const char *node = ""; char *args; lvm_response_t *response = NULL; diff --git a/lib/locking/locking.c b/lib/locking/locking.c index 22e83d2b1..a11c09b35 100644 --- a/lib/locking/locking.c +++ b/lib/locking/locking.c @@ -498,7 +498,7 @@ int locking_supports_remote_queries(void) return (_locking.flags & LCK_SUPPORTS_REMOTE_QUERIES) ? 1 : 0; } -int remote_lock_held(const char *vol, int *exclusive) +int cluster_lock_held(const char *vol, const char *node, int *exclusive) { int mode = LCK_NULL; @@ -511,7 +511,7 @@ int remote_lock_held(const char *vol, int *exclusive) /* * If an error occured, expect that volume is active */ - if (!_locking.query_resource(vol, &mode)) { + if (!_locking.query_resource(vol, node, &mode)) { stack; return 1; } diff --git a/lib/locking/locking.h b/lib/locking/locking.h index 706b59e92..cb4f92312 100644 --- a/lib/locking/locking.h +++ b/lib/locking/locking.h @@ -28,7 +28,12 @@ int vg_write_lock_held(void); int locking_is_clustered(void); int locking_supports_remote_queries(void); -int remote_lock_held(const char *vol, int *exclusive); +#ifndef NODE_ALL +# define NODE_ALL "*" +# define NODE_LOCAL "." +# define NODE_REMOTE "^" +#endif +int cluster_lock_held(const char *vol, const char *node, int *exclusive); /* * LCK_VG: diff --git a/lib/locking/locking_types.h b/lib/locking/locking_types.h index 64d13dbd6..5f0cd6b5f 100644 --- a/lib/locking/locking_types.h +++ b/lib/locking/locking_types.h @@ -18,7 +18,7 @@ typedef int (*lock_resource_fn) (struct cmd_context * cmd, const char *resource, uint32_t flags, const struct logical_volume *lv); -typedef int (*query_resource_fn) (const char *resource, int *mode); +typedef int (*query_resource_fn) (const char *resource, const char *node, int *mode); typedef void (*fin_lock_fn) (void); typedef void (*reset_lock_fn) (void); diff --git a/lib/locking/no_locking.c b/lib/locking/no_locking.c index 6b0ac6343..e909a2436 100644 --- a/lib/locking/no_locking.c +++ b/lib/locking/no_locking.c @@ -70,7 +70,7 @@ static int _no_lock_resource(struct cmd_context *cmd, const char *resource, return 1; } -static int _no_query_resource(const char *resource, int *mode) +static int _no_query_resource(const char *resource, const char *node, int *mode) { log_very_verbose("Locking is disabled: Treating lock %s as not held.", resource); |