From 14f782c5a752251f6fc418a1582f8967fb6877bd Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Fri, 21 Jun 2024 11:08:30 +0200 Subject: [PATCH] dev_manager: no layer suffix for component Do not attach layer suffix to the UUID when activating component LV. In this case we want to see allow this LV to be public, thus such LV should not be using -layer suffix in its UUID. This also requires that our 'cached' access will check for both UUID (with & without suffix) which was unnoticed issue before. This change is now necesssary since our udev rule automatically expects any LV with -layer suffix is private and will prevent generaring any systemd unit even when there are no 'DM' flags bits passed via cookie mechanism while creating such LV. --- lib/activate/dev_manager.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c index 4d6e5c169..e9054a929 100644 --- a/lib/activate/dev_manager.c +++ b/lib/activate/dev_manager.c @@ -1053,6 +1053,7 @@ int dev_manager_info(struct cmd_context *cmd, struct dm_info *dminfo, uint32_t *read_ahead, struct lv_seg_status *seg_status) { + char old_style_dlid[sizeof(UUID_PREFIX) + 2 * ID_LEN]; char *dlid, *name; int r = 0; @@ -1062,8 +1063,11 @@ int dev_manager_info(struct cmd_context *cmd, if (!(dlid = build_dm_uuid(cmd->mem, lv, layer))) goto_out; + dm_strncpy(old_style_dlid, dlid, sizeof(old_style_dlid)); + if (cmd->cache_dm_devs && - !dm_device_list_find_by_uuid(cmd->cache_dm_devs, dlid, NULL)) { + !dm_device_list_find_by_uuid(cmd->cache_dm_devs, dlid, NULL) && + !dm_device_list_find_by_uuid(cmd->cache_dm_devs, old_style_dlid, NULL)) { log_debug("Cached as inactive %s.", name); if (dminfo) memset(dminfo, 0, sizeof(*dminfo)); @@ -3633,7 +3637,11 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, if (!layer && lv_is_writecache_origin(lv)) layer = lv_layer(lv); /* "real" */ - if (!(dlid = build_dm_uuid(dm->mem, lv, layer))) + if (lvlayer->visible_component) { + /* Component LV will be public, do not add any layer suffixes */ + if (!(dlid = dm_build_dm_uuid(dm->mem, UUID_PREFIX, lv->lvid.s, NULL))) + return_0; + } else if (!(dlid = build_dm_uuid(dm->mem, lv,layer))) return_0; /* We've already processed this node if it already has a context ptr */