]> sourceware.org Git - lvm2.git/commitdiff
Introduce origin_from_cow()
authorAlasdair Kergon <agk@redhat.com>
Thu, 6 Apr 2006 13:39:16 +0000 (13:39 +0000)
committerAlasdair Kergon <agk@redhat.com>
Thu, 6 Apr 2006 13:39:16 +0000 (13:39 +0000)
WHATS_NEW
lib/metadata/metadata.h
lib/metadata/snapshot_manip.c
lib/report/report.c
tools/lvremove.c
tools/lvresize.c
tools/lvscan.c
tools/vgchange.c

index 592262ef6a7624c87e60092b04e23f3eb615483f..9a2638a21baa2d9063491d8dabf6f99e6e274b73 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.03 - 
 ===================================
+  Introduce origin_from_cow().
   pvremove without -f now fails if there's no PV label.
   Support lvconvert -s.
   Suppress locking library load failure message if --ignorelockingfailure.
index 3e0a73c5bc5a8a9381895c65a19c9b55216c4129..b80afbbfdd0b964d2829dbb21330753a8a0e1099 100644 (file)
@@ -538,8 +538,12 @@ int lv_is_cow(const struct logical_volume *lv);
 
 int pv_is_in_vg(struct volume_group *vg, struct physical_volume *pv);
 
+/* Given a cow LV, return return the snapshot lv_segment that uses it */
 struct lv_segment *find_cow(const struct logical_volume *lv);
 
+/* Given a cow LV, return its origin */
+struct logical_volume *origin_from_cow(const struct logical_volume *lv);
+
 int vg_add_snapshot(struct format_instance *fid, const char *name,
                    struct logical_volume *origin, struct logical_volume *cow,
                    union lvid *lvid, uint32_t extent_count,
index a2536f50f1948ece729dc27fb2ea9876b2c199ad..792bc741d517833598357145ed1d942fac632d7c 100644 (file)
@@ -34,6 +34,12 @@ struct lv_segment *find_cow(const struct logical_volume *lv)
        return lv->snapshot;
 }
 
+/* Given a cow LV, return its origin */
+struct logical_volume *origin_from_cow(const struct logical_volume *lv)
+{
+       return lv->snapshot->origin;
+}
+
 int vg_add_snapshot(struct format_instance *fid, const char *name,
                    struct logical_volume *origin,
                    struct logical_volume *cow, union lvid *lvid,
index 855f197007f6e58f9f14426edd7ce92618029903..cf8f71fe6ce61f80d94f7ef4bf3f1775d1087073 100644 (file)
@@ -324,7 +324,6 @@ static int _lvstatus_disp(struct report_handle *rh, struct field *field,
        const struct logical_volume *lv = (const struct logical_volume *) data;
        struct lvinfo info;
        char *repstr;
-       struct lv_segment *snap_seg;
        float snap_percent;
 
        if (!(repstr = dm_pool_zalloc(rh->mem, 7))) {
@@ -344,7 +343,7 @@ static int _lvstatus_disp(struct report_handle *rh, struct field *field,
                repstr[0] = 'v';
        else if (lv_is_origin(lv))
                repstr[0] = 'o';
-       else if (find_cow(lv))
+       else if (lv_is_cow(lv))
                repstr[0] = 's';
        else
                repstr[0] = '-';
@@ -377,8 +376,8 @@ static int _lvstatus_disp(struct report_handle *rh, struct field *field,
                        repstr[4] = 'd';        /* Inactive without table */
 
                /* Snapshot dropped? */
-               if (info.live_table && (snap_seg = find_cow(lv)) &&
-                   (!lv_snapshot_percent(snap_seg->cow, &snap_percent) ||
+               if (info.live_table && lv_is_cow(lv) &&
+                   (!lv_snapshot_percent(find_cow(lv)->cow, &snap_percent) ||
                     snap_percent < 0 || snap_percent >= 100)) {
                        repstr[0] = toupper(repstr[0]);
                        if (info.suspended)
@@ -491,10 +490,9 @@ static int _origin_disp(struct report_handle *rh, struct field *field,
                        const void *data)
 {
        const struct logical_volume *lv = (const struct logical_volume *) data;
-       struct lv_segment *snap_seg;
 
-       if ((snap_seg = find_cow(lv)))
-               return _string_disp(rh, field, &snap_seg->origin->name);
+       if (lv_is_cow(lv))
+               return _string_disp(rh, field, &origin_from_cow(lv)->name);
 
        field->report_string = "";
        field->sort_value = (const void *) field->report_string;
@@ -667,11 +665,10 @@ static int _chunksize_disp(struct report_handle *rh, struct field *field,
                           const void *data)
 {
        const struct lv_segment *seg = (const struct lv_segment *) data;
-       struct lv_segment *snap_seg;
        uint64_t size;
 
-       if ((snap_seg = find_cow(seg->lv)))
-               size = (uint64_t) snap_seg->chunk_size;
+       if (lv_is_cow(seg->lv))
+               size = (uint64_t) find_cow(seg->lv)->chunk_size;
        else
                size = 0;
 
index e29af6f387350044b83448273ee14cc3299292e5..5ecf850e403de2aefb5befd88417c75836a5048c 100644 (file)
@@ -83,7 +83,7 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
        }
 
        if (lv_is_cow(lv)) {
-               origin = find_cow(lv)->origin;
+               origin = origin_from_cow(lv);
                log_verbose("Removing snapshot %s", lv->name);
                if (!vg_remove_snapshot(lv)) {
                        stack;
index ce5f821a93df59ef1a84c58525325589ec39c0ec..fc9724695ab7ae784caa079ee036353a59fecd80 100644 (file)
@@ -116,7 +116,6 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
 {
        struct volume_group *vg;
        struct logical_volume *lv;
-       struct lv_segment *snap_seg;
        struct lvinfo info;
        uint32_t stripesize_extents = 0;
        uint32_t seg_stripes = 0, seg_stripesize = 0, seg_size = 0;
@@ -521,8 +520,8 @@ static int _lvresize(struct cmd_context *cmd, struct lvresize_params *lp)
        backup(vg);
 
        /* If snapshot, must suspend all associated devices */
-       if ((snap_seg = find_cow(lv)))
-               lock_lv = snap_seg->origin;
+       if (lv_is_cow(lv))
+               lock_lv = origin_from_cow(lv);
        else
                lock_lv = lv;
 
index 41a74674e15b9ded382d19f6395ef5c24126dbf8..bad372ef01ec0f55ef7513c7463d3838bb89c0ae 100644 (file)
@@ -43,9 +43,9 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
                                        snap_active = 0;
                }
                snap_seg = NULL;
-       } else if ((snap_seg = find_cow(lv))) {
+       } else if (lv_is_cow(lv)) {
                if (inkernel &&
-                   (snap_active = lv_snapshot_percent(snap_seg->cow,
+                   (snap_active = lv_snapshot_percent(find_cow(lv)->cow,
                                                       &snap_percent)))
                        if (snap_percent < 0 || snap_percent >= 100)
                                snap_active = 0;
index 461caa940d7571d02eee4c2aa2f2ba83e302372d..6584560e459bb9d3702f50d5655969f4e2f3d586 100644 (file)
@@ -198,7 +198,7 @@ static int _vgchange_clustered(struct cmd_context *cmd,
 
        if (clustered) {
                list_iterate_items(lvl, &vg->lvs) {
-                       if (lvl->lv->origin_count || lvl->lv->snapshot) {
+                       if (lv_is_origin(lvl->lv) || lv_is_cow(lvl->lv)) {
                                log_error("Volume group %s contains snapshots "
                                          "that are not yet supported.",
                                          vg->name);
This page took 0.046633 seconds and 5 git commands to generate.