1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-03-13 00:58:47 +03:00

Add --monitor to vgcreate and lvcreate to control dmeventd registration.

Propagate --monitor around cluster.
Filter LCK_NONBLOCK in clvmd lock_vg.
This commit is contained in:
Alasdair Kergon 2006-05-12 19:16:48 +00:00
parent 6560de21e2
commit 3e3d5d8593
15 changed files with 210 additions and 31 deletions

View File

@ -1,5 +1,8 @@
Version 2.02.06 - Version 2.02.06 -
================================= =================================
Propagate --monitor around cluster.
Add --monitor to vgcreate and lvcreate to control dmeventd registration.
Filter LCK_NONBLOCK in clvmd lock_vg.
Add --nosync to lvcreate with LV flag NOTSYNCED. Add --nosync to lvcreate with LV flag NOTSYNCED.
Use mirror's uuid for a core log. Use mirror's uuid for a core log.
Add mirror log fault-handling policy. Add mirror log fault-handling policy.

View File

@ -180,7 +180,7 @@ static int lock_vg(struct local_client *client)
} }
else { else {
status = sync_lock(lockname, (int)lock_cmd, (int)lock_flags, &lkid); status = sync_lock(lockname, (int)lock_cmd, (lock_flags & LCK_NONBLOCK) ? LKF_NOQUEUE : 0, &lkid);
if (status) if (status)
status = errno; status = errno;
else else

View File

@ -309,6 +309,9 @@ int do_lock_lv(unsigned char command, unsigned char lock_flags, char *resource)
if (lock_flags & LCK_MIRROR_NOSYNC_MODE) if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
init_mirror_in_sync(1); init_mirror_in_sync(1);
if (!(lock_flags & LCK_DMEVENTD_MONITOR))
init_dmeventd_register(0);
switch (command) { switch (command) {
case LCK_LV_EXCLUSIVE: case LCK_LV_EXCLUSIVE:
status = do_activate_lv(resource, lock_flags, LKM_EXMODE); status = do_activate_lv(resource, lock_flags, LKM_EXMODE);
@ -340,6 +343,12 @@ int do_lock_lv(unsigned char command, unsigned char lock_flags, char *resource)
if (lock_flags & LCK_PARTIAL_MODE) if (lock_flags & LCK_PARTIAL_MODE)
init_partial(0); init_partial(0);
if (lock_flags & LCK_MIRROR_NOSYNC_MODE)
init_mirror_in_sync(0);
if (!(lock_flags & LCK_DMEVENTD_REGISTER_MODE))
init_dmeventd_register(DEFAULT_DMEVENTD_MONITOR);
/* clean the pool for another command */ /* clean the pool for another command */
dm_pool_empty(cmd->mem); dm_pool_empty(cmd->mem);

View File

@ -152,7 +152,7 @@ int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv)
} }
int pv_uses_vg(struct cmd_context *cmd, struct physical_volume *pv, int pv_uses_vg(struct cmd_context *cmd, struct physical_volume *pv,
struct volume_group *vg) struct volume_group *vg)
{ {
return 0; return 0;
} }
@ -574,15 +574,31 @@ int lvs_in_vg_opened(struct volume_group *vg)
return count; return count;
} }
static int _register_dev_for_events(struct cmd_context *cmd, /*
struct logical_volume *lv, int do_reg) * register_dev_for_events
*
* This function uses proper error codes (but breaks convention)
* to return:
* -1 on error
* 0 if the lv's targets don't do event [un]registration
* 0 if the lv is already [un]registered -- FIXME: not implemented
* 1 if the lv had a segment which was [un]registered
*
* Returns: -1 on error
*/
int register_dev_for_events(struct cmd_context *cmd,
struct logical_volume *lv, int do_reg)
{ {
#ifdef DMEVENTD #ifdef DMEVENTD
int r = 0;
struct list *tmp; struct list *tmp;
struct lv_segment *seg; struct lv_segment *seg;
int (*reg) (struct dm_pool *mem, struct lv_segment *, int (*reg) (struct dm_pool *mem, struct lv_segment *,
struct config_tree *cft, int events); struct config_tree *cft, int events);
if (do_reg && !dmeventd_register_mode())
return 1;
list_iterate(tmp, &lv->segments) { list_iterate(tmp, &lv->segments) {
seg = list_item(tmp, struct lv_segment); seg = list_item(tmp, struct lv_segment);
@ -595,17 +611,21 @@ static int _register_dev_for_events(struct cmd_context *cmd,
reg = seg->segtype->ops->target_unregister_events; reg = seg->segtype->ops->target_unregister_events;
if (!reg) if (!reg)
return_0; continue;
/* FIXME specify events */ /* FIXME specify events */
if (!reg(cmd->mem, seg, cmd->cft, 0)) { if (!reg(cmd->mem, seg, cmd->cft, 0)) {
stack; stack;
return 0; return -1;
} }
r = 1;
} }
#endif return r;
#else
return 1; return 1;
#endif
} }
static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s, static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
@ -643,7 +663,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
} }
} }
if (!_register_dev_for_events(cmd, lv, 0)) if (register_dev_for_events(cmd, lv, 0) != 1)
/* FIXME Consider aborting here */ /* FIXME Consider aborting here */
stack; stack;
@ -697,7 +717,7 @@ static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,
memlock_dec(); memlock_dec();
fs_unlock(); fs_unlock();
if (!_register_dev_for_events(cmd, lv, 1)) if (register_dev_for_events(cmd, lv, 1) != 1)
stack; stack;
return 1; return 1;
@ -743,7 +763,7 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
return 0; return 0;
} }
if (!_register_dev_for_events(cmd, lv, 0)) if (register_dev_for_events(cmd, lv, 0) != 1)
stack; stack;
memlock_inc(); memlock_inc();
@ -816,7 +836,7 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
memlock_dec(); memlock_dec();
fs_unlock(); fs_unlock();
if (!_register_dev_for_events(cmd, lv, 1)) if (!register_dev_for_events(cmd, lv, 1) != 1)
stack; stack;
return r; return r;
@ -863,7 +883,7 @@ int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv)
* Returns 1 on failure. * Returns 1 on failure.
*/ */
int pv_uses_vg(struct physical_volume *pv, int pv_uses_vg(struct physical_volume *pv,
struct volume_group *vg) struct volume_group *vg)
{ {
if (!activation()) if (!activation())
return 0; return 0;

View File

@ -80,6 +80,10 @@ int lv_mirror_percent(struct cmd_context *cmd, struct logical_volume *lv,
int lvs_in_vg_activated(struct volume_group *vg); int lvs_in_vg_activated(struct volume_group *vg);
int lvs_in_vg_opened(struct volume_group *vg); int lvs_in_vg_opened(struct volume_group *vg);
int register_dev_for_events(struct cmd_context *cmd,
struct logical_volume *lv, int do_reg);
/* /*
* Returns 1 if PV has a dependency tree that uses anything in VG. * Returns 1 if PV has a dependency tree that uses anything in VG.
*/ */

View File

@ -37,6 +37,7 @@
#define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate" #define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
#define DEFAULT_MIRROR_DEV_FAULT_POLICY "remove" #define DEFAULT_MIRROR_DEV_FAULT_POLICY "remove"
#define DEFAULT_DMEVENTD_MIRROR_LIB "libdevmapper-event-lvm2mirror.so" #define DEFAULT_DMEVENTD_MIRROR_LIB "libdevmapper-event-lvm2mirror.so"
#define DEFAULT_DMEVENTD_MONITOR 1
#define DEFAULT_UMASK 0077 #define DEFAULT_UMASK 0077

View File

@ -336,6 +336,9 @@ static int _lock_for_cluster(unsigned char cmd, unsigned int flags, char *name)
if (mirror_in_sync()) if (mirror_in_sync())
args[1] |= LCK_MIRROR_NOSYNC_MODE; args[1] |= LCK_MIRROR_NOSYNC_MODE;
if (dmeventd_register_mode())
args[1] |= LCK_DMEVENTD_REGISTER_MODE;
/* /*
* VG locks are just that: locks, and have no side effects * VG locks are just that: locks, and have no side effects
* so we only need to do them on the local node because all * so we only need to do them on the local node because all

View File

@ -75,6 +75,8 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
*/ */
#define LCK_PARTIAL_MODE 0x00000001 /* Running in partial mode */ #define LCK_PARTIAL_MODE 0x00000001 /* Running in partial mode */
#define LCK_MIRROR_NOSYNC_MODE 0x00000002 /* Mirrors don't require sync */ #define LCK_MIRROR_NOSYNC_MODE 0x00000002 /* Mirrors don't require sync */
#define LCK_DMEVENTD_REGISTER_MODE 0x00000004 /* Register with dmeventd */
/* /*
* Common combinations * Common combinations

View File

@ -17,6 +17,7 @@
#include "device.h" #include "device.h"
#include "memlock.h" #include "memlock.h"
#include "lvm-string.h" #include "lvm-string.h"
#include "defaults.h"
#include <stdarg.h> #include <stdarg.h>
#include <syslog.h> #include <syslog.h>
@ -46,6 +47,7 @@ static char _cmd_name[30] = "";
static char _msg_prefix[30] = " "; static char _msg_prefix[30] = " ";
static int _already_logging = 0; static int _already_logging = 0;
static int _mirror_in_sync = 0; static int _mirror_in_sync = 0;
static int _dmeventd_register = DEFAULT_DMEVENTD_MONITOR;
static lvm2_log_fn_t _lvm2_log_fn = NULL; static lvm2_log_fn_t _lvm2_log_fn = NULL;
@ -181,6 +183,11 @@ void init_mirror_in_sync(int in_sync)
_mirror_in_sync = in_sync; _mirror_in_sync = in_sync;
} }
void init_dmeventd_register(int reg)
{
_dmeventd_register = reg;
}
void init_cmd_name(int status) void init_cmd_name(int status)
{ {
_log_cmd_name = status; _log_cmd_name = status;
@ -250,6 +257,11 @@ int mirror_in_sync(void)
return _mirror_in_sync; return _mirror_in_sync;
} }
int dmeventd_register_mode(void)
{
return _dmeventd_register;
}
void init_debug(int level) void init_debug(int level)
{ {
_debug_level = level; _debug_level = level;

View File

@ -74,6 +74,7 @@ void init_ignorelockingfailure(int level);
void init_lockingfailed(int level); void init_lockingfailed(int level);
void init_security_level(int level); void init_security_level(int level);
void init_mirror_in_sync(int in_sync); void init_mirror_in_sync(int in_sync);
void init_dmeventd_register(int reg);
void set_cmd_name(const char *cmd_name); void set_cmd_name(const char *cmd_name);
@ -87,6 +88,7 @@ int ignorelockingfailure(void);
int lockingfailed(void); int lockingfailed(void);
int security_level(void); int security_level(void);
int mirror_in_sync(void); int mirror_in_sync(void);
int dmeventd_register_mode(void);
/* Suppress messages to stdout/stderr (1) or everywhere (2) */ /* Suppress messages to stdout/stderr (1) or everywhere (2) */
/* Returns previous setting */ /* Returns previous setting */

View File

@ -47,6 +47,7 @@ arg(separator_ARG, '\0', "separator", string_arg)
arg(mirrorsonly_ARG, '\0', "mirrorsonly", NULL) arg(mirrorsonly_ARG, '\0', "mirrorsonly", NULL)
arg(nosync_ARG, '\0', "nosync", NULL) arg(nosync_ARG, '\0', "nosync", NULL)
arg(corelog_ARG, '\0', "corelog", NULL) arg(corelog_ARG, '\0', "corelog", NULL)
arg(monitor_ARG, '\0', "monitor", yes_no_arg)
/* Allow some variations */ /* Allow some variations */
arg(resizable_ARG, '\0', "resizable", yes_no_arg) arg(resizable_ARG, '\0', "resizable", yes_no_arg)

View File

@ -63,6 +63,7 @@ xx(lvchange,
"\t[-f|--force]\n" "\t[-f|--force]\n"
"\t[-h|--help]\n" "\t[-h|--help]\n"
"\t[--ignorelockingfailure]\n" "\t[--ignorelockingfailure]\n"
"\t[--monitor {y|n}]\n"
"\t[-M|--persistent y|n] [--major major] [--minor minor]\n" "\t[-M|--persistent y|n] [--major major] [--minor minor]\n"
"\t[-P|--partial] " "\n" "\t[-P|--partial] " "\n"
"\t[-p|--permission r|rw]\n" "\t[-p|--permission r|rw]\n"
@ -74,9 +75,9 @@ xx(lvchange,
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n", "\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
alloc_ARG, autobackup_ARG, available_ARG, contiguous_ARG, force_ARG, alloc_ARG, autobackup_ARG, available_ARG, contiguous_ARG, force_ARG,
ignorelockingfailure_ARG, major_ARG, minor_ARG, partial_ARG, permission_ARG, ignorelockingfailure_ARG, major_ARG, minor_ARG, monitor_ARG,
persistent_ARG, readahead_ARG, refresh_ARG, addtag_ARG, deltag_ARG, partial_ARG, permission_ARG, persistent_ARG, readahead_ARG,
test_ARG) refresh_ARG, addtag_ARG, deltag_ARG, test_ARG)
xx(lvconvert, xx(lvconvert,
"Change logical volume layout", "Change logical volume layout",
@ -347,7 +348,7 @@ xx(lvs,
"\t[-v|--verbose]\n" "\t[-v|--verbose]\n"
"\t[--version]" "\n" "\t[--version]" "\n"
"\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n", "\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n",
aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG, aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG,
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, segments_ARG, nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, segments_ARG,
separator_ARG, sort_ARG, unbuffered_ARG, units_ARG) separator_ARG, sort_ARG, unbuffered_ARG, units_ARG)
@ -494,7 +495,7 @@ xx(pvmove,
"\tSourcePhysicalVolume[:PhysicalExtent[-PhysicalExtent]...]}\n" "\tSourcePhysicalVolume[:PhysicalExtent[-PhysicalExtent]...]}\n"
"\t[DestinationPhysicalVolume[:PhysicalExtent[-PhysicalExtent]...]...]\n", "\t[DestinationPhysicalVolume[:PhysicalExtent[-PhysicalExtent]...]...]\n",
abort_ARG, alloc_ARG, autobackup_ARG, background_ARG, abort_ARG, alloc_ARG, autobackup_ARG, background_ARG,
interval_ARG, name_ARG, test_ARG) interval_ARG, name_ARG, test_ARG)
xx(pvremove, xx(pvremove,
@ -531,7 +532,7 @@ xx(pvs,
"\t[-v|--verbose]\n" "\t[-v|--verbose]\n"
"\t[--version]\n" "\t[--version]\n"
"\t[PhysicalVolume [PhysicalVolume...]]\n", "\t[PhysicalVolume [PhysicalVolume...]]\n",
aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG, aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG,
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, segments_ARG, nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, segments_ARG,
separator_ARG, sort_ARG, unbuffered_ARG, units_ARG) separator_ARG, sort_ARG, unbuffered_ARG, units_ARG)
@ -595,6 +596,7 @@ xx(vgchange,
"\t[-d|--debug] " "\n" "\t[-d|--debug] " "\n"
"\t[-h|--help] " "\n" "\t[-h|--help] " "\n"
"\t[--ignorelockingfailure]\n" "\t[--ignorelockingfailure]\n"
"\t[--monitor {y|n}]\n"
"\t[-t|--test]" "\n" "\t[-t|--test]" "\n"
"\t[-u|--uuid] " "\n" "\t[-u|--uuid] " "\n"
"\t[-v|--verbose] " "\n" "\t[-v|--verbose] " "\n"
@ -610,8 +612,8 @@ xx(vgchange,
addtag_ARG, alloc_ARG, allocation_ARG, autobackup_ARG, available_ARG, addtag_ARG, alloc_ARG, allocation_ARG, autobackup_ARG, available_ARG,
clustered_ARG, deltag_ARG, ignorelockingfailure_ARG, logicalvolume_ARG, clustered_ARG, deltag_ARG, ignorelockingfailure_ARG, logicalvolume_ARG,
partial_ARG, physicalextentsize_ARG, resizeable_ARG, resizable_ARG, monitor_ARG, partial_ARG, physicalextentsize_ARG, resizeable_ARG,
test_ARG, uuid_ARG) resizable_ARG, test_ARG, uuid_ARG)
xx(vgck, xx(vgck,
"Check the consistency of volume group(s)", "Check the consistency of volume group(s)",
@ -822,7 +824,7 @@ xx(vgs,
"\t[-v|--verbose]\n" "\t[-v|--verbose]\n"
"\t[--version]\n" "\t[--version]\n"
"\t[VolumeGroupName [VolumeGroupName...]]\n", "\t[VolumeGroupName [VolumeGroupName...]]\n",
aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG, aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG,
nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, separator_ARG, nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, separator_ARG,
sort_ARG, unbuffered_ARG, units_ARG) sort_ARG, unbuffered_ARG, units_ARG)
@ -835,7 +837,7 @@ xx(vgscan,
"\t[--ignorelockingfailure]\n" "\t[--ignorelockingfailure]\n"
"\t[--mknodes]\n" "\t[--mknodes]\n"
"\t[-P|--partial] " "\n" "\t[-P|--partial] " "\n"
"\t[-v|--verbose]\n" "\t[-v|--verbose]\n"
"\t[--version]" "\n", "\t[--version]" "\n",
ignorelockingfailure_ARG, mknodes_ARG, partial_ARG) ignorelockingfailure_ARG, mknodes_ARG, partial_ARG)

View File

@ -72,6 +72,38 @@ static int lvchange_permission(struct cmd_context *cmd,
return 1; return 1;
} }
static int lvchange_registration(struct cmd_context *cmd,
struct logical_volume *lv)
{
int r;
struct lvinfo info;
if (!lv_info(cmd, lv, &info, 0) || !info.exists) {
log_error("Logical volume, %s, is not active", lv->name);
return 0;
}
/* do not register pvmove lv's */
if (lv->status & PVMOVE)
return 1;
log_verbose("%smonitoring logical volume \"%s\"",
(dmeventd_register_mode()) ? "" : "Not ", lv->name);
r = register_dev_for_events(cmd, lv, dmeventd_register_mode());
if (r < 0) {
log_error("Unable to %smonitor logical volume, %s",
(dmeventd_register_mode()) ? "" : "un", lv->name);
r = 0;
} else if (!r) {
log_verbose("Logical volume %s needs no monitoring.",
lv->name);
r = 1;
}
return r;
}
static int lvchange_availability(struct cmd_context *cmd, static int lvchange_availability(struct cmd_context *cmd,
struct logical_volume *lv) struct logical_volume *lv)
{ {
@ -422,6 +454,8 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
return ECMD_FAILED; return ECMD_FAILED;
} }
init_dmeventd_register(arg_int_value(cmd, monitor_ARG, DEFAULT_DMEVENTD_MONITOR));
/* access permission change */ /* access permission change */
if (arg_count(cmd, permission_ARG)) { if (arg_count(cmd, permission_ARG)) {
if (!archive(lv->vg)) if (!archive(lv->vg))
@ -474,14 +508,22 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
log_print("Logical volume \"%s\" changed", lv->name); log_print("Logical volume \"%s\" changed", lv->name);
/* availability change */ /* availability change */
if (arg_count(cmd, available_ARG)) if (arg_count(cmd, available_ARG)) {
if (!lvchange_availability(cmd, lv)) if (!lvchange_availability(cmd, lv))
return ECMD_FAILED; return ECMD_FAILED;
}
if (arg_count(cmd, refresh_ARG)) if (arg_count(cmd, refresh_ARG))
if (!lvchange_refresh(cmd, lv)) if (!lvchange_refresh(cmd, lv))
return ECMD_FAILED; return ECMD_FAILED;
if (!arg_count(cmd, available_ARG) &&
!arg_count(cmd, refresh_ARG) &&
arg_count(cmd, monitor_ARG)) {
if (!lvchange_registration(cmd, lv))
return ECMD_FAILED;
}
return ECMD_PROCESSED; return ECMD_PROCESSED;
} }
@ -492,9 +534,10 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
&& !arg_count(cmd, minor_ARG) && !arg_count(cmd, major_ARG) && !arg_count(cmd, minor_ARG) && !arg_count(cmd, major_ARG)
&& !arg_count(cmd, persistent_ARG) && !arg_count(cmd, addtag_ARG) && !arg_count(cmd, persistent_ARG) && !arg_count(cmd, addtag_ARG)
&& !arg_count(cmd, deltag_ARG) && !arg_count(cmd, refresh_ARG) && !arg_count(cmd, deltag_ARG) && !arg_count(cmd, refresh_ARG)
&& !arg_count(cmd, alloc_ARG)) { && !arg_count(cmd, alloc_ARG) && !arg_count(cmd, monitor_ARG)) {
log_error("One or more of -a, -C, -j, -m, -M, -p, -r, " log_error("Need 1 or more of -a, -C, -j, -m, -M, -p, -r, "
"--refresh, --alloc, --addtag or --deltag required"); "--refresh, --alloc, --addtag, --deltag "
"or --monitor");
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;
} }

View File

@ -15,6 +15,51 @@
#include "tools.h" #include "tools.h"
static int _register_lvs_in_vg(struct cmd_context *cmd,
struct volume_group *vg, int reg)
{
struct lv_list *lvl;
struct logical_volume *lv;
struct lvinfo info;
int lv_active;
int count = 0;
int r;
list_iterate_items(lvl, &vg->lvs) {
lv = lvl->lv;
if (!lv_info(cmd, lv, &info, 0))
lv_active = 0;
else
lv_active = info.exists;
/*
* FIXME: Need to consider all cases... PVMOVE, etc
*/
if ((lv->status & PVMOVE) || !lv_active)
continue;
r = register_dev_for_events(cmd, lv, reg);
if (r < 0) {
log_error("Failed to %s logical volume, %s",
(reg) ? "register" : "unregister",
lv->name);
continue;
}
if (r)
count++;
}
/*
* returns the number of monitored devices, not the number
* of _new_ monitored devices
*/
return count;
}
static int _activate_lvs_in_vg(struct cmd_context *cmd, static int _activate_lvs_in_vg(struct cmd_context *cmd,
struct volume_group *vg, int activate) struct volume_group *vg, int activate)
{ {
@ -65,9 +110,23 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd,
return count; return count;
} }
static int _vgchange_monitoring(struct cmd_context *cmd, struct volume_group *vg)
{
int active, monitored;
if ((active = lvs_in_vg_activated(vg))) {
monitored = _register_lvs_in_vg(cmd, vg, dmeventd_register_mode());
log_print("%d logical volume(s) in volume group "
"\"%s\" now %smonitored",
monitored, vg->name, (dmeventd_register_mode()) ? "" : "un");
}
return ECMD_PROCESSED;
}
static int _vgchange_available(struct cmd_context *cmd, struct volume_group *vg) static int _vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
{ {
int lv_open, active; int lv_open, active, monitored;
int available; int available;
int activate = 1; int activate = 1;
@ -93,9 +152,15 @@ static int _vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
if (activate && !lockingfailed()) if (activate && !lockingfailed())
check_current_backup(vg); check_current_backup(vg);
if (activate && (active = lvs_in_vg_activated(vg))) if (activate && (active = lvs_in_vg_activated(vg))) {
log_verbose("%d logical volume(s) in volume group \"%s\" " log_verbose("%d logical volume(s) in volume group \"%s\" "
"already active", active, vg->name); "already active", active, vg->name);
monitored = _register_lvs_in_vg(cmd, vg, dmeventd_register_mode());
log_verbose("%d existing logical volume(s) in volume "
"group \"%s\" now %smonitored",
monitored, vg->name,
dmeventd_register_mode() ? "" : "un");
}
if (activate && _activate_lvs_in_vg(cmd, vg, available)) if (activate && _activate_lvs_in_vg(cmd, vg, available))
log_verbose("Activated logical volumes in " log_verbose("Activated logical volumes in "
@ -429,9 +494,14 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_FAILED; return ECMD_FAILED;
} }
init_dmeventd_register(arg_int_value(cmd, monitor_ARG, DEFAULT_DMEVENTD_MONITOR));
if (arg_count(cmd, available_ARG)) if (arg_count(cmd, available_ARG))
r = _vgchange_available(cmd, vg); r = _vgchange_available(cmd, vg);
else if (arg_count(cmd, monitor_ARG))
r = _vgchange_monitoring(cmd, vg);
else if (arg_count(cmd, resizeable_ARG)) else if (arg_count(cmd, resizeable_ARG))
r = _vgchange_resizeable(cmd, vg); r = _vgchange_resizeable(cmd, vg);
@ -466,7 +536,8 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
arg_count(cmd, resizeable_ARG) + arg_count(cmd, deltag_ARG) + arg_count(cmd, resizeable_ARG) + arg_count(cmd, deltag_ARG) +
arg_count(cmd, addtag_ARG) + arg_count(cmd, uuid_ARG) + arg_count(cmd, addtag_ARG) + arg_count(cmd, uuid_ARG) +
arg_count(cmd, physicalextentsize_ARG) + arg_count(cmd, physicalextentsize_ARG) +
arg_count(cmd, clustered_ARG) + arg_count(cmd, alloc_ARG))) { arg_count(cmd, clustered_ARG) + arg_count(cmd, alloc_ARG) +
arg_count(cmd, monitor_ARG))) {
log_error("One of -a, -c, -l, -s, -x, --uuid, --alloc, --addtag or " log_error("One of -a, -c, -l, -s, -x, --uuid, --alloc, --addtag or "
"--deltag required"); "--deltag required");
return EINVALID_CMD_LINE; return EINVALID_CMD_LINE;

View File

@ -111,7 +111,13 @@ static int _remove_lv(struct cmd_context *cmd, struct logical_volume *lv,
* and add to list of LVs to be removed later. * and add to list of LVs to be removed later.
* Doesn't apply to snapshots/origins yet - they're already deactivated. * Doesn't apply to snapshots/origins yet - they're already deactivated.
*/ */
if (lv_info(cmd, lv, &info, 0) && info.exists) { /*
* If the LV is a part of mirror segment,
* the mirrored LV also should be cleaned up.
* Clean-up is currently done by caller (_make_vg_consistent()).
*/
if ((lv_info(cmd, lv, &info, 0) && info.exists)
|| first_seg(lv)->mirror_seg) {
extents = lv->le_count; extents = lv->le_count;
mirror_seg = first_seg(lv)->mirror_seg; mirror_seg = first_seg(lv)->mirror_seg;
if (!lv_empty(lv)) { if (!lv_empty(lv)) {