]> sourceware.org Git - lvm2.git/commitdiff
Fix free_vg order
authorZdenek Kabelac <zkabelac@redhat.com>
Wed, 30 Mar 2011 14:35:00 +0000 (14:35 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Wed, 30 Mar 2011 14:35:00 +0000 (14:35 +0000)
As now the FID management is more complex, the code inside free_vg needs
to access some parts of memory pools which were not needed before.

For this - makes the order of unlock_and_free_vg() unconditional.
Keek using unlock_and_free_vg() API function.

For properly working VG locking mechanism only the alphabeting locking
orderer needs to be preserved.

TODO: there could be few more code parts simplified when we 'officially'
support of referencies between different memory pools.

tools/vgmerge.c
tools/vgsplit.c

index adb00a0f6c3c2da99f82f2bfbea6acb5cc4b5e9d..6b403bf422d9b6c76b0ac0c39d25225ca7f2370f 100644 (file)
@@ -151,13 +151,13 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
                  vg_from->name, vg_to->name);
        r = ECMD_PROCESSED;
 bad:
-       if (lock_vg_from_first) {
-               unlock_and_free_vg(cmd, vg_to, vg_name_to);
-               unlock_and_free_vg(cmd, vg_from, vg_name_from);
-       } else {
-               unlock_and_free_vg(cmd, vg_from, vg_name_from);
-               unlock_and_free_vg(cmd, vg_to, vg_name_to);
-       }
+       /*
+        * Note: as vg_to is referencing moved elements from vg_from
+        * the order of free_vg calls is mandatory.
+        */
+       unlock_and_free_vg(cmd, vg_to, vg_name_to);
+       unlock_and_free_vg(cmd, vg_from, vg_name_from);
+
        return r;
 }
 
index b97db97b1e7406ffecca60e792fb43780e9e8cc6..b0494a0d505856245128066965c742a25e2fa5d7 100644 (file)
@@ -487,12 +487,12 @@ int vgsplit(struct cmd_context *cmd, int argc, char **argv)
        r = ECMD_PROCESSED;
 
 bad:
-       if (lock_vg_from_first) {
-               unlock_and_free_vg(cmd, vg_to, vg_name_to);
-               unlock_and_free_vg(cmd, vg_from, vg_name_from);
-       } else {
-               unlock_and_free_vg(cmd, vg_from, vg_name_from);
-               unlock_and_free_vg(cmd, vg_to, vg_name_to);
-       }
+       /*
+        * Note: as vg_to is referencing moved elements from vg_from
+        * the order of free_vg calls is mandatory.
+        */
+       unlock_and_free_vg(cmd, vg_to, vg_name_to);
+       unlock_and_free_vg(cmd, vg_from, vg_name_from);
+
        return r;
 }
This page took 0.040676 seconds and 5 git commands to generate.