master - RAID: Fix segfault when reporting raid_syncaction field on older kernel
by Jonathan Brassow
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4eea66019157ab...
Commit: 4eea66019157abd992c8802564b675fd97420c01
Parent: f0ab6c33a9475502ea8af1cf54addba68f97428f
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Fri Jul 19 10:01:48 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Fri Jul 19 10:01:48 2013 -0500
RAID: Fix segfault when reporting raid_syncaction field on older kernel
The status printed for dm-raid targets on older kernels does not include
the syncaction field. This is handled by dev_manager_raid_status() just
fine by populating the raid status structure with NULL for that field.
However, lv_raid_sync_action() does not properly handle that field being
NULL. So, check for it and return 0 if it is NULL.
---
WHATS_NEW | 1 +
lib/activate/activate.c | 2 ++
2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0b96df0..46d7d23 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Fix segfault when reporting raid_syncaction for older kernels.
Add LV reporting fields raid_mismatch_count, raid_sync_action, raid_write_behind.
Add LV reporting fields raid_min_recovery_rate, raid_max_recovery_rate.
Add sync_percent as alias for copy_percent LV reporting field.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 204cceb..61dbc02 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -874,7 +874,9 @@ int lv_raid_sync_action(const struct logical_volume *lv, char **sync_action)
if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
return_0;
+ /* status->sync_action can be NULL if dm-raid version < 1.5.0 */
if (!dev_manager_raid_status(dm, lv, &status) ||
+ !status->sync_action ||
!(action = dm_pool_strdup(lv->vg->cmd->mem,
status->sync_action))) {
dev_manager_destroy(dm);
9 years, 8 months
master - dev-type: dev_get_primary_dev default error code 0, not -1
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f0ab6c33a94755...
Commit: f0ab6c33a9475502ea8af1cf54addba68f97428f
Parent: da79fe4c1db8936667954403e6f690df464fc638
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Jul 19 15:26:53 2013 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Jul 19 15:26:53 2013 +0200
dev-type: dev_get_primary_dev default error code 0, not -1
---
lib/device/dev-type.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index 642ee27..11f0407 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -349,7 +349,7 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
char buffer[64];
struct stat info;
FILE *fp = NULL;
- int parts, residue, size, ret = -1;
+ int parts, residue, size, ret = 0;
/*
* Try to get the primary dev out of the
@@ -384,7 +384,8 @@ int dev_get_primary_dev(struct dev_types *dt, struct device *dev, dev_t *result)
if (errno != ENOENT)
log_sys_error("stat", path);
*result = dev->dev;
- ret = 1; goto out; /* dev is not a partition! */
+ ret = 1;
+ goto out; /* dev is not a partition! */
}
9 years, 8 months
master - reporting: tidy recent new fields
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=da79fe4c1db893...
Commit: da79fe4c1db8936667954403e6f690df464fc638
Parent: 1a005b40a4ce9cc1f54a564f8f74917935cb35c4
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Jul 19 01:30:02 2013 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Jul 19 01:30:02 2013 +0100
reporting: tidy recent new fields
Add underscores and prefixes to recently-added fields.
(Might add more alias functionality in future.)
---
WHATS_NEW | 4 +++
lib/report/columns.h | 33 +++++++++++++++++++-----------
lib/report/properties.c | 46 +++++++++++++++++++++---------------------
lib/report/report.c | 10 ++++----
test/shell/lvchange-raid.sh | 16 +++++++-------
5 files changed, 61 insertions(+), 48 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9102613..0b96df0 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,9 @@
Version 2.02.99 -
===================================
+ Add LV reporting fields raid_mismatch_count, raid_sync_action, raid_write_behind.
+ Add LV reporting fields raid_min_recovery_rate, raid_max_recovery_rate.
+ Add sync_percent as alias for copy_percent LV reporting field.
+ Add lv_ prefix to modules reporting field.
Use units B or b (never E) with no decimal places when displaying sizes < 1k.
Add support for poolmetadataspare LV, that will be used for pool recovery.
Improve activation order when creating thin pools in non-clustered VG.
diff --git a/lib/report/columns.h b/lib/report/columns.h
index 4c0bca2..9bb99d3 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -16,6 +16,15 @@
/*
* This file defines the fields (columns) for the reporting commands
* (pvs/vgs/lvs).
+ *
+ * The preferred order of the field descriptions in the help text
+ * determines the order the entries appear in this file.
+ *
+ * When adding new entries take care to use the existing style.
+ * Displayed fields names normally have a type prefix and use underscores.
+ * Field-specific internal functions names normally match the displayed
+ * field names but without underscores.
+ * Help text ends with a full stop.
*/
/* *INDENT-OFF* */
@@ -23,6 +32,7 @@ FIELD(LVS, lv, STR, "LV UUID", lvid.id[1], 38, uuid, lv_uuid, "Unique identifier
FIELD(LVS, lv, STR, "LV", lvid, 4, lvname, lv_name, "Name. LVs created for internal use are enclosed in brackets.", 0)
FIELD(LVS, lv, STR, "Path", lvid, 4, lvpath, lv_path, "Full pathname for LV.", 0)
FIELD(LVS, lv, STR, "Attr", lvid, 4, lvstatus, lv_attr, "Various attributes - see man page.", 0)
+FIELD(LVS, lv, STR, "Active", lvid, 6, lvactive, lv_active, "Active state of the LV.", 0)
FIELD(LVS, lv, NUM, "Maj", major, 3, int32, lv_major, "Persistent major number or -1 if not persistent.", 0)
FIELD(LVS, lv, NUM, "Min", minor, 3, int32, lv_minor, "Persistent minor number or -1 if not persistent.", 0)
FIELD(LVS, lv, NUM, "Rahead", lvid, 6, lvreadahead, lv_read_ahead, "Read ahead setting in current units.", 0)
@@ -39,23 +49,22 @@ FIELD(LVS, lv, NUM, "Snap%", lvid, 6, snpercent, snap_percent, "For snapshots, t
FIELD(LVS, lv, NUM, "Meta%", lvid, 6, metadatapercent, metadata_percent, "For thin pools, the percentage of metadata full if LV is active.", 0)
FIELD(LVS, lv, NUM, "Cpy%Sync", lvid, 8, copypercent, copy_percent, "For RAID, mirrors and pvmove, current percentage in-sync.", 0)
FIELD(LVS, lv, NUM, "Cpy%Sync", lvid, 8, copypercent, sync_percent, "For RAID, mirrors and pvmove, current percentage in-sync.", 0)
-FIELD(LVS, lv, NUM, "Mismatches", lvid, 10, mismatch_count, mismatches, "For RAID, number of mismatches found or repaired.", 0)
-FIELD(LVS, lv, STR, "SyncAction", lvid, 10, sync_action, syncaction, "For RAID, the current synchronization action being performed.", 0)
-FIELD(LVS, lv, NUM, "WBehind", lvid, 7, write_behind, writebehind, "For RAID1, the number of outstanding writes allowed to writemostly devices.", 0)
-FIELD(LVS, lv, NUM, "MinSync", lvid, 7, min_recovery_rate, minrecoveryrate, "For RAID1, the minimum recovery I/O load in kiB/sec/disk.", 0)
-FIELD(LVS, lv, NUM, "MaxSync", lvid, 7, max_recovery_rate, maxrecoveryrate, "For RAID1, the maximum recovery I/O load in kiB/sec/disk.", 0)
+FIELD(LVS, lv, NUM, "Mismatches", lvid, 10, raidmismatchcount, raid_mismatch_count, "For RAID, number of mismatches found or repaired.", 0)
+FIELD(LVS, lv, STR, "SyncAction", lvid, 10, raidsyncaction, raid_sync_action, "For RAID, the current synchronization action being performed.", 0)
+FIELD(LVS, lv, NUM, "WBehind", lvid, 7, raidwritebehind, raid_write_behind, "For RAID1, the number of outstanding writes allowed to writemostly devices.", 0)
+FIELD(LVS, lv, NUM, "MinSync", lvid, 7, raidminrecoveryrate, raid_min_recovery_rate, "For RAID1, the minimum recovery I/O load in kiB/sec/disk.", 0)
+FIELD(LVS, lv, NUM, "MaxSync", lvid, 7, raidmaxrecoveryrate, raid_max_recovery_rate, "For RAID1, the maximum recovery I/O load in kiB/sec/disk.", 0)
FIELD(LVS, lv, STR, "Move", lvid, 4, movepv, move_pv, "For pvmove, Source PV of temporary LV created by pvmove.", 0)
FIELD(LVS, lv, STR, "Convert", lvid, 7, convertlv, convert_lv, "For lvconvert, Name of temporary LV created by lvconvert.", 0)
FIELD(LVS, lv, STR, "Log", lvid, 3, loglv, mirror_log, "For mirrors, the LV holding the synchronisation log.", 0)
FIELD(LVS, lv, STR, "Data", lvid, 4, datalv, data_lv, "For thin pools, the LV holding the associated data.", 0)
FIELD(LVS, lv, STR, "Meta", lvid, 4, metadatalv, metadata_lv, "For thin pools, the LV holding the associated metadata.", 0)
FIELD(LVS, lv, STR, "Pool", lvid, 4, poollv, pool_lv, "For thin volumes, the thin pool LV for this volume.", 0)
-FIELD(LVS, lv, STR, "Active", lvid, 6, lvactive, lv_active, "Active state of the LV.", 0)
FIELD(LVS, lv, STR, "LV Tags", tags, 7, tags, lv_tags, "Tags, if any.", 0)
+FIELD(LVS, lv, STR, "LProfile", lvid, 8, lvprofile, lv_profile, "Configuration profile attached to this LV.", 0)
FIELD(LVS, lv, STR, "Time", lvid, 26, lvtime, lv_time, "Creation time of the LV, if known", 0)
FIELD(LVS, lv, STR, "Host", lvid, 10, lvhost, lv_host, "Creation host of the LV, if known.", 0)
-FIELD(LVS, lv, STR, "Modules", lvid, 7, modules, modules, "Kernel device-mapper modules required for this LV.", 0)
-FIELD(LVS, lv, STR, "LProfile", lvid, 8, lvprofile, lv_profile, "Configuration profile attached to this LV", 0)
+FIELD(LVS, lv, STR, "Modules", lvid, 7, modules, lv_modules, "Kernel device-mapper modules required for this LV.", 0)
FIELD(LABEL, pv, STR, "Fmt", id, 3, pvfmt, pv_fmt, "Type of metadata.", 0)
FIELD(LABEL, pv, STR, "PV UUID", id, 38, uuid, pv_uuid, "Unique identifier.", 0)
@@ -74,8 +83,8 @@ FIELD(PVS, pv, NUM, "Alloc", pe_alloc_count, 5, uint32, pv_pe_alloc_count, "Tota
FIELD(PVS, pv, STR, "PV Tags", tags, 7, tags, pv_tags, "Tags, if any.", 0)
FIELD(PVS, pv, NUM, "#PMda", id, 5, pvmdas, pv_mda_count, "Number of metadata areas on this device.", 0)
FIELD(PVS, pv, NUM, "#PMdaUse", id, 8, pvmdasused, pv_mda_used_count, "Number of metadata areas in use on this device.", 0)
-FIELD(PVS, pv, NUM, "BA start", ba_start, 8, size64, ba_start, "Offset to the start of PV Bootloader Area on the underlying device.", 0)
-FIELD(PVS, pv, NUM, "BA size", ba_size, 7, size64, ba_size, "Size of PV Bootloader Area in current units.", 0)
+FIELD(PVS, pv, NUM, "BA start", ba_start, 8, size64, pv_ba_start, "Offset to the start of PV Bootloader Area on the underlying device in current units.", 0)
+FIELD(PVS, pv, NUM, "BA size", ba_size, 7, size64, pv_ba_size, "Size of PV Bootloader Area in current units.", 0)
FIELD(VGS, vg, STR, "Fmt", cmd, 3, vgfmt, vg_fmt, "Type of metadata.", 0)
FIELD(VGS, vg, STR, "VG UUID", id, 38, uuid, vg_uuid, "Unique identifier.", 0)
@@ -94,12 +103,12 @@ FIELD(VGS, vg, NUM, "#LV", cmd, 3, lvcount, lv_count, "Number of LVs.", 0)
FIELD(VGS, vg, NUM, "#SN", cmd, 3, snapcount, snap_count, "Number of snapshots.", 0)
FIELD(VGS, vg, NUM, "Seq", seqno, 3, uint32, vg_seqno, "Revision number of internal metadata. Incremented whenever it changes.", 0)
FIELD(VGS, vg, STR, "VG Tags", tags, 7, tags, vg_tags, "Tags, if any.", 0)
+FIELD(VGS, vg, STR, "VProfile", cmd, 8, vgprofile, vg_profile, "Configuration profile attached to this VG.", 0)
FIELD(VGS, vg, NUM, "#VMda", cmd, 5, vgmdas, vg_mda_count, "Number of metadata areas on this VG.", 0)
FIELD(VGS, vg, NUM, "#VMdaUse", cmd, 8, vgmdasused, vg_mda_used_count, "Number of metadata areas in use on this VG.", 0)
FIELD(VGS, vg, NUM, "VMdaFree", cmd, 9, vgmdafree, vg_mda_free, "Free metadata area space for this VG in current units.", 0)
FIELD(VGS, vg, NUM, "VMdaSize", cmd, 9, vgmdasize, vg_mda_size, "Size of smallest metadata area for this VG in current units.", 0)
FIELD(VGS, vg, NUM, "#VMdaCps", cmd, 8, vgmdacopies, vg_mda_copies, "Target number of in use metadata areas in the VG.", 1)
-FIELD(VGS, vg, STR, "VProfile", cmd, 8, vgprofile, vg_profile, "Configuration profile attached to this VG", 0)
FIELD(SEGS, seg, STR, "Type", list, 4, segtype, segtype, "Type of LV segment.", 0)
FIELD(SEGS, seg, NUM, "#Str", area_count, 4, uint32, stripes, "Number of stripes or mirror legs.", 0)
@@ -119,7 +128,7 @@ FIELD(SEGS, seg, NUM, "SSize", list, 5, segsize, seg_size, "Size of segment in c
FIELD(SEGS, seg, STR, "Seg Tags", tags, 8, tags, seg_tags, "Tags, if any.", 0)
FIELD(SEGS, seg, STR, "PE Ranges", list, 9, peranges, seg_pe_ranges, "Ranges of Physical Extents of underlying devices in command line format.", 0)
FIELD(SEGS, seg, STR, "Devices", list, 7, devices, devices, "Underlying devices used with starting extent numbers.", 0)
-FIELD(SEGS, seg, STR, "Monitor", list, 7, segmonitor, monitor, "Dmeventd monitoring status of the segment.", 0)
+FIELD(SEGS, seg, STR, "Monitor", list, 7, segmonitor, seg_monitor, "Dmeventd monitoring status of the segment.", 0)
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)
diff --git a/lib/report/properties.c b/lib/report/properties.c
index a4832af..3eeb78a 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -58,7 +58,7 @@ static percent_t _copy_percent(const struct logical_volume *lv)
return percent;
}
-static uint64_t _mismatches(const struct logical_volume *lv)
+static uint64_t _raidmismatchcount(const struct logical_volume *lv)
{
uint64_t cnt;
@@ -67,7 +67,7 @@ static uint64_t _mismatches(const struct logical_volume *lv)
return cnt;
}
-static char *_sync_action(const struct logical_volume *lv)
+static char *_raidsyncaction(const struct logical_volume *lv)
{
char *action;
@@ -77,17 +77,17 @@ static char *_sync_action(const struct logical_volume *lv)
return action;
}
-static uint32_t _writebehind(const struct logical_volume *lv)
+static uint32_t _raidwritebehind(const struct logical_volume *lv)
{
return first_seg(lv)->writebehind;
}
-static uint32_t _minrecoveryrate(const struct logical_volume *lv)
+static uint32_t _raidminrecoveryrate(const struct logical_volume *lv)
{
return first_seg(lv)->min_recovery_rate;
}
-static uint32_t _maxrecoveryrate(const struct logical_volume *lv)
+static uint32_t _raidmaxrecoveryrate(const struct logical_volume *lv)
{
return first_seg(lv)->max_recovery_rate;
}
@@ -155,10 +155,10 @@ GET_PV_NUM_PROPERTY_FN(pv_mda_count, pv_mda_count(pv))
#define _pv_mda_count_set prop_not_implemented_set
GET_PV_NUM_PROPERTY_FN(pv_mda_used_count, pv_mda_used_count(pv))
#define _pv_mda_used_count_set prop_not_implemented_set
-GET_PV_NUM_PROPERTY_FN(ba_start, SECTOR_SIZE * pv->ba_start)
-#define _ba_start_set prop_not_implemented_set
-GET_PV_NUM_PROPERTY_FN(ba_size, SECTOR_SIZE * pv->ba_size)
-#define _ba_size_set prop_not_implemented_set
+GET_PV_NUM_PROPERTY_FN(pv_ba_start, SECTOR_SIZE * pv->ba_start)
+#define _pv_ba_start_set prop_not_implemented_set
+GET_PV_NUM_PROPERTY_FN(pv_ba_size, SECTOR_SIZE * pv->ba_size)
+#define _pv_ba_size_set prop_not_implemented_set
/* LV */
GET_LV_STR_PROPERTY_FN(lv_uuid, lv_uuid_dup(lv))
@@ -195,16 +195,16 @@ GET_LV_NUM_PROPERTY_FN(copy_percent, _copy_percent(lv))
#define _copy_percent_set prop_not_implemented_set
GET_LV_NUM_PROPERTY_FN(sync_percent, _copy_percent(lv))
#define _sync_percent_set prop_not_implemented_set
-GET_LV_NUM_PROPERTY_FN(mismatches, _mismatches(lv))
-#define _mismatches_set prop_not_implemented_set
-GET_LV_NUM_PROPERTY_FN(writebehind, _writebehind(lv))
-#define _writebehind_set prop_not_implemented_set
-GET_LV_NUM_PROPERTY_FN(minrecoveryrate, _minrecoveryrate(lv))
-#define _minrecoveryrate_set prop_not_implemented_set
-GET_LV_NUM_PROPERTY_FN(maxrecoveryrate, _maxrecoveryrate(lv))
-#define _maxrecoveryrate_set prop_not_implemented_set
-GET_LV_STR_PROPERTY_FN(syncaction, _sync_action(lv))
-#define _syncaction_set prop_not_implemented_set
+GET_LV_NUM_PROPERTY_FN(raid_mismatch_count, _raidmismatchcount(lv))
+#define _raid_mismatch_count_set prop_not_implemented_set
+GET_LV_NUM_PROPERTY_FN(raid_write_behind, _raidwritebehind(lv))
+#define _raid_write_behind_set prop_not_implemented_set
+GET_LV_NUM_PROPERTY_FN(raid_min_recovery_rate, _raidminrecoveryrate(lv))
+#define _raid_min_recovery_rate_set prop_not_implemented_set
+GET_LV_NUM_PROPERTY_FN(raid_max_recovery_rate, _raidmaxrecoveryrate(lv))
+#define _raid_max_recovery_rate_set prop_not_implemented_set
+GET_LV_STR_PROPERTY_FN(raid_sync_action, _raidsyncaction(lv))
+#define _raid_sync_action_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(move_pv, lv_move_pv_dup(lv->vg->vgmem, lv))
#define _move_pv_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(convert_lv, lv_convert_lv_dup(lv->vg->vgmem, lv))
@@ -213,8 +213,8 @@ GET_LV_STR_PROPERTY_FN(lv_tags, lv_tags_dup(lv))
#define _lv_tags_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(mirror_log, lv_mirror_log_dup(lv->vg->vgmem, lv))
#define _mirror_log_set prop_not_implemented_set
-GET_LV_STR_PROPERTY_FN(modules, lv_modules_dup(lv->vg->vgmem, lv))
-#define _modules_set prop_not_implemented_set
+GET_LV_STR_PROPERTY_FN(lv_modules, lv_modules_dup(lv->vg->vgmem, lv))
+#define _lv_modules_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(data_lv, lv_data_lv_dup(lv->vg->vgmem, lv))
#define _data_lv_set prop_not_implemented_set
GET_LV_STR_PROPERTY_FN(metadata_lv, lv_metadata_lv_dup(lv->vg->vgmem, lv))
@@ -322,8 +322,8 @@ GET_LVSEG_STR_PROPERTY_FN(seg_pe_ranges,
#define _seg_pe_ranges_set prop_not_implemented_set
GET_LVSEG_STR_PROPERTY_FN(devices, lvseg_devices(lvseg->lv->vg->vgmem, lvseg))
#define _devices_set prop_not_implemented_set
-GET_LVSEG_STR_PROPERTY_FN(monitor, lvseg_monitor_dup(lvseg->lv->vg->vgmem, lvseg))
-#define _monitor_set prop_not_implemented_set
+GET_LVSEG_STR_PROPERTY_FN(seg_monitor, lvseg_monitor_dup(lvseg->lv->vg->vgmem, lvseg))
+#define _seg_monitor_set prop_not_implemented_set
/* PVSEG */
GET_PVSEG_NUM_PROPERTY_FN(pvseg_start, pvseg->pe)
diff --git a/lib/report/report.c b/lib/report/report.c
index 8b5455b..77332a2 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -977,7 +977,7 @@ no_copypercent:
return 1;
}
-static int _sync_action_disp(struct dm_report *rh __attribute__((unused)),
+static int _raidsyncaction_disp(struct dm_report *rh __attribute__((unused)),
struct dm_pool *mem,
struct dm_report_field *field,
const void *data,
@@ -995,7 +995,7 @@ static int _sync_action_disp(struct dm_report *rh __attribute__((unused)),
return _string_disp(rh, mem, field, &sync_action, private);
}
-static int _mismatch_count_disp(struct dm_report *rh __attribute__((unused)),
+static int _raidmismatchcount_disp(struct dm_report *rh __attribute__((unused)),
struct dm_pool *mem,
struct dm_report_field *field,
const void *data,
@@ -1013,7 +1013,7 @@ static int _mismatch_count_disp(struct dm_report *rh __attribute__((unused)),
return dm_report_field_uint64(rh, field, &mismatch_count);
}
-static int _write_behind_disp(struct dm_report *rh __attribute__((unused)),
+static int _raidwritebehind_disp(struct dm_report *rh __attribute__((unused)),
struct dm_pool *mem,
struct dm_report_field *field,
const void *data,
@@ -1029,7 +1029,7 @@ static int _write_behind_disp(struct dm_report *rh __attribute__((unused)),
return dm_report_field_uint32(rh, field, &first_seg(lv)->writebehind);
}
-static int _min_recovery_rate_disp(struct dm_report *rh __attribute__((unused)),
+static int _raidminrecoveryrate_disp(struct dm_report *rh __attribute__((unused)),
struct dm_pool *mem,
struct dm_report_field *field,
const void *data,
@@ -1046,7 +1046,7 @@ static int _min_recovery_rate_disp(struct dm_report *rh __attribute__((unused)),
&first_seg(lv)->min_recovery_rate);
}
-static int _max_recovery_rate_disp(struct dm_report *rh __attribute__((unused)),
+static int _raidmaxrecoveryrate_disp(struct dm_report *rh __attribute__((unused)),
struct dm_pool *mem,
struct dm_report_field *field,
const void *data,
diff --git a/test/shell/lvchange-raid.sh b/test/shell/lvchange-raid.sh
index d7878a7..291928a 100644
--- a/test/shell/lvchange-raid.sh
+++ b/test/shell/lvchange-raid.sh
@@ -100,14 +100,14 @@ run_writemostly_check() {
not lvchange --writebehind -256 $1/$2
# Set writebehind
- [ ! `lvs --noheadings -o writebehind $1/$2` ]
+ [ ! `lvs --noheadings -o raid_write_behind $1/$2` ]
lvchange --writebehind 512 $1/$2
- [ `lvs --noheadings -o writebehind $1/$2` -eq 512 ]
+ [ `lvs --noheadings -o raid_write_behind $1/$2` -eq 512 ]
# Converting to linear should clear flags and writebehind
lvconvert -m 0 $1/$2 $d1
lvconvert --type raid1 -m 1 $1/$2 $d1
- [ ! `lvs --noheadings -o writebehind $1/$2` ]
+ [ ! `lvs --noheadings -o raid_write_behind $1/$2` ]
lvs -a --noheadings -o lv_attr $1/${2}_rimage_0 | grep '.*-.$'
lvs -a --noheadings -o lv_attr $1/${2}_rimage_1 | grep '.*-.$'
}
@@ -142,7 +142,7 @@ run_syncaction_check() {
# Check all is normal
if ! lvs --noheadings -o lv_attr $1/$2 | grep '.*-.$' ||
- [ `lvs --noheadings -o mismatches $1/$2` != 0 ]; then
+ [ `lvs --noheadings -o raid_mismatch_count $1/$2` != 0 ]; then
# I think this is a kernel bug. It happens randomly after
# a RAID device creation. I think the mismatch count
@@ -160,7 +160,7 @@ run_syncaction_check() {
fi
lvs --noheadings -o lv_attr $1/$2 | grep '.*-.$'
- [ `lvs --noheadings -o mismatches $1/$2` == 0 ]
+ [ `lvs --noheadings -o raid_mismatch_count $1/$2` == 0 ]
# Overwrite the last half of one of the PVs with crap
dd if=/dev/urandom of=$device bs=1k count=$size seek=$seek
@@ -174,20 +174,20 @@ run_syncaction_check() {
lvchange --syncaction check $1/$2
aux wait_for_sync $1 $2
lvs --noheadings -o lv_attr $1/$2 | grep '.*m.$'
- [ `lvs --noheadings -o mismatches $1/$2` != 0 ]
+ [ `lvs --noheadings -o raid_mismatch_count $1/$2` != 0 ]
# "repair" will fix discrepancies and record number fixed
lvchange --syncaction repair $1/$2
aux wait_for_sync $1 $2
lvs --noheadings -o lv_attr $1/$2 | grep '.*m.$'
- [ `lvs --noheadings -o mismatches $1/$2` != 0 ]
+ [ `lvs --noheadings -o raid_mismatch_count $1/$2` != 0 ]
# Final "check" should show no mismatches
# 'lvs' should show results
lvchange --syncaction check $1/$2
aux wait_for_sync $1 $2
lvs --noheadings -o lv_attr $1/$2 | grep '.*-.$'
- [ `lvs --noheadings -o mismatches $1/$2` == 0 ]
+ [ `lvs --noheadings -o raid_mismatch_count $1/$2` == 0 ]
}
# run_refresh_check <VG> <LV>
9 years, 8 months
master - python-lvm: Add call to close/re-open C lib.
by tasleson
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1a005b40a4ce9c...
Commit: 1a005b40a4ce9cc1f54a564f8f74917935cb35c4
Parent: 357df34133fae754eb25cf3c3a784b1905fc9291
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Thu Jul 18 16:53:43 2013 -0400
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Thu Jul 18 16:03:29 2013 -0500
python-lvm: Add call to close/re-open C lib.
As the library handle has a dm pool associated with
it for long running processes it is required to close and
re-open the library to free the dm pool. Call added so
python clients can reclaim memory, lvm.gc().
Note: Any python objects on the heap become invalid at the
time this call is made. If referenced, a seg. fault could
occur. No simple way to make this safe with the current
memory management in the C library. Use with caution!
Signed-off-by: Tony Asleson <tasleson(a)redhat.com>
---
python/liblvm.c | 25 +++++++++++++++++++++++--
1 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/python/liblvm.c b/python/liblvm.c
index cdeb4bf..8fa26ea 100644
--- a/python/liblvm.c
+++ b/python/liblvm.c
@@ -128,6 +128,24 @@ liblvm_library_get_version(void)
return Py_BuildValue("s", lvm_library_get_version());
}
+const static char gc_doc[] = "Garbage collect the C library";
+
+static PyObject *
+liblvm_lvm_gc(void)
+{
+ LVM_VALID();
+
+ lvm_quit(libh);
+ libh = lvm_init(NULL);
+
+ if (!libh) {
+ PyErr_SetObject(LibLVMError, liblvm_get_last_error());
+ return NULL;
+ }
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
static PyObject *
liblvm_lvm_list_vg_names(void)
{
@@ -1844,6 +1862,7 @@ liblvm_lvm_pvseg_get_property(pvsegobject *self, PyObject *args)
static PyMethodDef Liblvm_methods[] = {
/* LVM methods */
{ "getVersion", (PyCFunction)liblvm_library_get_version, METH_NOARGS },
+ { "gc", (PyCFunction)liblvm_lvm_gc, METH_NOARGS, gc_doc },
{ "vgOpen", (PyCFunction)liblvm_lvm_vg_open, METH_VARARGS },
{ "vgCreate", (PyCFunction)liblvm_lvm_vg_create, METH_VARARGS },
{ "configFindBool", (PyCFunction)liblvm_lvm_config_find_bool, METH_VARARGS },
@@ -2024,8 +2043,10 @@ static PyTypeObject LibLVMpvsegType = {
static void
liblvm_cleanup(void)
{
- lvm_quit(libh);
- libh = NULL;
+ if (libh) {
+ lvm_quit(libh);
+ libh = NULL;
+ }
}
PyMODINIT_FUNC
9 years, 8 months
master - display: fix units for sizes <1k
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=357df34133fae7...
Commit: 357df34133fae754eb25cf3c3a784b1905fc9291
Parent: ef3a1a0f8a7dc9656fa9269f08b36d1a9cb96d91
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Thu Jul 18 17:55:58 2013 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Jul 18 17:55:58 2013 +0100
display: fix units for sizes <1k
---
WHATS_NEW | 1 +
lib/display/display.c | 40 +++++++++++++++++++++-------------------
2 files changed, 22 insertions(+), 19 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index e87f781..9102613 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.99 -
===================================
+ Use units B or b (never E) with no decimal places when displaying sizes < 1k.
Add support for poolmetadataspare LV, that will be used for pool recovery.
Improve activation order when creating thin pools in non-clustered VG.
List thin-pool and thin modules for thin volumes.
diff --git a/lib/display/display.c b/lib/display/display.c
index 3f7f360..bf4b642 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -176,9 +176,9 @@ alloc_policy_t get_alloc_from_string(const char *str)
#define BASE_UNKNOWN 0
#define BASE_SHARED 1
-#define BASE_1024 7
-#define BASE_1000 13
-#define BASE_SPECIAL 19
+#define BASE_1024 8
+#define BASE_1000 15
+#define BASE_SPECIAL 21
#define NUM_UNIT_PREFIXES 6
#define NUM_SPECIAL 3
@@ -203,27 +203,29 @@ static const char *_display_size(const struct cmd_context *cmd,
{" Gigabyte", " GB", "G"}, /* [4] */
{" Megabyte", " MB", "M"}, /* [5] */
{" Kilobyte", " KB", "K"}, /* [6] */
+ {" Byte ", " B", "B"}, /* [7] */
/* BASE_1024 - Used if cmd->si_unit_consistency = 1 */
- {" Exbibyte", " EiB", "e"}, /* [7] */
- {" Pebibyte", " PiB", "p"}, /* [8] */
- {" Tebibyte", " TiB", "t"}, /* [9] */
- {" Gibibyte", " GiB", "g"}, /* [10] */
- {" Mebibyte", " MiB", "m"}, /* [11] */
- {" Kibibyte", " KiB", "k"}, /* [12] */
+ {" Exbibyte", " EiB", "e"}, /* [8] */
+ {" Pebibyte", " PiB", "p"}, /* [9] */
+ {" Tebibyte", " TiB", "t"}, /* [10] */
+ {" Gibibyte", " GiB", "g"}, /* [11] */
+ {" Mebibyte", " MiB", "m"}, /* [12] */
+ {" Kibibyte", " KiB", "k"}, /* [13] */
+ {" Byte ", " B", "b"}, /* [14] */
/* BASE_1000 - Used if cmd->si_unit_consistency = 1 */
- {" Exabyte", " EB", "E"}, /* [13] */
- {" Petabyte", " PB", "P"}, /* [14] */
- {" Terabyte", " TB", "T"}, /* [15] */
- {" Gigabyte", " GB", "G"}, /* [16] */
- {" Megabyte", " MB", "M"}, /* [17] */
- {" Kilobyte", " kB", "K"}, /* [18] */
+ {" Exabyte", " EB", "E"}, /* [15] */
+ {" Petabyte", " PB", "P"}, /* [16] */
+ {" Terabyte", " TB", "T"}, /* [17] */
+ {" Gigabyte", " GB", "G"}, /* [18] */
+ {" Megabyte", " MB", "M"}, /* [19] */
+ {" Kilobyte", " kB", "K"}, /* [20] */
/* BASE_SPECIAL */
- {" Byte ", " B ", "B"}, /* [19] */
- {" Units ", " Un", "U"}, /* [20] */
- {" Sectors ", " Se", "S"}, /* [21] */
+ {" Byte ", " B ", "B"}, /* [21] (shared with BASE_1000) */
+ {" Units ", " Un", "U"}, /* [22] */
+ {" Sectors ", " Se", "S"}, /* [23] */
};
if (!(size_buf = dm_pool_alloc(cmd->mem, SIZE_BUF))) {
@@ -302,7 +304,7 @@ static const char *_display_size(const struct cmd_context *cmd,
}
/* FIXME Make precision configurable */
- switch(toupper((int) cmd->current_settings.unit_type)) {
+ switch (toupper(*size_str[base + s][SIZE_UNIT])) {
case 'B':
case 'S':
precision = 0;
9 years, 8 months
master - thin: vgsplit and vgmerge spare support
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ef3a1a0f8a7dc9...
Commit: ef3a1a0f8a7dc9656fa9269f08b36d1a9cb96d91
Parent: aab53f46eedda64ca8cd73b25eaac9aea7894957
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jul 9 12:01:25 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jul 18 18:22:44 2013 +0200
thin: vgsplit and vgmerge spare support
When spliting a VG with spare, update to which VG it will belong.
When merging and both VGs have spare, unmark the smaller one first.
---
tools/vgmerge.c | 30 ++++++++++++++++++++++++++++++
tools/vgsplit.c | 6 ++++++
2 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/tools/vgmerge.c b/tools/vgmerge.c
index fb3321d..3782779 100644
--- a/tools/vgmerge.c
+++ b/tools/vgmerge.c
@@ -28,6 +28,29 @@ static struct volume_group *_vgmerge_vg_read(struct cmd_context *cmd,
return vg;
}
+/* Select bigger pool metadata spare volume */
+static int _vgmerge_select_pool_metadata_spare(struct cmd_context *cmd,
+ struct volume_group *vg_to,
+ struct volume_group *vg_from)
+{
+ struct volume_group *svg;
+
+ if (!vg_to->pool_metadata_spare_lv ||
+ !vg_from->pool_metadata_spare_lv)
+ return 1; /* no problem */
+
+ /* Drop smaller pool metadata spare */
+ svg = (vg_to->pool_metadata_spare_lv->le_count <
+ vg_from->pool_metadata_spare_lv->le_count) ? vg_to : vg_from;
+ vg_remove_pool_metadata_spare(svg);
+
+ /* Re-test lv name compatibility */
+ if (!vgs_are_compatible(cmd, vg_from, vg_to))
+ return_0;
+
+ return 1;
+}
+
static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
const char *vg_name_from)
{
@@ -73,6 +96,9 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
if (!drop_cached_metadata(vg_from))
stack;
+ if (!_vgmerge_select_pool_metadata_spare(cmd, vg_to, vg_from))
+ goto_bad;
+
/* Merge volume groups */
dm_list_iterate_items_safe(pvl, tpvl, &vg_from->pvs) {
del_pvl_from_vgs(vg_from, pvl);
@@ -127,6 +153,10 @@ static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
dm_list_move(&vg_to->fid->metadata_areas_ignored, mdah);
}
+ if (!vg_to->pool_metadata_spare_lv)
+ vg_to->pool_metadata_spare_lv =
+ vg_from->pool_metadata_spare_lv;
+
vg_to->extent_count += vg_from->extent_count;
vg_to->free_count += vg_from->free_count;
diff --git a/tools/vgsplit.c b/tools/vgsplit.c
index ed31a57..dfcb120 100644
--- a/tools/vgsplit.c
+++ b/tools/vgsplit.c
@@ -41,6 +41,12 @@ static int _move_one_lv(struct volume_group *vg_from,
return 0;
}
+ /* Moved pool metadata spare LV */
+ if (vg_from->pool_metadata_spare_lv == lv) {
+ vg_to->pool_metadata_spare_lv = lv;
+ vg_from->pool_metadata_spare_lv = NULL;
+ }
+
return 1;
}
9 years, 8 months
master - thin: add lvconvert pool metadata spare
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=aab53f46eedda6...
Commit: aab53f46eedda64ca8cd73b25eaac9aea7894957
Parent: 307578495511e35398e0f9ef3f796641dfa5038e
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jun 25 13:35:12 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jul 18 18:22:44 2013 +0200
thin: add lvconvert pool metadata spare
Support poolmetadataspare when convering volumes into thin pool.
Same rules applied as with lvcreate.
---
tools/commands.h | 6 ++++--
tools/lvconvert.c | 11 +++++++++++
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/tools/commands.h b/tools/commands.h
index 3c9ed82..fc4f7ef 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -170,6 +170,7 @@ xx(lvconvert,
"\t[--poolmetadata ThinMetadataLogicalVolume[Path] |\n"
"\t [--poolmetadatasize size]\n"
"\t [-r|--readahead ReadAheadSectors|auto|none]\n"
+ "\t [--poolmetadataspare {y|n}]\n"
"\t [--stripes Stripes [-I|--stripesize StripeSize]]]\n"
"\t[-T|--thin ExternalLogicalVolume[Path]\n"
"\t [--originname NewExternalOriginVolumeName]]\n"
@@ -180,8 +181,9 @@ xx(lvconvert,
merge_ARG, mirrorlog_ARG, mirrors_ARG, name_ARG, noudevsync_ARG,
readahead_ARG, regionsize_ARG, repair_ARG, replace_ARG, snapshot_ARG, splitmirrors_ARG,
trackchanges_ARG, type_ARG, stripes_long_ARG, stripesize_ARG, test_ARG,
- chunksize_ARG, discards_ARG, poolmetadata_ARG, poolmetadatasize_ARG,
- originname_ARG, thin_ARG, thinpool_ARG,
+ chunksize_ARG, discards_ARG, originname_ARG,
+ poolmetadata_ARG, poolmetadatasize_ARG, poolmetadataspare_ARG,
+ thin_ARG, thinpool_ARG,
use_policies_ARG, force_ARG, zero_ARG)
xx(lvcreate,
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 5e7484e..97ef7e4 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -21,6 +21,7 @@ struct lvconvert_params {
int snapshot;
int merge;
int merge_mirror;
+ int poolmetadataspare;
int thin;
int yes;
int zero;
@@ -253,6 +254,9 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
} else if (arg_count(cmd, discards_ARG)) {
log_error("--discards is only valid with --thinpool.");
return 0;
+ } else if (arg_count(cmd, poolmetadataspare_ARG)) {
+ log_error("--poolmetadataspare is only valid with --thinpool.");
+ return 0;
}
/*
@@ -486,6 +490,9 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
return_0;
}
+ /* TODO: default in lvm.conf ? */
+ lp->poolmetadataspare = arg_int_value(cmd, poolmetadataspare_ARG,
+ DEFAULT_POOL_METADATA_SPARE);
lp->force = arg_count(cmd, force_ARG);
lp->yes = arg_count(cmd, yes_ARG);
@@ -2158,6 +2165,10 @@ static int _lvconvert_thinpool(struct cmd_context *cmd,
return 0;
}
+ if (!handle_pool_metadata_spare(pool_lv->vg, metadata_lv->le_count,
+ lp->pvh, lp->poolmetadataspare))
+ return_0;
+
old_name = data_lv->name; /* Use for pool name */
/*
* Since we wish to have underlaying devs to match _tdata
9 years, 8 months
master - thin: add spare lvcreate support
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=307578495511e3...
Commit: 307578495511e35398e0f9ef3f796641dfa5038e
Parent: a916bf7eeb9130435c78573ddb51da9318f68411
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Jun 25 13:34:31 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jul 18 18:22:44 2013 +0200
thin: add spare lvcreate support
Add --poolmetadataspare option and creates and handles
pool metadata spare lv when thin pool is created.
With default setting 'y' it tries to ensure, spare has
at least the size of created LV.
---
lib/config/defaults.h | 1 +
lib/metadata/metadata-exported.h | 3 +
lib/metadata/thin_manip.c | 99 ++++++++++++++++++++++++++++++++++++++
man/lvcreate.8.in | 11 ++++-
tools/commands.h | 4 +-
tools/lvcreate.c | 18 ++++++-
6 files changed, 132 insertions(+), 4 deletions(-)
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index a789a9c..34ce2ea 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -73,6 +73,7 @@
#define DEFAULT_THIN_POOL_CHUNK_SIZE 64 /* KB */
#define DEFAULT_THIN_POOL_DISCARDS "passdown"
#define DEFAULT_THIN_POOL_ZERO 1
+#define DEFAULT_POOL_METADATA_SPARE 1
#define DEFAULT_UMASK 0077
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 65999cd..67dc7f7 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -667,6 +667,8 @@ struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
uint32_t stripes, uint32_t stripe_size,
uint64_t size, alloc_policy_t alloc,
struct dm_list *pvh);
+int handle_pool_metadata_spare(struct volume_group *vg, uint32_t extents,
+ struct dm_list *pvh, int poolmetadataspare);
int vg_set_pool_metadata_spare(struct logical_volume *lv);
int vg_remove_pool_metadata_spare(struct volume_group *vg);
@@ -710,6 +712,7 @@ struct lvcreate_params {
int minor; /* all */
int log_count; /* mirror */
int nosync; /* mirror */
+ int poolmetadataspare; /* thin pool */
#define ACTIVATION_SKIP_SET 0x01 /* request to set LV activation skip flag state */
#define ACTIVATION_SKIP_SET_ENABLED 0x02 /* set the LV activation skip flag state to 'enabled' */
#define ACTIVATION_SKIP_IGNORE 0x04 /* request to ignore LV activation skip flag (if any) */
diff --git a/lib/metadata/thin_manip.c b/lib/metadata/thin_manip.c
index 9ee8a55..5ac356f 100644
--- a/lib/metadata/thin_manip.c
+++ b/lib/metadata/thin_manip.c
@@ -728,6 +728,102 @@ struct logical_volume *alloc_pool_metadata(struct logical_volume *pool_lv,
return metadata_lv;
}
+static struct logical_volume *_alloc_pool_metadata_spare(struct volume_group *vg,
+ uint32_t extents,
+ struct dm_list *pvh)
+{
+ struct logical_volume *lv;
+
+ /* FIXME: Make lvm2api usable */
+ struct lvcreate_params lp = {
+ .activate = CHANGE_ALY,
+ .alloc = ALLOC_INHERIT,
+ .extents = extents,
+ .major = -1,
+ .minor = -1,
+ .permission = LVM_READ | LVM_WRITE,
+ .pvh = pvh ? : &vg->pvs,
+ .read_ahead = DM_READ_AHEAD_AUTO,
+ .stripes = 1,
+ .vg_name = vg->name,
+ .zero = 1,
+ };
+
+ dm_list_init(&lp.tags);
+
+ if (!(lp.segtype = get_segtype_from_string(vg->cmd, "striped")))
+ return_0;
+
+ /* FIXME: Maybe using silent mode ? */
+ if (!(lv = lv_create_single(vg, &lp)))
+ return_0;
+
+ /* Spare LV should not be active */
+ if (!deactivate_lv_local(vg->cmd, lv)) {
+ log_error("Unable to deactivate pool metadata spare LV. "
+ "Manual intervention required.");
+ return 0;
+ }
+
+ if (!vg_set_pool_metadata_spare(lv))
+ return_0;
+
+ return lv;
+}
+
+/*
+ * Create/resize pool metadata spare LV
+ * Caller does vg_write(), vg_commit() with pool creation
+ * extents is 0, max size is determined
+ */
+int handle_pool_metadata_spare(struct volume_group *vg, uint32_t extents,
+ struct dm_list *pvh, int poolmetadataspare)
+{
+ struct logical_volume *lv = vg->pool_metadata_spare_lv;
+ uint32_t seg_mirrors;
+ struct lv_segment *seg;
+ const struct lv_list *lvl;
+
+ if (!extents)
+ /* Find maximal size of metadata LV */
+ dm_list_iterate_items(lvl, &vg->lvs)
+ if (lv_is_thin_pool_metadata(lvl->lv) &&
+ (lvl->lv->le_count > extents))
+ extents = lvl->lv->le_count;
+
+ if (!poolmetadataspare) {
+ /* TODO: Not showing when lvm.conf would define 'n' ? */
+ if (DEFAULT_POOL_METADATA_SPARE && extents)
+ /* Warn if there would be any user */
+ log_warn("WARNING: recovery of pools without pool "
+ "metadata spare LV is not automated.");
+ return 1;
+ }
+
+ if (!lv) {
+ if (!_alloc_pool_metadata_spare(vg, extents, pvh))
+ return_0;
+
+ return 1;
+ }
+
+ seg = last_seg(lv);
+ seg_mirrors = lv_mirror_count(lv);
+
+ /* Check spare LV is big enough and preserve segtype */
+ if ((lv->le_count < extents) && seg &&
+ !lv_extend(lv, seg->segtype,
+ seg->area_count / seg_mirrors,
+ seg->stripe_size,
+ seg_mirrors,
+ seg->region_size,
+ extents - lv->le_count, NULL,
+ pvh, lv->alloc))
+ return_0;
+
+ return 1;
+}
+
int vg_set_pool_metadata_spare(struct logical_volume *lv)
{
char new_name[NAME_LEN];
@@ -797,5 +893,8 @@ int vg_remove_pool_metadata_spare(struct volume_group *vg)
if (!lv_rename_update(vg->cmd, lv, new_name, 0))
return_0;
+ /* To display default warning */
+ (void) handle_pool_metadata_spare(vg, 0, 0, 0);
+
return 1;
}
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index 64319c1..ecbf363 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -64,7 +64,9 @@ lvcreate \- create a logical volume in an existing volume group
.RB [ \-\-discards
.RI { ignore | nopassdown | passdown }]
.RB [ \-\-poolmetadatasize
-.IR MetadataVolumeSize [ bBsSkKmMgG ]]]
+.IR MetadataVolumeSize [ bBsSkKmMgG ]]
+.RB [ \-\-poolmetadataspare
+.RI { y | n }]]
.RB [ \-\-thinpool
.IR ThinPoolLogicalVolume { Name | Path }
.RB [ \-s | \-\-snapshot
@@ -293,6 +295,13 @@ Supported values are in range between 2MiB and 16GiB.
Default value is (Pool_LV_size / Pool_LV_chunk_size * 64b).
Default unit is megabytes.
.TP
+.IR \fB\-\-poolmetadataspare " {" y | n }
+Controls creation and maintanence of pool metadata spare logical volume
+that will be used for automated thin pool recovery.
+Only one such volume is maintained within a volume group
+with the size of the biggest thin metadata volume.
+Default is \fIy\fPes.
+.TP
.IR \fB\-r ", " \fB\-\-readahead " {" ReadAheadSectors | auto | none }
Sets read ahead sector count of this logical volume.
For volume groups with metadata in lvm1 format, this must
diff --git a/tools/commands.h b/tools/commands.h
index f4fdb0b..3c9ed82 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -214,6 +214,7 @@ xx(lvcreate,
"\t[-T|--thin [-c|--chunksize ChunkSize]\n"
"\t [--discards {ignore|nopassdown|passdown}]\n"
"\t [--poolmetadatasize MetadataSize[bBsSkKmMgG]]]\n"
+ "\t [--poolmetadataspare {y|n}]\n"
"\t[--thinpool ThinPoolLogicalVolume{Name|Path}]\n"
"\t[-t|--test]\n"
"\t[--type VolumeType]\n"
@@ -260,9 +261,10 @@ xx(lvcreate,
ignoremonitoring_ARG, major_ARG, minor_ARG, mirrorlog_ARG, mirrors_ARG,
monitor_ARG, minrecoveryrate_ARG, maxrecoveryrate_ARG, name_ARG, nosync_ARG,
noudevsync_ARG, ignoreactivationskip_ARG, setactivationskip_ARG,
+ poolmetadatasize_ARG, poolmetadataspare_ARG,
permission_ARG, persistent_ARG, readahead_ARG, regionsize_ARG, size_ARG,
snapshot_ARG, stripes_ARG, stripesize_ARG, test_ARG, thin_ARG, thinpool_ARG,
- type_ARG, virtualoriginsize_ARG, poolmetadatasize_ARG, virtualsize_ARG,
+ type_ARG, virtualoriginsize_ARG, virtualsize_ARG,
zero_ARG)
xx(lvdisplay,
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index d9578aa..2e8c65f 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -904,6 +904,14 @@ static int _lvcreate_params(struct lvcreate_params *lp,
return 0;
}
+ if (lp->create_thin_pool) {
+ /* TODO: add lvm.conf default y|n */
+ lp->poolmetadataspare = arg_int_value(cmd, poolmetadataspare_ARG,
+ DEFAULT_POOL_METADATA_SPARE);
+ } else if (arg_count(cmd, poolmetadataspare_ARG)) {
+ log_error("--poolmetadataspare is only available with thin pool creation.");
+ return 0;
+ }
/*
* Allocation parameters
*/
@@ -962,6 +970,7 @@ static int _check_thin_parameters(struct volume_group *vg, struct lvcreate_param
contiguous_ARG,
discards_ARG,
poolmetadatasize_ARG,
+ poolmetadataspare_ARG,
stripes_ARG,
stripesize_ARG,
zero_ARG
@@ -1096,9 +1105,14 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
if (seg_is_thin(&lp) && !_validate_internal_thin_processing(&lp))
goto_out;
- if (lp.create_thin_pool)
+ if (lp.create_thin_pool) {
+ if (!handle_pool_metadata_spare(vg, lp.poolmetadataextents,
+ lp.pvh, lp.poolmetadataspare))
+ goto_out;
+
log_verbose("Making thin pool %s in VG %s using segtype %s",
lp.pool ? : "with generated name", lp.vg_name, lp.segtype->name);
+ }
if (lp.thin)
log_verbose("Making thin LV %s in pool %s in VG %s%s%s using segtype %s",
9 years, 8 months
master - thin: removal of spare disables recovery
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a916bf7eeb9130...
Commit: a916bf7eeb9130435c78573ddb51da9318f68411
Parent: 915cc5a2faf67dd3438651b80414f2a054016749
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jun 17 19:54:15 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jul 18 18:22:44 2013 +0200
thin: removal of spare disables recovery
Warn user when removing spare LV.
Remove spare automatically, when last pool from VG is removed.
---
lib/metadata/lv_manip.c | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 42a5f1e..16ad7e7 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -4525,7 +4525,9 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
{
percent_t snap_percent;
struct dm_list *snh, *snht;
+ struct lv_list *lvl;
struct lvinfo info;
+ int is_last_pool;
if (lv_is_cow(lv)) {
/*
@@ -4583,6 +4585,30 @@ int lv_remove_with_dependencies(struct cmd_context *cmd, struct logical_volume *
!_lv_remove_segs_using_this_lv(cmd, lv, force, level, "pool"))
return_0;
+ if (lv_is_thin_pool(lv) && lv->vg->pool_metadata_spare_lv) {
+ /* When removing last thin pool, remove also spare */
+ is_last_pool = 1;
+ dm_list_iterate_items(lvl, &lv->vg->lvs)
+ if (lv_is_thin_pool(lvl->lv) && lvl->lv != lv) {
+ is_last_pool = 0;
+ break;
+ }
+
+ if (is_last_pool &&
+ !lv_remove_with_dependencies(cmd, lv->vg->pool_metadata_spare_lv,
+ DONT_PROMPT, level + 1))
+ return_0;
+ }
+
+ if (lv_is_pool_metadata_spare(lv) &&
+ (force == PROMPT) &&
+ (yes_no_prompt("Removal of pool metadata spare logical volume \"%s\" "
+ "disables automatic recovery attempts after damage "
+ "to a thin pool. Proceed? [y/n]: ", lv->name) == 'n')) {
+ log_error("Logical volume \"%s\" not removed.", lv->name);
+ return 0;
+ }
+
return lv_remove_single(cmd, lv, force);
}
9 years, 8 months
master - thin: report 'e' volume type pool metadata spare
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=915cc5a2faf67d...
Commit: 915cc5a2faf67dd3438651b80414f2a054016749
Parent: 460d0254ebc7df514081997a12238a88e8b203c6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jun 17 19:42:52 2013 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Thu Jul 18 18:22:44 2013 +0200
thin: report 'e' volume type pool metadata spare
Reuse m'e'tadata volume type for spar'e' volume as well.
Essentially they are related and there is no big reason
to introduce new flag.
---
lib/metadata/lv.c | 1 +
man/lvs.8.in | 2 +-
2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/lv.c b/lib/metadata/lv.c
index 4d3a259..db71cf0 100644
--- a/lib/metadata/lv.c
+++ b/lib/metadata/lv.c
@@ -547,6 +547,7 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv)
else if (lv_is_origin(lv) || lv_is_external_origin(lv))
repstr[0] = (lv_is_merging_origin(lv)) ? 'O' : 'o';
else if (lv_is_thin_pool_metadata(lv) ||
+ lv_is_pool_metadata_spare(lv) ||
(lv->status & RAID_META))
repstr[0] = 'e';
else if (lv->status & RAID)
diff --git a/man/lvs.8.in b/man/lvs.8.in
index 5df6b47..4da4370 100644
--- a/man/lvs.8.in
+++ b/man/lvs.8.in
@@ -135,7 +135,7 @@ Volume type: (m)irrored, (M)irrored without initial sync, (o)rigin,
(s)napshot, merging (S)napshot, (p)vmove, (v)irtual,
mirror or raid (i)mage, mirror or raid (I)mage out-of-sync, mirror (l)og device,
under (c)onversion, thin (V)olume, (t)hin pool, (T)hin pool data, raid or
-thin pool m(e)tadata
+thin pool m(e)tadata or pool metadata spare.
.IP 2 3
Permissions: (w)riteable, (r)ead-only, (R)ead-only activation of non-read-only
volume
9 years, 8 months