1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-08-02 04:22:02 +03:00

Monitor origin -real device below snapshot instead of overlay device. (brassow)

This commit is contained in:
Alasdair Kergon
2010-08-17 01:16:41 +00:00
parent 85a80e0505
commit f92b4f9482
6 changed files with 21 additions and 18 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.73 - Version 2.02.73 -
================================ ================================
Monitor origin -real device below snapshot instead of overlay device.
Don't really change monitoring status when in test mode. Don't really change monitoring status when in test mode.
Fix some exit statuses when starting/stopping monitoring fails. Fix some exit statuses when starting/stopping monitoring fails.
Enable snapshot monitoring by default when dmeventd is enabled. Enable snapshot monitoring by default when dmeventd is enabled.

View File

@ -770,7 +770,8 @@ char *get_monitor_dso_path(struct cmd_context *cmd, const char *libpath)
return path; return path;
} }
int target_registered_with_dmeventd(struct cmd_context *cmd, const char *dso, const char *lvid, int *pending) int target_registered_with_dmeventd(struct cmd_context *cmd, const char *dso,
struct logical_volume *lv, int *pending)
{ {
char *uuid; char *uuid;
enum dm_event_mask evmask = 0; enum dm_event_mask evmask = 0;
@ -781,7 +782,8 @@ int target_registered_with_dmeventd(struct cmd_context *cmd, const char *dso, co
if (!dso) if (!dso)
return_0; return_0;
if (!(uuid = build_dm_uuid(cmd->mem, lvid, NULL))) /* We always monitor the "real" device, never the "snapshot-origin" itself. */
if (!(uuid = build_dm_uuid(cmd->mem, lv->lvid.s, lv_is_origin(lv) ? "real" : NULL)))
return_0; return_0;
if (!(dmevh = _create_dm_event_handler(cmd, uuid, dso, 0, DM_EVENT_ALL_ERRORS))) if (!(dmevh = _create_dm_event_handler(cmd, uuid, dso, 0, DM_EVENT_ALL_ERRORS)))
@ -803,7 +805,7 @@ int target_registered_with_dmeventd(struct cmd_context *cmd, const char *dso, co
return evmask; return evmask;
} }
int target_register_events(struct cmd_context *cmd, const char *dso, const char *lvid, int target_register_events(struct cmd_context *cmd, const char *dso, struct logical_volume *lv,
int evmask __attribute__((unused)), int set, int timeout) int evmask __attribute__((unused)), int set, int timeout)
{ {
char *uuid; char *uuid;
@ -813,7 +815,8 @@ int target_register_events(struct cmd_context *cmd, const char *dso, const char
if (!dso) if (!dso)
return_0; return_0;
if (!(uuid = build_dm_uuid(cmd->mem, lvid, NULL))) /* We always monitor the "real" device, never the "snapshot-origin" itself. */
if (!(uuid = build_dm_uuid(cmd->mem, lv->lvid.s, lv_is_origin(lv) ? "real" : NULL)))
return_0; return_0;
if (!(dmevh = _create_dm_event_handler(cmd, uuid, dso, timeout, if (!(dmevh = _create_dm_event_handler(cmd, uuid, dso, timeout,
@ -869,18 +872,14 @@ int monitor_dev_for_events(struct cmd_context *cmd,
/* /*
* In case this LV is a snapshot origin, we instead monitor * In case this LV is a snapshot origin, we instead monitor
* each of its respective snapshots (the origin itself does * each of its respective snapshots. The origin itself may
* not need to be monitored). * also need to be monitored if it is a mirror, for example.
*
* TODO: This may change when snapshots of mirrors are allowed.
*/ */
if (lv_is_origin(lv)) { if (lv_is_origin(lv))
dm_list_iterate_safe(snh, snht, &lv->snapshot_segs) dm_list_iterate_safe(snh, snht, &lv->snapshot_segs)
if (!monitor_dev_for_events(cmd, dm_list_struct_base(snh, if (!monitor_dev_for_events(cmd, dm_list_struct_base(snh,
struct lv_segment, origin_list)->cow, monitor)) struct lv_segment, origin_list)->cow, monitor))
r = 0; r = 0;
return r;
}
/* /*
* If the volume is mirrored and its log is also mirrored, monitor * If the volume is mirrored and its log is also mirrored, monitor

View File

@ -105,8 +105,9 @@ int monitor_dev_for_events(struct cmd_context *cmd,
#ifdef DMEVENTD #ifdef DMEVENTD
# include "libdevmapper-event.h" # include "libdevmapper-event.h"
char *get_monitor_dso_path(struct cmd_context *cmd, const char *libpath); char *get_monitor_dso_path(struct cmd_context *cmd, const char *libpath);
int target_registered_with_dmeventd(struct cmd_context *cmd, const char *libpath, const char *lvid, int *pending); int target_registered_with_dmeventd(struct cmd_context *cmd, const char *libpath,
int target_register_events(struct cmd_context *cmd, const char *dso, const char *lvid, struct logical_volume *lv, int *pending);
int target_register_events(struct cmd_context *cmd, const char *dso, struct logical_volume *lv,
int evmask __attribute__((unused)), int set, int timeout); int evmask __attribute__((unused)), int set, int timeout);
#endif #endif

View File

@ -548,17 +548,18 @@ static const char *_get_mirror_dso_path(struct cmd_context *cmd)
DEFAULT_DMEVENTD_MIRROR_LIB)); DEFAULT_DMEVENTD_MIRROR_LIB));
} }
/* FIXME Cache this */
static int _target_registered(struct lv_segment *seg, int *pending) static int _target_registered(struct lv_segment *seg, int *pending)
{ {
return target_registered_with_dmeventd(seg->lv->vg->cmd, _get_mirror_dso_path(seg->lv->vg->cmd), return target_registered_with_dmeventd(seg->lv->vg->cmd, _get_mirror_dso_path(seg->lv->vg->cmd),
seg->lv->lvid.s, pending); seg->lv, pending);
} }
/* FIXME This gets run while suspended and performs banned operations. */ /* FIXME This gets run while suspended and performs banned operations. */
static int _target_set_events(struct lv_segment *seg, int evmask, int set) static int _target_set_events(struct lv_segment *seg, int evmask, int set)
{ {
return target_register_events(seg->lv->vg->cmd, _get_mirror_dso_path(seg->lv->vg->cmd), return target_register_events(seg->lv->vg->cmd, _get_mirror_dso_path(seg->lv->vg->cmd),
seg->lv->lvid.s, evmask, set, 0); seg->lv, evmask, set, 0);
} }
static int _target_monitor_events(struct lv_segment *seg, int events) static int _target_monitor_events(struct lv_segment *seg, int events)

View File

@ -168,10 +168,11 @@ static const char *_get_snapshot_dso_path(struct cmd_context *cmd)
DEFAULT_DMEVENTD_SNAPSHOT_LIB)); DEFAULT_DMEVENTD_SNAPSHOT_LIB));
} }
/* FIXME Cache this */
static int _target_registered(struct lv_segment *seg, int *pending) static int _target_registered(struct lv_segment *seg, int *pending)
{ {
return target_registered_with_dmeventd(seg->lv->vg->cmd, _get_snapshot_dso_path(seg->lv->vg->cmd), return target_registered_with_dmeventd(seg->lv->vg->cmd, _get_snapshot_dso_path(seg->lv->vg->cmd),
seg->cow->lvid.s, pending); seg->cow, pending);
} }
/* FIXME This gets run while suspended and performs banned operations. */ /* FIXME This gets run while suspended and performs banned operations. */
@ -179,7 +180,7 @@ static int _target_set_events(struct lv_segment *seg, int evmask, int set)
{ {
/* FIXME Make timeout (10) configurable */ /* FIXME Make timeout (10) configurable */
return target_register_events(seg->lv->vg->cmd, _get_snapshot_dso_path(seg->lv->vg->cmd), return target_register_events(seg->lv->vg->cmd, _get_snapshot_dso_path(seg->lv->vg->cmd),
seg->cow->lvid.s, evmask, set, 10); seg->cow, evmask, set, 10);
} }
static int _target_register_events(struct lv_segment *seg, static int _target_register_events(struct lv_segment *seg,

View File

@ -190,7 +190,7 @@ static int _vgchange_background_polling(struct cmd_context *cmd, struct volume_g
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, monitored; int lv_open, active, monitored = 0;
int available, ret_max = ECMD_PROCESSED; int available, ret_max = ECMD_PROCESSED;
int activate = 1; int activate = 1;