]> sourceware.org Git - lvm2.git/commitdiff
cachevol: move cvol rename
authorZdenek Kabelac <zkabelac@redhat.com>
Wed, 16 Oct 2019 10:10:47 +0000 (12:10 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Thu, 17 Oct 2019 11:03:50 +0000 (13:03 +0200)
Move rename of CVOL after archive().

tools/lvconvert.c

index 48ff8e111723995f1d4573f72e5c26d7551d91dd..a21f9654933a95337341221bf9be4bd5bd13d71f 100644 (file)
@@ -3453,6 +3453,7 @@ static int _cache_vol_attach(struct cmd_context *cmd,
                                struct logical_volume *lv,
                                struct logical_volume *lv_fast)
 {
+       char cvol_name[NAME_LEN];
        struct volume_group *vg = lv->vg;
        struct logical_volume *cache_lv;
        uint32_t chunk_size = 0;
@@ -3475,6 +3476,18 @@ static int _cache_vol_attach(struct cmd_context *cmd,
        if (!archive(vg))
                goto_out;
 
+       /*
+        * The lvm tradition is to rename an LV with a special role-specific
+        * suffix when it becomes hidden.  Here the _cvol suffix is added to
+        * the fast LV name.  When the cache is detached, it's renamed back.
+        */
+       if (dm_snprintf(cvol_name, sizeof(cvol_name), "%s_cvol", lv_fast->name) < 0) {
+               log_error("Can't prepare new cachevol name for %s.", display_lvname(lv_fast));
+               goto out;
+       }
+       if (!lv_rename_update(cmd, lv_fast, cvol_name, 0))
+               goto_out;
+
        lv_fast->status |= LV_CACHE_VOL; /* Mark as cachevol LV */
 
        /*
@@ -4216,7 +4229,6 @@ static int _lvconvert_cachevol_attach_single(struct cmd_context *cmd,
        struct volume_group *vg = lv->vg;
        struct logical_volume *cachevol_lv;
        const char *cachevol_name;
-       char cvol_name[NAME_LEN];
 
        if (!(cachevol_name = arg_str_value(cmd, cachevol_ARG, NULL)))
                goto_out;
@@ -4261,18 +4273,6 @@ static int _lvconvert_cachevol_attach_single(struct cmd_context *cmd,
        if (_raid_split_image_conversion(lv))
                goto_out;
 
-       /*
-        * The lvm tradition is to rename an LV with a special role-specific
-        * suffix when it becomes hidden.  Here the _cvol suffix is added to
-        * the fast LV name.  When the cache is detached, it's renamed back.
-        */
-       if (dm_snprintf(cvol_name, sizeof(cvol_name), "%s_cvol", cachevol_lv->name) < 0) {
-               log_error("Can't prepare new metadata name for %s.", display_lvname(cachevol_lv));
-               return 0;
-       }
-       if (!lv_rename_update(cmd, cachevol_lv, cvol_name, 0))
-               return_0;
-
        /* Attach the cache to the main LV. */
 
        if (!_cache_vol_attach(cmd, lv, cachevol_lv))
This page took 0.04254 seconds and 5 git commands to generate.