master - tools: remove metadata.h
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9d5bdc91ca5173...
Commit: 9d5bdc91ca51737be82c463e05e5818a833a1fea
Parent: 1280a3c7ed52e7af303c65a367f3d4fda941dfaa
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Jul 9 02:51:24 2013 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Jul 9 02:51:24 2013 +0100
tools: remove metadata.h
---
lib/metadata/metadata-exported.h | 11 +++++++++++
lib/metadata/metadata.h | 11 -----------
tools/lvconvert.c | 1 -
tools/vgck.c | 1 +
4 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 478337f..ef192d3 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -663,6 +663,17 @@ struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
uint64_t size, alloc_policy_t alloc,
struct dm_list *pvh);
+int attach_thin_external_origin(struct lv_segment *seg,
+ struct logical_volume *external_lv);
+int detach_thin_external_origin(struct lv_segment *seg);
+int attach_pool_metadata_lv(struct lv_segment *pool_seg,
+ struct logical_volume *pool_metadata_lv);
+int detach_pool_metadata_lv(struct lv_segment *pool_seg,
+ struct logical_volume **pool_metadata_lv);
+int attach_pool_data_lv(struct lv_segment *pool_seg,
+ struct logical_volume *pool_data_lv);
+int is_mirror_image_removable(struct logical_volume *mimage_lv, void *baton);
+
/*
* Activation options
*/
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 80ad22b..d313198 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -462,12 +462,6 @@ int fixup_imported_mirrors(struct volume_group *vg);
/*
* From thin_manip.c
*/
-int attach_pool_metadata_lv(struct lv_segment *pool_seg,
- struct logical_volume *pool_metadata_lv);
-int detach_pool_metadata_lv(struct lv_segment *pool_seg,
- struct logical_volume **pool_metadata_lv);
-int attach_pool_data_lv(struct lv_segment *pool_seg,
- struct logical_volume *pool_data_lv);
int attach_pool_lv(struct lv_segment *seg, struct logical_volume *pool_lv,
struct logical_volume *origin_lv);
int detach_pool_lv(struct lv_segment *seg);
@@ -479,9 +473,6 @@ int pool_has_message(const struct lv_segment *seg,
int pool_below_threshold(const struct lv_segment *pool_seg);
int extend_pool(struct logical_volume *lv, const struct segment_type *segtype,
struct alloc_handle *ah, uint32_t stripes, uint32_t stripe_size);
-int attach_thin_external_origin(struct lv_segment *seg,
- struct logical_volume *external_lv);
-int detach_thin_external_origin(struct lv_segment *seg);
/*
* Begin skeleton for external LVM library
@@ -493,8 +484,6 @@ struct id pv_vgid(const struct physical_volume *pv);
int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
struct physical_volume *pv, struct pvcreate_params *pp);
-int is_mirror_image_removable(struct logical_volume *mimage_lv, void *baton);
-
uint64_t find_min_mda_size(struct dm_list *mdas);
char *tags_format_and_copy(struct dm_pool *mem, const struct dm_list *tags);
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 3ea1987..5e7484e 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -15,7 +15,6 @@
#include "tools.h"
#include "polldaemon.h"
#include "lv_alloc.h"
-#include "metadata.h"
struct lvconvert_params {
int force;
diff --git a/tools/vgck.c b/tools/vgck.c
index eb0ecaf..e9c26a6 100644
--- a/tools/vgck.c
+++ b/tools/vgck.c
@@ -14,6 +14,7 @@
*/
#include "tools.h"
+#include "metadata-exported.h"
static int vgck_single(struct cmd_context *cmd __attribute__((unused)),
const char *vg_name,
10 years, 10 months
master - tools: remove metadata.h from pvresize/vgck
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1280a3c7ed52e7...
Commit: 1280a3c7ed52e7af303c65a367f3d4fda941dfaa
Parent: 8adddbf101b362884d62ba066cc72b5ded016f37
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Jul 9 02:41:56 2013 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Jul 9 02:41:56 2013 +0100
tools: remove metadata.h from pvresize/vgck
---
tools/pvresize.c | 1 -
tools/vgck.c | 1 -
2 files changed, 0 insertions(+), 2 deletions(-)
diff --git a/tools/pvresize.c b/tools/pvresize.c
index a5f81f8..8004700 100644
--- a/tools/pvresize.c
+++ b/tools/pvresize.c
@@ -15,7 +15,6 @@
*/
#include "tools.h"
-#include "metadata.h"
#include "metadata-exported.h"
struct pvresize_params {
diff --git a/tools/vgck.c b/tools/vgck.c
index 2a009db..eb0ecaf 100644
--- a/tools/vgck.c
+++ b/tools/vgck.c
@@ -14,7 +14,6 @@
*/
#include "tools.h"
-#include "metadata.h"
static int vgck_single(struct cmd_context *cmd __attribute__((unused)),
const char *vg_name,
10 years, 10 months
master - pvcreate: remove metadata.h header
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8adddbf101b362...
Commit: 8adddbf101b362884d62ba066cc72b5ded016f37
Parent: dd302daf646f680531bf76ab13a9dafd06f63220
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Jul 9 02:37:56 2013 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Jul 9 02:37:56 2013 +0100
pvcreate: remove metadata.h header
Files in tools/ should only use metadata-exported.h not metadata.h.
Rename pvcreate_locked to pvcreate_single.
---
lib/metadata/metadata-exported.h | 6 ++----
lib/metadata/metadata.c | 10 ++++------
lib/metadata/metadata.h | 4 ++--
lib/metadata/pv_manip.c | 6 +++---
liblvm/lvm_pv.c | 2 +-
tools/pvcreate.c | 3 +--
6 files changed, 13 insertions(+), 18 deletions(-)
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 412d29c..478337f 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -481,10 +481,8 @@ struct lvresize_params {
const char *ac_type;
};
-struct physical_volume *pvcreate_single(struct cmd_context *cmd,
- const char *pv_name,
- struct pvcreate_params *pp,
- int write_now);
+int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
+ struct pvcreate_params *pp);
void pvcreate_params_set_defaults(struct pvcreate_params *pp);
/*
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 96a636c..ca6da86 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -635,7 +635,7 @@ static int vg_extend_single_pv(struct volume_group *vg, char *pv_name,
"physical volume", pv_name);
return 0;
} else if (!pv && pp) {
- if (!(pv = pvcreate_single(vg->cmd, pv_name, pp, 0)))
+ if (!(pv = pvcreate_vol(vg->cmd, pv_name, pp, 0)))
return_0;
}
if (!add_pv_to_vg(vg, pv_name, pv, pp)) {
@@ -1487,7 +1487,7 @@ static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_create *pvc)
}
/*
- * pvcreate_single() - initialize a device with PV label and metadata area
+ * pvcreate_vol() - initialize a device with PV label and metadata area
*
* Parameters:
* - pv_name: device path to initialize
@@ -1497,10 +1497,8 @@ static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_create *pvc)
* NULL: error
* struct physical_volume * (non-NULL): handle to physical volume created
*/
-struct physical_volume * pvcreate_single(struct cmd_context *cmd,
- const char *pv_name,
- struct pvcreate_params *pp,
- int write_now)
+struct physical_volume *pvcreate_vol(struct cmd_context *cmd, const char *pv_name,
+ struct pvcreate_params *pp, int write_now)
{
struct physical_volume *pv = NULL;
struct device *dev;
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 364722f..80ad22b 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -345,8 +345,8 @@ int pvremove_single(struct cmd_context *cmd, const char *pv_name,
void *handle __attribute__((unused)), unsigned force_count,
unsigned prompt);
-int pvcreate_locked(struct cmd_context *cmd, const char *pv_name,
- struct pvcreate_params *pp);
+struct physical_volume *pvcreate_vol(struct cmd_context *cmd, const char *pv_name,
+ struct pvcreate_params *pp, int write_now);
/* Manipulate PV structures */
int pv_add(struct volume_group *vg, struct physical_volume *pv);
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index 3a3ac09..2b16206 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -786,8 +786,8 @@ out:
return r;
}
-int pvcreate_locked(struct cmd_context *cmd, const char *pv_name,
- struct pvcreate_params *pp)
+int pvcreate_single(struct cmd_context *cmd, const char *pv_name,
+ struct pvcreate_params *pp)
{
int r = 0;
@@ -796,7 +796,7 @@ int pvcreate_locked(struct cmd_context *cmd, const char *pv_name,
return 0;
}
- if (!(pvcreate_single(cmd, pv_name, pp, 1)))
+ if (!(pvcreate_vol(cmd, pv_name, pp, 1)))
goto_out;
r = 1;
diff --git a/liblvm/lvm_pv.c b/liblvm/lvm_pv.c
index e679b3a..a2e7ef0 100644
--- a/liblvm/lvm_pv.c
+++ b/liblvm/lvm_pv.c
@@ -235,7 +235,7 @@ int lvm_pv_create(lvm_t libh, const char *pv_name, uint64_t size)
pp.size = size_sectors;
- if (!pvcreate_locked(cmd, pv_name, &pp))
+ if (!pvcreate_single(cmd, pv_name, &pp))
return -1;
return 0;
diff --git a/tools/pvcreate.c b/tools/pvcreate.c
index 38642f6..cbd1a59 100644
--- a/tools/pvcreate.c
+++ b/tools/pvcreate.c
@@ -15,7 +15,6 @@
#include "tools.h"
#include "metadata-exported.h"
-#include "metadata.h"
/*
* Intial sanity checking of recovery-related command-line arguments.
@@ -113,7 +112,7 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv)
dm_unescape_colons_and_at_signs(argv[i], NULL, NULL);
- if (!pvcreate_locked(cmd, argv[i], &pp))
+ if (!pvcreate_single(cmd, argv[i], &pp))
ret = ECMD_FAILED;
}
10 years, 10 months
master - report: remove LV_CREATE_PARAMS report type
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=dd302daf646f68...
Commit: dd302daf646f680531bf76ab13a9dafd06f63220
Parent: 5ed7d0cf1de4ebea6be8cb67759da40cb61c3913
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Jul 9 02:06:29 2013 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Jul 9 02:06:29 2013 +0100
report: remove LV_CREATE_PARAMS report type
Remove LV_CREATE_PARAMS from lib/report as it is not a type of metadata.
Added by 4d5de8322b3a6050def60542b167b46d97b2824d
---
lib/report/columns.h | 2 -
lib/report/properties.c | 86 ++++++---------
lib/report/properties.h | 6 -
lib/report/report.c | 1 -
lib/report/report.h | 3 +-
liblvm/lvm2app.h | 152 -------------------------
liblvm/lvm_lv.c | 289 +----------------------------------------------
liblvm/lvm_misc.c | 16 +---
liblvm/lvm_misc.h | 6 +-
liblvm/lvm_pv.c | 4 +-
liblvm/lvm_vg.c | 4 +-
tools/reporter.c | 4 -
12 files changed, 45 insertions(+), 528 deletions(-)
diff --git a/lib/report/columns.h b/lib/report/columns.h
index 4a05167..d13d19a 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -164,6 +164,4 @@ FIELD(SEGS, seg, STR, "Monitor", list, 7, segmonitor, monitor, "Dmeventd monitor
FIELD(PVSEGS, pvseg, NUM, "Start", pe, 5, uint32, pvseg_start, "Physical Extent number of start of segment.", 0)
FIELD(PVSEGS, pvseg, NUM, "SSize", len, 5, uint32, pvseg_size, "Number of extents in segment.", 0)
-
-FIELD(LV_CREATE_PARAMS, lvcreate_params, NUM, "skip_zero", zero, 2, uint32, skip_zero, "Skip zeroing on lv creation", 1)
/* *INDENT-ON* */
diff --git a/lib/report/properties.c b/lib/report/properties.c
index c20868b..c7194c5 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -39,9 +39,6 @@ static int _ ## NAME ## _get (const void *obj, struct lvm_property_type *prop) \
GET_NUM_PROPERTY_FN(NAME, VALUE, lv_segment, lvseg)
#define GET_PVSEG_NUM_PROPERTY_FN(NAME, VALUE) \
GET_NUM_PROPERTY_FN(NAME, VALUE, pv_segment, pvseg)
-#define GET_LVCREATEPARAMS_NUM_PROPERTY_FN(NAME, VALUE)\
- GET_NUM_PROPERTY_FN(NAME, VALUE, lvcreate_params, lvcp)
-
#define SET_NUM_PROPERTY_FN(NAME, SETFN, TYPE, VAR) \
static int _ ## NAME ## _set (void *obj, struct lvm_property_type *prop) \
@@ -51,15 +48,6 @@ static int _ ## NAME ## _set (void *obj, struct lvm_property_type *prop) \
SETFN(VAR, prop->value.integer); \
return 1; \
}
-
-#define SET_NUM_PROPERTY(NAME, VALUE, TYPE, VAR) \
-static int _ ## NAME ## _set (void *obj, struct lvm_property_type *prop) \
-{ \
- struct TYPE *VAR = (struct TYPE *)obj; \
-\
- VALUE = prop->value.integer; \
- return 1; \
-}
#define SET_VG_NUM_PROPERTY_FN(NAME, SETFN) \
SET_NUM_PROPERTY_FN(NAME, SETFN, volume_group, vg)
#define SET_PV_NUM_PROPERTY_FN(NAME, SETFN) \
@@ -67,9 +55,6 @@ static int _ ## NAME ## _set (void *obj, struct lvm_property_type *prop) \
#define SET_LV_NUM_PROPERTY_FN(NAME, SETFN) \
SET_NUM_PROPERTY_FN(NAME, SETFN, logical_volume, lv)
-#define SET_LVCREATEPARAMS_NUM_PROPERTY_FN(NAME, VALUE) \
- SET_NUM_PROPERTY(NAME, VALUE, lvcreate_params, lvcp)
-
#define GET_STR_PROPERTY_FN(NAME, VALUE, TYPE, VAR) \
static int _ ## NAME ## _get (const void *obj, struct lvm_property_type *prop) \
{ \
@@ -92,23 +77,29 @@ static int _ ## NAME ## _get (const void *obj, struct lvm_property_type *prop) \
static int _not_implemented_get(const void *obj, struct lvm_property_type *prop)
{
log_errno(ENOSYS, "Function not implemented");
+
return 0;
}
static int _not_implemented_set(void *obj, struct lvm_property_type *prop)
{
log_errno(ENOSYS, "Function not implemented");
+
return 0;
}
-static percent_t _copy_percent(const struct logical_volume *lv) {
- percent_t perc;
- if (!lv_mirror_percent(lv->vg->cmd, lv, 0, &perc, NULL))
- perc = PERCENT_INVALID;
- return perc;
+static percent_t _copy_percent(const struct logical_volume *lv)
+{
+ percent_t percent;
+
+ if (!lv_mirror_percent(lv->vg->cmd, lv, 0, &percent, NULL))
+ percent = PERCENT_INVALID;
+
+ return percent;
}
-static uint64_t _mismatches(const struct logical_volume *lv) {
+static uint64_t _mismatches(const struct logical_volume *lv)
+{
uint64_t cnt;
if (!lv_raid_mismatch_count(lv, &cnt))
@@ -116,53 +107,59 @@ static uint64_t _mismatches(const struct logical_volume *lv) {
return cnt;
}
-static char *_sync_action(const struct logical_volume *lv) {
+static char *_sync_action(const struct logical_volume *lv)
+{
char *action;
if (!lv_raid_sync_action(lv, &action))
return 0;
+
return action;
}
-static uint32_t _writebehind(const struct logical_volume *lv) {
+static uint32_t _writebehind(const struct logical_volume *lv)
+{
return first_seg(lv)->writebehind;
}
-static uint32_t _minrecoveryrate(const struct logical_volume *lv) {
+static uint32_t _minrecoveryrate(const struct logical_volume *lv)
+{
return first_seg(lv)->min_recovery_rate;
}
-static uint32_t _maxrecoveryrate(const struct logical_volume *lv) {
+static uint32_t _maxrecoveryrate(const struct logical_volume *lv)
+{
return first_seg(lv)->max_recovery_rate;
}
-static percent_t _snap_percent(const struct logical_volume *lv) {
- percent_t perc;
+static percent_t _snap_percent(const struct logical_volume *lv)
+{
+ percent_t percent;
- if (!lv_is_cow(lv) || !lv_snapshot_percent(lv, &perc))
- perc = PERCENT_INVALID;
+ if (!lv_is_cow(lv) || !lv_snapshot_percent(lv, &percent))
+ percent = PERCENT_INVALID;
- return perc;
+ return percent;
}
static percent_t _data_percent(const struct logical_volume *lv)
{
- percent_t perc;
+ percent_t percent;
if (lv_is_cow(lv))
return _snap_percent(lv);
if (lv_is_thin_volume(lv))
- return lv_thin_percent(lv, 0, &perc) ? perc : PERCENT_INVALID;
+ return lv_thin_percent(lv, 0, &percent) ? percent : PERCENT_INVALID;
- return lv_thin_pool_percent(lv, 0, &perc) ? perc : PERCENT_INVALID;
+ return lv_thin_pool_percent(lv, 0, &percent) ? percent : PERCENT_INVALID;
}
static percent_t _metadata_percent(const struct logical_volume *lv)
{
- percent_t perc;
+ percent_t percent;
- return lv_thin_pool_percent(lv, 1, &perc) ? perc : PERCENT_INVALID;
+ return lv_thin_pool_percent(lv, 1, &percent) ? percent : PERCENT_INVALID;
}
/* PV */
@@ -368,16 +365,12 @@ GET_LVSEG_STR_PROPERTY_FN(devices, lvseg_devices(lvseg->lv->vg->vgmem, lvseg))
GET_LVSEG_STR_PROPERTY_FN(monitor, lvseg_monitor_dup(lvseg->lv->vg->vgmem, lvseg))
#define _monitor_set _not_implemented_set
-
/* PVSEG */
GET_PVSEG_NUM_PROPERTY_FN(pvseg_start, pvseg->pe)
#define _pvseg_start_set _not_implemented_set
GET_PVSEG_NUM_PROPERTY_FN(pvseg_size, (SECTOR_SIZE * pvseg->len))
#define _pvseg_size_set _not_implemented_set
-/* lv create parameters */
-GET_LVCREATEPARAMS_NUM_PROPERTY_FN(skip_zero, lvcp->zero)
-SET_LVCREATEPARAMS_NUM_PROPERTY_FN(skip_zero, lvcp->zero)
#define STR DM_REPORT_FIELD_TYPE_STRING
#define NUM DM_REPORT_FIELD_TYPE_NUMBER
@@ -393,7 +386,6 @@ struct lvm_property_type _properties[] = {
#undef NUM
#undef FIELD
-
static int _get_property(const void *obj, struct lvm_property_type *prop,
unsigned type)
{
@@ -419,6 +411,7 @@ static int _get_property(const void *obj, struct lvm_property_type *prop,
if (!p->get(obj, prop)) {
return 0;
}
+
return 1;
}
@@ -455,6 +448,7 @@ static int _set_property(void *obj, struct lvm_property_type *prop,
if (!p->set(obj, p)) {
return 0;
}
+
return 1;
}
@@ -482,18 +476,6 @@ int pvseg_get_property(const struct pv_segment *pvseg,
return _get_property(pvseg, prop, PVSEGS);
}
-int lv_create_param_get_property(const struct lvcreate_params *lvcp,
- struct lvm_property_type *prop)
-{
- return _get_property(lvcp, prop, LV_CREATE_PARAMS);
-}
-
-int lv_create_param_set_property(struct lvcreate_params *lvcp,
- struct lvm_property_type *prop)
-{
- return _set_property(lvcp, prop, LV_CREATE_PARAMS);
-}
-
int pv_get_property(const struct physical_volume *pv,
struct lvm_property_type *prop)
{
diff --git a/lib/report/properties.h b/lib/report/properties.h
index 1a08589..aefd3f5 100644
--- a/lib/report/properties.h
+++ b/lib/report/properties.h
@@ -50,10 +50,4 @@ int vg_set_property(struct volume_group *vg,
int pv_set_property(struct physical_volume *pv,
struct lvm_property_type *prop);
-int lv_create_param_get_property(const struct lvcreate_params *lvcp,
- struct lvm_property_type *prop);
-
-int lv_create_param_set_property(struct lvcreate_params *lvcp,
- struct lvm_property_type *prop);
-
#endif
diff --git a/lib/report/report.c b/lib/report/report.c
index 965859d..8b5455b 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -1295,7 +1295,6 @@ typedef struct logical_volume type_lv;
typedef struct volume_group type_vg;
typedef struct lv_segment type_seg;
typedef struct pv_segment type_pvseg;
-typedef struct lvcreate_params type_lvcreate_params;
static const struct dm_report_field_type _fields[] = {
#include "columns.h"
diff --git a/lib/report/report.h b/lib/report/report.h
index d5bfb6a..26cc2f7 100644
--- a/lib/report/report.h
+++ b/lib/report/report.h
@@ -24,8 +24,7 @@ typedef enum {
VGS = 4,
SEGS = 8,
PVSEGS = 16,
- LABEL = 32,
- LV_CREATE_PARAMS = 64
+ LABEL = 32
} report_type_t;
struct field;
diff --git a/liblvm/lvm2app.h b/liblvm/lvm2app.h
index f4475c0..2775de6 100644
--- a/liblvm/lvm2app.h
+++ b/liblvm/lvm2app.h
@@ -97,7 +97,6 @@ struct volume_group;
struct logical_volume;
struct lv_segment;
struct pv_segment;
-struct lvm_lv_create_params;
/**
* \class lvm_t
@@ -154,14 +153,6 @@ typedef struct lv_segment *lvseg_t;
typedef struct pv_segment *pvseg_t;
/**
- * \class lv_create_params
- *
- * This lv_create_params represents the plethora of available options when
- * creating a logical volume
- */
-typedef struct lvm_lv_create_params *lv_create_params_t;
-
-/**
* Logical Volume object list.
*
* Lists of these structures are returned by lvm_vg_list_lvs().
@@ -1489,149 +1480,6 @@ int lvm_lv_resize(const lv_t lv, uint64_t new_size);
*/
lv_t lvm_lv_snapshot(const lv_t lv, const char *snap_name, uint64_t max_snap_size);
-/**
- * Thin provisioning discard policies
- */
-typedef enum {
- LVM_THIN_DISCARDS_IGNORE,
- LVM_THIN_DISCARDS_NO_PASSDOWN,
- LVM_THIN_DISCARDS_PASSDOWN,
-} lvm_thin_discards_t;
-
-/**
- * Create a thinpool parameter passing object for the specified VG
- *
- * \param vg
- * Volume Group handle.
- *
- * \param pool_name
- * Name of the pool.
- *
- * \param size
- * size of the pool
- *
- * \param chunk_size
- * data block size of the pool
- * Default value is DEFAULT_THIN_POOL_CHUNK_SIZE * 2 when 0 passed as chunk_size
- * DM_THIN_MIN_DATA_BLOCK_SIZE < chunk_size < DM_THIN_MAX_DATA_BLOCK_SIZE
- *
- * \param meta_size
- * Size of thin pool's metadata logical volume. Allowed range is 2MB-16GB.
- * Default value (ie if 0) pool size / pool chunk size * 64
- *
- * \param discard
- * Thin discard policy
- * Note: THIN_DISCARDS_PASSDOWN is the default.
- *
- * \return
- * Valid lv_create_params pointer on success, else NULL on error.
- * Note: Memory is associated with the vg, it will get reclaimed when vg is
- * closed.
- *
- */
-lv_create_params_t lvm_lv_params_create_thin_pool(vg_t vg,
- const char *pool_name, uint64_t size, uint32_t chunk_size,
- uint64_t meta_size, lvm_thin_discards_t discard);
-
-#define lvm_lv_params_create_thin_pool_default(vg, pool_name, size) \
- lvm_lv_params_create_thin_pool((vg), (pool_name), (size), 0, 0, \
- LVM_THIN_DISCARDS_PASSDOWN)
-
-
-/**
- * Creates the snapshot parameter passing object for the specified lv.
- *
- * \param lv
- * The logical volume to snapshot
- *
- * \param snap_name
- * Name of snapshot
- *
- * \param max_snap_size
- * Used for old snap shots max size, set to zero for thinp
- *
- * \return
- * Valid lv_create_params pointer on success, else NULL on error.
- * Note: Memory is associated with the vg, it will get reclaimed when vg is
- * closed.
- */
-lv_create_params_t lvm_lv_params_create_snapshot(const lv_t lv,
- const char *snap_name,
- uint64_t max_snap_size);
-/**
- * Get the specific value of a lv create parameter by name
- *
- * \param params lv create parameters
- *
- * \param name name of parameter
- *
- * \return
- * lvm_property_value structure that will contain the current
- * value of the property. Caller should check 'is_valid' flag before using
- * the value. If 'is_valid' is not set, caller should check lvm_errno()
- * for specific error.
- */
-struct lvm_property_value lvm_lv_params_get_property(
- const lv_create_params_t params,
- const char *name);
-
-
-/**
- * Set the specific value of a lv create parameter by name
- *
- * Note that the property must be a 'settable' property, as evidenced '
- * by the 'is_settable' flag when querying the property.
- *
- * The memory allocated for a string property value is tied to the vg_t
- * handle associated with the lv_create_params_t and will be released when
- * lvm_vg_close() is called.
- *
- * \param params lv create parameters
- *
- * \param name name of parameter
- *
- * \param prop Property value to use for setting
- *
- * \return
- * 0 on success, -1 on error.
- */
-int lvm_lv_params_set_property(lv_create_params_t params,
- const char *name,
- struct lvm_property_value *prop);
-
-/**
- * Create a thin LV creation parameters in a given VG & thin pool
- *
- * \param vg
- * Volume Group handle.
- *
- * \param pool_name
- * Name of the pool.
- *
- * \param lvname
- * Name of the LV to create
- *
- * \param size
- * Size of logical volume
- *
- * \return
- * Valid lv_create_params pointer on success, else NULL on error.
- * Note: Memory is associated with the vg, it will get reclaimed when vg is
- * closed.
- *
- */
-lv_create_params_t lvm_lv_params_create_thin(const vg_t vg, const char *pool_name,
- const char *lvname, uint64_t size);
-/**
- * Create the actual logical volume.
- *
- * \param params The parameters object for lv creation
- *
- * \return
- * Valid lv pointer on success, else NULL on error.
- */
-lv_t lvm_lv_create(lv_create_params_t params);
-
/************************** physical volume handling ************************/
/**
diff --git a/liblvm/lvm_lv.c b/liblvm/lvm_lv.c
index 4171baa..0590bd6 100644
--- a/liblvm/lvm_lv.c
+++ b/liblvm/lvm_lv.c
@@ -24,15 +24,6 @@
/* FIXME Improve all the log messages to include context. Which VG/LV as a minimum? */
-struct lvm_lv_create_params
-{
- uint32_t magic;
- vg_t vg;
- struct lvcreate_params lvp;
-};
-
-#define LV_CREATE_PARAMS_MAGIC 0xFEED0001
-
static int _lv_check_handle(const lv_t lv, const int vg_writeable)
{
if (!lv || !lv->vg || vg_read_error(lv->vg))
@@ -71,13 +62,13 @@ const char *lvm_lv_get_origin(const lv_t lv)
struct lvm_property_value lvm_lv_get_property(const lv_t lv, const char *name)
{
- return get_property(NULL, NULL, lv, NULL, NULL, NULL, name);
+ return get_property(NULL, NULL, lv, NULL, NULL, name);
}
struct lvm_property_value lvm_lvseg_get_property(const lvseg_t lvseg,
const char *name)
{
- return get_property(NULL, NULL, NULL, lvseg, NULL, NULL, name);
+ return get_property(NULL, NULL, NULL, lvseg, NULL, name);
}
uint64_t lvm_lv_is_active(const lv_t lv)
@@ -355,279 +346,3 @@ int lvm_lv_resize(const lv_t lv, uint64_t new_size)
return 0;
}
-lv_t lvm_lv_snapshot(const lv_t lv, const char *snap_name,
- uint64_t max_snap_size)
-{
- struct lvm_lv_create_params *lvcp = NULL;
-
- lvcp = lvm_lv_params_create_snapshot(lv, snap_name, max_snap_size);
- if (lvcp) {
- return lvm_lv_create(lvcp);
- }
- return NULL;
-}
-
-/* Set defaults for thin pool specific LV parameters */
-static void _lv_set_pool_params(struct lvcreate_params *lp,
- vg_t vg, const char *pool,
- uint64_t extents, uint64_t meta_size)
-{
- _lv_set_default_params(lp, vg, NULL, extents);
-
- lp->pool = pool;
-
- lp->create_thin_pool = 1;
- lp->segtype = get_segtype_from_string(vg->cmd, "thin-pool");
- lp->stripes = 1;
-
- if (!meta_size) {
- lp->poolmetadatasize = extents * vg->extent_size /
- (lp->chunk_size * (SECTOR_SIZE / 64));
- while ((lp->poolmetadatasize >
- (2 * DEFAULT_THIN_POOL_OPTIMAL_SIZE / SECTOR_SIZE)) &&
- lp->chunk_size < DM_THIN_MAX_DATA_BLOCK_SIZE) {
- lp->chunk_size <<= 1;
- lp->poolmetadatasize >>= 1;
- }
- } else
- lp->poolmetadatasize = meta_size;
-
- if (lp->poolmetadatasize % vg->extent_size)
- lp->poolmetadatasize +=
- vg->extent_size - lp->poolmetadatasize % vg->extent_size;
-
- lp->poolmetadataextents =
- extents_from_size(vg->cmd, lp->poolmetadatasize / SECTOR_SIZE,
- vg->extent_size);
-}
-
-lv_create_params_t lvm_lv_params_create_thin_pool(vg_t vg,
- const char *pool_name, uint64_t size, uint32_t chunk_size,
- uint64_t meta_size, lvm_thin_discards_t discard)
-{
- uint64_t extents = 0;
- struct lvm_lv_create_params *lvcp = NULL;
-
- if (meta_size > (2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE)) {
- log_error("Invalid metadata size");
- return NULL;
- }
-
- if (meta_size &&
- meta_size < (2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE)) {
- log_error("Invalid metadata size");
- return NULL;
- }
-
- if (vg_read_error(vg))
- return NULL;
-
- if (!vg_check_write_mode(vg))
- return NULL;
-
- if (pool_name == NULL || !strlen(pool_name)) {
- log_error("pool_name invalid");
- return NULL;
- }
-
- if (!(extents = extents_from_size(vg->cmd, size / SECTOR_SIZE,
- vg->extent_size))) {
- log_error("Unable to create LV thin pool without size.");
- return NULL;
- }
-
- lvcp = dm_pool_zalloc(vg->vgmem, sizeof (struct lvm_lv_create_params));
-
- if (lvcp) {
- lvcp->vg = vg;
- lvcp->lvp.discards = discard;
-
- if (chunk_size)
- lvcp->lvp.chunk_size = chunk_size;
- else
- lvcp->lvp.chunk_size = DEFAULT_THIN_POOL_CHUNK_SIZE * 2;
-
- if (lvcp->lvp.chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE ||
- lvcp->lvp.chunk_size > DM_THIN_MAX_DATA_BLOCK_SIZE) {
- log_error("Invalid chunk_size");
- return NULL;
- }
-
- _lv_set_pool_params(&lvcp->lvp, vg, pool_name, extents, meta_size);
-
- lvcp->magic = LV_CREATE_PARAMS_MAGIC;
- }
- return lvcp;
-}
-
-/* Set defaults for thin LV specific parameters */
-static void _lv_set_thin_params(struct lvcreate_params *lp,
- vg_t vg, const char *pool,
- const char *lvname,
- uint64_t extents)
-{
- _lv_set_default_params(lp, vg, lvname, extents);
-
- lp->thin = 1;
- lp->pool = pool;
- lp->segtype = get_segtype_from_string(vg->cmd, "thin");
-
- lp->voriginsize = extents * vg->extent_size;
- lp->voriginextents = extents_from_size(vg->cmd, lp->voriginsize,
- vg->extent_size);
-
- lp->stripes = 1;
-}
-
-lv_create_params_t lvm_lv_params_create_snapshot(const lv_t lv,
- const char *snap_name,
- uint64_t max_snap_size)
-{
- uint64_t size = 0;
- uint64_t extents = 0;
- struct lvm_lv_create_params *lvcp = NULL;
-
- if (vg_read_error(lv->vg)) {
- return NULL;
- }
-
- if (!vg_check_write_mode(lv->vg))
- return NULL;
-
- if (snap_name == NULL || !strlen(snap_name)) {
- log_error("snap_name invalid");
- return NULL;
- }
-
- if (max_snap_size) {
- size = max_snap_size >> SECTOR_SHIFT;
- extents = extents_from_size(lv->vg->cmd, size, lv->vg->extent_size);
- }
-
- if (!size && !lv_is_thin_volume(lv) ) {
- log_error("Origin is not thin, specify size of snapshot");
- return NULL;
- }
-
- lvcp = dm_pool_zalloc(lv->vg->vgmem, sizeof (struct lvm_lv_create_params));
- if (lvcp) {
- lvcp->vg = lv->vg;
- _lv_set_default_params(&lvcp->lvp, lv->vg, snap_name, extents);
- lvcp->lvp.snapshot = 1;
-
-
- if (size) {
- lvcp->lvp.segtype = _get_segtype(lvcp->vg->cmd);
- lvcp->lvp.chunk_size = 8;
- } else {
- lvcp->lvp.segtype = get_segtype_from_string(lv->vg->cmd, "thin");
-
- if (!lvcp->lvp.segtype) {
- log_error(INTERNAL_ERROR "Segtype thin not found.");
- return NULL;
- }
-
- lvcp->lvp.pool = first_seg(lv)->pool_lv->name;
- }
-
- lvcp->lvp.stripes = 1;
- lvcp->lvp.origin = lv->name;
-
- lvcp->magic = LV_CREATE_PARAMS_MAGIC;
- }
-
- return lvcp;
-}
-
-
-lv_create_params_t lvm_lv_params_create_thin(const vg_t vg, const char *pool_name,
- const char *lvname, uint64_t size)
-{
- struct lvm_lv_create_params *lvcp = NULL;
- uint64_t extents = 0;
-
- /* precondition checks */
- if (vg_read_error(vg))
- return NULL;
-
- if (!vg_check_write_mode(vg))
- return NULL;
-
- if (pool_name == NULL || !strlen(pool_name)) {
- log_error("pool_name invalid");
- return NULL;
- }
-
- if (lvname == NULL || !strlen(lvname)) {
- log_error("lvname invalid");
- return NULL;
- }
-
- if (!(extents = extents_from_size(vg->cmd, size / SECTOR_SIZE,
- vg->extent_size))) {
- log_error("Unable to create thin LV without size.");
- return NULL;
- }
-
- lvcp = dm_pool_zalloc(vg->vgmem, sizeof (struct lvm_lv_create_params));
- if (lvcp) {
- lvcp->vg = vg;
- _lv_set_thin_params(&lvcp->lvp, vg, pool_name, lvname, extents);
- lvcp->magic = LV_CREATE_PARAMS_MAGIC;
- }
-
- return lvcp;
-}
-
-struct lvm_property_value lvm_lv_params_get_property(
- const lv_create_params_t params,
- const char *name)
-{
- struct lvm_property_value rc;
-
- rc.is_valid = 0;
-
- if (params && params->magic == LV_CREATE_PARAMS_MAGIC) {
- rc = get_property(NULL, NULL, NULL, NULL, NULL, ¶ms->lvp, name);
- } else {
- log_error("Invalid lv_create_params parameter");
- }
- return rc;
-}
-
-int lvm_lv_params_set_property(lv_create_params_t params, const char *name,
- struct lvm_property_value *prop)
-{
- int rc = -1;
-
- if (params && params->magic == LV_CREATE_PARAMS_MAGIC) {
- rc = set_property(NULL, NULL, NULL, ¶ms->lvp, name, prop);
- } else {
- log_error("Invalid lv_create_params parameter");
- }
- return rc;
-}
-
-lv_t lvm_lv_create(lv_create_params_t params)
-{
- struct lv_list *lvl = NULL;
-
- if (params && params->magic == LV_CREATE_PARAMS_MAGIC) {
- if (!params->lvp.segtype) {
- log_error("segtype parameter is NULL");
- return_NULL;
- }
- if (!lv_create_single(params->vg, ¶ms->lvp))
- return_NULL;
-
- /* In some case we are making a thin pool so lv_name is not valid, but
- * pool is.
- */
- if (!(lvl = find_lv_in_vg(params->vg,
- (params->lvp.lv_name) ? params->lvp.lv_name : params->lvp.pool)))
- return_NULL;
- return (lv_t) lvl->lv;
- }
- log_error("Invalid lv_create_params parameter");
- return NULL;
-}
diff --git a/liblvm/lvm_misc.c b/liblvm/lvm_misc.c
index de66417..0a0ea12 100644
--- a/liblvm/lvm_misc.c
+++ b/liblvm/lvm_misc.c
@@ -47,8 +47,7 @@ struct dm_list *tag_list_copy(struct dm_pool *p, struct dm_list *tag_list)
struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
const lv_t lv, const lvseg_t lvseg,
- const pvseg_t pvseg, const struct lvcreate_params *lvcp,
- const char *name)
+ const pvseg_t pvseg, const char *name)
{
struct lvm_property_type prop;
struct lvm_property_value v = { 0 };
@@ -70,9 +69,6 @@ struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
} else if (pvseg) {
if (!pvseg_get_property(pvseg, &prop))
return v;
- } else if (lvcp) {
- if (!lv_create_param_get_property(lvcp, &prop))
- return v;
} else {
log_errno(EINVAL, "Invalid NULL handle passed to library function.");
return v;
@@ -91,8 +87,7 @@ struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
int set_property(const pv_t pv, const vg_t vg, const lv_t lv,
- struct lvcreate_params *lvcp, const char *name,
- struct lvm_property_value *v)
+ const char *name, struct lvm_property_value *v)
{
struct lvm_property_type prop;
@@ -116,13 +111,6 @@ int set_property(const pv_t pv, const vg_t vg, const lv_t lv,
v->is_valid = 0;
return -1;
}
- } else if (lvcp) {
- if (!lv_create_param_set_property(lvcp, &prop)) {
- v->is_valid = 0;
- return -1;
- }
- } else {
- return -1;
}
return 0;
}
diff --git a/liblvm/lvm_misc.h b/liblvm/lvm_misc.h
index 76f4e0a..a0324b8 100644
--- a/liblvm/lvm_misc.h
+++ b/liblvm/lvm_misc.h
@@ -20,10 +20,8 @@
struct dm_list *tag_list_copy(struct dm_pool *p, struct dm_list *tag_list);
struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
const lv_t lv, const lvseg_t lvseg,
- const pvseg_t pvseg, const struct lvcreate_params *lvcp,
- const char *name);
+ const pvseg_t pvseg, const char *name);
int set_property(const pv_t pv, const vg_t vg, const lv_t lv,
- struct lvcreate_params *lvcp, const char *name,
- struct lvm_property_value *value);
+ const char *name, struct lvm_property_value *value);
#endif
diff --git a/liblvm/lvm_pv.c b/liblvm/lvm_pv.c
index 5d8a66b..e679b3a 100644
--- a/liblvm/lvm_pv.c
+++ b/liblvm/lvm_pv.c
@@ -53,13 +53,13 @@ uint64_t lvm_pv_get_free(const pv_t pv)
struct lvm_property_value lvm_pv_get_property(const pv_t pv, const char *name)
{
- return get_property(pv, NULL, NULL, NULL, NULL, NULL, name);
+ return get_property(pv, NULL, NULL, NULL, NULL, name);
}
struct lvm_property_value lvm_pvseg_get_property(const pvseg_t pvseg,
const char *name)
{
- return get_property(NULL, NULL, NULL, NULL, pvseg, NULL, name);
+ return get_property(NULL, NULL, NULL, NULL, pvseg, name);
}
struct lvm_list_wrapper
diff --git a/liblvm/lvm_vg.c b/liblvm/lvm_vg.c
index 955afdb..4a5fdf5 100644
--- a/liblvm/lvm_vg.c
+++ b/liblvm/lvm_vg.c
@@ -339,7 +339,7 @@ const char *lvm_vg_get_name(const vg_t vg)
struct lvm_property_value lvm_vg_get_property(const vg_t vg, const char *name)
{
- return get_property(NULL, vg, NULL, NULL, NULL, NULL, name);
+ return get_property(NULL, vg, NULL, NULL, NULL, name);
}
int lvm_vg_set_property(const vg_t vg, const char *name,
@@ -356,7 +356,7 @@ int lvm_vg_set_property(const vg_t vg, const char *name,
strlen(value->value.string) + 1);
}
- return set_property(NULL, vg, NULL, NULL, name, value);
+ return set_property(NULL, vg, NULL, name, value);
}
struct dm_list *lvm_list_vg_names(lvm_t libh)
diff --git a/tools/reporter.c b/tools/reporter.c
index ced7d56..a6941e3 100644
--- a/tools/reporter.c
+++ b/tools/reporter.c
@@ -271,7 +271,6 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
else
options = find_config_tree_str(cmd, report_pvsegs_cols_verbose_CFG, NULL);
break;
- case LV_CREATE_PARAMS:
default:
log_error(INTERNAL_ERROR "Unknown report type.");
return ECMD_FAILED;
@@ -383,9 +382,6 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
r = process_each_vg(cmd, argc, argv, 0,
report_handle, &_pvsegs_in_vg);
break;
-
- case LV_CREATE_PARAMS:
- break;
}
dm_report_output(report_handle);
10 years, 10 months
master - dumpconfig: add --mergedconfig option
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5ed7d0cf1de4eb...
Commit: 5ed7d0cf1de4ebea6be8cb67759da40cb61c3913
Parent: f1e289001286f978630f5e6423acca1af322ebd7
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jul 8 15:34:27 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jul 8 16:05:56 2013 +0200
dumpconfig: add --mergedconfig option
Normally, the lvm dumpconfig processes only the configuration tree
that is at the top of the cascade. Considering the cascade is:
CONFIG_STRING -> CONFIG_PROFILE -> CONFIG_MERGED_FILES/CONFIG_FILE
...then:
(dumpconfig of lvm.conf only)
raw/~ $ lvm dumpconfig allocation
allocation {
maximise_cling=1
mirror_logs_require_separate_pvs=0
thin_pool_metadata_require_separate_pvs=0
thin_pool_chunk_size=64
}
(dumpconfig of selected profile configuration only)
raw/~ $ lvm dumpconfig --profile test allocation
allocation {
thin_pool_chunk_size=8
thin_pool_discards="passdown"
thin_pool_zero=1
}
(dumpconfig of given --config configuration only)
raw/~ $ lvm dumpconfig --config 'allocation{thin_pool_chunk_size=16}' allocation
allocation {
thin_pool_chunk_size=16
}
The --mergedconfig option causes the configuration cascade to be
merged before processing it with dumpconfig:
(dumpconfig of merged selected profile and lvm.conf)
raw/~ $ lvm dumpconfig --profile test allocation --mergedconfig
allocation {
maximise_cling=1
thin_pool_zero=1
thin_pool_discards="passdown"
mirror_logs_require_separate_pvs=0
thin_pool_metadata_require_separate_pvs=0
thin_pool_chunk_size=8
}
(dumpconfig merged given --config and selected profile and lvm.conf)
raw/~ $ lvm dumpconfig --profile test --config 'allocation{thin_pool_chunk_size=16}' allocation --mergedconfig
allocation {
maximise_cling=1
thin_pool_zero=1
thin_pool_discards="passdown"
mirror_logs_require_separate_pvs=0
thin_pool_metadata_require_separate_pvs=0
thin_pool_chunk_size=16
}
Hence with the --mergedconfig, we are able to see the
configuration that is actually used when processing any
LVM command while using any combination of --config/--profile
options together with lvm.conf file.
---
WHATS_NEW | 1 +
tools/args.h | 1 +
tools/commands.h | 3 +-
tools/dumpconfig.c | 87 ++++++++++++++++++++++++++++++++++++++-------------
4 files changed, 69 insertions(+), 23 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 567441a..68b3b78 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Add --mergedconfig to lvm dumpconfig for merged --config/--profile/lvm.conf.
Relase memory and unblock signals in lock_vol error path.
Define LVM2_* command errors in lvm2cmd.h and use in dmeventd plugins.
Move errors.h to tools dir.
diff --git a/tools/args.h b/tools/args.h
index 73312ca..ee95ad8 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -93,6 +93,7 @@ arg(minrecoveryrate_ARG, '\0', "minrecoveryrate", size_kb_arg, 0)
arg(maxrecoveryrate_ARG, '\0', "maxrecoveryrate", size_kb_arg, 0)
arg(profile_ARG, '\0', "profile", string_arg, 0)
arg(detachprofile_ARG, '\0', "detachprofile", NULL, 0)
+arg(mergedconfig_ARG, '\0', "mergedconfig", NULL, 0)
/* Allow some variations */
arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)
diff --git a/tools/commands.h b/tools/commands.h
index f84aa35..3f43260 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -38,12 +38,13 @@ xx(dumpconfig,
"\t[--withversions] \n"
"\t[--ignoreadvanced] \n"
"\t[--ignoreunsupported] \n"
+ "\t[--mergedconfig] \n"
"\t[--atversion version]] \n"
"\t[--validate]\n"
"\t[ConfigurationNode...]\n",
file_ARG, configtype_ARG, withcomments_ARG, atversion_ARG,
withversions_ARG, ignoreadvanced_ARG, ignoreunsupported_ARG,
- validate_ARG)
+ mergedconfig_ARG, validate_ARG)
xx(formats,
"List available metadata formats",
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c
index 3839def..08f996a 100644
--- a/tools/dumpconfig.c
+++ b/tools/dumpconfig.c
@@ -15,7 +15,7 @@
#include "tools.h"
-static int _get_vsn(struct cmd_context *cmd, uint16_t *version)
+static int _get_vsn(struct cmd_context *cmd, uint16_t *version_int)
{
const char *atversion = arg_str_value(cmd, atversion_ARG, LVM_VERSION);
unsigned int major, minor, patchlevel;
@@ -25,31 +25,42 @@ static int _get_vsn(struct cmd_context *cmd, uint16_t *version)
return 0;
}
- *version = vsn(major, minor, patchlevel);
+ *version_int = vsn(major, minor, patchlevel);
return 1;
}
-static struct cft_check_handle *_get_cft_check_handle(struct cmd_context *cmd)
+static struct cft_check_handle *_get_cft_check_handle(struct cmd_context *cmd, struct dm_config_tree *cft)
{
- struct cft_check_handle *handle = cmd->cft_check_handle;
+ struct cft_check_handle *handle;
+ struct dm_pool *mem;
+
+ if (cft == cmd->cft) {
+ mem = cmd->libmem;
+ handle = cmd->cft_check_handle;
+ } else {
+ mem = cft->mem;
+ handle = NULL;
+ }
if (!handle) {
- if (!(handle = dm_pool_zalloc(cmd->libmem, sizeof(*cmd->cft_check_handle)))) {
+ if (!(handle = dm_pool_zalloc(mem, sizeof(struct cft_check_handle)))) {
log_error("Configuration check handle allocation failed.");
return NULL;
}
- handle->cft = cmd->cft;
- cmd->cft_check_handle = handle;
+ handle->cft = cft;
+ if (cft == cmd->cft)
+ cmd->cft_check_handle = handle;
}
return handle;
}
-static int _do_def_check(struct cmd_context *cmd, struct cft_check_handle **cft_check_handle)
+static int _do_def_check(struct cmd_context *cmd, struct dm_config_tree *cft,
+ struct cft_check_handle **cft_check_handle)
{
struct cft_check_handle *handle;
- if (!(handle = _get_cft_check_handle(cmd)))
+ if (!(handle = _get_cft_check_handle(cmd, cft)))
return 0;
handle->force_check = 1;
@@ -62,6 +73,21 @@ static int _do_def_check(struct cmd_context *cmd, struct cft_check_handle **cft_
return 1;
}
+static int _merge_config_cascade(struct cmd_context *cmd, struct dm_config_tree *cft_cascaded,
+ struct dm_config_tree **cft_merged)
+{
+ if (!cft_cascaded)
+ return 1;
+
+ if (!*cft_merged && !(*cft_merged = config_open(CONFIG_MERGED_FILES, NULL, 0)))
+ return_0;
+
+ if (!_merge_config_cascade(cmd, cft_cascaded->cascade, cft_merged))
+ return_0;
+
+ return merge_config_tree(cmd, *cft_merged, cft_cascaded, CONFIG_MERGE_TYPE_RAW);
+}
+
int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
{
const char *file = arg_str_value(cmd, file_ARG, NULL);
@@ -103,8 +129,21 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
if (!_get_vsn(cmd, &tree_spec.version))
return EINVALID_CMD_LINE;
+ /*
+ * Set the 'cft' to work with based on whether we need the plain
+ * config tree or merged config tree cascade if --mergedconfig is used.
+ */
+ if (arg_count(cmd, mergedconfig_ARG) && cmd->cft->cascade) {
+ if (!_merge_config_cascade(cmd, cmd->cft, &cft)) {
+ log_error("Failed to merge configuration.");
+ r = ECMD_FAILED;
+ goto out;
+ }
+ } else
+ cft = cmd->cft;
+
if (arg_count(cmd, validate_ARG)) {
- if (!(cft_check_handle = _get_cft_check_handle(cmd)))
+ if (!(cft_check_handle = _get_cft_check_handle(cmd, cft)))
return ECMD_FAILED;
cft_check_handle->force_check = 1;
@@ -113,22 +152,27 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
if (config_def_check(cmd, cft_check_handle)) {
log_print("LVM configuration valid.");
- return ECMD_PROCESSED;
+ goto out;
} else {
log_error("LVM configuration invalid.");
- return ECMD_FAILED;
+ r = ECMD_FAILED;
+ goto out;
}
}
if (!strcmp(type, "current")) {
tree_spec.type = CFG_DEF_TREE_CURRENT;
- if (!_do_def_check(cmd, &cft_check_handle))
- return ECMD_FAILED;
+ if (!_do_def_check(cmd, cft, &cft_check_handle)) {
+ r = ECMD_FAILED;
+ goto_out;
+ }
}
else if (!strcmp(type, "missing")) {
tree_spec.type = CFG_DEF_TREE_MISSING;
- if (!_do_def_check(cmd, &cft_check_handle))
- return ECMD_FAILED;
+ if (!_do_def_check(cmd, cft, &cft_check_handle)) {
+ r = ECMD_FAILED;
+ goto_out;
+ }
}
else if (!strcmp(type, "default")) {
tree_spec.type = CFG_DEF_TREE_DEFAULT;
@@ -141,15 +185,14 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
else {
log_error("Incorrect type of configuration specified. "
"Expected one of: current, default, missing, new.");
- return EINVALID_CMD_LINE;
+ r = EINVALID_CMD_LINE;
+ goto out;
}
if (cft_check_handle)
tree_spec.check_status = cft_check_handle->status;
- if (tree_spec.type == CFG_DEF_TREE_CURRENT)
- cft = cmd->cft;
- else
+ if (tree_spec.type != CFG_DEF_TREE_CURRENT)
cft = config_def_create_tree(&tree_spec);
if (!config_write(cft, arg_count(cmd, withcomments_ARG),
@@ -158,8 +201,8 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
stack;
r = ECMD_FAILED;
}
-
- if (cft != cmd->cft)
+out:
+ if (cft && (cft != cmd->cft))
dm_pool_destroy(cft->mem);
/*
10 years, 10 months
master - config: make it possible to do a raw config tree merge
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f1e289001286f9...
Commit: f1e289001286f978630f5e6423acca1af322ebd7
Parent: 661406a417e3cbf2170ba7c3debd767d50e99cae
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jul 8 14:31:44 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jul 8 15:59:25 2013 +0200
config: make it possible to do a raw config tree merge
Till now, we needed the config tree merge only for merging
tag configs with lvm.conf. However, this type of merging
did a few extra exceptions:
- leaving out the tags section
- merging values in activation/volume_list
- merging values in devices/filter
- merging values in devices/types
Any other config values were replaced by new values.
However, we'd like to do a 'raw merge' as well, simply
bypassing the exceptions listed above. This will help
us to create a single tree representing the cascaded
configs like CONFIG_STRING -> CONFIG_PROFILE -> ...
The reason for this patch is that when trees are cascaded,
the first value found while traversing the cascade is used,
not making any exceptions like we do for tag configs.
---
lib/commands/toolcontext.c | 2 +-
lib/config/config.c | 69 +++++++++++++++++++++++++-------------------
lib/config/config.h | 13 +++++++-
3 files changed, 52 insertions(+), 32 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 4919b93..2c4a698 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -659,7 +659,7 @@ static struct dm_config_tree *_merge_config_files(struct cmd_context *cmd, struc
dm_list_iterate_items(cfl, &cmd->config_files) {
/* Merge all config trees into cmd->cft using merge/tag rules */
- if (!merge_config_tree(cmd, cft, cfl->cft))
+ if (!merge_config_tree(cmd, cft, cfl->cft, CONFIG_MERGE_TYPE_TAGS))
return_0;
}
diff --git a/lib/config/config.c b/lib/config/config.c
index 26b2aa8..4c1b415 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -955,7 +955,8 @@ static void _insert_config_node(struct dm_config_node **cn1,
* Merge section cn2 into section cn1 (which has the same name)
* overwriting any existing cn1 nodes with matching names.
*/
-static void _merge_section(struct dm_config_node *cn1, struct dm_config_node *cn2)
+static void _merge_section(struct dm_config_node *cn1, struct dm_config_node *cn2,
+ config_merge_t merge_type)
{
struct dm_config_node *cn, *nextn, *oldn;
struct dm_config_value *cv;
@@ -963,9 +964,11 @@ static void _merge_section(struct dm_config_node *cn1, struct dm_config_node *cn
for (cn = cn2->child; cn; cn = nextn) {
nextn = cn->sib;
- /* Skip "tags" */
- if (!strcmp(cn->key, "tags"))
- continue;
+ if (merge_type == CONFIG_MERGE_TYPE_TAGS) {
+ /* Skip "tags" */
+ if (!strcmp(cn->key, "tags"))
+ continue;
+ }
/* Subsection? */
if (!cn->v)
@@ -976,15 +979,17 @@ static void _merge_section(struct dm_config_node *cn1, struct dm_config_node *cn
_insert_config_node(&cn1->child, cn);
continue;
}
- /* Merge certain value lists */
- if ((!strcmp(cn1->key, "activation") &&
- !strcmp(cn->key, "volume_list")) ||
- (!strcmp(cn1->key, "devices") &&
- (!strcmp(cn->key, "filter") || !strcmp(cn->key, "types")))) {
- cv = cn->v;
- while (cv->next)
- cv = cv->next;
- cv->next = oldn->v;
+ if (merge_type == CONFIG_MERGE_TYPE_TAGS) {
+ /* Merge certain value lists */
+ if ((!strcmp(cn1->key, "activation") &&
+ !strcmp(cn->key, "volume_list")) ||
+ (!strcmp(cn1->key, "devices") &&
+ (!strcmp(cn->key, "filter") || !strcmp(cn->key, "types")))) {
+ cv = cn->v;
+ while (cv->next)
+ cv = cv->next;
+ cv->next = oldn->v;
+ }
}
/* Replace values */
@@ -1014,7 +1019,7 @@ static int _match_host_tags(struct dm_list *tags, const struct dm_config_node *t
/* Destructively merge a new config tree into an existing one */
int merge_config_tree(struct cmd_context *cmd, struct dm_config_tree *cft,
- struct dm_config_tree *newdata)
+ struct dm_config_tree *newdata, config_merge_t merge_type)
{
struct dm_config_node *root = cft->root;
struct dm_config_node *cn, *nextn, *oldn, *cn2;
@@ -1023,30 +1028,34 @@ int merge_config_tree(struct cmd_context *cmd, struct dm_config_tree *cft,
for (cn = newdata->root; cn; cn = nextn) {
nextn = cn->sib;
- /* Ignore tags section */
- if (!strcmp(cn->key, "tags"))
- continue;
- /* If there's a tags node, skip if host tags don't match */
- if ((tn = dm_config_find_node(cn->child, "tags"))) {
- if (!_match_host_tags(&cmd->tags, tn))
+ if (merge_type == CONFIG_MERGE_TYPE_TAGS) {
+ /* Ignore tags section */
+ if (!strcmp(cn->key, "tags"))
continue;
+ /* If there's a tags node, skip if host tags don't match */
+ if ((tn = dm_config_find_node(cn->child, "tags"))) {
+ if (!_match_host_tags(&cmd->tags, tn))
+ continue;
+ }
}
if (!(oldn = dm_config_find_node(root, cn->key))) {
_insert_config_node(&cft->root, cn);
- /* Remove any "tags" nodes */
- for (cn2 = cn->child; cn2; cn2 = cn2->sib) {
- if (!strcmp(cn2->key, "tags")) {
- cn->child = cn2->sib;
- continue;
- }
- if (cn2->sib && !strcmp(cn2->sib->key, "tags")) {
- cn2->sib = cn2->sib->sib;
- continue;
+ if (merge_type == CONFIG_MERGE_TYPE_TAGS) {
+ /* Remove any "tags" nodes */
+ for (cn2 = cn->child; cn2; cn2 = cn2->sib) {
+ if (!strcmp(cn2->key, "tags")) {
+ cn->child = cn2->sib;
+ continue;
+ }
+ if (cn2->sib && !strcmp(cn2->sib->key, "tags")) {
+ cn2->sib = cn2->sib->sib;
+ continue;
+ }
}
}
continue;
}
- _merge_section(oldn, cn);
+ _merge_section(oldn, cn, merge_type);
}
/*
diff --git a/lib/config/config.h b/lib/config/config.h
index 9f54af6..94fd1d9 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -173,8 +173,19 @@ int config_file_changed(struct dm_config_tree *cft);
int config_file_check(struct dm_config_tree *cft, const char **filename, struct stat *info);
+typedef enum {
+ CONFIG_MERGE_TYPE_RAW, /* always replace old config values with new config values when merging */
+ CONFIG_MERGE_TYPE_TAGS /* apply some exceptions when merging tag configs:
+ - skip tags section
+ - do not replace, but merge values of these settings:
+ activation/volume_list
+ devices/filter
+ devices/types
+ */
+} config_merge_t;
+
int merge_config_tree(struct cmd_context *cmd, struct dm_config_tree *cft,
- struct dm_config_tree *newdata);
+ struct dm_config_tree *newdata, config_merge_t);
/*
* These versions check an override tree, if present, first.
10 years, 10 months
master - config: fix use of last config check status if creating CFG_DEF_TREE_MISSING tree
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=661406a417e3cb...
Commit: 661406a417e3cbf2170ba7c3debd767d50e99cae
Parent: f5584d420356c8ca0b797952b07f5b5387957c17
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jul 8 14:13:09 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jul 8 15:57:49 2013 +0200
config: fix use of last config check status if creating CFG_DEF_TREE_MISSING tree
When CFG_DEF_TREE_MISSING is created, it needs to know the status
of the check done on the tree used (the CFG_USED flag).
This bug was introduced with f1c292cc38f4ba2e8d9b7272bc1a1ce17bd729a5
"make it possible to run several instances of configuration check at
once". This patch separated the CFG_USED and CFG_VALID flags in
a separate 'status' field in struct cft_check_handle.
However, when creating some trees, like CFG_DEF_TREE_MISSING,
we need this status to do a comparison with full config definition
to determine which items are missing and for which default values
were used. Otherwise, all items would be considered missing.
So, pass this status in a new field called 'check_status' in
struct config_def_tree_spec that defines how the (dumpconfig) tree
should be constructed (and this struct is passed to
config_def_create_tree fn then).
---
lib/config/config.c | 15 +++++++++++----
lib/config/config.h | 1 +
tools/dumpconfig.c | 47 +++++++++++++++++++++++++++++++++--------------
3 files changed, 45 insertions(+), 18 deletions(-)
diff --git a/lib/config/config.c b/lib/config/config.c
index 61e92cf..26b2aa8 100644
--- a/lib/config/config.c
+++ b/lib/config/config.c
@@ -1336,8 +1336,10 @@ static struct dm_config_node *_add_def_node(struct dm_config_tree *cft,
return cn;
}
-static int _should_skip_def_node(struct config_def_tree_spec *spec, int section_id, cfg_def_item_t *def)
+static int _should_skip_def_node(struct config_def_tree_spec *spec, int section_id, int id)
{
+ cfg_def_item_t *def = cfg_def_get_item_p(id);
+
if ((def->parent != section_id) ||
(spec->ignoreadvanced && def->flags & CFG_ADVANCED) ||
(spec->ignoreunsupported && def->flags & CFG_UNSUPPORTED))
@@ -1345,7 +1347,12 @@ static int _should_skip_def_node(struct config_def_tree_spec *spec, int section_
switch (spec->type) {
case CFG_DEF_TREE_MISSING:
- if ((def->flags & CFG_USED) ||
+ if (!spec->check_status) {
+ log_error_once(INTERNAL_ERROR "couldn't determine missing "
+ "config nodes - unknown status of last config check.");
+ return 1;
+ }
+ if ((spec->check_status[id] & CFG_USED) ||
(def->flags & CFG_NAME_VARIABLE) ||
(def->since_version > spec->version))
return 1;
@@ -1374,13 +1381,13 @@ static struct dm_config_node *_add_def_section_subtree(struct dm_config_tree *cf
int id;
for (id = 0; id < CFG_COUNT; id++) {
- def = cfg_def_get_item_p(id);
- if (_should_skip_def_node(spec, section_id, def))
+ if (_should_skip_def_node(spec, section_id, id))
continue;
if (!cn && !(cn = _add_def_node(cft, spec, parent, relay, cfg_def_get_item_p(section_id))))
goto bad;
+ def = cfg_def_get_item_p(id);
if ((tmp = def->type == CFG_TYPE_SECTION ? _add_def_section_subtree(cft, spec, cn, relay_sub, id)
: _add_def_node(cft, spec, cn, relay_sub, def)))
relay_sub = tmp;
diff --git a/lib/config/config.h b/lib/config/config.h
index 5109a23..9f54af6 100644
--- a/lib/config/config.h
+++ b/lib/config/config.h
@@ -110,6 +110,7 @@ struct config_def_tree_spec {
uint16_t version; /* tree at this LVM2 version */
int ignoreadvanced; /* do not include advanced configs */
int ignoreunsupported; /* do not include unsupported configs */
+ uint8_t *check_status; /* status of last tree check (currently needed for CFG_DEF_TREE_MISSING only) */
};
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c
index ebee786..3839def 100644
--- a/tools/dumpconfig.c
+++ b/tools/dumpconfig.c
@@ -45,13 +45,30 @@ static struct cft_check_handle *_get_cft_check_handle(struct cmd_context *cmd)
return handle;
}
+static int _do_def_check(struct cmd_context *cmd, struct cft_check_handle **cft_check_handle)
+{
+ struct cft_check_handle *handle;
+
+ if (!(handle = _get_cft_check_handle(cmd)))
+ return 0;
+
+ handle->force_check = 1;
+ handle->skip_if_checked = 1;
+ handle->suppress_messages = 1;
+
+ config_def_check(cmd, handle);
+ *cft_check_handle = handle;
+
+ return 1;
+}
+
int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
{
const char *file = arg_str_value(cmd, file_ARG, NULL);
const char *type = arg_str_value(cmd, configtype_ARG, "current");
struct config_def_tree_spec tree_spec = {0};
struct dm_config_tree *cft = NULL;
- struct cft_check_handle *cft_check_handle;
+ struct cft_check_handle *cft_check_handle = NULL;
int r = ECMD_PROCESSED;
if (arg_count(cmd, configtype_ARG) && arg_count(cmd, validate_ARG)) {
@@ -105,29 +122,31 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
if (!strcmp(type, "current")) {
tree_spec.type = CFG_DEF_TREE_CURRENT;
-
- if (!(cft_check_handle = _get_cft_check_handle(cmd)))
+ if (!_do_def_check(cmd, &cft_check_handle))
return ECMD_FAILED;
-
- cft_check_handle->force_check = 1;
- cft_check_handle->skip_if_checked = 1;
- cft_check_handle->suppress_messages = 1;
-
- config_def_check(cmd, cft_check_handle);
}
-
- else if (!strcmp(type, "default"))
- tree_spec.type = CFG_DEF_TREE_DEFAULT;
- else if (!strcmp(type, "missing"))
+ else if (!strcmp(type, "missing")) {
tree_spec.type = CFG_DEF_TREE_MISSING;
- else if (!strcmp(type, "new"))
+ if (!_do_def_check(cmd, &cft_check_handle))
+ return ECMD_FAILED;
+ }
+ else if (!strcmp(type, "default")) {
+ tree_spec.type = CFG_DEF_TREE_DEFAULT;
+ /* default type does not require check status */
+ }
+ else if (!strcmp(type, "new")) {
tree_spec.type = CFG_DEF_TREE_NEW;
+ /* new type does not require check status */
+ }
else {
log_error("Incorrect type of configuration specified. "
"Expected one of: current, default, missing, new.");
return EINVALID_CMD_LINE;
}
+ if (cft_check_handle)
+ tree_spec.check_status = cft_check_handle->status;
+
if (tree_spec.type == CFG_DEF_TREE_CURRENT)
cft = cmd->cft;
else
10 years, 10 months
master - cleanup: cleanup dumpconfig code
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f5584d420356c8...
Commit: f5584d420356c8ca0b797952b07f5b5387957c17
Parent: 985251c8f385d2611dde44d1bf6824223f073749
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jul 8 13:45:37 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Mon Jul 8 15:46:19 2013 +0200
cleanup: cleanup dumpconfig code
---
tools/dumpconfig.c | 57 ++++++++++++++++++++++++++++-----------------------
1 files changed, 31 insertions(+), 26 deletions(-)
diff --git a/tools/dumpconfig.c b/tools/dumpconfig.c
index 2d6cbe3..ebee786 100644
--- a/tools/dumpconfig.c
+++ b/tools/dumpconfig.c
@@ -15,19 +15,17 @@
#include "tools.h"
-static int _get_vsn(struct cmd_context *cmd, unsigned int *major,
- unsigned int *minor, unsigned int *patchlevel)
+static int _get_vsn(struct cmd_context *cmd, uint16_t *version)
{
- const char *atversion = arg_str_value(cmd, atversion_ARG, NULL);
-
- if (!atversion)
- atversion = LVM_VERSION;
+ const char *atversion = arg_str_value(cmd, atversion_ARG, LVM_VERSION);
+ unsigned int major, minor, patchlevel;
- if (sscanf(atversion, "%u.%u.%u", major, minor, patchlevel) != 3) {
+ if (sscanf(atversion, "%u.%u.%u", &major, &minor, &patchlevel) != 3) {
log_error("Incorrect version format.");
return 0;
}
+ *version = vsn(major, minor, patchlevel);
return 1;
}
@@ -51,9 +49,8 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
{
const char *file = arg_str_value(cmd, file_ARG, NULL);
const char *type = arg_str_value(cmd, configtype_ARG, "current");
- unsigned int major, minor, patchlevel;
struct config_def_tree_spec tree_spec = {0};
- struct dm_config_tree *cft = cmd->cft;
+ struct dm_config_tree *cft = NULL;
struct cft_check_handle *cft_check_handle;
int r = ECMD_PROCESSED;
@@ -73,6 +70,22 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
if (arg_count(cmd, ignoreunsupported_ARG))
tree_spec.ignoreunsupported = 1;
+ if (!strcmp(type, "current")) {
+ if (arg_count(cmd, atversion_ARG)) {
+ log_error("--atversion has no effect with --type current");
+ return EINVALID_CMD_LINE;
+ }
+
+ if ((tree_spec.ignoreadvanced || tree_spec.ignoreunsupported)) {
+ log_error("--ignoreadvanced and --ignoreunsupported has "
+ "no effect with --type current");
+ return EINVALID_CMD_LINE;
+ }
+ }
+
+ if (!_get_vsn(cmd, &tree_spec.version))
+ return EINVALID_CMD_LINE;
+
if (arg_count(cmd, validate_ARG)) {
if (!(cft_check_handle = _get_cft_check_handle(cmd)))
return ECMD_FAILED;
@@ -91,10 +104,6 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
}
if (!strcmp(type, "current")) {
- if (arg_count(cmd, atversion_ARG)) {
- log_error("--atversion has no effect with --type current");
- return EINVALID_CMD_LINE;
- }
tree_spec.type = CFG_DEF_TREE_CURRENT;
if (!(cft_check_handle = _get_cft_check_handle(cmd)))
@@ -119,18 +128,10 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- if ((tree_spec.ignoreadvanced || tree_spec.ignoreunsupported) &&
- (tree_spec.type == CFG_DEF_TREE_CURRENT)) {
- log_error("--ignoreadvanced and --ignoreunsupported has no effect with --type current");
- return EINVALID_CMD_LINE;
- }
-
- if (tree_spec.type != CFG_DEF_TREE_CURRENT) {
- if (!_get_vsn(cmd, &major, &minor, &patchlevel))
- return EINVALID_CMD_LINE;
- tree_spec.version = vsn(major, minor, patchlevel);
+ if (tree_spec.type == CFG_DEF_TREE_CURRENT)
+ cft = cmd->cft;
+ else
cft = config_def_create_tree(&tree_spec);
- }
if (!config_write(cft, arg_count(cmd, withcomments_ARG),
arg_count(cmd, withversions_ARG),
@@ -139,9 +140,13 @@ int dumpconfig(struct cmd_context *cmd, int argc, char **argv)
r = ECMD_FAILED;
}
- /* cmd->cft (the "current" tree) is destroyed with cmd context destroy! */
- if (tree_spec.type != CFG_DEF_TREE_CURRENT && cft)
+ if (cft != cmd->cft)
dm_pool_destroy(cft->mem);
+ /*
+ * The cmd->cft (the "current" tree) is destroyed
+ * together with cmd context destroy...
+ */
+
return r;
}
10 years, 10 months
master - locking: unlock memory on error path
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=985251c8f385d2...
Commit: 985251c8f385d2611dde44d1bf6824223f073749
Parent: edf5cae6799549827d4031f472451bd96d2f0f47
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Jul 6 10:58:56 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 8 14:02:49 2013 +0200
locking: unlock memory on error path
Unlock memory and unblock signals on error path.
---
WHATS_NEW | 1 +
lib/locking/locking.c | 8 ++++----
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index e389a36..567441a 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Relase memory and unblock signals in lock_vol error path.
Define LVM2_* command errors in lvm2cmd.h and use in dmeventd plugins.
Move errors.h to tools dir.
Add man page entries for profile configuration and related options.
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index 34e8bd9..9183ee6 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -368,18 +368,18 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource,
if (!*resource) {
log_error(INTERNAL_ERROR "Use of P_orphans is deprecated.");
- return 0;
+ goto out;
}
if ((is_orphan_vg(resource) || is_global_vg(resource)) && (flags & LCK_CACHE)) {
log_error(INTERNAL_ERROR "P_%s referenced", resource);
- return 0;
+ goto out;
}
if (cmd->metadata_read_only && lck_type == LCK_WRITE &&
strcmp(resource, VG_GLOBAL)) {
log_error("Operation prohibited while global/metadata_read_only is set.");
- return 0;
+ goto out;
}
if ((ret = _locking.lock_resource(cmd, resource, flags, lv))) {
@@ -399,7 +399,7 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource,
if (!ret)
_update_vg_lock_count(resource, flags);
}
-
+out:
_unlock_memory(cmd, lv_op);
_unblock_signals();
10 years, 10 months
master - pvremove: stack trace
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=edf5cae6799549...
Commit: edf5cae6799549827d4031f472451bd96d2f0f47
Parent: ccf3dd60f2a486f8ac1b9788ca6378b1dc88827d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Jul 6 14:15:42 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 8 14:01:41 2013 +0200
pvremove: stack trace
Stack trace error.
Remove unused var.
---
tools/pvremove.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/tools/pvremove.c b/tools/pvremove.c
index 45c675e..7048b97 100644
--- a/tools/pvremove.c
+++ b/tools/pvremove.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -18,7 +18,7 @@
int pvremove(struct cmd_context *cmd, int argc, char **argv)
{
- int i, r;
+ int i;
int ret = ECMD_PROCESSED;
unsigned force_count;
unsigned prompt;
@@ -33,8 +33,10 @@ int pvremove(struct cmd_context *cmd, int argc, char **argv)
for (i = 0; i < argc; i++) {
dm_unescape_colons_and_at_signs(argv[i], NULL, NULL);
- if (!pvremove_single(cmd, argv[i], NULL, force_count, prompt))
+ if (!pvremove_single(cmd, argv[i], NULL, force_count, prompt)) {
+ stack;
ret = ECMD_FAILED;
+ }
}
return ret;
10 years, 10 months