master - lv: lv_active_change add needs_exclusive flag
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a3a2c792a87054...
Commit: a3a2c792a87054ab78a1b8e54b99db1c24739fb8
Parent: a82dcadf66dbd43a43d3be40cd62a5074248d218
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Nov 5 15:14:58 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Nov 5 15:29:43 2014 +0100
lv: lv_active_change add needs_exclusive flag
Let's use this function for more activations in the code.
'needs_exlusive' will enforce exlusive type for any given LV.
We may want to activate LV in exlusive mode, even when we know
the LV (as is) supports non-exlusive activation as well.
lvcreate -ay -> exclusive & local
lvcreate -aay -> exclusive & local
lvcreate -aly -> exclusive & local
lvcreate -aey -> exclusive (might be on any node).
---
lib/metadata/lv.c | 8 ++++----
lib/metadata/lv.h | 2 +-
lib/metadata/lv_manip.c | 4 ++--
tools/lvchange.c | 2 +-
tools/toollib.c | 2 +-
5 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 92b38f4..ed21894 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -866,7 +866,7 @@ static int _lv_is_exclusive(struct logical_volume *lv)
}
int lv_active_change(struct cmd_context *cmd, struct logical_volume *lv,
- enum activation_change activate)
+ enum activation_change activate, int needs_exclusive)
{
switch (activate) {
case CHANGE_AN:
@@ -876,7 +876,7 @@ deactivate:
return_0;
break;
case CHANGE_ALN:
- if (vg_is_clustered(lv->vg) && _lv_is_exclusive(lv)) {
+ if (vg_is_clustered(lv->vg) && (needs_exclusive || _lv_is_exclusive(lv))) {
if (!lv_is_active_locally(lv)) {
log_error("Cannot deactivate remotely exclusive device locally.");
return 0;
@@ -891,7 +891,7 @@ deactivate:
break;
case CHANGE_ALY:
case CHANGE_AAY:
- if (_lv_is_exclusive(lv)) {
+ if (needs_exclusive || _lv_is_exclusive(lv)) {
log_verbose("Activating logical volume \"%s\" exclusively locally.",
lv->name);
if (!activate_lv_excl_local(cmd, lv))
@@ -911,7 +911,7 @@ exclusive:
return_0;
break;
default: /* CHANGE_AY */
- if (_lv_is_exclusive(lv))
+ if (needs_exclusive || _lv_is_exclusive(lv))
goto exclusive;
log_verbose("Activating logical volume \"%s\".", lv->name);
if (!activate_lv(cmd, lv))
diff --git a/lib/metadata/lv.h b/lib/metadata/lv.h
index 2261913..8064ba2 100644
--- a/lib/metadata/lv.h
+++ b/lib/metadata/lv.h
@@ -94,7 +94,7 @@ int lv_set_creation(struct logical_volume *lv,
const char *hostname, uint64_t timestamp);
const char *lv_layer(const struct logical_volume *lv);
int lv_active_change(struct cmd_context *cmd, struct logical_volume *lv,
- enum activation_change activate);
+ enum activation_change activate, int needs_exlusive);
char *lv_active_dup(struct dm_pool *mem, const struct logical_volume *lv);
const struct logical_volume *lv_lock_holder(const struct logical_volume *lv);
const struct logical_volume *lv_ondisk(const struct logical_volume *lv);
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 6cf51f9..30188e4 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -7051,7 +7051,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
backup(vg);
- if (!lv_active_change(cmd, lv, lp->activate)) {
+ if (!lv_active_change(cmd, lv, lp->activate, 0)) {
log_error("Failed to activate thin %s.", lv->name);
goto deactivate_and_revert_new_lv;
}
@@ -7070,7 +7070,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
"exception store.");
goto revert_new_lv;
}
- } else if (!lv_active_change(cmd, lv, lp->activate)) {
+ } else if (!lv_active_change(cmd, lv, lp->activate, 0)) {
log_error("Failed to activate new LV.");
goto deactivate_and_revert_new_lv;
}
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 99dba82..e0bb4b1 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -593,7 +593,7 @@ static int lvchange_persistent(struct cmd_context *cmd,
if (activate != CHANGE_AN) {
log_verbose("Re-activating logical volume %s", display_lvname(lv));
- if (!lv_active_change(cmd, lv, activate)) {
+ if (!lv_active_change(cmd, lv, activate, 0)) {
log_error("%s: reactivation failed", display_lvname(lv));
backup(lv->vg);
return 0;
diff --git a/tools/toollib.c b/tools/toollib.c
index 5906ccb..596dba5 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -731,7 +731,7 @@ int lv_change_activate(struct cmd_context *cmd, struct logical_volume *lv,
}
}
- if (!lv_active_change(cmd, lv, activate))
+ if (!lv_active_change(cmd, lv, activate, 0))
return_0;
if (background_polling() &&
9 years, 5 months
master - snapshot: no snapshot of any cache type LVs
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a82dcadf66dbd4...
Commit: a82dcadf66dbd43a43d3be40cd62a5074248d218
Parent: 3261e539a01efffb56abd78e5a060af8d1cf1537
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 4 23:21:07 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Wed Nov 5 15:28:38 2014 +0100
snapshot: no snapshot of any cache type LVs
Unsupported as of now.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 6 ++++++
2 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 8acbc3d..03baa06 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Properly report error when taking snapshot of any cache type LV.
Add basic thread debugging messages to dmeventd.
Include threads being shutdown in dmeventd device registration responses.
Inital support for external users of thin pools based on transaction_id.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index d3c0c47..6cf51f9 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6804,6 +6804,12 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
+ if (lv_is_cache_type(origin_lv)) {
+ log_error("Snapshots of cache type volume %s "
+ "is not supported.", display_lvname(origin_lv));
+ return NULL;
+ }
+
if (lv_is_thin_type(origin_lv) && !lv_is_thin_volume(origin_lv)) {
log_error("Snapshots of thin pool %sdevices "
"are not supported.",
9 years, 5 months
master - cleanup: keep 'fall through' switch case for LVSINFO for compiler to understand this properly
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3261e539a01eff...
Commit: 3261e539a01efffb56abd78e5a060af8d1cf1537
Parent: bf4681ba134914e5847d94bc0ca01b7a2af0b2b5
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Nov 5 10:46:52 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Nov 5 10:46:52 2014 +0100
cleanup: keep 'fall through' switch case for LVSINFO for compiler to understand this properly
---
tools/reporter.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/tools/reporter.c b/tools/reporter.c
index 080e3d5..b49f37d 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -414,6 +414,8 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
case DEVTYPES:
r = _process_each_devtype(cmd, argc, report_handle);
break;
+ case LVSINFO:
+ /* fall through */
case LVS:
r = process_each_lv(cmd, argc, argv, 0, report_handle,
lv_info_needed ? &_lvs_with_info_single
9 years, 5 months
master - report: cleanup: simplify LVSINFO detection
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bf4681ba134914...
Commit: bf4681ba134914e5847d94bc0ca01b7a2af0b2b5
Parent: 160777bb3eda1cae32511292070c92e076305ef6
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Nov 5 10:35:38 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Nov 5 10:42:18 2014 +0100
report: cleanup: simplify LVSINFO detection
LVSINFO is just a subtype of LVS report type with extra "info" ioctl
called for each LV reported (per output line) so include its processing
within "case LVS" switch, not as completely different kind of reporting
which may be misleading when reading the code.
There's already the "lv_info_needed" flag set in the _report fn, so
call the approriate reporting function based on this flag within the
"case LVS" switch line.
Actually the same is already done for LV is reported per segments
within the "case SEGS" switch line. So this patch makes the code more
consistent so it's processed the same way for all cases.
Also, this is a preparation for another and new subtype that will
be introduced later - the "LVSSTATUS" and "SEGSSTATUS" report type.
---
tools/reporter.c | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/tools/reporter.c b/tools/reporter.c
index 02f6064..080e3d5 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -394,9 +394,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
report_type = PVS;
else if (report_type & SEGS)
report_type = SEGS;
- else if (report_type & LVSINFO)
- report_type = LVSINFO;
- else if (report_type & LVS)
+ else if (report_type & (LVS | LVSINFO))
report_type = LVS;
/*
@@ -418,11 +416,8 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
break;
case LVS:
r = process_each_lv(cmd, argc, argv, 0, report_handle,
- &_lvs_single);
- break;
- case LVSINFO:
- r = process_each_lv(cmd, argc, argv, 0, report_handle,
- &_lvs_with_info_single);
+ lv_info_needed ? &_lvs_with_info_single
+ : &_lvs_single);
break;
case VGS:
r = process_each_vg(cmd, argc, argv, 0,
9 years, 5 months
master - dmeventd: Add basic thread debugging messages.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=160777bb3eda1c...
Commit: 160777bb3eda1cae32511292070c92e076305ef6
Parent: 89f635a0759dd9499155b4bf6bf8c07090444ade
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Nov 4 18:56:20 2014 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Nov 4 18:56:20 2014 +0000
dmeventd: Add basic thread debugging messages.
Only with -DDEBUG.
---
WHATS_NEW | 1 +
daemons/dmeventd/dmeventd.c | 91 ++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 90 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 6c76fa9..8acbc3d 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Add basic thread debugging messages to dmeventd.
Include threads being shutdown in dmeventd device registration responses.
Inital support for external users of thin pools based on transaction_id.
Report some basic percentage info for cache pools.
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index 1b950cf..e8d1e3b 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -117,6 +117,73 @@ static int _foreground = 0;
static int _restart = 0;
static char **_initial_registrations = 0;
+/* FIXME Make configurable at runtime */
+#ifdef DEBUG
+# define DEBUGLOG(fmt, args...) debuglog("[Thr %x]: " fmt, (int)pthread_self(), ## args)
+void debuglog(const char *fmt, ... ) __attribute__ ((format(printf, 1, 2)));
+
+void debuglog(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ vsyslog(LOG_DEBUG, fmt, ap);
+ va_end(ap);
+}
+
+static const char *decode_cmd(uint32_t cmd)
+{
+ static char buf[128];
+ const char *command;
+
+ switch (cmd) {
+ case DM_EVENT_CMD_ACTIVE:
+ command = "ACTIVE";
+ break;
+ case DM_EVENT_CMD_REGISTER_FOR_EVENT:
+ command = "REGISTER_FOR_EVENT";
+ break;
+ case DM_EVENT_CMD_UNREGISTER_FOR_EVENT:
+ command = "UNREGISTER_FOR_EVENT";
+ break;
+ case DM_EVENT_CMD_GET_REGISTERED_DEVICE:
+ command = "GET_REGISTERED_DEVICE";
+ break;
+ case DM_EVENT_CMD_GET_NEXT_REGISTERED_DEVICE:
+ command = "GET_NEXT_REGISTERED_DEVICE";
+ break;
+ case DM_EVENT_CMD_SET_TIMEOUT:
+ command = "SET_TIMEOUT";
+ break;
+ case DM_EVENT_CMD_GET_TIMEOUT:
+ command = "GET_TIMEOUT";
+ break;
+ case DM_EVENT_CMD_HELLO:
+ command = "HELLO";
+ break;
+ case DM_EVENT_CMD_DIE:
+ command = "DIE";
+ break;
+ case DM_EVENT_CMD_GET_STATUS:
+ command = "GET_STATUS";
+ break;
+ case DM_EVENT_CMD_GET_PARAMETERS:
+ command = "GET_PARAMETERS";
+ break;
+ default:
+ command = "unknown";
+ break;
+ }
+
+ snprintf(buf, sizeof(buf), "%s (0x%x)", command, cmd);
+
+ return buf;
+}
+
+#else
+# define DEBUGLOG(fmt, args...) do { } while (0)
+#endif
+
/* Data kept about a DSO. */
struct dso_data {
struct dm_list list;
@@ -538,6 +605,7 @@ static void *_timeout_thread(void *unused __attribute__((unused)))
struct timespec timeout;
time_t curr_time;
+ DEBUGLOG("Timeout thread starting.");
timeout.tv_nsec = 0;
pthread_cleanup_push(_exit_timeout, NULL);
pthread_mutex_lock(&_timeout_mutex);
@@ -549,6 +617,7 @@ static void *_timeout_thread(void *unused __attribute__((unused)))
dm_list_iterate_items_gen(thread, &_timeout_registry, timeout_list) {
if (thread->next_time <= curr_time) {
thread->next_time = curr_time + thread->timeout;
+ DEBUGLOG("Sending SIGALRM to Thr %x for timeout.", (int) thread->thread);
pthread_kill(thread->thread, SIGALRM);
}
@@ -560,6 +629,7 @@ static void *_timeout_thread(void *unused __attribute__((unused)))
&timeout);
}
+ DEBUGLOG("Timeout thread finished.");
pthread_cleanup_pop(1);
return NULL;
@@ -643,6 +713,7 @@ static int _event_wait(struct thread_status *thread, struct dm_task **task)
*task = 0;
+ DEBUGLOG("Preparing waitevent task for %s", thread->device.uuid);
if (!(dmt = dm_task_create(DM_DEVICE_WAITEVENT)))
return DM_WAIT_RETRY;
@@ -661,6 +732,8 @@ static int _event_wait(struct thread_status *thread, struct dm_task **task)
if (!_in_event_counter++)
dm_log_init(_no_intr_log);
_unlock_mutex();
+
+ DEBUGLOG("Starting waitevent task for %s", thread->device.uuid);
/*
* This is so that you can break out of waiting on an event,
* either for a timeout event, or to cancel the thread.
@@ -687,6 +760,7 @@ static int _event_wait(struct thread_status *thread, struct dm_task **task)
ret = DM_WAIT_FATAL;
}
}
+ DEBUGLOG("Completed waitevent task for %s", thread->device.uuid);
pthread_sigmask(SIG_SETMASK, &set, NULL);
_lock_mutex();
@@ -735,6 +809,7 @@ static void _monitor_unregister(void *arg)
{
struct thread_status *thread = arg, *thread_iter;
+ DEBUGLOG("_monitor_unregister thread cleanup handler running");
if (!_do_unregister_device(thread))
syslog(LOG_ERR, "%s: %s unregister failed\n", __func__,
thread->device.name);
@@ -760,6 +835,7 @@ static void _monitor_unregister(void *arg)
_unlock_mutex();
return;
}
+ DEBUGLOG("Marking Thr %x as DONE and unused.", (int)thread->thread);
thread->status = DM_THREAD_DONE;
UNLINK_THREAD(thread);
LINK(thread, &_thread_registry_unused);
@@ -863,6 +939,7 @@ static void *_monitor_thread(void *arg)
}
}
+ DEBUGLOG("Finished _monitor_thread");
pthread_cleanup_pop(1);
return NULL;
@@ -876,6 +953,7 @@ static int _create_thread(struct thread_status *thread)
static int _terminate_thread(struct thread_status *thread)
{
+ DEBUGLOG("Sending SIGALRM to terminate Thr %x.", (int)thread->thread);
return pthread_kill(thread->thread, SIGALRM);
}
@@ -1099,6 +1177,7 @@ static int _unregister_for_event(struct message_data *message_data)
* unlink and terminate its monitoring thread.
*/
if (!thread->events) {
+ DEBUGLOG("Marking Thr %x unused (no events).", (int)thread->thread);
UNLINK_THREAD(thread);
LINK(thread, &_thread_registry_unused);
}
@@ -1516,6 +1595,9 @@ static void _process_request(struct dm_event_fifos *fifos)
{
int die;
struct dm_event_daemon_message msg = { 0 };
+#ifdef DEBUG
+ const char *cmd;
+#endif
/*
* Read the request from the client (client_read, client_write
@@ -1524,6 +1606,7 @@ static void _process_request(struct dm_event_fifos *fifos)
if (!_client_read(fifos, &msg))
return;
+ DEBUGLOG("%s processing...", cmd = decode_cmd(msg.cmd));
die = (msg.cmd == DM_EVENT_CMD_DIE) ? 1 : 0;
/* _do_process_request fills in msg (if memory allows for
@@ -1535,6 +1618,8 @@ static void _process_request(struct dm_event_fifos *fifos)
dm_free(msg.data);
+ DEBUGLOG("%s completed.", cmd);
+
if (die) {
if (unlink(DMEVENTD_PIDFILE))
perror(DMEVENTD_PIDFILE ": unlink failed");
@@ -1601,6 +1686,7 @@ static void _cleanup_unused_threads(void)
}
if (thread->status == DM_THREAD_DONE) {
+ DEBUGLOG("Destroying Thr %x.", (int)thread->thread);
dm_list_del(l);
_unlock_mutex();
join_ret = pthread_join(thread->thread, NULL);
@@ -1617,6 +1703,7 @@ static void _cleanup_unused_threads(void)
static void _sig_alarm(int signum __attribute__((unused)))
{
+ DEBUGLOG("Received SIGALRM.");
pthread_testcancel();
}
@@ -1940,8 +2027,8 @@ static void restart(void)
if (version < 1) {
fprintf(stderr, "WARNING: The running dmeventd instance is too old.\n"
- "Protocol version %d (required: 1). Action cancelled.\n",
- version);
+ "Protocol version %d (required: 1). Action cancelled.\n",
+ version);
goto bad;
}
9 years, 5 months
master - dmeventd: Include shutdown threads in responses.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=89f635a0759dd9...
Commit: 89f635a0759dd9499155b4bf6bf8c07090444ade
Parent: 6b25faa218fc5cd1601e5418ce1481400386ecce
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Nov 4 16:58:14 2014 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Nov 4 16:58:14 2014 +0000
dmeventd: Include shutdown threads in responses.
When responding to DM_EVENT_CMD_GET_REGISTERED_DEVICE no longer
ignore threads that have already been unregistered but which
are still present.
This means the caller can unregister a device and poll dmeventd
to ensure the monitoring thread has gone away before removing
the device. If a device was registered and unregistered in quick
succession and then removed, WAITEVENT could run in parallel with
the REMOVE.
Threads are moved to the _thread_registry_unused list when they
are unregistered.
---
WHATS_NEW | 1 +
daemons/dmeventd/dmeventd.c | 12 ++++++++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3914392..6c76fa9 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Include threads being shutdown in dmeventd device registration responses.
Inital support for external users of thin pools based on transaction_id.
Report some basic percentage info for cache pools.
Introduce size_mb_arg_with_percent() for advanced size arg reading.
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index faae5ba..1b950cf 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -1177,6 +1177,18 @@ static int _get_registered_dev(struct message_data *message_data, int next)
if (hit && !next)
goto reg;
+ /*
+ * If we didn't get a match, try the threads waiting to be deleted.
+ * FIXME Do something similar if 'next' is set.
+ */
+ if (!hit && !next)
+ dm_list_iterate_items(thread, &_thread_registry_unused)
+ if (_want_registered_device(message_data->dso_name,
+ message_data->device_uuid, thread)) {
+ hit = thread;
+ goto reg;
+ }
+
if (!hit)
goto out;
9 years, 5 months
master - dmeventd: Remove redundant checks.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=6b25faa218fc5c...
Commit: 6b25faa218fc5cd1601e5418ce1481400386ecce
Parent: cebbda0931e43097a148bbf2c4b8a1de1c77d9fa
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Nov 4 16:55:42 2014 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Nov 4 16:55:42 2014 +0000
dmeventd: Remove redundant checks.
The status of threads in _thread_registry is always DM_THREAD_RUNNING
(zero).
DM_EVENT_REGISTRATION_PENDING is never stored in thread->events.
---
daemons/dmeventd/dmeventd.c | 14 ++++----------
1 files changed, 4 insertions(+), 10 deletions(-)
diff --git a/daemons/dmeventd/dmeventd.c b/daemons/dmeventd/dmeventd.c
index dcde7b1..faae5ba 100644
--- a/daemons/dmeventd/dmeventd.c
+++ b/daemons/dmeventd/dmeventd.c
@@ -1136,26 +1136,20 @@ static int _registered_device(struct message_data *message_data,
}
static int _want_registered_device(char *dso_name, char *device_uuid,
- struct thread_status *thread)
+ struct thread_status *thread)
{
/* If DSO names and device paths are equal. */
if (dso_name && device_uuid)
return !strcmp(dso_name, thread->dso_data->dso_name) &&
- !strcmp(device_uuid, thread->device.uuid) &&
- (thread->status == DM_THREAD_RUNNING ||
- (thread->events & DM_EVENT_REGISTRATION_PENDING));
+ !strcmp(device_uuid, thread->device.uuid);
/* If DSO names are equal. */
if (dso_name)
- return !strcmp(dso_name, thread->dso_data->dso_name) &&
- (thread->status == DM_THREAD_RUNNING ||
- (thread->events & DM_EVENT_REGISTRATION_PENDING));
+ return !strcmp(dso_name, thread->dso_data->dso_name);
/* If device paths are equal. */
if (device_uuid)
- return !strcmp(device_uuid, thread->device.uuid) &&
- (thread->status == DM_THREAD_RUNNING ||
- (thread->events & DM_EVENT_REGISTRATION_PENDING));
+ return !strcmp(device_uuid, thread->device.uuid);
return 1;
}
9 years, 5 months
master - tests: duplicate update of config
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cebbda0931e430...
Commit: cebbda0931e43097a148bbf2c4b8a1de1c77d9fa
Parent: 00a45ca491de21336f8d1d0253344995cea3b4f0
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 4 15:07:40 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Nov 4 15:29:22 2014 +0100
tests: duplicate update of config
---
test/shell/thin-volume-list.sh | 4 +---
1 files changed, 1 insertions(+), 3 deletions(-)
diff --git a/test/shell/thin-volume-list.sh b/test/shell/thin-volume-list.sh
index 31f4034..32d13b8 100644
--- a/test/shell/thin-volume-list.sh
+++ b/test/shell/thin-volume-list.sh
@@ -22,6 +22,7 @@ aux prepare_vg 2
lvcreate -T -L8M $vg/pool -V10M -n $lv1
+# skip $vg from activation
aux lvmconf "activation/volume_list = [ \"$vg1\" ]"
# We still could pass - since pool is still active
@@ -32,9 +33,6 @@ check inactive $vg $lv2
vgchange -an $vg
-# skip $vg from activation
-aux lvmconf "activation/volume_list = [ \"$vg1\" ]"
-
# Pool is not active - so it cannot create thin volume
not lvcreate -V10 -T $vg/pool
9 years, 5 months
master - thin: new pool is activated without overlay
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=00a45ca491de21...
Commit: 00a45ca491de21336f8d1d0253344995cea3b4f0
Parent: 8563c3e1a96f0d7ad180c859e9bf23a90e63e907
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 4 10:33:35 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Nov 4 15:29:22 2014 +0100
thin: new pool is activated without overlay
Activate of new/unused/empty thin pool volume skips
the 'overlay' part and directly provides 'visible' thin-pool LV to the user.
Such thin pool still gets 'private' -tpool UUID suffix for easier
udev detection of protected lvm2 devices, and also gets udev flags to
avoid any scan.
Such pool device is 'public' LV with regular /dev/vgname/poolname link,
but it's still 'udev' hidden device for any other use.
To display proper active state we need to do few explicit tests
for this condition.
Before it's used for any lvm2 thin volume, deactivation is
now needed to avoid any 'race' with external usage.
---
lib/activate/activate.c | 4 ++++
lib/activate/dev_manager.c | 15 ++++++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 49e86e7..c2a662f 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -641,6 +641,10 @@ int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_la
fs_unlock(); /* For non clustered - wait if there are non-delete ops */
}
+ /* New thin-pool has no layer, but -tpool suffix needs to be queried */
+ if (!use_layer && lv_is_new_thin_pool(lv))
+ use_layer = 1;
+
if (!dev_manager_info(cmd->mem, lv,
(use_layer) ? lv_layer(lv) : NULL,
with_open_count, with_read_ahead,
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 41911c1..e81c5d3 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1527,7 +1527,11 @@ static uint16_t _get_udev_flags(struct dev_manager *dm, const struct logical_vol
* If not, create just the /dev/mapper content.
*/
/* FIXME: add target's method for this */
- if (layer || !lv_is_visible(lv) || lv_is_thin_pool(lv))
+ if (lv_is_new_thin_pool(lv))
+ /* New thin-pool is regular LV with -tpool UUID suffix. */
+ udev_flags |= DM_UDEV_DISABLE_DISK_RULES_FLAG |
+ DM_UDEV_DISABLE_OTHER_RULES_FLAG;
+ else if (layer || !lv_is_visible(lv) || lv_is_thin_pool(lv))
udev_flags |= DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG |
DM_UDEV_DISABLE_DISK_RULES_FLAG |
DM_UDEV_DISABLE_OTHER_RULES_FLAG;
@@ -2604,6 +2608,10 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
if (!(name = dm_build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
return_0;
+ /* Even unused thin-pool still needs to get layered UUID -suffix */
+ if (!layer && lv_is_new_thin_pool(lv))
+ layer = lv_layer(lv);
+
if (!(dlid = build_dm_uuid(dm->mem, lv, layer)))
return_0;
@@ -2679,8 +2687,9 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
return_0;
if (!_add_snapshot_target_to_dtree(dm, dnode, lv, laopts))
return_0;
- } else if ((lv_is_external_origin(lv) || lv_is_thin_pool(lv)) && !layer) {
- /* External origin or Thin pool is using layer */
+ } else if (!layer && ((lv_is_thin_pool(lv) && !lv_is_new_thin_pool(lv)) ||
+ lv_is_external_origin(lv))) {
+ /* External origin or 'used' Thin pool is using layer */
if (!_add_new_lv_to_dtree(dm, dtree, lv, laopts, lv_layer(lv)))
return_0;
if (!_add_layer_target_to_dtree(dm, dnode, lv))
9 years, 5 months
master - thin: check for new pool before creating thin volume
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8563c3e1a96f0d...
Commit: 8563c3e1a96f0d7ad180c859e9bf23a90e63e907
Parent: 6116b1d6e302097086c9dcd418e4404ddd337939
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 4 15:08:15 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Nov 4 15:29:19 2014 +0100
thin: check for new pool before creating thin volume
Call check_new_thin_pool() to detect in-use thin-pool.
Save extra reactivation of thin-pool when thin pool is not active.
(it's now a bit more expensive to invoke thin_check for new pools.)
For new pools:
We now active locally exclusively thin-pool as 'public' LV.
Validate transaction_id is till 0.
Deactive.
Prepare create message for thin-pool and exclusively active pool.
Active new thin LV.
And deactivate thin pool if it used to be inactive.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 37 +++++++++++++++++++++++++++++++++++--
2 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index d824289..3914392 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.112 -
=====================================
+ Inital support for external users of thin pools based on transaction_id.
Report some basic percentage info for cache pools.
Introduce size_mb_arg_with_percent() for advanced size arg reading.
Add extra support for '.' as decimal point in size args.
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index b5fc84a..d3c0c47 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6559,6 +6559,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
struct logical_volume *pool_lv = NULL;
struct logical_volume *tmp_lv;
struct lv_segment *seg, *pool_seg;
+ int thin_pool_was_active = -1; /* not scanned, inactive, active */
if (new_lv_name && find_lv_in_vg(vg, new_lv_name)) {
log_error("Logical volume \"%s\" already exists in "
@@ -6679,6 +6680,14 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
}
+ if (seg_is_thin_volume(lp) &&
+ lv_is_new_thin_pool(pool_lv)) {
+ thin_pool_was_active = lv_is_active(pool_lv);
+ if (!check_new_thin_pool(pool_lv))
+ return_NULL;
+ /* New pool is now inactive */
+ }
+
if (seg_is_cache(lp) &&
!wipe_cache_pool(pool_lv))
return_NULL;
@@ -7003,7 +7012,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
goto revert_new_lv;
}
/* At this point remove pool messages, snapshot is active */
- if (!update_pool_lv(first_seg(origin_lv)->pool_lv, 0)) {
+ if (!update_pool_lv(pool_lv, 0)) {
stack;
goto revert_new_lv;
}
@@ -7013,7 +7022,23 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
if (is_change_activating(lp->activate)) {
/* Send message so that table preload knows new thin */
- if (!update_pool_lv(first_seg(lv)->pool_lv, 1)) {
+ if (!lv_is_active(pool_lv)) {
+ /* Avoid multiple thin-pool activations in this case */
+ if (thin_pool_was_active < 0)
+ thin_pool_was_active = 0;
+ if (!activate_lv_excl(cmd, pool_lv)) {
+ log_error("Failed to activate thin pool %s/%s.",
+ origin_lv->vg->name, origin_lv->name);
+ goto revert_new_lv;
+ }
+ if (!lv_is_active(pool_lv)) {
+ log_error("Cannot activate thin pool %s, perhaps skipped in lvm.conf volume_list?",
+ display_lvname(pool_lv));
+ return 0;
+ }
+ }
+ /* Keep thin pool active until thin volume is activated */
+ if (!update_pool_lv(pool_lv, (thin_pool_was_active < 0) ? 1 : 0)) {
stack;
goto revert_new_lv;
}
@@ -7024,6 +7049,14 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
log_error("Failed to activate thin %s.", lv->name);
goto deactivate_and_revert_new_lv;
}
+
+ /* Restore inactive state if needed */
+ if (!thin_pool_was_active &&
+ !deactivate_lv(cmd, pool_lv)) {
+ log_error("Failed to deactivate thin pool %s.",
+ display_lvname(pool_lv));
+ return NULL;
+ }
}
} else if (lp->snapshot) {
if (!activate_lv_local(cmd, lv)) {
9 years, 5 months