public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 lib/format_text/flags.c lib/metadata/lv_m ...
@ 2011-09-08 16:41 agk
0 siblings, 0 replies; 2+ messages in thread
From: agk @ 2011-09-08 16:41 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2011-09-08 16:41:20
Modified files:
lib/format_text: flags.c
lib/metadata : lv_manip.c merge.c metadata-exported.h
metadata.h thin_manip.c
lib/thin : thin.c
tools : lvcreate.c
Log message:
lvcreate/remove thin_pool and thin volumes (--driverloaded n only)
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/flags.c.diff?cvsroot=lvm2&r1=1.47&r2=1.48
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.282&r2=1.283
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/merge.c.diff?cvsroot=lvm2&r1=1.47&r2=1.48
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.208&r2=1.209
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.254&r2=1.255
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/thin_manip.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/thin/thin.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.239&r2=1.240
--- LVM2/lib/format_text/flags.c 2011/08/30 14:55:17 1.47
+++ LVM2/lib/format_text/flags.c 2011/09/08 16:41:18 1.48
@@ -71,6 +71,10 @@
{VIRTUAL_ORIGIN, NULL, 0},
{REPLICATOR, NULL, 0},
{REPLICATOR_LOG, NULL, 0},
+ {THIN_VOLUME, NULL, 0},
+ {THIN_POOL, NULL, 0},
+ {THIN_POOL_DATA, NULL, 0},
+ {THIN_POOL_METADATA, NULL, 0},
{0, NULL, 0}
};
--- LVM2/lib/metadata/lv_manip.c 2011/09/06 22:43:56 1.282
+++ LVM2/lib/metadata/lv_manip.c 2011/09/08 16:41:18 1.283
@@ -255,13 +255,8 @@
if (thin_pool_lv && !attach_pool_lv(seg, thin_pool_lv))
return_NULL;
- if (log_lv) {
- if (thin_pool_lv) {
- if (!attach_pool_metadata_lv(seg, log_lv))
- return_NULL;
- } else if (!attach_mirror_log(seg, log_lv))
- return_NULL;
- }
+ if (log_lv && !attach_mirror_log(seg, log_lv))
+ return_NULL;
return seg;
}
@@ -310,6 +305,11 @@
return;
}
+ if (seg_lv(seg, s)->status & THIN_POOL_DATA) {
+ lv_reduce(seg_lv(seg, s), area_reduction);
+ return;
+ }
+
if (seg_lv(seg, s)->status & RAID_IMAGE) {
/*
* FIXME: Use lv_reduce not lv_remove
@@ -510,6 +510,12 @@
/* FIXME Check this is safe */
if (seg->log_lv && !lv_remove(seg->log_lv))
return_0;
+ if (seg->pool_metadata_lv && !lv_remove(seg->pool_metadata_lv))
+ return_0;
+
+ if (seg->pool_lv && !detach_pool_lv(seg))
+ return_0;
+
dm_list_del(&seg->list);
reduction = seg->len;
} else
@@ -770,7 +776,14 @@
* RAID device's metadata_area
*/
ah->new_extents += (ah->log_len * ah->area_multiple);
+ } else {
+ ah->log_area_count = 0;
+ ah->log_len = 0;
}
+ } else if (segtype_is_thin_pool(segtype)) {
+ ah->log_area_count = metadata_area_count;
+// FIXME Calculate thin metadata area size
+ ah->log_len = 1;
} else {
ah->log_area_count = metadata_area_count;
ah->log_len = !metadata_area_count ? 0 :
@@ -2314,7 +2327,7 @@
{
struct logical_volume *sub_lv;
uint32_t i;
- uint64_t status = 0;
+ uint64_t sub_lv_status = 0;
const char *layer_name;
size_t len = strlen(lv->name) + 32;
char img_name[len];
@@ -2328,15 +2341,14 @@
if (segtype_is_raid(segtype)) {
lv->status |= RAID;
- status = RAID_IMAGE;
+ sub_lv_status = RAID_IMAGE;
layer_name = "rimage";
} else if (segtype_is_mirrored(segtype)) {
lv->status |= MIRRORED;
- status = MIRROR_IMAGE;
+ sub_lv_status = MIRROR_IMAGE;
layer_name = "mimage";
} else if (segtype_is_thin_pool(segtype)) {
- // lv->status |= THIN_POOL;
- // status = THIN_IMAGE;
+ lv->status |= THIN_POOL;
layer_name = "tpool";
} else
return_0;
@@ -2356,37 +2368,52 @@
*/
for (i = 0; i < devices; i++) {
/* Data LVs */
- if (dm_snprintf(img_name, len, "%s_%s_%u",
- lv->name, layer_name, i) < 0)
- return_0;
-
- sub_lv = lv_create_empty(img_name, NULL,
- LVM_READ | LVM_WRITE | status,
- lv->alloc, lv->vg);
+ if (devices > 1) {
+ if (dm_snprintf(img_name, len, "%s_%s_%u",
+ lv->name, layer_name, i) < 0)
+ return_0;
+ } else {
+ if (dm_snprintf(img_name, len, "%s_%s",
+ lv->name, layer_name) < 0)
+ return_0;
+ }
- if (!sub_lv)
+ /* FIXME Should use ALLOC_INHERIT here and inherit from parent LV */
+ if (!(sub_lv = lv_create_empty(img_name, NULL,
+ LVM_READ | LVM_WRITE,
+ lv->alloc, lv->vg)))
return_0;
- if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, status))
+
+ if (segtype_is_thin_pool(segtype)) {
+ if (!attach_pool_data_lv(mapseg, sub_lv))
+ return_0;
+ } else if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, sub_lv_status))
return_0;
- if (!segtype_is_raid(segtype))
+
+ /* Metadata LVs for raid or thin pool */
+ if (segtype_is_raid(segtype)) {
+ if (dm_snprintf(img_name, len, "%s_rmeta_%u", lv->name, i) < 0)
+ return_0;
+ } else if (segtype_is_thin_pool(segtype)) {
+ if (dm_snprintf(img_name, len, "%s_tmeta", lv->name) < 0)
+ return_0;
+ } else
continue;
- /* RAID meta LVs */
- if (dm_snprintf(img_name, len, "%s_rmeta_%u", lv->name, i) < 0)
+ /* FIXME Should use ALLOC_INHERIT here and inherit from parent LV */
+ if (!(sub_lv = lv_create_empty(img_name, NULL,
+ LVM_READ | LVM_WRITE,
+ lv->alloc, lv->vg)))
return_0;
- sub_lv = lv_create_empty(img_name, NULL,
- LVM_READ | LVM_WRITE | RAID_META,
- lv->alloc, lv->vg);
- if (!sub_lv)
- return_0;
- if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, RAID_META))
- return_0;
+ if (segtype_is_thin_pool(segtype)) {
+ if (!attach_pool_metadata_lv(mapseg, sub_lv))
+ return_0;
+ } else if (!set_lv_segment_area_lv(mapseg, i, sub_lv, 0, RAID_META))
+ return_0;
}
dm_list_add(&lv->segments, &mapseg->list);
-// FIXME If thin pool, create one "log_lv" as tmeta here lv->metadata_lv
-
return 1;
}
@@ -2509,9 +2536,22 @@
struct dm_list *allocatable_pvs, alloc_policy_t alloc)
{
int r = 1;
- int raid_logs = 0;
+ int log_count = 0;
struct alloc_handle *ah;
- uint32_t dev_count = mirrors * stripes + segtype->parity_devs;
+ uint32_t sub_lv_count;
+
+ /*
+ * For RAID, all the devices are AREA_LV.
+ * However, for 'mirror on stripe' using non-RAID targets,
+ * the mirror legs are AREA_LV while the stripes underneath
+ * are AREA_PV.
+ */
+ if (segtype_is_raid(segtype))
+ sub_lv_count = mirrors * stripes + segtype->parity_devs;
+ else if (segtype_is_thin_pool(segtype))
+ sub_lv_count = 1;
+ else
+ sub_lv_count = mirrors;
log_very_verbose("Extending segment type, %s", segtype->name);
@@ -2519,12 +2559,14 @@
return lv_add_virtual_segment(lv, 0u, extents, segtype, thin_pool_name);
if (segtype_is_raid(segtype) && !lv->le_count)
- raid_logs = mirrors * stripes;
+ log_count = mirrors * stripes;
-// For thin pool, ensure space for "log_lv" ->metadata_lv is allocated simultaneously here
+ if (segtype_is_thin_pool(segtype))
+ log_count = 1;
+ /* Thin pool allocation treats its metadata device like a mirror log. */
if (!(ah = allocate_extents(lv->vg, lv, segtype, stripes, mirrors,
- raid_logs, region_size, extents,
+ log_count, region_size, extents,
allocatable_pvs, alloc, NULL)))
return_0;
@@ -2532,27 +2574,20 @@
r = lv_add_segment(ah, 0, ah->area_count, lv, segtype,
stripe_size, 0u, 0);
else {
- /*
- * For RAID, all the devices are AREA_LV.
- * However, for 'mirror on stripe' using non-RAID targets,
- * the mirror legs are AREA_LV while the stripes underneath
- * are AREA_PV. So if this is not RAID, reset dev_count to
- * just 'mirrors' - the necessary sub_lv count.
- */
- if (!segtype_is_raid(segtype))
- dev_count = mirrors;
-
if (!lv->le_count &&
!_lv_insert_empty_sublvs(lv, segtype, stripe_size,
- region_size, dev_count)) {
+ region_size, sub_lv_count)) {
log_error("Failed to insert layer for %s", lv->name);
alloc_destroy(ah);
return 0;
}
-// For thin_pool, populate tmeta here too
r = _lv_extend_layered_lv(ah, lv, extents, 0,
stripes, stripe_size);
+
+ if (r && segtype_is_thin_pool(segtype))
+ r = lv_add_segment(ah, ah->area_count, 1, first_seg(lv)->pool_metadata_lv,
+ get_segtype_from_string(lv->vg->cmd, "striped"), 0, 0, 0);
}
alloc_destroy(ah);
return r;
@@ -3872,6 +3907,7 @@
lp->extents = lp->extents - size_rest + lp->stripes;
}
+ /* Does LV need to be zeroed? Thin handles this as a per-pool in-kernel setting. */
if (lp->zero && !segtype_is_thin(lp->segtype) && !activation()) {
log_error("Can't wipe start of new LV without using "
"device-mapper kernel driver");
@@ -3945,7 +3981,7 @@
}
}
- if (!lp->thin && !lp->extents) {
+ if (!seg_is_thin_volume(lp) && !lp->extents) {
log_error("Unable to create new logical volume with no extents");
return NULL;
}
@@ -3975,7 +4011,8 @@
log_error("Can't create %s without using "
"device-mapper kernel driver.",
segtype_is_raid(lp->segtype) ? lp->segtype->name :
- "mirror");
+ segtype_is_mirrored(lp->segtype) ? "mirror" :
+ "thin volume");
return NULL;
}
@@ -4073,7 +4110,7 @@
(lp->activate == CHANGE_AE && !activate_lv_excl(cmd, lv)) ||
(lp->activate == CHANGE_ALY && !activate_lv_local(cmd, lv))) {
log_error("Failed to activate new LV.");
- if (lp->zero)
+ if (lp->zero && !seg_is_thin(lp))
goto deactivate_and_revert_new_lv;
return NULL;
}
--- LVM2/lib/metadata/merge.c 2011/09/06 22:43:57 1.47
+++ LVM2/lib/metadata/merge.c 2011/09/08 16:41:18 1.48
@@ -75,6 +75,40 @@
struct replicator_site *rsite;
struct replicator_device *rdev;
+ /* Check LV flags match first segment type */
+ if (complete_vg) {
+ if (lv_is_thin_volume(lv) &&
+ (!(seg2 = first_seg(lv)) || !seg_is_thin_volume(seg2))) {
+ log_error("LV %s is thin volume without first thin volume segment",
+ lv->name);
+ inc_error_count;
+ }
+
+ if (lv_is_thin_pool(lv) &&
+ (!(seg2 = first_seg(lv)) || !seg_is_thin_pool(seg2))) {
+ log_error("LV %s is thin pool without first thin pool segment",
+ lv->name);
+ inc_error_count;
+ }
+
+ if (lv_is_thin_pool_data(lv) &&
+ (!(seg2 = first_seg(lv)) || !(seg2 = find_pool_seg(seg2)) ||
+ seg2->area_count != 1 || seg_type(seg2, 0) != AREA_LV ||
+ seg_lv(seg2, 0) != lv)) {
+ log_error("LV %s: segment 1 pool data LV does not point back to same LV",
+ lv->name);
+ inc_error_count;
+ }
+
+ if (lv_is_thin_pool_metadata(lv) &&
+ (!(seg2 = first_seg(lv)) || !(seg2 = find_pool_seg(seg2)) ||
+ seg2->pool_metadata_lv != lv)) {
+ log_error("LV %s: segment 1 pool metadata LV does not point back to same LV",
+ lv->name);
+ inc_error_count;
+ }
+ }
+
dm_list_iterate_items(seg, &lv->segments) {
seg_count++;
if (seg->le != le) {
@@ -132,6 +166,80 @@
}
}
+ /* Check the various thin segment types */
+ if (complete_vg) {
+ if (seg_is_thin_pool(seg)) {
+ if (!lv_is_thin_pool(lv)) {
+ log_error("LV %s is missing thin pool flag for segment %u",
+ lv->name, seg_count);
+ inc_error_count;
+ }
+
+ if (lv_is_thin_volume(lv)) {
+ log_error("LV %s is a thin volume that must not contain thin pool segment %u",
+ lv->name, seg_count);
+ inc_error_count;
+ }
+
+ if (seg->area_count != 1 || seg_type(seg, 0) != AREA_LV) {
+ log_error("LV %s: thin pool segment %u is missing a pool data LV",
+ lv->name, seg_count);
+ inc_error_count;
+ } else if (!(seg2 = first_seg(seg_lv(seg, 0))) || find_pool_seg(seg2) != seg) {
+ log_error("LV %s: thin pool segment %u data LV does not refer back to pool LV",
+ lv->name, seg_count);
+ inc_error_count;
+ }
+
+ if (!seg->pool_metadata_lv) {
+ log_error("LV %s: thin pool segment %u is missing a pool metadata LV",
+ lv->name, seg_count);
+ inc_error_count;
+ } else if (!(seg2 = first_seg(seg->pool_metadata_lv)) ||
+ find_pool_seg(seg2) != seg) {
+ log_error("LV %s: thin pool segment %u metadata LV does not refer back to pool LV",
+ lv->name, seg_count);
+ inc_error_count;
+ }
+ } else {
+ if (seg->pool_metadata_lv) {
+ log_error("LV %s: segment %u must not have thin pool metadata LV set",
+ lv->name, seg_count);
+ inc_error_count;
+ }
+ }
+
+ if (seg_is_thin_volume(seg)) {
+ if (!lv_is_thin_volume(lv)) {
+ log_error("LV %s is missing thin volume flag for segment %u",
+ lv->name, seg_count);
+ inc_error_count;
+ }
+
+ if (lv_is_thin_pool(lv)) {
+ log_error("LV %s is a thin pool that must not contain thin volume segment %u",
+ lv->name, seg_count);
+ inc_error_count;
+ }
+
+ if (!seg->pool_lv) {
+ log_error("LV %s: segment %u is missing thin pool LV",
+ lv->name, seg_count);
+ inc_error_count;
+ } else if (!lv_is_thin_pool(seg->pool_lv)) {
+ log_error("LV %s: thin volume segment %u pool LV is not flagged as a pool LV",
+ lv->name, seg_count);
+ inc_error_count;
+ }
+ } else {
+ if (seg->pool_lv) {
+ log_error("LV %s: segment %u must not have thin pool LV set",
+ lv->name, seg_count);
+ inc_error_count;
+ }
+ }
+ }
+
if (seg_is_snapshot(seg)) {
if (seg->cow && seg->cow == seg->origin) {
log_error("LV %s: segment %u has same LV %s for "
@@ -250,6 +358,8 @@
seg_found++;
if (seg->log_lv == lv)
seg_found++;
+ if (seg->pool_metadata_lv == lv || seg->pool_lv == lv)
+ seg_found++;
if (!seg_found) {
log_error("LV %s is used by LV %s:%" PRIu32 "-%" PRIu32
", but missing ptr from %s to %s",
--- LVM2/lib/metadata/metadata-exported.h 2011/09/07 08:34:22 1.208
+++ LVM2/lib/metadata/metadata-exported.h 2011/09/08 16:41:18 1.209
@@ -85,8 +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 THIN_POOL_DATA UINT64_C(0x0000004000000000) /* LV */
+#define THIN_POOL_METADATA UINT64_C(0x0000008000000000) /* LV */
#define LVM_READ 0x00000100U /* LV VG 32-bit */
#define LVM_WRITE 0x00000200U /* LV VG 32-bit */
@@ -327,7 +327,6 @@
struct lv_segment_area *areas;
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 */
--- LVM2/lib/metadata/metadata.h 2011/09/06 22:43:57 1.254
+++ LVM2/lib/metadata/metadata.h 2011/09/08 16:41:19 1.255
@@ -371,6 +371,9 @@
/* Find LV segment containing given LE */
struct lv_segment *find_seg_by_le(const struct logical_volume *lv, uint32_t le);
+/* Find pool LV segment given a thin pool data or metadata segment. */
+struct lv_segment *find_pool_seg(struct lv_segment *seg);
+
/*
* Remove a dev_dir if present.
*/
@@ -447,6 +450,7 @@
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);
+int detach_pool_lv(struct lv_segment *seg);
/*
* Begin skeleton for external LVM library
--- LVM2/lib/metadata/thin_manip.c 2011/09/06 22:43:57 1.2
+++ LVM2/lib/metadata/thin_manip.c 2011/09/08 16:41:19 1.3
@@ -14,6 +14,8 @@
#include "lib.h"
#include "metadata.h"
+#include "segtype.h"
+#include "lv_alloc.h"
int attach_pool_metadata_lv(struct lv_segment *seg, struct logical_volume *pool_metadata_lv)
{
@@ -26,17 +28,55 @@
int attach_pool_data_lv(struct lv_segment *seg, struct logical_volume *pool_data_lv)
{
- seg->pool_data_lv = pool_data_lv;
- pool_data_lv->status |= THIN_POOL_DATA;
+ if (!set_lv_segment_area_lv(seg, 0, pool_data_lv, 0, THIN_POOL_DATA))
+ return_0;
+
lv_set_hidden(pool_data_lv);
- return add_seg_to_segs_using_this_lv(pool_data_lv, seg);
+ return 1;
}
int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv)
{
+ if (!lv_is_thin_pool(pool_lv)) {
+ log_error(INTERNAL_ERROR "LV %s is not a thin pool",
+ pool_lv->name);
+ return 0;
+ }
+
seg->pool_lv = pool_lv;
- pool_lv->status |= THIN_POOL;
+ seg->lv->status |= THIN_VOLUME;
return add_seg_to_segs_using_this_lv(pool_lv, seg);
}
+
+int detach_pool_lv(struct lv_segment *seg)
+{
+ if (!lv_is_thin_pool(seg->pool_lv)) {
+ log_error(INTERNAL_ERROR "LV %s is not a thin pool",
+ seg->pool_lv->name);
+ return 0;
+ }
+
+ return remove_seg_from_segs_using_this_lv(seg->pool_lv, seg);
+}
+
+struct lv_segment *find_pool_seg(struct lv_segment *seg)
+{
+ struct lv_segment *pool_seg;
+
+ pool_seg = get_only_segment_using_this_lv(seg->lv);
+
+ if (!pool_seg) {
+ log_error("Failed to find pool_seg for %s", seg->lv->name);
+ return NULL;
+ }
+
+ if (!seg_is_thin_pool(pool_seg)) {
+ log_error("%s on %s is not a pool segment",
+ pool_seg->lv->name, seg->lv->name);
+ return NULL;
+ }
+
+ return pool_seg;
+}
--- LVM2/lib/thin/thin.c 2011/09/06 22:43:57 1.11
+++ LVM2/lib/thin/thin.c 2011/09/08 16:41:19 1.12
@@ -61,10 +61,10 @@
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))
+ if (!attach_pool_data_lv(seg, pool_data_lv))
return_0;
- if (!attach_pool_data_lv(seg, pool_data_lv))
+ if (!attach_pool_metadata_lv(seg, pool_metadata_lv))
return_0;
if (!dm_config_get_uint64(sn, "transaction_id", &seg->transaction_id))
@@ -74,12 +74,22 @@
!dm_config_get_uint32(sn, "zero_new_blocks", &seg->zero_new_blocks))
return SEG_LOG_ERROR("Could not read zero_new_blocks for");
+ seg->lv->status |= THIN_POOL;
+
+ return 1;
+}
+
+static int _thin_pool_text_import_area_count(const struct dm_config_node *sn,
+ uint32_t *area_count)
+{
+ *area_count = 1;
+
return 1;
}
static int _thin_pool_text_export(const struct lv_segment *seg, struct formatter *f)
{
- outf(f, "pool = \"%s\"", seg->pool_data_lv->name);
+ outf(f, "pool = \"%s\"", seg_lv(seg, 0)->name);
outf(f, "metadata = \"%s\"", seg->pool_metadata_lv->name);
outf(f, "transaction_id = %" PRIu64, seg->transaction_id);
if (seg->zero_new_blocks)
@@ -182,6 +192,7 @@
static struct segtype_handler _thin_pool_ops = {
.name = _thin_pool_name,
.text_import = _thin_pool_text_import,
+ .text_import_area_count = _thin_pool_text_import_area_count,
.text_export = _thin_pool_text_export,
.modules_needed = _thin_modules_needed,
.destroy = _thin_destroy,
--- LVM2/tools/lvcreate.c 2011/09/07 09:25:51 1.239
+++ LVM2/tools/lvcreate.c 2011/09/08 16:41:19 1.240
@@ -590,6 +590,11 @@
lp->segtype = get_segtype_from_string(cmd, arg_str_value(cmd, type_ARG, segtype_str));
+ if (seg_unknown(lp)) {
+ log_error("Unable to create LV with unknown segment type %s.", arg_str_value(cmd, type_ARG, segtype_str));
+ return 0;
+ }
+
if (arg_count(cmd, snapshot_ARG) || seg_is_snapshot(lp) ||
(!seg_is_thin(lp) && arg_count(cmd, virtualsize_ARG)))
lp->snapshot = 1;
^ permalink raw reply [flat|nested] 2+ messages in thread
* LVM2 lib/format_text/flags.c lib/metadata/lv_m ...
@ 2010-01-13 1:56 snitzer
0 siblings, 0 replies; 2+ messages in thread
From: snitzer @ 2010-01-13 1:56 UTC (permalink / raw)
To: lvm-devel, lvm2-cvs
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: snitzer@sourceware.org 2010-01-13 01:56:19
Modified files:
lib/format_text: flags.c
lib/metadata : lv_manip.c metadata-exported.h snapshot_manip.c
lib/snapshot : snapshot.c
tools : toollib.c vgchange.c
Log message:
Rename segment and lv status flag from SNAPSHOT_MERGE to MERGING.
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.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/flags.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.201&r2=1.202
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.127&r2=1.128
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/snapshot_manip.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/snapshot/snapshot.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.183&r2=1.184
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.97&r2=1.98
--- LVM2/lib/format_text/flags.c 2010/01/13 01:35:49 1.40
+++ LVM2/lib/format_text/flags.c 2010/01/13 01:56:18 1.41
@@ -61,7 +61,7 @@
{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},
--- LVM2/lib/metadata/lv_manip.c 2010/01/13 01:55:44 1.201
+++ LVM2/lib/metadata/lv_manip.c 2010/01/13 01:56:18 1.202
@@ -1877,7 +1877,6 @@
}
lv->snapshot = NULL;
- lv->merging_snapshot = NULL;
dm_list_init(&lv->snapshot_segs);
dm_list_init(&lv->segments);
dm_list_init(&lv->tags);
--- LVM2/lib/metadata/metadata-exported.h 2010/01/13 01:55:44 1.127
+++ LVM2/lib/metadata/metadata-exported.h 2010/01/13 01:56:18 1.128
@@ -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 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;
--- LVM2/lib/metadata/snapshot_manip.c 2010/01/13 01:55:44 1.46
+++ LVM2/lib/metadata/snapshot_manip.c 2010/01/13 01:56:18 1.47
@@ -25,7 +25,7 @@
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_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 @@
* 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,
--- LVM2/lib/snapshot/snapshot.c 2010/01/13 01:39:44 1.41
+++ LVM2/lib/snapshot/snapshot.c 2010/01/13 01:56:18 1.42
@@ -84,7 +84,7 @@
{
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 @@
_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;
--- LVM2/tools/toollib.c 2010/01/13 01:55:44 1.183
+++ LVM2/tools/toollib.c 2010/01/13 01:56:18 1.184
@@ -1307,7 +1307,7 @@
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);
--- LVM2/tools/vgchange.c 2010/01/13 01:55:44 1.97
+++ LVM2/tools/vgchange.c 2010/01/13 01:56:18 1.98
@@ -69,8 +69,7 @@
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 @@
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++;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-09-08 16:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-08 16:41 LVM2 lib/format_text/flags.c lib/metadata/lv_m agk
-- strict thread matches above, loose matches on Subject: below --
2010-01-13 1:56 snitzer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).