master - post-release
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=131aaeb6344b17...
Commit: 131aaeb6344b17586571f126468b67c960075f50
Parent: 9a5910bdf9a8d79051181f110a43a7c1ef2288d6
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Nov 11 14:15:32 2014 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Nov 11 14:15:32 2014 +0000
post-release
---
VERSION | 2 +-
VERSION_DM | 2 +-
WHATS_NEW | 3 +++
WHATS_NEW_DM | 3 +++
4 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/VERSION b/VERSION
index a533a72..2acba4f 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.02.112(2)-git (2014-11-11)
+2.02.113(2)-git (2014-11-11)
diff --git a/VERSION_DM b/VERSION_DM
index a5eac8b..5b592b1 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.91-git (2014-11-11)
+1.02.92-git (2014-11-11)
diff --git a/WHATS_NEW b/WHATS_NEW
index 820106b..0c8fcc7 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,3 +1,6 @@
+Version 2.02.113 -
+=====================================
+
Version 2.02.112 - 11th November 2014
=====================================
Add cache_{read,write}_{hits,misses} reporting fields.
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 97eb339..6f23958 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,3 +1,6 @@
+Version 1.02.92 -
+====================================
+
Version 1.02.91 - 11th November 2014
====================================
Update cache creation and dm_config_node to pass policy.
9 years, 7 months
master - pre-release
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9a5910bdf9a8d7...
Commit: 9a5910bdf9a8d79051181f110a43a7c1ef2288d6
Parent: 9704515c1e22ff0ebaec16572d1c51d954259da5
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Nov 11 14:13:00 2014 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Nov 11 14:13:00 2014 +0000
pre-release
---
VERSION | 2 +-
VERSION_DM | 2 +-
WHATS_NEW | 21 +++++++++++++--------
WHATS_NEW_DM | 8 ++++----
daemons/cmirrord/compat.c | 1 -
lib/cache_segtype/cache.c | 2 +-
lib/format_text/flags.c | 2 +-
lib/locking/locking_types.h | 4 ++--
lib/metadata/cache_manip.c | 2 +-
lib/metadata/lv.c | 2 +-
lib/metadata/lv_manip.c | 26 +++++++++++++-------------
lib/metadata/metadata.c | 4 ++--
lib/metadata/vg.c | 4 +---
libdm/libdevmapper.h | 4 ++--
libdm/libdm-report.c | 2 +-
tools/lvcreate.c | 8 ++++----
16 files changed, 48 insertions(+), 46 deletions(-)
diff --git a/VERSION b/VERSION
index 061e5da..a533a72 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.02.112(2)-git (2014-09-01)
+2.02.112(2)-git (2014-11-11)
diff --git a/VERSION_DM b/VERSION_DM
index d021c49..a5eac8b 100644
--- a/VERSION_DM
+++ b/VERSION_DM
@@ -1 +1 @@
-1.02.91-git (2014-09-01)
+1.02.91-git (2014-11-11)
diff --git a/WHATS_NEW b/WHATS_NEW
index a4f5c97..820106b 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,9 +1,9 @@
-Version 2.02.112 -
+Version 2.02.112 - 11th November 2014
=====================================
Add cache_{read,write}_{hits,misses} reporting fields.
Add cache_{total,used,dirty}_blocks reporting fields.
Add _corig as reserved suffix.
- Reduce vg write and vg commits when creating spare volumes.
+ Reduce number of VG writes and commits when creating spare volumes.
When remove_layer_from_lv() removes layer, restore subLV names.
Cache-pool in use becomes invisible LV.
Don't prompt for removal of _pmspare in VG without pool metadata LV.
@@ -15,7 +15,8 @@ Version 2.02.112 -
Report some basic percentage info for cache pools.
Introduce size_mb_arg_with_percent() for advanced size arg reading.
Add extra support for '.' as decimal point in size args.
- Configurable support for creation of sparse volumes with thin-pools.
+ Add configure parameters for default segment type choices.
+ Add global/sparse_segtype_default setting to use thin for --type sparse.
Update and correct lvcreate and lvcovert man pages.
Mark pools and snapshots as unzeroable volumes.
Check for zeroing of volume after segment type is fully detected.
@@ -28,13 +29,14 @@ Version 2.02.112 -
Query lock holding LV when replacing and converting raid volumes.
Add extra validate for locked lv within validate_lv_cache_create().
Add internal lvseg_name() function.
- Skip trying to file lock virtual internal vg name.
+ Skip use of lock files for virtual internal VG names.
Fix selection on {vg,lv}_permissions fields to properly match selection criteria.
Fix lv_permissions reporting to display read-only{-override} instead of blank.
Fix liblvm2cmd and lvm shell to respect quotes around args in cmd line string.
Permit extent sizes > 128KB that are not power of 2 with lvm2 format.
Remove workaround for lvm2-monitor.service hang on stop if lvmetad stopped.
Change vgremove to use process_each_lv_in_vg.
+ Allow lvconvert --repair and --splitmirrors on internal LVs.
Introduce WARN_ flags to control some metadata warning messages.
Use process_each_pv in vgreduce.
Refactor process_each_pv in toollib.
@@ -47,11 +49,12 @@ Version 2.02.112 -
Improve code for creation of cache and cache pool volumes.
Check cluster-wide (not local) active status before removing LV.
Properly check if activation of removed cached LV really activated.
- Lvremoving cached LV removes cachepool (keep with lvconvert --splitcache).
+ lvremove cached LV removes cachepool (keep with lvconvert --splitcache).
Always remove spare LV with last removed pool volume.
Support lvconvert --splitcache and --uncache of cached LV.
Option --cache has also shortcut -H (i.e. lvcreate -H).
Refactor lvcreate code and better preserve --type argument.
+ Refactor filter processing around lvmetad.
Refactor process_each_lv in toollib.
Refactor process_each_vg in toollib.
Pools cannot be used as external origin.
@@ -64,6 +67,7 @@ Version 2.02.112 -
Unify handling of --persistent option for lvcreate and lvchange.
Validate major and minor numbers stored in metadata.
Use -fPIE when linking -pie executables.
+ Support DEBUG_MEMLOCK to trap unsupported mmap usage.
Enable cache segment type by default.
Ensure only supported volume types are used with cache segments.
Fix inablility to specify cachemode when 'lvconvert'ing to cache-pool.
@@ -75,8 +79,6 @@ Version 2.02.112 -
Fix cmirror endian conversions.
Introduce lv_is_pvmove/locked/converting/merging macros.
Avoid leaving linear logical volume when thin pool creation fails.
- Demote an error to a warning when devices known to lvmetad are filtered out.
- Re-order filter evaluation, making component filters global.
Don't leak alloc_handle on raid target error path.
Properly validate raid leg names.
Archive metadata before starting their modification in raid target.
@@ -84,7 +86,10 @@ Version 2.02.112 -
Add missing backup of lvm2 metadata after some raid modifications.
Use vg memory pool for extent allocation.
Add allocation/physical_extent_size config option for default PE size of VGs.
- Introduce common code to modify metadate and reload updated LV.
+ Demote an error to a warning when devices known to lvmetad are filtered out.
+ Re-order filter evaluation, making component filters global.
+ Fix logic that checks for full scan before iterating through devices.
+ Introduce common code to modify metadata and reload updated LV.
Fix rename of active snapshot volume in cluster.
Make sure shared libraries are built with RELRO option.
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index f4148bc..97eb339 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,10 +1,10 @@
-Version 1.02.91 -
+Version 1.02.91 - 11th November 2014
====================================
- Update API for cache creation and dm_config_node to pass policy.
- Allow activation of any thin-pool with passed transaction_id == 0.
+ Update cache creation and dm_config_node to pass policy.
+ Allow activation of any thin-pool if transaction_id supplied is 0.
Don't print uninitialized stack bytes when non-root uses dm_check_version().
Fix selection criteria to not match reserved values when using >, <, >=, <.
- Add DM_LIST_HEAD_INIT macro to libdevmapper.h
+ Add DM_LIST_HEAD_INIT macro to libdevmapper.h.
Fix dm_is_dm_major to not issue error about missing /proc lines for dm module.
Version 1.02.90 - 1st September 2014
diff --git a/daemons/cmirrord/compat.c b/daemons/cmirrord/compat.c
index 4955f50..a9696d7 100644
--- a/daemons/cmirrord/compat.c
+++ b/daemons/cmirrord/compat.c
@@ -183,7 +183,6 @@ int clog_request_from_network(void *data, size_t data_len)
{
uint64_t *vp = data;
uint64_t version = xlate64(vp[0]);
- uint64_t unconverted_version = vp[1];
struct clog_request *rq = data;
switch (version) {
diff --git a/lib/cache_segtype/cache.c b/lib/cache_segtype/cache.c
index b42a529..02ac198 100644
--- a/lib/cache_segtype/cache.c
+++ b/lib/cache_segtype/cache.c
@@ -78,7 +78,7 @@ static int _cache_pool_text_import(struct lv_segment *seg,
return SEG_LOG_ERROR("Failed to duplicate policy in");
} else
/* Cannot use 'just' default, so pick one */
- seg->policy_name = DEFAULT_CACHE_POOL_POLICY; /* TODO: configurable default */
+ seg->policy_name = DEFAULT_CACHE_POOL_POLICY; /* FIXME make configurable */
/*
* Read in policy args:
diff --git a/lib/format_text/flags.c b/lib/format_text/flags.c
index 21555d6..e3a00a6 100644
--- a/lib/format_text/flags.c
+++ b/lib/format_text/flags.c
@@ -88,7 +88,7 @@ static const struct flag _lv_flags[] = {
{CACHE_POOL, NULL, 0},
{CACHE_POOL_DATA, NULL, 0},
{CACHE_POOL_METADATA, NULL, 0},
- {LV_PENDING_DELETE, NULL, 0}, /* TODO: print as COMPATIBLE_FLAG */
+ {LV_PENDING_DELETE, NULL, 0}, /* FIXME Display like COMPATIBLE_FLAG */
{0, NULL, 0}
};
diff --git a/lib/locking/locking_types.h b/lib/locking/locking_types.h
index 8280e4f..64d13db 100644
--- a/lib/locking/locking_types.h
+++ b/lib/locking/locking_types.h
@@ -23,8 +23,8 @@ typedef int (*query_resource_fn) (const char *resource, int *mode);
typedef void (*fin_lock_fn) (void);
typedef void (*reset_lock_fn) (void);
-#define LCK_PRE_MEMLOCK 0x00000001 /* Is memlock() needed before calls? */
-#define LCK_CLUSTERED 0x00000002
+#define LCK_PRE_MEMLOCK 0x00000001 /* Is memlock() needed before calls? */
+#define LCK_CLUSTERED 0x00000002
#define LCK_SUPPORTS_REMOTE_QUERIES 0x00000004
struct locking_type {
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 9c69970..d7813c3 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -27,7 +27,7 @@
#define DM_TRANSACTION_OVERHEAD 4096 /* KiB */
#define DM_BYTES_PER_BLOCK 16 /* bytes */
#define DM_HINT_OVERHEAD_PER_BLOCK 8 /* bytes */
-#define DM_MAX_HINT_WIDTH (4+16) /* bytes, TODO: configurable ?? */
+#define DM_MAX_HINT_WIDTH (4+16) /* bytes. FIXME Configurable? */
const char *get_cache_pool_cachemode_name(const struct lv_segment *seg)
{
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 85076fa..bf2d04e 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -863,7 +863,7 @@ static int _lv_is_exclusive(struct logical_volume *lv)
struct lv_segment *seg;
/* Some seg types require exclusive activation */
- /* TODO: deep-scan of every segtype in use */
+ /* FIXME Scan recursively */
dm_list_iterate_items(seg, &lv->segments)
if (seg_only_exclusive(seg))
return 1;
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index a6ab3d3..543f070 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -6768,11 +6768,11 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return NULL;
}
/* Create cache origin for cache pool */
- /* TODO: eventually support raid/mirrors with -m */
+ /* FIXME Eventually support raid/mirrors with -m */
if (!(create_segtype = get_segtype_from_string(vg->cmd, "striped")))
return_0;
} else if (seg_is_mirrored(lp) || seg_is_raid(lp)) {
- /* FIXME: this will not pass cluster lock! */
+ /* FIXME This will not pass cluster lock! */
init_mirror_in_sync(lp->nosync);
if (lp->nosync) {
@@ -6809,11 +6809,11 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
return_NULL;
if (origin_lv->status & LVM_WRITE) {
log_error("Cannot use writable LV as the external origin.");
- return NULL; // TODO conversion for inactive
+ return NULL; /* FIXME conversion for inactive */
}
if (lv_is_active(origin_lv) && !lv_is_external_origin(origin_lv)) {
log_error("Cannot use active LV for the external origin.");
- return NULL; // We can't be sure device is read-only
+ return NULL; /* We can't be sure device is read-only */
}
}
}
@@ -7029,7 +7029,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
lv->status |= LV_TEMPORARY;
if (seg_is_cache(lp)) {
- /* TODO: support remote exclusive activation? */
+ /* FIXME Support remote exclusive activation? */
/* Not yet 'cache' LV, it is stripe volume for wiping */
if (is_change_activating(lp->activate) &&
!activate_lv_excl_local(cmd, lv)) {
@@ -7132,7 +7132,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
if (origin_lv) {
/* Convert origin to cached LV */
if (!(tmp_lv = lv_cache_create(lv, origin_lv))) {
- /* TODO: do a better revert */
+ /* FIXME Do a better revert */
log_error("Aborting. Leaving cache pool %s and uncached origin volume %s.",
display_lvname(lv), display_lvname(origin_lv));
return NULL;
@@ -7146,7 +7146,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
}
lv = tmp_lv;
if (!lv_update_and_reload(lv)) {
- /* TODO: do a better revert */
+ /* FIXME Do a better revert */
log_error("Aborting. Manual intervention required.");
return NULL; /* FIXME: revert */
}
@@ -7186,13 +7186,13 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
backup(vg);
/*
- * TODO:
- * We do not actually need snapshot-origin as an active device,
- * as virtual origin is already 'hidden' private device without
- * vg/lv links. As such it is not supposed to be used by any user.
- * Also it would save one dm table entry, but it needs quite a few
- * changes in the libdm/lvm2 code base to support it.
+ * FIXME We do not actually need snapshot-origin as an active device,
+ * as virtual origin is already 'hidden' private device without
+ * vg/lv links. As such it is not supposed to be used by any user.
+ * Also it would save one dm table entry, but it needs quite a few
+ * changes in the libdm/lvm2 code base to support it.
*/
+
/* Activate spare snapshot once it is a complete LV */
if (!lv_active_change(cmd, origin_lv, lp->activate, 1)) {
log_error("Failed to activate sparce volume %s.",
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index df2d6a3..11dabcc 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -2547,12 +2547,12 @@ int vg_validate(struct volume_group *vg)
if (lv_is_pool_metadata_spare(lvl->lv)) {
if (++spare_count > 1) {
- log_error(INTERNAL_ERROR "LV %s is %u. pool metadata spare (>1).",
+ log_error(INTERNAL_ERROR "LV %s is extra pool metadata spare volume. %u found but only 1 allowed.",
lvl->lv->name, spare_count);
r = 0;
}
if (vg->pool_metadata_spare_lv != lvl->lv) {
- log_error(INTERNAL_ERROR "LV %s is not vg pool metadata spare.",
+ log_error(INTERNAL_ERROR "LV %s is not the VG's pool metadata spare volume.",
lvl->lv->name);
r = 0;
}
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index 71b894b..fee3767 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -552,9 +552,7 @@ int vg_set_alloc_policy(struct volume_group *vg, alloc_policy_t alloc)
}
/*
- * Switching the cluster attribute make the active volume
- * exclusively activate
- * with any active logical volumes.
+ * Setting the cluster attribute marks active volumes exclusive.
*
* FIXME: resolve logic with reacquiring proper top-level LV locks
* and we likely can't giveup DLM locks for active LVs...
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 9ea7dbe..6e237c0 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -799,8 +799,8 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
uint32_t chunk_size);
/*
- * TODO: Add individual cache policy pairs <key> = value, like:
- *int dm_tree_node_add_cache_policy_arg(struct dm_tree_node *dnode,
+ * FIXME Add individual cache policy pairs <key> = value, like:
+ * int dm_tree_node_add_cache_policy_arg(struct dm_tree_node *dnode,
* const char *key, uint64_t value);
*/
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index f68aa85..bf64cc3 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -1265,7 +1265,7 @@ static int _check_value_is_reserved(struct dm_report *rh, unsigned type, const v
return 1;
break;
case DM_REPORT_FIELD_TYPE_STRING_LIST:
- // TODO: add comparison for string list
+ /* FIXME Add comparison for string list */
break;
}
}
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index af00fee..b0186d3 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -675,7 +675,7 @@ static int _lvcreate_params(struct cmd_context *cmd,
/* Starts basic option validation for every segment type */
- /* TODO: Use these ARGS macros also in commands.h ? */
+ /* FIXME Use these ARGS macros also in commands.h? */
/* ARGS are disjoint! sets of options */
#define LVCREATE_ARGS \
activate_ARG,\
@@ -783,7 +783,7 @@ static int _lvcreate_params(struct cmd_context *cmd,
-1))
return_0;
- /* TODO: resolve this ambiguous case with --pooldatasize */
+ /* FIXME Resolve this ambiguous case with --pooldatasize */
if (arg_is_set(cmd, thinpool_ARG)) {
if (lp->type) {
/* Unsupported with --type snapshot */
@@ -1071,12 +1071,12 @@ static int _determine_cache_argument(struct volume_group *vg,
log_error("Change of volume permission is unsupported with cache conversion, use lvchange.");
return 0;
}
- /* FIXME: how to handle skip flag */
+ /* FIXME How to handle skip flag? */
if (arg_from_list_is_set(cmd, "is unsupported with cache conversion",
setactivationskip_ARG,
ignoreactivationskip_ARG,
-1))
- return_0; /* TODO FIX THIS */
+ return_0; /* FIXME */
/* Put origin into resulting activation state first */
if (is_change_activating(lp->activate)) {
9 years, 7 months
master - dev_manager: only support status for cache segment at the moment
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9704515c1e22ff...
Commit: 9704515c1e22ff0ebaec16572d1c51d954259da5
Parent: 8121074fda126cc6c0df05fba066cc9365e00255
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Nov 11 14:55:58 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Nov 11 15:02:21 2014 +0100
dev_manager: only support status for cache segment at the moment
When getting status for LV segment types, we need to be sure
that proper segment is selected for the status ioctl.
When reporting fields that require status ioctl,
the "_choose_lv_segment_for_status_report" fn in tools/reporter.c
must be completed properly to choose the proper segment for all
the LV types (at the moment, it just takes the first LV segment
by default).
This works fine with cache LVs surely. The other segment types
need more auditing. We use this status ioctl only for cache status
fields at the moment only, so restrict it to the cache only.
Once the _choose_lv_segment_for_status_report is completed
properly, release the restriction in _get_segment_status_from_target_params.
---
lib/activate/dev_manager.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 4351bc9..a392387 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -112,10 +112,14 @@ static int _get_segment_status_from_target_params(const char *target_name,
{
struct segment_type *segtype;
- /* FIXME: linear is also represented as striped with stripe count 1.
- We're not reporting linear or striped status anyway, so
- just skip the error here till this is properly resolved.*/
- if (!strcmp(target_name, "linear") || !strcmp(target_name, "striped"))
+ /*
+ * TODO: Add support for other segment types too!
+ * The segment to report status for must be properly
+ * selected for all the other types - mainly make sure
+ * linear/striped, old snapshots and raids have proper
+ * segment selected for status!
+ */
+ if (strcmp(target_name, "cache"))
return 1;
segtype = get_segtype_from_string(seg_status->seg->lv->vg->cmd, target_name);
9 years, 7 months
master - cache: pending_delete fixes
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8121074fda126c...
Commit: 8121074fda126cc6c0df05fba066cc9365e00255
Parent: 9a6e3683a292adec96a8e2421c86f4aae4756797
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 11 13:31:25 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Nov 11 13:32:41 2014 +0100
cache: pending_delete fixes
---
lib/activate/dev_manager.c | 18 +++++++++++-------
lib/metadata/cache_manip.c | 5 ++++-
lib/metadata/lv_manip.c | 19 +++++++++++++++----
lib/metadata/pool_manip.c | 19 ++++++++++++++++---
4 files changed, 46 insertions(+), 15 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 4dc08d2..4351bc9 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -1969,15 +1969,14 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
if (lv_is_cache_pool(lv)) {
if (!dm_list_empty(&lv->segs_using_this_lv)) {
- /* origin_only is ignored */
- /* cache pool is 'meta' LV and does not have a real device node */
if (!_add_lv_to_dtree(dm, dtree, seg_lv(first_seg(lv), 0), 0))
return_0;
if (!_add_lv_to_dtree(dm, dtree, first_seg(lv)->metadata_lv, 0))
return_0;
- } else if (!_add_dev_to_dtree(dm, dtree, lv, NULL))
- return_0; /* For internal use - empty pool makes meta visible */
- return 1;
+ /* Cache pool does not have a real device node */
+ return 1;
+ }
+ /* Unused cache pool is activated as metadata */
}
if (!origin_only && !_add_dev_to_dtree(dm, dtree, lv, NULL))
@@ -2988,14 +2987,19 @@ static int _clean_tree(struct dev_manager *dm, struct dm_tree_node *root, char *
continue;
/* FIXME: we still occasionally need to activate these at top-level */
- if (strstr(lvname, "_tmeta") || strstr(lvname, "_tdata"))
+ if (((name = strstr(lvname, "_tmeta")) && !name[6]) ||
+ ((name = strstr(lvname, "_tdata")) && !name[6]))
continue;
/* If operation was performed on a partial tree, don't remove it */
if (non_toplevel_tree_dlid && !strcmp(non_toplevel_tree_dlid, uuid))
continue;
- if (!dm_tree_deactivate_children(root, uuid, strlen(uuid)))
+ if ((name = strstr(lvname, "_corig")) && !name[6]) {
+ /* FIXME: for now just for _corig deactivate LVM subtree, should be generic */
+ if (!dm_tree_deactivate_children(root, "LVM-", 4))
+ return_0;
+ } else if (!dm_tree_deactivate_children(root, uuid, strlen(uuid)))
return_0;
}
diff --git a/lib/metadata/cache_manip.c b/lib/metadata/cache_manip.c
index 6c74e57..9c69970 100644
--- a/lib/metadata/cache_manip.c
+++ b/lib/metadata/cache_manip.c
@@ -246,8 +246,11 @@ int lv_cache_remove(struct logical_volume *cache_lv)
return 0;
}
- if (lv_is_pending_delete(cache_lv))
+ if (lv_is_pending_delete(cache_lv)) {
+ log_error(INTERNAL_ERROR "LV %s is already dropped cache volume.",
+ display_lvname(cache_lv));
goto remove; /* Already dropped */
+ }
/* Localy active volume is needed for writeback */
if (!lv_is_active_locally(cache_lv)) {
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 20bf76f..a6ab3d3 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -1280,9 +1280,19 @@ static int _lv_reduce(struct logical_volume *lv, uint32_t extents, int delete)
return_0;
/* Remove cache origin only when removing (not on lv_empty()) */
- if (delete && seg_is_cache(seg) &&
- !lv_is_pending_delete(seg->lv) && !lv_remove(seg_lv(seg, 0)))
- return_0;
+ if (delete && seg_is_cache(seg)) {
+ if (lv_is_pending_delete(seg->lv)) {
+ /* Just dropping reference on origin when pending delete */
+ if (!remove_seg_from_segs_using_this_lv(seg_lv(seg, 0), seg))
+ return_0;
+ seg_lv(seg, 0) = NULL;
+ seg_le(seg, 0) = 0;
+ seg_type(seg, 0) = AREA_UNASSIGNED;
+ if (seg->pool_lv && !detach_pool_lv(seg))
+ return_0;
+ } else if (!lv_remove(seg_lv(seg, 0)))
+ return_0;
+ }
if ((pool_lv = seg->pool_lv)) {
if (!detach_pool_lv(seg))
@@ -5383,6 +5393,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
return_0;
if ((force == PROMPT) &&
+ !lv_is_pending_delete(lv) &&
lv_is_visible(lv) &&
lv_is_active(lv)) {
if (yes_no_prompt("Do you really want to remove%s active "
@@ -5406,7 +5417,7 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
return 0;
}
- if (lv_is_cache(lv)) {
+ if (lv_is_cache(lv) && !lv_is_pending_delete(lv)) {
if (!lv_remove_single(cmd, first_seg(lv)->pool_lv, force,
suppress_remove_message)) {
if (force < DONT_PROMPT_OVERRIDE) {
diff --git a/lib/metadata/pool_manip.c b/lib/metadata/pool_manip.c
index b2e99f1..70b5a23 100644
--- a/lib/metadata/pool_manip.c
+++ b/lib/metadata/pool_manip.c
@@ -217,10 +217,23 @@ int detach_pool_lv(struct lv_segment *seg)
struct lv_segment *find_pool_seg(const struct lv_segment *seg)
{
- struct lv_segment *pool_seg;
+ struct lv_segment *pool_seg = NULL;
+ struct seg_list *sl;
- if (!(pool_seg = get_only_segment_using_this_lv(seg->lv)))
- return_NULL;
+ dm_list_iterate_items(sl, &seg->lv->segs_using_this_lv) {
+ /* Needs to be he only item in list */
+ if (lv_is_pending_delete(sl->seg->lv))
+ continue;
+
+ if (pool_seg) {
+ log_error("%s is referenced by more then one segments (%s, %s).",
+ display_lvname(seg->lv), display_lvname(pool_seg->lv),
+ display_lvname(sl->seg->lv));
+ return NULL; /* More then one segment */
+ }
+
+ pool_seg = sl->seg;
+ }
if ((lv_is_thin_type(seg->lv) && !seg_is_pool(pool_seg))) {
log_error("%s on %s is not a %s pool segment",
9 years, 7 months
master - cache: never create new table entry for deleted cache
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9a6e3683a292ad...
Commit: 9a6e3683a292adec96a8e2421c86f4aae4756797
Parent: 42a3305ec7aac3b1b75098c5d1ea7fa9b92a0477
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 11 11:00:51 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Nov 11 13:32:41 2014 +0100
cache: never create new table entry for deleted cache
---
lib/activate/dev_manager.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 5a07fad..4dc08d2 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -2678,6 +2678,10 @@ static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
uint32_t read_ahead = lv->read_ahead;
uint32_t read_ahead_flags = UINT32_C(0);
+ /* LV with pending delete is never put new into a table */
+ if (lv_is_pending_delete(lv) && !_cached_dm_info(dm->mem, dtree, lv, NULL))
+ return 1; /* Replace with error only when already exists */
+
if (lv_is_cache_pool(lv) &&
!dm_list_empty(&lv->segs_using_this_lv)) {
/* cache pool is 'meta' LV and does not have a real device node */
9 years, 7 months
master - cache: no status for pending deleted cache
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=42a3305ec7aac3...
Commit: 42a3305ec7aac3b1b75098c5d1ea7fa9b92a0477
Parent: 7fa7ac528d1dbbcaf424b422a462af437bcf56fb
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Nov 11 11:00:35 2014 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Nov 11 13:32:41 2014 +0100
cache: no status for pending deleted cache
---
lib/activate/activate.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 2843e61..ddbebf7 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -1015,6 +1015,9 @@ int lv_cache_status(const struct logical_volume *cache_lv,
cache_lv = cache_seg->lv;
}
+ if (lv_is_pending_delete(cache_lv))
+ return 0;
+
if (!lv_info(cache_lv->vg->cmd, cache_lv, 0, NULL, 0, 0))
return 0;
9 years, 7 months
master - WHATS_NEW: '_' -> ','
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7fa7ac528d1dbb...
Commit: 7fa7ac528d1dbbcaf424b422a462af437bcf56fb
Parent: 2dde6c6531f9a06896ae61f0878745542b4001b6
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Nov 11 13:27:34 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Nov 11 13:27:34 2014 +0100
WHATS_NEW: '_' -> ','
---
WHATS_NEW | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3a3f7d5..a4f5c97 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,6 +1,6 @@
Version 2.02.112 -
=====================================
- Add cache_{read_write}_{hits,misses} reporting fields.
+ Add cache_{read,write}_{hits,misses} reporting fields.
Add cache_{total,used,dirty}_blocks reporting fields.
Add _corig as reserved suffix.
Reduce vg write and vg commits when creating spare volumes.
9 years, 7 months
master - report: add cache device status fields
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2dde6c6531f9a0...
Commit: 2dde6c6531f9a06896ae61f0878745542b4001b6
Parent: a2c1024f6ac7e22ac5c010a267d0c1df331ee416
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Oct 24 13:39:56 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Nov 11 13:07:30 2014 +0100
report: add cache device status fields
New reporting fields related to cache device status:
- cache_total_blocks
- cache_used_blocks
- cache_dirty_blocks
- cache_read_hits
- cache_read_misses
- cache_write_hits
- cache_write_misses
---
WHATS_NEW | 2 ++
lib/report/columns.h | 8 ++++++++
lib/report/properties.c | 15 +++++++++++++++
lib/report/report.c | 25 +++++++++++++++++++++++++
4 files changed, 50 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0b5d892..3a3f7d5 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
Version 2.02.112 -
=====================================
+ Add cache_{read_write}_{hits,misses} reporting fields.
+ Add cache_{total,used,dirty}_blocks reporting fields.
Add _corig as reserved suffix.
Reduce vg write and vg commits when creating spare volumes.
When remove_layer_from_lv() removes layer, restore subLV names.
diff --git a/lib/report/columns.h b/lib/report/columns.h
index a2f34f9..db43e13 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -95,6 +95,14 @@ FIELD(LVSINFO, lv, BIN, "LiveTable", lvid, 20, lvlivetable, lv_live_table, "Set
FIELD(LVSINFO, lv, BIN, "InactiveTable", lvid, 20, lvinactivetable, lv_inactive_table, "Set if LV has inactive table present.", 0)
FIELD(LVSINFO, lv, BIN, "DevOpen", lvid, 10, lvdeviceopen, lv_device_open, "Set if LV device is open.", 0)
+FIELD(LVSSTATUS, lv, NUM, "CacheTotalBlocks", lvid, 16, cache_total_blocks, cache_total_blocks, "Total cache blocks.", 0)
+FIELD(LVSSTATUS, lv, NUM, "CacheUsedBlocks", lvid, 16, cache_used_blocks, cache_used_blocks, "Used cache blocks.", 0)
+FIELD(LVSSTATUS, lv, NUM, "CacheDirtyBlocks", lvid, 16, cache_dirty_blocks, cache_dirty_blocks, "Dirty cache blocks.", 0)
+FIELD(LVSSTATUS, lv, NUM, "CacheReadHits", lvid, 16, cache_read_hits, cache_read_hits, "Cache read hits.", 0)
+FIELD(LVSSTATUS, lv, NUM, "CacheReadMisses", lvid, 16, cache_read_misses, cache_read_misses, "Cache read misses.", 0)
+FIELD(LVSSTATUS, lv, NUM, "CacheWriteHits", lvid, 16, cache_write_hits, cache_write_hits, "Cache write hits.", 0)
+FIELD(LVSSTATUS, lv, NUM, "CacheWriteMisses", lvid, 16, cache_write_misses, cache_write_misses, "Cache write misses.", 0)
+
FIELD(LABEL, label, STR, "Fmt", type, 3, pvfmt, pv_fmt, "Type of metadata.", 0)
FIELD(LABEL, label, STR, "PV UUID", type, 38, pvuuid, pv_uuid, "Unique identifier.", 0)
FIELD(LABEL, label, SIZ, "DevSize", dev, 7, devsize, dev_size, "Size of underlying device in current units.", 0)
diff --git a/lib/report/properties.c b/lib/report/properties.c
index 3389087..2308c36 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -248,6 +248,21 @@ GET_PV_NUM_PROPERTY_FN(pv_ba_size, SECTOR_SIZE * pv->ba_size)
#define _lv_skip_activation_set prop_not_implemented_set
#define _lv_skip_activation_get prop_not_implemented_get
+#define _cache_total_blocks_set prop_not_implemented_set
+#define _cache_total_blocks_get prop_not_implemented_get
+#define _cache_used_blocks_set prop_not_implemented_set
+#define _cache_used_blocks_get prop_not_implemented_get
+#define _cache_dirty_blocks_set prop_not_implemented_set
+#define _cache_dirty_blocks_get prop_not_implemented_get
+#define _cache_read_hits_set prop_not_implemented_set
+#define _cache_read_hits_get prop_not_implemented_get
+#define _cache_read_misses_set prop_not_implemented_set
+#define _cache_read_misses_get prop_not_implemented_get
+#define _cache_write_hits_set prop_not_implemented_set
+#define _cache_write_hits_get prop_not_implemented_get
+#define _cache_write_misses_set prop_not_implemented_set
+#define _cache_write_misses_get prop_not_implemented_get
+
/* LV */
GET_LV_STR_PROPERTY_FN(lv_uuid, lv_uuid_dup(lv))
#define _lv_uuid_set prop_not_implemented_set
diff --git a/lib/report/report.c b/lib/report/report.c
index 74ba4bc..42355e2 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1686,6 +1686,31 @@ static int _lvskipactivation_disp(struct dm_report *rh, struct dm_pool *mem,
return _binary_disp(rh, mem, field, skip_activation, "skip activation", private);
}
+/*
+ * Macro to generate '_cache_<cache_status_field_name>_disp' reporting function.
+ * The 'cache_status_field_name' is field name from struct dm_cache_status.
+ */
+#define GENERATE_CACHE_STATUS_DISP_FN(cache_status_field_name) \
+static int _cache_ ## cache_status_field_name ## _disp (struct dm_report *rh, \
+ struct dm_pool *mem, \
+ struct dm_report_field *field, \
+ const void *data, \
+ void *private) \
+{ \
+ const struct lv_with_info_and_seg_status *lvdm = (const struct lv_with_info_and_seg_status *) data; \
+ if (lvdm->seg_status->type != SEG_STATUS_CACHE) \
+ return _field_set_value(field, "", &RESERVED(number_undef_64)); \
+ return dm_report_field_uint64(rh, field, (void *) ((char *) lvdm->seg_status->status + offsetof(struct dm_status_cache, cache_status_field_name))); \
+}
+
+GENERATE_CACHE_STATUS_DISP_FN(total_blocks)
+GENERATE_CACHE_STATUS_DISP_FN(used_blocks)
+GENERATE_CACHE_STATUS_DISP_FN(dirty_blocks)
+GENERATE_CACHE_STATUS_DISP_FN(read_hits)
+GENERATE_CACHE_STATUS_DISP_FN(read_misses)
+GENERATE_CACHE_STATUS_DISP_FN(write_hits)
+GENERATE_CACHE_STATUS_DISP_FN(write_misses)
+
/* Report object types */
/* necessary for displaying something for PVs not belonging to VG */
9 years, 7 months
master - dev_manager: enhance dev_manager_info to acquire LV segment status if requested, add lv_info_with_seg_status fn
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a2c1024f6ac7e2...
Commit: a2c1024f6ac7e22ac5c010a267d0c1df331ee416
Parent: 7f90ad84c1f9bbc51a833b7ebb6459842405de52
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Nov 4 15:00:32 2014 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Nov 11 13:04:02 2014 +0100
dev_manager: enhance dev_manager_info to acquire LV segment status if requested, add lv_info_with_seg_status fn
---
lib/activate/activate.c | 42 ++++++++++---
lib/activate/activate.h | 5 ++
lib/activate/dev_manager.c | 140 ++++++++++++++++++++++++++++++++++++-------
lib/activate/dev_manager.h | 4 +-
tools/reporter.c | 2 +
5 files changed, 160 insertions(+), 33 deletions(-)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 93f9b9c..2843e61 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -617,17 +617,12 @@ int target_present(struct cmd_context *cmd, const char *target_name,
return target_version(target_name, &maj, &min, &patchlevel);
}
-/*
- * Returns 1 if info structure populated, else 0 on failure.
- * When lvinfo* is NULL, it returns 1 if the device is locally active, 0 otherwise.
- */
-int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_layer,
- struct lvinfo *info, int with_open_count, int with_read_ahead)
+static int _lv_info(struct cmd_context *cmd, const struct logical_volume *lv,
+ int use_layer, struct lvinfo *info, struct lv_seg_status *seg_status,
+ int with_open_count, int with_read_ahead)
{
struct dm_info dminfo;
- if (!activation())
- return 0;
/*
* If open_count info is requested and we have to be sure our own udev
* transactions are finished
@@ -648,7 +643,8 @@ int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_la
if (!dev_manager_info(cmd->mem, lv,
(use_layer) ? lv_layer(lv) : NULL,
with_open_count, with_read_ahead,
- &dminfo, (info) ? &info->read_ahead : NULL))
+ &dminfo, (info) ? &info->read_ahead : NULL,
+ seg_status))
return_0;
if (!info)
@@ -666,6 +662,19 @@ int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_la
return 1;
}
+/*
+ * Returns 1 if info structure populated, else 0 on failure.
+ * When lvinfo* is NULL, it returns 1 if the device is locally active, 0 otherwise.
+ */
+int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_layer,
+ struct lvinfo *info, int with_open_count, int with_read_ahead)
+{
+ if (!activation())
+ return 0;
+
+ return _lv_info(cmd, lv, use_layer, info, NULL, with_open_count, with_read_ahead);
+}
+
int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,
struct lvinfo *info, int with_open_count, int with_read_ahead)
{
@@ -681,6 +690,21 @@ int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,
return r;
}
+int lv_info_with_seg_status(struct cmd_context *cmd, const struct logical_volume *lv,
+ const struct lv_segment *lv_seg, int use_layer,
+ struct lv_with_info_and_seg_status *lvdm,
+ int with_open_count, int with_read_ahead)
+{
+ if (!activation())
+ return 0;
+
+ if (!_lv_info(cmd, lv, use_layer, lvdm->info, lvdm->seg_status,
+ with_open_count, with_read_ahead))
+ return 0;
+
+ return 1;
+}
+
#define OPEN_COUNT_CHECK_RETRIES 25
#define OPEN_COUNT_CHECK_USLEEP_DELAY 200000
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index ab5e69d..86c53f5 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -118,6 +118,11 @@ int lv_info(struct cmd_context *cmd, const struct logical_volume *lv, int use_la
int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s, int use_layer,
struct lvinfo *info, int with_open_count, int with_read_ahead);
+int lv_info_with_seg_status(struct cmd_context *cmd, const struct logical_volume *lv,
+ const struct lv_segment *lv_seg, int use_layer,
+ struct lv_with_info_and_seg_status *lvdm,
+ int with_open_count, int with_read_ahead);
+
int lv_check_not_in_use(const struct logical_volume *lv);
/*
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 2651ec8..5a07fad 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -106,32 +106,122 @@ static struct dm_task *_setup_task(const char *name, const char *uuid,
return NULL;
}
-static int _info_run(const char *name, const char *dlid, struct dm_info *info,
- uint32_t *read_ahead, int mknodes, int with_open_count,
- int with_read_ahead, uint32_t major, uint32_t minor)
+static int _get_segment_status_from_target_params(const char *target_name,
+ const char *params,
+ struct lv_seg_status *seg_status)
+{
+ struct segment_type *segtype;
+
+ /* FIXME: linear is also represented as striped with stripe count 1.
+ We're not reporting linear or striped status anyway, so
+ just skip the error here till this is properly resolved.*/
+ if (!strcmp(target_name, "linear") || !strcmp(target_name, "striped"))
+ return 1;
+
+ segtype = get_segtype_from_string(seg_status->seg->lv->vg->cmd, target_name);
+
+ if (segtype != seg_status->seg->segtype) {
+ log_error(INTERNAL_ERROR "_get_segment_status_from_target_params: "
+ "segment type %s found does not match expected segment type %s",
+ segtype->name, seg_status->seg->segtype->name);
+ return 0;
+ }
+
+ if (!strcmp(segtype->name, "cache")) {
+ if (!dm_get_status_cache(seg_status->mem, params,
+ (struct dm_status_cache **) &seg_status->status))
+ return_0;
+ seg_status->type = SEG_STATUS_CACHE;
+ } else if (!strcmp(segtype->name, "raid")) {
+ if (!dm_get_status_raid(seg_status->mem, params,
+ (struct dm_status_raid **) &seg_status->status))
+ return_0;
+ seg_status->type = SEG_STATUS_RAID;
+ } else if (!strcmp(segtype->name, "thin")) {
+ if (!dm_get_status_thin(seg_status->mem, params,
+ (struct dm_status_thin **) &seg_status->status))
+ return_0;
+ seg_status->type = SEG_STATUS_THIN;
+ } else if (!strcmp(segtype->name, "thin-pool")) {
+ if (!dm_get_status_thin_pool(seg_status->mem, params,
+ (struct dm_status_thin_pool **) &seg_status->status))
+ return_0;
+ seg_status->type = SEG_STATUS_THIN_POOL;
+ } else if (!strcmp(segtype->name, "snapshot")) {
+ if (!dm_get_status_snapshot(seg_status->mem, params,
+ (struct dm_status_snapshot **) &seg_status->status))
+ return_0;
+ seg_status->type = SEG_STATUS_SNAPSHOT;
+ }
+
+ return 1;
+}
+
+typedef enum {
+ INFO, /* DM_DEVICE_INFO ioctl */
+ STATUS, /* DM_DEVICE_STATUS ioctl */
+ MKNODES
+} info_type_t;
+
+static int _info_run(info_type_t type, const char *name, const char *dlid,
+ struct dm_info *dminfo, uint32_t *read_ahead,
+ struct lv_seg_status *seg_status,
+ int with_open_count, int with_read_ahead,
+ uint32_t major, uint32_t minor)
{
int r = 0;
struct dm_task *dmt;
int dmtask;
+ void *target = NULL;
+ uint64_t target_start, target_length;
+ char *target_name, *target_params, *params_to_process = NULL;
+ uint32_t extent_size;
+
+ switch (type) {
+ case INFO:
+ dmtask = DM_DEVICE_INFO;
+ break;
+ case STATUS:
+ dmtask = DM_DEVICE_STATUS;
+ break;
+ case MKNODES:
+ dmtask = DM_DEVICE_MKNODES;
+ break;
+ }
- dmtask = mknodes ? DM_DEVICE_MKNODES : DM_DEVICE_INFO;
-
- if (!(dmt = _setup_task(mknodes ? name : NULL, dlid, 0, dmtask, major, minor,
- with_open_count)))
+ if (!(dmt = _setup_task(type != MKNODES ? name : NULL, dlid, 0, dmtask,
+ major, minor, with_open_count)))
return_0;
if (!dm_task_run(dmt))
goto_out;
- if (!dm_task_get_info(dmt, info))
+ if (!dm_task_get_info(dmt, dminfo))
goto_out;
- if (with_read_ahead && info->exists) {
+ if (with_read_ahead && dminfo->exists) {
if (!dm_task_get_read_ahead(dmt, read_ahead))
goto_out;
} else if (read_ahead)
*read_ahead = DM_READ_AHEAD_NONE;
+ if (type == STATUS) {
+ extent_size = seg_status->seg->lv->vg->extent_size;
+ do {
+ target = dm_get_next_target(dmt, target, &target_start,
+ &target_length, &target_name, &target_params);
+ if ((seg_status->seg->le * extent_size == target_start) &&
+ (seg_status->seg->len * extent_size == target_length)) {
+ params_to_process = target_params;
+ break;
+ }
+ } while (target);
+
+ if (params_to_process &&
+ !_get_segment_status_from_target_params(target_name, params_to_process, seg_status))
+ goto_out;
+ }
+
r = 1;
out:
@@ -476,7 +566,8 @@ int device_is_usable(struct device *dev, struct dev_usable_check_params check)
}
static int _info(const char *dlid, int with_open_count, int with_read_ahead,
- struct dm_info *info, uint32_t *read_ahead)
+ struct dm_info *dminfo, uint32_t *read_ahead,
+ struct lv_seg_status *seg_status)
{
int r = 0;
char old_style_dlid[sizeof(UUID_PREFIX) + 2 * ID_LEN];
@@ -484,8 +575,8 @@ static int _info(const char *dlid, int with_open_count, int with_read_ahead,
unsigned i = 0;
/* Check for dlid */
- if ((r = _info_run(NULL, dlid, info, read_ahead, 0, with_open_count,
- with_read_ahead, 0, 0)) && info->exists)
+ if ((r = _info_run(seg_status ? STATUS : INFO, NULL, dlid, dminfo, read_ahead,
+ seg_status, with_open_count, with_read_ahead, 0, 0)) && dminfo->exists)
return 1;
/* Check for original version of dlid before the suffixes got added in 2.02.106 */
@@ -496,16 +587,17 @@ static int _info(const char *dlid, int with_open_count, int with_read_ahead,
(void) strncpy(old_style_dlid, dlid, sizeof(old_style_dlid));
old_style_dlid[sizeof(old_style_dlid) - 1] = '\0';
- if ((r = _info_run(NULL, old_style_dlid, info, read_ahead, 0, with_open_count,
- with_read_ahead, 0, 0)) && info->exists)
+ if ((r = _info_run(seg_status ? STATUS : INFO, NULL, old_style_dlid, dminfo,
+ read_ahead, seg_status, with_open_count,
+ with_read_ahead, 0, 0)) && dminfo->exists)
return 1;
}
}
/* Check for dlid before UUID_PREFIX was added */
- if ((r = _info_run(NULL, dlid + sizeof(UUID_PREFIX) - 1, info,
- read_ahead, 0, with_open_count,
- with_read_ahead, 0, 0)) && info->exists)
+ if ((r = _info_run(seg_status ? STATUS : INFO, NULL, dlid + sizeof(UUID_PREFIX) - 1,
+ dminfo, read_ahead, seg_status, with_open_count,
+ with_read_ahead, 0, 0)) && dminfo->exists)
return 1;
return r;
@@ -513,13 +605,14 @@ static int _info(const char *dlid, int with_open_count, int with_read_ahead,
static int _info_by_dev(uint32_t major, uint32_t minor, struct dm_info *info)
{
- return _info_run(NULL, NULL, info, NULL, 0, 0, 0, major, minor);
+ return _info_run(INFO, NULL, NULL, info, NULL, 0, 0, 0, major, minor);
}
int dev_manager_info(struct dm_pool *mem, const struct logical_volume *lv,
const char *layer,
int with_open_count, int with_read_ahead,
- struct dm_info *info, uint32_t *read_ahead)
+ struct dm_info *dminfo, uint32_t *read_ahead,
+ struct lv_seg_status *seg_status)
{
char *dlid, *name;
int r;
@@ -536,7 +629,8 @@ int dev_manager_info(struct dm_pool *mem, const struct logical_volume *lv,
}
log_debug_activation("Getting device info for %s [%s]", name, dlid);
- r = _info(dlid, with_open_count, with_read_ahead, info, read_ahead);
+ r = _info(dlid, with_open_count, with_read_ahead,
+ dminfo, read_ahead, seg_status);
out:
dm_pool_free(mem, name);
@@ -1447,7 +1541,7 @@ int dev_manager_mknodes(const struct logical_volume *lv)
if (!(name = dm_build_dm_name(lv->vg->cmd->mem, lv->vg->name, lv->name, NULL)))
return_0;
- if ((r = _info_run(name, NULL, &dminfo, NULL, 1, 0, 0, 0, 0))) {
+ if ((r = _info_run(MKNODES, name, NULL, &dminfo, NULL, NULL, 0, 0, 0, 0))) {
if (dminfo.exists) {
if (lv_is_visible(lv))
r = _dev_manager_lv_mknodes(lv);
@@ -1589,7 +1683,7 @@ static int _add_dev_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
return_0;
log_debug_activation("Getting device info for %s [%s]", name, dlid);
- if (!_info(dlid, 1, 0, &info, NULL)) {
+ if (!_info(dlid, 1, 0, &info, NULL, NULL)) {
log_error("Failed to get info for %s [%s].", name, dlid);
return 0;
}
@@ -2078,7 +2172,7 @@ static char *_add_error_device(struct dev_manager *dm, struct dm_tree *dtree,
return_NULL;
log_debug_activation("Getting device info for %s [%s]", name, dlid);
- if (!_info(dlid, 1, 0, &info, NULL)) {
+ if (!_info(dlid, 1, 0, &info, NULL, NULL)) {
log_error("Failed to get info for %s [%s].", name, dlid);
return 0;
}
diff --git a/lib/activate/dev_manager.h b/lib/activate/dev_manager.h
index f4f989c..bfc6c02 100644
--- a/lib/activate/dev_manager.h
+++ b/lib/activate/dev_manager.h
@@ -25,6 +25,7 @@ struct cmd_context;
struct dev_manager;
struct dm_info;
struct device;
+struct lv_seg_status;
int read_only_lv(const struct logical_volume *lv, const struct lv_activate_opts *laopts);
@@ -47,7 +48,8 @@ void dev_manager_exit(void);
int dev_manager_info(struct dm_pool *mem, const struct logical_volume *lv,
const char *layer,
int with_open_count, int with_read_ahead,
- struct dm_info *info, uint32_t *read_ahead);
+ struct dm_info *dminfo, uint32_t *read_ahead,
+ struct lv_seg_status *seg_status);
int dev_manager_snapshot_percent(struct dev_manager *dm,
const struct logical_volume *lv,
dm_percent_t *percent);
diff --git a/tools/reporter.c b/tools/reporter.c
index d8c19eb..8fe5698 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -59,6 +59,8 @@ static void _get_lv_info_for_report(struct cmd_context *cmd,
static void _get_lv_info_with_segment_status_for_report(struct cmd_context *cmd,
struct lv_with_info_and_seg_status *lvdm)
{
+ if (!lv_info_with_seg_status(cmd, lvdm->seg_status->seg->lv, lvdm->seg_status->seg, 0, lvdm, 1, 1))
+ lvdm->info->exists = 0;
}
static int _lvs_with_info_single(struct cmd_context *cmd, struct logical_volume *lv,
9 years, 7 months
master - report: add new LVSSTATUS and SEGSSTATUS report type
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7f90ad84c1f9bb...
Commit: 7f90ad84c1f9bbc51a833b7ebb6459842405de52
Parent: d7e5f038887be820874522674a51071705439c8e
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Oct 21 12:01:57 2014 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Tue Nov 11 08:53:28 2014 +0100
report: add new LVSSTATUS and SEGSSTATUS report type
Similar to LVSINFO type which gathers LV + its DM_DEVICE_INFO, the
new LVSSTATUS/SEGSSTATUS report type will gather LV/segment + its
DM_DEVICE_STATUS.
Since we can report status only for certain segment, in case
of LVSSTATUS we need to choose which segment related to the LV
should be processed that represents the "LV status". In case of
SEGSSTATUS type it's clear - the status is reported for the
segment just processed.
---
lib/report/report.c | 2 +
lib/report/report.h | 14 +++---
tools/reporter.c | 122 ++++++++++++++++++++++++++++++++++++++++++++++-----
3 files changed, 121 insertions(+), 17 deletions(-)
diff --git a/lib/report/report.c b/lib/report/report.c
index 511d6cb..74ba4bc 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1749,9 +1749,11 @@ static const struct dm_report_object_type _report_types[] = {
{ VGS, "Volume Group", "vg_", _obj_get_vg },
{ LVS, "Logical Volume", "lv_", _obj_get_lv },
{ LVSINFO, "Logical Volume Device Info", "lv_", _obj_get_lv_with_info_and_seg_status },
+ { LVSSTATUS, "Logical Volume Device Status", "lv_", _obj_get_lv_with_info_and_seg_status },
{ PVS, "Physical Volume", "pv_", _obj_get_pv },
{ LABEL, "Physical Volume Label", "pv_", _obj_get_label },
{ SEGS, "Logical Volume Segment", "seg_", _obj_get_seg },
+ { SEGSSTATUS, "Logical Volume Device Segment Status", "seg_", _obj_get_lv_with_info_and_seg_status },
{ PVSEGS, "Physical Volume Segment", "pvseg_", _obj_get_pvseg },
{ 0, "", "", NULL },
};
diff --git a/lib/report/report.h b/lib/report/report.h
index e4b302e..20fb6bd 100644
--- a/lib/report/report.h
+++ b/lib/report/report.h
@@ -23,12 +23,14 @@
typedef enum {
LVS = 1,
LVSINFO = 2,
- PVS = 4,
- VGS = 8,
- SEGS = 16,
- PVSEGS = 32,
- LABEL = 64,
- DEVTYPES = 128
+ LVSSTATUS = 4,
+ PVS = 8,
+ VGS = 16,
+ SEGS = 32,
+ SEGSSTATUS = 64,
+ PVSEGS = 128,
+ LABEL = 256,
+ DEVTYPES = 512
} report_type_t;
struct field;
diff --git a/tools/reporter.c b/tools/reporter.c
index 959e884..d8c19eb 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -56,6 +56,11 @@ static void _get_lv_info_for_report(struct cmd_context *cmd,
lvinfo->exists = 0;
}
+static void _get_lv_info_with_segment_status_for_report(struct cmd_context *cmd,
+ struct lv_with_info_and_seg_status *lvdm)
+{
+}
+
static int _lvs_with_info_single(struct cmd_context *cmd, struct logical_volume *lv,
void *handle)
{
@@ -68,6 +73,58 @@ static int _lvs_with_info_single(struct cmd_context *cmd, struct logical_volume
return ECMD_PROCESSED;
}
+static void _choose_lv_segment_for_status_report(struct lv_with_info_and_seg_status *lvdm)
+{
+ /*
+ * By default, take the first LV segment to report status for.
+ * If there's any other specific segment that needs to be
+ * reported instead for the LV, choose it here and assign it
+ * to lvdm->seg_status->seg. This is the segment whose
+ * status line will be used for report exactly.
+ */
+ lvdm->seg_status->seg = first_seg(lvdm->lv);
+}
+
+static int _lvs_with_status_single(struct cmd_context *cmd, struct logical_volume *lv,
+ void *handle)
+{
+ struct lvinfo lvinfo;
+ struct lv_seg_status lv_seg_status = { .mem = lv->vg->vgmem,
+ .type = SEG_STATUS_NONE,
+ .status = NULL };
+ struct lv_with_info_and_seg_status lvdm = { .lv = lv,
+ .seg_status = &lv_seg_status };
+ int r = ECMD_FAILED;
+
+ _choose_lv_segment_for_status_report(&lvdm);
+
+ if (lvdm.seg_status->seg->lv != lv) {
+ /*
+ * If the info is requested on one LV and segment
+ * status on another LV, we need to call these separately.
+ */
+ _get_lv_info_for_report(cmd, lv, &lvinfo);
+ lvdm.info = NULL;
+ _get_lv_info_with_segment_status_for_report(cmd, &lvdm);
+ } else {
+ /*
+ * If the info is requested on the same LV as status,
+ * we can get info and status in one go!
+ */
+ lvdm.info = &lvinfo;
+ _get_lv_info_with_segment_status_for_report(cmd, &lvdm);
+ }
+
+ if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL, &lvinfo, lvdm.seg_status, NULL))
+ goto out;
+
+ r = ECMD_PROCESSED;
+out:
+ if (lvdm.seg_status->status)
+ dm_pool_free(lvdm.seg_status->mem, lvdm.seg_status->status);
+ return r;
+}
+
static int _segs_single(struct cmd_context *cmd __attribute__((unused)),
struct lv_segment *seg, void *handle)
{
@@ -89,6 +146,30 @@ static int _segs_with_lv_info_single(struct cmd_context *cmd __attribute__((unus
return ECMD_PROCESSED;
}
+static int _segs_with_lv_status_single(struct cmd_context *cmd __attribute__((unused)),
+ struct lv_segment *seg, void *handle)
+{
+ struct lvinfo lvinfo;
+ struct lv_seg_status lv_seg_status = { .seg = seg,
+ .mem = seg->lv->vg->vgmem,
+ .type = SEG_STATUS_NONE,
+ .status = NULL };
+ struct lv_with_info_and_seg_status lvdm = { .lv = seg->lv,
+ .info = &lvinfo,
+ .seg_status = &lv_seg_status };
+ int r = ECMD_FAILED;
+
+ _get_lv_info_with_segment_status_for_report(cmd, &lvdm);
+ if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL, lvdm.info, lvdm.seg_status, NULL))
+ goto_out;
+
+ r = ECMD_PROCESSED;
+out:
+ if (lvdm.seg_status->status)
+ dm_pool_free(lvdm.seg_status->mem, lvdm.seg_status->status);
+ return r;
+}
+
static int _do_pvsegs_sub_single(struct cmd_context *cmd,
struct volume_group *vg,
struct pv_segment *pvseg,
@@ -182,6 +263,16 @@ static int _lvsegs_with_lv_info_single(struct cmd_context *cmd,
return process_each_segment_in_lv(cmd, lv, handle, _segs_with_lv_info_single);
}
+static int _lvsegs_with_lv_status_single(struct cmd_context *cmd,
+ struct logical_volume *lv,
+ void *handle)
+{
+ if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv))
+ return ECMD_PROCESSED;
+
+ return process_each_segment_in_lv(cmd, lv, handle, _segs_with_lv_status_single);
+}
+
static int _pvsegs_single(struct cmd_context *cmd, struct volume_group *vg,
struct physical_volume *pv, void *handle)
{
@@ -254,7 +345,7 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
int r = ECMD_PROCESSED;
int aligned, buffered, headings, field_prefixes, quoted;
int columns_as_rows;
- unsigned args_are_pvs, lv_info_needed;
+ unsigned args_are_pvs, lv_info_needed, lv_segment_status_needed;
int lock_global = 0;
aligned = find_config_tree_bool(cmd, report_aligned_CFG, NULL);
@@ -373,15 +464,18 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
columns_as_rows, selection)))
return_ECMD_FAILED;
- /* Do we need lv_info to be called for LV device status? */
+ /* Do we need to acquire LV device info in addition? */
lv_info_needed = (report_type & LVSINFO) ? 1 : 0;
+ /* Do we need to acquire LV device status in addition? */
+ lv_segment_status_needed = (report_type & (SEGSSTATUS | LVSSTATUS)) ? 1 : 0;
+
/* Ensure options selected are compatible */
- if (report_type & SEGS)
+ if (report_type & (SEGS | SEGSSTATUS))
report_type |= LVS;
if (report_type & PVSEGS)
report_type |= PVS;
- if ((report_type & (LVS | LVSINFO)) && (report_type & (PVS | LABEL)) && !args_are_pvs) {
+ if ((report_type & (LVS | LVSINFO | LVSSTATUS)) && (report_type & (PVS | LABEL)) && !args_are_pvs) {
log_error("Can't report LV and PV fields at the same time");
dm_report_free(report_handle);
return ECMD_FAILED;
@@ -389,15 +483,15 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
/* Change report type if fields specified makes this necessary */
if ((report_type & PVSEGS) ||
- ((report_type & (PVS | LABEL)) && (report_type & (LVS | LVSINFO))))
+ ((report_type & (PVS | LABEL)) && (report_type & (LVS | LVSINFO | LVSSTATUS))))
report_type = PVSEGS;
else if ((report_type & LABEL) && (report_type & VGS))
report_type = PVS;
else if (report_type & PVS)
report_type = PVS;
- else if (report_type & SEGS)
+ else if (report_type & (SEGS | SEGSSTATUS))
report_type = SEGS;
- else if (report_type & (LVS | LVSINFO))
+ else if (report_type & (LVS | LVSINFO | LVSSTATUS))
report_type = LVS;
/*
@@ -419,10 +513,13 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
break;
case LVSINFO:
/* fall through */
+ case LVSSTATUS:
+ /* fall through */
case LVS:
r = process_each_lv(cmd, argc, argv, 0, report_handle,
- lv_info_needed ? &_lvs_with_info_single
- : &_lvs_single);
+ lv_segment_status_needed ? &_lvs_with_status_single
+ : lv_info_needed ? &_lvs_with_info_single
+ : &_lvs_single);
break;
case VGS:
r = process_each_vg(cmd, argc, argv, 0,
@@ -440,10 +537,13 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
r = process_each_vg(cmd, argc, argv, 0,
report_handle, &_pvs_in_vg);
break;
+ case SEGSSTATUS:
+ /* fall through */
case SEGS:
r = process_each_lv(cmd, argc, argv, 0, report_handle,
- lv_info_needed ? &_lvsegs_with_lv_info_single
- : &_lvsegs_single);
+ lv_segment_status_needed ? &_lvsegs_with_lv_status_single
+ :lv_info_needed ? &_lvsegs_with_lv_info_single
+ : &_lvsegs_single);
break;
case PVSEGS:
if (args_are_pvs)
9 years, 7 months