]> sourceware.org Git - lvm2.git/commitdiff
cleanup: move towards using direct LV pointers
authorZdenek Kabelac <zkabelac@redhat.com>
Sat, 21 Nov 2015 22:31:44 +0000 (23:31 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 23 Nov 2015 22:42:59 +0000 (23:42 +0100)
We do not won't to 'expose'  internals of VG struct.
ATM we use lists to keep all LVs - we may want to switch
to better struct for quicker 'search'.

Since we do not need 'lists' but always actual LV,
switch find_lv_in_vg_by_lvid() to return LV,
and replaces some use case of  find_lv_in_vg()
with 'better' working find_lv() which already
returns LV.

lib/activate/activate.c
lib/metadata/metadata.c
lib/metadata/metadata.h

index 7d2adf1ee13c08fe31c37cc3d1c2f41b8b7c27ca..6a6a952ceeb1e3ce43d053c568ca5202d809c291 100644 (file)
@@ -1763,25 +1763,25 @@ struct detached_lv_data {
 static int _preload_detached_lv(struct logical_volume *lv, void *data)
 {
        struct detached_lv_data *detached = data;
-       struct lv_list *lvl_pre;
+       struct logical_volume *lv_pre;
 
        /* Check and preload removed raid image leg or metadata */
        if (lv_is_raid_image(lv)) {
-               if ((lvl_pre = find_lv_in_vg_by_lvid(detached->lv_pre->vg, &lv->lvid)) &&
-                   !lv_is_raid_image(lvl_pre->lv) && lv_is_active(lv) &&
-                   !_lv_preload(lvl_pre->lv, detached->laopts, detached->flush_required))
+               if ((lv_pre = find_lv_in_vg_by_lvid(detached->lv_pre->vg, &lv->lvid)) &&
+                   !lv_is_raid_image(lv_pre) && lv_is_active(lv) &&
+                   !_lv_preload(lv_pre, detached->laopts, detached->flush_required))
                        return_0;
        } else if (lv_is_raid_metadata(lv)) {
-               if ((lvl_pre = find_lv_in_vg_by_lvid(detached->lv_pre->vg, &lv->lvid)) &&
-                   !lv_is_raid_metadata(lvl_pre->lv) && lv_is_active(lv) &&
-                   !_lv_preload(lvl_pre->lv, detached->laopts, detached->flush_required))
+               if ((lv_pre = find_lv_in_vg_by_lvid(detached->lv_pre->vg, &lv->lvid)) &&
+                   !lv_is_raid_metadata(lv_pre) && lv_is_active(lv) &&
+                   !_lv_preload(lv_pre, detached->laopts, detached->flush_required))
                        return_0;
        }
 
-       if ((lvl_pre = find_lv_in_vg(detached->lv_pre->vg, lv->name))) {
-               if (lv_is_visible(lvl_pre->lv) && lv_is_active(lv) &&
-                   (!lv_is_cow(lv) || !lv_is_cow(lvl_pre->lv)) &&
-                   !_lv_preload(lvl_pre->lv, detached->laopts, detached->flush_required))
+       if ((lv_pre = find_lv(detached->lv_pre->vg, lv->name))) {
+               if (lv_is_visible(lv_pre) && lv_is_active(lv) &&
+                   (!lv_is_cow(lv) || !lv_is_cow(lv_pre)) &&
+                   !_lv_preload(lv_pre, detached->laopts, detached->flush_required))
                        return_0;
        }
 
@@ -1795,7 +1795,7 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
        const struct logical_volume *pvmove_lv = NULL;
        const struct logical_volume *ondisk_lv_to_free = NULL;
        const struct logical_volume *incore_lv_to_free = NULL;
-       struct lv_list *lvl_pre;
+       struct logical_volume *lv_pre;
        struct seg_list *sl;
         struct lv_segment *snap_seg;
        struct lvinfo info;
@@ -1854,19 +1854,19 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
            (pvmove_lv = find_pvmove_lv_in_lv(ondisk_lv))) {
                /* Preload all the LVs above the PVMOVE LV */
                dm_list_iterate_items(sl, &pvmove_lv->segs_using_this_lv) {
-                       if (!(lvl_pre = find_lv_in_vg(incore_lv->vg, sl->seg->lv->name))) {
+                       if (!(lv_pre = find_lv(incore_lv->vg, sl->seg->lv->name))) {
                                log_error(INTERNAL_ERROR "LV %s missing from preload metadata", sl->seg->lv->name);
                                goto out;
                        }
-                       if (!_lv_preload(lvl_pre->lv, laopts, &flush_required))
+                       if (!_lv_preload(lv_pre, laopts, &flush_required))
                                goto_out;
                }
                /* Now preload the PVMOVE LV itself */
-               if (!(lvl_pre = find_lv_in_vg(incore_lv->vg, pvmove_lv->name))) {
+               if (!(lv_pre = find_lv(incore_lv->vg, pvmove_lv->name))) {
                        log_error(INTERNAL_ERROR "LV %s missing from preload metadata", pvmove_lv->name);
                        goto out;
                }
-               if (!_lv_preload(lvl_pre->lv, laopts, &flush_required))
+               if (!_lv_preload(lv_pre, laopts, &flush_required))
                        goto_out;
        } else {
                if (!_lv_preload(incore_lv, laopts, &flush_required))
@@ -1888,13 +1888,13 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
                 */
                if (!laopts->origin_only && lv_is_origin(ondisk_lv)) {
                        dm_list_iterate_items_gen(snap_seg, &ondisk_lv->snapshot_segs, origin_list) {
-                               if (!(lvl_pre = find_lv_in_vg_by_lvid(incore_lv->vg, &snap_seg->cow->lvid))) {
+                               if (!(lv_pre = find_lv_in_vg_by_lvid(incore_lv->vg, &snap_seg->cow->lvid))) {
                                        log_error(INTERNAL_ERROR "LV %s (%s) missing from preload metadata",
                                                  snap_seg->cow->name, snap_seg->cow->lvid.id[1].uuid);
                                        goto out;
                                }
-                               if (!lv_is_cow(lvl_pre->lv) &&
-                                   !_lv_preload(lvl_pre->lv, laopts, &flush_required))
+                               if (!lv_is_cow(lv_pre) &&
+                                   !_lv_preload(lv_pre, laopts, &flush_required))
                                        goto_out;
                        }
                }
index 77bbeab8e89144ac64910ff4670de7baaf2b014f..b1ddb344016dcbd19a0847eeedf0fe4c487cbfe9 100644 (file)
@@ -1975,14 +1975,14 @@ struct lv_list *find_lv_in_lv_list(const struct dm_list *ll,
        return NULL;
 }
 
-struct lv_list *find_lv_in_vg_by_lvid(struct volume_group *vg,
-                                     const union lvid *lvid)
+struct logical_volume *find_lv_in_vg_by_lvid(struct volume_group *vg,
+                                            const union lvid *lvid)
 {
        struct lv_list *lvl;
 
        dm_list_iterate_items(lvl, &vg->lvs)
                if (!strncmp(lvl->lv->lvid.s, lvid->s, sizeof(*lvid)))
-                       return lvl;
+                       return lvl->lv;
 
        return NULL;
 }
@@ -4134,7 +4134,7 @@ static struct volume_group *_vg_read_by_vgid(struct cmd_context *cmd,
 struct logical_volume *lv_from_lvid(struct cmd_context *cmd, const char *lvid_s,
                                    unsigned precommitted)
 {
-       struct lv_list *lvl;
+       struct logical_volume *lv;
        struct volume_group *vg;
        const union lvid *lvid;
 
@@ -4151,12 +4151,12 @@ struct logical_volume *lv_from_lvid(struct cmd_context *cmd, const char *lvid_s,
                log_error("Volume group \"%s\" is exported", vg->name);
                goto out;
        }
-       if (!(lvl = find_lv_in_vg_by_lvid(vg, lvid))) {
+       if (!(lv = find_lv_in_vg_by_lvid(vg, lvid))) {
                log_very_verbose("Can't find logical volume id %s", lvid_s);
                goto out;
        }
 
-       return lvl->lv;
+       return lv;
 out:
        release_vg(vg);
        return NULL;
@@ -5534,7 +5534,7 @@ char *tags_format_and_copy(struct dm_pool *mem, const struct dm_list *tagsl)
 const struct logical_volume *lv_ondisk(const struct logical_volume *lv)
 {
        struct volume_group *vg;
-       struct lv_list *lvl;
+       struct logical_volume *found_lv;
 
        if (!lv)
                return NULL;
@@ -5544,13 +5544,13 @@ const struct logical_volume *lv_ondisk(const struct logical_volume *lv)
 
        vg = lv->vg->vg_ondisk;
 
-       if (!(lvl = find_lv_in_vg_by_lvid(vg, &lv->lvid))) {
+       if (!(found_lv = find_lv_in_vg_by_lvid(vg, &lv->lvid))) {
                log_error(INTERNAL_ERROR "LV %s (UUID %s) not found in ondisk metadata.",
                          display_lvname(lv), lv->lvid.s);
                return NULL;
        }
 
-       return lvl->lv;
+       return found_lv;
 }
 
 /*
index 1a5306bde45309ebd6d1578e5293e02d53c317b9..e19bd16fc5a364a8678069a5cca70e517760a1fd 100644 (file)
@@ -364,8 +364,8 @@ int get_pv_from_vg_by_id(const struct format_type *fmt, const char *vg_name,
                         const char *vgid, const char *pvid,
                         struct physical_volume *pv);
 
-struct lv_list *find_lv_in_vg_by_lvid(struct volume_group *vg,
-                                     const union lvid *lvid);
+struct logical_volume *find_lv_in_vg_by_lvid(struct volume_group *vg,
+                                            const union lvid *lvid);
 
 struct lv_list *find_lv_in_lv_list(const struct dm_list *ll,
                                   const struct logical_volume *lv);
This page took 0.049786 seconds and 5 git commands to generate.