return 0;
dm_list_iterate_items(lvl, &vg->lvs)
- if (lv_is_visible(lvl->lv))
+ if (lv_is_visible(lvl->lv) && !lv_is_used_thin_pool(lvl->lv))
count += (_lv_open_count(vg->cmd, lvl->lv) > 0);
log_debug("Counted %d open LVs in VG %s", count, vg->name);
}
}
- if (lv_is_thin_pool(lv) && dm_list_size(&lv->segs_using_this_lv)) {
+ if (lv_is_used_thin_pool(lv)) {
/* remove thin LVs first */
if ((force == PROMPT) &&
yes_no_prompt("Do you really want to remove all thin volumes when removing"
} else if (seg_is_thin_volume(lp)) {
pool_lv = first_seg(lv)->pool_lv;
+ /* Ensure unused thin pool is not active */
+ if (!lv_is_used_thin_pool(pool_lv) &&
+ !deactivate_lv(cmd, pool_lv)) {
+ log_error("Failed to deactivate unused pool %s.",
+ pool_lv->name);
+ return NULL;
+ }
+
+ /*
+ * From now the thin pool de/activation is made
+ * only via implicit thin volume dependency.
+ */
+
if (!(first_seg(lv)->device_id =
get_free_pool_device_id(first_seg(pool_lv))))
return_NULL;
- if (!activate_lv(pool_lv->vg->cmd, pool_lv)) {
- log_error("Failed to activate %s/%s to send message.",
- pool_lv->vg->name, pool_lv->name);
- return NULL;
- }
-
if (!attach_pool_message(first_seg(pool_lv),
DM_THIN_MESSAGE_CREATE_THIN, lv, 0, 0))
return_NULL;
- /*
- * FIXME: Skipping deactivate_lv(pool_lv) as it is going to be needed anyway
- * but revert_new_lv should revert to deactivated state.
- */
}
if (lp->log_count &&
#define lv_is_thin_volume(lv) ((lv)->status & THIN_VOLUME ? 1 : 0)
#define lv_is_thin_pool(lv) ((lv)->status & THIN_POOL ? 1 : 0)
+#define lv_is_used_thin_pool(lv) (lv_is_thin_pool(lv) && !dm_list_empty(&(lv)->segs_using_this_lv))
#define lv_is_thin_pool_data(lv) ((lv)->status & THIN_POOL_DATA ? 1 : 0)
#define lv_is_thin_pool_metadata(lv) ((lv)->status & THIN_POOL_METADATA ? 1 : 0)
#define lv_is_mirrored(lv) ((lv)->status & MIRRORED ? 1 : 0)
return ECMD_FAILED;
}
+ if (lv_is_used_thin_pool(lv) &&
+ (arg_count(cmd, available_ARG))) {
+ log_error("Can't change pool volume \"%s\".", lv->name);
+ return ECMD_FAILED;
+ }
+
if (lv_is_cow(lv) && !lv_is_virtual_origin(origin_from_cow(lv)) &&
arg_count(cmd, available_ARG)) {
log_error("Can't change snapshot logical volume \"%s\"",
if (lv_is_virtual_origin(lvl->lv) && !arg_count(cmd, all_ARG))
continue;
+ /* Only unused thin pool can change its availability */
+ if (!lvargs_supplied && lv_is_used_thin_pool(lvl->lv) &&
+ arg_count(cmd, available_ARG))
+ continue;
+
/*
* Only let hidden LVs through it --all was used or the LVs
* were specifically named on the command line.
if (!lv_is_visible(lv))
continue;
+ /* Never manipulate with thin pools in use */
+ if (lv_is_used_thin_pool(lv))
+ continue;
+
/* If LV is sparse, activate origin instead */
if (lv_is_cow(lv) && lv_is_virtual_origin(origin_from_cow(lv)))
lv = origin_from_cow(lv);