]> sourceware.org Git - lvm2.git/commitdiff
writecache: use dm suffixes and lv attributes
authorDavid Teigland <teigland@redhat.com>
Fri, 20 Sep 2019 19:04:18 +0000 (14:04 -0500)
committerDavid Teigland <teigland@redhat.com>
Fri, 20 Sep 2019 19:08:51 +0000 (14:08 -0500)
- use internal CACHE_VOL flag on cachevol LV
- add suffixes to dm uuids for internal LVs
- display appropriate letters in the LV attr field
- display writecache's cachevol in lvs output

lib/metadata/lv.c
lib/metadata/metadata-exported.h
lib/metadata/metadata.c
lib/misc/lvm-string.c
lib/writecache/writecache.c
tools/lvconvert.c

index b4ed712a005968711cac92e540c270181c07b910..4c2ab2bbf961e9ef08a17892f97fe4f2dc6d3177 100644 (file)
@@ -716,6 +716,9 @@ struct logical_volume *lv_pool_lv(const struct logical_volume *lv)
        if (lv_is_vdo(lv))
                return seg_lv(first_seg(lv), 0);
 
+       if (lv_is_writecache(lv))
+               return first_seg(lv)->writecache;
+
        return NULL;
 }
 
@@ -1235,7 +1238,7 @@ char *lv_attr_dup_with_info_and_seg_status(struct dm_pool *mem, const struct lv_
                repstr[0] = 'l';
        else if (lv_is_cow(lv))
                repstr[0] = (lv_is_merging_cow(lv)) ? 'S' : 's';
-       else if (lv_is_cache_origin(lv))
+       else if (lv_is_cache_origin(lv) || lv_is_writecache_origin(lv))
                repstr[0] = 'o';
        else
                repstr[0] = '-';
@@ -1314,7 +1317,12 @@ char *lv_attr_dup_with_info_and_seg_status(struct dm_pool *mem, const struct lv_
 
        if (lv_is_thin_pool(lv) || lv_is_thin_volume(lv))
                repstr[6] = 't';
-       else if (lv_is_cache_pool(lv) || lv_is_cache_vol(lv) || lv_is_cache(lv) || lv_is_cache_origin(lv))
+       else if (lv_is_cache_pool(lv) ||
+                lv_is_cache_vol(lv) ||
+                lv_is_cache(lv) ||
+                lv_is_cache_origin(lv) ||
+                lv_is_writecache(lv) ||
+                lv_is_writecache_origin(lv))
                repstr[6] = 'C';
        else if (lv_is_raid_type(lv))
                repstr[6] = 'r';
index 1c10390b3283baa9aec2b645ec62658f3aab46ea..63d3fade134ab7175ae83f908a79fdc862447efc 100644 (file)
 #define lv_is_removed(lv)      (((lv)->status & LV_REMOVED) ? 1 : 0)
 
 /* Recognize component LV (matching lib/misc/lvm-string.c _lvname_has_reserved_component_string()) */
-#define lv_is_component(lv) (lv_is_cache_origin(lv) || ((lv)->status & (\
-       CACHE_POOL_DATA |\
-       CACHE_POOL_METADATA |\
-       LV_VDO_POOL_DATA |\
-       MIRROR_IMAGE |\
-       MIRROR_LOG |\
-       RAID_IMAGE |\
-       RAID_META |\
-       THIN_POOL_DATA |\
-       THIN_POOL_METADATA)) ? 1 : 0)
+#define lv_is_component(lv) (lv_is_cache_origin(lv) || \
+                            lv_is_writecache_origin(lv) || \
+                            ((lv)->status & (\
+                                             CACHE_POOL_DATA |\
+                                             CACHE_POOL_METADATA |\
+                                             LV_CACHE_VOL |\
+                                             LV_VDO_POOL_DATA |\
+                                             MIRROR_IMAGE |\
+                                             MIRROR_LOG |\
+                                             RAID_IMAGE |\
+                                             RAID_META |\
+                                             THIN_POOL_DATA |\
+                                             THIN_POOL_METADATA)) ? 1 : 0)
 
 int lv_layout_and_role(struct dm_pool *mem, const struct logical_volume *lv,
                       struct dm_list **layout, struct dm_list **role);
@@ -1077,6 +1080,7 @@ int lv_is_cow(const struct logical_volume *lv);
 #define lv_is_thick_snapshot lv_is_cow
 
 int lv_is_cache_origin(const struct logical_volume *lv);
+int lv_is_writecache_origin(const struct logical_volume *lv);
 
 int lv_is_merging_cow(const struct logical_volume *cow);
 uint32_t cow_max_extents(const struct logical_volume *origin, uint32_t chunk_size);
index b43496793c3a46a2ff46c8166257470771954248..dc88d877a585761560fa87f78e9589cb7921f266 100644 (file)
@@ -5166,3 +5166,17 @@ struct volume_group *vg_read_for_update(struct cmd_context *cmd, const char *vg_
 
        return vg;
 }
+
+int lv_is_writecache_origin(const struct logical_volume *lv)
+{
+       struct seg_list *sl;
+
+       dm_list_iterate_items(sl, &lv->segs_using_this_lv) {
+               if (!sl->seg || !sl->seg->lv || !sl->seg->origin)
+                       continue;
+               if (lv_is_writecache(sl->seg->lv) && (sl->seg->origin == lv))
+                       return 1;
+       }
+       return 0;
+}
+
index b7c1c121e842ea2cd3aa81d4c0daf57b2c0b9eca..4034b405d1b8b6809e8f07343888e00bc857b9d3 100644 (file)
@@ -158,6 +158,7 @@ static const char *_lvname_has_reserved_component_string(const char *lvname)
                "_cmeta",
                "_corig",
                "_cvol",
+               "_wcorig",
                "_mimage",
                "_mlog",
                "_rimage",
@@ -249,6 +250,7 @@ char *build_dm_uuid(struct dm_pool *mem, const struct logical_volume *lv,
                 */
                /* Suffixes used here MUST match lib/activate/dev_manager.c */
                layer = lv_is_cache_origin(lv) ? "real" :
+                       lv_is_writecache_origin(lv) ? "real" :
                        (lv_is_cache(lv) && lv_is_pending_delete(lv)) ? "real" :
                        lv_is_cache_pool_data(lv) ? "cdata" :
                        lv_is_cache_pool_metadata(lv) ? "cmeta" :
index 53619c3d67919a76f079e69c4934c58f04417a78..0a5b485fe2d8d9655332eb8d068a62772a99371b 100644 (file)
@@ -260,10 +260,10 @@ static int _writecache_add_target_line(struct dev_manager *dm,
        if ((pmem = lv_on_pmem(seg->writecache)) < 0)
                return_0;
 
-       if (!(origin_uuid = build_dm_uuid(mem, seg_lv(seg, 0), NULL)))
+       if (!(origin_uuid = build_dm_uuid(mem, seg_lv(seg, 0), "real")))
                return_0;
 
-       if (!(fast_uuid = build_dm_uuid(mem, seg->writecache, NULL)))
+       if (!(fast_uuid = build_dm_uuid(mem, seg->writecache, "cvol")))
                return_0;
 
        if (!dm_tree_node_add_writecache_target(node, len,
index 77aad9daffdebf6353508d7c711f66bc5e8ff195..5d1267a242fc1a67ee6cee149454a522f9371233 100644 (file)
@@ -5230,6 +5230,8 @@ static int _lv_writecache_detach(struct cmd_context *cmd, struct logical_volume
        lv->status &= ~WRITECACHE;
        seg->writecache = NULL;
 
+       lv_fast->status &= ~LV_CACHE_VOL;
+
        if (!remove_layer_from_lv(lv, origin))
                return_0;
 
@@ -5646,6 +5648,8 @@ static int _lvconvert_writecache_attach_single(struct cmd_context *cmd,
        if (!archive(vg))
                goto_bad;
 
+       lv_fast->status |= LV_CACHE_VOL;
+
        /*
         * TODO: use libblkid to get the sector size of lv.  If it doesn't
         * match the block_size we are using for the writecache, then warn that
This page took 0.046047 seconds and 5 git commands to generate.