master - lvmdbustest.py: Use _lookup function
by Tony Asleson
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=157948b5a5f6f651fa5...
Commit: 157948b5a5f6f651fa56ec45f71b031c1a132c15
Parent: c25b95e2ef01874e67048f96b1e4928ec12fdb4e
Author: Tony Asleson <tasleson(a)redhat.com>
AuthorDate: Wed Mar 1 09:35:01 2017 -0600
Committer: Tony Asleson <tasleson(a)redhat.com>
CommitterDate: Wed Mar 1 17:47:04 2017 -0600
lvmdbustest.py: Use _lookup function
Be consistent in using this helper function for dbus object lookups.
---
test/dbus/lvmdbustest.py | 28 ++++++++++++----------------
1 files changed, 12 insertions(+), 16 deletions(-)
diff --git a/test/dbus/lvmdbustest.py b/test/dbus/lvmdbustest.py
index af4fef1..20bf38e 100755
--- a/test/dbus/lvmdbustest.py
+++ b/test/dbus/lvmdbustest.py
@@ -339,7 +339,8 @@ class TestDbusService(unittest.TestCase):
self.assertTrue(cached_thin_pool_object.ThinPool.MetaDataLv != '/')
def _lookup(self, lvm_id):
- return self.objs[MANAGER_INT][0].Manager.LookUpByLvmId(lvm_id)
+ return self.objs[MANAGER_INT][0].\
+ Manager.LookUpByLvmId(dbus.String(lvm_id))
def test_lookup_by_lvm_id(self):
# For the moment lets just lookup what we know about which is PVs
@@ -392,10 +393,8 @@ class TestDbusService(unittest.TestCase):
def test_vg_rename(self):
vg = self._vg_create().Vg
- mgr = self.objs[MANAGER_INT][0].Manager
-
# Do a vg lookup
- path = mgr.LookUpByLvmId(dbus.String(vg.Name))
+ path = self._lookup(vg.Name)
vg_name_start = vg.Name
@@ -406,7 +405,7 @@ class TestDbusService(unittest.TestCase):
for i in range(0, 5):
lv_t = self._create_lv(size=mib(4), vg=vg)
full_name = "%s/%s" % (vg_name_start, lv_t.LvCommon.Name)
- lv_path = mgr.LookUpByLvmId(dbus.String(full_name))
+ lv_path = self._lookup(full_name)
self.assertTrue(lv_path == lv_t.object_path)
new_name = 'renamed_' + vg.Name
@@ -417,7 +416,7 @@ class TestDbusService(unittest.TestCase):
self._check_consistency()
# Do a vg lookup
- path = mgr.LookUpByLvmId(dbus.String(new_name))
+ path = self._lookup(new_name)
self.assertTrue(path != '/', "%s" % (path))
self.assertTrue(prev_path == path, "%s != %s" % (prev_path, path))
@@ -435,14 +434,12 @@ class TestDbusService(unittest.TestCase):
lv_proxy.Vg == vg.object_path, "%s != %s" %
(lv_proxy.Vg, vg.object_path))
full_name = "%s/%s" % (new_name, lv_proxy.Name)
- lv_path = mgr.LookUpByLvmId(dbus.String(full_name))
+ lv_path = self._lookup(full_name)
self.assertTrue(
lv_path == lv_proxy.object_path, "%s != %s" %
(lv_path, lv_proxy.object_path))
def _verify_hidden_lookups(self, lv_common_object, vgname):
- mgr = self.objs[MANAGER_INT][0].Manager
-
hidden_lv_paths = lv_common_object.HiddenLvs
for h in hidden_lv_paths:
@@ -454,7 +451,7 @@ class TestDbusService(unittest.TestCase):
full_name = "%s/%s" % (vgname, h_lv.Name)
# print("Hidden check %s" % (full_name))
- lookup_path = mgr.LookUpByLvmId(dbus.String(full_name))
+ lookup_path = self._lookup(full_name)
self.assertTrue(lookup_path != '/')
self.assertTrue(lookup_path == h_lv.object_path)
@@ -462,7 +459,7 @@ class TestDbusService(unittest.TestCase):
full_name = "%s/%s" % (vgname, h_lv.Name[1:-1])
# print("Hidden check %s" % (full_name))
- lookup_path = mgr.LookUpByLvmId(dbus.String(full_name))
+ lookup_path = self._lookup(full_name)
self.assertTrue(lookup_path != '/')
self.assertTrue(lookup_path == h_lv.object_path)
@@ -490,7 +487,7 @@ class TestDbusService(unittest.TestCase):
full_name = "%s/%s" % (vg_name_start, lv_name)
- lookup_lv_path = mgr.LookUpByLvmId(dbus.String(full_name))
+ lookup_lv_path = self._lookup(full_name)
self.assertTrue(
thin_lv_path == lookup_lv_path,
"%s != %s" % (thin_lv_path, lookup_lv_path))
@@ -518,7 +515,7 @@ class TestDbusService(unittest.TestCase):
(lv_proxy.Vg, vg.object_path))
full_name = "%s/%s" % (new_name, lv_proxy.Name)
# print('Full Name %s' % (full_name))
- lv_path = mgr.LookUpByLvmId(dbus.String(full_name))
+ lv_path = self._lookup(full_name)
self.assertTrue(
lv_path == lv_proxy.object_path, "%s != %s" %
(lv_path, lv_proxy.object_path))
@@ -643,7 +640,7 @@ class TestDbusService(unittest.TestCase):
# Rename a regular LV
lv = self._create_lv()
- path = self.objs[MANAGER_INT][0].Manager.LookUpByLvmId(lv.LvCommon.Name)
+ path = self._lookup(lv.LvCommon.Name)
prev_path = path
new_name = 'renamed_' + lv.LvCommon.Name
@@ -651,8 +648,7 @@ class TestDbusService(unittest.TestCase):
self.handle_return(lv.Lv.Rename(dbus.String(new_name),
dbus.Int32(g_tmo), EOD))
- path = self.objs[MANAGER_INT][0].Manager.LookUpByLvmId(
- dbus.String(new_name))
+ path = self._lookup(new_name)
self._check_consistency()
self.assertTrue(prev_path == path, "%s != %s" % (prev_path, path))
7 years, 1 month
master - man: fix typo
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c25b95e2ef01874e670...
Commit: c25b95e2ef01874e67048f96b1e4928ec12fdb4e
Parent: 51dfbf1fb34199d00fcace378df50f580f7ed57d
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Mar 1 16:59:17 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Mar 1 16:59:51 2017 -0600
man: fix typo
---
tools/args.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/args.h b/tools/args.h
index f4eec0b..66de6d5 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -693,7 +693,7 @@ arg(unquoted_ARG, '\0', "unquoted", 0, 0, 0,
"pairs are not quoted.\n")
arg(usepolicies_ARG, '\0', "usepolicies", 0, 0, 0,
- "Perform an operation according to the policy configured in lvm.conf.\n"
+ "Perform an operation according to the policy configured in lvm.conf\n"
"or a profile.\n")
arg(validate_ARG, '\0', "validate", 0, 0, 0,
7 years, 1 month
master - commands: tweak some descriptions
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=51dfbf1fb34199d00fc...
Commit: 51dfbf1fb34199d00fcace378df50f580f7ed57d
Parent: daf1d4cadc69aeb8f4d83e44697948150ffcfda3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Mar 1 16:50:27 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Mar 1 16:59:51 2017 -0600
commands: tweak some descriptions
---
tools/command-lines.in | 47 +++++++++++++++++++++--------------------------
1 files changed, 21 insertions(+), 26 deletions(-)
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 5f65093..6956c15 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -338,7 +338,8 @@ lvconvert --type mirror LV
OO: OO_LVCONVERT_RAID, OO_LVCONVERT, --mirrorlog MirrorLog
OP: PV ...
ID: lvconvert_raid_types
-DESC: Convert LV to type mirror (also see type raid1).
+DESC: Convert LV to type mirror (also see type raid1),
+DESC: (also see lvconvert --mirrors).
RULE: all not lv_is_locked lv_is_pvmove
FLAGS: SECONDARY_SYNTAX
@@ -431,8 +432,8 @@ RULE: all not lv_is_locked
lvconvert --thin --thinpool LV LV_linear_striped_raid_cache
OO: --type thin, --originname LV_new, --zero Bool, OO_LVCONVERT_POOL, OO_LVCONVERT
ID: lvconvert_to_thin_with_external
-DESC: Convert LV to a thin LV, using the original LV as an external origin.
-DESC: (variant, infers --type thin).
+DESC: Convert LV to a thin LV, using the original LV as an external origin
+DESC: (infers --type thin).
FLAGS: SECONDARY_SYNTAX
RULE: all and lv_is_visible
RULE: all not lv_is_locked
@@ -449,9 +450,9 @@ RULE: all and lv_is_visible
lvconvert --cache --cachepool LV LV_linear_striped_raid_thinpool
OO: --type cache, OO_LVCONVERT_CACHE, OO_LVCONVERT_POOL, OO_LVCONVERT
ID: lvconvert_to_cache_vol
-DESC: Convert LV to type cache (variant, infers --type cache).
-FLAGS: SECONDARY_SYNTAX
+DESC: Convert LV to type cache (infers --type cache).
RULE: all and lv_is_visible
+FLAGS: SECONDARY_SYNTAX
---
@@ -664,7 +665,7 @@ lvconvert --replace PV LV_raid
OO: OO_LVCONVERT
OP: PV ...
ID: lvconvert_replace_pv
-DESC: Replace specific PV(s) in a raid* LV with another PV.
+DESC: Replace specific PV(s) in a raid LV with another PV.
RULE: all not lv_is_locked lv_is_pvmove
---
@@ -683,7 +684,7 @@ RULE: all and lv_is_converting
lvconvert LV_mirror_raid
OO: OO_LVCONVERT
ID: lvconvert_start_poll
-DESC: Poll LV to continue conversion.
+DESC: Poll LV to continue conversion (also see --startpoll).
RULE: all and lv_is_converting
FLAGS: SECONDARY_SYNTAX
@@ -733,17 +734,12 @@ ID: lvcreate_linear
DESC: Create a linear LV.
FLAGS: SECONDARY_SYNTAX
-# This is the one place we mention the optional --name
-# because it's the most common case and may be confusing
-# to people to not see the name parameter.
-
lvcreate --size SizeMB VG
OO: --type linear, OO_LVCREATE
OP: PV ...
IO: --mirrors 0, --stripes 1
ID: lvcreate_linear
-DESC: Create a linear LV (default --type linear).
-DESC: When --name is omitted, the name is generated.
+DESC: Create a linear LV.
---
@@ -751,7 +747,7 @@ lvcreate --type striped --size SizeMB VG
OO: --stripes Number, --stripesize SizeKB, OO_LVCREATE
OP: PV ...
ID: lvcreate_striped
-DESC: Create a striped LV.
+DESC: Create a striped LV (also see lvcreate --stripes).
FLAGS: SECONDARY_SYNTAX
lvcreate --stripes Number --size SizeMB VG
@@ -774,7 +770,7 @@ lvcreate --mirrors SNumber --size SizeMB VG
OO: --type raid1, --type mirror, --mirrorlog MirrorLog, --stripes Number, OO_LVCREATE_RAID, OO_LVCREATE
OP: PV ...
ID: lvcreate_mirror_or_raid1
-DESC: Create a raid1 or mirror LV (variant, infers --type raid1|mirror).
+DESC: Create a raid1 or mirror LV (infers --type raid1|mirror).
---
@@ -782,17 +778,14 @@ lvcreate --type raid --size SizeMB VG
OO: OO_LVCREATE_RAID, OO_LVCREATE
OP: PV ...
ID: lvcreate_raid_any
-DESC: Create a raid LV (a specific raid level must be used, e.g. raid1.)
+DESC: Create a raid LV (a specific raid level must be used, e.g. raid1).
---
-# FIXME: the LV created by these commands actually has type linear or striped,
+# The LV created by these commands actually has type linear or striped,
# not snapshot as specified by the command. If LVs never have type
# snapshot, perhaps "snapshot" should not be considered an LV type, but
# another new LV property?
-#
-# This is the one case where the --type variant is the unpreferred,
-# secondary syntax, because the LV type is not actually "snapshot".
# alternate form of lvcreate --snapshot
lvcreate --type snapshot --size SizeMB LV
@@ -800,7 +793,8 @@ OO: --snapshot, --stripes Number, --stripesize SizeKB,
--chunksize SizeKB, OO_LVCREATE
OP: PV ...
ID: lvcreate_cow_snapshot
-DESC: Create a COW snapshot LV from an origin LV.
+DESC: Create a COW snapshot LV of an origin LV
+DESC: (also see --snapshot).
FLAGS: SECONDARY_SYNTAX
lvcreate --snapshot --size SizeMB LV
@@ -808,7 +802,7 @@ OO: --type snapshot, --stripes Number, --stripesize SizeKB,
--chunksize SizeKB, OO_LVCREATE
OP: PV ...
ID: lvcreate_cow_snapshot
-DESC: Create a COW snapshot LV from an origin LV.
+DESC: Create a COW snapshot LV of an origin LV.
---
@@ -817,7 +811,8 @@ lvcreate --type snapshot --size SizeMB --virtualsize SizeMB VG
OO: --snapshot, --chunksize SizeKB, OO_LVCREATE
OP: PV ...
ID: lvcreate_cow_snapshot_with_virtual_origin
-DESC: Create a sparse COW snapshot LV of a virtual origin LV.
+DESC: Create a sparse COW snapshot LV of a virtual origin LV
+DESC: (also see --snapshot).
FLAGS: SECONDARY_SYNTAX
lvcreate --snapshot --size SizeMB --virtualsize SizeMB VG
@@ -844,7 +839,7 @@ OO: --type thin-pool, OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE,
OP: PV ...
IO: --mirrors 0
ID: lvcreate_thinpool
-DESC: Create a thin pool (variant, infers --type thin-pool).
+DESC: Create a thin pool (infers --type thin-pool).
FLAGS: SECONDARY_SYNTAX
# alternate form of lvcreate --type thin-pool
@@ -855,7 +850,7 @@ OP: PV ...
IO: --mirrors 0
ID: lvcreate_thinpool
DESC: Create a thin pool named by the --thinpool arg
-DESC: (variant, infers --type thin-pool).
+DESC: (infers --type thin-pool).
FLAGS: SECONDARY_SYNTAX
---
@@ -906,7 +901,7 @@ lvcreate --virtualsize SizeMB --thinpool LV_thinpool VG
OO: --type thin, --thin, OO_LVCREATE_THIN, OO_LVCREATE
IO: --mirrors 0
ID: lvcreate_thin_vol
-DESC: Create a thin LV in a thin pool (variant, infers --type thin).
+DESC: Create a thin LV in a thin pool (infers --type thin).
# alternate form of lvcreate --type thin
lvcreate --virtualsize SizeMB LV_thinpool
7 years, 1 month
master - lvconvert: add new reporting fields for reshaping
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=daf1d4cadc69aeb8f4d...
Commit: daf1d4cadc69aeb8f4d83e44697948150ffcfda3
Parent: fb42874a4f4b5e69a930be7b39c4ca9ad9e7e47f
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Wed Mar 1 19:30:52 2017 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Wed Mar 1 19:30:52 2017 +0100
lvconvert: add new reporting fields for reshaping
Commit 48778bc5038f introduced new RAID reshaping related report fields.
The inclusioon of segtype.h in properties.c isn't mandatory, remove it.
Related: rhbz834579
Related: rhbz1191935
Related: rhbz1191978
---
lib/report/properties.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/lib/report/properties.c b/lib/report/properties.c
index 5264eb1..04f2cef 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -16,7 +16,6 @@
#include "properties.h"
#include "activate.h"
#include "metadata.h"
-#include "segtype.h"
#define GET_VG_NUM_PROPERTY_FN(NAME, VALUE) \
@@ -461,7 +460,7 @@ GET_LVSEG_NUM_PROPERTY_FN(parity_chunks, lvseg->data_offset)
#define _parity_chunks_set prop_not_implemented_set
GET_LVSEG_NUM_PROPERTY_FN(stripes, lvseg->area_count)
#define _stripes_set prop_not_implemented_set
-GET_LVSEG_NUM_PROPERTY_FN(data_stripes, lvseg->area_count - lvseg->segtype->parity_devs)
+GET_LVSEG_NUM_PROPERTY_FN(data_stripes, lvseg->area_count)
#define _data_stripes_set prop_not_implemented_set
GET_LVSEG_NUM_PROPERTY_FN(stripe_size, (SECTOR_SIZE * lvseg->stripe_size))
#define _stripe_size_set prop_not_implemented_set
7 years, 1 month
master - lvconvert: libdm RAID API compatibility versioning; remove new function
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=fb42874a4f4b5e69a93...
Commit: fb42874a4f4b5e69a930be7b39c4ca9ad9e7e47f
Parent: 48778bc5038f0384bf0e6ad43bac048f6700637b
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Wed Mar 1 18:58:48 2017 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Wed Mar 1 18:58:48 2017 +0100
lvconvert: libdm RAID API compatibility versioning; remove new function
Commit 80a6de616a19 versioned the dm_tree_node_add_raid_target_with_params()
and dm_tree_node_add_raid_target() APIs for compatibility reasons.
There's no user of the latter function, remove it.
Related: rhbz834579
Related: rhbz1191935
Related: rhbz1191978
---
libdm/.exported_symbols.DM_1_02_138 | 1 -
libdm/libdevmapper.h | 9 ---------
libdm/libdm-deptree.c | 20 --------------------
3 files changed, 0 insertions(+), 30 deletions(-)
diff --git a/libdm/.exported_symbols.DM_1_02_138 b/libdm/.exported_symbols.DM_1_02_138
index 43e4111..6d658b9 100644
--- a/libdm/.exported_symbols.DM_1_02_138
+++ b/libdm/.exported_symbols.DM_1_02_138
@@ -3,5 +3,4 @@ dm_bit_get_prev
dm_stats_update_regions_from_fd
dm_bitset_parse_list
dm_stats_bind_from_fd
-dm_tree_node_add_raid_target_v2
dm_tree_node_add_raid_target_with_params_v2
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index b515f6d..e1dc5a4 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -1723,15 +1723,6 @@ int dm_tree_node_add_raid_target(struct dm_tree_node *node,
uint64_t rebuilds,
uint64_t flags);
-/* Version 2 coping with 253 (MD kernel limitation) devices */
-int dm_tree_node_add_raid_target_v2(struct dm_tree_node *node,
- uint64_t size,
- const char *raid_type,
- uint32_t region_size,
- uint32_t stripe_size,
- uint64_t *rebuilds,
- uint64_t flags);
-
/*
* Defines below are based on kernel's dm-cache.c defines
* DM_CACHE_MIN_DATA_BLOCK_SIZE (32 * 1024 >> SECTOR_SHIFT)
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index 79117d2..a78fbcc 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -3386,26 +3386,6 @@ int dm_tree_node_add_raid_target_with_params_v2(struct dm_tree_node *node,
return 1;
}
-int dm_tree_node_add_raid_target_v2(struct dm_tree_node *node,
- uint64_t size,
- const char *raid_type,
- uint32_t region_size,
- uint32_t stripe_size,
- uint64_t *rebuilds,
- uint64_t flags)
-{
- struct dm_tree_node_raid_params_v2 params = {
- .raid_type = raid_type,
- .region_size = region_size,
- .stripe_size = stripe_size,
- .flags = flags
- };
-
- memcpy(params.rebuilds, rebuilds, sizeof(params.rebuilds));
-
- return dm_tree_node_add_raid_target_with_params_v2(node, size, ¶ms);
-}
-
int dm_tree_node_add_cache_target(struct dm_tree_node *node,
uint64_t size,
uint64_t feature_flags, /* DM_CACHE_FEATURE_* */
7 years, 1 month
master - lvconvert: add new reporting fields for reshaping
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=48778bc5038f0384bf0...
Commit: 48778bc5038f0384bf0e6ad43bac048f6700637b
Parent: 62abae1525cec51279c39c5127afaced8f0463e2
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Wed Mar 1 18:50:35 2017 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Wed Mar 1 18:50:35 2017 +0100
lvconvert: add new reporting fields for reshaping
During an ongoing reshape, the MD kernel runtime reads stripes relative
to data_offset and starts storing the reshaped stripes (with new raid
layout and/or new stripesize and/or new number of stripes) relative
to new_data_offset. This is to avoid writing over any data in place
which is non-atomic by nature and thus be recoverable without data loss
in the transition. MD uses the term out-of-place reshaping for it.
There's 2 other areas we don't have report capability for:
- number of data stripes vs. total stripes
(e.g. raid6 with 7 stripes toal has 5 data stripes)
- number of (rotating) parity/syndrome chunks
(e.g. raid6 with 7 stripes toal has 2 parity chunks; one
per stripe for P-Syndrome and another one for Q-Syndrome)
Thus, add the following reportable keys:
- reshape_len (in current units)
- reshape_len_le (in logical extents)
- data_offset (in sectors)
- new_data_offset ( " )
- data_stripes
- parity_chunks
Enhance lvchange-raid.sh, lvconvert-raid-reshape-linear_to_striped.sh,
lvconvert-raid-reshape-striped_to_linear.sh, lvconvert-raid-reshape.sh
and lvconvert-raid-takeover.sh to make use of new keys.
Related: rhbz834579
Related: rhbz1191935
Related: rhbz1191978
---
lib/report/columns.h | 9 +-
lib/report/properties.c | 17 ++-
lib/report/report.c | 173 ++++++++++++++++++++
test/shell/lvchange-raid.sh | 2 +-
.../lvconvert-raid-reshape-linear_to_striped.sh | 4 +
.../lvconvert-raid-reshape-striped_to_linear.sh | 24 +++-
test/shell/lvconvert-raid-reshape.sh | 90 ++++++-----
test/shell/lvconvert-raid-takeover.sh | 167 ++++++++++---------
8 files changed, 359 insertions(+), 127 deletions(-)
diff --git a/lib/report/columns.h b/lib/report/columns.h
index 6d9b851..0452641 100644
--- a/lib/report/columns.h
+++ b/lib/report/columns.h
@@ -241,7 +241,14 @@ FIELD(VGS, vg, NUM, "#VMdaCps", cmd, 0, vgmdacopies, vg_mda_copies, "Target numb
* SEGS type fields
*/
FIELD(SEGS, seg, STR, "Type", list, 0, segtype, segtype, "Type of LV segment.", 0)
-FIELD(SEGS, seg, NUM, "#Str", area_count, 0, uint32, stripes, "Number of stripes or mirror legs.", 0)
+FIELD(SEGS, seg, NUM, "#Str", list, 0, seg_stripes, stripes, "Number of data stripes or mirror/raid1 legs.", 0)
+FIELD(SEGS, seg, NUM, "#DStr", list, 0, seg_data_stripes, data_stripes, "Number of data stripes or mirror/raid1 legs.", 0)
+FIELD(SEGS, seg, NUM, "RSize", list, 0, seg_reshape_len, reshape_len, "Size of out-of-place reshape space in current units.", 0)
+FIELD(SEGS, seg, SIZ, "RSize", list, 0, seg_reshape_len_le, reshape_len_le, "Size of out-of-place reshape space in physical extents.", 0)
+FIELD(SEGS, seg, NUM, "#Cpy", list, 0, seg_data_copies, data_copies, "Number of data copies.", 0)
+FIELD(SEGS, seg, NUM, "DOff", list, 0, seg_data_offset, data_offset, "Data offset on each image device.", 0)
+FIELD(SEGS, seg, NUM, "NOff", list, 0, seg_new_data_offset, new_data_offset, "New data offset after any reshape on each image device.", 0)
+FIELD(SEGS, seg, NUM, "#Par", list, 0, seg_parity_chunks, parity_chunks, "Number of (rotating) parity chunks.", 0)
FIELD(SEGS, seg, SIZ, "Stripe", stripe_size, 0, size32, stripe_size, "For stripes, amount of data placed on one device before switching to the next.", 0)
FIELD(SEGS, seg, SIZ, "Region", region_size, 0, size32, region_size, "For mirrors, the unit of data copied when synchronising devices.", 0)
FIELD(SEGS, seg, SIZ, "Chunk", list, 0, chunksize, chunk_size, "For snapshots, the unit of data used when tracking changes.", 0)
diff --git a/lib/report/properties.c b/lib/report/properties.c
index 3b27bdc..5264eb1 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2010-2013 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2010-2017 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -16,6 +16,7 @@
#include "properties.h"
#include "activate.h"
#include "metadata.h"
+#include "segtype.h"
#define GET_VG_NUM_PROPERTY_FN(NAME, VALUE) \
@@ -446,8 +447,22 @@ GET_VG_NUM_PROPERTY_FN(vg_missing_pv_count, vg_missing_pv_count(vg))
/* LVSEG */
GET_LVSEG_STR_PROPERTY_FN(segtype, lvseg_segtype_dup(lvseg->lv->vg->vgmem, lvseg))
#define _segtype_set prop_not_implemented_set
+GET_LVSEG_NUM_PROPERTY_FN(data_copies, lvseg->data_copies)
+#define _data_copies_set prop_not_implemented_set
+GET_LVSEG_NUM_PROPERTY_FN(reshape_len, lvseg->reshape_len)
+#define _reshape_len_set prop_not_implemented_set
+GET_LVSEG_NUM_PROPERTY_FN(reshape_len_le, lvseg->reshape_len)
+#define _reshape_len_le_set prop_not_implemented_set
+GET_LVSEG_NUM_PROPERTY_FN(data_offset, lvseg->data_offset)
+#define _data_offset_set prop_not_implemented_set
+GET_LVSEG_NUM_PROPERTY_FN(new_data_offset, lvseg->data_offset)
+#define _new_data_offset_set prop_not_implemented_set
+GET_LVSEG_NUM_PROPERTY_FN(parity_chunks, lvseg->data_offset)
+#define _parity_chunks_set prop_not_implemented_set
GET_LVSEG_NUM_PROPERTY_FN(stripes, lvseg->area_count)
#define _stripes_set prop_not_implemented_set
+GET_LVSEG_NUM_PROPERTY_FN(data_stripes, lvseg->area_count - lvseg->segtype->parity_devs)
+#define _data_stripes_set prop_not_implemented_set
GET_LVSEG_NUM_PROPERTY_FN(stripe_size, (SECTOR_SIZE * lvseg->stripe_size))
#define _stripe_size_set prop_not_implemented_set
GET_LVSEG_NUM_PROPERTY_FN(region_size, (SECTOR_SIZE * lvseg->region_size))
diff --git a/lib/report/report.c b/lib/report/report.c
index 702befb..5142f72 100644
--- a/lib/report/report.c
+++ b/lib/report/report.c
@@ -2412,6 +2412,179 @@ static int _segstartpe_disp(struct dm_report *rh,
return dm_report_field_uint32(rh, field, &seg->le);
}
+static int _get_seg_used_stripes(const struct lv_segment *seg)
+{
+ uint32_t s;
+ uint32_t stripes = seg->area_count;
+
+ for (s = seg->area_count - 1; stripes && s; s--) {
+ if (seg_type(seg, s) == AREA_LV &&
+ seg_lv(seg, s)->status & LV_REMOVE_AFTER_RESHAPE)
+ stripes--;
+ else
+ break;
+ }
+
+ return stripes;
+}
+
+static int _seg_stripes_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ const struct lv_segment *seg = ((const struct lv_segment *) data);
+
+ return dm_report_field_uint32(rh, field, &seg->area_count);
+}
+
+static int _seg_data_stripes_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ const struct lv_segment *seg = (const struct lv_segment *) data;
+ uint32_t stripes = _get_seg_used_stripes(seg) - seg->segtype->parity_devs;
+
+ /* FIXME: in case of odd numbers of raid10 stripes */
+ if (seg_is_raid10(seg))
+ stripes /= seg->data_copies;
+
+ return dm_report_field_uint32(rh, field, &stripes);
+}
+
+static int _seg_reshape_len_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ const struct lv_segment *seg = (const struct lv_segment *) data;
+ uint32_t reshape_len = seg->reshape_len;
+
+ if (reshape_len && seg->lv) {
+ reshape_len *= seg->area_count * seg->lv->vg->extent_size;
+
+ return _size32_disp(rh, mem, field, &reshape_len, private);
+ }
+
+ return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_32));
+}
+
+static int _seg_reshape_len_le_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ const struct lv_segment *seg = (const struct lv_segment *) data;
+ uint32_t reshape_len = seg->reshape_len;
+
+ if (reshape_len) {
+ reshape_len *= seg->area_count;
+
+ return dm_report_field_uint32(rh, field, &reshape_len);
+ }
+
+ return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_32));
+}
+
+static int _seg_data_copies_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ const struct lv_segment *seg = (const struct lv_segment *) data;
+
+ if (seg->data_copies > 1)
+ return dm_report_field_uint32(rh, field, &seg->data_copies);
+
+ return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_32));
+}
+
+static int _segdata_offset(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private, int new_data_offset)
+{
+ const struct lv_segment *seg = (const struct lv_segment *) data;
+ const char *what = "";
+
+ if (lv_is_raid_image(seg->lv) &&
+ !seg->le &&
+ (seg->reshape_len || !new_data_offset)) {
+ struct lv_list *lvl;
+ char *lv_name;
+
+ if ((lv_name = strdup(seg->lv->name))) {
+ char *p = strchr(lv_name, '_');
+
+ if (p) {
+ /* Handle duplicated sub LVs */
+ if (strstr(p, "_dup_"))
+ p = strchr(p + 5, '_');
+
+ if (p) {
+ *p = '\0';
+ if ((lvl = find_lv_in_vg(seg->lv->vg, lv_name))) {
+ if (seg_is_reshapable_raid(first_seg(lvl->lv))) {
+ uint64_t data_offset;
+
+ if (lv_raid_data_offset(lvl->lv, &data_offset)) {
+ if (new_data_offset && !lv_raid_image_in_sync(seg->lv))
+ data_offset = data_offset ? 0 :
+ seg->reshape_len * seg->lv->vg->extent_size;
+
+ return dm_report_field_uint64(rh, field, &data_offset);
+ }
+
+ what = _str_unknown;
+ }
+ }
+ }
+ }
+ }
+
+ }
+
+ return _field_set_value(field, what, &GET_TYPE_RESERVED_VALUE(num_undef_64));
+}
+
+static int _seg_data_offset_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ return _segdata_offset(rh, mem, field, data, private, 0);
+}
+
+static int _seg_new_data_offset_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ return _segdata_offset(rh, mem, field, data, private, 1);
+}
+
+static int _seg_parity_chunks_disp(struct dm_report *rh, struct dm_pool *mem,
+ struct dm_report_field *field,
+ const void *data, void *private)
+{
+ const struct lv_segment *seg = (const struct lv_segment *) data;
+ uint32_t parity_chunks = seg->segtype->parity_devs ?: seg->data_copies - 1;
+
+ if (parity_chunks) {
+ uint32_t s, resilient_sub_lvs = 0;
+
+ for (s = 0; s < seg->area_count; s++) {
+ if (seg_type(seg, s) == AREA_LV) {
+ struct lv_segment *seg1 = first_seg(seg_lv(seg, s));
+
+ if (seg1->segtype->parity_devs ||
+ seg1->data_copies > 1)
+ resilient_sub_lvs++;
+ }
+ }
+
+ if (resilient_sub_lvs && resilient_sub_lvs == seg->area_count)
+ parity_chunks++;
+
+ return dm_report_field_uint32(rh, field, &parity_chunks);
+ }
+
+ return _field_set_value(field, "", &GET_TYPE_RESERVED_VALUE(num_undef_32));
+}
+
static int _segsize_disp(struct dm_report *rh, struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private)
diff --git a/test/shell/lvchange-raid.sh b/test/shell/lvchange-raid.sh
index 4bc8855..f81cc53 100644
--- a/test/shell/lvchange-raid.sh
+++ b/test/shell/lvchange-raid.sh
@@ -188,7 +188,7 @@ run_syncaction_check() {
# 'lvs' should show results
lvchange --syncaction check $vg/$lv
aux wait_for_sync $vg $lv
- check lv_attr_bit health $vg/$lv "-"
+ check lv_attr_bit health $vg/$lv "-" || check lv_attr_bit health $vg/$lv "m"
check lv_field $vg/$lv raid_mismatch_count "0"
}
diff --git a/test/shell/lvconvert-raid-reshape-linear_to_striped.sh b/test/shell/lvconvert-raid-reshape-linear_to_striped.sh
index 3b6120c..5a266ee 100644
--- a/test/shell/lvconvert-raid-reshape-linear_to_striped.sh
+++ b/test/shell/lvconvert-raid-reshape-linear_to_striped.sh
@@ -27,6 +27,7 @@ aux prepare_vg 5
lvcreate -aey -L 16M -n $lv1 $vg
check lv_field $vg/$lv1 segtype "linear"
check lv_field $vg/$lv1 stripes 1
+check lv_field $vg/$lv1 data_stripes 1
echo y|mkfs -t ext4 $DM_DEV_DIR/$vg/$lv1
fsck -fn $DM_DEV_DIR/$vg/$lv1
@@ -35,6 +36,7 @@ lvconvert -y -m 1 $vg/$lv1
fsck -fn $DM_DEV_DIR/$vg/$lv1
check lv_field $vg/$lv1 segtype "raid1"
check lv_field $vg/$lv1 stripes 2
+check lv_field $vg/$lv1 data_stripes 2
check lv_field $vg/$lv1 regionsize "512.00k"
aux wait_for_sync $vg $lv1
fsck -fn $DM_DEV_DIR/$vg/$lv1
@@ -44,6 +46,7 @@ lvconvert -y --ty raid5_n $vg/$lv1
fsck -fn $DM_DEV_DIR/$vg/$lv1
check lv_field $vg/$lv1 segtype "raid5_n"
check lv_field $vg/$lv1 stripes 2
+check lv_field $vg/$lv1 data_stripes 1
check lv_field $vg/$lv1 stripesize "64.00k"
check lv_field $vg/$lv1 regionsize "512.00k"
@@ -51,6 +54,7 @@ check lv_field $vg/$lv1 regionsize "512.00k"
lvconvert -y --stripes 4 $vg/$lv1
fsck -fn $DM_DEV_DIR/$vg/$lv1
check lv_first_seg_field $vg/$lv1 segtype "raid5_n"
+check lv_first_seg_field $vg/$lv1 data_stripes 4
check lv_first_seg_field $vg/$lv1 stripes 5
check lv_first_seg_field $vg/$lv1 stripesize "64.00k"
check lv_first_seg_field $vg/$lv1 regionsize "512.00k"
diff --git a/test/shell/lvconvert-raid-reshape-striped_to_linear.sh b/test/shell/lvconvert-raid-reshape-striped_to_linear.sh
index fc87caf..dd857c1 100644
--- a/test/shell/lvconvert-raid-reshape-striped_to_linear.sh
+++ b/test/shell/lvconvert-raid-reshape-striped_to_linear.sh
@@ -26,8 +26,10 @@ aux prepare_vg 5
# Create 4-way striped LV
lvcreate -aey -i 4 -I 32k -L 16M -n $lv1 $vg
check lv_field $vg/$lv1 segtype "striped"
+check lv_field $vg/$lv1 data_stripes 4
check lv_field $vg/$lv1 stripes 4
check lv_field $vg/$lv1 stripesize "32.00k"
+check lv_field $vg/$lv1 reshape_len ""
echo y|mkfs -t ext4 $DM_DEV_DIR/$vg/$lv1
fsck -fn $DM_DEV_DIR/$vg/$lv1
@@ -35,14 +37,22 @@ fsck -fn $DM_DEV_DIR/$vg/$lv1
lvconvert -y --ty raid5 -R 128k $vg/$lv1
fsck -fn $DM_DEV_DIR/$vg/$lv1
check lv_field $vg/$lv1 segtype "raid5_n"
+check lv_field $vg/$lv1 data_stripes 4
check lv_field $vg/$lv1 stripes 5
check lv_field $vg/$lv1 stripesize "32.00k"
check lv_field $vg/$lv1 regionsize "128.00k"
+check lv_field $vg/$lv1 reshape_len ""
aux wait_for_sync $vg $lv1
fsck -fn $DM_DEV_DIR/$vg/$lv1
# Extend raid5_n LV by factor 4 to keep size once linear
lvresize -y -L 64 $vg/$lv1
+check lv_field $vg/$lv1 segtype "raid5_n"
+check lv_field $vg/$lv1 data_stripes 4
+check lv_field $vg/$lv1 stripes 5
+check lv_field $vg/$lv1 stripesize "32.00k"
+check lv_field $vg/$lv1 regionsize "128.00k"
+check lv_field $vg/$lv1 reshape_len ""
aux wait_for_sync $vg $lv1
fsck -fn $DM_DEV_DIR/$vg/$lv1
@@ -52,33 +62,45 @@ fsck -fn $DM_DEV_DIR/$vg/$lv1
lvconvert -y -f --ty raid5_n --stripes 1 -I 64k -R 1024k $vg/$lv1
fsck -fn $DM_DEV_DIR/$vg/$lv1
check lv_first_seg_field $vg/$lv1 segtype "raid5_n"
+check lv_first_seg_field $vg/$lv1 data_stripes 1
check lv_first_seg_field $vg/$lv1 stripes 5
check lv_first_seg_field $vg/$lv1 stripesize "64.00k"
check lv_first_seg_field $vg/$lv1 regionsize "1.00m"
+check lv_first_seg_field $vg/$lv1 reshape_len 10
+# for slv in {0..4}
+# do
+# check lv_first_seg_field $vg/${lv1}_rimage_${slv} reshape_len 2
+# done
aux wait_for_sync $vg $lv1 1
fsck -fn $DM_DEV_DIR/$vg/$lv1
# Remove the now freed legs
lvconvert --stripes 1 $vg/$lv1
check lv_first_seg_field $vg/$lv1 segtype "raid5_n"
+check lv_first_seg_field $vg/$lv1 data_stripes 1
check lv_first_seg_field $vg/$lv1 stripes 2
check lv_first_seg_field $vg/$lv1 stripesize "64.00k"
check lv_first_seg_field $vg/$lv1 regionsize "1.00m"
+check lv_first_seg_field $vg/$lv1 reshape_len 4
# Convert raid5_n to raid1
lvconvert -y --type raid1 $vg/$lv1
fsck -fn $DM_DEV_DIR/$vg/$lv1
check lv_first_seg_field $vg/$lv1 segtype "raid1"
+check lv_first_seg_field $vg/$lv1 data_stripes 2
check lv_first_seg_field $vg/$lv1 stripes 2
check lv_first_seg_field $vg/$lv1 stripesize "0"
check lv_first_seg_field $vg/$lv1 regionsize "1.00m"
+check lv_first_seg_field $vg/$lv1 reshape_len ""
-# Convert raid5_n -> striped
+# Convert raid5_n -> linear
lvconvert -y --type linear $vg/$lv1
fsck -fn $DM_DEV_DIR/$vg/$lv1
check lv_first_seg_field $vg/$lv1 segtype "linear"
+check lv_first_seg_field $vg/$lv1 data_stripes 1
check lv_first_seg_field $vg/$lv1 stripes 1
check lv_first_seg_field $vg/$lv1 stripesize "0"
check lv_first_seg_field $vg/$lv1 regionsize "0"
+check lv_first_seg_field $vg/$lv1 reshape_len ""
vgremove -ff $vg
diff --git a/test/shell/lvconvert-raid-reshape.sh b/test/shell/lvconvert-raid-reshape.sh
index 2c302dd..6764d30 100644
--- a/test/shell/lvconvert-raid-reshape.sh
+++ b/test/shell/lvconvert-raid-reshape.sh
@@ -17,7 +17,9 @@ SKIP_WITH_LVMPOLLD=1
which mkfs.ext4 || skip
aux have_raid 1 10 2 || skip
-aux prepare_vg 64
+aux prepare_pvs 65 64
+
+vgcreate -s 1M $vg $(cat DEVICES)
function _lvcreate
{
@@ -30,6 +32,7 @@ function _lvcreate
lvcreate -y -aey --type $level -i $req_stripes -L $size -n $lv $vg
check lv_first_seg_field $vg/$lv segtype "$level"
+ check lv_first_seg_field $vg/$lv datastripes $req_stripes
check lv_first_seg_field $vg/$lv stripes $stripes
mkfs.ext4 "$DM_DEV_DIR/$vg/$lv"
fsck -fn "$DM_DEV_DIR/$vg/$lv"
@@ -39,10 +42,11 @@ function _lvconvert
{
local req_level=$1
local level=$2
- local stripes=$3
- local vg=$4
- local lv=$5
- local region_size=$6
+ local data_stripes=$3
+ local stripes=$4
+ local vg=$5
+ local lv=$6
+ local region_size=$7
local wait_and_check=1
local R=""
@@ -53,6 +57,7 @@ function _lvconvert
lvconvert -y --ty $req_level $R $vg/$lv
[ $? -ne 0 ] && return $?
check lv_first_seg_field $vg/$lv segtype "$level"
+ check lv_first_seg_field $vg/$lv data_stripes $data_stripes
check lv_first_seg_field $vg/$lv stripes $stripes
[ -n "$region_size" ] && check lv_field $vg/$lv regionsize $region_size
if [ "$wait_and_check" -eq 1 ]
@@ -67,6 +72,8 @@ function _reshape_layout
{
local type=$1
shift
+ local data_stripes=$1
+ shift
local stripes=$1
shift
local vg=$1
@@ -80,6 +87,7 @@ function _reshape_layout
lvconvert -vvvv -y --ty $type $opts $vg/$lv
check lv_first_seg_field $vg/$lv segtype "$type"
+ check lv_first_seg_field $vg/$lv data_stripes $data_stripes
check lv_first_seg_field $vg/$lv stripes $stripes
aux wait_for_sync $vg $lv $ignore_a_chars
fsck -fn "$DM_DEV_DIR/$vg/$lv"
@@ -99,101 +107,101 @@ check lv_first_seg_field $vg/$lv1 segtype "raid5_ls"
aux wait_for_sync $vg $lv1
# Reshape it to 256K stripe size
-_reshape_layout raid5_ls 4 $vg $lv1 --stripesize 256K
+_reshape_layout raid5_ls 3 4 $vg $lv1 --stripesize 256K
check lv_first_seg_field $vg/$lv1 stripesize "256.00k"
# Convert raid5(_n) -> striped
-not _lvconvert striped striped 3 $vg $lv1 512k
-_reshape_layout raid5_n 4 $vg $lv1
-_lvconvert striped striped 3 $vg $lv1
+not _lvconvert striped striped 3 3 $vg $lv1 512k
+_reshape_layout raid5_n 3 4 $vg $lv1
+_lvconvert striped striped 3 3 $vg $lv1
# Convert striped -> raid5_n
-_lvconvert raid5_n raid5_n 4 $vg $lv1 "" 1
+_lvconvert raid5_n raid5_n 3 4 $vg $lv1 "" 1
# Convert raid5_n -> raid5_ls
-_reshape_layout raid5_ls 4 $vg $lv1
+_reshape_layout raid5_ls 3 4 $vg $lv1
# Convert raid5_ls to 5 stripes
-_reshape_layout raid5_ls 6 $vg $lv1 --stripes 5
+_reshape_layout raid5_ls 5 6 $vg $lv1 --stripes 5
# Convert raid5_ls back to 3 stripes
-_reshape_layout raid5_ls 6 $vg $lv1 --stripes 3 --force
-_reshape_layout raid5_ls 4 $vg $lv1 --stripes 3
+_reshape_layout raid5_ls 3 6 $vg $lv1 --stripes 3 --force
+_reshape_layout raid5_ls 3 4 $vg $lv1 --stripes 3
# Convert raid5_ls to 7 stripes
-_reshape_layout raid5_ls 8 $vg $lv1 --stripes 7
+_reshape_layout raid5_ls 7 8 $vg $lv1 --stripes 7
# Convert raid5_ls to 9 stripes
-_reshape_layout raid5_ls 10 $vg $lv1 --stripes 9
+_reshape_layout raid5_ls 9 10 $vg $lv1 --stripes 9
# Convert raid5_ls to 14 stripes
-_reshape_layout raid5_ls 15 $vg $lv1 --stripes 14
+_reshape_layout raid5_ls 14 15 $vg $lv1 --stripes 14
# Convert raid5_ls to 63 stripes
-_reshape_layout raid5_ls 64 $vg $lv1 --stripes 63
+_reshape_layout raid5_ls 63 64 $vg $lv1 --stripes 63
# Convert raid5_ls back to 27 stripes
-_reshape_layout raid5_ls 64 $vg $lv1 --stripes 27 --force
-_reshape_layout raid5_ls 28 $vg $lv1 --stripes 27
+_reshape_layout raid5_ls 27 64 $vg $lv1 --stripes 27 --force
+_reshape_layout raid5_ls 27 28 $vg $lv1 --stripes 27
# Convert raid5_ls back to 4 stripes
-_reshape_layout raid5_ls 28 $vg $lv1 --stripes 4 --force
-_reshape_layout raid5_ls 5 $vg $lv1 --stripes 4
+_reshape_layout raid5_ls 4 28 $vg $lv1 --stripes 4 --force
+_reshape_layout raid5_ls 4 5 $vg $lv1 --stripes 4
# Convert raid5_ls back to 3 stripes
-_reshape_layout raid5_ls 5 $vg $lv1 --stripes 3 --force
-_reshape_layout raid5_ls 4 $vg $lv1 --stripes 3
+_reshape_layout raid5_ls 3 5 $vg $lv1 --stripes 3 --force
+_reshape_layout raid5_ls 3 4 $vg $lv1 --stripes 3
# Convert raid5_ls -> raid5_rs
-_reshape_layout raid5_rs 4 $vg $lv1
+_reshape_layout raid5_rs 3 4 $vg $lv1
# Convert raid5_rs -> raid5_la
-_reshape_layout raid5_la 4 $vg $lv1
+_reshape_layout raid5_la 3 4 $vg $lv1
# Convert raid5_la -> raid5_ra
-_reshape_layout raid5_ra 4 $vg $lv1
+_reshape_layout raid5_ra 3 4 $vg $lv1
# Convert raid5_ra -> raid6_ra_6
-_lvconvert raid6_ra_6 raid6_ra_6 5 $vg $lv1 "4.00m" 1
+_lvconvert raid6_ra_6 raid6_ra_6 3 5 $vg $lv1 "4.00m" 1
# Convert raid5_la -> raid6(_zr)
-_reshape_layout raid6 5 $vg $lv1
+_reshape_layout raid6 3 5 $vg $lv1
# Convert raid6(_zr) -> raid6_nc
-_reshape_layout raid6_nc 5 $vg $lv1
+_reshape_layout raid6_nc 3 5 $vg $lv1
# Convert raid6(_nc) -> raid6_nr
-_reshape_layout raid6_nr 5 $vg $lv1
+_reshape_layout raid6_nr 3 5 $vg $lv1
# Convert raid6_nr) -> raid6_rs_6
-_reshape_layout raid6_rs_6 5 $vg $lv1
+_reshape_layout raid6_rs_6 3 5 $vg $lv1
# Convert raid6_rs_6 to 5 stripes
-_reshape_layout raid6_rs_6 7 $vg $lv1 --stripes 5
+_reshape_layout raid6_rs_6 5 7 $vg $lv1 --stripes 5
# Convert raid6_rs_6 to 4 stripes
-_reshape_layout raid6_rs_6 7 $vg $lv1 --stripes 4 --force
-_reshape_layout raid6_rs_6 6 $vg $lv1 --stripes 4
+_reshape_layout raid6_rs_6 4 7 $vg $lv1 --stripes 4 --force
+_reshape_layout raid6_rs_6 4 6 $vg $lv1 --stripes 4
check lv_first_seg_field $vg/$lv1 stripesize "256.00k"
# Convert raid6_rs_6 to raid6_n_6
-_reshape_layout raid6_n_6 6 $vg $lv1
+_reshape_layout raid6_n_6 4 6 $vg $lv1
# Convert raid6_n_6 -> striped
-_lvconvert striped striped 4 $vg $lv1
+_lvconvert striped striped 4 4 $vg $lv1
check lv_first_seg_field $vg/$lv1 stripesize "256.00k"
# Convert striped -> raid10(_near)
-_lvconvert raid10 raid10 8 $vg $lv1
+_lvconvert raid10 raid10 4 8 $vg $lv1
# Convert raid10 to 10 stripes and 64K stripesize
# FIXME: change once we support odd numbers of raid10 stripes
-not _reshape_layout raid10 9 $vg $lv1 --stripes 9 --stripesize 64K
-_reshape_layout raid10 10 $vg $lv1 --stripes 10 --stripesize 64K
+not _reshape_layout raid10 4 9 $vg $lv1 --stripes 9 --stripesize 64K
+_reshape_layout raid10 5 10 $vg $lv1 --stripes 10 --stripesize 64K
check lv_first_seg_field $vg/$lv1 stripesize "64.00k"
# Convert raid6_n_6 -> striped
-_lvconvert striped striped 5 $vg $lv1
+_lvconvert striped striped 5 5 $vg $lv1
check lv_first_seg_field $vg/$lv1 stripesize "64.00k"
vgremove -ff $vg
diff --git a/test/shell/lvconvert-raid-takeover.sh b/test/shell/lvconvert-raid-takeover.sh
index 5d8f858..2ce6367 100644
--- a/test/shell/lvconvert-raid-takeover.sh
+++ b/test/shell/lvconvert-raid-takeover.sh
@@ -33,6 +33,7 @@ function _lvcreate
lvcreate -y -aey --type $level -i $req_stripes -L $size -n $lv $vg
check lv_field $vg/$lv segtype "$level"
+ check lv_field $vg/$lv data_stripes $req_stripes
check lv_field $vg/$lv stripes $stripes
mkfs.ext4 "$DM_DEV_DIR/$vg/$lv"
fsck -fn "$DM_DEV_DIR/$vg/$lv"
@@ -42,10 +43,11 @@ function _lvconvert
{
local req_level=$1
local level=$2
- local stripes=$3
- local vg=$4
- local lv=$5
- local region_size=$6
+ local data_stripes=$3
+ local stripes=$4
+ local vg=$5
+ local lv=$6
+ local region_size=$7
local wait_and_check=1
local R=""
@@ -56,6 +58,7 @@ function _lvconvert
lvconvert -y --ty $req_level $R $vg/$lv
[ $? -ne 0 ] && return $?
check lv_field $vg/$lv segtype "$level"
+ check lv_field $vg/$lv data_stripes $data_stripes
check lv_field $vg/$lv stripes $stripes
if [ "$wait_and_check" -eq 1 ]
then
@@ -70,19 +73,19 @@ function _invalid_raid5_conversions
local vg=$1
local lv=$2
- not _lvconvert striped 4 $vg $lv1
- not _lvconvert raid0 raid0 4 $vg $lv1
- not _lvconvert raid0_meta raid0_meta 4 $vg $lv1
- not _lvconvert raid4 raid4 5 $vg $lv1
- not _lvconvert raid5_ls raid5_ls 5 $vg $lv1
- not _lvconvert raid5_rs raid5_rs 5 $vg $lv1
- not _lvconvert raid5_la raid5_la 5 $vg $lv1
- not _lvconvert raid5_ra raid5_ra 5 $vg $lv1
- not _lvconvert raid6_zr raid6_zr 6 $vg $lv1
- not _lvconvert raid6_nr raid6_nr 6 $vg $lv1
- not _lvconvert raid6_nc raid6_nc 6 $vg $lv1
- not _lvconvert raid6_n_6 raid6_n_6 6 $vg $lv1
- not _lvconvert raid6 raid6_n_6 6 $vg $lv1
+ not _lvconvert striped 4 4 $vg $lv1
+ not _lvconvert raid0 raid0 4 4 $vg $lv1
+ not _lvconvert raid0_meta raid0_meta 4 4 $vg $lv1
+ not _lvconvert raid4 raid4 4 5 $vg $lv1
+ not _lvconvert raid5_ls raid5_ls 4 5 $vg $lv1
+ not _lvconvert raid5_rs raid5_rs 4 5 $vg $lv1
+ not _lvconvert raid5_la raid5_la 4 5 $vg $lv1
+ not _lvconvert raid5_ra raid5_ra 4 5 $vg $lv1
+ not _lvconvert raid6_zr raid6_zr 4 6 $vg $lv1
+ not _lvconvert raid6_nr raid6_nr 4 6 $vg $lv1
+ not _lvconvert raid6_nc raid6_nc 4 6 $vg $lv1
+ not _lvconvert raid6_n_6 raid6_n_6 4 6 $vg $lv1
+ not _lvconvert raid6 raid6_n_6 4 6 $vg $lv1
}
# Delayst leg so that rebuilding status characters
@@ -162,116 +165,116 @@ _lvcreate raid4 3 4 8M $vg $lv1
aux wait_for_sync $vg $lv1
# Convert raid4 -> striped
-not _lvconvert striped striped 3 $vg $lv1 512k
-_lvconvert striped striped 3 $vg $lv1
+not _lvconvert striped striped 3 3 $vg $lv1 512k
+_lvconvert striped striped 3 3 $vg $lv1
# Convert striped -> raid4
-_lvconvert raid4 raid4 4 $vg $lv1 64k
+_lvconvert raid4 raid4 3 4 $vg $lv1 64k
check lv_field $vg/$lv1 regionsize "64.00k"
# Convert raid4 -> raid5_n
-_lvconvert raid5 raid5_n 4 $vg $lv1 128k
+_lvconvert raid5 raid5_n 3 4 $vg $lv1 128k
check lv_field $vg/$lv1 regionsize "128.00k"
# Convert raid5_n -> striped
-_lvconvert striped striped 3 $vg $lv1
+_lvconvert striped striped 3 3 $vg $lv1
# Convert striped -> raid5_n
-_lvconvert raid5_n raid5_n 4 $vg $lv1
+_lvconvert raid5_n raid5_n 3 4 $vg $lv1
# Convert raid5_n -> raid4
-_lvconvert raid4 raid4 4 $vg $lv1
+_lvconvert raid4 raid4 3 4 $vg $lv1
# Convert raid4 -> raid0
-_lvconvert raid0 raid0 3 $vg $lv1
+_lvconvert raid0 raid0 3 3 $vg $lv1
# Convert raid0 -> raid5_n
-_lvconvert raid5_n raid5_n 4 $vg $lv1
+_lvconvert raid5_n raid5_n 3 4 $vg $lv1
# Convert raid5_n -> raid0_meta
-_lvconvert raid0_meta raid0_meta 3 $vg $lv1
+_lvconvert raid0_meta raid0_meta 3 3 $vg $lv1
# Convert raid0_meta -> raid5_n
-_lvconvert raid5 raid5_n 4 $vg $lv1
+_lvconvert raid5 raid5_n 3 4 $vg $lv1
# Convert raid4 -> raid0_meta
-not _lvconvert raid0_meta raid0_meta 3 $vg $lv1 256k
-_lvconvert raid0_meta raid0_meta 3 $vg $lv1
+not _lvconvert raid0_meta raid0_meta 3 3 $vg $lv1 256k
+_lvconvert raid0_meta raid0_meta 3 3 $vg $lv1
# Convert raid0_meta -> raid4
-_lvconvert raid4 raid4 4 $vg $lv1
+_lvconvert raid4 raid4 3 4 $vg $lv1
# Convert raid4 -> raid0
-_lvconvert raid0 raid0 3 $vg $lv1
+_lvconvert raid0 raid0 3 3 $vg $lv1
# Convert raid0 -> raid4
-_lvconvert raid4 raid4 4 $vg $lv1
+_lvconvert raid4 raid4 3 4 $vg $lv1
# Convert raid4 -> striped
-_lvconvert striped striped 3 $vg $lv1
+_lvconvert striped striped 3 3 $vg $lv1
# Convert striped -> raid6_n_6
-_lvconvert raid6_n_6 raid6_n_6 5 $vg $lv1
+_lvconvert raid6_n_6 raid6_n_6 3 5 $vg $lv1
# Convert raid6_n_6 -> striped
-_lvconvert striped striped 3 $vg $lv1
+_lvconvert striped striped 3 3 $vg $lv1
# Convert striped -> raid6_n_6
-_lvconvert raid6 raid6_n_6 5 $vg $lv1
+_lvconvert raid6 raid6_n_6 3 5 $vg $lv1
# Convert raid6_n_6 -> raid5_n
-_lvconvert raid5_n raid5_n 4 $vg $lv1
+_lvconvert raid5_n raid5_n 3 4 $vg $lv1
# Convert raid5_n -> raid6_n_6
-_lvconvert raid6_n_6 raid6_n_6 5 $vg $lv1
+_lvconvert raid6_n_6 raid6_n_6 3 5 $vg $lv1
# Convert raid6_n_6 -> raid4
-_lvconvert raid4 raid4 4 $vg $lv1
+_lvconvert raid4 raid4 3 4 $vg $lv1
# Convert raid4 -> raid6_n_6
-_lvconvert raid6 raid6_n_6 5 $vg $lv1
+_lvconvert raid6 raid6_n_6 3 5 $vg $lv1
# Convert raid6_n_6 -> raid0
-_lvconvert raid0 raid0 3 $vg $lv1
+_lvconvert raid0 raid0 3 3 $vg $lv1
# Convert raid0 -> raid6_n_6
-_lvconvert raid6_n_6 raid6_n_6 5 $vg $lv1
+_lvconvert raid6_n_6 raid6_n_6 3 5 $vg $lv1
# Convert raid6_n_6 -> raid0_meta
-_lvconvert raid0_meta raid0_meta 3 $vg $lv1
+_lvconvert raid0_meta raid0_meta 3 3 $vg $lv1
# Convert raid0_meta -> raid6_n_6
-_lvconvert raid6 raid6_n_6 5 $vg $lv1
+_lvconvert raid6 raid6_n_6 3 5 $vg $lv1
# Convert raid6_n_6 -> striped
-not _lvconvert striped striped 3 $vg $lv1 128k
-_lvconvert striped striped 3 $vg $lv1
+not _lvconvert striped striped 3 3 $vg $lv1 128k
+_lvconvert striped striped 3 3 $vg $lv1
# Convert striped -> raid10
-_lvconvert raid10 raid10 6 $vg $lv1
+_lvconvert raid10 raid10 3 6 $vg $lv1
# Convert raid10 -> raid0
-not _lvconvert raid0 raid0 3 $vg $lv1 64k
-_lvconvert raid0 raid0 3 $vg $lv1
+not _lvconvert raid0 raid0 3 3 $vg $lv1 64k
+_lvconvert raid0 raid0 3 3 $vg $lv1
# Convert raid0 -> raid10
-_lvconvert raid10 raid10 6 $vg $lv1
+_lvconvert raid10 raid10 3 6 $vg $lv1
# Convert raid10 -> raid0_meta
-_lvconvert raid0_meta raid0_meta 3 $vg $lv1
+_lvconvert raid0_meta raid0_meta 3 3 $vg $lv1
# Convert raid0_meta -> raid5
-_lvconvert raid5_n raid5_n 4 $vg $lv1
+_lvconvert raid5_n raid5_n 3 4 $vg $lv1
# Convert raid5_n -> raid0_meta
-_lvconvert raid0_meta raid0_meta 3 $vg $lv1
+_lvconvert raid0_meta raid0_meta 3 3 $vg $lv1
# Convert raid0_meta -> raid10
-_lvconvert raid10 raid10 6 $vg $lv1
+_lvconvert raid10 raid10 3 6 $vg $lv1
# Convert raid10 -> striped
-not _lvconvert striped striped 3 $vg $lv1 256k
-_lvconvert striped striped 3 $vg $lv1
+not _lvconvert striped striped 3 3 $vg $lv1 256k
+_lvconvert striped striped 3 3 $vg $lv1
# Clean up
lvremove -y $vg
@@ -280,51 +283,51 @@ lvremove -y $vg
_lvcreate raid5 4 5 8M $vg $lv1
aux wait_for_sync $vg $lv1
_invalid_raid5_conversions $vg $lv1
-not _lvconvert raid6_rs_6 raid6_rs_6 6 $vg $lv1
-not _lvconvert raid6_la_6 raid6_la_6 6 $vg $lv1
-not _lvconvert raid6_ra_6 raid6_ra_6 6 $vg $lv1
-_lvconvert raid6_ls_6 raid6_ls_6 6 $vg $lv1
-_lvconvert raid5_ls raid5_ls 5 $vg $lv1
+not _lvconvert raid6_rs_6 raid6_rs_6 4 6 $vg $lv1
+not _lvconvert raid6_la_6 raid6_la_6 4 6 $vg $lv1
+not _lvconvert raid6_ra_6 raid6_ra_6 4 6 $vg $lv1
+_lvconvert raid6_ls_6 raid6_ls_6 4 6 $vg $lv1
+_lvconvert raid5_ls raid5_ls 4 5 $vg $lv1
lvremove -y $vg
_lvcreate raid5_ls 4 5 8M $vg $lv1
aux wait_for_sync $vg $lv1
_invalid_raid5_conversions $vg $lv1
-not _lvconvert raid6_rs_6 raid6_rs_6 6 $vg $lv1
-not _lvconvert raid6_la_6 raid6_la_6 6 $vg $lv1
-not _lvconvert raid6_ra_6 raid6_ra_6 6 $vg $lv1
-_lvconvert raid6_ls_6 raid6_ls_6 6 $vg $lv1
-_lvconvert raid5_ls raid5_ls 5 $vg $lv1
+not _lvconvert raid6_rs_6 raid6_rs_6 4 6 $vg $lv1
+not _lvconvert raid6_la_6 raid6_la_6 4 6 $vg $lv1
+not _lvconvert raid6_ra_6 raid6_ra_6 4 6 $vg $lv1
+_lvconvert raid6_ls_6 raid6_ls_6 4 6 $vg $lv1
+_lvconvert raid5_ls raid5_ls 4 5 $vg $lv1
lvremove -y $vg
_lvcreate raid5_rs 4 5 8M $vg $lv1
aux wait_for_sync $vg $lv1
_invalid_raid5_conversions $vg $lv1
-not _lvconvert raid6_ra_6 raid6_ra_6 6 $vg $lv1
-not _lvconvert raid6_la_6 raid6_la_6 6 $vg $lv1
-not _lvconvert raid6_ra_6 raid6_ra_6 6 $vg $lv1
-_lvconvert raid6_rs_6 raid6_rs_6 6 $vg $lv1
-_lvconvert raid5_rs raid5_rs 5 $vg $lv1
+not _lvconvert raid6_ra_6 raid6_ra_6 4 6 $vg $lv1
+not _lvconvert raid6_la_6 raid6_la_6 4 6 $vg $lv1
+not _lvconvert raid6_ra_6 raid6_ra_6 4 6 $vg $lv1
+_lvconvert raid6_rs_6 raid6_rs_6 4 6 $vg $lv1
+_lvconvert raid5_rs raid5_rs 4 5 $vg $lv1
lvremove -y $vg
_lvcreate raid5_la 4 5 8M $vg $lv1
aux wait_for_sync $vg $lv1
_invalid_raid5_conversions $vg $lv1
-not _lvconvert raid6_ls_6 raid6_ls_6 6 $vg $lv1
-not _lvconvert raid6_rs_6 raid6_rs_6 6 $vg $lv1
-not _lvconvert raid6_ra_6 raid6_ra_6 6 $vg $lv1
-_lvconvert raid6_la_6 raid6_la_6 6 $vg $lv1
-_lvconvert raid5_la raid5_la 5 $vg $lv1
+not _lvconvert raid6_ls_6 raid6_ls_6 4 6 $vg $lv1
+not _lvconvert raid6_rs_6 raid6_rs_6 4 6 $vg $lv1
+not _lvconvert raid6_ra_6 raid6_ra_6 4 6 $vg $lv1
+_lvconvert raid6_la_6 raid6_la_6 4 6 $vg $lv1
+_lvconvert raid5_la raid5_la 4 5 $vg $lv1
lvremove -y $vg
_lvcreate raid5_ra 4 5 8M $vg $lv1
aux wait_for_sync $vg $lv1
_invalid_raid5_conversions $vg $lv1
-not _lvconvert raid6_ls_6 raid6_ls_6 6 $vg $lv1
-not _lvconvert raid6_rs_6 raid6_rs_6 6 $vg $lv1
-not _lvconvert raid6_la_6 raid6_la_6 6 $vg $lv1
-_lvconvert raid6_ra_6 raid6_ra_6 6 $vg $lv1
-_lvconvert raid5_ra raid5_ra 5 $vg $lv1
+not _lvconvert raid6_ls_6 raid6_ls_6 4 6 $vg $lv1
+not _lvconvert raid6_rs_6 raid6_rs_6 4 6 $vg $lv1
+not _lvconvert raid6_la_6 raid6_la_6 4 6 $vg $lv1
+_lvconvert raid6_ra_6 raid6_ra_6 4 6 $vg $lv1
+_lvconvert raid5_ra raid5_ra 4 5 $vg $lv1
lvremove -y $vg
else
7 years, 1 month
master - man: put some commands into advanced usage section
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=62abae1525cec51279c...
Commit: 62abae1525cec51279c39c5127afaced8f0463e2
Parent: eb9586bd3bc6741a3819147b35546ae35f363de1
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Feb 28 17:04:46 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Mar 1 10:22:48 2017 -0600
man: put some commands into advanced usage section
and separate commands with --
---
man/Makefile.in | 4 +-
tools/command.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++----
tools/lvmcmdline.c | 2 +-
3 files changed, 101 insertions(+), 11 deletions(-)
diff --git a/man/Makefile.in b/man/Makefile.in
index ca2249c..3ae00d9 100644
--- a/man/Makefile.in
+++ b/man/Makefile.in
@@ -144,12 +144,12 @@ Makefile: Makefile.in
man-generator:
$(CC) -DMAN_PAGE_GENERATOR -I$(top_builddir)/tools $(CFLAGS) $(top_srcdir)/tools/command.c -o $@
- - ./man-generator lvmconfig > test.gen
+ - ./man-generator --primary lvmconfig > test.gen
if [ ! -s test.gen ] ; then cp genfiles/*.gen $(top_builddir)/man; fi;
$(MAN8GEN): man-generator
echo "Generating $@" ;
- if [ ! -e $@.gen ]; then ./man-generator $(basename $@) $(top_srcdir)/man/$@.des > $@.gen; fi
+ if [ ! -e $@.gen ]; then ./man-generator --primary $(basename $@) $(top_srcdir)/man/$@.des > $@.gen; ./man-generator --secondary $(basename $@) >> $@.gen; fi
if [ -f $(top_srcdir)/man/$@.end ]; then cat $(top_srcdir)/man/$@.end >> $@.gen; fi;
cat $(top_srcdir)/man/see_also.end >> $@.gen
$(SED) -e "s+#VERSION#+$(LVM_VERSION)+;s+#DEFAULT_SYS_DIR#+$(DEFAULT_SYS_DIR)+;s+#DEFAULT_ARCHIVE_DIR#+$(DEFAULT_ARCHIVE_DIR)+;s+#DEFAULT_BACKUP_DIR#+$(DEFAULT_BACKUP_DIR)+;s+#DEFAULT_PROFILE_DIR#+$(DEFAULT_PROFILE_DIR)+;s+#DEFAULT_CACHE_DIR#+$(DEFAULT_CACHE_DIR)+;s+#DEFAULT_LOCK_DIR#+$(DEFAULT_LOCK_DIR)+;s+#CLVMD_PATH#+@CLVMD_PATH@+;s+#LVM_PATH#+@LVM_PATH@+;s+#DEFAULT_RUN_DIR#+@DEFAULT_RUN_DIR@+;s+#DEFAULT_PID_DIR#+@DEFAULT_PID_DIR@+;s+#SYSTEMD_GENERATOR_DIR#+$(SYSTEMD_GENERATOR_DIR)+;s+#DEFAULT_MANGLING#+$(DEFAULT_MANGLING)+;" $@.gen > $@
diff --git a/tools/command.c b/tools/command.c
index a8c38ba..7c5bf7c 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -2866,7 +2866,7 @@ static void include_description_file(char *name, char *des_file)
close(fd);
}
-void print_man(char *name, char *des_file, int include_primary, int include_secondary)
+void print_man(char *name, char *des_file, int secondary)
{
struct command_name *cname;
struct command *cmd, *prev_cmd = NULL;
@@ -2905,10 +2905,7 @@ void print_man(char *name, char *des_file, int include_primary, int include_seco
if (cmd->cmd_flags & CMD_FLAG_PREVIOUS_SYNTAX)
continue;
- if ((cmd->cmd_flags & CMD_FLAG_SECONDARY_SYNTAX) && !include_secondary)
- continue;
-
- if (!(cmd->cmd_flags & CMD_FLAG_SECONDARY_SYNTAX) && !include_primary)
+ if ((cmd->cmd_flags & CMD_FLAG_SECONDARY_SYNTAX) && !secondary)
continue;
if (strcmp(name, cmd->name))
@@ -2995,6 +2992,12 @@ void print_man(char *name, char *des_file, int include_primary, int include_seco
printf(".SH VARIABLES\n");
printf(".br\n");
print_man_all_positions_desc(cname);
+ } else {
+ if (cname->variants > 2) {
+ printf("--\n");
+ printf("\n");
+ printf(".br\n");
+ }
}
printf("\n");
@@ -3002,20 +3005,107 @@ void print_man(char *name, char *des_file, int include_primary, int include_seco
}
}
+void print_man_secondary(char *name)
+{
+ struct command *cmd;
+ char *lvmname = name;
+ int header = 0;
+ int i;
+
+ if (!strncmp(name, "lvm-", 4)) {
+ name[3] = ' ';
+ name += 4;
+ }
+
+ for (i = 0; i < COMMAND_COUNT; i++) {
+
+ cmd = &commands[i];
+
+ if (cmd->cmd_flags & CMD_FLAG_PREVIOUS_SYNTAX)
+ continue;
+
+ if (!(cmd->cmd_flags & CMD_FLAG_SECONDARY_SYNTAX))
+ continue;
+
+ if (strcmp(name, cmd->name))
+ continue;
+
+ if (!header) {
+ printf(".SH ADVANCED USAGE\n");
+ printf("Alternate command forms, advanced command usage, and listing of all valid syntax for completeness.\n");
+ printf(".P\n");
+ header = 1;
+ }
+
+ if (cmd->desc) {
+ print_desc_man(cmd->desc);
+ printf(".P\n");
+ }
+
+ print_man_usage(lvmname, cmd);
+
+ printf("--\n");
+ printf("\n");
+ printf(".br\n");
+
+ printf("\n");
+ }
+}
+
int main(int argc, char *argv[])
{
+ char *cmdname = NULL;
+ char *desfile = NULL;
+ int primary = 0;
+ int secondary = 0;
+
memset(&commands, 0, sizeof(commands));
- if (argc < 2) {
- log_error("Usage: %s <command> [/path/to/description-file]", argv[0]);
+ static struct option long_options[] = {
+ {"primary", no_argument, 0, 'p' },
+ {"secondary", no_argument, 0, 's' },
+ {0, 0, 0, 0 }
+ };
+
+ while (1) {
+ int c;
+ int option_index = 0;
+
+ c = getopt_long(argc, argv, "ps", long_options, &option_index);
+ if (c == -1)
+ break;
+
+ switch (c) {
+ case '0':
+ break;
+ case 'p':
+ primary = 1;
+ break;
+ case 's':
+ secondary = 1;
+ break;
+ }
+ }
+
+ if (!primary && !secondary) {
+ log_error("Usage: %s --primary|--secondary <command> [/path/to/description-file]", argv[0]);
exit(EXIT_FAILURE);
}
+ if (optind < argc)
+ cmdname = strdup(argv[optind++]);
+
+ if (optind < argc)
+ desfile = argv[optind++];
+
define_commands(NULL);
factor_common_options();
- print_man(argv[1], (argc > 2) ? argv[2] : NULL, 1, 1);
+ if (primary)
+ print_man(cmdname, desfile, secondary);
+ else if (secondary)
+ print_man_secondary(cmdname);
return 0;
}
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index d440987..e2be7c7 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1720,7 +1720,7 @@ static int _usage(const char *name, int longhelp)
print_usage_common_cmd(cname, cmd);
print_usage_common_lvm(cname, cmd);
} else
- log_print("Use --longhelp to show all options.");
+ log_print("Use --longhelp to show all options and advanced commands.");
return 1;
}
7 years, 1 month
master - commands: SECONDARY flag changes in cmd defs
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=eb9586bd3bc6741a381...
Commit: eb9586bd3bc6741a3819147b35546ae35f363de1
Parent: d6dd700bf75d218a6f7627451d020232d3d88c31
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Feb 28 16:15:11 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Mar 1 10:22:48 2017 -0600
commands: SECONDARY flag changes in cmd defs
Add/remove the SECONDARY_SYNTAX flag to cmd defs.
cmd defs with this flag will be listed under the
ADVANCED USAGE man page section, so that the main
USAGE section contains the most common commands
without distraction.
- When multiple cmd defs do the same thing, one variant
can be displayed in the first list.
- Very advanced, unusual or uncommon commands should be
in the second list.
---
tools/command-lines.in | 26 ++++++++++++++------------
1 files changed, 14 insertions(+), 12 deletions(-)
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 1727bbb..5f65093 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -340,6 +340,7 @@ OP: PV ...
ID: lvconvert_raid_types
DESC: Convert LV to type mirror (also see type raid1).
RULE: all not lv_is_locked lv_is_pvmove
+FLAGS: SECONDARY_SYNTAX
# When LV is already raid, this changes the raid layout
# (changing layout of raid0 and raid1 not allowed.)
@@ -379,6 +380,7 @@ ID: lvconvert_change_region_size
DESC: Change the region size of an LV.
RULE: all not lv_is_locked lv_is_pvmove
RULE: all not LV_raid0
+FLAGS: SECONDARY_SYNTAX
---
@@ -411,6 +413,7 @@ OP: PV ...
ID: lvconvert_change_mirrorlog
DESC: Change the type of mirror log used by a mirror LV.
RULE: all not lv_is_locked lv_is_pvmove
+FLAGS: SECONDARY_SYNTAX
---
@@ -543,6 +546,7 @@ lvconvert --uncache LV_cache_thinpool
OO: OO_LVCONVERT
ID: lvconvert_split_and_remove_cachepool
DESC: Separate and delete the cache pool from a cache LV.
+FLAGS: SECONDARY_SYNTAX
---
@@ -550,6 +554,7 @@ lvconvert --swapmetadata --poolmetadata LV LV_thinpool_cachepool
OO: --chunksize SizeKB, OO_LVCONVERT
ID: lvconvert_swap_pool_metadata
DESC: Swap metadata LV in a thin pool or cache pool (for repair only).
+FLAGS: SECONDARY_SYNTAX
---
@@ -597,6 +602,7 @@ OO: OO_LVCONVERT
ID: lvconvert_split_cow_snapshot
DESC: Separate a COW snapshot from its origin LV.
RULE: all not lv_is_locked lv_is_pvmove lv_is_origin lv_is_external_origin lv_is_merging_cow
+FLAGS: SECONDARY_SYNTAX
---
@@ -614,9 +620,9 @@ OO: --snapshot, --chunksize SizeKB, --zero Bool, OO_LVCONVERT
ID: lvconvert_combine_split_snapshot
DESC: Combine a former COW snapshot (second arg) with a former
DESC: origin LV (first arg) to reverse a splitsnapshot command.
-FLAGS: SECONDARY_SYNTAX
RULE: all not lv_is_locked lv_is_pvmove
RULE: all and lv_is_visible
+FLAGS: SECONDARY_SYNTAX
lvconvert --snapshot LV LV_linear
OO: --type snapshot, --chunksize SizeKB, --zero Bool, OO_LVCONVERT
@@ -625,6 +631,7 @@ DESC: Combine a former COW snapshot (second arg) with a former
DESC: origin LV (first arg) to reverse a splitsnapshot command.
RULE: all not lv_is_locked lv_is_pvmove
RULE: all and lv_is_visible
+FLAGS: SECONDARY_SYNTAX
---
@@ -745,6 +752,7 @@ OO: --stripes Number, --stripesize SizeKB, OO_LVCREATE
OP: PV ...
ID: lvcreate_striped
DESC: Create a striped LV.
+FLAGS: SECONDARY_SYNTAX
lvcreate --stripes Number --size SizeMB VG
OO: --type striped, --stripesize SizeKB, OO_LVCREATE
@@ -759,6 +767,7 @@ OO: --mirrors SNumber, --mirrorlog MirrorLog, --regionsize RegionSize, --stripes
OP: PV ...
ID: lvcreate_mirror
DESC: Create a mirror LV (also see --type raid1).
+FLAGS: SECONDARY_SYNTAX
# alternate form of lvcreate --type raid1|mirror
lvcreate --mirrors SNumber --size SizeMB VG
@@ -816,6 +825,7 @@ OO: --type snapshot, --chunksize SizeKB, OO_LVCREATE
OP: PV ...
ID: lvcreate_cow_snapshot_with_virtual_origin
DESC: Create a sparse COW snapshot LV of a virtual origin LV.
+FLAGS: SECONDARY_SYNTAX
---
@@ -877,6 +887,7 @@ OO: --thin, OO_LVCREATE_POOL, OO_LVCREATE_THIN, OO_LVCREATE
IO: --mirrors 0
ID: lvcreate_thin_vol
DESC: Create a thin LV in a thin pool.
+FLAGS: SECONDARY_SYNTAX
# alternate form of lvcreate --type thin
lvcreate --type thin --virtualsize SizeMB LV_thinpool
@@ -896,7 +907,6 @@ OO: --type thin, --thin, OO_LVCREATE_THIN, OO_LVCREATE
IO: --mirrors 0
ID: lvcreate_thin_vol
DESC: Create a thin LV in a thin pool (variant, infers --type thin).
-FLAGS: SECONDARY_SYNTAX
# alternate form of lvcreate --type thin
lvcreate --virtualsize SizeMB LV_thinpool
@@ -915,6 +925,7 @@ OO: --thin, OO_LVCREATE_THIN, OO_LVCREATE
IO: --mirrors 0
ID: lvcreate_thin_snapshot
DESC: Create a thin LV that is a snapshot of an existing thin LV.
+FLAGS: SECONDARY_SYNTAX
# alternate form of lvcreate --type thin
lvcreate --thin LV_thin
@@ -946,6 +957,7 @@ IO: --mirrors 0
ID: lvcreate_thin_snapshot_of_external
DESC: Create a thin LV that is a snapshot of an external origin LV
DESC: (infers --type thin).
+FLAGS: SECONDARY_SYNTAX
---
@@ -1153,7 +1165,6 @@ OO: --alloc Alloc, --autobackup Bool, --force, --mirrors SNumber,
--type SegType
ID: lvextend_by_pv
DESC: Extend an LV by specified PV extents.
-FLAGS: SECONDARY_SYNTAX
lvextend --poolmetadatasize SizeMB LV_thinpool
OO: --alloc Alloc, --autobackup Bool, --force, --mirrors SNumber,
@@ -1226,7 +1237,6 @@ OO: --alloc Alloc, --autobackup Bool, --force,
--type SegType
ID: lvresize_by_pv
DESC: Resize an LV by specified PV extents.
-FLAGS: SECONDARY_SYNTAX
lvresize --poolmetadatasize SizeMB LV_thinpool
OO: --alloc Alloc, --autobackup Bool, --force,
@@ -1504,7 +1514,6 @@ vgexport --all
OO: OO_VGEXPORT
ID: vgexport_all
DESC: Export all VGs.
-FLAGS: SECONDARY_SYNTAX
---
@@ -1628,14 +1637,12 @@ config
OO: OO_CONFIG
OP: String ...
ID: lvmconfig_general
-FLAGS: SECONDARY_SYNTAX
# use lvmconfig
dumpconfig
OO: OO_CONFIG
OP: String ...
ID: lvmconfig_general
-FLAGS: SECONDARY_SYNTAX
devtypes
OO: --aligned, --binary, --nameprefixes, --noheadings,
@@ -1669,7 +1676,6 @@ ID: version_general
# deprecated
pvdata
ID: pvdata_general
-FLAGS: SECONDARY_SYNTAX
segtypes
ID: segtypes_general
@@ -1683,22 +1689,18 @@ ID: tags_general
# deprecated
lvmchange
ID: lvmchange_general
-FLAGS: SECONDARY_SYNTAX
# deprecated
lvmdiskscan
OO: --lvmpartition, --readonly
ID: lvmdiskscan_general
-FLAGS: SECONDARY_SYNTAX
# deprecated
lvmsadc
ID: lvmsadc_general
-FLAGS: SECONDARY_SYNTAX
# deprecated
lvmsar
OO: --full, --stdin
ID: lvmsar_general
-FLAGS: SECONDARY_SYNTAX
7 years, 1 month
master - raid: rework _raid_target_present()
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d6dd700bf75d218a6f7...
Commit: d6dd700bf75d218a6f7627451d020232d3d88c31
Parent: 7a064303fe1a14e205a50abc5a54e38467fcb455
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Wed Mar 1 14:52:23 2017 +0100
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Wed Mar 1 14:52:23 2017 +0100
raid: rework _raid_target_present()
Recently added check for reshaping in this function called for
a cleanup to avoid proliferating it with more explicit conditionals.
Base the reshaping check on the given _features array.
Related: rhbz834579
Related: rhbz1191935
Related: rhbz1191978
---
lib/raid/raid.c | 43 +++++++++++++++++++++++++++++--------------
1 files changed, 29 insertions(+), 14 deletions(-)
diff --git a/lib/raid/raid.c b/lib/raid/raid.c
index 6815454..6439a3e 100644
--- a/lib/raid/raid.c
+++ b/lib/raid/raid.c
@@ -448,19 +448,32 @@ out:
return r;
}
+/* Define raid feature based on the tuple(major, minor, patchlevel) of raid target */
+struct raid_feature {
+ uint32_t maj;
+ uint32_t min;
+ uint32_t patchlevel;
+ unsigned raid_feature;
+ const char *feature;
+};
+
+/* Return true if tuple(@maj, @min, @patchlevel) is greater/equal to @*feature members */
+static int _check_feature(const struct raid_feature *feature, uint32_t maj, uint32_t min, uint32_t patchlevel)
+{
+ return (maj > feature->maj) ||
+ (maj == feature->maj && min >= feature->min) ||
+ (maj == feature->maj && min == feature->min && patchlevel >= feature->patchlevel);
+}
+
static int _raid_target_present(struct cmd_context *cmd,
const struct lv_segment *seg __attribute__((unused)),
unsigned *attributes)
{
/* List of features with their kernel target version */
- static const struct feature {
- uint32_t maj;
- uint32_t min;
- unsigned raid_feature;
- const char *feature;
- } _features[] = {
- { 1, 3, RAID_FEATURE_RAID10, SEG_TYPE_NAME_RAID10 },
- { 1, 7, RAID_FEATURE_RAID0, SEG_TYPE_NAME_RAID0 },
+ const struct raid_feature _features[] = {
+ { 1, 3, 0, RAID_FEATURE_RAID10, SEG_TYPE_NAME_RAID10 },
+ { 1, 7, 0, RAID_FEATURE_RAID0, SEG_TYPE_NAME_RAID0 },
+ { 1, 10, 1, RAID_FEATURE_RESHAPE, "reshaping" },
};
static int _raid_checked = 0;
@@ -482,22 +495,24 @@ static int _raid_target_present(struct cmd_context *cmd,
return_0;
for (i = 0; i < DM_ARRAY_SIZE(_features); ++i)
- if ((maj > _features[i].maj) ||
- (maj == _features[i].maj && min >= _features[i].min))
+ if (_check_feature(_features + i, maj, min, patchlevel))
_raid_attrs |= _features[i].raid_feature;
else
log_very_verbose("Target raid does not support %s.",
_features[i].feature);
+ /*
+ * Seperate check for proper raid4 mapping supported
+ *
+ * If we get more of these range checks, avoid them
+ * altogether by enhancing 'struct raid_feature'
+ * and _check_feature() to handle them.
+ */
if (!(maj == 1 && (min == 8 || (min == 9 && patchlevel == 0))))
_raid_attrs |= RAID_FEATURE_RAID4;
else
log_very_verbose("Target raid does not support %s.",
SEG_TYPE_NAME_RAID4);
-
- if (maj > 1 ||
- (maj == 1 && (min > 10 || (min == 10 && patchlevel >= 1))))
- _raid_attrs |= RAID_FEATURE_RESHAPE;
}
if (attributes)
7 years, 1 month