mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
Add detection of clustered mirror log capability.
Currently only check for kernel module presence.
This commit is contained in:
parent
9da5d7ac02
commit
5619c629f6
@ -1,5 +1,6 @@
|
||||
Version 2.02.34 -
|
||||
===================================
|
||||
Add detection of clustered mirror log capability.
|
||||
Add check to vg_commit() ensuring VG lock held before writing new VG metadata.
|
||||
Add validation of LV name to pvmove -n.
|
||||
Make clvmd refresh the context correctly when lvm.conf is updated.
|
||||
|
@ -391,12 +391,26 @@ int target_version(const char *target_name, uint32_t *maj,
|
||||
return r;
|
||||
}
|
||||
|
||||
int module_present(const char *target_name)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef MODPROBE_CMD
|
||||
char module[128];
|
||||
|
||||
if (dm_snprintf(module, sizeof(module), "dm-%s", target_name) < 0) {
|
||||
log_error("module_present module name too long: %s",
|
||||
target_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = exec_cmd(MODPROBE_CMD, module, "", "");
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
int target_present(const char *target_name, int use_modprobe)
|
||||
{
|
||||
uint32_t maj, min, patchlevel;
|
||||
#ifdef MODPROBE_CMD
|
||||
char module[128];
|
||||
#endif
|
||||
|
||||
if (!activation())
|
||||
return 0;
|
||||
@ -406,14 +420,7 @@ int target_present(const char *target_name, int use_modprobe)
|
||||
if (target_version(target_name, &maj, &min, &patchlevel))
|
||||
return 1;
|
||||
|
||||
if (dm_snprintf(module, sizeof(module), "dm-%s", target_name)
|
||||
< 0) {
|
||||
log_error("target_present module name too long: %s",
|
||||
target_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!exec_cmd(MODPROBE_CMD, module, "", ""))
|
||||
if (!module_present(target_name))
|
||||
return_0;
|
||||
}
|
||||
#endif
|
||||
|
@ -30,6 +30,9 @@ struct lvinfo {
|
||||
uint32_t read_ahead;
|
||||
};
|
||||
|
||||
/* target attribute flags */
|
||||
#define MIRROR_LOG_CLUSTERED 0x00000001U
|
||||
|
||||
void set_activation(int activation);
|
||||
int activation(void);
|
||||
|
||||
@ -37,6 +40,7 @@ int driver_version(char *version, size_t size);
|
||||
int library_version(char *version, size_t size);
|
||||
int lvm1_present(struct cmd_context *cmd);
|
||||
|
||||
int module_present(const char *target_name);
|
||||
int target_present(const char *target_name, int use_modprobe);
|
||||
int target_version(const char *target_name, uint32_t *maj,
|
||||
uint32_t *min, uint32_t *patchlevel);
|
||||
|
@ -823,7 +823,7 @@ static int _add_segment_to_dtree(struct dev_manager *dm,
|
||||
layer ? "-" : "", layer ? : "");
|
||||
|
||||
if (seg_present->segtype->ops->target_present &&
|
||||
!seg_present->segtype->ops->target_present(seg_present)) {
|
||||
!seg_present->segtype->ops->target_present(seg_present, NULL)) {
|
||||
log_error("Can't expand LV %s: %s target support missing "
|
||||
"from kernel?", seg->lv->name, seg_present->segtype->name);
|
||||
return 0;
|
||||
|
@ -51,7 +51,8 @@ static int _errseg_add_target_line(struct dev_manager *dm __attribute((unused)),
|
||||
return dm_tree_node_add_error_target(node, len);
|
||||
}
|
||||
|
||||
static int _errseg_target_present(const struct lv_segment *seg __attribute((unused)))
|
||||
static int _errseg_target_present(const struct lv_segment *seg __attribute((unused)),
|
||||
unsigned *attributes __attribute((unused)))
|
||||
{
|
||||
static int _errseg_checked = 0;
|
||||
static int _errseg_present = 0;
|
||||
|
@ -1300,7 +1300,7 @@ int add_mirror_log(struct cmd_context *cmd,
|
||||
return_0;
|
||||
|
||||
if (activation() && segtype->ops->target_present &&
|
||||
!segtype->ops->target_present(NULL)) {
|
||||
!segtype->ops->target_present(NULL, NULL)) {
|
||||
log_error("%s: Required device-mapper target(s) not "
|
||||
"detected in your kernel", segtype->name);
|
||||
return 0;
|
||||
|
@ -78,7 +78,8 @@ struct segtype_handler {
|
||||
struct lv_segment *seg, char *params,
|
||||
uint64_t *total_numerator,
|
||||
uint64_t *total_denominator, float *percent);
|
||||
int (*target_present) (const struct lv_segment *seg);
|
||||
int (*target_present) (const struct lv_segment *seg,
|
||||
unsigned *attributes);
|
||||
int (*modules_needed) (struct dm_pool *mem,
|
||||
const struct lv_segment *seg,
|
||||
struct list *modules);
|
||||
|
@ -33,6 +33,7 @@
|
||||
#endif
|
||||
|
||||
static int _block_on_error_available = 0;
|
||||
static unsigned _mirror_attributes = 0;
|
||||
|
||||
enum {
|
||||
MIRR_DISABLED,
|
||||
@ -343,7 +344,8 @@ static int _mirrored_add_target_line(struct dev_manager *dm, struct dm_pool *mem
|
||||
return add_areas_line(dm, seg, node, start_area, area_count);
|
||||
}
|
||||
|
||||
static int _mirrored_target_present(const struct lv_segment *seg __attribute((unused)))
|
||||
static int _mirrored_target_present(const struct lv_segment *seg __attribute((unused)),
|
||||
unsigned *attributes)
|
||||
{
|
||||
static int _mirrored_checked = 0;
|
||||
static int _mirrored_present = 0;
|
||||
@ -369,6 +371,15 @@ static int _mirrored_target_present(const struct lv_segment *seg __attribute((un
|
||||
_block_on_error_available = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check only for modules if atttributes requested and no previous check.
|
||||
* FIXME: need better check
|
||||
*/
|
||||
if (attributes) {
|
||||
if (!_mirror_attributes && module_present("cmirror"))
|
||||
_mirror_attributes |= MIRROR_LOG_CLUSTERED;
|
||||
*attributes = _mirror_attributes;
|
||||
}
|
||||
_mirrored_checked = 1;
|
||||
|
||||
return _mirrored_present;
|
||||
|
@ -114,7 +114,8 @@ static int _snap_target_percent(void **target_state __attribute((unused)),
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _snap_target_present(const struct lv_segment *seg __attribute((unused)))
|
||||
static int _snap_target_present(const struct lv_segment *seg __attribute((unused)),
|
||||
unsigned *attributes __attribute((unused)))
|
||||
{
|
||||
static int _snap_checked = 0;
|
||||
static int _snap_present = 0;
|
||||
|
@ -175,7 +175,8 @@ static int _striped_add_target_line(struct dev_manager *dm,
|
||||
return add_areas_line(dm, seg, node, 0u, seg->area_count);
|
||||
}
|
||||
|
||||
static int _striped_target_present(const struct lv_segment *seg __attribute((unused)))
|
||||
static int _striped_target_present(const struct lv_segment *seg __attribute((unused)),
|
||||
unsigned *attributes __attribute((unused)))
|
||||
{
|
||||
static int _striped_checked = 0;
|
||||
static int _striped_present = 0;
|
||||
|
@ -50,7 +50,8 @@ static int _zero_add_target_line(struct dev_manager *dm __attribute((unused)),
|
||||
return dm_tree_node_add_zero_target(node, len);
|
||||
}
|
||||
|
||||
static int _zero_target_present(const struct lv_segment *seg __attribute((unused)))
|
||||
static int _zero_target_present(const struct lv_segment *seg __attribute((unused)),
|
||||
unsigned *attributes __attribute((unused)))
|
||||
{
|
||||
static int _zero_checked = 0;
|
||||
static int _zero_present = 0;
|
||||
|
@ -219,7 +219,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
if (activation() && lp->segtype->ops->target_present &&
|
||||
!lp->segtype->ops->target_present(NULL)) {
|
||||
!lp->segtype->ops->target_present(NULL, NULL)) {
|
||||
log_error("%s: Required device-mapper target(s) not "
|
||||
"detected in your kernel", lp->segtype->name);
|
||||
return 0;
|
||||
|
@ -420,7 +420,7 @@ static int _lvcreate_params(struct lvcreate_params *lp, struct cmd_context *cmd,
|
||||
}
|
||||
|
||||
if (activation() && lp->segtype->ops->target_present &&
|
||||
!lp->segtype->ops->target_present(NULL)) {
|
||||
!lp->segtype->ops->target_present(NULL, NULL)) {
|
||||
log_error("%s: Required device-mapper target(s) not "
|
||||
"detected in your kernel", lp->segtype->name);
|
||||
return 0;
|
||||
|
@ -17,6 +17,30 @@
|
||||
#include "polldaemon.h"
|
||||
#include "display.h"
|
||||
|
||||
static int pvmove_target_present(struct cmd_context *cmd, int clustered)
|
||||
{
|
||||
const struct segment_type *segtype;
|
||||
unsigned attr = 0;
|
||||
|
||||
if (!(segtype = get_segtype_from_string(cmd, "mirror")))
|
||||
return_0;
|
||||
|
||||
if (activation() && segtype->ops->target_present &&
|
||||
!segtype->ops->target_present(NULL, clustered ? &attr : NULL)) {
|
||||
log_error("%s: Required device-mapper target(s) not "
|
||||
"detected in your kernel", segtype->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (clustered && !(attr & MIRROR_LOG_CLUSTERED)) {
|
||||
log_error("%s: Required device-mapper clustered log "
|
||||
"module not detected in your kernel", segtype->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Allow /dev/vgname/lvname, vgname/lvname or lvname */
|
||||
static const char *_extract_lvname(struct cmd_context *cmd, const char *vgname,
|
||||
const char *arg)
|
||||
@ -540,17 +564,9 @@ int pvmove(struct cmd_context *cmd, int argc, char **argv)
|
||||
char *pv_name = NULL;
|
||||
char *colon;
|
||||
int ret;
|
||||
const struct segment_type *segtype;
|
||||
|
||||
if (!(segtype = get_segtype_from_string(cmd, "mirror")))
|
||||
return_0;
|
||||
|
||||
if (activation() && segtype->ops->target_present &&
|
||||
!segtype->ops->target_present(NULL)) {
|
||||
log_error("%s: Required device-mapper target(s) not "
|
||||
"detected in your kernel", segtype->name);
|
||||
if (!pvmove_target_present(cmd, 0))
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (argc) {
|
||||
pv_name = argv[0];
|
||||
|
Loading…
Reference in New Issue
Block a user