mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-30 10:50:34 +03:00
Some basic checking for presence of device-mapper targets.
This commit is contained in:
parent
cb919290c2
commit
224565478c
@ -2034,6 +2034,58 @@ static int _remove_suspended_lvs(struct dev_manager *dm,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _targets_present(struct dev_manager *dm, struct list *lvs)
|
||||
{
|
||||
struct logical_volume *lv;
|
||||
struct list *lvh;
|
||||
struct segment_type *segtype;
|
||||
int snapshots = 0, mirrors = 0;
|
||||
|
||||
list_iterate(lvh, lvs) {
|
||||
lv = list_item(lvh, struct lv_list)->lv;
|
||||
|
||||
if (!snapshots)
|
||||
if (lv_is_cow(lv) || lv_is_origin(lv))
|
||||
snapshots = 1;
|
||||
|
||||
if (!mirrors)
|
||||
if (lv->status & PVMOVE)
|
||||
mirrors = 1;
|
||||
}
|
||||
|
||||
if (mirrors) {
|
||||
if (!(segtype = get_segtype_from_string(dm->cmd, "mirror"))) {
|
||||
log_error("Can't expand LV: Mirror support "
|
||||
"missing from tools?");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!segtype->ops->target_present ||
|
||||
!segtype->ops->target_present()) {
|
||||
log_error("Can't expand LV: Mirror support missing "
|
||||
"from kernel?");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (snapshots) {
|
||||
if (!(segtype = get_segtype_from_string(dm->cmd, "snapshot"))) {
|
||||
log_error("Can't expand LV: Snapshot support "
|
||||
"missing from tools?");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!segtype->ops->target_present ||
|
||||
!segtype->ops->target_present()) {
|
||||
log_error("Can't expand LV: Snapshot support missing "
|
||||
"from kernel?");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _fill_in_active_list(struct dev_manager *dm, struct volume_group *vg)
|
||||
{
|
||||
char *dlid;
|
||||
@ -2116,6 +2168,12 @@ static int _action(struct dev_manager *dm, struct logical_volume *lv,
|
||||
}
|
||||
}
|
||||
|
||||
if (!_targets_present(dm, &dm->active_list) ||
|
||||
!_targets_present(dm, &dm->reload_list)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!_execute(dm, lv->vg)) {
|
||||
stack;
|
||||
return 0;
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "defaults.h"
|
||||
#include "lvm-string.h"
|
||||
#include "targets.h"
|
||||
#include "activate.h"
|
||||
|
||||
enum {
|
||||
MIRR_DISABLED,
|
||||
@ -192,6 +193,19 @@ static int _target_percent(void **target_state, struct pool *mem,
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _target_present(void)
|
||||
{
|
||||
static int checked = 0;
|
||||
static int present = 0;
|
||||
|
||||
if (!checked)
|
||||
present = target_present("mirror");
|
||||
|
||||
checked = 1;
|
||||
|
||||
return present;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void _destroy(const struct segment_type *segtype)
|
||||
@ -208,6 +222,7 @@ static struct segtype_handler _mirrored_ops = {
|
||||
#ifdef DEVMAPPER_SUPPORT
|
||||
compose_target_line:_compose_target_line,
|
||||
target_percent:_target_percent,
|
||||
target_present:_target_present,
|
||||
#endif
|
||||
destroy:_destroy,
|
||||
};
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "segtypes.h"
|
||||
#include "text_export.h"
|
||||
#include "config.h"
|
||||
#include "activate.h"
|
||||
|
||||
static const char *_name(const struct lv_segment *seg)
|
||||
{
|
||||
@ -86,6 +87,7 @@ static int _text_export(const struct lv_segment *seg, struct formatter *f)
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef DEVMAPPER_SUPPORT
|
||||
static int _target_percent(void **target_state, struct pool *mem,
|
||||
struct config_tree *cft, struct lv_segment *seg,
|
||||
char *params, uint64_t *total_numerator,
|
||||
@ -108,6 +110,21 @@ static int _target_percent(void **target_state, struct pool *mem,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _target_present(void)
|
||||
{
|
||||
static int checked = 0;
|
||||
static int present = 0;
|
||||
|
||||
if (!checked)
|
||||
present = target_present("snapshot") &&
|
||||
target_present("snapshot-origin");
|
||||
|
||||
checked = 1;
|
||||
|
||||
return present;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void _destroy(const struct segment_type *segtype)
|
||||
{
|
||||
dbg_free((void *) segtype);
|
||||
@ -117,7 +134,10 @@ static struct segtype_handler _snapshot_ops = {
|
||||
name:_name,
|
||||
text_import:_text_import,
|
||||
text_export:_text_export,
|
||||
#ifdef DEVMAPPER_SUPPORT
|
||||
target_percent:_target_percent,
|
||||
target_present:_target_present,
|
||||
#endif
|
||||
destroy:_destroy,
|
||||
};
|
||||
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "str_list.h"
|
||||
#include "targets.h"
|
||||
#include "lvm-string.h"
|
||||
#include "activate.h"
|
||||
|
||||
static const char *_name(const struct lv_segment *seg)
|
||||
{
|
||||
@ -167,6 +168,18 @@ static int _compose_target_line(struct dev_manager *dm, struct pool *mem,
|
||||
return compose_areas_line(dm, seg, params, paramsize, pos, 0u,
|
||||
seg->area_count);
|
||||
}
|
||||
|
||||
static int _target_present(void)
|
||||
{
|
||||
static int checked = 0;
|
||||
static int present = 0;
|
||||
|
||||
if (!checked)
|
||||
present = target_present("linear") && target_present("striped");
|
||||
|
||||
checked = 1;
|
||||
return present;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void _destroy(const struct segment_type *segtype)
|
||||
@ -183,6 +196,7 @@ static struct segtype_handler _striped_ops = {
|
||||
merge_segments:_merge_segments,
|
||||
#ifdef DEVMAPPER_SUPPORT
|
||||
compose_target_line:_compose_target_line,
|
||||
target_present:_target_present,
|
||||
#endif
|
||||
destroy:_destroy,
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user