summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2011-09-06 19:25:42 +0000
committerAlasdair Kergon <agk@redhat.com>2011-09-06 19:25:42 +0000
commitb88362ff95fa3e8f5be2ae359f3a859efbf3d694 (patch)
treedff6058b200cee0049f3a2b7a7c80cdbf2a4158c
parent2ef5b7cca66314cdc0455a02a79713cc11e31ca2 (diff)
downloadlvm2-b88362ff95fa3e8f5be2ae359f3a859efbf3d694.tar.gz
lvm2-b88362ff95fa3e8f5be2ae359f3a859efbf3d694.tar.xz
lvm2-b88362ff95fa3e8f5be2ae359f3a859efbf3d694.zip
add thin_manip.c like the other manip files
move basic lv_is_* to macros data_lv -> pool_lv - we decided to call it 'pool' everywhere now
-rw-r--r--lib/Makefile.in3
-rw-r--r--lib/metadata/lv_manip.c20
-rw-r--r--lib/metadata/metadata-exported.h9
-rw-r--r--lib/metadata/metadata.h7
-rw-r--r--lib/metadata/mirror.c8
-rw-r--r--lib/metadata/replicator_manip.c8
-rw-r--r--lib/metadata/thin_manip.c33
-rw-r--r--lib/thin/thin.c6
-rw-r--r--tools/lvcreate.c8
9 files changed, 57 insertions, 45 deletions
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 6758a78c..a46e5960 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -1,6 +1,6 @@
#
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
-# Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
@@ -93,6 +93,7 @@ SOURCES =\
metadata/replicator_manip.c \
metadata/segtype.c \
metadata/snapshot_manip.c \
+ metadata/thin_manip.c \
metadata/vg.c \
misc/crc.c \
misc/lvm-exec.c \
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 36c1a2c9..f1c0db60 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -198,22 +198,6 @@ uint32_t find_free_lvnum(struct logical_volume *lv)
return i;
}
-static int _attach_pool_metadata(struct lv_segment *seg, struct logical_volume *thin_pool_metadata)
-{
- // FIXME Housekeeping needed here (cf attach_mirror_log)
- seg->metadata_lv = thin_pool_metadata;
-
- return 1;
-}
-
-static int _attach_pool_lv(struct lv_segment *seg, struct logical_volume *thin_pool_lv)
-{
- // FIXME Housekeeping needed here (cf attach_mirror_log)
- seg->thin_pool_lv = thin_pool_lv;
-
- return 1;
-}
-
/*
* All lv_segments get created here.
*/
@@ -268,12 +252,12 @@ struct lv_segment *alloc_lv_segment(struct dm_pool *mem,
seg->pvmove_source_seg = pvmove_source_seg;
dm_list_init(&seg->tags);
- if (thin_pool_lv && !_attach_pool_lv(seg, thin_pool_lv))
+ if (thin_pool_lv && !attach_pool_lv(seg, thin_pool_lv))
return_NULL;
if (log_lv) {
if (thin_pool_lv) {
- if (!_attach_pool_metadata(seg, log_lv))
+ if (!attach_pool_metadata(seg, log_lv))
return_NULL;
} else if (!attach_mirror_log(seg, log_lv))
return_NULL;
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index e0c1fd8c..4948f0da 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -132,6 +132,11 @@
#define VGMETADATACOPIES_ALL UINT32_MAX
#define VGMETADATACOPIES_UNMANAGED 0
+#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_mirrored(lv) ((lv)->status & MIRRORED ? 1 : 0)
+#define lv_is_rlog(lv) ((lv)->status & REPLICATOR_LOG ? 1 : 0)
+
/* Ordered list - see lv_manip.c */
typedef enum {
AREA_UNASSIGNED,
@@ -318,7 +323,7 @@ struct lv_segment {
struct lv_segment_area *areas;
struct lv_segment_area *meta_areas; /* For RAID */
- struct logical_volume *data_lv; /* For thin_pool */
+ struct logical_volume *pool_lv; /* For thin_pool */
struct logical_volume *metadata_lv; /* For thin_pool */
uint64_t transaction_id; /* For thin_pool */
uint32_t zero_new_blocks; /* For thin_pool */
@@ -696,7 +701,6 @@ int lv_remove_mirrors(struct cmd_context *cmd, struct logical_volume *lv,
int is_temporary_mirror_layer(const struct logical_volume *lv);
struct logical_volume * find_temporary_mirror(const struct logical_volume *lv);
-int lv_is_mirrored(const struct logical_volume *lv);
uint32_t lv_mirror_count(const struct logical_volume *lv);
uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents,
uint32_t region_size);
@@ -742,7 +746,6 @@ int lv_is_active_replicator_dev(const struct logical_volume *lv);
int lv_is_replicator(const struct logical_volume *lv);
int lv_is_replicator_dev(const struct logical_volume *lv);
int lv_is_rimage(const struct logical_volume *lv);
-int lv_is_rlog(const struct logical_volume *lv);
int lv_is_slog(const struct logical_volume *lv);
struct logical_volume *first_replicator_dev(const struct logical_volume *lv);
/* -- metadata/replicator_manip.c */
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index e48c8980..d48c6cc7 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -440,6 +440,13 @@ struct volume_group *import_vg_from_config_tree(const struct dm_config_tree *cft
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);
+
+/*
* Begin skeleton for external LVM library
*/
struct id pv_id(const struct physical_volume *pv);
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index d7be24ee..db187e20 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -72,14 +72,6 @@ struct logical_volume *find_temporary_mirror(const struct logical_volume *lv)
return NULL;
}
-int lv_is_mirrored(const struct logical_volume *lv)
-{
- if (lv->status & MIRRORED)
- return 1;
-
- return 0;
-}
-
/*
* cluster_mirror_is_available
*
diff --git a/lib/metadata/replicator_manip.c b/lib/metadata/replicator_manip.c
index 9f9dc97d..2853e50d 100644
--- a/lib/metadata/replicator_manip.c
+++ b/lib/metadata/replicator_manip.c
@@ -446,14 +446,6 @@ int lv_is_rimage(const struct logical_volume *lv)
}
/**
- * Is this LV rlog
- */
-int lv_is_rlog(const struct logical_volume *lv)
-{
- return (lv->status & REPLICATOR_LOG);
-}
-
-/**
* Is this LV sync log
*/
int lv_is_slog(const struct logical_volume *lv)
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
new file mode 100644
index 00000000..3f520737
--- /dev/null
+++ b/lib/metadata/thin_manip.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2011 Red Hat, Inc. All rights reserved.
+ *
+ * This file is part of LVM2.
+ *
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License v.2.1.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "lib.h"
+#include "metadata.h"
+
+int attach_pool_metadata(struct lv_segment *seg, struct logical_volume *thin_pool_metadata)
+{
+ // FIXME Housekeeping needed here (cf attach_mirror_log)
+ seg->metadata_lv = thin_pool_metadata;
+
+ return 1;
+}
+
+int attach_pool_lv(struct lv_segment *seg, struct logical_volume *thin_pool_lv)
+{
+ // FIXME Housekeeping needed here (cf attach_mirror_log)
+ seg->thin_pool_lv = thin_pool_lv;
+
+ return 1;
+}
+
diff --git a/lib/thin/thin.c b/lib/thin/thin.c
index eeaa38fb..dcb60289 100644
--- a/lib/thin/thin.c
+++ b/lib/thin/thin.c
@@ -51,12 +51,14 @@ static int _thin_pool_text_import(struct lv_segment *seg, const struct dm_config
if (!dm_config_get_str(sn, "data", &lv_name))
return SEG_LOG_ERROR("Thin pool data must be a string in");
- if (!(seg->data_lv = find_lv(seg->lv->vg, lv_name)))
+// Use attach_pool_lv
+ if (!(seg->pool_lv = find_lv(seg->lv->vg, lv_name)))
return SEG_LOG_ERROR("Unknown pool data %s in", lv_name);
if (!dm_config_get_str(sn, "metadata", &lv_name))
return SEG_LOG_ERROR("Thin pool metadata must be a string in");
+// Use attach_pool_metadata()
if (!(seg->metadata_lv = find_lv(seg->lv->vg, lv_name)))
return SEG_LOG_ERROR("Unknown pool metadata %s in", lv_name);
@@ -72,7 +74,7 @@ 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, "data = \"%s\"", seg->data_lv->name);
+ outf(f, "data = \"%s\"", seg->pool_lv->name);
outf(f, "metadata = \"%s\"", seg->metadata_lv->name);
outf(f, "transaction_id = %" PRIu64, seg->transaction_id);
if (seg->zero_new_blocks)
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 6d6a7b98..e8722a3f 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -192,7 +192,6 @@ static int _determine_snapshot_type(struct volume_group *vg,
struct lvcreate_params *lp)
{
struct lv_list *lvl;
- struct lv_segment *seg;
if (!(lvl = find_lv_in_vg(vg, lp->origin))) {
log_error("Snapshot origin LV %s not found in Volume group %s.", lp->origin, vg->name);
@@ -200,12 +199,12 @@ static int _determine_snapshot_type(struct volume_group *vg,
}
/* FIXME Replace with lv_is_thin_volume() once more flags are added */
- if (seg_is_thin_volume(seg = first_seg(lvl->lv))) {
+ if (lv_is_thin_volume(lvl->lv)) {
lp->thin = 1;
if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin")))
return_0;
- lp->pool = seg->thin_pool_lv->name;
+ lp->pool = first_seg(lvl->lv)->thin_pool_lv->name;
}
if (!lp->thin && !arg_count(vg->cmd, extents_ARG) && !arg_count(vg->cmd, size_ARG)) {
@@ -804,8 +803,7 @@ static int _check_thin_parameters(struct volume_group *vg, struct lvcreate_param
log_error("Pool %s not found in Volume group %s.", lp->pool, vg->name);
return 0;
}
- /* FIXME Use lv_is_thin_pool() */
- if (!seg_is_thin_pool(first_seg(lvl->lv))) {
+ if (!lv_is_thin_pool(lvl->lv)) {
log_error("Logical volume %s is not a thin pool.", lp->pool);
return 0;
}