]> sourceware.org Git - lvm2.git/commitdiff
Rename segment and lv status flag from SNAPSHOT_MERGE to MERGING.
authorMike Snitzer <snitzer@redhat.com>
Wed, 13 Jan 2010 01:56:18 +0000 (01:56 +0000)
committerMike Snitzer <snitzer@redhat.com>
Wed, 13 Jan 2010 01:56:18 +0000 (01:56 +0000)
Eliminate 'merging_snapshot' from 'struct logical_volume' and just use
'snapshot' for origin lv's reference to the merging snapshot; also set
MERGING in the origin lv's status.

lib/format_text/flags.c
lib/metadata/lv_manip.c
lib/metadata/metadata-exported.h
lib/metadata/snapshot_manip.c
lib/snapshot/snapshot.c
tools/toollib.c
tools/vgchange.c

index eeabc90a60a9495903e3993cac90d28f4d4c22b0..a41dc1a7d939207eaaab1a311b1f5af03f979025 100644 (file)
@@ -61,7 +61,7 @@ static const struct flag _lv_flags[] = {
        {MIRRORED, NULL, 0},
        {VIRTUAL, NULL, 0},
        {SNAPSHOT, NULL, 0},
-       {SNAPSHOT_MERGE, NULL, 0},
+       {MERGING, NULL, 0},
        {ACTIVATE_EXCL, NULL, 0},
        {CONVERTING, NULL, 0},
        {PARTIAL_LV, NULL, 0},
index a1794e61c80ef1bb01081b95747baaf3e2aa67b6..8c0ecf9e198f8cbb0c13ec3ee928c1d8255b76ef 100644 (file)
@@ -1877,7 +1877,6 @@ struct logical_volume *alloc_lv(struct dm_pool *mem)
        }
 
        lv->snapshot = NULL;
-       lv->merging_snapshot = NULL;
        dm_list_init(&lv->snapshot_segs);
        dm_list_init(&lv->segments);
        dm_list_init(&lv->tags);
index 721b57c8bc88181170e0b44a60ec975aa2db087d..8342dc03ce9018590a78b75290bd498ae1575933 100644 (file)
@@ -69,7 +69,7 @@
 //#define POSTORDER_OPEN_FLAG  0x04000000U    temporary use inside vg_read_internal. */
 //#define VIRTUAL_ORIGIN       0x08000000U     /* LV - internal use only */
 
-#define SNAPSHOT_MERGE         0x10000000U     /* SEG */
+#define MERGING                        0x10000000U     /* LV SEG */
 
 #define LVM_READ               0x00000100U     /* LV VG */
 #define LVM_WRITE              0x00000200U     /* LV VG */
@@ -330,9 +330,6 @@ struct logical_volume {
        struct dm_list snapshot_segs;
        struct lv_segment *snapshot;
 
-       /* A snapshot that is merging into this origin */
-       struct lv_segment *merging_snapshot;
-
        struct dm_list segments;
        struct dm_list tags;
        struct dm_list segs_using_this_lv;
index 4bdd9db3f6371c179086cee3f3cc7c7563737d7d..19effe380247b74b13e9eb133d80fd7f4695996c 100644 (file)
@@ -25,7 +25,7 @@ int lv_is_origin(const struct logical_volume *lv)
 
 int lv_is_cow(const struct logical_volume *lv)
 {
-       return lv->snapshot ? 1 : 0;
+       return (!lv_is_origin(lv) && lv->snapshot) ? 1 : 0;
 }
 
 int lv_is_visible(const struct logical_volume *lv)
@@ -53,18 +53,21 @@ int lv_is_virtual_origin(const struct logical_volume *lv)
 
 int lv_is_merging_origin(const struct logical_volume *origin)
 {
-       return origin->merging_snapshot ? 1 : 0;
+       return (origin->status & MERGING) ? 1 : 0;
 }
 
 struct lv_segment *find_merging_cow(const struct logical_volume *origin)
 {
-       return origin->merging_snapshot;
+       /* FIXME: eliminate this wrapper and just use find_cow()?
+        * - find_merging_cow() adds to code clarity in caller
+        */
+       return find_cow(origin);
 }
 
 int lv_is_merging_cow(const struct logical_volume *snapshot)
 {
-       /* NOTE: use of find_cow() rather than find_merging_cow() */
-       return (find_cow(snapshot)->status & SNAPSHOT_MERGE) ? 1 : 0;
+       /* checks lv_segment's status to see if cow is merging */
+       return (find_cow(snapshot)->status & MERGING) ? 1 : 0;
 }
 
 /* Given a cow LV, return the snapshot lv_segment that uses it */
@@ -117,15 +120,17 @@ void init_snapshot_merge(struct lv_segment *cow_seg,
         *   merge metadata (cow_seg->lv is now "internal")
         */
        cow_seg->lv->status &= ~VISIBLE_LV;
-       cow_seg->status |= SNAPSHOT_MERGE;
-       origin->merging_snapshot = cow_seg;
+       cow_seg->status |= MERGING;
+       origin->snapshot = cow_seg;
+       origin->status |= MERGING;
 }
 
 void clear_snapshot_merge(struct logical_volume *origin)
 {
        /* clear merge attributes */
-       origin->merging_snapshot->status &= ~SNAPSHOT_MERGE;
-       origin->merging_snapshot = NULL;
+       origin->snapshot->status &= ~MERGING;
+       origin->snapshot = NULL;
+       origin->status &= ~MERGING;
 }
 
 int vg_add_snapshot(struct logical_volume *origin,
index 0e8ac4d6ee45640af94f713441e3d2b6ce25ceb2..8e1f8926265be10c3910051c4c9e2bbd118bbc06 100644 (file)
@@ -84,7 +84,7 @@ static int _snap_text_export(const struct lv_segment *seg, struct formatter *f)
 {
        outf(f, "chunk_size = %u", seg->chunk_size);
        outf(f, "origin = \"%s\"", seg->origin->name);
-       if (!(seg->status & SNAPSHOT_MERGE))
+       if (!(seg->status & MERGING))
                outf(f, "cow_store = \"%s\"", seg->cow->name);
        else
                outf(f, "merging_store = \"%s\"", seg->cow->name);
@@ -144,7 +144,7 @@ static int _snap_target_present(struct cmd_context *cmd,
                _snap_checked = 1;
        }
 
-       if (!_snap_merge_checked && seg && (seg->status & SNAPSHOT_MERGE)) {
+       if (!_snap_merge_checked && seg && (seg->status & MERGING)) {
                _snap_merge_present = target_present(cmd, "snapshot-merge", 0);
                _snap_merge_checked = 1;
                return _snap_present && _snap_merge_present;
index 991fd30b2f482cd14a997d24fcf5bfb31a6be9eb..6c1a4225980922e67e626c9c1965f485a0523774 100644 (file)
@@ -1307,7 +1307,7 @@ void lv_spawn_background_polling(struct cmd_context *cmd,
                pvmove_poll(cmd, pvname, 1);
        }
 
-       if (lv->status & CONVERTING || lv_is_merging_origin(lv)) {
+       if (lv->status & (CONVERTING|MERGING)) {
                log_verbose("Spawning background lvconvert process for %s",
                        lv->name);
                lvconvert_poll(cmd, lv, 1);
index 3056ebaa8884785d07150375c31b01a28d485a2a..b4f5d003e34dd4336ffcab6f8f36776cf6a276b1 100644 (file)
@@ -69,8 +69,7 @@ static int _poll_lvs_in_vg(struct cmd_context *cmd,
                        lv_active = info.exists;
 
                if (lv_active &&
-                   (lv->status & (PVMOVE|CONVERTING) ||
-                    lv_is_merging_origin(lv))) {
+                   (lv->status & (PVMOVE|CONVERTING|MERGING))) {
                        lv_spawn_background_polling(cmd, lv);
                        count++;
                }
@@ -140,8 +139,7 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd,
 
                if (background_polling() &&
                    activate != CHANGE_AN && activate != CHANGE_ALN &&
-                   (lv->status & (PVMOVE|CONVERTING) ||
-                    lv_is_merging_origin(lv)))
+                   (lv->status & (PVMOVE|CONVERTING|MERGING)))
                        lv_spawn_background_polling(cmd, lv);
 
                count++;
This page took 0.05232 seconds and 5 git commands to generate.