1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

Fix lvscan snapshot full display.

dmeventd fixes
This commit is contained in:
Alasdair Kergon 2005-12-08 17:49:34 +00:00
parent 3c588200fe
commit e64934773b
7 changed files with 51 additions and 22 deletions

View File

@ -1,5 +1,6 @@
Version 2.02.02 - Version 2.02.02 -
==================================== ====================================
Fix lvscan snapshot full display.
Bring lvdisplay man page example into line. Bring lvdisplay man page example into line.
Add mirror dmeventd library. Add mirror dmeventd library.
Add some activation logic to remove_mirror_images(). Add some activation logic to remove_mirror_images().

View File

@ -577,10 +577,11 @@ static int _register_dev(struct cmd_context *cmd, struct logical_volume *lv,
list_iterate(tmp, &lv->segments) { list_iterate(tmp, &lv->segments) {
seg = list_item(tmp, struct lv_segment); seg = list_item(tmp, struct lv_segment);
if (do_reg) if (do_reg) {
reg = seg->segtype->ops->target_register; if (seg->segtype->ops->target_register_events)
else reg = seg->segtype->ops->target_register_events;
reg = seg->segtype->ops->target_unregister; } else if(seg->setype->ops->target_unregister_events)
reg = seg->segtype->ops->target_unregister_events;
if (reg) if (reg)
/* FIXME specify events */ /* FIXME specify events */
@ -589,6 +590,7 @@ static int _register_dev(struct cmd_context *cmd, struct logical_volume *lv,
return 0; return 0;
} }
} }
return 1; return 1;
} }
#endif #endif

View File

@ -78,9 +78,11 @@ struct segtype_handler {
uint64_t *total_denominator, float *percent); uint64_t *total_denominator, float *percent);
int (*target_present) (void); int (*target_present) (void);
void (*destroy) (const struct segment_type * segtype); void (*destroy) (const struct segment_type * segtype);
int (*target_register) (struct dm_pool *mem, struct lv_segment *seg, int (*target_register_events) (struct dm_pool *mem,
struct lv_segment *seg,
struct config_tree *cft, int events); struct config_tree *cft, int events);
int (*target_unregister) (struct dm_pool *mem, struct lv_segment *seg, int (*target_unregister_events) (struct dm_pool *mem,
struct lv_segment *seg,
struct config_tree *cft, int events); struct config_tree *cft, int events);
}; };

View File

@ -341,7 +341,8 @@ static int _setup_registration(struct dm_pool *mem, struct config_tree *cft,
} }
/* FIXME This gets run while suspended and performs banned operations. */ /* FIXME This gets run while suspended and performs banned operations. */
static int _target_register(struct dm_pool *mem, struct lv_segment *seg, static int _target_register_events(struct dm_pool *mem,
struct lv_segment *seg,
struct config_tree *cft, int events) struct config_tree *cft, int events)
{ {
char *dso; char *dso;
@ -362,7 +363,7 @@ static int _target_register(struct dm_pool *mem, struct lv_segment *seg,
strncpy(dm_name, build_dm_name(mem, vg->name, lv->name, NULL), strncpy(dm_name, build_dm_name(mem, vg->name, lv->name, NULL),
PATH_MAX); PATH_MAX);
if((err = dm_event_register(dso, dm_name, ALL_ERRORS)) < 0) { if((err = dm_event_register(dso, dm_name, DM_EVENT_ALL_ERRORS)) < 0) {
log_error("Unable to register %s for events: %s", dm_name, log_error("Unable to register %s for events: %s", dm_name,
strerror(-err)); strerror(-err));
return 0; return 0;
@ -372,7 +373,8 @@ static int _target_register(struct dm_pool *mem, struct lv_segment *seg,
return 1; return 1;
} }
static int _target_unregister(struct dm_pool *mem, struct lv_segment *seg, static int _target_unregister_events(struct dm_pool *mem,
struct lv_segment *seg,
struct config_tree *cft, int events) struct config_tree *cft, int events)
{ {
char *dso; char *dso;
@ -424,8 +426,8 @@ static struct segtype_handler _mirrored_ops = {
target_present:_target_present, target_present:_target_present,
#endif #endif
#ifdef DMEVENTD #ifdef DMEVENTD
target_register:_target_register, target_register_events:_target_register_events,
target_unregister:_target_unregister, target_unregister_events:_target_unregister_events,
#endif #endif
destroy:_destroy, destroy:_destroy,
}; };

View File

@ -87,12 +87,12 @@ ifeq ("@CMDLIB@", "yes")
INSTALL_TARGETS += $(INSTALL_CMDLIB_TARGETS) INSTALL_TARGETS += $(INSTALL_CMDLIB_TARGETS)
endif endif
ifeq ("@DEVMAPPER@", "yes") ifeq ("@DMEVENTD@", "yes")
LVMLIBS += -ldevmapper LVMLIBS += -ldevmapper-event -lpthread
endif endif
ifeq ("@DMEVENTD@", "yes") ifeq ("@DEVMAPPER@", "yes")
LVMLIBS += -ldevmapper-event LVMLIBS += -ldevmapper
endif endif
CFLAGS += -DLVM_SHARED_PATH=\"$(exec_prefix)/sbin/lvm\" CFLAGS += -DLVM_SHARED_PATH=\"$(exec_prefix)/sbin/lvm\"

View File

@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved. * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved.
* *
* This file is part of LVM2. * This file is part of LVM2.
* *
@ -21,6 +21,9 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
struct lvinfo info; struct lvinfo info;
int lv_total = 0; int lv_total = 0;
uint64_t lv_capacity_total = 0; uint64_t lv_capacity_total = 0;
int inkernel, snap_active = 1;
struct lv_segment *snap_seg = NULL;
float snap_percent; /* fused, fsize; */
const char *active_str, *snapshot_str; const char *active_str, *snapshot_str;
@ -29,8 +32,27 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
!(lv_is_cow(lv))) !(lv_is_cow(lv)))
return ECMD_PROCESSED; return ECMD_PROCESSED;
inkernel = lv_info(cmd, lv, &info, 1) && info.exists;
if (lv_is_origin(lv)) {
list_iterate_items_gen(snap_seg, &lv->snapshot_segs,
origin_list) {
if (inkernel &&
(snap_active = lv_snapshot_percent(snap_seg->cow,
&snap_percent)))
if (snap_percent < 0 || snap_percent >= 100)
snap_active = 0;
}
snap_seg = NULL;
} else if ((snap_seg = find_cow(lv))) {
if (inkernel &&
(snap_active = lv_snapshot_percent(snap_seg->cow,
&snap_percent)))
if (snap_percent < 0 || snap_percent >= 100)
snap_active = 0;
}
/* FIXME Add -D arg to skip this! */ /* FIXME Add -D arg to skip this! */
if (lv_info(cmd, lv, &info, 0) && info.exists) if (inkernel && snap_active)
active_str = "ACTIVE "; active_str = "ACTIVE ";
else else
active_str = "inactive "; active_str = "inactive ";

View File

@ -78,7 +78,7 @@ static int pvcreate_check(struct cmd_context *cmd, const char *name)
} }
if (!dev) { if (!dev) {
log_error("Device %s not found.", name); log_error("Device %s not found (or ignored by filtering).", name);
return 0; return 0;
} }