master - lvconvert: require different LV for pool
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=04d7444afa88f1f4e56...
Commit: 04d7444afa88f1f4e56065888124fff775a5638f
Parent: a96c8b46b62c316381eb029416b92197d9cfa4de
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Apr 11 12:15:10 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 11 12:17:14 2017 -0500
lvconvert: require different LV for pool
When convering an LV to a cache or thin LV, require
that an LV being converted to cache pool or thin pool
at the same time be a different LV.
---
tools/lvconvert.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index c18b5a4..f4ee660 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3826,6 +3826,12 @@ static int _lvconvert_to_cache_vol_single(struct cmd_context *cmd,
goto out;
}
+ if (cachepool_lv == lv) {
+ log_error("Use a different LV for cache pool LV and cache LV %s.",
+ display_lvname(cachepool_lv));
+ goto out;
+ }
+
if (!_lvconvert_to_pool(cmd, cachepool_lv, lv, 0, 1, &vg->pvs)) {
log_error("LV %s could not be converted to a cache pool.",
display_lvname(cachepool_lv));
@@ -3924,6 +3930,12 @@ static int _lvconvert_to_thin_with_external_single(struct cmd_context *cmd,
goto out;
}
+ if (thinpool_lv == lv) {
+ log_error("Use a different LV for thin pool LV and thin LV %s.",
+ display_lvname(thinpool_lv));
+ goto out;
+ }
+
if (!_lvconvert_to_pool(cmd, thinpool_lv, lv, 1, 0, &vg->pvs)) {
log_error("LV %s could not be converted to a thin pool.",
display_lvname(thinpool_lv));
7 years
master - lvconvert: prevent duplicate use of metadata lv
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a96c8b46b62c316381e...
Commit: a96c8b46b62c316381eb029416b92197d9cfa4de
Parent: e0c169f8b7f214100ad11c68b1cab799e8adaaed
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Apr 11 12:07:14 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 11 12:11:00 2017 -0500
lvconvert: prevent duplicate use of metadata lv
The LV being processed cannot be used as the
pool metadata LV.
---
tools/lvconvert.c | 19 +++++++++++++++----
1 files changed, 15 insertions(+), 4 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index ee7fb8b..c18b5a4 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2658,10 +2658,15 @@ static int _lvconvert_swap_pool_metadata(struct cmd_context *cmd,
* Create a new pool LV, using the lv arg as the data sub LV.
* The metadata sub LV is either a new LV created here, or an
* existing LV specified by --poolmetadata.
+ *
+ * process_single_lv is the LV currently being processed by
+ * process_each_lv(). It will sometimes be the same as the
+ * lv arg, and sometimes not.
*/
static int _lvconvert_to_pool(struct cmd_context *cmd,
struct logical_volume *lv,
+ struct logical_volume *process_single_lv,
int to_thinpool,
int to_cachepool,
struct dm_list *use_pvh)
@@ -2773,6 +2778,12 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
return 0;
}
+ if (metadata_lv == process_single_lv) {
+ log_error("Use a different LV for pool metadata %s.",
+ display_lvname(metadata_lv));
+ return 0;
+ }
+
if (!lv_is_visible(metadata_lv)) {
log_error("Can't convert internal LV %s.",
display_lvname(metadata_lv));
@@ -3765,7 +3776,7 @@ static int _lvconvert_to_pool_single(struct cmd_context *cmd,
} else
use_pvh = &lv->vg->pvs;
- if (!_lvconvert_to_pool(cmd, lv, to_thinpool, to_cachepool, use_pvh))
+ if (!_lvconvert_to_pool(cmd, lv, lv, to_thinpool, to_cachepool, use_pvh))
return_ECMD_FAILED;
return ECMD_PROCESSED;
@@ -3815,7 +3826,7 @@ static int _lvconvert_to_cache_vol_single(struct cmd_context *cmd,
goto out;
}
- if (!_lvconvert_to_pool(cmd, cachepool_lv, 0, 1, &vg->pvs)) {
+ if (!_lvconvert_to_pool(cmd, cachepool_lv, lv, 0, 1, &vg->pvs)) {
log_error("LV %s could not be converted to a cache pool.",
display_lvname(cachepool_lv));
goto out;
@@ -3913,7 +3924,7 @@ static int _lvconvert_to_thin_with_external_single(struct cmd_context *cmd,
goto out;
}
- if (!_lvconvert_to_pool(cmd, thinpool_lv, 1, 0, &vg->pvs)) {
+ if (!_lvconvert_to_pool(cmd, thinpool_lv, lv, 1, 0, &vg->pvs)) {
log_error("LV %s could not be converted to a thin pool.",
display_lvname(thinpool_lv));
goto out;
@@ -4066,7 +4077,7 @@ static int _lvconvert_to_pool_or_swap_metadata_single(struct cmd_context *cmd,
return _lvconvert_swap_pool_metadata_single(cmd, lv, handle);
}
- if (!_lvconvert_to_pool(cmd, lv, to_thinpool, to_cachepool, use_pvh))
+ if (!_lvconvert_to_pool(cmd, lv, lv, to_thinpool, to_cachepool, use_pvh))
return_ECMD_FAILED;
return ECMD_PROCESSED;
7 years
master - man lvmraid: improve text layout
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e0c169f8b7f214100ad...
Commit: e0c169f8b7f214100ad11c68b1cab799e8adaaed
Parent: 2fd9ae070351dd2682d42aad3df5c9acec195bc0
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Apr 11 10:55:02 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 11 10:55:02 2017 -0500
man lvmraid: improve text layout
---
man/lvmraid.7_main | 64 +++++++++++++++++++++++++++++++++------------------
1 files changed, 41 insertions(+), 23 deletions(-)
diff --git a/man/lvmraid.7_main b/man/lvmraid.7_main
index d000687..99218a5 100644
--- a/man/lvmraid.7_main
+++ b/man/lvmraid.7_main
@@ -520,6 +520,7 @@ lvs -a -o name,segtype,devices
[lvr6_rmeta_3] linear /dev/sdd(...)
[lvr6_rmeta_4] linear /dev/sde(...)
[lvr6_rmeta_5] linear /dev/sdf(...)
+.fi
.B raid10
.br
@@ -905,6 +906,8 @@ between raid4 and raid5.
between raid4/raid5 and raid6.
.IP \(bu 3
between striped/raid0 and raid10.
+.IP \(bu 3
+between striped and raid4.
.SS Examples
@@ -935,8 +938,6 @@ between striped/raid0 and raid10.
[lv_mimage_0] linear 100.00g
[lv_mimage_1] linear 100.00g
[lv_mlog] linear 3.00m
-.IP \(bu 3
-between striped and raid4.
.SS Examples
@@ -1123,21 +1124,27 @@ For performance reasons the raid6_nr RaidLV can be restriped.
Convert it from 3-way striped to 5-way-striped.
.nf
-# lvconvert --stripes 5 -y vg/lv
+# lvconvert --stripes 5 vg/lv
Using default stripesize 64.00 KiB.
- WARNING: Adding stripes to active logical volume vg/lv will grow it from 99 to 165 extents!
- Run "lvresize -l99 vg/lv" to shrink it or use the additional capacity.
+ WARNING: Adding stripes to active logical volume vg/lv will \
+ grow it from 99 to 165 extents!
+ Run "lvresize -l99 vg/lv" to shrink it or use the additional \
+ capacity.
Logical volume vg/lv successfully converted.
# lvs
- LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
+ LV VG Attr LSize Cpy%Sync
root fedora -wi-ao---- 15.00g
swap fedora -wi-ao---- 3.99g
- lv vg rwi-a-r-s- 652.00m 52.94
+ lv vg rwi-a-r-s- 652.00m 52.94
# lvs -a -o lv_name,attr,segtype,seg_pe_ranges,dataoffset vg
LV Attr Type PE Ranges DOff
- lv rwi-a-r--- raid6_nr lv_rimage_0:0-33 lv_rimage_1:0-33 lv_rimage_2:0-33 ... lv_rimage_5:0-33 lv_rimage_6:0-33 0
+ lv rwi-a-r--- raid6_nr lv_rimage_0:0-33 \
+ lv_rimage_1:0-33 \
+ lv_rimage_2:0-33 ... \
+ lv_rimage_5:0-33 \
+ lv_rimage_6:0-33 0
[lv_rimage_0] iwi-aor--- linear /dev/sda:0-32 0
[lv_rimage_0] iwi-aor--- linear /dev/sda:34-34
[lv_rimage_1] iwi-aor--- linear /dev/sdaa:0-32 0
@@ -1163,28 +1170,35 @@ The force option needs to be used, because removing stripes
(i.e. image SubLVs) from a RaidLV will shrink its size.
.nf
-# lvconvert --stripes 4 --force -y vg/lv
+# lvconvert --stripes 4 vg/lv
Using default stripesize 64.00 KiB.
- WARNING: Removing stripes from active logical volume vg/lv will shrink it from 660.00 MiB to 528.00 MiB!
+ WARNING: Removing stripes from active logical volume vg/lv will \
+ shrink it from 660.00 MiB to 528.00 MiB!
THIS MAY DESTROY (PARTS OF) YOUR DATA!
- If that leaves the logical volume larger than 206 extents due to stripe rounding,
+ If that leaves the logical volume larger than 206 extents due \
+ to stripe rounding,
you may want to grow the content afterwards (filesystem etc.)
- WARNING: too remove freed stripes after the conversion has finished, you have to run "lvconvert --stripes 4 vg/lv"
+ WARNING: too remove freed stripes after the conversion has finished,\
+ you have to run "lvconvert --stripes 4 vg/lv"
Logical volume vg/lv successfully converted.
# lvs -a -o lv_name,attr,segtype,seg_pe_ranges,dataoffset vg
- LV Attr Type PE Ranges DOff
- lv rwi-a-r-s- raid6_nr lv_rimage_0:0-33 lv_rimage_1:0-33 lv_rimage_2:0-33 ... lv_rimage_5:0-33 lv_rimage_6:0-33 0
- [lv_rimage_0] Iwi-aor--- linear /dev/sda:0-32 0
+ LV Attr Type PE Ranges DOff
+ lv rwi-a-r-s- raid6_nr lv_rimage_0:0-33 \
+ lv_rimage_1:0-33 \
+ lv_rimage_2:0-33 ... \
+ lv_rimage_5:0-33
+ lv_rimage_6:0-33 0
+ [lv_rimage_0] Iwi-aor--- linear /dev/sda:0-32 0
[lv_rimage_0] Iwi-aor--- linear /dev/sda:34-34
- [lv_rimage_1] Iwi-aor--- linear /dev/sdaa:0-32 0
+ [lv_rimage_1] Iwi-aor--- linear /dev/sdaa:0-32 0
[lv_rimage_1] Iwi-aor--- linear /dev/sdaa:34-34
- [lv_rimage_2] Iwi-aor--- linear /dev/sdab:0-32 0
+ [lv_rimage_2] Iwi-aor--- linear /dev/sdab:0-32 0
[lv_rimage_2] Iwi-aor--- linear /dev/sdab:34-34
- [lv_rimage_3] Iwi-aor--- linear /dev/sdac:1-34 0
- [lv_rimage_4] Iwi-aor--- linear /dev/sdad:1-34 0
- [lv_rimage_5] Iwi-aor--- linear /dev/sdae:1-34 0
- [lv_rimage_6] Iwi-aor-R- linear /dev/sdaf:1-34 0
+ [lv_rimage_3] Iwi-aor--- linear /dev/sdac:1-34 0
+ [lv_rimage_4] Iwi-aor--- linear /dev/sdad:1-34 0
+ [lv_rimage_5] Iwi-aor--- linear /dev/sdae:1-34 0
+ [lv_rimage_6] Iwi-aor-R- linear /dev/sdaf:1-34 0
[lv_rmeta_0] ewi-aor--- linear /dev/sda:33-33
[lv_rmeta_1] ewi-aor--- linear /dev/sdaa:33-33
[lv_rmeta_2] ewi-aor--- linear /dev/sdab:33-33
@@ -1199,8 +1213,12 @@ The 'R' in the same column of the attribute field shows the freed image Sub LVs
.nf
# lvs -o lv_name,attr,segtype,seg_pe_ranges,dataoffset vg
- LV Attr Type PE Ranges DOff
- lv rwi-a-r-R- raid6_nr lv_rimage_0:0-33 lv_rimage_1:0-33 lv_rimage_2:0-33 ... lv_rimage_5:0-33 lv_rimage_6:0-33 8192
+ LV Attr Type PE Ranges DOff
+ lv rwi-a-r-R- raid6_nr lv_rimage_0:0-33 \
+ lv_rimage_1:0-33 \
+ lv_rimage_2:0-33 ... \
+ lv_rimage_5:0-33
+ lv_rimage_6:0-33 8192
.fi
Now that the reshape is finished the 'R' atribute on the RaidLV shows images can be removed.
7 years
master - lvconvert: validate vg name prefix for pool metadata name
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2fd9ae070351dd2682d...
Commit: 2fd9ae070351dd2682d42aad3df5c9acec195bc0
Parent: 21da004e58cdd406d5de0d67f27686373d7d2bfe
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Apr 11 10:40:08 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 11 10:40:08 2017 -0500
lvconvert: validate vg name prefix for pool metadata name
---
tools/lvconvert.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index c28a75f..ee7fb8b 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -2750,6 +2750,11 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
*/
if ((pool_metadata_name = arg_str_value(cmd, poolmetadata_ARG, NULL))) {
+ if (!validate_lvname_param(cmd, &vg->name, &pool_metadata_name)) {
+ log_error("Metadata LV %s not found.", pool_metadata_name);
+ return 0;
+ }
+
if (!(metadata_lv = find_lv(vg, pool_metadata_name))) {
log_error("Unknown pool metadata LV %s.", pool_metadata_name);
return 0;
7 years
master - man lvcreate/lvconvert: minor clean up rewording
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=21da004e58cdd406d5d...
Commit: 21da004e58cdd406d5de0d67f27686373d7d2bfe
Parent: a4f07b701a009aba2ceca7fdb4ef880505ad54c3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Apr 10 16:29:40 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Apr 11 10:21:36 2017 -0500
man lvcreate/lvconvert: minor clean up rewording
---
man/lvconvert.8_des | 81 +++++++++++++++++++++++++++-----------------------
man/lvcreate.8_des | 15 ++++-----
2 files changed, 51 insertions(+), 45 deletions(-)
diff --git a/man/lvconvert.8_des b/man/lvconvert.8_des
index dc51aae..6fd1ed9 100644
--- a/man/lvconvert.8_des
+++ b/man/lvconvert.8_des
@@ -7,6 +7,17 @@ To display the current LV type, run the command:
.B lvs -o name,segtype
.I LV
+In some cases, an LV is a single device mapper (dm) layer above physical
+devices. In other cases, hidden LVs (dm devices) are layered between the
+visible LV and physical devices. LVs in the middle layers are called sub LVs.
+A command run on a visible LV sometimes operates on a sub LV rather than
+the specified LV. In other cases, a sub LV must be specified directly on
+the command line.
+
+Sub LVs can be displayed with the command:
+
+.B lvs -a
+
The
.B linear
type is equivalent to the
@@ -20,45 +31,41 @@ type is deprecated and the
.B raid1
type should be used. They are both implementations of mirroring.
-In some cases, an LV is a single device mapper (dm) layer above physical
-devices. In other cases, hidden LVs (dm devices) are layered between the
-visible LV and physical devices. LVs in the middle layers are called sub LVs.
-A command run on a visible LV sometimes operates on a sub LV rather than
-the specified LV. In other cases, a sub LV must be specified directly on
-the command line.
-
Striped raid types are
-.B raid0/raid0_meta
-,
-.B raid5
-(an alias for raid5_ls),
-.B raid6
-(an alias for raid6_zr) and
-.B raid10
-(an alias for raid10_near).
+\fBraid0/raid0_meta\fP,
+\fBraid5\fP (an alias for raid5_ls),
+\fBraid6\fP (an alias for raid6_zr) and
+\fBraid10\fP (an alias for raid10_near).
As opposed to mirroring, raid5 and raid6 stripe data and calculate parity
-blocks. The parity blocks can be used for data block recovery in case devices
-fail. A maximum number of one device in a raid5 LV may fail and two in case
-of raid6. Striped raid types typically rotate the parity blocks for performance
-reasons thus avoiding contention on a single device. Layouts of raid5 rotating
-parity blocks can be one of left-asymmetric (raid5_la), left-symmetric (raid5_ls
-with alias raid5), right-asymmetric (raid5_ra), right-symmetric (raid5_rs) and raid5_n,
-which doesn't rotate parity blocks. Any \"_n\" layouts allow for conversion between
-raid levels (raid5_n -> raid6 or raid5_n -> striped/raid0/raid0_meta).
-raid6 layouts are zero-restart (raid6_zr with alias raid6), next-restart (raid6_nr),
-next-continue (raid6_nc). Additionally, special raid6 layouts for raid level conversions
-between raid5 and raid6 are raid6_ls_6, raid6_rs_6, raid6_la_6 and raid6_ra_6. Those
-correspond to their raid5 counterparts (e.g. raid5_rs can be directly converted to raid6_rs_6
-and vice-versa).
-raid10 (an alias for raid10_near) is currently limited to one data copy and even number of
-sub LVs. This is a mirror group layout thus a single sub LV may fail per mirror group
-without data loss.
-Striped raid types support converting the layout, their stripesize
-and their number of stripes.
+blocks. The parity blocks can be used for data block recovery in case
+devices fail. A maximum number of one device in a raid5 LV may fail, and
+two in case of raid6. Striped raid types typically rotate the parity and
+data blocks for performance reasons, thus avoiding contention on a single
+device. Specific arrangements of parity and data blocks (layouts) can be
+used to optimize I/O performance, or to convert between raid levels. See
+\fBlvmraid\fP(7) for more information.
-The striped raid types combined with raid1 allow for conversion from linear -> striped/raid0/raid0_meta
-and vice-versa by e.g. linear <-> raid1 <-> raid5_n (then adding stripes) <-> striped/raid0/raid0_meta.
+Layouts of raid5 rotating parity blocks can be: left-asymmetric
+(raid5_la), left-symmetric (raid5_ls with alias raid5), right-asymmetric
+(raid5_ra), right-symmetric (raid5_rs) and raid5_n, which doesn't rotate
+parity blocks. Layouts of raid6 are: zero-restart (raid6_zr with alias
+raid6), next-restart (raid6_nr), and next-continue (raid6_nc).
-Sub LVs can be displayed with the command
-.B lvs -a
+Layouts including _n allow for conversion between raid levels (raid5_n to
+raid6 or raid5_n to striped/raid0/raid0_meta). Additionally, special raid6
+layouts for raid level conversions between raid5 and raid6 are:
+raid6_ls_6, raid6_rs_6, raid6_la_6 and raid6_ra_6. Those correspond to
+their raid5 counterparts (e.g. raid5_rs can be directly converted to
+raid6_rs_6 and vice-versa).
+
+raid10 (an alias for raid10_near) is currently limited to one data copy
+and even number of sub LVs. This is a mirror group layout, thus a single
+sub LV may fail per mirror group without data loss.
+
+Striped raid types support converting the layout, their stripesize and
+their number of stripes.
+
+The striped raid types combined with raid1 allow for conversion from
+linear -> striped/raid0/raid0_meta and vice-versa by e.g. linear <-> raid1
+<-> raid5_n (then adding stripes) <-> striped/raid0/raid0_meta.
diff --git a/man/lvcreate.8_des b/man/lvcreate.8_des
index 42f4213..589bd63 100644
--- a/man/lvcreate.8_des
+++ b/man/lvcreate.8_des
@@ -1,8 +1,8 @@
lvcreate creates a new LV in a VG. For standard LVs, this requires
allocating logical extents from the VG's free physical extents. If there
-is not enough free space, then the VG can be extended (see
-\fBvgextend\fP(8)) with other PVs, or existing LVs can be reduced or
-removed (see \fBlvremove\fP, \fBlvreduce\fP.)
+is not enough free space, the VG can be extended with other PVs
+(\fBvgextend\fP(8)), or existing LVs can be reduced or removed
+(\fBlvremove\fP(8), \fBlvreduce\fP(8).)
To control which PVs a new LV will use, specify one or more PVs as
position args at the end of the command line. lvcreate will allocate
@@ -19,7 +19,7 @@ unique PVs be available in the VG for allocation.
Thin pools (for thin provisioning) and cache pools (for caching) are
represented by special LVs with types thin-pool and cache-pool (see
\fBlvmthin\fP(7) and \fBlvmcache\fP(7)). The pool LVs are not usable as
-standard block devices, but the LV names act references to the pools.
+standard block devices, but the LV names act as references to the pools.
Thin LVs are thinly provisioned from a thin pool, and are created with a
virtual size rather than a physical size. A cache LV is the combination of
@@ -27,10 +27,9 @@ a standard LV with a cache pool, used to cache active portions of the LV
to improve performance.
.SS Usage notes
In the usage section below, \fB--size\fP \fISize\fP can be replaced
-with \fB--extents\fP \fINumber\fP. See both descriptions
-the options section.
+with \fB--extents\fP \fINumber\fP. See descriptions in the options section.
In the usage section below, \fB--name\fP is omitted from the required
-options, even though it is typically used. When the name is not
+options, even though it is typically used. When the name is not
specified, a new LV name is generated with the "lvol" prefix and a unique
-numeric suffix. Also see the description in the options section.
+numeric suffix.
7 years
master - commands: check required option value when matching command
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a4f07b701a009aba2ce...
Commit: a4f07b701a009aba2ceca7fdb4ef880505ad54c3
Parent: a14a8cef2ff1ae5c9c946bde5a885667288e24d3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Apr 10 13:41:47 2017 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Apr 10 13:41:47 2017 -0500
commands: check required option value when matching command
A command def can include a specific constant option value,
but the value was not being checked for optional opts.
e.g. this is an incorrect command and does not match any
command defs:
lvconvert --type cache --cachepool vg/lv
However, it was mistakely being matched to this cmd def,
where the required options match, but the optional options
do not:
lonvert --cachepool LV_linear_striped_raid_cachepool
OO: --type cache-pool, ...
The optional options were mistakely considered matching
because 'cache' and 'cache-pool' were not being compared.
---
tools/lvmcmdline.c | 31 ++++++++++++++++++++++++++++---
1 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 280a052..3626b1b 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1338,6 +1338,25 @@ static int _opt_synonym_is_set(struct cmd_context *cmd, int opt_std)
return opt_syn && arg_is_set(cmd, opt_syn);
}
+static int _command_optional_opt_matches(struct cmd_context *cmd, int ci, int oo)
+{
+ int opt_enum = commands[ci].optional_opt_args[oo].opt;
+
+ if (val_bit_is_set(commands[ci].optional_opt_args[oo].def.val_bits, conststr_VAL)) {
+ if (!strcmp(commands[ci].optional_opt_args[oo].def.str, arg_str_value(cmd, opt_enum, "")))
+ return 1;
+ return 0;
+ }
+
+ if (val_bit_is_set(commands[ci].optional_opt_args[oo].def.val_bits, constnum_VAL)) {
+ if (commands[ci].optional_opt_args[oo].def.num == arg_int_value(cmd, opt_enum, 0))
+ return 1;
+ return 0;
+ }
+
+ return 1;
+}
+
static int _command_ignore_opt_matches(struct cmd_context *cmd, int ci, int io)
{
int opt_enum = commands[ci].ignore_opt_args[io].opt;
@@ -1625,7 +1644,8 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path,
continue;
for (j = 0; j < commands[i].oo_count; j++) {
- if (commands[i].optional_opt_args[j].opt == opt_enum) {
+ if ((commands[i].optional_opt_args[j].opt == opt_enum) &&
+ _command_optional_opt_matches(cmd, i, j)) {
accepted = 1;
break;
}
@@ -1695,8 +1715,13 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path,
if (best_unused_count) {
for (i = 0; i < best_unused_count; i++) {
- log_error("Invalid option for command: %s.",
- arg_long_option_name(best_unused_options[i]));
+ const char *opt_val = NULL;
+ opt_enum = best_unused_options[i];
+ opt_val = arg_value(cmd, opt_enum);
+
+ log_error("Invalid option for command: %s%s%s.",
+ arg_long_option_name(opt_enum),
+ opt_val ? " " : "", opt_val ?: "");
}
return NULL;
}
7 years
master - signals: fix comparison flaw
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a14a8cef2ff1ae5c9c9...
Commit: a14a8cef2ff1ae5c9c946bde5a885667288e24d3
Parent: 9a689fb8f0a6b1675a4e819f4837bf2e0269832f
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Mon Apr 10 18:29:26 2017 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Mon Apr 10 18:41:28 2017 +0200
signals: fix comparison flaw
commit 9a689fb8f0a6b1675a4e819f4837bf2e0269832f
fixed SIGINT blocking but introduced a comparision
flaw to sigint_restore().
Related: rhbz1440766
---
lib/misc/lvm-signal.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/misc/lvm-signal.c b/lib/misc/lvm-signal.c
index 15d8a6f..8a4ead4 100644
--- a/lib/misc/lvm-signal.c
+++ b/lib/misc/lvm-signal.c
@@ -98,7 +98,7 @@ void sigint_restore(void)
return;
if (!_handler_installed ||
- --_handler_installed > MAX_SIGINTS)
+ --_handler_installed >= MAX_SIGINTS)
return;
/* Nesting count went below MAX_SIGINTS. */
7 years
master - signals: fix comparison flaw
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4e21159a7f2c8d28068...
Commit: 4e21159a7f2c8d2806890b743866a0b9702e7532
Parent: 9a689fb8f0a6b1675a4e819f4837bf2e0269832f
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Mon Apr 10 18:29:26 2017 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Mon Apr 10 18:29:26 2017 +0200
signals: fix comparison flaw
commit 9a689fb8f0a6b1675a4e819f4837bf2e0269832f
fixed SIGINT blocking but introduced a comparision
flaw to sigint_restore.
Related: rhbz1440766
---
lib/misc/lvm-signal.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/misc/lvm-signal.c b/lib/misc/lvm-signal.c
index 15d8a6f..8a4ead4 100644
--- a/lib/misc/lvm-signal.c
+++ b/lib/misc/lvm-signal.c
@@ -98,7 +98,7 @@ void sigint_restore(void)
return;
if (!_handler_installed ||
- --_handler_installed > MAX_SIGINTS)
+ --_handler_installed >= MAX_SIGINTS)
return;
/* Nesting count went below MAX_SIGINTS. */
7 years
master - signals: fix SIGINT blocking flaw causing inconsistent metadata
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9a689fb8f0a6b1675a4...
Commit: 9a689fb8f0a6b1675a4e819f4837bf2e0269832f
Parent: ef3e1013aa8d7797fa432e2da219255178b8ede3
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Mon Apr 10 18:16:09 2017 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Mon Apr 10 18:16:09 2017 +0200
signals: fix SIGINT blocking flaw causing inconsistent metadata
SIGINT isn't blocked properly after a sigint_allow(),
sigint_restore() cycle leading to illicit interruptable
metadata updates. These can leave corrupted metadata behind.
Issues addressed in this commit:
sigint_allow() fails to set _oldmasked[] members properly due
to an offset by one bug on indexing the members of the array.
It bails out prematurely comparing to MAX_SIGINTS causing nesting
depths to be one less than MAX_SIGINTS. Fix the comparision.
Correct the related comparison flaw in sigint_restore().
Initialize all sig_atomic_t variables consequently.
Resolves: rhbz1440766
---
lib/misc/lvm-signal.c | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/misc/lvm-signal.c b/lib/misc/lvm-signal.c
index 7e78407..15d8a6f 100644
--- a/lib/misc/lvm-signal.c
+++ b/lib/misc/lvm-signal.c
@@ -22,7 +22,7 @@
static sigset_t _oldset;
static int _signals_blocked = 0;
static volatile sig_atomic_t _sigint_caught = 0;
-static volatile sig_atomic_t _handler_installed;
+static volatile sig_atomic_t _handler_installed = 0;
/* Support 3 level nesting, increase if needed more */
#define MAX_SIGINTS 3
@@ -67,7 +67,7 @@ void sigint_allow(void)
* Do not overwrite the backed-up handler data -
* just increase nesting count.
*/
- if (++_handler_installed >= MAX_SIGINTS)
+ if (++_handler_installed > MAX_SIGINTS)
return;
/* Grab old sigaction for SIGINT: shall not fail. */
@@ -85,7 +85,7 @@ void sigint_allow(void)
if (sigprocmask(0, NULL, &sigs))
log_sys_debug("sigprocmask", "");
- if ((_oldmasked[_handler_installed] = sigismember(&sigs, SIGINT))) {
+ if ((_oldmasked[_handler_installed - 1] = sigismember(&sigs, SIGINT))) {
sigdelset(&sigs, SIGINT);
if (sigprocmask(SIG_SETMASK, &sigs, NULL))
log_sys_debug("sigprocmask", "SIG_SETMASK");
@@ -98,7 +98,7 @@ void sigint_restore(void)
return;
if (!_handler_installed ||
- --_handler_installed >= MAX_SIGINTS)
+ --_handler_installed > MAX_SIGINTS)
return;
/* Nesting count went below MAX_SIGINTS. */
7 years
master - lvconvert: cleanup prompting
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ef3e1013aa8d7797fa4...
Commit: ef3e1013aa8d7797fa432e2da219255178b8ede3
Parent: eb6302c8cb6bfd1d9831e5ff3d76ecbb49613178
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Thu Apr 6 19:59:57 2017 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu Apr 6 19:59:57 2017 +0200
lvconvert: cleanup prompting
---
lib/metadata/raid_manip.c | 29 ++++++++++++-----------------
1 files changed, 12 insertions(+), 17 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 922eea7..93c3c30 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -1989,8 +1989,8 @@ static int _raid_reshape_keep_images(struct logical_volume *lv,
if (seg->segtype != new_segtype)
log_print_unless_silent("Converting %s LV %s to %s.",
lvseg_name(seg), display_lvname(lv), new_segtype->name);
- if (!yes && yes_no_prompt("Are you sure you want to convert %s LV %s? [y/n]: ",
- lvseg_name(seg), display_lvname(lv)) == 'n') {
+ if (!yes && yes_no_prompt("Are you sure you want to convert %s LV %s to %s? [y/n]: ",
+ lvseg_name(seg), display_lvname(lv), new_segtype->name) == 'n') {
log_error("Logical volume %s NOT converted.", display_lvname(lv));
return 0;
}
@@ -4577,7 +4577,7 @@ static int _raid1_to_mirrored_wrapper(TAKEOVER_FN_ARGS)
if (!_raid_in_sync(lv))
return_0;
- if (!yes && yes_no_prompt("Are you sure you want to convert %s back to the older \"%s\" type? [y/n]: ",
+ if (!yes && yes_no_prompt("Are you sure you want to convert %s back to the older %s type? [y/n]: ",
display_lvname(lv), SEG_TYPE_NAME_MIRROR) == 'n') {
log_error("Logical volume %s NOT converted to \"%s\".",
display_lvname(lv), SEG_TYPE_NAME_MIRROR);
@@ -4888,13 +4888,6 @@ static int _takeover_downconvert_wrapper(TAKEOVER_FN_ARGS)
} else
*res_str = '\0';
- if (!yes && yes_no_prompt("Are you sure you want to convert \"%s\" LV %s to \"%s\" type%s? [y/n]: ",
- lvseg_name(seg), display_lvname(lv), new_segtype->name, res_str) == 'n') {
- log_error("Logical volume %s NOT converted to \"%s\"",
- display_lvname(lv), new_segtype->name);
- return 0;
- }
-
/* Archive metadata */
if (!archive(lv->vg))
return_0;
@@ -5737,13 +5730,6 @@ replaced:
if (segtype_sav != *segtype)
log_warn("Replaced LV type %s with possible type %s.",
segtype_sav->name, (*segtype)->name);
- if (!yes && yes_no_prompt("Do you want to convert %s LV %s to %s? [y/n]: ",
- lvseg_name(seg_from), display_lvname(seg_from->lv),
- (*segtype)->name) == 'n') {
- log_error("Logical volume %s NOT converted.", display_lvname(seg_from->lv));
- return 0;
- }
-
return 1;
}
@@ -5855,6 +5841,15 @@ static int _conversion_options_allowed(const struct lv_segment *seg_from,
r = 0;
}
+ if (r &&
+ strcmp((*segtype_to)->name, SEG_TYPE_NAME_MIRROR) && /* "mirror" is prompted for later */
+ !yes && yes_no_prompt("Are you sure you want to convert %s LV %s to %s type? [y/n]: ",
+ lvseg_name(seg_from), display_lvname(seg_from->lv),
+ (*segtype_to)->name) == 'n') {
+ log_error("Logical volume %s NOT converted.", display_lvname(seg_from->lv));
+ r = 0;
+ }
+
return r;
}
7 years