]> sourceware.org Git - lvm2.git/commitdiff
pool attach fns & more field renaming
authorAlasdair Kergon <agk@redhat.com>
Tue, 6 Sep 2011 22:43:56 +0000 (22:43 +0000)
committerAlasdair Kergon <agk@redhat.com>
Tue, 6 Sep 2011 22:43:56 +0000 (22:43 +0000)
lib/metadata/lv_manip.c
lib/metadata/merge.c
lib/metadata/metadata-exported.h
lib/metadata/metadata.h
lib/metadata/thin_manip.c
lib/thin/thin.c
tools/lvcreate.c

index f1c0db6054cd25cb4fbab3fc80d0e2e20e1cc802..413bcf2a6d7c9bf89ce85b4fc141103bc993808d 100644 (file)
@@ -257,7 +257,7 @@ struct lv_segment *alloc_lv_segment(struct dm_pool *mem,
 
        if (log_lv) {
                if (thin_pool_lv) {
-                       if (!attach_pool_metadata(seg, log_lv))
+                       if (!attach_pool_metadata_lv(seg, log_lv))
                                return_NULL;
                } else if (!attach_mirror_log(seg, log_lv))
                        return_NULL;
index 3c460093834e66a1aecd85ebf9683261db451026..9f7b3c99e66adec1f17aa6013e0f3876414bf789 100644 (file)
@@ -313,7 +313,7 @@ static int _lv_split_segment(struct logical_volume *lv, struct lv_segment *seg,
        if (!(split_seg = alloc_lv_segment(lv->vg->vgmem, seg->segtype,
                                           seg->lv, seg->le, seg->len,
                                           seg->status, seg->stripe_size,
-                                          seg->log_lv, seg->thin_pool_lv,
+                                          seg->log_lv, seg->pool_lv,
                                           seg->area_count, seg->area_len,
                                           seg->chunk_size, seg->region_size,
                                           seg->extents_copied, seg->pvmove_source_seg))) {
index 4948f0daa4a48c1f69b994b4f434493157308e2b..b531195c3b3d9937c47ee15978f33c39404819de 100644 (file)
@@ -85,6 +85,8 @@
 
 #define THIN_VOLUME            UINT64_C(0x0000001000000000)    /* LV */
 #define THIN_POOL              UINT64_C(0x0000002000000000)    /* LV */
+#define THIN_POOL_DATA         UINT64_C(0x0000002000000000)    /* LV */
+#define THIN_POOL_METADATA     UINT64_C(0x0000004000000000)    /* LV */
 
 #define LVM_READ               0x00000100U     /* LV VG 32-bit */
 #define LVM_WRITE              0x00000200U     /* LV VG 32-bit */
 
 #define lv_is_thin_volume(lv)  ((lv)->status & THIN_VOLUME ? 1 : 0)
 #define lv_is_thin_pool(lv)    ((lv)->status & THIN_POOL ? 1 : 0)
+#define lv_is_thin_pool_data(lv)       ((lv)->status & THIN_POOL_DATA ? 1 : 0)
+#define lv_is_thin_pool_metadata(lv)   ((lv)->status & THIN_POOL_METADATA ? 1 : 0)
 #define lv_is_mirrored(lv)     ((lv)->status & MIRRORED ? 1 : 0)
 #define lv_is_rlog(lv)         ((lv)->status & REPLICATOR_LOG ? 1 : 0)
 
@@ -322,12 +326,12 @@ struct lv_segment {
        struct dm_list tags;
 
        struct lv_segment_area *areas;
-       struct lv_segment_area *meta_areas; /* For RAID */
-       struct logical_volume *pool_lv;         /* For thin_pool */
-       struct logical_volume *metadata_lv;     /* For thin_pool */
+       struct lv_segment_area *meta_areas;     /* For RAID */
+       struct logical_volume *pool_data_lv;    /* For thin_pool */
+       struct logical_volume *pool_metadata_lv;/* For thin_pool */
        uint64_t transaction_id;                /* For thin_pool */
        uint32_t zero_new_blocks;               /* For thin_pool */
-       struct logical_volume *thin_pool_lv;    /* For thin */
+       struct logical_volume *pool_lv;         /* For thin */
        uint64_t device_id;                     /* For thin */
 
        struct logical_volume *replicator;/* For replicator-devs - link to replicator LV */
index d48c6cc77c999efde262c9b3ed600f05e1adb3a2..8350a870a323fb6c21952679760a63cb8fb9514d 100644 (file)
@@ -442,9 +442,11 @@ int fixup_imported_mirrors(struct volume_group *vg);
 /*
  * From thin_manip.c
  */
-int attach_pool_metadata(struct lv_segment *seg,
-                        struct logical_volume *thin_pool_metadata);
-int attach_pool_lv(struct lv_segment *seg, struct logical_volume *thin_pool_lv);
+int attach_pool_metadata_lv(struct lv_segment *seg,
+                           struct logical_volume *pool_metadata_lv);
+int attach_pool_data_lv(struct lv_segment *seg,
+                       struct logical_volume *pool_data_lv);
+int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv);
 
 /*
  * Begin skeleton for external LVM library
index 3f52073773ae329c51766adb64dcb03378b6bbc2..8329d13a986e357323e3eae5540e96dede54b811 100644 (file)
 #include "lib.h"
 #include "metadata.h"
 
-int attach_pool_metadata(struct lv_segment *seg, struct logical_volume *thin_pool_metadata)
+int attach_pool_metadata_lv(struct lv_segment *seg, struct logical_volume *pool_metadata_lv)
 {
-       // FIXME Housekeeping needed here (cf attach_mirror_log)
-       seg->metadata_lv = thin_pool_metadata;
+       seg->pool_metadata_lv = pool_metadata_lv;
+       pool_metadata_lv->status |= THIN_POOL_METADATA;
+        lv_set_hidden(pool_metadata_lv);
 
-       return 1;
+        return add_seg_to_segs_using_this_lv(pool_metadata_lv, seg);
 }
 
-int attach_pool_lv(struct lv_segment *seg, struct logical_volume *thin_pool_lv)
+int attach_pool_data_lv(struct lv_segment *seg, struct logical_volume *pool_data_lv)
 {
-       // FIXME Housekeeping needed here (cf attach_mirror_log)
-       seg->thin_pool_lv = thin_pool_lv;
+       seg->pool_data_lv = pool_data_lv;
+       pool_data_lv->status |= THIN_POOL_DATA;
+        lv_set_hidden(pool_data_lv);
 
-       return 1;
+        return add_seg_to_segs_using_this_lv(pool_data_lv, seg);
 }
 
+int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv)
+{
+       seg->pool_lv = pool_lv;
+       pool_lv->status |= THIN_POOL;
+
+        return add_seg_to_segs_using_this_lv(pool_lv, seg);
+}
index 2a3546caddf850c376b6efa4717e25260744f2aa..4759dbbd25b7bd1ea6021ffcda648ba9d38c8c28 100644 (file)
@@ -47,21 +47,26 @@ static int _thin_pool_text_import(struct lv_segment *seg, const struct dm_config
                        struct dm_hash_table *pv_hash __attribute__((unused)))
 {
        const char *lv_name;
+       struct logical_volume *pool_data_lv, *pool_metadata_lv;
 
        if (!dm_config_get_str(sn, "pool", &lv_name))
                return SEG_LOG_ERROR("Pool must be a string in");
 
-// Use attach_pool_lv
-       if (!(seg->pool_lv = find_lv(seg->lv->vg, lv_name)))
+       if (!(pool_data_lv = find_lv(seg->lv->vg, lv_name)))
                return SEG_LOG_ERROR("Unknown pool %s in", lv_name);
 
        if (!dm_config_get_str(sn, "metadata", &lv_name))
                return SEG_LOG_ERROR("Metadata must be a string in");
 
-// Use attach_pool_metadata()
-       if (!(seg->metadata_lv = find_lv(seg->lv->vg, lv_name)))
+       if (!(pool_metadata_lv = find_lv(seg->lv->vg, lv_name)))
                return SEG_LOG_ERROR("Unknown metadata %s in", lv_name);
 
+       if (!attach_pool_metadata_lv(seg, pool_metadata_lv))
+               return_0;
+
+       if (!attach_pool_data_lv(seg, pool_data_lv))
+               return_0;
+
        if (!dm_config_get_uint64(sn, "transaction_id", &seg->transaction_id))
                return SEG_LOG_ERROR("Could not read transaction_id for");
 
@@ -74,8 +79,8 @@ static int _thin_pool_text_import(struct lv_segment *seg, const struct dm_config
 
 static int _thin_pool_text_export(const struct lv_segment *seg, struct formatter *f)
 {
-       outf(f, "pool = \"%s\"", seg->pool_lv->name);
-       outf(f, "metadata = \"%s\"", seg->metadata_lv->name);
+       outf(f, "pool = \"%s\"", seg->pool_data_lv->name);
+       outf(f, "metadata = \"%s\"", seg->pool_metadata_lv->name);
        outf(f, "transaction_id = %" PRIu64, seg->transaction_id);
        if (seg->zero_new_blocks)
                outf(f, "zero_new_blocks = 1");
@@ -92,13 +97,17 @@ static int _thin_text_import(struct lv_segment *seg, const struct dm_config_node
                        struct dm_hash_table *pv_hash __attribute__((unused)))
 {
        const char *lv_name;
+       struct logical_volume *pool_lv;
 
        if (!dm_config_get_str(sn, "thin_pool", &lv_name))
                return SEG_LOG_ERROR("Thin pool must be a string in");
 
-       if (!(seg->thin_pool_lv = find_lv(seg->lv->vg, lv_name)))
+       if (!(pool_lv = find_lv(seg->lv->vg, lv_name)))
                return SEG_LOG_ERROR("Unknown thin pool %s in", lv_name);
 
+       if (!attach_pool_lv(seg, pool_lv))
+               return_0;
+
        if (dm_config_has_node(sn, "origin")) {
                if (!dm_config_get_str(sn, "origin", &lv_name))
                        return SEG_LOG_ERROR("Origin must be a string in");
@@ -115,7 +124,7 @@ static int _thin_text_import(struct lv_segment *seg, const struct dm_config_node
 
 static int _thin_text_export(const struct lv_segment *seg, struct formatter *f)
 {
-       outf(f, "thin_pool = \"%s\"", seg->thin_pool_lv->name);
+       outf(f, "thin_pool = \"%s\"", seg->pool_lv->name);
        outf(f, "device_id = %" PRIu64, seg->device_id);
 
        if (seg->origin)
index e8722a3fa329e7a4453e292507354e16f680adc3..2fd9a6989e9ba9ab5ca2f449687e39fd2ed694e0 100644 (file)
@@ -198,13 +198,12 @@ static int _determine_snapshot_type(struct volume_group *vg,
                return 0;
        }
 
-       /* FIXME Replace with lv_is_thin_volume() once more flags are added */
        if (lv_is_thin_volume(lvl->lv)) {
                lp->thin = 1;
                if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin")))
                        return_0;
 
-               lp->pool = first_seg(lvl->lv)->thin_pool_lv->name;
+               lp->pool = first_seg(lvl->lv)->pool_lv->name;
        }
 
        if (!lp->thin && !arg_count(vg->cmd, extents_ARG) && !arg_count(vg->cmd, size_ARG)) {
This page took 0.064048 seconds and 5 git commands to generate.