summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZdenek Kabelac <zkabelac@redhat.com>2014-11-04 10:33:35 +0100
committerZdenek Kabelac <zkabelac@redhat.com>2014-11-04 15:29:22 +0100
commit00a45ca491de21336f8d1d0253344995cea3b4f0 (patch)
tree314d556ba64409b0b932d7f9ff6b818425f5b3b6
parent8563c3e1a96f0d7ad180c859e9bf23a90e63e907 (diff)
downloadlvm2-00a45ca491de21336f8d1d0253344995cea3b4f0.tar.gz
thin: new pool is activated without overlay
Activate of new/unused/empty thin pool volume skips the 'overlay' part and directly provides 'visible' thin-pool LV to the user. Such thin pool still gets 'private' -tpool UUID suffix for easier udev detection of protected lvm2 devices, and also gets udev flags to avoid any scan. Such pool device is 'public' LV with regular /dev/vgname/poolname link, but it's still 'udev' hidden device for any other use. To display proper active state we need to do few explicit tests for this condition. Before it's used for any lvm2 thin volume, deactivation is now needed to avoid any 'race' with external usage.
-rw-r--r--lib/activate/activate.c4
-rw-r--r--lib/activate/dev_manager.c15
2 files changed, 16 insertions, 3 deletions
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 49e86e734..c2a662f03 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -641,6 +641,10 @@ int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_la
fs_unlock(); /* For non clustered - wait if there are non-delete ops */
}
+ /* New thin-pool has no layer, but -tpool suffix needs to be queried */
+ if (!use_layer && lv_is_new_thin_pool(lv))
+ use_layer = 1;
+
if (!dev_manager_info(cmd->mem, lv,
(use_layer) ? lv_layer(lv) : NULL,
with_open_count, with_read_ahead,
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 41911c127..e81c5d33d 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1527,7 +1527,11 @@ static uint16_t _get_udev_flags(struct dev_manager *dm, const struct logical_vol
* If not, create just the /dev/mapper content.
*/
/* FIXME: add target's method for this */
- if (layer || !lv_is_visible(lv) || lv_is_thin_pool(lv))
+ if (lv_is_new_thin_pool(lv))
+ /* New thin-pool is regular LV with -tpool UUID suffix. */
+ udev_flags |= DM_UDEV_DISABLE_DISK_RULES_FLAG |
+ DM_UDEV_DISABLE_OTHER_RULES_FLAG;
+ else if (layer || !lv_is_visible(lv) || lv_is_thin_pool(lv))
udev_flags |= DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG |
DM_UDEV_DISABLE_DISK_RULES_FLAG |
DM_UDEV_DISABLE_OTHER_RULES_FLAG;
@@ -2604,6 +2608,10 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
if (!(name = dm_build_dm_name(dm->mem, lv->vg->name, lv->name, layer)))
return_0;
+ /* Even unused thin-pool still needs to get layered UUID -suffix */
+ if (!layer && lv_is_new_thin_pool(lv))
+ layer = lv_layer(lv);
+
if (!(dlid = build_dm_uuid(dm->mem, lv, layer)))
return_0;
@@ -2679,8 +2687,9 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
return_0;
if (!_add_snapshot_target_to_dtree(dm, dnode, lv, laopts))
return_0;
- } else if ((lv_is_external_origin(lv) || lv_is_thin_pool(lv)) && !layer) {
- /* External origin or Thin pool is using layer */
+ } else if (!layer && ((lv_is_thin_pool(lv) && !lv_is_new_thin_pool(lv)) ||
+ lv_is_external_origin(lv))) {
+ /* External origin or 'used' Thin pool is using layer */
if (!_add_new_lv_to_dtree(dm, dtree, lv, laopts, lv_layer(lv)))
return_0;
if (!_add_layer_target_to_dtree(dm, dnode, lv))