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

Fix last check-ins: seg can be NULL.

This commit is contained in:
Alasdair Kergon 2009-02-28 20:04:24 +00:00
parent 2b23864219
commit 81680dce3c
11 changed files with 27 additions and 21 deletions

View File

@ -908,7 +908,8 @@ static int _add_segment_to_dtree(struct dev_manager *dm,
layer ? "-" : "", layer ? : ""); layer ? "-" : "", layer ? : "");
if (seg_present->segtype->ops->target_present && if (seg_present->segtype->ops->target_present &&
!seg_present->segtype->ops->target_present(seg_present, NULL)) { !seg_present->segtype->ops->target_present(seg_present->lv->vg->cmd,
seg_present, NULL)) {
log_error("Can't expand LV %s: %s target support missing " log_error("Can't expand LV %s: %s target support missing "
"from kernel?", seg->lv->name, seg_present->segtype->name); "from kernel?", seg->lv->name, seg_present->segtype->name);
return 0; return 0;

View File

@ -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); return dm_tree_node_add_error_target(node, len);
} }
static int _errseg_target_present(const struct lv_segment *seg, static int _errseg_target_present(struct cmd_context *cmd,
const struct lv_segment *seg __attribute((unused)),
unsigned *attributes __attribute((unused))) unsigned *attributes __attribute((unused)))
{ {
static int _errseg_checked = 0; static int _errseg_checked = 0;
@ -59,8 +60,8 @@ static int _errseg_target_present(const struct lv_segment *seg,
/* Reported truncated in older kernels */ /* Reported truncated in older kernels */
if (!_errseg_checked && if (!_errseg_checked &&
(target_present(seg->lv->vg->cmd, "error", 0) || (target_present(cmd, "error", 0) ||
target_present(seg->lv->vg->cmd, "erro", 0))) target_present(cmd, "erro", 0)))
_errseg_present = 1; _errseg_present = 1;
_errseg_checked = 1; _errseg_checked = 1;

View File

@ -1380,7 +1380,7 @@ int add_mirror_log(struct cmd_context *cmd, struct logical_volume *lv,
return_0; return_0;
if (activation() && segtype->ops->target_present && if (activation() && segtype->ops->target_present &&
!segtype->ops->target_present(NULL, NULL)) { !segtype->ops->target_present(cmd, NULL, NULL)) {
log_error("%s: Required device-mapper target(s) not " log_error("%s: Required device-mapper target(s) not "
"detected in your kernel", segtype->name); "detected in your kernel", segtype->name);
return 0; return 0;

View File

@ -78,7 +78,8 @@ struct segtype_handler {
struct lv_segment *seg, char *params, struct lv_segment *seg, char *params,
uint64_t *total_numerator, uint64_t *total_numerator,
uint64_t *total_denominator); uint64_t *total_denominator);
int (*target_present) (const struct lv_segment *seg, int (*target_present) (struct cmd_context *cmd,
const struct lv_segment *seg,
unsigned *attributes); unsigned *attributes);
int (*modules_needed) (struct dm_pool *mem, int (*modules_needed) (struct dm_pool *mem,
const struct lv_segment *seg, const struct lv_segment *seg,

View File

@ -343,7 +343,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); return add_areas_line(dm, seg, node, start_area, area_count);
} }
static int _mirrored_target_present(const struct lv_segment *seg, static int _mirrored_target_present(struct cmd_context *cmd,
const struct lv_segment *seg,
unsigned *attributes) unsigned *attributes)
{ {
static int _mirrored_checked = 0; static int _mirrored_checked = 0;
@ -353,7 +354,7 @@ static int _mirrored_target_present(const struct lv_segment *seg,
char vsn[80]; char vsn[80];
if (!_mirrored_checked) { if (!_mirrored_checked) {
_mirrored_present = target_present(seg->lv->vg->cmd, "mirror", 1); _mirrored_present = target_present(cmd, "mirror", 1);
/* /*
* block_on_error available with mirror target >= 1.1 and <= 1.11 * block_on_error available with mirror target >= 1.1 and <= 1.11
@ -375,8 +376,7 @@ static int _mirrored_target_present(const struct lv_segment *seg,
* FIXME: Fails incorrectly if cmirror was built into kernel. * FIXME: Fails incorrectly if cmirror was built into kernel.
*/ */
if (attributes) { if (attributes) {
if (!_mirror_attributes && module_present(seg->lv->vg->cmd, if (!_mirror_attributes && module_present(cmd, "log-clustered"))
"log-clustered"))
_mirror_attributes |= MIRROR_LOG_CLUSTERED; _mirror_attributes |= MIRROR_LOG_CLUSTERED;
*attributes = _mirror_attributes; *attributes = _mirror_attributes;
} }

View File

@ -108,15 +108,16 @@ static int _snap_target_percent(void **target_state __attribute((unused)),
return 1; return 1;
} }
static int _snap_target_present(const struct lv_segment *seg, static int _snap_target_present(struct cmd_context *cmd,
const struct lv_segment *seg __attribute((unused)),
unsigned *attributes __attribute((unused))) unsigned *attributes __attribute((unused)))
{ {
static int _snap_checked = 0; static int _snap_checked = 0;
static int _snap_present = 0; static int _snap_present = 0;
if (!_snap_checked) if (!_snap_checked)
_snap_present = target_present(seg->lv->vg->cmd, "snapshot", 1) && _snap_present = target_present(cmd, "snapshot", 1) &&
target_present(seg->lv->vg->cmd, "snapshot-origin", 0); target_present(cmd, "snapshot-origin", 0);
_snap_checked = 1; _snap_checked = 1;

View File

@ -175,15 +175,16 @@ static int _striped_add_target_line(struct dev_manager *dm,
return add_areas_line(dm, seg, node, 0u, seg->area_count); return add_areas_line(dm, seg, node, 0u, seg->area_count);
} }
static int _striped_target_present(const struct lv_segment *seg, static int _striped_target_present(struct cmd_context *cmd,
const struct lv_segment *seg __attribute((unused)),
unsigned *attributes __attribute((unused))) unsigned *attributes __attribute((unused)))
{ {
static int _striped_checked = 0; static int _striped_checked = 0;
static int _striped_present = 0; static int _striped_present = 0;
if (!_striped_checked) if (!_striped_checked)
_striped_present = target_present(seg->lv->vg->cmd, "linear", 0) && _striped_present = target_present(cmd, "linear", 0) &&
target_present(seg->lv->vg->cmd, "striped", 0); target_present(cmd, "striped", 0);
_striped_checked = 1; _striped_checked = 1;

View File

@ -50,14 +50,15 @@ static int _zero_add_target_line(struct dev_manager *dm __attribute((unused)),
return dm_tree_node_add_zero_target(node, len); return dm_tree_node_add_zero_target(node, len);
} }
static int _zero_target_present(const struct lv_segment *seg, static int _zero_target_present(struct cmd_context *cmd,
const struct lv_segment *seg __attribute((unused)),
unsigned *attributes __attribute((unused))) unsigned *attributes __attribute((unused)))
{ {
static int _zero_checked = 0; static int _zero_checked = 0;
static int _zero_present = 0; static int _zero_present = 0;
if (!_zero_checked) if (!_zero_checked)
_zero_present = target_present(seg->lv->vg->cmd, "zero", 0); _zero_present = target_present(cmd, "zero", 0);
_zero_checked = 1; _zero_checked = 1;

View File

@ -219,7 +219,7 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
} }
if (activation() && lp->segtype->ops->target_present && if (activation() && lp->segtype->ops->target_present &&
!lp->segtype->ops->target_present(NULL, NULL)) { !lp->segtype->ops->target_present(cmd, NULL, NULL)) {
log_error("%s: Required device-mapper target(s) not " log_error("%s: Required device-mapper target(s) not "
"detected in your kernel", lp->segtype->name); "detected in your kernel", lp->segtype->name);
return 0; return 0;

View File

@ -420,7 +420,7 @@ static int _lvcreate_params(struct lvcreate_params *lp, struct cmd_context *cmd,
} }
if (activation() && lp->segtype->ops->target_present && if (activation() && lp->segtype->ops->target_present &&
!lp->segtype->ops->target_present(NULL, NULL)) { !lp->segtype->ops->target_present(cmd, NULL, NULL)) {
log_error("%s: Required device-mapper target(s) not " log_error("%s: Required device-mapper target(s) not "
"detected in your kernel", lp->segtype->name); "detected in your kernel", lp->segtype->name);
return 0; return 0;

View File

@ -33,7 +33,7 @@ static int _pvmove_target_present(struct cmd_context *cmd, int clustered)
return_0; return_0;
if (activation() && segtype->ops->target_present && if (activation() && segtype->ops->target_present &&
!segtype->ops->target_present(NULL, clustered ? &attr : NULL)) !segtype->ops->target_present(cmd, NULL, clustered ? &attr : NULL))
found = 0; found = 0;
if (activation() && clustered) { if (activation() && clustered) {