1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-09-27 05:44:18 +03:00

Compare commits

..

1 Commits

Author SHA1 Message Date
David Teigland
6d4b67aebd lvconvert: add command to change region size of a raid LV 2017-02-07 12:42:14 -06:00
46 changed files with 210 additions and 626 deletions

View File

@@ -1221,15 +1221,14 @@ cfg_array(activation_read_only_volume_list_CFG, "read_only_volume_list", activat
"read_only_volume_list = [ \"vg1\", \"vg2/lvol1\", \"@tag1\", \"@*\" ]\n"
"#\n")
cfg(activation_mirror_region_size_CFG, "mirror_region_size", activation_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_RAID_REGION_SIZE, vsn(1, 0, 0), NULL, vsn(2, 2, 99),
cfg(activation_mirror_region_size_CFG, "mirror_region_size", activation_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_RAID_REGION_SIZE, vsn(1, 0, 0), NULL, vsn(2, 2, 99),
"This has been replaced by the activation/raid_region_size setting.\n",
"Size in KiB of each raid or mirror synchronization region.\n")
"Size in KiB of each copy operation when mirroring.\n")
cfg(activation_raid_region_size_CFG, "raid_region_size", activation_CFG_SECTION, 0, CFG_TYPE_INT, DEFAULT_RAID_REGION_SIZE, vsn(2, 2, 99), NULL, 0, NULL,
"Size in KiB of each raid or mirror synchronization region.\n"
"The clean/dirty state of data is tracked for each region.\n"
"The value is rounded down to a power of two if necessary, and\n"
"is ignored if it is not a multiple of the machine memory page size.\n")
"For raid or mirror segment types, this is the amount of data that is\n"
"copied at once when initializing, or moved at once by pvmove.\n")
cfg(activation_error_when_full_CFG, "error_when_full", activation_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, DEFAULT_ERROR_WHEN_FULL, vsn(2, 2, 115), NULL, 0, NULL,
"Return errors if a thin pool runs out of space.\n"

View File

@@ -712,7 +712,6 @@ static int _round_down_pow2(int r)
int get_default_region_size(struct cmd_context *cmd)
{
int pagesize = lvm_getpagesize();
int region_size = _get_default_region_size(cmd);
if (!is_power_of_2(region_size)) {
@@ -721,12 +720,6 @@ int get_default_region_size(struct cmd_context *cmd)
region_size / 2);
}
if (region_size % (pagesize >> SECTOR_SHIFT)) {
region_size = DEFAULT_RAID_REGION_SIZE * 2;
log_verbose("Using default region size %u kiB (multiple of page size).",
region_size / 2);
}
return region_size;
}

View File

@@ -46,6 +46,8 @@ MAN8GEN=lvm-config.8 lvm-dumpconfig.8 lvm-fullreport.8 lvm-lvpoll.8 \
vgrename.8 vgs.8 vgscan.8 vgsplit.8 \
lvmsar.8 lvmsadc.8 lvmdiskscan.8 lvmchange.8
MAN8+=$(MAN8GEN)
ifeq ($(MAKECMDGOALS),all_man)
MAN_ALL="yes"
endif
@@ -115,8 +117,8 @@ MAN8DIR=$(mandir)/man8
include $(top_builddir)/make.tmpl
CLEAN_TARGETS+=$(MAN5) $(MAN7) $(MAN8) $(MAN8GEN) $(MAN8CLUSTER) \
$(MAN8SYSTEMD_GENERATORS) $(MAN8DM) *.gen man-generator
CLEAN_TARGETS+=$(MAN5) $(MAN7) $(MAN8) $(MAN8CLUSTER) \
$(MAN8SYSTEMD_GENERATORS) $(MAN8DM)
DISTCLEAN_TARGETS+=$(FSADMMAN) $(BLKDEACTIVATEMAN) $(DMEVENTDMAN) \
$(LVMETADMAN) $(LVMPOLLDMAN) $(LVMLOCKDMAN) $(CLVMDMAN) $(CMIRRORDMAN) \
$(LVMCACHEMAN) $(LVMTHINMAN) $(LVMDBUSDMAN) $(LVMRAIDMAN)
@@ -127,11 +129,11 @@ all: man device-mapper
device-mapper: $(MAN8DM)
man: $(MAN5) $(MAN7) $(MAN8) $(MAN8GEN) $(MAN8CLUSTER) $(MAN8SYSTEMD_GENERATORS)
man: $(MAN5) $(MAN7) $(MAN8) $(MAN8CLUSTER) $(MAN8SYSTEMD_GENERATORS)
all_man: man
$(MAN5) $(MAN7) $(MAN8) $(MAN8GEN) $(MAN8DM) $(MAN8CLUSTER): Makefile
$(MAN5) $(MAN7) $(MAN8) $(MAN8DM) $(MAN8CLUSTER): Makefile
Makefile: Makefile.in
@:
@@ -142,14 +144,14 @@ Makefile: Makefile.in
*) echo "Creating $@" ; $(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)+;" $< > $@ ;; \
esac
man-generator:
$(CC) -DMAN_PAGE_GENERATOR -I$(top_builddir)/tools $(CFLAGS) $(top_srcdir)/tools/command.c -o $@
generator:
$(CC) -DMAN_PAGE_GENERATOR $(top_builddir)/tools/command.c -o man-generator
$(MAN8GEN): man-generator
$(MAN8GEN): generator
echo "Generating $@" ;
./man-generator $(basename $@) > $@.gen
if [ -f $(top_srcdir)/man/$@.end ]; then cat $(top_srcdir)/man/$@.end >> $@.gen; fi;
$(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 > $@
./man-generator `basename -s .8 $@` > $@.in
if [ -f $@.notes ]; then cat $@.notes >> $@.in; fi;
$(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)+;" $@.in > $@
install_man5: $(MAN5)
$(INSTALL) -d $(MAN5DIR)
@@ -162,7 +164,6 @@ install_man7: $(MAN7)
install_man8: $(MAN8) $(MAN8GEN)
$(INSTALL) -d $(MAN8DIR)
$(INSTALL_DATA) $(MAN8) $(MAN8DIR)/
$(INSTALL_DATA) $(MAN8GEN) $(MAN8DIR)/
install_lvm2: install_man5 install_man7 install_man8

View File

@@ -1,6 +0,0 @@
.EXAMPLES
Change LV permission to read-only:
.sp
.B lvchange \-pr vg00/lvol1

View File

@@ -1,95 +0,0 @@
.SH EXAMPLES
Convert a linear LV to a two-way mirror LV:
.br
.B lvconvert \-\-type mirror \-\-mirrors 1 vg/lvol1
Convert a linear LV to a two-way RAID1 LV:
.br
.B lvconvert \-\-type raid1 \-\-mirrors 1 vg/lvol1
Convert a mirror LV to use an in\-memory log:
.br
.B lvconvert \-\-mirrorlog core vg/lvol1
Convert a mirror LV to use a disk log:
.br
.B lvconvert \-\-mirrorlog disk vg/lvol1
Convert a mirror or raid1 LV to a linear LV:
.br
.B lvconvert --type linear vg/lvol1
Convert a mirror LV to a raid1 LV with the same number of images:
.br
.B lvconvert \-\-type raid1 vg/lvol1
Convert a linear LV to a two-way mirror LV, allocating new extents from specific
PV ranges:
.br
.B lvconvert \-\-mirrors 1 vg/lvol1 /dev/sda:0\-15 /dev/sdb:0\-15
Convert a mirror LV to a linear LV, freeing physical extents from a specific PV:
.br
.B lvconvert \-\-type linear vg/lvol1 /dev/sda
Split one image from a mirror or raid1 LV, making it a new LV:
.br
.B lvconvert \-\-splitmirrors 1 \-\-name lv_split vg/lvol1
Split one image from a raid1 LV, and track changes made to the raid1 LV
while the split image remains detached:
.br
.B lvconvert \-\-splitmirrors 1 \-\-trackchanges vg/lvol1
Merge an image (that was previously created with \-\-splitmirrors and
\-\-trackchanges) back into the original raid1 LV:
.br
.B lvconvert \-\-mergemirrors vg/lvol1_rimage_1
Replace PV /dev/sdb1 with PV /dev/sdf1 in a raid1/4/5/6/10 LV:
.br
.B lvconvert \-\-replace /dev/sdb1 vg/lvol1 /dev/sdf1
Replace 3 PVs /dev/sd[b-d]1 with PVs /dev/sd[f-h]1 in a raid1 LV:
.br
.B lvconvert \-\-replace /dev/sdb1 \-\-replace /dev/sdc1 \-\-replace /dev/sdd1
.RS
.B vg/lvol1 /dev/sd[fgh]1
.RE
Replace the maximum of 2 PVs /dev/sd[bc]1 with PVs /dev/sd[gh]1 in a raid6 LV:
.br
.B lvconvert \-\-replace /dev/sdb1 \-\-replace /dev/sdc1 vg/lvol1 /dev/sd[gh]1
Convert an LV into a thin LV in the specified thin pool. The existing LV
is used as an external read\-only origin for the new thin LV.
.br
.B lvconvert \-\-type thin \-\-thinpool vg/tpool1 vg/lvol1
Convert an LV into a thin LV in the specified thin pool. The existing LV
is used as an external read\-only origin for the new thin LV, and is
renamed "external":
.br
.B lvconvert \-\-type thin \-\-thinpool vg/tpool1
.RS
.B \-\-originname external vg/lvol1
.RE
Convert an LV to a cache pool LV using another specified LV for cache pool
metadata:
.br
.B lvconvert \-\-type cache-pool \-\-poolmetadata vg/poolmeta1 vg/lvol1
Convert an LV to a cache LV using the specified cache pool and chunk size:
.br
.B lvconvert \-\-type cache \-\-cachepool vg/cpool1 \-c 128 vg/lvol1
Detach and keep the cache pool from a cache LV:
.br
.B lvconvert \-\-splitcache vg/lvol1
Detach and remove the cache pool from a cache LV:
.br
.B lvconvert \-\-uncache vg/lvol1

View File

@@ -1,98 +0,0 @@
.SH EXAMPLES
Create a striped LV with 3 stripes, a stripe size of 8KiB and a size of 100MiB.
The LV name is chosen by lvcreate.
.br
.B lvcreate \-i 3 \-I 8 \-L 100m vg00
Create a raid1 LV with two images, and a useable size of 500 MiB. This
operation requires two devices, one for each mirror image. RAID metadata
(superblock and bitmap) is also included on the two devices.
.br
.B lvcreate \-\-type raid1 \-m1 \-L 500m \-n mylv vg00
Create a mirror LV with two images, and a useable size of 500 MiB.
This operation requires three devices: two for mirror images and
one for a disk log.
.br
.B lvcreate \-\-type mirror \-m1 \-L 500m \-n mylv vg00
Create a mirror LV with 2 images, and a useable size of 500 MiB.
This operation requires 2 devices because the log is in memory.
.br
.B lvcreate \-\-type mirror \-m1 \-\-mirrorlog core \-L 500m \-n mylv vg00
Create a copy\-on\-write snapshot of an LV:
.br
.B lvcreate \-\-snapshot \-\-size 100m \-\-name mysnap vg00/mylv
Create a copy\-on\-write snapshot with a size sufficient
for overwriting 20% of the size of the original LV.
.br
.B lvcreate \-s \-l 20%ORIGIN \-n mysnap vg00/mylv
Create a sparse LV with 1TiB of virtual space, and actual space just under
100MiB.
.br
.B lvcreate \-\-snapshot \-\-virtualsize 1t \-\-size 100m \-\-name mylv vg00
Create a linear LV with a usable size of 64MiB on specific physical extents.
.br
.B lvcreate \-L 64m \-n mylv vg00 /dev/sda:0\-7 /dev/sdb:0\-7
Create a RAID5 LV with a usable size of 5GiB, 3 stripes, a stripe size of
64KiB, using a total of 4 devices (including one for parity).
.br
.B lvcreate \-\-type raid5 \-L 5G \-i 3 \-I 64 \-n mylv vg00
Create a RAID5 LV using all of the free space in the VG and spanning all the
PVs in the VG (note that the command will fail if there are more than 8 PVs in
the VG, in which case \fB\-i 7\fP must be used to get to the current maximum of
8 devices including parity for RaidLVs).
.br
.B lvcreate \-\-config allocation/raid_stripe_all_devices=1
.RS
.B \-\-type raid5 \-l 100%FREE \-n mylv vg00
.RE
Create RAID10 LV with a usable size of 5GiB, using 2 stripes, each on
a two-image mirror. (Note that the \fB-i\fP and \fB-m\fP arguments behave
differently:
\fB-i\fP specifies the total number of stripes,
but \fB-m\fP specifies the number of images in addition
to the first image).
.br
.B lvcreate \-\-type raid10 \-L 5G \-i 2 \-m 1 \-n mylv vg00
Create a 1TiB thin LV, first creating a new thin pool for it, where
the thin pool has 100MiB of space, uses 2 stripes, has a 64KiB stripe
size, and 256KiB chunk size.
.br
.B lvcreate \-\-type thin \-\-name mylv \-\-thinpool mypool
.RS
.B \-V 1t \-L 100m \-i 2 \-I 64 \-c 256 vg00
.RE
Create a thin snapshot of a thin LV (the size option must not be
used, otherwise a copy-on-write snapshot would be created).
.br
.B lvcreate \-\-snapshot \-\-name mysnap vg00/thinvol
Create a thin snapshot of the read-only inactive LV named "origin"
which becomes an external origin for the thin snapshot LV.
.br
.B lvcreate \-\-snapshot \-\-name mysnap \-\-thinpool mypool vg00/origin
Create a cache pool from a fast physical device. The cache pool can
then be used to cache an LV.
.br
.B lvcreate \-\-type cache-pool \-L 1G \-n my_cpool vg00 /dev/fast1
Create a cache LV, first creating a new origin LV on a slow physical device,
then combining the new origin LV with an existing cache pool.
.br
.B lvcreate \-\-type cache \-\-cachepool my_cpool
.RS
.B \-L 100G \-n mylv vg00 /dev/slow1
.RE

View File

@@ -1,16 +0,0 @@
.SH EXAMPLES
Extend the size of an LV by 54MiB, using a specific PV.
.br
.B lvextend \-L +54 vg01/lvol10 /dev/sdk3
Extend the size of an LV by the amount of free
space on PV /dev/sdk3. This is equivalent to specifying
"\-l +100%PVS" on the command line.
.br
.B lvextend vg01/lvol01 /dev/sdk3
Extend an LV by 16MiB using specific physical extents.
.br
.B lvextend \-L+16m vg01/lvol01 /dev/sda:8\-9 /dev/sdb:8\-9

View File

@@ -1,34 +0,0 @@
.SH NOTES
.IP \[bu] 3
To find the name of the pvmove LV that was created by an original
\fBpvmove /dev/name\fP command, use the command:
.br
\fBlvs -a -S move_pv=/dev/name\fP.
.SH EXAMPLES
Continue polling a pvmove operation:
.br
.B lvm lvpoll --polloperation pvmove vg00/pvmove0
Abort a pvmove operation:
.br
.B lvm lvpoll --polloperation pvmove --abort vg00/pvmove0
Continue polling a mirror conversion:
.br
.B lvm lvpoll --polloperation convert vg00/lvmirror
Continue mirror repair:
.br
.B lvm lvpoll --polloperation convert vg/damaged_mirror --handlemissingpvs
Continue snapshot merge:
.br
.B lvm lvpoll --polloperation merge vg/snapshot_old
Continue thin snapshot merge:
.br
.B lvm lvpoll --polloperation merge_thin vg/thin_snapshot

View File

@@ -1,5 +0,0 @@
.SH EXAMPLES
Reduce the size of an LV by 3 logical extents:
.br
.B lvreduce \-l \-3 vg00/lvol1

View File

@@ -1,11 +0,0 @@
.SH EXAMPLES
Remove an active LV without asking for confirmation.
.br
.B lvremove \-f vg00/lvol1
Remove all LVs the specified VG.
.br
.B lvremove vg00

View File

@@ -1,10 +0,0 @@
.SH EXAMPLES
Rename "lvold" to "lvnew":
.br
.B lvrename /dev/vg02/lvold vg02/lvnew
An alternate syntax to rename "lvold" to "lvnew":
.br
.B lvrename vg02 lvold lvnew

View File

@@ -1,6 +0,0 @@
.SH EXAMPLES
Extend an LV by 16MB using specific physical extents:
.br
.B lvresize \-L+16M vg1/lv1 /dev/sda:0\-1 /dev/sdb:0\-1

View File

@@ -1,6 +0,0 @@
.SH EXAMPLES
Disallow the allocation of physical extents on a PV (e.g. because of
disk errors, or because it will be removed after freeing it).
.br
.B pvchange \-x n /dev/sdk1

View File

@@ -1,8 +0,0 @@
.SH EXAMPLES
If the partition table is corrupted or lost on /dev/sda, and you suspect
there was an LVM partition at approximately 100 MiB, then this
area of the disk can be scanned using the \fB\-\-labelsector\fP
parameter with a value of 204800 (100 * 1024 * 1024 / 512 = 204800).
.br
.B pvck \-\-labelsector 204800 /dev/sda

View File

@@ -1,13 +0,0 @@
.SH EXAMPLES
Initialize a partition and a full device.
.br
.B pvcreate /dev/sdc4 /dev/sde
If a device is a 4KiB sector drive that compensates for windows
partitioning (sector 7 is the lowest aligned logical block, the 4KiB
sectors start at LBA -1, and consequently sector 63 is aligned on a 4KiB
boundary) manually account for this when initializing for use by LVM.
.br
.B pvcreate \-\-dataalignmentoffset 7s /dev/sdb

View File

@@ -45,49 +45,3 @@ LVs are removed, leaving behind the segments on the destination PV. If an
abort is issued during the move, all LVs being moved will remain on the
source PV.
.SH EXAMPLES
Move all physical extents that are used by simple LVs on the specified PV to
free physical extents elsewhere in the VG.
.br
.B pvmove /dev/sdb1
Use a specific destination PV when moving physical extents.
.br
.B pvmove /dev/sdb1 /dev/sdc1
Move extents belonging to a single LV.
.br
.B pvmove \-n lvol1 /dev/sdb1 /dev/sdc1
Rather than moving the contents of an entire device, it is possible to
move a range of physical extents, for example numbers 1000 to 1999
inclusive on the specified PV.
.br
.B pvmove /dev/sdb1:1000\-1999
A range of physical extents to move can be specified as start+length. For
example, starting from PE 1000. (Counting starts from 0, so this refers to the
1001st to the 2000th PE inclusive.)
.br
.B pvmove /dev/sdb1:1000+1000
Move a range of physical extents to a specific PV (which must have
sufficient free extents).
.br
.B pvmove /dev/sdb1:1000\-1999 /dev/sdc1
Move a range of physical extents to specific new extents on a new PV.
.br
.B pvmove /dev/sdb1:1000\-1999 /dev/sdc1:0\-999
If the source and destination are on the same disk, the
\fBanywhere\fP allocation policy is needed.
.br
.B pvmove \-\-alloc anywhere /dev/sdb1:1000\-1999 /dev/sdb1:0\-999
The part of a specific LV present within in a range of physical
extents can also be picked out and moved.
.br
.B pvmove \-n lvol1 /dev/sdb1:1000\-1999 /dev/sdc1

View File

@@ -1,17 +0,0 @@
.SH NOTES
.IP \[bu] 3
pvresize will refuse to shrink a PV if it has allocated extents beyond the
new end.
.SH EXAMPLES
Expand a PV after enlarging the partition.
.br
.B pvresize /dev/sda1
Shrink a PV prior to shrinking the partition (ensure that the PV size is
appropriate for the intended new partition size).
.br
.B pvresize \-\-setphysicalvolumesize 40G /dev/sda1

View File

@@ -1,11 +0,0 @@
.SH NOTES
.IP \[bu] 3
To replace PVs, \fBvgdisplay \-\-partial \-\-verbose\fP will show the
UUIDs and sizes of any PVs that are no longer present. If a PV in the VG
is lost and you wish to substitute another of the same size, use
\fBpvcreate \-\-restorefile filename \-\-uuid uuid\fP (plus additional
arguments as appropriate) to initialise it with the same UUID as the
missing PV. Repeat for all other missing PVs in the VG. Then use
\fBvgcfgrestore \-\-file filename\fP to restore the volume group's
metadata.

View File

@@ -1,10 +0,0 @@
.EXAMPLES
Activate all LVs in all VGs on all existing devices.
.br
.B vgchange \-a y
Change the maximum number of LVs for an inactive VG.
.br
.B vgchange \-l 128 vg00

View File

@@ -1,6 +0,0 @@
.EXAMPLES
Create a VG with two PVs, using the default physical extent size.
.br
.B vgcreate myvg /dev/sdk1 /dev/sdl1

View File

@@ -1,6 +0,0 @@
.SH EXAMPLES
Add two PVs to a VG.
.br
.B vgextend vg00 /dev/sda4 /dev/sdn1

View File

@@ -1,20 +0,0 @@
.SH NOTES
.IP \[bu] 3
vgimportclone can be used to import a VG from duplicated PVs (e.g. created
by a hardware snapshot of the PV devices).
.IP \[bu] 3
A duplicated VG cannot used until it is made to coexist with the original
VG. vgimportclone renames the VG associated with the specified PVs and
changes the associated VG and PV UUIDs.
.SH EXAMPLES
An original VG "vg00" has PVs "/dev/sda" and "/dev/sdb".
The corresponding PVs from a hardware snapshot are "/dev/sdc" and "/dev/sdd".
Rename the VG associated with "/dev/sdc" and "/dev/sdd" from "vg00" to "vg00_snap"
(and change associated UUIDs).
.br
.B vgimportclone \-\-basevgname vg00_snap /dev/sdc /dev/sdd

View File

@@ -0,0 +1,9 @@
.SH NOTES
.
vgimportclone can be used to import a VG from duplicated PVs (e.g. created
by a hardware snapshot of the PV devices).
A duplicated VG cannot used until it is made to coexist with the original
VG. vgimportclone renames the VG associated with the specified PVs and
changes the associated VG and PV UUIDs.

View File

@@ -1,7 +0,0 @@
.SH EXAMPLES
Merge an inactive VG named "vg00" into the active or inactive VG named
"databases", giving verbose runtime information.
.br
.B vgmerge \-v databases vg00

View File

@@ -1,10 +0,0 @@
.SH EXAMPLES
Rename VG "vg02" to "myvg":
.br
.B vgrename "vg02" "myvg"
Rename the VG with the specified UUID to "myvg".
.br
.B vgrename Zvlifi\-Ep3t\-e0Ng\-U42h\-o0ye\-KHu1\-nl7Ns4 myvg

View File

@@ -26,7 +26,7 @@ function _test_regionsize
local vg=$4
local lv=$5
lvconvert --yes -R $regionsize $vg/$lv
lvconvert --type $type --yes -R $regionsize $vg/$lv
[ $? -ne 0 ] && return 1
check lv_field $vg/$lv regionsize "$regionsize_str"
fsck -fn /dev/mapper/$vg-$lv

View File

@@ -1,3 +1,4 @@
#
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
# Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved.
@@ -77,6 +78,9 @@ SOURCES2 =\
TARGETS =\
.commands \
cmds.h \
command-count.h \
command-lines-input.h \
liblvm2cmd.a \
lvm
@@ -101,7 +105,7 @@ CLEAN_TARGETS = liblvm2cmd.$(LIB_SUFFIX) $(TARGETS_DM) \
liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION) lvm-static.o \
liblvm2cmd-static.a dmsetup.static lvm.static \
$(LDDEPS) .exported_symbols_generated \
cmds.h command-lines-input.h command-count.h
command-lines-input.h command-lines-count.h
ifeq ("@CMDLIB@", "yes")
TARGETS += liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION)
@@ -181,31 +185,26 @@ liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION): liblvm2cmd.$(LIB_SUFFIX)
WC = /usr/bin/wc
GREP = /bin/grep
SORT = /bin/sort
CUT = /bin/cut
SED = /bin/sed
# FIXME Prepend licence text from a template file to top of each generated file
# FIXME Prepend 'do not edit' and timestamp comment to each generated file
# FIXME Add licence text from template file
command-count.h: $(srcdir)/command-lines.in Makefile
set -o pipefail && \
( echo -n "#define COMMAND_COUNT " && \
$(GREP) '^ID:' $(srcdir)/command-lines.in | $(WC) -l \
(echo -n "#define COMMAND_COUNT " && \
$(GREP) '^ID:' $(srcdir)/command-lines.in | $(WC) -l \
) > $@
cmds.h: $(srcdir)/command-lines.in Makefile
set -o pipefail && \
( echo "cmd(CMD_NONE, none)" && \
$(GREP) '^ID:' $(srcdir)/command-lines.in | $(SORT) -u | $(AWK) '{print "cmd(" $$2 "_CMD, " $$2 ")"}' && \
echo "cmd(CMD_COUNT, count)" \
) > $@
echo "cmd(CMD_NONE, none)" > cmds.h
cat command-lines.in | grep '^ID:' | sort | uniq | awk '{print "cmd(" $$2 "_CMD, " $$2 ")"}' >> cmds.h
echo "cmd(CMD_COUNT, count)" >> cmds.h
command-lines-input.h: $(srcdir)/command-lines.in Makefile
set -o pipefail && \
( echo -en "const char _command_input[] =\n\n\"" && \
$(GREP) -Ev '^#|\-\-\-|^$$' $(srcdir)/command-lines.in | $(AWK) 'BEGIN {ORS = "\\n\"\n\""} //' && \
echo "\\n\";" \
) > $@
$(srcdir)/command-lines-input.sh
$(SOURCES:%.c=%.d) $(SOURCES2:%.c=%.d): command-lines-input.h command-count.h cmds.h
$(SOURCES:%.c=%.d): command-lines-input.h command-count.h cmds.h
ifneq ("$(CFLOW_CMD)", "")
CFLOW_SOURCES = $(addprefix $(srcdir)/, $(SOURCES))

View File

@@ -1212,8 +1212,10 @@ arg(resizefs_ARG, 'r', "resizefs", 0, 0, 0,
/* Not used */
arg(reset_ARG, 'R', "reset", 0, 0, 0, NULL)
arg(regionsize_ARG, 'R', "regionsize", regionsize_VAL, 0, 0,
"Size of each raid or mirror synchronization region.\n")
arg(regionsize_ARG, 'R', "regionsize", sizemb_VAL, 0, 0,
"A mirror is divided into regions of this size, and the mirror log\n"
"uses this granularity to track which regions are in sync.\n"
"(This can be used with the \"mirror\" type, not the \"raid1\" type.)\n")
arg(physicalextentsize_ARG, 's', "physicalextentsize", sizemb_VAL, 0, 0,
"#vgcreate\n"

11
tools/command-lines-input.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
cat command-lines.in | grep -v '^#' | grep -v '\-\-\-' | grep -v '^$' > command-lines.tmp
echo "" >> command-lines.tmp
echo "const char _command_input[] =" > command-lines-input.h
while read -r line; do
echo "" >> command-lines-input.h
printf '\"%s\\n\"' "$line" >> command-lines-input.h
done < command-lines.tmp
echo ";" >> command-lines-input.h

View File

@@ -305,7 +305,7 @@ RULE: all not LV_thinpool LV_cachepool
---
OO_LVCONVERT_RAID: --mirrors SNumber, --stripes_long Number,
--stripesize SizeKB, --regionsize RegionSize, --interval Number
--stripesize SizeKB, --regionsize SizeMB, --interval Number
OO_LVCONVERT_POOL: --poolmetadata LV, --poolmetadatasize SizeMB,
--poolmetadataspare Bool, --readahead Readahead, --chunksize SizeKB
@@ -352,12 +352,11 @@ ID: lvconvert_raid_types
DESC: Convert LV to raid1 or mirror, or change number of mirror images.
RULE: all not lv_is_locked lv_is_pvmove
lvconvert --regionsize RegionSize LV_raid
lvconvert --regionsize SizeMB LV
OO: OO_LVCONVERT
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
---
@@ -643,7 +642,7 @@ OO_LVCREATE_POOL: --poolmetadatasize SizeMB, --poolmetadataspare Bool, --chunksi
OO_LVCREATE_THIN: --discards Discards, --errorwhenfull Bool
OO_LVCREATE_RAID: --mirrors SNumber, --stripes Number, --stripesize SizeKB,
--regionsize RegionSize, --minrecoveryrate SizeKB, --maxrecoveryrate SizeKB
--regionsize SizeMB, --minrecoveryrate SizeKB, --maxrecoveryrate SizeKB
---
@@ -700,7 +699,7 @@ DESC: Create a striped LV (infers --type striped).
---
lvcreate --type mirror --size SizeMB VG
OO: --mirrors SNumber, --mirrorlog MirrorLog, --regionsize RegionSize, --stripes Number, OO_LVCREATE
OO: --mirrors SNumber, --mirrorlog MirrorLog, --regionsize SizeMB, --stripes Number, OO_LVCREATE
OP: PV ...
ID: lvcreate_mirror
DESC: Create a mirror LV (also see --type raid1).

View File

@@ -74,7 +74,6 @@ static inline int segtype_arg(struct cmd_context *cmd, struct arg_values *av) {
static inline int alloc_arg(struct cmd_context *cmd, struct arg_values *av) { return 0; }
static inline int locktype_arg(struct cmd_context *cmd, struct arg_values *av) { return 0; }
static inline int readahead_arg(struct cmd_context *cmd, struct arg_values *av) { return 0; }
static inline int regionsize_arg(struct cmd_context *cmd, struct arg_values *av) { return 0; }
static inline int vgmetadatacopies_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av) { return 0; }
static inline int pvmetadatacopies_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av) { return 0; }
static inline int metadatacopies_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av) { return 0; }
@@ -1316,9 +1315,7 @@ int define_commands(void)
return 0;
}
cmd = &commands[cmd_count];
cmd->command_index = cmd_count;
cmd_count++;
cmd = &commands[cmd_count++];
cmd->name = strdup(name);
cmd->pos_count = 1;
add_required_line(cmd, line_argc, line_argv);
@@ -1358,7 +1355,7 @@ int define_commands(void)
}
if (is_id_line(line_argv[0])) {
cmd->command_id = strdup(line_argv[1]);
cmd->command_line_id = strdup(line_argv[1]);
continue;
}
@@ -1851,17 +1848,16 @@ static char *man_long_opt_name(const char *cmdname, int opt_enum)
return long_opt_name;
}
void print_man_usage(char *lvmname, struct command *cmd)
void print_man_usage(struct command *cmd)
{
struct command_name *cname;
int onereq = (cmd->cmd_flags & CMD_FLAG_ONE_REQUIRED_OPT) ? 1 : 0;
int i, sep, ro, rp, oo, op, opt_enum;
int need_ro_indent_end = 0;
if (!(cname = find_command_name(cmd->name)))
return;
printf("\\fB%s\\fP", lvmname);
printf("\\fB%s\\fP", cmd->name);
if (!onereq)
goto ro_normal;
@@ -1911,7 +1907,7 @@ void print_man_usage(char *lvmname, struct command *cmd)
print_def_man(&cmd->required_opt_args[ro].def, 1);
}
sep++;
sep = 1;
}
/* print required options without a short opt */
@@ -1935,7 +1931,7 @@ void print_man_usage(char *lvmname, struct command *cmd)
print_def_man(&cmd->required_opt_args[ro].def, 1);
}
sep++;
sep = 1;
}
printf(" )\n");
@@ -1969,16 +1965,7 @@ void print_man_usage(char *lvmname, struct command *cmd)
*/
if (cmd->ro_count) {
sep = 0;
for (ro = 0; ro < cmd->ro_count; ro++) {
/* avoid long line wrapping */
if ((cmd->ro_count > 2) && (sep == 2)) {
printf("\n.RS 5\n");
need_ro_indent_end = 1;
}
opt_enum = cmd->required_opt_args[ro].opt;
if (opt_names[opt_enum].short_opt) {
@@ -1993,8 +1980,6 @@ void print_man_usage(char *lvmname, struct command *cmd)
printf(" ");
print_def_man(&cmd->required_opt_args[ro].def, 1);
}
sep++;
}
}
@@ -2012,9 +1997,6 @@ void print_man_usage(char *lvmname, struct command *cmd)
printf("\n");
}
if (need_ro_indent_end)
printf(".RE\n");
printf(".br\n");
oo_count:
@@ -2430,6 +2412,9 @@ void print_man_all_options_desc(struct command_name *cname)
if (print_common && !is_lvm_all_opt(opt_enum))
continue;
if (sep)
printf("\n.br\n");
printf("\n.TP\n");
if (opt_names[opt_enum].short_opt) {
@@ -2520,21 +2505,15 @@ static char *upper_command_name(char *str)
return str_upper;
}
void print_man(char *name, int include_primary, int include_secondary)
void print_man(char *man_command_name, int include_primary, int include_secondary)
{
struct command_name *cname;
struct command_name *cname = find_command_name(man_command_name);
struct command *cmd, *prev_cmd = NULL;
char *lvmname = name;
const char *desc;
int i, j, ro, rp, oo, op;
if (!strncmp(name, "lvm-", 4))
name += 4;
cname = find_command_name(name);
printf(".TH %s 8 \"LVM TOOLS #VERSION#\" \"Sistina Software UK\"\n",
upper_command_name(lvmname));
man_command_name ? upper_command_name(man_command_name) : "LVM_COMMANDS");
for (i = 0; i < COMMAND_COUNT; i++) {
@@ -2559,16 +2538,16 @@ void print_man(char *name, int include_primary, int include_secondary)
if (!(cmd->cmd_flags & CMD_FLAG_SECONDARY_SYNTAX) && !include_primary)
continue;
if (name && strcmp(name, cmd->name))
if (man_command_name && strcmp(man_command_name, cmd->name))
continue;
if (!prev_cmd || strcmp(prev_cmd->name, cmd->name)) {
printf(".SH NAME\n");
printf(".\n");
if (cname->desc)
printf("%s \\- %s\n", lvmname, cname->desc);
printf("%s \\- %s\n", cmd->name, cname->desc);
else
printf("%s\n", lvmname);
printf("%s\n", cmd->name);
printf(".br\n");
printf(".P\n");
printf(".\n");
@@ -2582,13 +2561,13 @@ void print_man(char *name, int include_primary, int include_secondary)
return;
if (cname->variant_has_ro && cname->variant_has_rp)
printf("\\fB%s\\fP \\fIrequired_option_args\\fP \\fIrequired_position_args\\fP\n", lvmname);
printf("\\fB%s\\fP \\fIrequired_option_args\\fP \\fIrequired_position_args\\fP\n", cmd->name);
else if (cname->variant_has_ro && !cname->variant_has_rp)
printf("\\fB%s\\fP \\fIrequired_option_args\\fP\n", lvmname);
printf("\\fB%s\\fP \\fIrequired_option_args\\fP\n", cmd->name);
else if (!cname->variant_has_ro && cname->variant_has_rp)
printf("\\fB%s\\fP \\fIrequired_position_args\\fP\n", lvmname);
printf("\\fB%s\\fP \\fIrequired_position_args\\fP\n", cmd->name);
else if (!cname->variant_has_ro && !cname->variant_has_rp)
printf("\\fB%s\\fP\n", lvmname);
printf("\\fB%s\\fP\n", cmd->name);
printf(".br\n");
@@ -2625,7 +2604,7 @@ void print_man(char *name, int include_primary, int include_secondary)
printf(".P\n");
}
print_man_usage(lvmname, cmd);
print_man_usage(cmd);
if (i == (COMMAND_COUNT - 1)) {
printf("Common options:\n");

View File

@@ -22,11 +22,11 @@ struct cmd_context;
typedef int (*command_fn) (struct cmd_context *cmd, int argc, char **argv);
/* new per-command-line-id functions */
typedef int (*command_id_fn) (struct cmd_context *cmd, int argc, char **argv);
typedef int (*command_line_fn) (struct cmd_context *cmd, int argc, char **argv);
struct command_function {
int command_enum;
command_id_fn fn;
int command_line_enum;
command_line_fn fn;
};
#define MAX_COMMAND_NAMES 64
@@ -170,10 +170,9 @@ struct cmd_rule {
/* a register of the lvm commands */
struct command {
const char *name;
const char *desc; /* specific command description from command-lines.in */
const char *command_id; /* ID string in command-lines.in */
int command_enum; /* <command_id>_CMD */
int command_index; /* position in commands[] */
const char *desc; /* specific command description from command-lines.h */
const char *command_line_id; /* ID string in command-lines.in */
int command_line_enum; /* <command_line_id>_CMD */
struct command_function *functions; /* new style */
command_fn fn; /* old style */

View File

@@ -1016,7 +1016,9 @@ static int _lvchange_properties_check(struct cmd_context *cmd,
{
if (!lv_is_visible(lv)) {
if (lv_is_named_arg)
log_error("Operation not permitted on hidden LV %s.", display_lvname(lv));
log_error("Operation not permitted (%s %d) on hidden LV %s.",
cmd->command->command_line_id, cmd->command->command_line_enum,
display_lvname(lv));
return 0;
}
@@ -1127,7 +1129,9 @@ static int _lvchange_activate_check(struct cmd_context *cmd,
{
if (!lv_is_visible(lv)) {
if (lv_is_named_arg)
log_error("Operation not permitted on hidden LV %s.", display_lvname(lv));
log_error("Operation not permitted (%s %d) on hidden LV %s.",
cmd->command->command_line_id, cmd->command->command_line_enum,
display_lvname(lv));
return 0;
}
@@ -1181,7 +1185,9 @@ static int _lvchange_refresh_check(struct cmd_context *cmd,
{
if (!lv_is_visible(lv)) {
if (lv_is_named_arg)
log_error("Operation not permitted on hidden LV %s.", display_lvname(lv));
log_error("Operation not permitted (%s %d) on hidden LV %s.",
cmd->command->command_line_id, cmd->command->command_line_enum,
display_lvname(lv));
return 0;
}
@@ -1361,7 +1367,9 @@ static int _lvchange_persistent_check(struct cmd_context *cmd,
{
if (!lv_is_visible(lv)) {
if (lv_is_named_arg)
log_error("Operation not permitted on hidden LV %s.", display_lvname(lv));
log_error("Operation not permitted (%s %d) on hidden LV %s.",
cmd->command->command_line_id, cmd->command->command_line_enum,
display_lvname(lv));
return 0;
}
@@ -1377,8 +1385,8 @@ int lvchange_persistent_cmd(struct cmd_context *cmd, int argc, char **argv)
int lvchange(struct cmd_context *cmd, int argc, char **argv)
{
log_error(INTERNAL_ERROR "Missing function for command definition %d:%s.",
cmd->command->command_index, cmd->command->command_id);
log_error(INTERNAL_ERROR "Missing function for command definition %s.",
cmd->command->command_line_id);
return ECMD_FAILED;
}

View File

@@ -146,6 +146,8 @@ static int _read_conversion_type(struct cmd_context *cmd,
static int _read_params(struct cmd_context *cmd, struct lvconvert_params *lp)
{
const char *vg_name = NULL;
int region_size;
int pagesize = lvm_getpagesize();
if (!_read_conversion_type(cmd, lp))
return_0;
@@ -247,10 +249,45 @@ static int _read_params(struct cmd_context *cmd, struct lvconvert_params *lp)
return 0;
}
if (arg_is_set(cmd, regionsize_ARG))
/*
* --regionsize is only valid if converting an LV into a mirror.
* Checked when we know the state of the LV being converted.
*/
if (arg_is_set(cmd, regionsize_ARG)) {
if (arg_sign_value(cmd, regionsize_ARG, SIGN_NONE) ==
SIGN_MINUS) {
log_error("Negative regionsize is invalid.");
return 0;
}
lp->region_size = arg_uint_value(cmd, regionsize_ARG, 0);
else
lp->region_size = get_default_region_size(cmd);
} else {
region_size = get_default_region_size(cmd);
if (region_size < 0) {
log_error("Negative regionsize in "
"configuration file is invalid.");
return 0;
}
lp->region_size = region_size;
}
if (lp->region_size % (pagesize >> SECTOR_SHIFT)) {
log_error("Region size (%" PRIu32 ") must be "
"a multiple of machine memory "
"page size (%d).",
lp->region_size, pagesize >> SECTOR_SHIFT);
return 0;
}
if (!is_power_of_2(lp->region_size)) {
log_error("Region size (%" PRIu32
") must be a power of 2.", lp->region_size);
return 0;
}
if (!lp->region_size) {
log_error("Non-zero region size must be supplied.");
return 0;
}
/* FIXME man page says in one place that --type and --mirrors can't be mixed */
if (lp->mirrors_supplied && !lp->mirrors)
@@ -1365,13 +1402,13 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
return 1;
}
goto try_new_takeover_or_reshape;
} else if (!*lp->type_str || seg->segtype == lp->segtype) {
} else if (!arg_is_set(cmd, regionsize_ARG) && (!*lp->type_str || seg->segtype == lp->segtype)) {
log_error("Conversion operation not yet supported.");
return 0;
}
if ((seg_is_linear(seg) || seg_is_striped(seg) || seg_is_mirrored(seg) || lv_is_raid(lv)) &&
(lp->type_str && lp->type_str[0])) {
((lp->type_str && lp->type_str[0]) || arg_is_set(cmd, regionsize_ARG))) {
/* Activation is required later which precludes existing supported raid0 segment */
if ((seg_is_any_raid0(seg) || segtype_is_any_raid0(lp->segtype)) &&
!(lp->target_attr & RAID_FEATURE_RAID0)) {
@@ -1393,8 +1430,12 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
if (!arg_is_set(cmd, stripes_long_ARG))
lp->stripes = 0;
/*
* FIXME: arg_is_set() workaround for region size until the cli validation patches got merged;
* i needs "--type raid*", because lp->region_size isn't set w/o it
*/
if (!lv_raid_convert(lv, lp->segtype, lp->yes, lp->force, lp->stripes, lp->stripe_size_supplied, lp->stripe_size,
lp->region_size, lp->pvh))
arg_is_set(cmd, regionsize_ARG) ? lp->region_size : 0, lp->pvh))
return_0;
log_print_unless_silent("Logical volume %s successfully converted.",
@@ -1415,8 +1456,12 @@ try_new_takeover_or_reshape:
if (lp->type_str && lp->type_str[0] && lp->segtype != seg->segtype &&
((seg_is_raid4(seg) && seg_is_striped(lp) && lp->stripes > 1) ||
(seg_is_striped(seg) && seg->area_count > 1 && seg_is_raid4(lp)))) {
/*
* FIXME: arg_is_set() workaround for region size until the cli validation patches got merged;
* i needs "--type raid*", because lp->region_size isn't set w/o it
*/
if (!lv_raid_convert(lv, lp->segtype, lp->yes, lp->force, lp->stripes, lp->stripe_size_supplied, lp->stripe_size,
lp->region_size, lp->pvh))
arg_is_set(cmd, regionsize_ARG) ? lp->region_size : 0, lp->pvh))
return_0;
log_print_unless_silent("Logical volume %s successfully converted.",
@@ -3718,7 +3763,7 @@ static int _lvconvert_to_pool_single(struct cmd_context *cmd,
int to_thinpool = 0;
int to_cachepool = 0;
switch (cmd->command->command_enum) {
switch (cmd->command->command_line_enum) {
case lvconvert_to_thinpool_CMD:
to_thinpool = 1;
break;
@@ -3767,7 +3812,7 @@ int lvconvert_to_pool_noarg_cmd(struct cmd_context *cmd, int argc, char **argv)
char *pool_data_name;
int i, p;
switch (cmd->command->command_enum) {
switch (cmd->command->command_line_enum) {
case lvconvert_to_thinpool_noarg_CMD:
pool_data_name = (char *)arg_str_value(cmd, thinpool_ARG, NULL);
new_command = get_command(lvconvert_to_thinpool_CMD);
@@ -3781,9 +3826,9 @@ int lvconvert_to_pool_noarg_cmd(struct cmd_context *cmd, int argc, char **argv)
return 0;
};
log_debug("Changing command %d:%s to standard form %d:%s",
cmd->command->command_index, cmd->command->command_id,
new_command->command_index, new_command->command_id);
log_debug("Changing command line id %s %d to standard form %s %d",
cmd->command->command_line_id, cmd->command->command_line_enum,
new_command->command_line_id, new_command->command_line_enum);
/* Make the LV the first position arg. */
@@ -4046,7 +4091,7 @@ int lvconvert_swap_pool_metadata_noarg_cmd(struct cmd_context *cmd, int argc, ch
struct command *new_command;
char *pool_name;
switch (cmd->command->command_enum) {
switch (cmd->command->command_line_enum) {
case lvconvert_swap_thinpool_metadata_CMD:
pool_name = (char *)arg_str_value(cmd, thinpool_ARG, NULL);
break;
@@ -4060,9 +4105,9 @@ int lvconvert_swap_pool_metadata_noarg_cmd(struct cmd_context *cmd, int argc, ch
new_command = get_command(lvconvert_swap_pool_metadata_CMD);
log_debug("Changing command %d:%s to standard form %d:%s",
cmd->command->command_index, cmd->command->command_id,
new_command->command_index, new_command->command_id);
log_debug("Changing command line id %s %d to standard form %s %d",
cmd->command->command_line_id, cmd->command->command_line_enum,
new_command->command_line_id, new_command->command_line_enum);
/* Make the LV the first position arg. */
@@ -4126,7 +4171,7 @@ static int _lvconvert_split_cachepool_single(struct cmd_context *cmd,
return ECMD_FAILED;
}
switch (cmd->command->command_enum) {
switch (cmd->command->command_line_enum) {
case lvconvert_split_and_keep_cachepool_CMD:
ret = _lvconvert_split_and_keep_cachepool(cmd, cache_lv, cachepool_lv);
break;
@@ -4147,7 +4192,7 @@ static int _lvconvert_split_cachepool_single(struct cmd_context *cmd,
int lvconvert_split_cachepool_cmd(struct cmd_context *cmd, int argc, char **argv)
{
if (cmd->command->command_enum == lvconvert_split_and_remove_cachepool_CMD) {
if (cmd->command->command_line_enum == lvconvert_split_and_remove_cachepool_CMD) {
cmd->handles_missing_pvs = 1;
cmd->partial_activation = 1;
}
@@ -4226,7 +4271,8 @@ static int _lvconvert_raid_types_check(struct cmd_context *cmd, struct logical_v
case thinpool_LVT:
case cachepool_LVT:
case snapshot_LVT:
log_error("Operation not permitted on LV %s type %s.",
log_error("Operation not permitted (%s %d) on LV %s type %s.",
cmd->command->command_line_id, cmd->command->command_line_enum,
display_lvname(lv), lvtype ? lvtype->name : "unknown");
return 0;
}
@@ -4234,7 +4280,9 @@ static int _lvconvert_raid_types_check(struct cmd_context *cmd, struct logical_v
return 1;
fail_hidden:
log_error("Operation not permitted on hidden LV %s.", display_lvname(lv));
log_error("Operation not permitted (%s %d) on hidden LV %s.",
cmd->command->command_line_id, cmd->command->command_line_enum,
display_lvname(lv));
return 0;
}
@@ -4293,7 +4341,9 @@ static int _lvconvert_visible_check(struct cmd_context *cmd, struct logical_volu
int lv_is_named_arg)
{
if (!lv_is_visible(lv)) {
log_error("Operation not permitted on hidden LV %s.", display_lvname(lv));
log_error("Operation not permitted (%s %d) on hidden LV %s.",
cmd->command->command_line_id, cmd->command->command_line_enum,
display_lvname(lv));
return 0;
}
@@ -4511,8 +4561,8 @@ int lvconvert_merge_cmd(struct cmd_context *cmd, int argc, char **argv)
int lvconvert(struct cmd_context *cmd, int argc, char **argv)
{
log_error(INTERNAL_ERROR "Missing function for command definition %d:%s.",
cmd->command->command_index, cmd->command->command_id);
log_error(INTERNAL_ERROR "Missing function for command definition %s.",
cmd->command->command_line_id);
return ECMD_FAILED;
}

View File

@@ -545,6 +545,7 @@ static int _read_raid_params(struct cmd_context *cmd,
static int _read_mirror_and_raid_params(struct cmd_context *cmd,
struct lvcreate_params *lp)
{
int pagesize = lvm_getpagesize();
unsigned max_images;
if (seg_is_raid(lp)) {
@@ -615,6 +616,19 @@ static int _read_mirror_and_raid_params(struct cmd_context *cmd,
return 0;
}
if (!is_power_of_2(lp->region_size)) {
log_error("Region size (%" PRIu32 ") must be a power of 2",
lp->region_size);
return 0;
}
if (lp->region_size % (pagesize >> SECTOR_SHIFT)) {
log_error("Region size (%" PRIu32 ") must be a multiple of "
"machine memory page size (%d)",
lp->region_size, pagesize >> SECTOR_SHIFT);
return 0;
}
if (seg_is_mirror(lp) && !_read_mirror_params(cmd, lp))
return_0;

View File

@@ -797,45 +797,6 @@ int readahead_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_va
return 1;
}
int regionsize_arg(struct cmd_context *cmd, struct arg_values *av)
{
int pagesize = lvm_getpagesize();
uint32_t num;
if (!_size_arg(cmd, av, 2048, 0))
return 0;
if (av->sign == SIGN_MINUS) {
log_error("Region size may not be negative.");
return 0;
}
if (av->ui64_value > UINT32_MAX) {
log_error("Region size is too big (max %u).", UINT32_MAX);
return 0;
}
num = av->ui_value;
if (!num) {
log_error("Region size may not be zero.");
return 0;
}
if (num % (pagesize >> SECTOR_SHIFT)) {
log_error("Region size must be a multiple of machine memory page size (%d bytes).",
pagesize);
return 0;
}
if (!is_power_of_2(num)) {
log_error("Region size must be a power of 2.");
return 0;
}
return 1;
}
/*
* Non-zero, positive integer, "all", or "unmanaged"
*/
@@ -1112,15 +1073,15 @@ static struct command_name *find_command_name(const char *name)
return NULL;
}
static struct command_function *_find_command_id_function(int command_enum)
static struct command_function *_find_command_id_function(int command_line_enum)
{
int i;
if (!command_enum)
if (!command_line_enum)
return NULL;
for (i = 0; i < CMD_COUNT; i++) {
if (command_functions[i].command_enum == command_enum)
if (command_functions[i].command_line_enum == command_line_enum)
return &command_functions[i];
}
return NULL;
@@ -1145,10 +1106,10 @@ void lvm_register_commands(void)
_cmdline.num_commands = COMMAND_COUNT;
for (i = 0; i < COMMAND_COUNT; i++) {
commands[i].command_enum = command_id_to_enum(commands[i].command_id);
commands[i].command_line_enum = command_id_to_enum(commands[i].command_line_id);
/* new style */
commands[i].functions = _find_command_id_function(commands[i].command_enum);
commands[i].functions = _find_command_id_function(commands[i].command_line_enum);
/* old style */
if (!commands[i].functions) {
@@ -1188,7 +1149,7 @@ struct command *get_command(int cmd_enum)
int i;
for (i = 0; i < COMMAND_COUNT; i++) {
if (commands[i].command_enum == cmd_enum)
if (commands[i].command_line_enum == cmd_enum)
return &commands[i];
}
@@ -1559,7 +1520,8 @@ 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.",
log_error("Invalid option for command (%s %d): %s.",
commands[best_i].command_line_id, best_i,
arg_long_option_name(best_unused_options[i]));
}
return NULL;
@@ -1589,7 +1551,8 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path,
break;
if (count >= (commands[best_i].rp_count + commands[best_i].op_count)) {
log_error("Invalid positional argument for command: %s.", argv[count]);
log_error("Invalid positional argument for command (%s %d): %s.",
commands[best_i].command_line_id, best_i, argv[count]);
/* FIXME: to warn/ignore, clear so it can't be used when processing. */
/*
@@ -1633,21 +1596,22 @@ out:
if (opts_match_count && (rule->rule == RULE_INVALID)) {
memset(buf, 0, sizeof(buf));
opt_array_to_str(cmd, rule->check_opts, rule->check_opts_count, buf, sizeof(buf));
log_error("Invalid options for command: %s", buf);
log_error("Invalid options for command (%s %d): %s",
commands[best_i].command_line_id, best_i, buf);
return NULL;
}
if (opts_unmatch_count && (rule->rule == RULE_REQUIRE)) {
memset(buf, 0, sizeof(buf));
opt_array_to_str(cmd, rule->check_opts, rule->check_opts_count, buf, sizeof(buf));
log_error("Required options for command: %s", buf);
log_error("Required options for command (%s %d): %s",
commands[best_i].command_line_id, best_i, buf);
return NULL;
}
}
}
log_debug("Using command index %d id %s enum %d.",
best_i, commands[best_i].command_id, commands[best_i].command_enum);
log_debug("command line id: %s %d", commands[best_i].command_line_id, best_i);
return &commands[best_i];
}

View File

@@ -2688,8 +2688,8 @@ static int _check_lv_types(struct cmd_context *cmd, struct logical_volume *lv, i
return 1;
if (!val_bit_is_set(cmd->command->required_pos_args[pos-1].def.val_bits, lv_VAL)) {
log_error(INTERNAL_ERROR "Command %d:%s arg position %d does not permit an LV (%llx)",
cmd->command->command_index, cmd->command->command_id,
log_error(INTERNAL_ERROR "Command (%s %d) arg position %d does not permit an LV (%llx)",
cmd->command->command_line_id, cmd->command->command_line_enum,
pos, (unsigned long long)cmd->command->required_pos_args[pos-1].def.val_bits);
return 0;
}
@@ -3105,7 +3105,9 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
if (!_check_lv_types(cmd, lvl->lv, lv_arg_pos)) {
/* FIXME: include this result in report log? */
if (lv_is_named_arg) {
log_error("Operation not permitted on LV %s.", display_lvname(lvl->lv));
log_error("Operation not permitted (%s %d) on LV %s.",
cmd->command->command_line_id, cmd->command->command_line_enum,
display_lvname(lvl->lv));
ret_max = ECMD_FAILED;
}
continue;
@@ -3114,7 +3116,9 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
if (!_check_lv_rules(cmd, lvl->lv)) {
/* FIXME: include this result in report log? */
if (lv_is_named_arg) {
log_error("Operation not permitted on LV %s.", display_lvname(lvl->lv));
log_error("Operation not permitted (%s %d) on LV %s.",
cmd->command->command_line_id, cmd->command->command_line_enum,
display_lvname(lvl->lv));
ret_max = ECMD_FAILED;
}
continue;

View File

@@ -200,7 +200,6 @@ int segtype_arg(struct cmd_context *cmd, struct arg_values *av);
int alloc_arg(struct cmd_context *cmd, struct arg_values *av);
int locktype_arg(struct cmd_context *cmd, struct arg_values *av);
int readahead_arg(struct cmd_context *cmd, struct arg_values *av);
int regionsize_arg(struct cmd_context *cmd, struct arg_values *av);
int vgmetadatacopies_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
int pvmetadatacopies_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);
int metadatacopies_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av);

View File

@@ -92,10 +92,6 @@
* --size and other option args treat upper/lower letters
* the same, all as 1024 SI base. For this reason, we
* should avoid suggesting the upper case letters.
*
* FIXME: negative numbers should be automatically rejected
* for anything but int_arg_with_sign(), e.g.
* size_mb_arg() should reject a negative number.
*/
val(none_VAL, NULL, "None", "ERR") /* unused, for enum value 0 */
@@ -117,7 +113,6 @@ val(discards_VAL, discards_arg, "Discards", "passdown|nopassdown|ignore")
val(mirrorlog_VAL, mirrorlog_arg, "MirrorLog", "core|disk")
val(sizekb_VAL, size_kb_arg, "SizeKB", "Number[k|unit]")
val(sizemb_VAL, size_mb_arg, "SizeMB", "Number[m|unit]")
val(regionsize_VAL, regionsize_arg, "RegionSize", "Number[m|unit]")
val(numsigned_VAL, int_arg_with_sign, "SNumber", "[+|-]Number")
val(numsignedper_VAL, int_arg_with_sign_and_percent, "SNumberP", "[+|-]Number[%VG|%PVS|%FREE]")
val(permission_VAL, permission_arg, "Permission", "rw|r")