1
0
mirror of git://sourceware.org/git/lvm2.git synced 2026-02-06 20:32:50 +03:00

Compare commits

...

101 Commits

Author SHA1 Message Date
Jonathan Brassow
ba12a2e81a Typo: change loose to lose
loose (v): set free; release
lose (v) : be deprived of or cease to have or retain

We 'lose' redundancy or 'lose' meaning.
2017-04-12 10:28:19 -05:00
Heinz Mauelshagen
532388fad5 lvconvert: fix failing valid regionsize change
Reshape check failed when regionsize changed and current raid type
was provided with no other change requested (stripes or stripesize).

E.g. "lvconvert --type raid6 --regionsize 256K" on a raid6 LV
with != 256K regionsize.

Enable --type in test script.
2017-04-12 14:38:49 +02:00
Heinz Mauelshagen
01b5820d03 lvconvert: add segment type raid10_near
Introducing this alias for "raid10", avoid allocating
reshape space when converting between them.

Resolves: rhbz1441347
2017-04-12 01:28:22 +02:00
Heinz Mauelshagen
7bc85177b0 raid: handle insufficent PVs on takeover from striped/raid0
Remove any newly allocated sub LV (pair) remnants in case
allocation fails due to lag of (parallel) free PV space
and keep initial raid type.

Resolves: rhbz1438013
2017-04-12 00:27:59 +02:00
David Teigland
c7ecf379ab man lvmraid: wrap long lines
Break lines in examples to keep line length under 80.
2017-04-11 15:23:48 -05:00
David Teigland
69c3543855 raid_manip: fix typo warning message 2017-04-11 14:18:57 -05:00
David Teigland
1dfb4a2dae man lvmraid: fix line wrapping in examples 2017-04-11 14:17:08 -05:00
David Teigland
c448dcb349 man lvmraid: use same style as generated pages 2017-04-11 13:20:54 -05:00
David Teigland
04d7444afa 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.
2017-04-11 12:17:14 -05:00
David Teigland
a96c8b46b6 lvconvert: prevent duplicate use of metadata lv
The LV being processed cannot be used as the
pool metadata LV.
2017-04-11 12:11:00 -05:00
David Teigland
e0c169f8b7 man lvmraid: improve text layout 2017-04-11 10:55:02 -05:00
David Teigland
2fd9ae0703 lvconvert: validate vg name prefix for pool metadata name 2017-04-11 10:40:08 -05:00
David Teigland
21da004e58 man lvcreate/lvconvert: minor clean up rewording 2017-04-11 10:21:36 -05:00
David Teigland
a4f07b701a 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.
2017-04-10 13:41:47 -05:00
Heinz Mauelshagen
a14a8cef2f signals: fix comparison flaw
commit 9a689fb8f0
fixed SIGINT blocking but introduced a comparision
flaw to sigint_restore().

Related: rhbz1440766
2017-04-10 18:41:28 +02:00
Heinz Mauelshagen
9a689fb8f0 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
2017-04-10 18:16:09 +02:00
Heinz Mauelshagen
ef3e1013aa lvconvert: cleanup prompting 2017-04-06 19:59:57 +02:00
Heinz Mauelshagen
eb6302c8cb lvconvert: fixe conversion message
When selecting a convenience RAID type only display
the selected type when it changed.  Display proper
current raid type when prompting.
2017-04-06 19:28:32 +02:00
Heinz Mauelshagen
653bca6811 lvconvert: raid1 -> linear prompt
Avoid 2 prompts when downconverting raid1 to linear
(related commit 0f65d7ec3a).
2017-04-06 19:24:11 +02:00
Heinz Mauelshagen
3b1a96b9b3 lvconvert: avoid error message on raid1 -> raid4 conversion
Avoid error message
"Logical Volume *_rimage_0 already exists in volume group,,,"
on takeover conversion from a 2-legged raid1 to raid4
(aiming to reshape it adding images).

Resolves: rhbz1439398
2017-04-06 19:09:05 +02:00
Heinz Mauelshagen
0f65d7ec3a lvconvert: prompt on raid1 image changes
Don't change resilience of raid1 LVs without --yes.

Adjust respective tests.
2017-04-06 18:47:41 +02:00
Heinz Mauelshagen
e350b83d50 raid: reload on removing images
Requesting _raid_remove_images() to commit the
metadata missed to reload the origin causing a
kernel takeover error converting a 2-legged raid1
(with previously removed images) to raid5.
2017-04-06 00:47:34 +02:00
Heinz Mauelshagen
a8d5ada452 man: lvmraid.7 raid6_n_6 fix 2017-04-06 00:35:12 +02:00
Heinz Mauelshagen
d23cad16c9 raid: tidying 2017-04-06 00:06:52 +02:00
Heinz Mauelshagen
1ef1bdab27 lvconvert: allow --type with --regionsize
Allow the combination of both arguments keeping
the raid level but changing the regionssize
(e.g. "lvconvert --type raid1 --regionsize 1M RaidLV"
 on an existing raid1 LV).

Resolves: rhbz1438396
2017-04-06 00:03:16 +02:00
David Teigland
7ccb4825c7 lvchange/lvconvert: fix missing lvmlockd LV locks
lvchange/lvconvert operations that do not require the LV
to already be active need to acquire a transient LV lock
before changing/converting the LV to ensure the LV is not
active on another host.  If the LV is already active,
a persistent LV lock already exists on the host and the
transient LV lock request is a no-op.

Some lvmlockd locks in lvchange were lost in the cmd def
changes.  The lvmlockd locks in lvconvert seem to have
been missed from the start.
2017-04-05 16:46:38 -05:00
Heinz Mauelshagen
c9bc1c1c8c lvchange: tidy switch code in _lvchange_properties_single() 2017-04-05 17:29:31 +02:00
David Teigland
6fdc391bae lvchange: fix missing return value
A return value from lvchange_persistent_cmd() was missed
in commit 1c41898c07
2017-04-05 10:08:01 -05:00
Peter Rajnoha
448bf9491a lvmconf: fix systemd unit existence check for lvmconf --services --startstopservices
We have to unset the LoadState variable from previous use when we check
for systemd unit state. We use this variable to check if systemd services
are loaded or not and if it is loaded, we issue systemctl commands to
enable/disable and start/stop the service. We don't issue these commands
if the unit is not loaded to avoid error messages which may confuse users.
2017-04-05 11:06:56 +02:00
David Teigland
afa844817a commands: fix misspelling of option value
(The cmd def parser really needs to catch mistakes
like this as it did when it was external.)
2017-04-04 17:09:35 -05:00
David Teigland
a7d4156a9a lvchange: fix --poll value when set from option
The actual value specified by the --poll y|n option was not
being used.  The way the --poll value is used is hidden
through an indirection where the value is stored in a
global variable at the start of the command, and then the
value is read from there later.  Setting the global
variable early in the command had been lost with the
cmd def changes.
2017-04-04 17:04:45 -05:00
David Teigland
1c41898c07 vgchange/lvchange: fix poll and monitor use
Fill in some gaps where old versions of lvm allowed
--poll and --monitor in combination with other operations,
but those combinations had been lost since the cmd def work.
(The new cmd def code also added some combinations that
had been missed by the old code.)

Changes:

lvchange --activate: add poll and monitor options, and
                     add calls to them in implementation.

lvchange --refresh: add monitor option (poll already there),
                    and call to monitor in implementation.

lvchange <metadata ops>: add poll and monitor options, and
                         add calls to them in implementation.

vgchange <metadata ops>: add poll option (call to poll
                         already in implementation).

vgchange --refresh: remove monitor option (not used by code)

lvchange --persistent y: add poll and monitor options, and
                         add calls to them, and to activate
                         in the implementation. (Making it
                         match the main lvchange metadata
                         command.)

Summary of current usage:

lvchange --activate: monitor, poll
vgchange --activate: monitor, poll

lvchange --refresh: monitor, poll
vgchange --refresh: poll

lvchange --monitor: ok
lvchange --poll: ok
lvchange --monitor --poll: ok
vgchange --monitor: ok
vgchange --poll: ok
vgchange --monitor --poll: ok

lvchange <metadata ops>: monitor, poll
vgchange <metadata ops>: poll
2017-04-04 17:04:45 -05:00
Heinz Mauelshagen
a12b3af033 lvchange: enhance avoiding multiple metadata updates/reloads/backups
Enhance commit 25b5915c9b
to process options requiring immediate metadata commits
and reloads after those we can group together doing just
one commit and an optional reload for the whole group.

Backup metadata after processing options successfully.

Related: rhbz1437611
2017-04-04 23:53:55 +02:00
Heinz Mauelshagen
e7ec9aab8a man: '-pool' regexp 2017-04-04 23:53:28 +02:00
David Teigland
76b70d5058 lvconvert: fix converting hidden lv to pool
A hidden LV can not be converted to a thin pool or cache pool.
2017-04-04 16:47:47 -05:00
David Teigland
b951d04337 help: print all options in abbreviated help output
Don't abbreviate the --help output quite as much
when there are many command defs.  Print all the
options in the cmd defs that are shown.  --longhelp
output is unchanged and includes everything.
2017-04-03 16:36:04 -05:00
David Teigland
29161a145e commands: missing comma in cmd def option list
Does not affect parsing, but keep it consistent.
2017-04-03 16:20:55 -05:00
David Teigland
db579b9e93 help: include cmd def info in verbose output
It can sometimes be important to correlate a
command with its cmd def entry, so include
the cross reference info in help -vv output.
2017-04-03 16:17:37 -05:00
David Teigland
dece723dc7 commands: recognize ignored options 2017-04-03 15:49:24 -05:00
David Teigland
162272e5a5 commands: ignore partial option in most cases
These days --partial is only used with activation in
lvchange/vgchange.  It probably had another meaning
at some point in history which is no longer used,
so ignore it in those cases.

When included in the OO list, the option is advertised in
help/man output, implying it is meaningful to the command,
when in fact the command never uses it.
The IO list means the option won't cause an error if it's
used, but is not displayed as an valid option for the command.
If the option is not included in either OO or IO lists,
using the option would cause a command error, which would cause
problems for anyone is using the option for historical reasons.
2017-04-03 15:43:04 -05:00
David Teigland
51ff707ac8 man: fix description of --partial option 2017-04-03 14:15:29 -05:00
David Teigland
e0f284d372 lvchange: refresh command missing activationmode option 2017-04-03 13:44:35 -05:00
Heinz Mauelshagen
25b5915c9b lvchange: avoid multiple metadata updates/reloads/backups
_lvchange_properties_single() processes multiple command
line arguments in a loop causing metadata updates and/or
backups per argument.

Optimize to only perform one update and/or backup
(but necessary interim ones; e.g. for --resync)
per command run.

Related: rhbz1437611
2017-04-01 02:38:48 +02:00
Zdenek Kabelac
fb1f38a6f6 tests: fix LD_LIBRARY_PATH
Use only selected paths for finding .so in builddir.
So if builddir constains some embeded subdirs with some more
occurences of project (i.e.  'make rpm' build subdir)
those library paths will not get into list.
2017-03-31 17:12:00 +02:00
Zdenek Kabelac
970df59f91 cache: scan kallsyms for kernel symbols
With monolithic kernels we can't actually modprobe
for cache modules as they are already compiled-in
and policy modules do not export version symbol.

Reported issue on list:
https://www.redhat.com/archives/dm-devel/2017-March/msg00061.html

Fix will try to look for explicit kernel symbols first before
calling modprobe.
2017-03-31 17:12:00 +02:00
Heinz Mauelshagen
13ca11cc14 lvchange: persistent major/minor processing regression
Optimized change.

Resolves: rhbz1437611
2017-03-31 17:09:33 +02:00
Heinz Mauelshagen
d6ddacf6a1 lvchange: persistent major/minor processing regression
Fix a regression introduced by new command line processing
(see starting commit 1e2420bca8)
causing activation to be rejected in combination with setting
persistent minor device numbers.

Resolves: rhbz1437611
2017-03-31 13:51:39 +02:00
Heinz Mauelshagen
0ed087aae5 man: pregen file change 2017-03-30 20:48:53 +02:00
Heinz Mauelshagen
92ac1da16a man-generator: shutdown stdout buffer
Flush stdout and switch it back to line buffering before exit.
2017-03-30 20:40:44 +02:00
Heinz Mauelshagen
2c4e8254de man-generator: enhance performance
Set block buffering on stdout to
save ~30% time generating manuals.
2017-03-30 19:55:50 +02:00
Heinz Mauelshagen
0da040b1eb man-generator: don't ignore description file errors
In case we provide a description file it has to
succeed opening and reading.  Dynamically allocate
buffer space for it whilst on it.
2017-03-30 19:51:35 +02:00
Heinz Mauelshagen
980e4f673e raid: more coverity issues 2017-03-30 18:39:04 +02:00
Heinz Mauelshagen
c34ab29ec6 raid: favour dm_list_first() 2017-03-30 18:13:27 +02:00
Heinz Mauelshagen
2d75ef3b05 raid: address coverity issues 2017-03-30 18:09:06 +02:00
Heinz Mauelshagen
b3854155d9 man-generator: add '.' to all messages 2017-03-30 17:54:36 +02:00
Heinz Mauelshagen
99dc49c7dd man: add minor regexp 2017-03-30 17:54:02 +02:00
Bryn M. Reeves
2b46fe5843 dmsetup: replace (f)printf("\n") with putchar/putc 2017-03-30 16:30:50 +01:00
Bryn M. Reeves
febda60f3d libdm: use correct FMTu32 format specifier for uint32_t 2017-03-30 16:17:19 +01:00
Bryn M. Reeves
e8d5e05ff5 libdm: fix incorrect format specifier in _stats_resize_group()
The bitmap size in dm_bitset_t[0] is a uint32_t, not uint64_t: use
%u instead of FMTu64.
2017-03-30 10:31:36 +01:00
Nir Soffer
b8b2b1efd8 dmsetup: Flush ouptut when using --interval 2017-03-30 10:17:32 +01:00
Bryn M. Reeves
c7e4b97abc libdm: use uint64_t where possible in filemap routines
Use uint64_t where possible and explicit casts elsewhere to avoid
compiler warnings when converting between int, int64_t and
uint64_t.
2017-03-30 10:02:54 +01:00
Bryn M. Reeves
b823646ace libdm: use size_t for buflen in _stats_group_file_regions() 2017-03-30 10:02:45 +01:00
Bryn M. Reeves
833b02106d libdm: make _stats_resize_group() num_regions argument uint64_t 2017-03-30 10:02:39 +01:00
Bryn M. Reeves
722542fabb libdm: make _find_extent() nr_extents argument uint64_t 2017-03-30 10:02:35 +01:00
Bryn M. Reeves
5e74e43896 dmfilemapd: cast return value of strto* functions when needed 2017-03-30 10:02:31 +01:00
Bryn M. Reeves
834574cc27 dmfilemapd: use log_sys_error in _filemap_monitor_set_notify
Since _filemap_monitor_set_notify() is only called after daemon
start up it should not use the _early_log() macros. Instead, use
log_sys_error to log errors from the two syscalls in the function.
2017-03-30 10:01:57 +01:00
Bryn M. Reeves
bfc880994c dmfilemapd: cast sysconf() return value to int 2017-03-30 09:57:58 +01:00
Bryn M. Reeves
76b6cbea60 dmfilemapd: fix len type in _filemap_monitor_check_file_unlinked()
Make 'len' a size_t to match the return type of readlink(2).
2017-03-30 09:57:58 +01:00
Bryn M. Reeves
660bd4fe3e dmfilemapd: make filemap_monitor->nr_regions uint64_t 2017-03-30 09:57:58 +01:00
Bryn M. Reeves
ac6089ee8d libdm: use DM_STATS_GROUP_* constants in dm_stats_create_regions_from_fd 2017-03-30 09:57:58 +01:00
Bryn M. Reeves
fe0922b8a6 dmsetup: simplify branching in _stats_update_file()
The fallback branch in _stats_update_file() is redundant (since the
branch taken when the daemon starts successfully must jump to the
'out' label anyway): remove it and re-order the conditions to
improve readability.
2017-03-30 09:57:58 +01:00
Heinz Mauelshagen
803b1775ba man: raid cleanup 2017-03-30 00:44:35 +02:00
Heinz Mauelshagen
b6724fa423 man: Copyright 2017-03-30 00:44:35 +02:00
Heinz Mauelshagen
e9921ffd33 man: use variable in Makefile / regexp 2017-03-30 00:44:35 +02:00
Heinz Mauelshagen
2f1fd1584e man-generator: catch missing command name 2017-03-30 00:44:34 +02:00
Zdenek Kabelac
df86ee8c21 tests: fix typo in makefile
Use properly $(SORT)
2017-03-30 00:38:41 +02:00
Zdenek Kabelac
a66411bd7a man: fix type
With commit 4af09a94bd unwanted rename  of
target happened - restore it.
2017-03-30 00:38:41 +02:00
Zdenek Kabelac
dfdd6ccf3b vgrename: use long enough buffer for path
Use PATH_MAX when creating buffers for rename.
2017-03-30 00:38:41 +02:00
Bryn M. Reeves
4b3d71212f libdm: use log_sys_error if dmfilemapd exec fails
Use log_sys_error rather than log_error if execvp() fails:

  /mnt/redhat/xdoio.13752.XIORQ: Created new group with 2 region(s) as group ID 0.
  # execvp() failed.

vs:

  /var/lib/libvirt/images/rhel7-vm1.qcow2: Created new group with 884 region(s) as group ID 0.
  dmfilemapd: execvp failed: No such file or directory
2017-03-29 21:38:15 +01:00
Bryn M. Reeves
5994ed9df2 dmsetup: always close fd when leaving _stats_update_file() (coverity) 2017-03-29 18:34:57 +01:00
Bryn M. Reeves
11749e7adb dmsetup: do not start dmfilemapd if region creation fails (coverity) 2017-03-29 18:34:51 +01:00
Bryn M. Reeves
6740eb1c2b libdm: do not attempt filemap cleanup if dm_stats_list() fails (coverity) 2017-03-29 18:34:43 +01:00
Bryn M. Reeves
f86c1f5d0a libdm: abort filemap update if pool allocation fails (coverity) 2017-03-29 18:34:38 +01:00
Bryn M. Reeves
bc5d67884f libdm: do not leak FIEMAP extent buffer if pool allocation fails (coverity) 2017-03-29 18:34:30 +01:00
Bryn M. Reeves
13426092e9 dmfilemapd: free region table at end of _update_regions() (coverity) 2017-03-29 18:34:24 +01:00
Bryn M. Reeves
f66bc3dab0 dmfilemapd: fix off-by-one in fd comparison (coverity)
The function _filemap_monitor_check_file_unlinked() attempts to
test whether a fd value should be closed by comparison to zero:

        if ((fd > 0) && close(fd))
                log_error("Error closing fd %d", fd);

The test should be '>=' since 0 is a valid file descriptor.
2017-03-29 18:34:19 +01:00
Bryn M. Reeves
8658bbe3ee dmfilemapd: always close link check file descriptor (coverity)
Similar to 40fb91a, but for the file descriptor opened using the
link path reported by /proc/<self>/fd/<fd>.

The daemon opens a new file descriptor from /proc/<self>/fd when
checking for an unlinked file with mode=inode. Ensure that it is
always closed even if the same file test fails.
2017-03-29 18:34:11 +01:00
Bryn M. Reeves
7db51a6bed dmfilemapd: always terminate link buffer after readlink(2) (coverity) 2017-03-29 18:34:05 +01:00
Bryn M. Reeves
70bb726678 dmfilemapd: always close check file descriptor (coverity)
The daemon opens a new file descriptor from fm->path when checking
for an unlinked file with mode=inode. Ensure that it is always
closed even if the same file test fails.
2017-03-29 18:33:53 +01:00
Bryn M. Reeves
43fdbb8aeb dmfilemapd: use *argv[0] when testing for absolute path (coverity)
The path argument check in dmfilemapd incorrectly tests for:

  if (argv[0] == '/')

Rather than testing the 1st character in the string pointed to by
argv[0].
2017-03-29 18:33:42 +01:00
Bryn M. Reeves
b5252a51a5 dmfilemapd: pass correct dirp to closedir() 2017-03-29 16:54:44 +01:00
Bryn M. Reeves
481a522dd7 dmfilemapd: do not closdir(pid_d) unless it is open 2017-03-29 16:48:32 +01:00
Bryn M. Reeves
d71071a1af dmfilemapd: log closedir errors with log_sys_error() 2017-03-29 16:04:15 +01:00
Marian Csontos
5dfd35f2f8 dmstats: Fix path to static dmstats 2017-03-29 09:04:56 +02:00
Heinz Mauelshagen
5012be326d man: ranges/LV names/symbolic use regexp 2017-03-29 02:27:10 +02:00
Heinz Mauelshagen
4af09a94bd man: simplify by avoiding different headers on de-duplication of lvmconfig, lvm-config and lvm-dumpconfig 2017-03-29 01:44:09 +02:00
Heinz Mauelshagen
6742137964 man: de-duplicate lvmconfig, lvm-config and lvm-dumpconfig manuals 2017-03-29 00:22:15 +02:00
Marian Csontos
162552041f spec: Add dmfilemapd 2017-03-28 21:52:50 +02:00
Marian Csontos
a41d5b6491 dmfilemapd: Fix install target 2017-03-28 21:52:30 +02:00
Heinz Mauelshagen
3aab873199 man: regexp readability / use $(SED) 2017-03-28 17:51:22 +02:00
Alasdair G Kergon
0c2f7ed49a post-release 2017-03-28 16:14:03 +01:00
52 changed files with 1319 additions and 1620 deletions

View File

@@ -1 +1 @@
2.02.169(2)-git (2017-03-28)
2.02.170(2)-git (2017-03-28)

View File

@@ -1 +1 @@
1.02.138-git (2017-03-28)
1.02.139-git (2017-03-28)

View File

@@ -1,3 +1,8 @@
Version 2.02.170 -
==================================
Fix systemd unit existence check for lvmconf --services --startstopservices.
Check and use PATH_MAX buffers when creating vgrename device paths.
Version 2.02.169 - 28th March 2017
==================================
Automatically decide whether '-' in a man page is a hyphen or a minus sign.

View File

@@ -1,3 +1,6 @@
Version 1.02.139 -
==================================
Version 1.02.138 - 28th March 2017
==================================
Support additional raid5/6 configurations.

View File

@@ -182,7 +182,7 @@ int cluster_send(struct clog_request *rq)
}
/*
* Once the request heads for the cluster, the luid looses
* Once the request heads for the cluster, the luid loses
* all its meaning.
*/
rq->u_rq.luid = 0;

View File

@@ -377,7 +377,7 @@ static int _clog_ctr(char *uuid, uint64_t luid,
uint32_t block_on_error = 0;
int disk_log;
char disk_path[128];
char disk_path[PATH_MAX];
int unlink_path = 0;
long page_size;
int pages;

View File

@@ -60,7 +60,7 @@ install_dmfilemapd_dynamic: dmfilemapd
install_dmfilemapd_static: dmfilemapd.static
$(INSTALL_PROGRAM) -D $< $(staticdir)/$(<F)
install_dmfilemapd: $(INSTALL_DMEVENTD_TARGETS)
install_dmfilemapd: $(INSTALL_DMFILEMAPD_TARGETS)
install: install_dmfilemapd

View File

@@ -55,7 +55,7 @@ struct filemap_monitor {
/* monitoring heuristics */
int64_t blocks; /* allocated blocks, from stat.st_blocks */
int64_t nr_regions;
uint64_t nr_regions;
int deleted;
};
@@ -151,7 +151,7 @@ static int _is_open_in_pid(pid_t pid, const char *path)
if (dm_snprintf(path_buf, sizeof(path_buf),
DEFAULT_PROC_DIR "%d/fd", pid) < 0) {
log_error("Could not format pid path.");
goto bad;
return 0;
}
/*
@@ -160,12 +160,13 @@ static int _is_open_in_pid(pid_t pid, const char *path)
if (dm_snprintf(deleted_path, sizeof(deleted_path), "%s %s",
path, PROC_FD_DELETED_STR) < 0) {
log_error("Could not format check path.");
return 0;
}
pid_d = opendir(path_buf);
if (!pid_d) {
log_error("Could not open proc path: %s.", path_buf);
goto bad;
return 0;
}
while ((pid_dp = readdir(pid_d)) != NULL) {
@@ -179,13 +180,16 @@ static int _is_open_in_pid(pid_t pid, const char *path)
}
link_buf[len] = '\0';
if (!strcmp(deleted_path, link_buf)) {
closedir(pid_d);
if (closedir(pid_d))
log_sys_error("closedir", path_buf);
return 1;
}
}
bad:
closedir(pid_d);
if (closedir(pid_d))
log_sys_error("closedir", path_buf);
return 0;
}
@@ -221,15 +225,19 @@ static int _is_open(const char *path)
while ((proc_dp = readdir(proc_d)) != NULL) {
if (!isdigit(proc_dp->d_name[0]))
continue;
pid = strtol(proc_dp->d_name, NULL, 10);
pid = (pid_t) strtol(proc_dp->d_name, NULL, 10);
if (!pid)
continue;
if (_is_open_in_pid(pid, path)) {
closedir(proc_d);
if (closedir(proc_d))
log_sys_error("closedir", DEFAULT_PROC_DIR);
return 1;
}
}
closedir(proc_d);
if (closedir(proc_d))
log_sys_error("closedir", DEFAULT_PROC_DIR);
return 0;
}
@@ -272,7 +280,7 @@ static int _parse_args(int argc, char **argv, struct filemap_monitor *fm)
fm->nr_regions = 1;
/* parse <fd> */
fm->fd = strtol(argv[0], &endptr, 10);
fm->fd = (int) strtol(argv[0], &endptr, 10);
if (*endptr) {
_early_log("Could not parse file descriptor: %s", argv[0]);
return 0;
@@ -297,7 +305,7 @@ static int _parse_args(int argc, char **argv, struct filemap_monitor *fm)
return 0;
}
if (argv[0] != '/') {
if (*argv[0] != '/') {
_early_log("Path argument must specify an absolute path.");
return 0;
}
@@ -326,7 +334,7 @@ static int _parse_args(int argc, char **argv, struct filemap_monitor *fm)
/* parse [<foreground>[<verbose>]] */
if (argc) {
_foreground = strtol(argv[0], &endptr, 10);
_foreground = (int) strtol(argv[0], &endptr, 10);
if (*endptr) {
_early_log("Could not parse debug argument: %s.",
argv[0]);
@@ -335,7 +343,7 @@ static int _parse_args(int argc, char **argv, struct filemap_monitor *fm)
argc--;
argv++;
if (argc) {
_verbose = strtol(argv[0], &endptr, 10);
_verbose = (int) strtol(argv[0], &endptr, 10);
if (*endptr) {
_early_log("Could not parse verbose "
"argument: %s", argv[0]);
@@ -401,13 +409,13 @@ static int _filemap_monitor_set_notify(struct filemap_monitor *fm)
* and does not fork or exec.
*/
if ((inotify_fd = inotify_init1(IN_NONBLOCK)) < 0) {
_early_log("Failed to initialise inotify.");
log_sys_error("inotify_init1", "IN_NONBLOCK");
return 0;
}
if ((watch_fd = inotify_add_watch(inotify_fd, fm->path,
IN_MODIFY | IN_DELETE_SELF)) < 0) {
_early_log("Failed to add inotify watch.");
log_sys_error("inotify_add_watch", fm->path);
return 0;
}
fm->inotify_fd = inotify_fd;
@@ -551,19 +559,22 @@ static int _filemap_monitor_check_file_unlinked(struct filemap_monitor *fm)
{
char path_buf[PATH_MAX];
char link_buf[PATH_MAX];
int same, fd, len;
int same, fd;
ssize_t len;
fm->deleted = 0;
if ((fd = open(fm->path, O_RDONLY)) < 0)
goto check_unlinked;
if ((same = _filemap_monitor_check_same_file(fm->fd, fd)) < 0)
return 0;
same = _filemap_monitor_check_same_file(fm->fd, fd);
if (close(fd))
log_error("Error closing fd %d", fd);
if (same < 0)
return 0;
if (same)
return 1;
@@ -583,19 +594,22 @@ check_unlinked:
getpid(), fm->fd);
return 0;
}
link_buf[len] = '\0';
/*
* Try to re-open the file, from the path now reported in /proc/pid/fd.
*/
if ((fd = open(link_buf, O_RDONLY)) < 0)
fm->deleted = 1;
else
same = _filemap_monitor_check_same_file(fm->fd, fd);
if ((same = _filemap_monitor_check_same_file(fm->fd, fd)) < 0)
return 0;
if ((fd > 0) && close(fd))
if ((fd >= 0) && close(fd))
log_error("Error closing fd %d", fd);
if (same < 0)
return 0;
/* Should not happen with normal /proc. */
if ((fd > 0) && !same) {
log_error("File descriptor mismatch: %d and %s (read from %s) "
@@ -646,7 +660,7 @@ static int _daemonise(struct filemap_monitor *fm)
}
}
for (fd = sysconf(_SC_OPEN_MAX) - 1; fd > STDERR_FILENO; fd--) {
for (fd = (int) sysconf(_SC_OPEN_MAX) - 1; fd > STDERR_FILENO; fd--) {
if (fd == fm->fd)
continue;
close(fd);
@@ -674,7 +688,7 @@ static int _update_regions(struct dm_stats *dms, struct filemap_monitor *fm)
fm->group_id, regions[0]);
fm->group_id = regions[0];
}
dm_free(regions);
fm->nr_regions = nr_regions;
return 1;
}

View File

@@ -258,6 +258,39 @@ static void _destroy(struct segment_type *segtype)
}
#ifdef DEVMAPPER_SUPPORT
/*
* Parse and look for kernel symbol in /proc/kallsyms
* this could be our only change to figure out there is
* cache policy symbol already in the monolithic kernel
* where 'modprobe dm-cache-smq' will simply not work
*/
static int _lookup_kallsyms(const char *symbol)
{
static const char _syms[] = "/proc/kallsyms";
int ret = 0;
char *line = NULL;
size_t len;
FILE *s;
if (!(s = fopen(_syms, "r")))
log_sys_debug("fopen", _syms);
else {
while (getline(&line, &len, s) != -1)
if (strstr(line, symbol)) {
ret = 1; /* Found symbol */
log_debug("Found kernel symbol%s.", symbol); /* space is in symbol */
break;
}
free(line);
if (fclose(s))
log_sys_debug("fclose", _syms);
}
return ret;
}
static int _target_present(struct cmd_context *cmd,
const struct lv_segment *seg __attribute__((unused)),
unsigned *attributes __attribute__((unused)))
@@ -270,14 +303,15 @@ static int _target_present(struct cmd_context *cmd,
unsigned cache_alias;
const char feature[12];
const char module[12]; /* check dm-%s */
const char ksymbol[12]; /* check for kernel symbol */
const char *aliasing;
} _features[] = {
/* Assumption: cache >=1.9 always aliases MQ policy */
{ 1, 10, CACHE_FEATURE_METADATA2, 0, "metadata2" },
/* Assumption: cache >=1.9 always aliases MQ policy */
{ 1, 9, CACHE_FEATURE_POLICY_SMQ, CACHE_FEATURE_POLICY_MQ, "policy_smq", "cache-smq",
" and aliases cache-mq" },
{ 1, 8, CACHE_FEATURE_POLICY_SMQ, 0, "policy_smq", "cache-smq" },
{ 1, 3, CACHE_FEATURE_POLICY_MQ, 0, "policy_mq", "cache-mq" },
" smq_exit", " and aliases cache-mq" },
{ 1, 8, CACHE_FEATURE_POLICY_SMQ, 0, "policy_smq", "cache-smq", " smq_exit" },
{ 1, 3, CACHE_FEATURE_POLICY_MQ, 0, "policy_mq", "cache-mq", " mq_init" },
};
static const char _lvmconf[] = "global/cache_disabled_features";
static unsigned _attrs = 0;
@@ -323,7 +357,8 @@ static int _target_present(struct cmd_context *cmd,
}
if (((maj > _features[i].maj) ||
(maj == _features[i].maj && min >= _features[i].min)) &&
module_present(cmd, _features[i].module)) {
((_features[i].ksymbol[0] && _lookup_kallsyms(_features[i].ksymbol)) ||
module_present(cmd, _features[i].module))) {
log_debug_activation("Cache policy %s is available%s.",
_features[i].module,
_features[i].aliasing ? : "");

View File

@@ -751,6 +751,11 @@ static int _reorder_raid10_near_seg_areas(struct lv_segment *seg, enum raid0_rai
uint32_t *idx, stripes = seg->area_count;
unsigned i = 0;
if (!stripes) {
log_error(INTERNAL_ERROR "stripes may not be 0.");
return 0;
}
/* Internal sanity checks... */
if (!(conv == reorder_to_raid10_near || conv == reorder_from_raid10_near))
return_0;
@@ -937,11 +942,12 @@ static int _shift_and_rename_image_components(struct lv_segment *seg)
static char *_generate_raid_name(struct logical_volume *lv,
const char *suffix, int count)
{
const char *format = (count >= 0) ? "%s_%s_%u" : "%s_%s";
char name[NAME_LEN], *lvname;
int historical;
if (dm_snprintf(name, sizeof(name), format, lv->name, suffix, count) < 0) {
if (dm_snprintf(name, sizeof(name),
(count >= 0) ? "%s_%s_%u" : "%s_%s",
lv->name, suffix, count) < 0) {
log_error("Failed to new raid name for %s.",
display_lvname(lv));
return NULL;
@@ -1586,7 +1592,6 @@ static int _lv_free_reshape_space_with_status(struct logical_volume *lv, enum al
*/
if (!_lv_alloc_reshape_space(lv, alloc_end, &where, NULL))
return_0;
seg->extents_copied = first_seg(lv)->area_len;
if (!lv_reduce(lv, total_reshape_len))
return_0;
@@ -1701,7 +1706,7 @@ static int _reshape_adjust_to_size(struct logical_volume *lv,
/* Externally visible LV size w/o reshape space */
lv->le_count = seg->len = new_le_count;
lv->size = (uint64_t) (lv->le_count - new_image_count * _reshape_len_per_dev(seg)) * lv->vg->extent_size;
lv->size = (uint64_t) (lv->le_count - new_image_count * (uint32_t) _reshape_len_per_dev(seg)) * lv->vg->extent_size;
/* seg->area_len does not change */
if (old_image_count < new_image_count) {
@@ -1886,7 +1891,7 @@ static int _raid_reshape_remove_images(struct logical_volume *lv,
log_print_unless_silent("If that leaves the logical volume larger than %llu extents due to stripe rounding,",
(unsigned long long) extend_le_count);
log_print_unless_silent("you may want to grow the content afterwards (filesystem etc.)");
log_warn("WARNING: too remove freed stripes after the conversion has finished, you have to run \"lvconvert --stripes %u %s\"",
log_warn("WARNING: to remove freed stripes after the conversion has finished, you have to run \"lvconvert --stripes %u %s\"",
new_stripes, display_lvname(lv));
if (!force) {
@@ -1927,7 +1932,7 @@ static int _raid_reshape_remove_images(struct logical_volume *lv,
* -> remove the freed up images and reduce LV size
*
*/
if (!_get_available_removed_sublvs(lv, &available_slvs, &removed_slvs))
if (!_get_available_removed_sublvs(lv, &available_slvs, &removed_slvs))
return_0;
if (devs_in_sync != new_image_count) {
@@ -1971,6 +1976,7 @@ static int _raid_reshape_remove_images(struct logical_volume *lv,
* Reshape: keep images in RAID @lv but change stripe size or data copies
*
*/
static const char *_get_segtype_alias(const struct segment_type *segtype);
static int _raid_reshape_keep_images(struct logical_volume *lv,
const struct segment_type *new_segtype,
int yes, int force, int *force_repair,
@@ -1984,14 +1990,12 @@ 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;
}
seg->stripe_size = new_stripe_size;
/*
* Reshape layout alogorithm or chunksize:
*
@@ -2005,8 +2009,22 @@ static int _raid_reshape_keep_images(struct logical_volume *lv,
* The dm-raid target is able to use the space whereever it
* is found by appropriately selecting forward or backward reshape.
*/
if (seg->area_count != 2 &&
alloc_reshape_space &&
if (seg->segtype != new_segtype) {
const char *alias = _get_segtype_alias(seg->segtype);
if (!strcmp(alias, new_segtype->name))
alloc_reshape_space = 0;
}
if (seg->stripe_size != new_stripe_size)
alloc_reshape_space = 1;
seg->stripe_size = new_stripe_size;
if (seg->area_count == 2)
alloc_reshape_space = 0;
if (alloc_reshape_space &&
!_lv_alloc_reshape_space(lv, where, NULL, allocate_pvs))
return 0;
@@ -2081,7 +2099,7 @@ static int _activate_sub_lvs_excl_local(struct logical_volume *lv, uint32_t star
display_lvname(lv));
for (s = start_idx; s < seg->area_count; s++)
if (!_activate_sub_lv_excl_local(seg_lv(seg, s)) ||
!_activate_sub_lv_excl_local(seg_metalv(seg, s)))
(seg->meta_areas && !_activate_sub_lv_excl_local(seg_metalv(seg, s))))
return 0;
return 1;
@@ -2371,7 +2389,7 @@ static int _reshape_requested(const struct logical_volume *lv, const struct segm
if (seg_is_any_raid10(seg) && seg->area_count > 2 &&
stripes && stripes < seg->area_count - seg->segtype->parity_devs) {
log_error("Can't remove stripes from raid10");
goto err;
return 2;
}
if (data_copies != seg->data_copies) {
@@ -2382,22 +2400,20 @@ static int _reshape_requested(const struct logical_volume *lv, const struct segm
/* Change layout (e.g. raid5_ls -> raid5_ra) keeping # of stripes */
if (seg->segtype != segtype) {
if (stripes && stripes != _data_rimages_count(seg, seg->area_count))
goto err;
return 2;
return 1;
}
if (stripes && stripes == _data_rimages_count(seg, seg->area_count) &&
stripe_size == seg->stripe_size) {
stripe_size == seg->stripe_size &&
region_size == seg->region_size) {
log_error("LV %s already has %u stripes.",
display_lvname(lv), stripes);
return 2;
}
return (stripes || stripe_size) ? 1 : 0;
err:
return 2;
}
/*
@@ -2912,9 +2928,11 @@ static int _raid_remove_images(struct logical_volume *lv, int yes,
return 0;
}
first_seg(lv)->area_count = new_count;
/* Convert to linear? */
if (new_count == 1) {
if (!yes && yes_no_prompt("Are you sure you want to convert %s LV %s to type %s loosing all resilience? [y/n]: ",
if (!yes && yes_no_prompt("Are you sure you want to convert %s LV %s to type %s losing all resilience? [y/n]: ",
lvseg_name(first_seg(lv)), display_lvname(lv), SEG_TYPE_NAME_LINEAR) == 'n') {
log_error("Logical volume %s NOT converted to \"%s\".",
display_lvname(lv), SEG_TYPE_NAME_LINEAR);
@@ -2938,13 +2956,11 @@ static int _raid_remove_images(struct logical_volume *lv, int yes,
/*
* Eliminate the extracted LVs
*/
if (!dm_list_empty(removal_lvs)) {
if (!_deactivate_and_remove_lvs(lv->vg, removal_lvs))
return_0;
if (!_deactivate_and_remove_lvs(lv->vg, removal_lvs))
return_0;
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
}
if (!lv_update_and_reload_origin(lv))
return_0;
backup(lv->vg);
@@ -2994,7 +3010,15 @@ int lv_raid_change_image_count(struct logical_volume *lv, int yes, uint32_t new_
const uint32_t new_region_size, struct dm_list *allocate_pvs)
{
struct lv_segment *seg = first_seg(lv);
const char *level = seg->area_count == 1 ? "raid1 with " : "";
const char *resil = new_count < seg->area_count ? "reducing" : "enhancing";
if (new_count != 1 && /* Already prompted for in _raid_remove_images() */
!yes && yes_no_prompt("Are you sure you want to convert %s LV %s to %s%u images %s resilience? [y/n]: ",
lvseg_name(first_seg(lv)), display_lvname(lv), level, new_count, resil) == 'n') {
log_error("Logical volume %s NOT converted.", display_lvname(lv));
return 0;
}
if (new_region_size) {
seg->region_size = new_region_size;
_check_and_adjust_region_size(lv);
@@ -3048,9 +3072,9 @@ int lv_raid_split(struct logical_volume *lv, int yes, const char *split_name,
return 0;
}
/* Split on a 2-legged raid1 LV causes loosing all resilience */
/* Split on a 2-legged raid1 LV causes losing all resilience */
if (new_count == 1 &&
!yes && yes_no_prompt("Are you sure you want to split %s LV %s loosing all resilience? [y/n]: ",
!yes && yes_no_prompt("Are you sure you want to split %s LV %s losing all resilience? [y/n]: ",
lvseg_name(first_seg(lv)), display_lvname(lv)) == 'n') {
log_error("Logical volume %s NOT split.", display_lvname(lv));
return 0;
@@ -3090,8 +3114,7 @@ int lv_raid_split(struct logical_volume *lv, int yes, const char *split_name,
}
/* Get first item */
dm_list_iterate_items(lvl, &data_list)
break;
lvl = (struct lv_list *) dm_list_first(&data_list);
lvl->lv->name = split_name;
@@ -3191,9 +3214,9 @@ int lv_raid_split_and_track(struct logical_volume *lv,
return 0;
}
/* Split and track changes on a 2-legged raid1 LV causes loosing resilience for newly written data. */
/* Split and track changes on a 2-legged raid1 LV causes losing resilience for newly written data. */
if (seg->area_count == 2 &&
!yes && yes_no_prompt("Are you sure you want to split and track %s LV %s loosing resilience for any newly written data? [y/n]: ",
!yes && yes_no_prompt("Are you sure you want to split and track %s LV %s losing resilience for any newly written data? [y/n]: ",
lvseg_name(seg), display_lvname(lv)) == 'n') {
log_error("Logical volume %s NOT split.", display_lvname(lv));
return 0;
@@ -4399,6 +4422,12 @@ static const char *_get_segtype_alias(const struct segment_type *segtype)
if (!strcmp(segtype->name, SEG_TYPE_NAME_RAID6_ZR))
return SEG_TYPE_NAME_RAID6;
if (!strcmp(segtype->name, SEG_TYPE_NAME_RAID10))
return SEG_TYPE_NAME_RAID10_NEAR;
if (!strcmp(segtype->name, SEG_TYPE_NAME_RAID10_NEAR))
return SEG_TYPE_NAME_RAID10;
return "";
}
@@ -4565,7 +4594,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);
@@ -4598,7 +4627,7 @@ static int _clear_meta_lvs(struct logical_volume *lv)
struct lv_segment_area *tmp_areas;
const struct segment_type *tmp_segtype;
struct dm_list meta_lvs;
struct lv_list *lvl_array, *lvl;
struct lv_list *lvl;
int is_raid45n10 = seg_is_raid4(seg) || seg_is_raid5_n(seg) || seg_is_raid10(seg);
/* Reject non-raid0_meta/raid4/raid5_n segment types cautiously */
@@ -4606,9 +4635,6 @@ static int _clear_meta_lvs(struct logical_volume *lv)
(!seg_is_raid0_meta(seg) && !is_raid45n10))
return_0;
if (!(lvl_array = dm_pool_alloc(lv->vg->vgmem, seg->area_count * sizeof(*lvl_array))))
return_0;
dm_list_init(&meta_lvs);
tmp_segtype = seg->segtype;
tmp_areas = seg->meta_areas;
@@ -4879,13 +4905,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;
@@ -5004,6 +5023,7 @@ static int _takeover_upconvert_wrapper(TAKEOVER_FN_ARGS)
{
uint32_t extents_copied, region_size, seg_len, stripe_size;
struct lv_segment *seg = first_seg(lv);
const struct segment_type *initial_segtype = seg->segtype;
struct dm_list removal_lvs;
dm_list_init(&removal_lvs);
@@ -5081,7 +5101,7 @@ static int _takeover_upconvert_wrapper(TAKEOVER_FN_ARGS)
/* Add metadata LVs */
if (seg_is_raid0(seg)) {
log_debug_metadata("Adding metadata LVs to %s.", display_lvname(lv));
if (!_raid0_add_or_remove_metadata_lvs(lv, 1 /* update_and_reload */, allocate_pvs, NULL))
if (!_raid0_add_or_remove_metadata_lvs(lv, 0 /* update_and_reload */, allocate_pvs, NULL))
return 0;
/* raid0_meta -> raid4 needs clearing of MetaLVs in order to avoid raid disk role change issues in the kernel */
}
@@ -5091,7 +5111,6 @@ static int _takeover_upconvert_wrapper(TAKEOVER_FN_ARGS)
!_clear_meta_lvs(lv))
return_0;
extents_copied = seg->extents_copied;
seg_len = seg->len;
stripe_size = seg->stripe_size;
@@ -5110,8 +5129,28 @@ static int _takeover_upconvert_wrapper(TAKEOVER_FN_ARGS)
log_debug_metadata("Adding %" PRIu32 " component LV pair(s) to %s.",
new_image_count - lv_raid_image_count(lv),
display_lvname(lv));
if (!_lv_raid_change_image_count(lv, 1, new_image_count, allocate_pvs, NULL, 0, 1))
if (!_lv_raid_change_image_count(lv, 1, new_image_count, allocate_pvs, NULL, 0, 1)) {
/*
* Rollback to initial type raid0/striped after failure to upconvert
* to raid4/5/6/10 elminating any newly allocated metadata devices
* (raid4/5 -> raid6 doesn't need any explicit changes after
* the allocation of the additional sub LV pair failed)
*
* - initial type is raid0 -> just remove remove metadata devices
*
* - initial type is striped -> convert back to it (removes metadata devices)
*/
if (segtype_is_raid0(initial_segtype) &&
!_raid0_add_or_remove_metadata_lvs(lv, 0, NULL, &removal_lvs))
return_0;
if (segtype_is_striped_target(initial_segtype) &&
!_convert_raid0_to_striped(lv, 0, &removal_lvs))
return_0;
if (!_eliminate_extracted_lvs(lv->vg, &removal_lvs)) /* Updates vg */
return_0;
return 0;
}
seg = first_seg(lv);
}
@@ -5158,7 +5197,8 @@ static int _takeover_upconvert_wrapper(TAKEOVER_FN_ARGS)
_pre_raid_add_legs, NULL))
return 0;
if (segtype_is_raid4(new_segtype)) {
if (segtype_is_raid4(new_segtype) &&
seg->area_count != 2) {
/* We had to rename SubLVs because of collision free shifting, rename back... */
if (!_rename_area_lvs(lv, NULL))
return_0;
@@ -5353,7 +5393,7 @@ static int _takeover_from_raid1_to_raid0_meta(TAKEOVER_FN_ARGS)
static int _takeover_from_raid1_to_raid1(TAKEOVER_FN_ARGS)
{
return _takeover_unsupported_yet(lv, new_stripes, new_segtype);
return _takeover_unsupported(lv, new_segtype, 0, 0, 0, 0, new_stripes, 0, 0, NULL);
}
static int _takeover_from_raid1_to_raid10(TAKEOVER_FN_ARGS)
@@ -5725,15 +5765,9 @@ static int _set_convenient_raid1456_segtype_to(const struct lv_segment *seg_from
replaced:
if (!(*segtype = get_segtype_from_flag(cmd, seg_flag)))
return_0;
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]: ",
segtype_sav->name, display_lvname(seg_from->lv),
(*segtype)->name) == 'n') {
log_error("Logical volume %s NOT converted.", display_lvname(seg_from->lv));
return 0;
}
if (segtype_sav != *segtype)
log_warn("Replaced LV type %s with possible type %s.",
segtype_sav->name, (*segtype)->name);
return 1;
}
@@ -5845,6 +5879,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;
}
@@ -5894,7 +5937,7 @@ int lv_raid_convert(struct logical_volume *lv,
struct lv_segment *seg = first_seg(lv);
uint32_t stripes = new_stripes, stripe_size;
uint32_t new_image_count = seg->area_count;
uint32_t region_size = new_region_size;
uint32_t region_size;
uint32_t data_copies = seg->data_copies;
uint32_t available_slvs, removed_slvs;
takeover_fn_t takeover_fn;
@@ -5973,7 +6016,29 @@ int lv_raid_convert(struct logical_volume *lv,
/* Exit without doing activation checks if the combination isn't possible */
if (_takeover_not_possible(takeover_fn))
return takeover_fn(lv, new_segtype, yes, force, new_image_count, 0, new_stripes, stripe_size,
region_size, allocate_pvs);
region_size, allocate_pvs);
/*
* User requested "--type raid*" without neither
* requesting a reshape nor a takeover.
*
* I.e. the raid level is the same but no layout,
* stripesize or number of stripes change is required.
*
* Check if a regionsize change is required.
*/
if (seg->segtype == new_segtype && new_region_size) {
if (seg->region_size != new_region_size) {
log_verbose("Converting %s LV %s to regionsize %s.",
lvseg_name(first_seg(lv)), display_lvname(lv),
display_size(lv->vg->cmd, new_region_size));
return _region_size_change_requested(lv, yes, new_region_size);
} else {
log_error("Can't convert %s LV %s without a region size change.",
lvseg_name(seg), display_lvname(lv));
return 0;
}
}
log_verbose("Converting %s from %s to %s.",
display_lvname(lv), lvseg_name(first_seg(lv)),

View File

@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2016 Red Hat, Inc. All rights reserved.
* Copyright (C) 2004-2017 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -89,6 +89,7 @@ struct dev_manager;
#define SEG_TYPE_NAME_RAID0_META "raid0_meta"
#define SEG_TYPE_NAME_RAID1 "raid1"
#define SEG_TYPE_NAME_RAID10 "raid10"
#define SEG_TYPE_NAME_RAID10_NEAR "raid10_near"
#define SEG_TYPE_NAME_RAID4 "raid4"
#define SEG_TYPE_NAME_RAID5 "raid5"
#define SEG_TYPE_NAME_RAID5_N "raid5_n"
@@ -137,11 +138,12 @@ struct dev_manager;
#define segtype_is_raid6_rs_6(segtype) ((segtype)->flags & SEG_RAID6_RS_6 ? 1 : 0)
#define segtype_is_raid6_la_6(segtype) ((segtype)->flags & SEG_RAID6_LA_6 ? 1 : 0)
#define segtype_is_raid6_ra_6(segtype) ((segtype)->flags & SEG_RAID6_RA_6 ? 1 : 0)
#define segtype_is_any_raid10(segtype) ((segtype)->flags & SEG_RAID10 ? 1 : 0)
#define segtype_is_raid10(segtype) ((segtype)->flags & SEG_RAID10 ? 1 : 0)
#define segtype_is_raid10_near(segtype) segtype_is_raid10(segtype)
/* FIXME: once raid10_offset supported */
#define segtype_is_raid10_near(segtype) ((segtype)->flags & SEG_RAID10_NEAR ? 1 : 0)
/* FIXME: once raid10_{far,offset} supported */
#define segtype_is_raid10_far(segtype) 0 /* FIXME ((segtype)->flags & SEG_RAID10_FAR ? 1 : 0 */
#define segtype_is_raid10_offset(segtype) 0 /* FIXME ((segtype)->flags & SEG_RAID10_OFFSET ? 1 : 0 */
#define segtype_is_any_raid10(segtype) (segtype_is_raid10(segtype) || segtype_is_raid10_near(segtype) || segtype_is_raid10_far(segtype) || segtype_is_raid10_offset(segtype))
#define segtype_is_raid_with_meta(segtype) (segtype_is_raid(segtype) && !segtype_is_raid0(segtype))
#define segtype_is_striped_raid(segtype) (segtype_is_raid(segtype) && !segtype_is_raid1(segtype))
#define segtype_is_reshapable_raid(segtype) ((segtype_is_striped_raid(segtype) && !segtype_is_any_raid0(segtype)) || segtype_is_raid10_near(segtype) || segtype_is_raid10_offset(segtype))

View File

@@ -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");

View File

@@ -599,6 +599,7 @@ static const struct raid_type {
{ SEG_TYPE_NAME_RAID0_META, 0, SEG_RAID0_META | SEG_AREAS_STRIPED },
{ SEG_TYPE_NAME_RAID1, 0, SEG_RAID1 | SEG_AREAS_MIRRORED },
{ SEG_TYPE_NAME_RAID10, 0, SEG_RAID10 | SEG_AREAS_MIRRORED },
{ SEG_TYPE_NAME_RAID10_NEAR,0, SEG_RAID10_NEAR | SEG_AREAS_MIRRORED },
{ SEG_TYPE_NAME_RAID4, 1, SEG_RAID4 },
{ SEG_TYPE_NAME_RAID5, 1, SEG_RAID5 },
{ SEG_TYPE_NAME_RAID5_N, 1, SEG_RAID5_N },

View File

@@ -108,6 +108,7 @@ static const struct {
*/
{ SEG_RAID5_LS, "raid5"}, /* same as "raid5_ls" (default for MD also) */
{ SEG_RAID6_ZR, "raid6"}, /* same as "raid6_zr" */
{ SEG_RAID10, "raid10_near"}, /* same as "raid10" */
};
/* Some segment types have a list of areas of other devices attached */

View File

@@ -4181,21 +4181,23 @@ int dm_stats_get_group_descriptor(const struct dm_stats *dms,
* Resize the group bitmap corresponding to group_id so that it can
* contain at least num_regions members.
*/
static int _stats_resize_group(struct dm_stats_group *group, int num_regions)
static int _stats_resize_group(struct dm_stats_group *group,
uint64_t num_regions)
{
int last_bit = dm_bit_get_last(group->regions);
uint64_t last_bit = dm_bit_get_last(group->regions);
dm_bitset_t new, old;
if (last_bit >= num_regions) {
log_error("Cannot resize group bitmap to %d with bit %d set.",
num_regions, last_bit);
log_error("Cannot resize group bitmap to " FMTu64
" with bit " FMTu64 " set.", num_regions, last_bit);
return 0;
}
log_very_verbose("Resizing group bitmap from %d to %d (last_bit: %d).",
group->regions[0], num_regions, last_bit);
log_very_verbose("Resizing group bitmap from " FMTu32 " to " FMTu64
" (last_bit: " FMTu64 ").", group->regions[0],
num_regions, last_bit);
new = dm_bitset_create(NULL, num_regions);
new = dm_bitset_create(NULL, (unsigned) num_regions);
if (!new) {
log_error("Could not allocate memory for new group bitmap.");
return 0;
@@ -4217,7 +4219,7 @@ static int _stats_group_file_regions(struct dm_stats *dms, uint64_t *region_ids,
dm_bitset_t regions = dm_bitset_create(NULL, dms->nr_regions);
uint64_t i, group_id = DM_STATS_GROUP_NOT_PRESENT;
char *members = NULL;
int buflen;
size_t buflen;
if (!regions) {
log_error("Cannot map file: failed to allocate group bitmap.");
@@ -4401,10 +4403,14 @@ static struct _extent *_stats_get_extents_for_file(struct dm_pool *mem, int fd,
unsigned long flags = 0;
uint64_t *buf;
/* grow temporary extent table in the pool */
if (!dm_pool_begin_object(mem, sizeof(*extents)))
return NULL;
buf = dm_zalloc(STATS_FIE_BUF_LEN);
if (!buf) {
log_error("Could not allocate memory for FIEMAP buffer.");
return NULL;
goto bad;
}
/* initialise pointers into the ioctl buffer. */
@@ -4415,10 +4421,6 @@ static struct _extent *_stats_get_extents_for_file(struct dm_pool *mem, int fd,
*count = (STATS_FIE_BUF_LEN - sizeof(*fiemap))
/ sizeof(struct fiemap_extent);
/* grow temporary extent table in the pool */
if (!dm_pool_begin_object(mem, sizeof(*extents)))
return NULL;
flags = FIEMAP_FLAG_SYNC;
do {
@@ -4472,7 +4474,7 @@ bad:
#define MATCH_EXTENT(e, s, l) \
(((e).start == (s)) && ((e).len == (l)))
static struct _extent *_find_extent(size_t nr_extents, struct _extent *extents,
static struct _extent *_find_extent(uint64_t nr_extents, struct _extent *extents,
uint64_t start, uint64_t len)
{
size_t i;
@@ -4509,8 +4511,9 @@ static int _stats_unmap_regions(struct dm_stats *dms, uint64_t group_id,
{
struct dm_stats_region *region = NULL;
struct dm_stats_group *group = NULL;
int64_t nr_kept, nr_old, i;
uint64_t nr_kept, nr_old;
struct _extent ext;
int64_t i;
group = &dms->groups[group_id];
@@ -4540,8 +4543,9 @@ static int _stats_unmap_regions(struct dm_stats *dms, uint64_t group_id,
ext.id = i;
nr_kept++;
dm_pool_grow_object(mem, &ext,
sizeof(ext));
if (!dm_pool_grow_object(mem, &ext, sizeof(ext)))
goto out;
log_very_verbose("Kept region " FMTu64, i);
} else {
@@ -4568,7 +4572,7 @@ static int _stats_unmap_regions(struct dm_stats *dms, uint64_t group_id,
log_very_verbose("Found " FMTu64 " new extents",
*count - nr_kept);
return nr_kept;
return (int) nr_kept;
out:
dm_pool_abandon_object(mem);
return -1;
@@ -4591,15 +4595,15 @@ static uint64_t *_stats_map_file_regions(struct dm_stats *dms, int fd,
uint64_t *count, int *regroup)
{
struct _extent *extents = NULL, *old_extents = NULL;
uint64_t *regions = NULL, fail_region;
uint64_t *regions = NULL, fail_region, i, num_bits;
struct dm_stats_group *group = NULL;
struct dm_pool *extent_mem = NULL;
struct _extent *old_ext;
char *hist_arg = NULL;
int update, num_bits;
struct statfs fsbuf;
int64_t nr_kept = 0, i;
int64_t nr_kept = 0;
struct stat buf;
int update;
update = _stats_group_id_present(dms, group_id);
@@ -4684,9 +4688,10 @@ static uint64_t *_stats_map_file_regions(struct dm_stats *dms, int fd,
*/
for (i = 0; i < *count; i++) {
if (update) {
if ((old_ext = _find_extent(nr_kept, old_extents,
extents[i].start,
extents[i].len))) {
if ((old_ext = _find_extent((uint64_t) nr_kept,
old_extents,
extents[i].start,
extents[i].len))) {
regions[i] = old_ext->id;
continue;
}
@@ -4742,7 +4747,8 @@ out_remove:
* single list operation and call _stats_delete_region() directly
* to avoid a @stats_list ioctl and list parsing for each region.
*/
dm_stats_list(dms, NULL);
if (!dm_stats_list(dms, NULL))
goto out;
fail_region = i;
_stats_cleanup_region_ids(dms, regions, fail_region);
@@ -4775,7 +4781,8 @@ uint64_t *dm_stats_create_regions_from_fd(struct dm_stats *dms, int fd,
}
if (!(regions = _stats_map_file_regions(dms, fd, bounds, precise,
-1, &count, &regroup)))
DM_STATS_GROUP_NOT_PRESENT,
&count, &regroup)))
return NULL;
if (!group)
@@ -5030,7 +5037,7 @@ int dm_stats_start_filemapd(int fd, uint64_t group_id, const char *path,
}
execvp(args[0], args);
log_error("execvp() failed.");
log_sys_error("execvp", args[0]);
if (!foreground)
_exit(127);
return 0;

View File

@@ -32,8 +32,8 @@ LVMRAIDMAN = lvmraid.7
MAN5=lvm.conf.5
MAN7=lvmsystemid.7 lvmreport.7
MAN8=lvm.8 lvmconf.8 lvmdump.8 lvm-config.8 lvm-dumpconfig.8 lvm-fullreport.8 \
lvm-lvpoll.8 lvcreate.8 lvchange.8 lvmconfig.8 lvconvert.8 lvdisplay.8 \
MAN8=lvm.8 lvmconf.8 lvmdump.8 lvm-fullreport.8 lvm-lvpoll.8 \
lvcreate.8 lvchange.8 lvmconfig.8 lvconvert.8 lvdisplay.8 \
lvextend.8 lvreduce.8 lvremove.8 lvrename.8 lvresize.8 lvs.8 \
lvscan.8 pvchange.8 pvck.8 pvcreate.8 pvdisplay.8 pvmove.8 pvremove.8 \
pvresize.8 pvs.8 pvscan.8 vgcfgbackup.8 vgcfgrestore.8 vgchange.8 \
@@ -41,6 +41,7 @@ MAN8=lvm.8 lvmconf.8 lvmdump.8 lvm-config.8 lvm-dumpconfig.8 lvm-fullreport.8 \
vgimport.8 vgimportclone.8 vgmerge.8 vgmknodes.8 vgreduce.8 vgremove.8 \
vgrename.8 vgs.8 vgscan.8 vgsplit.8 \
lvmsar.8 lvmsadc.8 lvmdiskscan.8
MAN8SO=lvm-config.8 lvm-dumpconfig.8
MAN8DM=dmsetup.8 dmstats.8
MAN8CLUSTER=
MAN8SYSTEMD_GENERATORS=lvm2-activation-generator.8
@@ -122,7 +123,7 @@ TESTMAN=test.gen
include $(top_builddir)/make.tmpl
CLEAN_TARGETS+=$(MAN5) $(MAN7) $(MAN8) $(MAN8:%.8=%.8_gen) $(MAN8CLUSTER) \
CLEAN_TARGETS+=$(MAN5) $(MAN7) $(MAN8) $(MAN8SO) $(MAN8:%.8=%.8_gen) $(MAN8CLUSTER) \
$(MAN8SYSTEMD_GENERATORS) $(MAN8DM) $(TESTMAN)
DISTCLEAN_TARGETS+=$(FSADMMAN) $(BLKDEACTIVATEMAN) $(DMEVENTDMAN) \
$(LVMETADMAN) $(LVMPOLLDMAN) $(LVMLOCKDMAN) $(CLVMDMAN) $(CMIRRORDMAN) \
@@ -135,11 +136,11 @@ all: man device-mapper
device-mapper: $(MAN8DM)
man: $(MAN5) $(MAN7) $(MAN8) $(MAN8CLUSTER) $(MAN8SYSTEMD_GENERATORS)
man: $(MAN5) $(MAN7) $(MAN8) $(MAN8SO) $(MAN8CLUSTER) $(MAN8SYSTEMD_GENERATORS)
all_man: man
$(MAN5) $(MAN7) $(MAN8) $(MAN8DM) $(MAN8CLUSTER) $(MAN8SYSTEMD_GENERATORS): Makefile
$(MAN5) $(MAN7) $(MAN8) $(MAN8SO) $(MAN8DM) $(MAN8CLUSTER) $(MAN8SYSTEMD_GENERATORS): Makefile
# Test whether or not the man page generator works
$(TESTMAN): $(MANGENERATOR) Makefile
@@ -170,30 +171,56 @@ SEE_ALSO=$(srcdir)/see_also.end
) > $@
define SUBSTVARS
echo "Generating $@" ; $(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#+/data/lvmtest/usr/sbin/clvmd+;s+#LVM_PATH#+/data/lvmtest/sbin/lvm+;s+#DEFAULT_RUN_DIR#+/var/run/lvm+;s+#DEFAULT_PID_DIR#+/var/run+;s+#SYSTEMD_GENERATOR_DIR#+$(SYSTEMD_GENERATOR_DIR)+;s+#DEFAULT_MANGLING#+$(DEFAULT_MANGLING)+;" $< > $@
echo "Generating $@"
$(SED) -e "s+#VERSION#+$(LVM_VERSION)+" \
-e "s+#DEFAULT_SYS_DIR#+$(DEFAULT_SYS_DIR)+" \
-e "s+#DEFAULT_ARCHIVE_DIR#+$(DEFAULT_ARCHIVE_DIR)+" \
-e "s+#DEFAULT_BACKUP_DIR#+$(DEFAULT_BACKUP_DIR)+" \
-e "s+#DEFAULT_PROFILE_DIR#+$(DEFAULT_PROFILE_DIR)+" \
-e "s+#DEFAULT_CACHE_DIR#+$(DEFAULT_CACHE_DIR)+" \
-e "s+#DEFAULT_LOCK_DIR#+$(DEFAULT_LOCK_DIR)+" \
-e "s+#CLVMD_PATH#+/data/lvmtest/usr/sbin/clvmd+" \
-e "s+#LVM_PATH#+/data/lvmtest/sbin/lvm+" \
-e "s+#DEFAULT_RUN_DIR#+/var/run/lvm+" \
-e "s+#DEFAULT_PID_DIR#+/var/run+" \
-e "s+#SYSTEMD_GENERATOR_DIR#+$(SYSTEMD_GENERATOR_DIR)+" \
-e "s+#DEFAULT_MANGLING#+$(DEFAULT_MANGLING)+" $< > $@
endef
# Escape any '-':
#
# - multiple (>= 2)
# - in ' -'
# - in (cache|thin)-*
# - in numerical ranges
# - in ranges
# - in middle of options (e.g. '--use-policies') and their arguments
# - in symbolic use (e.g. '->')
# - in "$vg-$lv"
# - in single one in '\\f.-'
define ESCAPEHYPHENS
sed -i -e "s+\([^\\]\)-\{7\}+\1\\\-\\\-\\\-\\\-\\\-\\\-\\\-+g" \
-e "s+\([^\\]\)-\{6\}+\1\\\-\\\-\\\-\\\-\\\-\\\-+g" \
-e "s+\([^\\]\)-\{5\}+\1\\\-\\\-\\\-\\\-\\\-+g" \
-e "s+\([^\\]\)-\{4\}+\1\\\-\\\-\\\-\\\-+g" \
-e "s+\([^\\]\)-\{3\}+\1\\\-\\\-\\\-+g" \
-e "s+\([^\\]\)-\{2\}+\1\\\-\\\-+g" \
-e "s+^-\{2\}+\\\-\\\-+g" \
-e "s+ -+ \\\-+g" \
-e "s+\(cache\)-\([[:alpha:]]\{1,\}\)+\1\\\-\2+g" \
-e "s+\(thin\)-\([[:alpha:]]\{1,\}\)+\1\\\-\2+g" \
-e "s+\([0-9]\)-\([0-9]\)+\1\\\-\2+g" \
-e "s+\(\\\f.\)-\([^-]\)+\1\\\-\2+g" \
-e "s+\([[:digit:]]\{4\}\)\\\-\([[:digit:]]\{2\}\)\\\-\([[:digit:]]\{2\}\)+\1-\2-\3+g" $@
$(SED) -i -e "s+\([ [:alpha:]]\)-\{7\}+\1\\\-\\\-\\\-\\\-\\\-\\\-\\\-+g" \
-e "s+\([ [:alpha:]]\)-\{6\}+\1\\\-\\\-\\\-\\\-\\\-\\\-+g" \
-e "s+\([ [:alpha:]]\)-\{5\}+\1\\\-\\\-\\\-\\\-\\\-+g" \
-e "s+\([ [:alpha:]]\)-\{4\}+\1\\\-\\\-\\\-\\\-+g" \
-e "s+\([ [:alpha:]]\)-\{3\}+\1\\\-\\\-\\\-+g" \
-e "s+\([ [:alpha:]]\)-\{2\}+\1\\\-\\\-+g" \
-e "s+\([^\]\)-\([[:alnum:]\?]\)+\1\\\-\2+g" \
-e "s+ --+\\\-\\\-+g" \
-e "s+|-|+|\\\-|+g" \
-e "s+|-\\\-+\\\-\\\-+g" \
-e "s+ -\"+ \\\-\"+g" \
-e "s+'--'+'\\\-\\\-'+g" \
-e "s+^--+\\\-\\\-+g" \
-e "s+\([[:alnum:]]\) - \([[:alnum:]]\)+\1 \\\- \2+g" \
-e "s+\(<\)-+\1\\\-+g" \
-e "s+[^\\]-\(>\)+\\\-\1+g" \
-e "s+\([[:alnum:]]\{2,\}\)\\\-\([[:alnum:]]\{2,\}\)+\1-\2+g" \
-e "s+\(\\\-\\\-[[:alnum:]]\{2,\}\)-+\1\\\-+g" \
-e "s+\(lvm2\-activation\)+lvm2\\\-activation+" \
-e "s+\([^\\]\)-pool+\1\\\-pool+g" \
-e "s+\([[:digit:]]\)-\([[:digit:]]\)+\1\\\-\2+g" \
-e "s+\\\-git+\-git+g" \
-e "s+\(vg.*\)\-lv+\1\\\-lv+g" \
-e "s+\([[:digit:]]\{4\}\)\\\-\([[:digit:]]\{2\}\)\\\-\([[:digit:]]\{2\}\)+\1-\2-\3+g" $@
endef
%.5: $(srcdir)/%.5_main
@@ -212,6 +239,9 @@ endef
$(SUBSTVARS)
$(ESCAPEHYPHENS)
$(MAN8SO): lvmconfig.8
echo ".so $<" > $@
install_man5: $(MAN5)
$(INSTALL) -d $(MAN5DIR)
$(INSTALL_DATA) $(MAN5) $(MAN5DIR)/
@@ -220,9 +250,9 @@ install_man7: $(MAN7)
$(INSTALL) -d $(MAN7DIR)
$(INSTALL_DATA) $(MAN7) $(MAN7DIR)/
install_man8: $(MAN8) $(MAN8GENERATED)
install_man8: $(MAN8) $(MAN8SO)
$(INSTALL) -d $(MAN8DIR)
$(INSTALL_DATA) $(MAN8) $(MAN8GENERATED) $(MAN8DIR)/
$(INSTALL_DATA) $(MAN8) $(MAN8SO) $(MAN8DIR)/
install_lvm2: install_man5 install_man7 install_man8

View File

@@ -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.

View File

@@ -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.

View File

@@ -1,5 +0,0 @@
This command is the same as \fBlvmconfig\fP(8).
lvm config produces formatted output from the LVM configuration tree. The
sources of the configuration data include \fBlvm.conf\fP(5) and command
line settings from --config.

View File

View File

@@ -1,471 +0,0 @@
.TH LVM CONFIG 8 "LVM TOOLS #VERSION#" "Red Hat, Inc."
.SH NAME
lvm config - Display and manipulate configuration information
.
.SH SYNOPSIS
\fBlvm config\fP
.br
[ \fIoption_args\fP ]
.br
[ \fIposition_args\fP ]
.br
.SH DESCRIPTION
This command is the same as \fBlvmconfig\fP(8).
lvm config produces formatted output from the LVM configuration tree. The
sources of the configuration data include \fBlvm.conf\fP(5) and command
line settings from --config.
.SH USAGE
\fBlvm config\fP
.br
.RS 4
.ad l
[ \fB-f\fP|\fB--file\fP \fIString\fP ]
.ad b
.br
.ad l
[ \fB-l\fP|\fB--list\fP ]
.ad b
.br
.ad l
[ \fB--atversion\fP \fIString\fP ]
.ad b
.br
.ad l
[ \fB--typeconfig\fP \fBcurrent\fP|\fBdefault\fP|\fBdiff\fP|\fBfull\fP|\fBlist\fP|\fBmissing\fP|\fBnew\fP|\fBprofilable\fP|\fBprofilable-command\fP|\fBprofilable-metadata\fP ]
.ad b
.br
.ad l
[ \fB--ignoreadvanced\fP ]
.ad b
.br
.ad l
[ \fB--ignoreunsupported\fP ]
.ad b
.br
.ad l
[ \fB--ignorelocal\fP ]
.ad b
.br
.ad l
[ \fB--mergedconfig\fP ]
.ad b
.br
.ad l
[ \fB--metadataprofile\fP \fIString\fP ]
.ad b
.br
.ad l
[ \fB--sinceversion\fP \fIString\fP ]
.ad b
.br
.ad l
[ \fB--showdeprecated\fP ]
.ad b
.br
.ad l
[ \fB--showunsupported\fP ]
.ad b
.br
.ad l
[ \fB--validate\fP ]
.ad b
.br
.ad l
[ \fB--withsummary\fP ]
.ad b
.br
.ad l
[ \fB--withcomments\fP ]
.ad b
.br
.ad l
[ \fB--withspaces\fP ]
.ad b
.br
.ad l
[ \fB--unconfigured\fP ]
.ad b
.br
.ad l
[ \fB--withversions\fP ]
.ad b
.br
[ COMMON_OPTIONS ]
.RE
.br
.RS 4
[ \fIString\fP ... ]
.RE
Common options for lvm:
.
.RS 4
.ad l
[ \fB-d\fP|\fB--debug\fP ]
.ad b
.br
.ad l
[ \fB-h\fP|\fB--help\fP ]
.ad b
.br
.ad l
[ \fB-q\fP|\fB--quiet\fP ]
.ad b
.br
.ad l
[ \fB-t\fP|\fB--test\fP ]
.ad b
.br
.ad l
[ \fB-v\fP|\fB--verbose\fP ]
.ad b
.br
.ad l
[ \fB-y\fP|\fB--yes\fP ]
.ad b
.br
.ad l
[ \fB--commandprofile\fP \fIString\fP ]
.ad b
.br
.ad l
[ \fB--config\fP \fIString\fP ]
.ad b
.br
.ad l
[ \fB--driverloaded\fP \fBy\fP|\fBn\fP ]
.ad b
.br
.ad l
[ \fB--longhelp\fP ]
.ad b
.br
.ad l
[ \fB--profile\fP \fIString\fP ]
.ad b
.br
.ad l
[ \fB--version\fP ]
.ad b
.RE
.SH OPTIONS
.HP
.ad l
\fB--atversion\fP \fIString\fP
.br
Specify an LVM version in x.y.z format where x is the major version,
the y is the minor version and z is the patchlevel (e.g. 2.2.106).
When configuration is displayed, the configuration settings recognized
at this LVM version will be considered only. This can be used
to display a configuration that a certain LVM version understands and
which does not contain any newer settings for which LVM would
issue a warning message when checking the configuration.
.ad b
.HP
.ad l
\fB--commandprofile\fP \fIString\fP
.br
The command profile to use for command configuration.
See \fBlvm.conf\fP(5) for more information about profiles.
.ad b
.HP
.ad l
\fB--config\fP \fIString\fP
.br
Config settings for the command. These override lvm.conf settings.
The String arg uses the same format as lvm.conf,
or may use section/field syntax.
See \fBlvm.conf\fP(5) for more information about config.
.ad b
.HP
.ad l
\fB-d\fP|\fB--debug\fP ...
.br
Set debug level. Repeat from 1 to 6 times to increase the detail of
messages sent to the log file and/or syslog (if configured).
.ad b
.HP
.ad l
\fB--driverloaded\fP \fBy\fP|\fBn\fP
.br
If set to no, the command will not attempt to use device-mapper.
For testing and debugging.
.ad b
.HP
.ad l
\fB-f\fP|\fB--file\fP \fIString\fP
.br
Write output to the named file.
.ad b
.HP
.ad l
\fB-h\fP|\fB--help\fP
.br
Display help text.
.ad b
.HP
.ad l
\fB--ignoreadvanced\fP
.br
Exclude advanced configuration settings from the output.
.ad b
.HP
.ad l
\fB--ignorelocal\fP
.br
Ignore local section.
.ad b
.HP
.ad l
\fB--ignoreunsupported\fP
.br
Exclude unsupported configuration settings from the output. These settings are
either used for debugging and development purposes only or their support is not
yet complete and they are not meant to be used in production. The \fBcurrent\fP
and \fBdiff\fP types include unsupported settings in their output by default,
all the other types ignore unsupported settings.
.ad b
.HP
.ad l
\fB-l\fP|\fB--list\fP
.br
List config settings with summarizing comment. This is the same as using
options --typeconfig list --withsummary.
.ad b
.HP
.ad l
\fB--longhelp\fP
.br
Display long help text.
.ad b
.HP
.ad l
\fB--mergedconfig\fP
.br
When the command is run with --config
and/or --commandprofile (or using LVM_COMMAND_PROFILE
environment variable), --profile, or --metadataprofile,
merge all the contents of the "config cascade" before displaying it.
Without merging, only the configuration at the front of the
cascade is displayed.
See \fBlvm.conf\fP(5) for more information about config.
.ad b
.HP
.ad l
\fB--metadataprofile\fP \fIString\fP
.br
The metadata profile to use for command configuration.
See \fBlvm.conf\fP(5) for more information about profiles.
.ad b
.HP
.ad l
\fB--profile\fP \fIString\fP
.br
An alias for --commandprofile or --metadataprofile, depending
on the command.
.ad b
.HP
.ad l
\fB-q\fP|\fB--quiet\fP ...
.br
Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer no.
.ad b
.HP
.ad l
\fB--showdeprecated\fP
.br
Include deprecated configuration settings in the output. These settings
are deprecated after a certain version. If a concrete version is specified
with --atversion, deprecated settings are automatically included
if the specified version is lower than the version in which the settings were
deprecated. The current and diff types include deprecated settings
in their output by default, all the other types ignore deprecated settings.
.ad b
.HP
.ad l
\fB--showunsupported\fP
.br
Include unsupported configuration settings in the output. These settings
are either used for debugging or development purposes only, or their support
is not yet complete and they are not meant to be used in production. The
current and diff types include unsupported settings in their
output by default, all the other types ignore unsupported settings.
.ad b
.HP
.ad l
\fB--sinceversion\fP \fIString\fP
.br
Specify an LVM version in x.y.z format where x is the major version,
the y is the minor version and z is the patchlevel (e.g. 2.2.106).
This option is currently applicable only with --typeconfig new
to display all configuration settings introduced since given version.
.ad b
.HP
.ad l
\fB-t\fP|\fB--test\fP
.br
Run in test mode. Commands will not update metadata.
This is implemented by disabling all metadata writing but nevertheless
returning success to the calling function. This may lead to unusual
error messages in multi-stage operations if a tool relies on reading
back metadata it believes has changed but hasn't.
.ad b
.HP
.ad l
\fB--typeconfig\fP \fBcurrent\fP|\fBdefault\fP|\fBdiff\fP|\fBfull\fP|\fBlist\fP|\fBmissing\fP|\fBnew\fP|\fBprofilable\fP|\fBprofilable-command\fP|\fBprofilable-metadata\fP
.br
See lvmreport(7).
.ad b
.HP
.ad l
\fB--unconfigured\fP
.br
Internal option used for generating config file during build.
.ad b
.HP
.ad l
\fB--validate\fP
.br
Validate current configuration used and exit with appropriate
return code. The validation is done only for the configuration
at the front of the "config cascade". To validate the whole
merged configuration tree, also use --mergedconfig.
The validation is done even if lvm.conf config/checks is disabled.
.ad b
.HP
.ad l
\fB-v\fP|\fB--verbose\fP ...
.br
Set verbose level. Repeat from 1 to 4 times to increase the detail
of messages sent to stdout and stderr.
.ad b
.HP
.ad l
\fB--version\fP
.br
Display version information.
.ad b
.HP
.ad l
\fB--withcomments\fP
.br
Display a full comment for each configuration node. For deprecated
settings, also display comments about deprecation.
.ad b
.HP
.ad l
\fB--withspaces\fP
.br
Where appropriate, add more spaces in output for better readability.
.ad b
.HP
.ad l
\fB--withsummary\fP
.br
Display a one line comment for each configuration node.
.ad b
.HP
.ad l
\fB--withversions\fP
.br
Also display a comment containing the version of introduction for
each configuration node. If the setting is deprecated, also display
the version since which it is deprecated.
.ad b
.HP
.ad l
\fB-y\fP|\fB--yes\fP
.br
Do not prompt for confirmation interactively but always assume the
answer yes. Use with extreme caution.
(For automatic no, see -qq.)
.ad b
.SH VARIABLES
.HP
\fIString\fP
.br
See the option description for information about the string content.
.HP
\fISize\fP[UNIT]
.br
Size is an input number that accepts an optional unit.
Input units are always treated as base two values, regardless of
capitalization, e.g. 'k' and 'K' both refer to 1024.
The default input unit is specified by letter, followed by |UNIT.
UNIT represents other possible input units: \fBbBsSkKmMgGtTpPeE\fP.
b|B is bytes, s|S is sectors of 512 bytes, k|K is kilobytes,
m|M is megabytes, g|G is gigabytes, t|T is terabytes,
p|P is petabytes, e|E is exabytes.
(This should not be confused with the output control --units, where
capital letters mean multiple of 1000.)
.SH ENVIRONMENT VARIABLES
See \fBlvm\fP(8) for information about environment variables used by lvm.
For example, LVM_VG_NAME can generally be substituted for a required VG parameter.
.SH SEE ALSO
.BR lvm (8)
.BR lvm.conf (5)
.BR lvmconfig (8)
.BR pvchange (8)
.BR pvck (8)
.BR pvcreate (8)
.BR pvdisplay (8)
.BR pvmove (8)
.BR pvremove (8)
.BR pvresize (8)
.BR pvs (8)
.BR pvscan (8)
.BR vgcfgbackup (8)
.BR vgcfgrestore (8)
.BR vgchange (8)
.BR vgck (8)
.BR vgcreate (8)
.BR vgconvert (8)
.BR vgdisplay (8)
.BR vgexport (8)
.BR vgextend (8)
.BR vgimport (8)
.BR vgimportclone (8)
.BR vgmerge (8)
.BR vgmknodes (8)
.BR vgreduce (8)
.BR vgremove (8)
.BR vgrename (8)
.BR vgs (8)
.BR vgscan (8)
.BR vgsplit (8)
.BR lvcreate (8)
.BR lvchange (8)
.BR lvconvert (8)
.BR lvdisplay (8)
.BR lvextend (8)
.BR lvreduce (8)
.BR lvremove (8)
.BR lvrename (8)
.BR lvresize (8)
.BR lvs (8)
.BR lvscan (8)
.BR lvm2-activation-generator (8)
.BR blkdeactivate (8)
.BR lvmdump (8)
.BR dmeventd (8)
.BR lvmetad (8)
.BR lvmpolld (8)
.BR lvmlockd (8)
.BR lvmlockctl (8)
.BR clvmd (8)
.BR cmirrord (8)
.BR lvmdbusd (8)
.BR lvmsystemid (7)
.BR lvmreport (7)
.BR lvmraid (7)
.BR lvmthin (7)
.BR lvmcache (7)

View File

@@ -1,5 +0,0 @@
This command is the same as \fBlvmconfig\fP(8).
lvm dumpconfig produces formatted output from the LVM configuration tree. The
sources of the configuration data include \fBlvm.conf\fP(5) and command
line settings from --config.

View File

@@ -1,471 +0,0 @@
.TH LVM DUMPCONFIG 8 "LVM TOOLS #VERSION#" "Red Hat, Inc."
.SH NAME
lvm dumpconfig - Display and manipulate configuration information
.
.SH SYNOPSIS
\fBlvm dumpconfig\fP
.br
[ \fIoption_args\fP ]
.br
[ \fIposition_args\fP ]
.br
.SH DESCRIPTION
This command is the same as \fBlvmconfig\fP(8).
lvm dumpconfig produces formatted output from the LVM configuration tree. The
sources of the configuration data include \fBlvm.conf\fP(5) and command
line settings from --config.
.SH USAGE
\fBlvm dumpconfig\fP
.br
.RS 4
.ad l
[ \fB-f\fP|\fB--file\fP \fIString\fP ]
.ad b
.br
.ad l
[ \fB-l\fP|\fB--list\fP ]
.ad b
.br
.ad l
[ \fB--atversion\fP \fIString\fP ]
.ad b
.br
.ad l
[ \fB--typeconfig\fP \fBcurrent\fP|\fBdefault\fP|\fBdiff\fP|\fBfull\fP|\fBlist\fP|\fBmissing\fP|\fBnew\fP|\fBprofilable\fP|\fBprofilable-command\fP|\fBprofilable-metadata\fP ]
.ad b
.br
.ad l
[ \fB--ignoreadvanced\fP ]
.ad b
.br
.ad l
[ \fB--ignoreunsupported\fP ]
.ad b
.br
.ad l
[ \fB--ignorelocal\fP ]
.ad b
.br
.ad l
[ \fB--mergedconfig\fP ]
.ad b
.br
.ad l
[ \fB--metadataprofile\fP \fIString\fP ]
.ad b
.br
.ad l
[ \fB--sinceversion\fP \fIString\fP ]
.ad b
.br
.ad l
[ \fB--showdeprecated\fP ]
.ad b
.br
.ad l
[ \fB--showunsupported\fP ]
.ad b
.br
.ad l
[ \fB--validate\fP ]
.ad b
.br
.ad l
[ \fB--withsummary\fP ]
.ad b
.br
.ad l
[ \fB--withcomments\fP ]
.ad b
.br
.ad l
[ \fB--withspaces\fP ]
.ad b
.br
.ad l
[ \fB--unconfigured\fP ]
.ad b
.br
.ad l
[ \fB--withversions\fP ]
.ad b
.br
[ COMMON_OPTIONS ]
.RE
.br
.RS 4
[ \fIString\fP ... ]
.RE
Common options for lvm:
.
.RS 4
.ad l
[ \fB-d\fP|\fB--debug\fP ]
.ad b
.br
.ad l
[ \fB-h\fP|\fB--help\fP ]
.ad b
.br
.ad l
[ \fB-q\fP|\fB--quiet\fP ]
.ad b
.br
.ad l
[ \fB-t\fP|\fB--test\fP ]
.ad b
.br
.ad l
[ \fB-v\fP|\fB--verbose\fP ]
.ad b
.br
.ad l
[ \fB-y\fP|\fB--yes\fP ]
.ad b
.br
.ad l
[ \fB--commandprofile\fP \fIString\fP ]
.ad b
.br
.ad l
[ \fB--config\fP \fIString\fP ]
.ad b
.br
.ad l
[ \fB--driverloaded\fP \fBy\fP|\fBn\fP ]
.ad b
.br
.ad l
[ \fB--longhelp\fP ]
.ad b
.br
.ad l
[ \fB--profile\fP \fIString\fP ]
.ad b
.br
.ad l
[ \fB--version\fP ]
.ad b
.RE
.SH OPTIONS
.HP
.ad l
\fB--atversion\fP \fIString\fP
.br
Specify an LVM version in x.y.z format where x is the major version,
the y is the minor version and z is the patchlevel (e.g. 2.2.106).
When configuration is displayed, the configuration settings recognized
at this LVM version will be considered only. This can be used
to display a configuration that a certain LVM version understands and
which does not contain any newer settings for which LVM would
issue a warning message when checking the configuration.
.ad b
.HP
.ad l
\fB--commandprofile\fP \fIString\fP
.br
The command profile to use for command configuration.
See \fBlvm.conf\fP(5) for more information about profiles.
.ad b
.HP
.ad l
\fB--config\fP \fIString\fP
.br
Config settings for the command. These override lvm.conf settings.
The String arg uses the same format as lvm.conf,
or may use section/field syntax.
See \fBlvm.conf\fP(5) for more information about config.
.ad b
.HP
.ad l
\fB-d\fP|\fB--debug\fP ...
.br
Set debug level. Repeat from 1 to 6 times to increase the detail of
messages sent to the log file and/or syslog (if configured).
.ad b
.HP
.ad l
\fB--driverloaded\fP \fBy\fP|\fBn\fP
.br
If set to no, the command will not attempt to use device-mapper.
For testing and debugging.
.ad b
.HP
.ad l
\fB-f\fP|\fB--file\fP \fIString\fP
.br
Write output to the named file.
.ad b
.HP
.ad l
\fB-h\fP|\fB--help\fP
.br
Display help text.
.ad b
.HP
.ad l
\fB--ignoreadvanced\fP
.br
Exclude advanced configuration settings from the output.
.ad b
.HP
.ad l
\fB--ignorelocal\fP
.br
Ignore local section.
.ad b
.HP
.ad l
\fB--ignoreunsupported\fP
.br
Exclude unsupported configuration settings from the output. These settings are
either used for debugging and development purposes only or their support is not
yet complete and they are not meant to be used in production. The \fBcurrent\fP
and \fBdiff\fP types include unsupported settings in their output by default,
all the other types ignore unsupported settings.
.ad b
.HP
.ad l
\fB-l\fP|\fB--list\fP
.br
List config settings with summarizing comment. This is the same as using
options --typeconfig list --withsummary.
.ad b
.HP
.ad l
\fB--longhelp\fP
.br
Display long help text.
.ad b
.HP
.ad l
\fB--mergedconfig\fP
.br
When the command is run with --config
and/or --commandprofile (or using LVM_COMMAND_PROFILE
environment variable), --profile, or --metadataprofile,
merge all the contents of the "config cascade" before displaying it.
Without merging, only the configuration at the front of the
cascade is displayed.
See \fBlvm.conf\fP(5) for more information about config.
.ad b
.HP
.ad l
\fB--metadataprofile\fP \fIString\fP
.br
The metadata profile to use for command configuration.
See \fBlvm.conf\fP(5) for more information about profiles.
.ad b
.HP
.ad l
\fB--profile\fP \fIString\fP
.br
An alias for --commandprofile or --metadataprofile, depending
on the command.
.ad b
.HP
.ad l
\fB-q\fP|\fB--quiet\fP ...
.br
Suppress output and log messages. Overrides --debug and --verbose.
Repeat once to also suppress any prompts with answer no.
.ad b
.HP
.ad l
\fB--showdeprecated\fP
.br
Include deprecated configuration settings in the output. These settings
are deprecated after a certain version. If a concrete version is specified
with --atversion, deprecated settings are automatically included
if the specified version is lower than the version in which the settings were
deprecated. The current and diff types include deprecated settings
in their output by default, all the other types ignore deprecated settings.
.ad b
.HP
.ad l
\fB--showunsupported\fP
.br
Include unsupported configuration settings in the output. These settings
are either used for debugging or development purposes only, or their support
is not yet complete and they are not meant to be used in production. The
current and diff types include unsupported settings in their
output by default, all the other types ignore unsupported settings.
.ad b
.HP
.ad l
\fB--sinceversion\fP \fIString\fP
.br
Specify an LVM version in x.y.z format where x is the major version,
the y is the minor version and z is the patchlevel (e.g. 2.2.106).
This option is currently applicable only with --typeconfig new
to display all configuration settings introduced since given version.
.ad b
.HP
.ad l
\fB-t\fP|\fB--test\fP
.br
Run in test mode. Commands will not update metadata.
This is implemented by disabling all metadata writing but nevertheless
returning success to the calling function. This may lead to unusual
error messages in multi-stage operations if a tool relies on reading
back metadata it believes has changed but hasn't.
.ad b
.HP
.ad l
\fB--typeconfig\fP \fBcurrent\fP|\fBdefault\fP|\fBdiff\fP|\fBfull\fP|\fBlist\fP|\fBmissing\fP|\fBnew\fP|\fBprofilable\fP|\fBprofilable-command\fP|\fBprofilable-metadata\fP
.br
See lvmreport(7).
.ad b
.HP
.ad l
\fB--unconfigured\fP
.br
Internal option used for generating config file during build.
.ad b
.HP
.ad l
\fB--validate\fP
.br
Validate current configuration used and exit with appropriate
return code. The validation is done only for the configuration
at the front of the "config cascade". To validate the whole
merged configuration tree, also use --mergedconfig.
The validation is done even if lvm.conf config/checks is disabled.
.ad b
.HP
.ad l
\fB-v\fP|\fB--verbose\fP ...
.br
Set verbose level. Repeat from 1 to 4 times to increase the detail
of messages sent to stdout and stderr.
.ad b
.HP
.ad l
\fB--version\fP
.br
Display version information.
.ad b
.HP
.ad l
\fB--withcomments\fP
.br
Display a full comment for each configuration node. For deprecated
settings, also display comments about deprecation.
.ad b
.HP
.ad l
\fB--withspaces\fP
.br
Where appropriate, add more spaces in output for better readability.
.ad b
.HP
.ad l
\fB--withsummary\fP
.br
Display a one line comment for each configuration node.
.ad b
.HP
.ad l
\fB--withversions\fP
.br
Also display a comment containing the version of introduction for
each configuration node. If the setting is deprecated, also display
the version since which it is deprecated.
.ad b
.HP
.ad l
\fB-y\fP|\fB--yes\fP
.br
Do not prompt for confirmation interactively but always assume the
answer yes. Use with extreme caution.
(For automatic no, see -qq.)
.ad b
.SH VARIABLES
.HP
\fIString\fP
.br
See the option description for information about the string content.
.HP
\fISize\fP[UNIT]
.br
Size is an input number that accepts an optional unit.
Input units are always treated as base two values, regardless of
capitalization, e.g. 'k' and 'K' both refer to 1024.
The default input unit is specified by letter, followed by |UNIT.
UNIT represents other possible input units: \fBbBsSkKmMgGtTpPeE\fP.
b|B is bytes, s|S is sectors of 512 bytes, k|K is kilobytes,
m|M is megabytes, g|G is gigabytes, t|T is terabytes,
p|P is petabytes, e|E is exabytes.
(This should not be confused with the output control --units, where
capital letters mean multiple of 1000.)
.SH ENVIRONMENT VARIABLES
See \fBlvm\fP(8) for information about environment variables used by lvm.
For example, LVM_VG_NAME can generally be substituted for a required VG parameter.
.SH SEE ALSO
.BR lvm (8)
.BR lvm.conf (5)
.BR lvmconfig (8)
.BR pvchange (8)
.BR pvck (8)
.BR pvcreate (8)
.BR pvdisplay (8)
.BR pvmove (8)
.BR pvremove (8)
.BR pvresize (8)
.BR pvs (8)
.BR pvscan (8)
.BR vgcfgbackup (8)
.BR vgcfgrestore (8)
.BR vgchange (8)
.BR vgck (8)
.BR vgcreate (8)
.BR vgconvert (8)
.BR vgdisplay (8)
.BR vgexport (8)
.BR vgextend (8)
.BR vgimport (8)
.BR vgimportclone (8)
.BR vgmerge (8)
.BR vgmknodes (8)
.BR vgreduce (8)
.BR vgremove (8)
.BR vgrename (8)
.BR vgs (8)
.BR vgscan (8)
.BR vgsplit (8)
.BR lvcreate (8)
.BR lvchange (8)
.BR lvconvert (8)
.BR lvdisplay (8)
.BR lvextend (8)
.BR lvreduce (8)
.BR lvremove (8)
.BR lvrename (8)
.BR lvresize (8)
.BR lvs (8)
.BR lvscan (8)
.BR lvm2-activation-generator (8)
.BR blkdeactivate (8)
.BR lvmdump (8)
.BR dmeventd (8)
.BR lvmetad (8)
.BR lvmpolld (8)
.BR lvmlockd (8)
.BR lvmlockctl (8)
.BR clvmd (8)
.BR cmirrord (8)
.BR lvmdbusd (8)
.BR lvmsystemid (7)
.BR lvmreport (7)
.BR lvmraid (7)
.BR lvmthin (7)
.BR lvmcache (7)

View File

@@ -1,4 +1,4 @@
.TH LVM 8 "LVM TOOLS #VERSION#" "Sistina Software UK" \" -*- nroff -*-
.TH LVM 8 "LVM TOOLS #VERSION#" "Red Hat, Inc." \" -*- nroff -*-
.
.SH NAME
.

View File

@@ -1,4 +1,4 @@
.TH LVM.CONF 5 "LVM TOOLS #VERSION#" "Sistina Software UK" \" -*- nroff -*-
.TH LVM.CONF 5 "LVM TOOLS #VERSION#" "Red Hat, Inc." \" -*- nroff -*-
.SH NAME
lvm.conf \(em Configuration file for LVM2
.SH SYNOPSIS

View File

@@ -1,3 +1,4 @@
lvmconfig produces formatted output from the LVM configuration tree. The
lvmconfig, lvm config, lvm dumpconfig (for compatibility reasons, to be phased out) produce
formatted output from the LVM configuration tree. The
sources of the configuration data include \fBlvm.conf\fP(5) and command
line settings from --config.

View File

@@ -10,7 +10,8 @@ lvmconfig - Display and manipulate configuration information
[ \fIposition_args\fP ]
.br
.SH DESCRIPTION
lvmconfig produces formatted output from the LVM configuration tree. The
lvmconfig, lvm config, lvm dumpconfig (for compatibility reasons, to be phased out) produce
formatted output from the LVM configuration tree. The
sources of the configuration data include \fBlvm.conf\fP(5) and command
line settings from --config.
.SH USAGE

View File

@@ -23,7 +23,7 @@ devices, and MD is used to place data on physical devices.
LVM creates hidden LVs (dm devices) layered between the visible LV and
physical devices. LVs in the middle layers are called sub LVs.
For LVM raid, a sub LV pair to store data and metadata (raid superblock
and bitmap) is created per raid image/leg (see lvs command examples below).
and write intent bitmap) is created per raid image/leg (see lvs command examples below).
.SH Create a RAID LV
@@ -45,7 +45,7 @@ The basic RAID levels that can be used are:
To display the LV type of an existing LV, run:
.B lvs -o name,segtype
\fIVG\fP/\fILV\fP
\fILV\fP
(The LV type is also referred to as "segment type" or "segtype".)
@@ -142,7 +142,8 @@ raid5 is a form of striping that uses an extra device for storing parity
blocks. LV data and parity blocks are stored on each device, typically in
a rotating pattern for performance reasons. The LV data remains available
if one device fails. The parity is used to recalculate data that is lost
from a single device. The minimum number of devices required is 3.
from a single device. The minimum number of devices required is 3 (unless
converting from 2 legged raid1 to reshape to more stripes; see reshaping).
.B lvcreate --type raid5
[\fB--stripes\fP \fINumber\fP \fB--stripesize\fP \fISize\fP]
@@ -272,11 +273,13 @@ Correct blocks are read, parity is calculated, and recalculated blocks are
written.
The RAID implementation keeps track of which parts of a RAID LV are
synchronized. This uses a bitmap saved in the RAID metadata. The bitmap
can exclude large parts of the LV from synchronization to reduce the
amount of work after a crash. Without this, the entire LV would need
to be synchronized every time it was activated. When a RAID LV is
first created and activated the first synchronization is called initialization.
synchronized. When a RAID LV is first created and activated the first
synchronization is called initialization. A pointer stored in the raid
metadata keeps track of the initialization process thus allowing it to be
restarted after a deactivation of the RaidLV or a crash. Any writes to
the RaidLV dirties the respective region of the write intent bitmap which
allow for fast recovery of the regions after a crash. Without this, the
entire LV would need to be synchronized every time it was activated.
Automatic synchronization happens when a RAID LV is activated, but it is
usually partial because the bitmaps reduce the areas that are checked.
@@ -303,7 +306,7 @@ The command to scrub a RAID LV can operate in two different modes:
.B lvchange --syncaction
.BR check | repair
.IR VG / LV
.I LV
.HP
.B check
@@ -322,20 +325,20 @@ the RAID LV. To control the I/O rate used for scrubbing, use:
.HP
.B --maxrecoveryrate
.BR \fIRate [ b | B | s | S | k | K | m | M | g | G ]
\fISize\fP[k|UNIT]
.br
Sets the maximum recovery rate for a RAID LV. \fIRate\fP is specified as
Sets the maximum recovery rate for a RAID LV. \fISize\fP is specified as
an amount per second for each device in the array. If no suffix is given,
then KiB/sec/device is assumed. Setting the recovery rate to \fB0\fP
then KiB/sec/device is used. Setting the recovery rate to \fB0\fP
means it will be unbounded.
.HP
.BR --minrecoveryrate
.BR \fIRate [ b | B | s | S | k | K | m | M | g | G ]
\fISize\fP[k|UNIT]
.br
Sets the minimum recovery rate for a RAID LV. \fIRate\fP is specified as
Sets the minimum recovery rate for a RAID LV. \fISize\fP is specified as
an amount per second for each device in the array. If no suffix is given,
then KiB/sec/device is assumed. Setting the recovery rate to \fB0\fP
then KiB/sec/device is used. Setting the recovery rate to \fB0\fP
means it will be unbounded.
.P
@@ -354,9 +357,9 @@ Also, if mismatches were found, the lvs attr field will display the letter
"m" (mismatch) in the 9th position, e.g.
.nf
# lvs -o name,vgname,segtype,attr vg/lvol0
LV VG Type Attr
lvol0 vg raid1 Rwi-a-r-m-
# lvs -o name,vgname,segtype,attr vg/lv
LV VG Type Attr
lv vg raid1 Rwi-a-r-m-
.fi
@@ -424,9 +427,9 @@ Each rimage SubLV holds a portion of LV data. No parity is used.
No RAID metadata is used.
.nf
lvcreate --type raid0 --stripes 2 --name lvr0 ...
# lvcreate --type raid0 --stripes 2 --name lvr0 ...
lvs -a -o name,segtype,devices
# lvs -a -o name,segtype,devices
lvr0 raid0 lvr0_rimage_0(0),lvr0_rimage_1(0)
[lvr0_rimage_0] linear /dev/sda(...)
[lvr0_rimage_1] linear /dev/sdb(...)
@@ -438,9 +441,9 @@ Each rimage SubLV holds a complete copy of LV data. No parity is used.
Each rmeta SubLV holds RAID metadata.
.nf
lvcreate --type raid1 --mirrors 1 --name lvr1 ...
# lvcreate --type raid1 --mirrors 1 --name lvr1 ...
lvs -a -o name,segtype,devices
# lvs -a -o name,segtype,devices
lvr1 raid1 lvr1_rimage_0(0),lvr1_rimage_1(0)
[lvr1_rimage_0] linear /dev/sda(...)
[lvr1_rimage_1] linear /dev/sdb(...)
@@ -450,13 +453,13 @@ lvs -a -o name,segtype,devices
.B raid4
.br
Two rimage SubLVs each hold a portion of LV data and one rimage SubLV
At least three rimage SubLVs each hold a portion of LV data and one rimage SubLV
holds parity. Each rmeta SubLV holds RAID metadata.
.nf
lvcreate --type raid4 --stripes 2 --name lvr4 ...
# lvcreate --type raid4 --stripes 2 --name lvr4 ...
lvs -a -o name,segtype,devices
# lvs -a -o name,segtype,devices
lvr4 raid4 lvr4_rimage_0(0),\\
lvr4_rimage_1(0),\\
lvr4_rimage_2(0)
@@ -470,13 +473,14 @@ lvs -a -o name,segtype,devices
.B raid5
.br
Three rimage SubLVs each hold a portion of LV data and parity.
At least three rimage SubLVs each typcially hold a portion of LV data and parity
(see section on raid5)
Each rmeta SubLV holds RAID metadata.
.nf
lvcreate --type raid5 --stripes 2 --name lvr5 ...
# lvcreate --type raid5 --stripes 2 --name lvr5 ...
lvs -a -o name,segtype,devices
# lvs -a -o name,segtype,devices
lvr5 raid5 lvr5_rimage_0(0),\\
lvr5_rimage_1(0),\\
lvr5_rimage_2(0)
@@ -490,13 +494,14 @@ lvs -a -o name,segtype,devices
.B raid6
.br
Six rimage SubLVs each hold a portion of LV data and parity.
At least five rimage SubLVs each typically hold a portion of LV data and parity.
(see section on raid6)
Each rmeta SubLV holds RAID metadata.
.nf
lvcreate --type raid6 --stripes 3 --name lvr6
# lvcreate --type raid6 --stripes 3 --name lvr6
lvs -a -o name,segtype,devices
# lvs -a -o name,segtype,devices
lvr6 raid6 lvr6_rimage_0(0),\\
lvr6_rimage_1(0),\\
lvr6_rimage_2(0),\\
@@ -515,16 +520,17 @@ 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
Four rimage SubLVs each hold a portion of LV data. No parity is used.
At least four rimage SubLVs each hold a portion of LV data. No parity is used.
Each rmeta SubLV holds RAID metadata.
.nf
lvcreate --type raid10 --stripes 2 --mirrors 1 --name lvr10
# lvcreate --type raid10 --stripes 2 --mirrors 1 --name lvr10
lvs -a -o name,segtype,devices
# lvs -a -o name,segtype,devices
lvr10 raid10 lvr10_rimage_0(0),\\
lvr10_rimage_1(0),\\
lvr10_rimage_2(0),\\
@@ -563,9 +569,9 @@ RAID4 and RAID5 LVs can tolerate losing one device without LV data loss.
RAID6 LVs can tolerate losing two devices without LV data loss.
.IP \[bu] 3
RAID10 is variable, and depends on which devices are lost. It can
tolerate losing all but one device in a raid1 set, where each stripe
is composed of a raid1 set, without LV data loss.
RAID10 is variable, and depends on which devices are lost. It stripes
across multiple mirror groups with raid1 layout thus it can tolerate
losing all but one device in each of these groups without LV data loss.
.P
@@ -610,8 +616,8 @@ A RAID LV that is missing devices may be activated or not, depending on
the "activation mode" used in lvchange:
.B lvchange -ay --activationmode
.RB { complete | degraded | partial }
.IR VG / LV
.BR complete | degraded | partial
.I LV
.B complete
.br
@@ -649,12 +655,12 @@ repeated to replace multiple PVs. Replacement devices can be optionally
listed with either option.
.B lvconvert --repair
.IR VG / LV
.I LV
[\fINewPVs\fP]
.B lvconvert --replace
\fIOldPV\fP
.IR VG / LV
.I LV
[\fINewPV\fP]
.B lvconvert
@@ -663,7 +669,7 @@ listed with either option.
.B --replace
\fIOldPV2\fP
...
.IR VG / LV
.I LV
[\fINewPVs\fP]
New devices require synchronization with existing devices, see
@@ -679,18 +685,18 @@ in the RAID LV operating in degraded mode until it is reactivated. Use
the lvchange command to refresh an LV:
.B lvchange --refresh
.IR VG / LV
.I LV
.nf
# lvs -o name,vgname,segtype,attr,size vg
LV VG Type Attr LSize
raid1 vg raid1 Rwi-a-r-r- 100.00g
LV VG Type Attr LSize
lv vg raid1 Rwi-a-r-r- 100.00g
# lvchange --refresh vg/raid1
# lvchange --refresh vg/lv
# lvs -o name,vgname,segtype,attr,size vg
LV VG Type Attr LSize
raid1 vg raid1 Rwi-a-r--- 100.00g
LV VG Type Attr LSize
lv vg raid1 Rwi-a-r--- 100.00g
.fi
.SS Automatic repair
@@ -721,7 +727,7 @@ synchronization is started.
The specific command run by dmeventd to warn or repair is:
.br
.B lvconvert --repair --use-policies
.IR VG / LV
.I LV
.SS Corrupted Data
@@ -736,8 +742,9 @@ This should be rare, and can be detected (see \fBScrubbing\fP).
If specific PVs in a RAID LV are known to have corrupt data, the data on
those PVs can be reconstructed with:
.B lvchange --rebuild PV
.IR VG / LV
.B lvchange --rebuild
.I PV
.I LV
The rebuild option can be repeated with different PVs to replace the data
on multiple PVs.
@@ -783,8 +790,8 @@ while all devices are still written to.
.B lvchange
.BR -- [ raid ] writemostly
.BR \fIPhysicalVolume [ : { y | n | t }]
.IR VG / LV
\fIPV\fP[\fB:y\fP|\fBn\fP|\fBt\fP]
.I LV
The specified device will be marked as "write mostly", which means that
reading from this device will be avoided, and other devices will be
@@ -810,8 +817,8 @@ will not complete until writes to all the mirror images are complete.
.B lvchange
.BR -- [ raid ] writebehind
.IR IOCount
.IR VG / LV
.I Number
.I LV
To report the current write behind setting, run:
@@ -830,7 +837,7 @@ using lvconvert and specifying the new RAID level as the LV type:
.B lvconvert --type
.I RaidLevel
\fIVG\fP/\fILV\fP
.I LV
[\fIPVs\fP]
The most common and recommended RAID takeover conversions are:
@@ -862,10 +869,13 @@ needed.
Conversion often requires full synchronization of the RAID LV (see
\fBSynchronization\fP). Converting to RAID1 requires copying all LV data
blocks to a new image on a new device. Converting to a parity RAID level
blocks to N new images on new devices. Converting to a parity RAID level
requires reading all LV data blocks, calculating parity, and writing the
new parity blocks. Synchronization can take a long time and degrade
performance (rate controls also apply to conversion, see
new parity blocks. Synchronization can take a long time depending on the
throughpout of the devices used and the size of the RaidLV. It can degrade
performance (rate controls also apply to conversion; see
\fB--minrecoveryrate\fP
and
\fB--maxrecoveryrate\fP.)
Warning: though it is possible to create \fBstriped\fP LVs with up to 128 stripes,
@@ -897,6 +907,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
@@ -927,8 +939,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
@@ -984,7 +994,7 @@ Convert the linear LV to raid1 with three images
# lvconvert --type raid1 --mirrors 2 vg/lv
.fi
4. Converting an LV from \fBstriped\fP (with 4 stripes) to \fBraid6_nc\fP.
4. Converting an LV from \fBstriped\fP (with 4 stripes) to \fBraid6_n_6\fP.
.nf
Start with a striped LV:
@@ -1115,31 +1125,35 @@ 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 tb/lv
# lvconvert --stripes 5 vg/lv
Using default stripesize 64.00 KiB.
WARNING: Adding stripes to active logical volume tb/lv will grow it from 99 to 165 extents!
Run "lvresize -l99 tb/lv" to shrink it or use the additional capacity.
Logical volume tb/lv successfully converted.
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
root fedora -wi-ao---- 15.00g
swap fedora -wi-ao---- 3.99g
lv tb rwi-a-r-s- 652.00m 52.94
# lvs vg/lv
LV VG Attr LSize Cpy%Sync
lv vg rwi-a-r-s- 652.00m 52.94
# lvs -a -o lv_name,attr,segtype,seg_pe_ranges,dataoffset tb
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_rimage_0] iwi-aor--- linear /dev/sda:0-32 0
# 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_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--- 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--- 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
@@ -1155,28 +1169,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 tb/lv
# lvconvert --stripes 4 vg/lv
Using default stripesize 64.00 KiB.
WARNING: Removing stripes from active logical volume tb/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 tb/lv"
Logical volume tb/lv successfully converted.
WARNING: to 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 tb
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
# 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_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
@@ -1190,38 +1211,49 @@ The 's' in column 9 of the attribute field shows the RaidLV is still reshaping.
The 'R' in the same column of the attribute field shows the freed image Sub LVs which will need removing once the reshaping finished.
.nf
# lvs -o lv_name,attr,segtype,seg_pe_ranges,dataoffset tb
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
# 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
.fi
Now that the reshape is finished the 'R' atribute on the RaidLV shows images can be removed.
.nf
# lvs -o lv_name,attr,segtype,seg_pe_ranges,dataoffset tb
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
# 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
.fi
This is achieved by repeating the command ("lvconvert --stripes 4 tb/lv" would be sufficient).
This is achieved by repeating the command ("lvconvert --stripes 4 vg/lv" would be sufficient).
.nf
# lvconvert --stripes 4 --force -y tb/lv
# lvconvert --stripes 4 vg/lv
Using default stripesize 64.00 KiB.
Logical volume tb/lv successfully converted.
Logical volume vg/lv successfully converted.
# lvs -a -o lv_name,attr,segtype,seg_pe_ranges,dataoffset tb
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 8192
[lv_rimage_0] iwi-aor--- linear /dev/sda:0-32 8192
# 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 8192
[lv_rimage_0] iwi-aor--- linear /dev/sda:0-32 8192
[lv_rimage_0] iwi-aor--- linear /dev/sda:34-34
[lv_rimage_1] iwi-aor--- linear /dev/sdaa:0-32 8192
[lv_rimage_1] iwi-aor--- linear /dev/sdaa:0-32 8192
[lv_rimage_1] iwi-aor--- linear /dev/sdaa:34-34
[lv_rimage_2] iwi-aor--- linear /dev/sdab:0-32 8192
[lv_rimage_2] iwi-aor--- linear /dev/sdab:0-32 8192
[lv_rimage_2] iwi-aor--- linear /dev/sdab:34-34
[lv_rimage_3] iwi-aor--- linear /dev/sdac:1-34 8192
[lv_rimage_4] iwi-aor--- linear /dev/sdad:1-34 8192
[lv_rimage_5] iwi-aor--- linear /dev/sdae:1-34 8192
[lv_rimage_3] iwi-aor--- linear /dev/sdac:1-34 8192
[lv_rimage_4] iwi-aor--- linear /dev/sdad:1-34 8192
[lv_rimage_5] iwi-aor--- linear /dev/sdae:1-34 8192
[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
@@ -1229,7 +1261,7 @@ This is achieved by repeating the command ("lvconvert --stripes 4 tb/lv" would b
[lv_rmeta_4] ewi-aor--- linear /dev/sdad:0-0
[lv_rmeta_5] ewi-aor--- linear /dev/sdae:0-0
# lvs -a -o lv_name,attr,segtype,reshapelen tb
# lvs -a -o lv_name,attr,segtype,reshapelen vg
LV Attr Type RSize
lv rwi-a-r--- raid6_nr 24.00m
[lv_rimage_0] iwi-aor--- linear 4.00m
@@ -1249,15 +1281,17 @@ This is achieved by repeating the command ("lvconvert --stripes 4 tb/lv" would b
[lv_rmeta_5] ewi-aor--- linear
.fi
Future developments might include automatic removal of the freed images.
If the reshape space shall be removed any lvconvert command not changing the layout can be used:
.nf
# lvconvert --stripes 4 tb/lv
# lvconvert --stripes 4 vg/lv
Using default stripesize 64.00 KiB.
No change in RAID LV tb/lv layout, freeing reshape space.
Logical volume tb/lv successfully converted.
No change in RAID LV vg/lv layout, freeing reshape space.
Logical volume vg/lv successfully converted.
# lvs -a -o lv_name,attr,segtype,reshapelen tb
# lvs -a -o lv_name,attr,segtype,reshapelen vg
LV Attr Type RSize
lv rwi-a-r--- raid6_nr 0
[lv_rimage_0] iwi-aor--- linear 0
@@ -1280,9 +1314,9 @@ If the reshape space shall be removed any lvconvert command not changing the lay
In case the RaidLV should be converted to striped:
.nf
# lvconvert --type striped tb/lv
Unable to convert LV tb/lv from raid6_nr to striped.
Converting tb/lv from raid6_nr is directly possible to the following layouts:
# lvconvert --type striped vg/lv
Unable to convert LV vg/lv from raid6_nr to striped.
Converting vg/lv from raid6_nr is directly possible to the following layouts:
raid6_nc
raid6_zr
raid6_la_6
@@ -1290,48 +1324,72 @@ In case the RaidLV should be converted to striped:
raid6_ra_6
raid6_rs_6
raid6_n_6
.fi
A direct conversion isn't possible thus the command informed about the possible ones.
raid6_n_6 is suitable to convert to striped so convert to it first (this is a reshape
changing the raid6 layout from raid6_nr to raid6_n_6).
.nf
# lvconvert --type raid6_n_6
Using default stripesize 64.00 KiB.
Converting raid6_nr LV tb/lv to raid6_n_6.
Are you sure you want to convert raid6_nr LV tb/lv? [y/n]: y
Logical volume tb/lv successfully converted.
Converting raid6_nr LV vg/lv to raid6_n_6.
Are you sure you want to convert raid6_nr LV vg/lv? [y/n]: y
Logical volume vg/lv successfully converted.
.fi
# lvconvert -y --type striped tb/lv
Logical volume tb/lv successfully converted.
Wait for the reshape to finish.
[root@vm46 ~]# lvs -o lv_name,attr,segtype,seg_pe_ranges,dataoffset tb
LV Attr Type PE Ranges DOff
lv -wi-a----- striped /dev/sda:2-32 /dev/sdaa:2-32 /dev/sdab:2-32 /dev/sdac:3-33
lv -wi-a----- striped /dev/sda:34-35 /dev/sdaa:34-35 /dev/sdab:34-35 /dev/sdac:34-35
.nf
# lvconvert --type striped vg/lv
Logical volume vg/lv successfully converted.
# lvs -o lv_name,attr,segtype,seg_pe_ranges,dataoffset vg
LV Attr Type PE Ranges DOff
lv -wi-a----- striped /dev/sda:2-32 \\
/dev/sdaa:2-32 \\
/dev/sdab:2-32 \\
/dev/sdac:3-33
lv -wi-a----- striped /dev/sda:34-35 \\
/dev/sdaa:34-35 \\
/dev/sdab:34-35 \\
/dev/sdac:34-35
.fi
From striped we can convert to raid10
.nf
# lvconvert -y --type raid10 tb/lv
# lvconvert --type raid10 vg/lv
Using default stripesize 64.00 KiB.
Logical volume tb/lv successfully converted.
Logical volume vg/lv successfully converted.
# lvs -o lv_name,attr,segtype,seg_pe_ranges,dataoffset tb
LV Attr Type PE Ranges DOff
lv rwi-a-r--- raid10 lv_rimage_0:0-32 lv_rimage_4:0-32 lv_rimage_1:0-32 ... lv_rimage_3:0-32 lv_rimage_7:0-32 0
# lvs -o lv_name,attr,segtype,seg_pe_ranges,dataoffset vg
LV Attr Type PE Ranges DOff
lv rwi-a-r--- raid10 lv_rimage_0:0-32 \\
lv_rimage_4:0-32 \\
lv_rimage_1:0-32 ... \\
lv_rimage_3:0-32 \\
lv_rimage_7:0-32 0
# lvs -a -o lv_name,attr,segtype,seg_pe_ranges,dataoffset tb
WARNING: Cannot find matching striped segment for tb/lv_rimage_3.
LV Attr Type PE Ranges DOff
lv rwi-a-r--- raid10 lv_rimage_0:0-32 lv_rimage_4:0-32 lv_rimage_1:0-32 ... lv_rimage_3:0-32 lv_rimage_7:0-32 0
[lv_rimage_0] iwi-aor--- linear /dev/sda:2-32 0
# lvs -a -o lv_name,attr,segtype,seg_pe_ranges,dataoffset vg
WARNING: Cannot find matching striped segment for vg/lv_rimage_3.
LV Attr Type PE Ranges DOff
lv rwi-a-r--- raid10 lv_rimage_0:0-32 \\
lv_rimage_4:0-32 \\
lv_rimage_1:0-32 ... \\
lv_rimage_3:0-32 \\
lv_rimage_7:0-32 0
[lv_rimage_0] iwi-aor--- linear /dev/sda:2-32 0
[lv_rimage_0] iwi-aor--- linear /dev/sda:34-35
[lv_rimage_1] iwi-aor--- linear /dev/sdaa:2-32 0
[lv_rimage_1] iwi-aor--- linear /dev/sdaa:2-32 0
[lv_rimage_1] iwi-aor--- linear /dev/sdaa:34-35
[lv_rimage_2] iwi-aor--- linear /dev/sdab:2-32 0
[lv_rimage_2] iwi-aor--- linear /dev/sdab:2-32 0
[lv_rimage_2] iwi-aor--- linear /dev/sdab:34-35
[lv_rimage_3] iwi-XXr--- linear /dev/sdac:3-35 0
[lv_rimage_4] iwi-aor--- linear /dev/sdad:1-33 0
[lv_rimage_5] iwi-aor--- linear /dev/sdae:1-33 0
[lv_rimage_6] iwi-aor--- linear /dev/sdaf:1-33 0
[lv_rimage_7] iwi-aor--- linear /dev/sdag:1-33 0
[lv_rimage_3] iwi-XXr--- linear /dev/sdac:3-35 0
[lv_rimage_4] iwi-aor--- linear /dev/sdad:1-33 0
[lv_rimage_5] iwi-aor--- linear /dev/sdae:1-33 0
[lv_rimage_6] iwi-aor--- linear /dev/sdaf:1-33 0
[lv_rimage_7] iwi-aor--- linear /dev/sdag:1-33 0
[lv_rmeta_0] ewi-aor--- linear /dev/sda:0-0
[lv_rmeta_1] ewi-aor--- linear /dev/sdaa:0-0
[lv_rmeta_2] ewi-aor--- linear /dev/sdab:0-0
@@ -1352,24 +1410,27 @@ by restripe (4 steps).
We start with the linear LV.
.nf
# lvs -aoname,attr,size,segtype,syncpercent,datastripes,stripesize,reshapelenle,devices vg
LV Attr LSize Type Cpy%Sync #DStr Stripe RSize Devices
lv -wi-a----- 128.00m linear 1 0 /dev/sda(0)
# lvs -a -o name,size,segtype,syncpercent,datastripes,\\
stripesize,reshapelenle,devices vg
LV LSize Type Cpy%Sync #DStr Stripe RSize Devices
lv 128.00m linear 1 0 /dev/sda(0)
.fi
Then convert it to a 2-way raid1.
.nf
# lvconvert -m1 vg/lv
# lvconvert --mirrors 1 vg/lv
Logical volume vg/lv successfully converted.
# lvs -aoname,attr,size,segtype,syncpercent,datastripes,stripesize,reshapelenle,devices vg
LV Attr LSize Type Cpy%Sync #DStr Stripe RSize Devices
lv rwi-a-r--- 128.00m raid1 100.00 2 0 lv_rimage_0(0),lv_rimage_1(0)
[lv_rimage_0] iwi-aor--- 128.00m linear 1 0 /dev/sda(0)
[lv_rimage_1] iwi-aor--- 128.00m linear 1 0 /dev/sdhx(1)
[lv_rmeta_0] ewi-aor--- 4.00m linear 1 0 /dev/sda(32)
[lv_rmeta_1] ewi-aor--- 4.00m linear 1 0 /dev/sdhx(0)
# lvs -a -o name,size,segtype,datastripes,\\
stripesize,reshapelenle,devices vg
LV LSize Type #DStr Stripe RSize Devices
lv 128.00m raid1 2 0 lv_rimage_0(0),\\
lv_rimage_1(0)
[lv_rimage_0] 128.00m linear 1 0 /dev/sda(0)
[lv_rimage_1] 128.00m linear 1 0 /dev/sdhx(1)
[lv_rmeta_0] 4.00m linear 1 0 /dev/sda(32)
[lv_rmeta_1] 4.00m linear 1 0 /dev/sdhx(0)
.fi
Once the raid1 LV is fully synchronized we convert it to raid5_n (only 2-way raid1
@@ -1378,17 +1439,19 @@ SubLVs at the end and can be converted to striped directly without any additiona
conversion.
.nf
# lvconvert -y --ty raid5_n vg/lv
# lvconvert --type raid5_n vg/lv
Using default stripesize 64.00 KiB.
Logical volume vg/lv successfully converted.
# lvs -aoname,attr,size,segtype,syncpercent,datastripes,stripesize,reshapelenle,devices vg
LV Attr LSize Type Cpy%Sync #DStr Stripe RSize Devices
lv rwi-a-r--- 128.00m raid5_n 100.00 1 64.00k 0 lv_rimage_0(0),lv_rimage_1(0)
[lv_rimage_0] iwi-aor--- 128.00m linear 1 0 0 /dev/sda(0)
[lv_rimage_1] iwi-aor--- 128.00m linear 1 0 0 /dev/sdhx(1)
[lv_rmeta_0] ewi-aor--- 4.00m linear 1 0 /dev/sda(32)
[lv_rmeta_1] ewi-aor--- 4.00m linear 1 0 /dev/sdhx(0)
# lvs -a -o name,size,segtype,syncpercent,datastripes,\\
stripesize,reshapelenle,devices vg
LV LSize Type #DStr Stripe RSize Devices
lv 128.00m raid5_n 1 64.00k 0 lv_rimage_0(0),\\
lv_rimage_1(0)
[lv_rimage_0] 128.00m linear 1 0 0 /dev/sda(0)
[lv_rimage_1] 128.00m linear 1 0 0 /dev/sdhx(1)
[lv_rmeta_0] 4.00m linear 1 0 /dev/sda(32)
[lv_rmeta_1] 4.00m linear 1 0 /dev/sdhx(0)
.fi
Now we'll change the number of data stripes from 1 to 5 and request 128K stripe size
@@ -1397,50 +1460,67 @@ to the one given). That additonal space can be used by e.g. growing any contain
or the LV can be reduced in size after the reshaping conversion has finished.
.nf
# lvconvert --yes --stripesize 128k --stripes 5 vg/lv
# lvconvert --stripesize 128k --stripes 5 vg/lv
Converting stripesize 64.00 KiB of raid5_n LV vg/lv to 128.00 KiB.
WARNING: Adding stripes to active logical volume vg/lv will grow it from 32 to 160 extents!
WARNING: Adding stripes to active logical volume vg/lv will grow \\
it from 32 to 160 extents!
Run "lvresize -l32 vg/lv" to shrink it or use the additional capacity.
Logical volume vg/lv successfully converted.
# lvs -aoname,attr,size,segtype,syncpercent,datastripes,stripesize,reshapelenle,devices vg
LV Attr LSize Type Cpy%Sync #DStr Stripe RSize Devices
lv rwi-a-r--- 640.00m raid5_n 100.00 5 128.00k 6 lv_rimage_0(0),lv_rimage_1(0),lv_rimage_2(0),lv_rimage_3(0),lv_rimage_4(0),lv_rimage_5(0)
[lv_rimage_0] iwi-aor--- 132.00m linear 1 0 1 /dev/sda(33)
[lv_rimage_0] iwi-aor--- 132.00m linear 1 0 /dev/sda(0)
[lv_rimage_1] iwi-aor--- 132.00m linear 1 0 1 /dev/sdhx(33)
[lv_rimage_1] iwi-aor--- 132.00m linear 1 0 /dev/sdhx(1)
[lv_rimage_2] iwi-aor--- 132.00m linear 1 0 1 /dev/sdhw(33)
[lv_rimage_2] iwi-aor--- 132.00m linear 1 0 /dev/sdhw(1)
[lv_rimage_3] iwi-aor--- 132.00m linear 1 0 1 /dev/sdhv(33)
[lv_rimage_3] iwi-aor--- 132.00m linear 1 0 /dev/sdhv(1)
[lv_rimage_4] iwi-aor--- 132.00m linear 1 0 1 /dev/sdhu(33)
[lv_rimage_4] iwi-aor--- 132.00m linear 1 0 /dev/sdhu(1)
[lv_rimage_5] iwi-aor--- 132.00m linear 1 0 1 /dev/sdht(33)
[lv_rimage_5] iwi-aor--- 132.00m linear 1 0 /dev/sdht(1)
[lv_rmeta_0] ewi-aor--- 4.00m linear 1 0 /dev/sda(32)
[lv_rmeta_1] ewi-aor--- 4.00m linear 1 0 /dev/sdhx(0)
[lv_rmeta_2] ewi-aor--- 4.00m linear 1 0 /dev/sdhw(0)
[lv_rmeta_3] ewi-aor--- 4.00m linear 1 0 /dev/sdhv(0)
[lv_rmeta_4] ewi-aor--- 4.00m linear 1 0 /dev/sdhu(0)
[lv_rmeta_5] ewi-aor--- 4.00m linear 1 0 /dev/sdht(0)
# lvs -a -o name,size,segtype,datastripes,\\
stripesize,reshapelenle,devices
LV LSize Type #DStr Stripe RSize Devices
lv 640.00m raid5_n 5 128.00k 6 lv_rimage_0(0),\\
lv_rimage_1(0),\\
lv_rimage_2(0),\\
lv_rimage_3(0),\\
lv_rimage_4(0),\\
lv_rimage_5(0)
[lv_rimage_0] 132.00m linear 1 0 1 /dev/sda(33)
[lv_rimage_0] 132.00m linear 1 0 /dev/sda(0)
[lv_rimage_1] 132.00m linear 1 0 1 /dev/sdhx(33)
[lv_rimage_1] 132.00m linear 1 0 /dev/sdhx(1)
[lv_rimage_2] 132.00m linear 1 0 1 /dev/sdhw(33)
[lv_rimage_2] 132.00m linear 1 0 /dev/sdhw(1)
[lv_rimage_3] 132.00m linear 1 0 1 /dev/sdhv(33)
[lv_rimage_3] 132.00m linear 1 0 /dev/sdhv(1)
[lv_rimage_4] 132.00m linear 1 0 1 /dev/sdhu(33)
[lv_rimage_4] 132.00m linear 1 0 /dev/sdhu(1)
[lv_rimage_5] 132.00m linear 1 0 1 /dev/sdht(33)
[lv_rimage_5] 132.00m linear 1 0 /dev/sdht(1)
[lv_rmeta_0] 4.00m linear 1 0 /dev/sda(32)
[lv_rmeta_1] 4.00m linear 1 0 /dev/sdhx(0)
[lv_rmeta_2] 4.00m linear 1 0 /dev/sdhw(0)
[lv_rmeta_3] 4.00m linear 1 0 /dev/sdhv(0)
[lv_rmeta_4] 4.00m linear 1 0 /dev/sdhu(0)
[lv_rmeta_5] 4.00m linear 1 0 /dev/sdht(0)
.fi
Once the conversion has finished we can can convert to striped.
.nf
[root@vm46 ~]# lvconvert -y --ty striped vg/lv
# lvconvert --type striped vg/lv
Logical volume vg/lv successfully converted.
[root@vm46 ~]# lvs -aoname,attr,size,segtype,syncpercent,datastripes,stripesize,reshapelenle,devices vg|sed 's/ *$//'
LV Attr LSize Type Cpy%Sync #DStr Stripe RSize Devices
lv -wi-a----- 640.00m striped 5 128.00k /dev/sda(33),/dev/sdhx(33),/dev/sdhw(33),/dev/sdhv(33),/dev/sdhu(33)
lv -wi-a----- 640.00m striped 5 128.00k /dev/sda(0),/dev/sdhx(1),/dev/sdhw(1),/dev/sdhv(1),/dev/sdhu(1)
# lvs -a -o name,size,segtype,datastripes,\\
stripesize,reshapelenle,devices vg
LV LSize Type #DStr Stripe RSize Devices
lv 640.00m striped 5 128.00k /dev/sda(33),\\
/dev/sdhx(33),\\
/dev/sdhw(33),\\
/dev/sdhv(33),\\
/dev/sdhu(33)
lv 640.00m striped 5 128.00k /dev/sda(0),\\
/dev/sdhx(1),\\
/dev/sdhw(1),\\
/dev/sdhv(1),\\
/dev/sdhu(1)
.fi
Reversing these steps wil convert a given striped LV to linear.
Reversing these steps will convert a given striped LV to linear.
Mind the fact that stripes are removed thus the capacity of the RaidLV will shrink.
Mind the facts that stripes are removed thus the capacity of the RaidLV will shrink
and that changing the RaidLV layout will influence its performance.
"lvconvert --stripes 1 vg/lv" for converting to 1 stripe will inform upfront about
the reduced size to allow for resizing the content or growing the RaidLV before
@@ -1491,6 +1571,7 @@ RAID5 parity n
.br
\[bu]
Dedicated parity device n used for striped/raid0 conversions
.br
\[bu]
Used for RAID Takeover
@@ -1537,7 +1618,9 @@ raid6_n_6
RAID6 last parity devices
.br
\[bu]
Dedicated last parity devices used for striped/raid0 conversions
Fixed dedicated last devices (P-Syndrome N-1 and Q-Syndrome N)
with striped data used for striped/raid0 conversions
.br
\[bu]
Used for RAID Takeover
@@ -1549,17 +1632,6 @@ RAID6 last parity device
\[bu]
Dedicated last parity device used for conversions from/to raid5_{ls,rs,la,ra}
raid6_n_6
.br
\[bu]
RAID6 N continue
.br
\[bu]
Fixed P-Syndrome N-1 and Q-Syndrome N with striped data
.br
\[bu]
Used for RAID Takeover
raid6_ls_6
.br
\[bu]
@@ -1632,7 +1704,7 @@ The command to start duplication is:
[\fB--stripes\fP \fINumber\fP \fB--stripesize\fP \fISize\fP]
.RS
.B --duplicate
.IR VG / LV
.I LV
[\fIPVs\fP]
.RE
@@ -1682,7 +1754,7 @@ the new devices, specify the name of SubLV 0 (suffix _dup_0):
.B lvconvert --unduplicate
.BI --name
.IB LV _dup_0
.IR VG / LV
.I LV
To make the RAID LV use the data copy on the new devices, and drop the old
devices, specify the name of SubLV 1 (suffix _dup_1):
@@ -1690,7 +1762,7 @@ devices, specify the name of SubLV 1 (suffix _dup_1):
.B lvconvert --unduplicate
.BI --name
.IB LV _dup_1
.IR VG / LV
.I LV
FIXME: To make the LV use the data on the original devices, but keep the
data copy as a new LV, ...

View File

@@ -361,7 +361,8 @@ function set_service {
if [ "$type" = "systemd" ]; then
if [ "$action" = "activate" ]; then
for i in $@; do
eval $($SYSTEMCTL_BIN show $i -p LoadState)
unset LoadState
eval $($SYSTEMCTL_BIN show $i -p LoadState 2>/dev/null)
test "$LoadState" = "loaded" || continue
$SYSTEMCTL_BIN enable $i
if [ "$START_STOP_SERVICES" = "1" ]; then
@@ -370,7 +371,8 @@ function set_service {
done
elif [ "$action" = "deactivate" ]; then
for i in $@; do
eval $($SYSTEMCTL_BIN show $i -p LoadState)
unset LoadState
eval $($SYSTEMCTL_BIN show $i -p LoadState 2>/dev/null)
test "$LoadState" = "loaded" || continue
$SYSTEMCTL_BIN disable $i
if [ "$START_STOP_SERVICES" = "1" ]; then

View File

@@ -34,6 +34,7 @@
%enableif %{enable_python3} python3-bindings
%enableif %{enable_python} applib
%enableif %{enable_dbusd} dbus-service
%enableif %{enable_dmfilemapd} dmfilemapd
%build

View File

@@ -539,6 +539,10 @@ for the kernel device-mapper.
%{_sbindir}/dmstats
%{_mandir}/man8/dmsetup.8.gz
%{_mandir}/man8/dmstats.8.gz
%if %{enable_dmfilemapd}
%{_sbindir}/dmfilemapd
%{_mandir}/man8/dmfilemapd.8.gz
%endif
%if %{enable_udev}
%doc udev/12-dm-permissions.rules
%dir %{_udevbasedir}

View File

@@ -15,6 +15,7 @@
%global enable_lvmlockd 1
%global enable_lvmetad 1
%global enable_lvmpolld 1
%global enable_dmfilemapd 0
#%global enable_lockd_dlm 0
#%global enable_lockd_sanlock 0
@@ -93,6 +94,12 @@
##############################################################
%if %{rhel} >= 7 || %{fedora} >= 25
%global enable_dmfilemapd 1
%endif
##############################################################
%if %{rhel} >= 8 || %{fedora} >= 23
%if %{enable_python3}
%global enable_dbusd 1

View File

@@ -37,9 +37,9 @@ include $(top_builddir)/make.tmpl
T ?= .
S ?= @ # never match anything by default
VERBOSE ?= 0
ALL := $(shell find -L $(srcdir) \( -path \*/shell/\*.sh -or -path \*/api/\*.sh \) | sort)
ALL := $(shell find -L $(srcdir) \( -path \*/shell/\*.sh -or -path \*/api/\*.sh \) | $(SORT))
comma = ,
RUN := $(shell find -L $(srcdir) -regextype posix-egrep \( -path \*/shell/\*.sh -or -path \*/api/\*.sh \) -and -regex "$(srcdir)/.*($(subst $(comma),|,$(T))).*" -and -not -regex "$(srcdir)/.*($(subst $(comma),|,$(S))).*" | ($SORT))
RUN := $(shell find -L $(srcdir) -regextype posix-egrep \( -path \*/shell/\*.sh -or -path \*/api/\*.sh \) -and -regex "$(srcdir)/.*($(subst $(comma),|,$(T))).*" -and -not -regex "$(srcdir)/.*($(subst $(comma),|,$(S))).*" | $(SORT))
RUN_BASE = $(subst $(srcdir)/,,$(RUN))
ifeq ("@BUILD_LVMETAD@", "yes")

View File

@@ -258,12 +258,11 @@ if test -z "${installed_testsuite+varset}"; then
case "$PATH" in
*"$abs_top_builddir/test/lib"*) ;;
*)
PATH="$abs_top_builddir/test/lib":"$abs_top_builddir/test/api":$PATH
for i in `find $abs_top_builddir -name \*.so`; do
p=`dirname $i`
LD_LIBRARY_PATH="$p":$LD_LIBRARY_PATH
done
export PATH LD_LIBRARY_PATH ;;
PATH="$abs_top_builddir/test/lib":"$abs_top_builddir/test/api":$PATH
LD_LIBRARY_PATH=$(find -L "$abs_top_builddir/libdm/" "$abs_top_builddir/tools/"\
"$abs_top_builddir/daemons/" "$abs_top_builddir/liblvm/"\
-name "*.so" -printf "%h:")"$LD_LIBRARY_PATH"
export PATH LD_LIBRARY_PATH ;;
esac
fi

View File

@@ -128,7 +128,7 @@ run_writemostly_check() {
# Converting to linear should clear flags and writebehind
not lvconvert -m 0 $vg/$lv $d1
lvconvert -y -m 0 $vg/$lv $d1
lvconvert --type raid1 -m 1 $vg/$lv $d1
lvconvert -y --type raid1 -m 1 $vg/$lv $d1
check lv_field $vg/$lv raid_write_behind ""
check lv_attr_bit health $vg/${lv}_rimage_0 "-"
check lv_attr_bit health $vg/${lv}_rimage_1 "-"
@@ -274,7 +274,7 @@ run_checks() {
printf "#\n#\n# run_checks: RAID as thinpool data\n#\n#\n"
# Hey, specifying devices for thin allocation doesn't work
# lvconvert --thinpool $1/$2 "$dev6"
# lvconvert -y --thinpool $1/$2 "$dev6"
lvcreate -aey -L 2M -n ${2}_meta $1 "$dev6"
lvconvert --thinpool $1/$2 --poolmetadata ${2}_meta
lvcreate -T $1/$2 -V 1 -n thinlv
@@ -289,7 +289,7 @@ run_checks() {
lvrename $1/$2 ${2}_meta
lvcreate -aey -L 2M -n $2 $1 "$dev6"
lvconvert --thinpool $1/$2 --poolmetadata ${2}_meta
lvconvert -y --thinpool $1/$2 --poolmetadata ${2}_meta
lvcreate -T $1/$2 -V 1 -n thinlv
THIN_POSTFIX="_tmeta"

View File

@@ -66,8 +66,8 @@ aux wait_for_sync $vg cpool_cmeta
lvchange --syncaction repair $vg/cpool_cdata
aux wait_for_sync $vg cpool_cdata
lvconvert --repair -y $vg/cpool_cmeta
lvconvert --repair -y $vg/cpool_cdata
lvconvert -y --repair $vg/cpool_cmeta
lvconvert -y --repair $vg/cpool_cdata
# do not allow reserved names for *new* LVs
not lvconvert --splitmirrors 1 --name split_cmeta $vg/cpool_cmeta "$dev1"
@@ -87,18 +87,18 @@ lvremove -f $vg
lvcreate --type cache-pool $vg/cpool -l 10
lvcreate -n corigin -H $vg/cpool -l 20
lvconvert -m+1 --type raid1 $vg/cpool_cmeta
lvconvert -y -m +1 --type raid1 $vg/cpool_cmeta
check lv_field $vg/cpool_cmeta layout "raid,raid1"
check lv_field $vg/cpool_cmeta role "private,cache,pool,metadata"
lvconvert -m+1 --type raid1 $vg/cpool_cdata
lvconvert -y -m +1 --type raid1 $vg/cpool_cdata
check lv_field $vg/cpool_cdata layout "raid,raid1"
check lv_field $vg/cpool_cdata role "private,cache,pool,data"
not lvconvert -m-1 $vg/cpool_cmeta
lvconvert -y -m-1 $vg/cpool_cmeta
not lvconvert -m -1 $vg/cpool_cmeta
lvconvert -y -m -1 $vg/cpool_cmeta
check lv_field $vg/cpool_cmeta layout "linear"
lvconvert -y -m-1 $vg/cpool_cdata
lvconvert -y -m -1 $vg/cpool_cdata
check lv_field $vg/cpool_cdata layout "linear"
lvremove -f $vg

View File

@@ -24,11 +24,11 @@ vgcreate -s 256k $vg $(cat DEVICES)
lvcreate -aey -l 4 -n $lv1 $vg "$dev1:0-1" "$dev2:0-1"
not lvconvert --type raid1 -m 1 $vg/$lv1 "$dev1" "$dev2"
not lvconvert --type raid1 -m 1 $vg/$lv1 "$dev1" "$dev3:0-2"
lvconvert --type raid1 -m 1 $vg/$lv1 "$dev3"
lvconvert -y --type raid1 -m 1 $vg/$lv1 "$dev3"
not lvconvert -m 0 $vg/$lv1
lvconvert -y -m 0 $vg/$lv1
# RAID conversions are not honoring allocation policy!
# lvconvert --type raid1 -m 1 --alloc anywhere $vg/$lv1 "$dev1" "$dev2"
# lvconvert -y --type raid1 -m 1 --alloc anywhere $vg/$lv1 "$dev1" "$dev2"
lvremove -ff $vg
@@ -48,12 +48,12 @@ aux wait_for_sync $vg $lv1
# Should not be enough non-overlapping space.
not lvconvert -m +1 $vg/$lv1 \
"$dev5:0-1" "$dev1" "$dev2" "$dev3" "$dev4"
lvconvert -m +1 $vg/$lv1 "$dev5"
lvconvert -y -m +1 $vg/$lv1 "$dev5"
not lvconvert -m 0 $vg/$lv1
lvconvert -y -m 0 $vg/$lv1
# Should work due to '--alloc anywhere'
# RAID conversion not honoring allocation policy!
#lvconvert -m +1 --alloc anywhere $vg/$lv1 \
#lvconvert -y -m +1 --alloc anywhere $vg/$lv1 \
# "$dev5:0-1" "$dev1" "$dev2" "$dev3" "$dev4"
lvremove -ff $vg
@@ -68,7 +68,7 @@ lvcreate --type raid1 -m 1 -l 3 -n $lv1 $vg \
"$dev1:0-1" "$dev2:0-1" "$dev3:0-1" "$dev4:0-1"
aux wait_for_sync $vg $lv1
aux disable_dev "$dev1"
lvconvert --repair -y $vg/$lv1 "$dev2" "$dev3" "$dev4"
lvconvert -y --repair $vg/$lv1 "$dev2" "$dev3" "$dev4"
#FIXME: ensure non-overlapping images (they should not share PVs)
aux enable_dev "$dev1"
lvremove -ff $vg

View File

@@ -27,7 +27,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 "$DM_DEV_DIR/$vg/$lv"

View File

@@ -132,7 +132,7 @@ aux wait_for_sync $vg $lv1
fsck -fn "$DM_DEV_DIR/$vg/$lv1"
# Convert 3-way to 4-way mirror
lvconvert -m 3 $vg/$lv1
lvconvert -y -m 3 $vg/$lv1
detect_error_leak_
check lv_field $vg/$lv1 segtype "mirror"
check lv_field $vg/$lv1 stripes 4
@@ -149,7 +149,7 @@ check lv_field $vg/$lv1 regionsize "64.00k"
fsck -fn "$DM_DEV_DIR/$vg/$lv1"
## Convert 4-way raid1 to 5-way
lvconvert -m 4 -R 128K $vg/$lv1
lvconvert -y -m 4 -R 128K $vg/$lv1
detect_error_leak_
check lv_field $vg/$lv1 segtype "raid1"
check lv_field $vg/$lv1 stripes 5

View File

@@ -75,14 +75,14 @@ for i in 1 2 3; do
mirrors=$((j - 1))
if [ $i -eq 1 ]
then
[ $mirrors -eq 0 ] && lvconvert -m $mirrors $vg/$lv1
[ $mirrors -eq 0 ] && lvconvert -y -m $mirrors $vg/$lv1
else
if [ $mirrors -eq 0 ]
then
not lvconvert -m $mirrors $vg/$lv1
lvconvert -y -m $mirrors $vg/$lv1
else
lvconvert -m $mirrors $vg/$lv1
lvconvert -y -m $mirrors $vg/$lv1
fi
fi
@@ -105,13 +105,13 @@ lvcreate --type raid1 -m 1 -l 2 -n $lv1 $vg --nosync
not lvconvert -m +1 $vg/$lv1
lvchange --resync -y $vg/$lv1
aux wait_for_sync $vg $lv1
lvconvert -m +1 $vg/$lv1
lvconvert -y -m +1 $vg/$lv1
lvremove -ff $vg
# 3-way to 2-way convert while specifying devices
lvcreate --type raid1 -m 2 -l 2 -n $lv1 $vg "$dev1" "$dev2" "$dev3"
aux wait_for_sync $vg $lv1
lvconvert -m1 $vg/$lv1 "$dev2"
lvconvert -y -m 1 $vg/$lv1 "$dev2"
lvremove -ff $vg
#
@@ -188,7 +188,7 @@ lvremove -ff $vg
# Linear to RAID1 conversion ("raid1" default segtype)
###########################################
lvcreate -aey -l 2 -n $lv1 $vg
lvconvert -m 1 $vg/$lv1 \
lvconvert -y -m 1 $vg/$lv1 \
--config 'global { mirror_segtype_default = "raid1" }'
lvs --noheadings -o attr $vg/$lv1 | grep '^[[:space:]]*r'
lvremove -ff $vg
@@ -197,7 +197,7 @@ lvremove -ff $vg
# Linear to RAID1 conversion (override "mirror" default segtype)
###########################################
lvcreate -aey -l 2 -n $lv1 $vg
lvconvert --type raid1 -m 1 $vg/$lv1 \
lvconvert --yes --type raid1 -m 1 $vg/$lv1 \
--config 'global { mirror_segtype_default = "mirror" }'
lvs --noheadings -o attr $vg/$lv1 | grep '^[[:space:]]*r'
lvremove -ff $vg
@@ -207,7 +207,7 @@ lvremove -ff $vg
###########################################
if [ -e LOCAL_CLVMD ]; then
lvcreate -l 2 -n $lv1 $vg
not lvconvert --type raid1 -m 1 $vg/$lv1 \
not lvconvert -y --type raid1 -m 1 $vg/$lv1 \
--config 'global { mirror_segtype_default = "mirror" }'
lvremove -ff $vg
fi
@@ -218,7 +218,7 @@ fi
for i in 1 2 3 ; do
lvcreate -aey --type mirror -m $i -l 2 -n $lv1 $vg
aux wait_for_sync $vg $lv1
lvconvert --type raid1 $vg/$lv1
lvconvert -y --type raid1 $vg/$lv1
lvremove -ff $vg
done

View File

@@ -54,7 +54,7 @@ lvremove -ff $vg/data2 $vg/data3 $vg/meta1 $vg/meta2
lvconvert --merge $vg/${lv1}_tdata_rimage_1
lvconvert --merge $vg/${lv1}_tmeta_rimage_1
lvconvert -m+1 $vg/${lv1}_tdata "$dev2"
lvconvert -m+1 $vg/${lv1}_tmeta "$dev1"
lvconvert -y -m +1 $vg/${lv1}_tdata "$dev2"
lvconvert -y -m +1 $vg/${lv1}_tmeta "$dev1"
vgremove -ff $vg

View File

@@ -99,7 +99,7 @@ lvremove -ff $vg1
# Convert large 200 TiB linear to RAID1 (belong in different test script?)
#
lvcreate -aey -L 200T -n $lv1 $vg1
lvconvert --type raid1 -m 1 $vg1/$lv1
lvconvert -y --type raid1 -m 1 $vg1/$lv1
check lv_field $vg1/$lv1 size "200.00t"
check raid_leg_status $vg1 $lv1 "aa"
lvremove -ff $vg1

View File

@@ -251,7 +251,7 @@ install_dmsetup_dynamic: dmsetup
install_dmsetup_static: dmsetup.static
$(INSTALL_PROGRAM) -D $< $(staticdir)/$(<F)
$(LN_S) -f $(<F) $(sbindir)/dmstats
$(LN_S) -f $(<F) $(staticdir)/dmstats
install_device-mapper: $(INSTALL_DMSETUP_TARGETS)

View File

@@ -1223,13 +1223,11 @@ arg(maxphysicalvolumes_ARG, 'p', "maxphysicalvolumes", uint32_VAL, 0, 0,
arg(permission_ARG, 'p', "permission", permission_VAL, 0, 0,
"Set access permission to read only \\fBr\\fP or read and write \\fBrw\\fP.\n")
/* FIXME: I left out some of the previous description that didn't sound correct. */
arg(partial_ARG, 'P', "partial", 0, 0, 0,
"When set, the tools will do their best to provide access to VGs\n"
"that are only partially available (one or more PVs belonging\n"
"to the VG are missing from the system). Metadata may not be\n"
"changed with this option.\n")
"Commands will do their best to activate LVs with missing PV extents.\n"
"Missing extents may be replaced with error or zero segments\n"
"according to the lvm.conf missing_stripe_filler setting.\n"
"Metadata may not be changed with this option.\n")
/* Not used */
arg(physicalvolume_ARG, 'P', "physicalvolume", 0, 0, 0, NULL)

View File

@@ -196,7 +196,7 @@ OO_ALL: --commandprofile String, --config String, --debug,
OO_REPORT: --aligned, --all, --binary, --configreport ConfigReport, --foreign,
--ignorelockingfailure, --ignoreskippedcluster, --logonly,
--nameprefixes, --noheadings, --nolocking, --nosuffix,
--options String, --partial, --readonly, --reportformat ReportFmt, --rows,
--options String, --readonly, --reportformat ReportFmt, --rows,
--select String, --separator String, --shared, --sort String,
--trustcache, --unbuffered, --units Units, --unquoted
@@ -234,7 +234,7 @@ OO_LVCHANGE_META: --addtag Tag, --deltag Tag,
# in combination with unrelated metadata changes.
lvchange OO_LVCHANGE_META VG|LV|Tag|Select ...
OO: --activate Active, OO_LVCHANGE
OO: --activate Active, --poll Bool, --monitor Bool, OO_LVCHANGE
ID: lvchange_properties
DESC: Change a general LV attribute.
DESC: For options listed in parentheses, any one is
@@ -275,18 +275,18 @@ DESC: Reconstruct data on specific PVs of a raid LV.
RULE: all not LV_raid0
lvchange --activate Active VG|LV|Tag|Select ...
OO: --activationmode ActivationMode, --partial, --ignoreactivationskip,
--ignorelockingfailure, --sysinit, OO_LVCHANGE
OO: --activationmode ActivationMode, --partial, --poll Bool, --monitor Bool,
--ignoreactivationskip, --ignorelockingfailure, --sysinit, OO_LVCHANGE
ID: lvchange_activate
DESC: Activate or deactivate an LV.
lvchange --refresh VG|LV|Tag|Select ...
OO: --partial, --poll Bool, OO_LVCHANGE
OO: --activationmode ActivationMode, --partial, --poll Bool, --monitor Bool, OO_LVCHANGE
ID: lvchange_refresh
DESC: Reactivate an LV using the latest metadata.
lvchange --monitor Bool VG|LV|Tag|Select ...
OO: --poll Bool, OO_LVCHANGE
OO: OO_LVCHANGE
ID: lvchange_monitor
DESC: Start or stop monitoring an LV from dmeventd.
RULE: all not lv_is_pvmove
@@ -297,7 +297,7 @@ ID: lvchange_poll
DESC: Start or stop processing an LV conversion.
lvchange --persistent y --minor Number LV
OO: --major Number, OO_LVCHANGE
OO: --major Number, --activate Active, --poll Bool, --monitor Bool, OO_LVCHANGE
ID: lvchange_persistent
DESC: Make the minor device number persistent for an LV.
RULE: all not LV_thinpool LV_cachepool
@@ -495,6 +495,7 @@ ID: lvconvert_to_thinpool_or_swap_metadata
DESC: Convert LV to type thin-pool (variant, use \\-\\-type thin-pool).
DESC: Swap metadata LV in a thin pool (variant, use \\-\\-swapmetadata).
FLAGS: PREVIOUS_SYNTAX
RULE: all and lv_is_visible
---
@@ -533,6 +534,7 @@ ID: lvconvert_to_cachepool_or_swap_metadata
DESC: Convert LV to type cache-pool (variant, use \\-\\-type cache-pool).
DESC: Swap metadata LV in a cache pool (variant, use \\-\\-swapmetadata).
FLAGS: PREVIOUS_SYNTAX
RULE: all and lv_is_visible
---
@@ -1177,10 +1179,11 @@ lvdisplay
OO: --aligned, --all, --binary, --colon, --columns,
--configreport ConfigReport, --foreign, --history, --ignorelockingfailure,
--ignoreskippedcluster, --logonly, --maps, --noheadings,
--nosuffix, --options String, --sort String, --partial, --readonly,
--nosuffix, --options String, --sort String, --readonly,
--reportformat ReportFmt, --segments, --select String, --separator String,
--shared, --unbuffered, --units Units
OP: VG|LV|Tag ...
IO: --partial
ID: lvdisplay_general
---
@@ -1294,19 +1297,22 @@ DESC: Resize a pool metadata SubLV by a specified size.
lvs
OO: --history, --segments, OO_REPORT
OP: VG|LV|Tag ...
IO: --partial
ID: lvs_general
---
lvscan
OO: --all, --blockdevice, --ignorelockingfailure, --partial,
OO: --all, --blockdevice, --ignorelockingfailure,
--readonly, --reportformat ReportFmt
IO: --partial
ID: lvscan_general
lvscan --cache_long
OO: --blockdevice, --ignorelockingfailure, --partial,
OO: --blockdevice, --ignorelockingfailure,
--readonly, --reportformat ReportFmt
OP: LV ...
IO: --partial
ID: lvscan_cache
---
@@ -1390,6 +1396,7 @@ ID: pvremove_general
pvs
OO: --segments, OO_REPORT
OP: PV|Tag ...
IO: --partial
ID: pvs_general
---
@@ -1410,9 +1417,10 @@ DESC: Populate the lvmetad cache by scanning PVs.
---
vgcfgbackup
OO: --file String, --foreign, --ignorelockingfailure, --partial, --readonly,
OO: --file String, --foreign, --ignorelockingfailure, --readonly,
--reportformat ReportFmt
OP: VG ...
IO: --partial
ID: vgcfgbackup_general
---
@@ -1462,7 +1470,7 @@ OO_VGCHANGE_META: --addtag Tag, --deltag Tag,
--profile String, --detachprofile, --metadataprofile String
vgchange OO_VGCHANGE_META
OO: OO_VGCHANGE
OO: --poll Bool, OO_VGCHANGE
OP: VG|Tag|Select ...
ID: vgchange_properties
DESC: Change a general VG attribute.
@@ -1489,7 +1497,7 @@ ID: vgchange_activate
DESC: Activate or deactivate LVs.
vgchange --refresh
OO: --sysinit, --ignorelockingfailure, --monitor Bool, --poll Bool, OO_VGCHANGE
OO: --sysinit, --ignorelockingfailure, --poll Bool, OO_VGCHANGE
OP: VG|Tag|Select ...
ID: vgchange_refresh
DESC: Reactivate LVs using the latest metadata.
@@ -1538,9 +1546,10 @@ vgdisplay
OO: --activevolumegroups, --aligned, --binary, --colon, --columns,
--configreport ConfigReport, --foreign, --ignorelockingfailure,
--ignoreskippedcluster, --logonly, --noheadings, --nosuffix,
--options String, --partial, --readonly, --reportformat ReportFmt, --select String,
--options String, --readonly, --reportformat ReportFmt, --select String,
--shared, --short, --separator String, --sort String, --unbuffered, --units Units
OP: VG|Tag ...
IO: --partial
ID: vgdisplay_general
---
@@ -1642,13 +1651,15 @@ DESC: Rename a VG by specifying the VG UUID.
vgs
OO: OO_REPORT
OP: VG|Tag ...
IO: --partial
ID: vgs_general
---
vgscan
OO: --cache_long, --ignorelockingfailure, --mknodes, --notifydbus,
--partial, --reportformat ReportFmt
--reportformat ReportFmt
IO: --partial
ID: vgscan_general
---
@@ -1695,6 +1706,7 @@ ID: devtypes_general
fullreport
OO: OO_REPORT
OP: VG ...
IO: --partial
ID: fullreport_general
lastlog

View File

@@ -425,7 +425,7 @@ static int lvp_name_to_enum(struct command *cmd, char *str)
return lv_props[i].lvp_enum;
}
log_error("Parsing command defs: unknown lv property %s", str);
log_error("Parsing command defs: unknown lv property %s.", str);
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
return LVP_NONE;
}
@@ -441,7 +441,7 @@ static int lvt_name_to_enum(struct command *cmd, char *str)
return lv_types[i].lvt_enum;
}
log_error("Parsing command defs: unknown lv type %s", str);
log_error("Parsing command defs: unknown lv type %s.", str);
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
return LVT_NONE;
}
@@ -522,7 +522,7 @@ static int is_opt_name(char *str)
return 1;
if ((str[0] == '-') && (str[1] != '-'))
log_error("Parsing command defs: options must be specified in long form: %s", str);
log_error("Parsing command defs: options must be specified in long form: %s.", str);
return 0;
}
@@ -624,7 +624,7 @@ static void set_pos_def(struct command *cmd, char *str, struct arg_def *def)
val_enum = val_str_to_num(name);
if (!val_enum) {
log_error("Parsing command defs: unknown pos arg: %s", name);
log_error("Parsing command defs: unknown pos arg: %s.", name);
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
return;
}
@@ -673,7 +673,7 @@ static void set_opt_def(struct command *cmd, char *str, struct arg_def *def)
val_enum = conststr_VAL;
else {
log_error("Parsing command defs: unknown opt arg: %s", name);
log_error("Parsing command defs: unknown opt arg: %s.", name);
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
return;
}
@@ -725,7 +725,7 @@ static void add_oo_definition_line(const char *name, const char *line)
if ((colon = strchr(oo->name, ':')))
*colon = '\0';
else {
log_error("Parsing command defs: invalid OO definition");
log_error("Parsing command defs: invalid OO definition.");
return;
}
@@ -750,7 +750,7 @@ static void append_oo_definition_line(const char *new_line)
len = strlen(old_line) + strlen(new_line) + 2;
line = dm_malloc(len);
if (!line) {
log_error("Parsing command defs: no memory");
log_error("Parsing command defs: no memory.");
return;
}
@@ -797,7 +797,7 @@ static void include_optional_opt_args(struct command *cmd, const char *str)
int line_argc;
if (!(oo_line = get_oo_line(str))) {
log_error("Parsing command defs: no OO line found for %s", str);
log_error("Parsing command defs: no OO line found for %s.", str);
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
return;
}
@@ -940,7 +940,7 @@ static void update_prev_pos_arg(struct command *cmd, char *str, int required)
if (!strcmp(str, "..."))
def->flags |= ARG_DEF_FLAG_MAY_REPEAT;
else {
log_error("Parsing command defs: unknown pos arg: %s", str);
log_error("Parsing command defs: unknown pos arg: %s.", str);
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
return;
}
@@ -967,7 +967,7 @@ static void add_optional_opt_line(struct command *cmd, int argc, char *argv[])
else if (takes_arg)
update_prev_opt_arg(cmd, argv[i], OPTIONAL);
else {
log_error("Parsing command defs: can't parse argc %d argv %s prev %s",
log_error("Parsing command defs: can't parse argc %d argv %s prev %s.",
i, argv[i], argv[i-1]);
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
return;
@@ -993,7 +993,7 @@ static void add_ignore_opt_line(struct command *cmd, int argc, char *argv[])
else if (takes_arg)
update_prev_opt_arg(cmd, argv[i], IGNORE);
else {
log_error("Parsing command defs: can't parse argc %d argv %s prev %s",
log_error("Parsing command defs: can't parse argc %d argv %s prev %s.",
i, argv[i], argv[i-1]);
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
return;
@@ -1028,7 +1028,7 @@ static void add_required_opt_line(struct command *cmd, int argc, char *argv[])
else if (takes_arg)
update_prev_opt_arg(cmd, argv[i], REQUIRED);
else {
log_error("Parsing command defs: can't parse argc %d argv %s prev %s",
log_error("Parsing command defs: can't parse argc %d argv %s prev %s.",
i, argv[i], argv[i-1]);
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
return;
@@ -1053,7 +1053,7 @@ static void include_required_opt_args(struct command *cmd, char *str)
int line_argc;
if (!(oo_line = get_oo_line(str))) {
log_error("Parsing command defs: no OO line found for %s", str);
log_error("Parsing command defs: no OO line found for %s.", str);
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
return;
}
@@ -1107,7 +1107,7 @@ static void add_required_line(struct command *cmd, int argc, char *argv[])
/* set property for previous required_pos_arg */
update_prev_pos_arg(cmd, argv[i], REQUIRED);
} else {
log_error("Parsing command defs: can't parse argc %d argv %s prev %s",
log_error("Parsing command defs: can't parse argc %d argv %s prev %s.",
i, argv[i], argv[i-1]);
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
return;
@@ -1135,7 +1135,7 @@ static void add_rule(struct command *cmd, char *line)
int check = 0;
if (cmd->rule_count == CMD_MAX_RULES) {
log_error("Parsing command defs: too many rules for cmd");
log_error("Parsing command defs: too many rules for cmd.");
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
return;
}
@@ -1165,7 +1165,7 @@ static void add_rule(struct command *cmd, char *line)
else if (!strncmp(arg, "--", 2)) {
if (!rule->opts) {
if (!(rule->opts = dm_malloc(MAX_RULE_OPTS * sizeof(int)))) {
log_error("Parsing command defs: no mem");
log_error("Parsing command defs: no mem.");
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
return;
}
@@ -1174,7 +1174,7 @@ static void add_rule(struct command *cmd, char *line)
if (!rule->check_opts) {
if (!(rule->check_opts = dm_malloc(MAX_RULE_OPTS * sizeof(int)))) {
log_error("Parsing command defs: no mem");
log_error("Parsing command defs: no mem.");
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
return;
}
@@ -1509,7 +1509,7 @@ int define_commands(const char *run_name)
}
if (!skip)
log_error("Parsing command defs: can't process input line %s", line_orig);
log_error("Parsing command defs: can't process input line %s.", line_orig);
}
for (i = 0; i < COMMAND_COUNT; i++) {
@@ -2857,7 +2857,7 @@ static void _print_man_option_desc(struct command_name *cname, int opt_enum)
buf[bi++] = desc[di];
if (bi == DESC_LINE) {
log_error("Parsing command defs: print_man_option_desc line too long");
log_error("Parsing command defs: print_man_option_desc line too long.");
exit(EXIT_FAILURE);
}
@@ -3215,29 +3215,51 @@ static char *upper_command_name(char *str)
#define MAX_MAN_DESC (1024 * 1024)
static void include_description_file(char *name, char *des_file)
static int include_description_file(char *name, char *des_file)
{
char buf[MAX_MAN_DESC];
int fd;
char *buf;
int fd, r = 0;
ssize_t sz;
struct stat stat;
memset(buf, 0, sizeof(buf));
fd = open(des_file, O_RDONLY);
if ((fd = open(des_file, O_RDONLY)) < 0) {
log_error("Failed to open description file %s.", des_file);
return 0;
}
if (fd < 0)
return;
if (fstat(fd, &stat) < 0) {
log_error("Failed to stat description file %s.", des_file);
goto out_close;
}
(void)read(fd, buf, sizeof(buf));
if (stat.st_size > MAX_MAN_DESC) {
log_error("Description file %s is too large.", des_file);
goto out_close;
}
buf[MAX_MAN_DESC-1] = '\0';
if (!(buf = dm_malloc(stat.st_size + 1))) {
log_error("Failed to allocate buffer for description file %s.", des_file);
goto out_close;
}
printf(".SH DESCRIPTION\n");
printf("%s", buf);
if ((sz = read(fd, buf, stat.st_size)) < 0) {
log_error("Failed to read description file %s.", des_file);
goto out_free;
}
buf[sz] = '\0';
printf(".SH DESCRIPTION\n%s", buf);
r = 1;
out_free:
dm_free(buf);
out_close:
close(fd);
return r;
}
static void _print_man(char *name, char *des_file, int secondary)
static int _print_man(char *name, char *des_file, int secondary)
{
struct command_name *cname;
struct command *cmd, *prev_cmd = NULL;
@@ -3291,7 +3313,7 @@ static void _print_man(char *name, char *des_file, int secondary)
prev_cmd = cmd;
if (!(cname = find_command_name(cmd->name)))
return;
return 0;
if (cname->variant_has_ro && cname->variant_has_rp)
printf("\\fB%s\\fP \\fIoption_args\\fP \\fIposition_args\\fP\n", lvmname);
@@ -3320,9 +3342,8 @@ static void _print_man(char *name, char *des_file, int secondary)
_print_man_all_options_list(cname);
}
if (des_file) {
include_description_file(lvmname, des_file);
}
if (des_file && !include_description_file(lvmname, des_file))
return 0;
printf(".SH USAGE\n");
}
@@ -3351,6 +3372,8 @@ static void _print_man(char *name, char *des_file, int secondary)
printf("\n");
continue;
}
return 1;
}
static void _print_man_secondary(char *name)
@@ -3360,10 +3383,8 @@ static void _print_man_secondary(char *name)
int header = 0;
int i;
if (!strncmp(name, "lvm-", 4)) {
name[3] = ' ';
if (!strncmp(name, "lvm-", 4))
name += 4;
}
for (i = 0; i < COMMAND_COUNT; i++) {
@@ -3397,14 +3418,17 @@ static void _print_man_secondary(char *name)
}
}
#define STDOUT_BUF_SIZE (MAX_MAN_DESC + 4 * 1024)
int main(int argc, char *argv[])
{
char *cmdname = NULL;
char *desfile = NULL;
char *stdout_buf;
int primary = 0;
int secondary = 0;
memset(&commands, 0, sizeof(commands));
int r = 0;
size_t sz = STDOUT_BUF_SIZE;
static struct option long_options[] = {
{"primary", no_argument, 0, 'p' },
@@ -3412,6 +3436,13 @@ int main(int argc, char *argv[])
{0, 0, 0, 0 }
};
memset(&commands, 0, sizeof(commands));
if (!(stdout_buf = dm_malloc(sz)))
log_error("Failed to allocate stdout buffer; carrying on with default buffering.");
else
setbuffer(stdout, stdout_buf, sz);
while (1) {
int c;
int option_index = 0;
@@ -3433,12 +3464,16 @@ int main(int argc, char *argv[])
}
if (!primary && !secondary) {
log_error("Usage: %s --primary|--secondary <command> [/path/to/description-file]", argv[0]);
exit(EXIT_FAILURE);
log_error("Usage: %s --primary|--secondary <command> [/path/to/description-file].", argv[0]);
goto out_free;
}
if (optind < argc)
cmdname = strdup(argv[optind++]);
else {
log_error("Missing command name.");
goto out_free;
}
if (optind < argc)
desfile = argv[optind++];
@@ -3450,11 +3485,20 @@ int main(int argc, char *argv[])
factor_common_options();
if (primary)
_print_man(cmdname, desfile, secondary);
else if (secondary)
r = _print_man(cmdname, desfile, secondary);
else if (secondary) {
r = 1;
_print_man_secondary(cmdname);
}
return 0;
out_free:
if (stdout_buf) {
fflush(stdout);
setlinebuf(stdout);
free(stdout_buf);
}
exit(r ? EXIT_SUCCESS: EXIT_FAILURE);
}
#endif

View File

@@ -978,7 +978,7 @@ static void _display_info_long(struct dm_task *dmt, struct dm_info *info)
if ((uuid = dm_task_get_uuid(dmt)) && *uuid)
printf("UUID: %s\n", uuid);
printf("\n");
putchar('\n');
}
static int _display_info(struct dm_task *dmt)
@@ -1612,7 +1612,7 @@ static char _yes_no_prompt(const char *prompt, ...)
} while (!ret || c != '\n');
if (c != '\n')
printf("\n");
putchar('\n');
return ret;
}
@@ -2213,13 +2213,13 @@ static int _status(CMD_ARGS)
printf(FMTu64 " " FMTu64 " %s %s",
start, length, target_type, params);
}
printf("\n");
putchar('\n');
}
matched = 1;
} while (next);
if (multiple_devices && _switches[VERBOSE_ARG] && matched && !ls_only)
printf("\n");
putchar('\n');
if (matched && _switches[EXEC_ARG] && _command_to_exec && !_exec_command(name))
goto_out;
@@ -2374,10 +2374,10 @@ static int _deps(CMD_ARGS)
else
printf(" (%d, %d)", major, minor);
}
printf("\n");
putchar('\n');
if (multiple_devices && _switches[VERBOSE_ARG])
printf("\n");
putchar('\n');
r = 1;
@@ -5110,6 +5110,11 @@ static int _stats_create_file(CMD_ARGS)
regions = dm_stats_create_regions_from_fd(dms, fd, group, precise,
bounds, alias);
if (!regions) {
log_error("Could not create regions from file %s", abspath);
goto bad;
}
if (!_switches[NOMONITOR_ARG] && group) {
if (!dm_stats_start_filemapd(fd, regions[0], abspath, mode,
foreground, verbose))
@@ -5121,11 +5126,6 @@ static int _stats_create_file(CMD_ARGS)
fd = -1;
if (!regions) {
log_error("Could not create regions from file %s", abspath);
goto bad;
}
for (region = regions; *region != DM_STATS_REGIONS_ALL; region++)
count++;
@@ -5716,25 +5716,21 @@ static int _stats_update_file(CMD_ARGS)
* If starting the daemon fails, fall back to a direct update.
*/
if (!_switches[NOMONITOR_ARG]) {
if (!dm_stats_start_filemapd(fd, group_id, abspath, mode,
foreground, verbose)) {
log_warn("Failed to start filemap monitoring daemon.");
goto fallback;
}
goto out;
if (dm_stats_start_filemapd(fd, group_id, abspath, mode,
foreground, verbose))
goto out;
log_warn("Failed to start filemap monitoring daemon.");
/* fall back to one-shot update */
}
fallback:
/*
* --nomonitor case - perform a one-shot update directly from dmstats.
* --nomonitor and fall back case - perform a one-shot update directly
* from dmsetup.
*/
regions = dm_stats_update_regions_from_fd(dms, fd, group_id);
if (close(fd))
log_error("Error closing %s", abspath);
fd = -1;
if (!regions) {
log_error("Could not update regions from file %s", abspath);
goto bad;
@@ -5753,6 +5749,9 @@ fallback:
path, group_id, count);
out:
if (close(fd))
log_error("Error closing %s", abspath);
dm_free(regions);
dm_free(abspath);
dm_stats_destroy(dms);
@@ -5951,7 +5950,7 @@ static void _stats_usage(FILE *out)
fprintf(out, "\n<device> may be device name or (if only one) -u <uuid> or -j <major> -m <minor>\n");
fprintf(out, "<fields> are comma-separated. Use 'help -c' for list.\n");
fprintf(out, "\n");
putc('\n', out);
}
static void _dmsetup_usage(FILE *out)
@@ -5982,7 +5981,7 @@ static void _dmsetup_usage(FILE *out)
fprintf(out, "Options are: devno, devname, blkdevname.\n");
fprintf(out, "Tree specific options are: ascii, utf, vt100; compact, inverted, notrunc;\n"
" blkdevname, [no]device, active, open, rw and uuid.\n");
fprintf(out, "\n");
putc('\n', out);
}
static void _losetup_usage(FILE *out)
@@ -7080,7 +7079,8 @@ doit:
dm_report_output(_report);
if (_count > 1 && r) {
printf("\n");
putchar('\n');
fflush(stdout);
/* wait for --interval and update timestamps */
if (!_do_report_wait()) {
ret = 1;

View File

@@ -1,6 +1,6 @@
/*
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004-2016 Red Hat, Inc. All rights reserved.
* Copyright (C) 2004-2017 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -17,8 +17,32 @@
#include "memlock.h"
/*
* Passed back from callee to request caller to
* commit and optionally reload metadata.
*
* This allows for one metadata update per command run
* (unless mandatory interim ones in callee).
*/
#define MR_COMMIT 0x1 /* Commit metadata, don't reload table(s) */
#define MR_RELOAD 0x2 /* Commit metadata _and_ reload table(s) */
static int _vg_write_commit(const struct logical_volume *lv, const char *what)
{
log_very_verbose("Updating %s%slogical volume %s on disk(s).",
what ? : "", what ? " " : "", display_lvname(lv));
if (!vg_write(lv->vg) || !vg_commit(lv->vg)) {
log_error("Failed to update %smetadata of %s on disk.",
what ? : "", display_lvname(lv));
return 0;
}
return 1;
}
static int _lvchange_permission(struct cmd_context *cmd,
struct logical_volume *lv)
struct logical_volume *lv,
uint32_t *mr)
{
uint32_t lv_access;
struct lvinfo info;
@@ -67,14 +91,15 @@ static int _lvchange_permission(struct cmd_context *cmd,
display_lvname(lv));
}
if (!lv_update_and_reload(lv))
return_0;
/* Request caller to commit and reload metadata */
*mr |= MR_RELOAD;
return 1;
}
static int _lvchange_pool_update(struct cmd_context *cmd,
struct logical_volume *lv)
struct logical_volume *lv,
uint32_t *mr)
{
int update = 0;
unsigned val;
@@ -110,12 +135,18 @@ static int _lvchange_pool_update(struct cmd_context *cmd,
if (!update)
return 0;
if (!lv_update_and_reload(lv))
return_0;
/* Request caller to commit and reload metadata */
*mr |= MR_RELOAD;
return 1;
}
/*
* The --monitor y|n value is read from dmeventd_monitor_mode(),
* which was set by the init_dmeventd_monitor() /
* get_activation_monitoring_mode() / arg_int_value(monitor_ARG).
*/
static int _lvchange_monitoring(struct cmd_context *cmd,
struct logical_volume *lv)
{
@@ -127,13 +158,23 @@ static int _lvchange_monitoring(struct cmd_context *cmd,
return 0;
}
if ((dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) &&
!monitor_dev_for_events(cmd, lv, 0, dmeventd_monitor_mode()))
return_0;
if (dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) {
if (dmeventd_monitor_mode())
log_verbose("Monitoring LV %s", display_lvname(lv));
else
log_verbose("Unmonitoring LV %s", display_lvname(lv));
if (!monitor_dev_for_events(cmd, lv, 0, dmeventd_monitor_mode()))
return_0;
}
return 1;
}
/*
* The --poll y|n value is read from background_polling(),
* which was set by init_background_polling(arg_int_value(poll_ARG)).
*/
static int _lvchange_background_polling(struct cmd_context *cmd,
struct logical_volume *lv)
{
@@ -144,8 +185,10 @@ static int _lvchange_background_polling(struct cmd_context *cmd,
return 0;
}
if (background_polling())
if (background_polling()) {
log_verbose("Polling LV %s", display_lvname(lv));
lv_spawn_background_polling(cmd, lv);
}
return 1;
}
@@ -345,12 +388,8 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
if (!seg_is_raid(seg) && !seg->log_lv) {
if (lv_is_not_synced(lv)) {
lv->status &= ~LV_NOTSYNCED;
log_very_verbose("Updating logical volume %s on disk(s).",
display_lvname(lv));
if (!vg_write(lv->vg) || !vg_commit(lv->vg)) {
log_error("Failed to update metadata on disk.");
if (!_vg_write_commit(lv, NULL))
return 0;
}
}
if (!_reactivate_lv(lv, active, exclusive)) {
@@ -375,8 +414,7 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
return 0;
}
if (!vg_write(lv->vg) || !vg_commit(lv->vg)) {
log_error("Failed to update intermediate VG metadata on disk.");
if (!_vg_write_commit(lv, "intermediate")) {
if (!_reactivate_lv(lv, active, exclusive))
stack;
return 0;
@@ -426,11 +464,8 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
return 0;
}
if (!vg_write(lv->vg) || !vg_commit(lv->vg)) {
log_error("Failed to update metadata on disk for %s.",
display_lvname(lv));
if (!_vg_write_commit(lv, NULL))
return 0;
}
if (!_reactivate_lv(lv, active, exclusive)) {
backup(lv->vg);
@@ -444,7 +479,9 @@ static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
return 1;
}
static int _lvchange_alloc(struct cmd_context *cmd, struct logical_volume *lv)
static int _lvchange_alloc(struct cmd_context *cmd,
struct logical_volume *lv,
uint32_t *mr)
{
int want_contiguous = arg_int_value(cmd, contiguous_ARG, 0);
alloc_policy_t alloc = (alloc_policy_t)
@@ -467,16 +504,16 @@ static int _lvchange_alloc(struct cmd_context *cmd, struct logical_volume *lv)
log_very_verbose("Updating logical volume %s on disk(s).", display_lvname(lv));
/* No need to suspend LV for this change */
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
backup(lv->vg);
/* Request caller to commit metadata */
*mr |= MR_COMMIT;
return 1;
}
static int _lvchange_errorwhenfull(struct cmd_context *cmd,
struct logical_volume *lv)
struct logical_volume *lv,
uint32_t *mr)
{
unsigned ewf = arg_int_value(cmd, errorwhenfull_ARG, 0);
@@ -491,14 +528,15 @@ static int _lvchange_errorwhenfull(struct cmd_context *cmd,
else
lv->status &= ~LV_ERROR_WHEN_FULL;
if (!lv_update_and_reload(lv))
return_0;
/* Request caller to commit and reload metadata */
*mr |= MR_RELOAD;
return 1;
}
static int _lvchange_readahead(struct cmd_context *cmd,
struct logical_volume *lv)
struct logical_volume *lv,
uint32_t *mr)
{
unsigned read_ahead = 0;
unsigned pagesize = (unsigned) lvm_getpagesize() >> SECTOR_SHIFT;
@@ -537,14 +575,15 @@ static int _lvchange_readahead(struct cmd_context *cmd,
log_verbose("Setting read ahead to %u for %s.",
read_ahead, display_lvname(lv));
if (!lv_update_and_reload(lv))
return_0;
/* Request caller to commit and reload metadata */
*mr |= MR_RELOAD;
return 1;
}
static int _lvchange_persistent(struct cmd_context *cmd,
struct logical_volume *lv)
struct logical_volume *lv,
uint32_t *mr)
{
enum activation_change activate = CHANGE_AN;
@@ -600,11 +639,8 @@ static int _lvchange_persistent(struct cmd_context *cmd,
lv->major, lv->minor, display_lvname(lv));
}
log_very_verbose("Updating logical volume %s on disk(s).",
display_lvname(lv));
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
if (!_vg_write_commit(lv, NULL))
return 0;
if (activate != CHANGE_AN) {
log_verbose("Re-activating logical volume %s.", display_lvname(lv));
@@ -615,12 +651,12 @@ static int _lvchange_persistent(struct cmd_context *cmd,
}
}
backup(lv->vg);
return 1;
}
static int _lvchange_cache(struct cmd_context *cmd, struct logical_volume *lv)
static int _lvchange_cache(struct cmd_context *cmd,
struct logical_volume *lv,
uint32_t *mr)
{
cache_metadata_format_t format;
cache_mode_t mode;
@@ -655,8 +691,8 @@ static int _lvchange_cache(struct cmd_context *cmd, struct logical_volume *lv)
!cache_set_policy(first_seg(lv), name, settings))
goto_out;
if (!lv_update_and_reload(lv))
goto_out;
/* Request caller to commit and reload metadata */
*mr |= MR_RELOAD;
r = 1;
out:
@@ -666,7 +702,8 @@ out:
return r;
}
static int _lvchange_tag(struct cmd_context *cmd, struct logical_volume *lv, int arg)
static int _lvchange_tag(struct cmd_context *cmd, struct logical_volume *lv,
int arg, uint32_t *mr)
{
if (!change_tag(cmd, NULL, lv, NULL, arg))
return_0;
@@ -674,10 +711,9 @@ static int _lvchange_tag(struct cmd_context *cmd, struct logical_volume *lv, int
log_very_verbose("Updating logical volume %s on disk(s).", display_lvname(lv));
/* No need to suspend LV for this change */
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
backup(lv->vg);
/* Request caller to commit and reload metadata */
*mr |= MR_COMMIT;
return 1;
}
@@ -730,7 +766,8 @@ static int _lvchange_rebuild(struct logical_volume *lv)
return lv_raid_rebuild(lv, rebuild_pvh);
}
static int _lvchange_writemostly(struct logical_volume *lv)
static int _lvchange_writemostly(struct logical_volume *lv,
uint32_t *mr)
{
int pv_count, i = 0;
uint32_t s, writemostly;
@@ -847,13 +884,14 @@ static int _lvchange_writemostly(struct logical_volume *lv)
}
}
if (!lv_update_and_reload(lv))
return_0;
/* Request caller to commit and reload metadata */
*mr |= MR_RELOAD;
return 1;
}
static int _lvchange_recovery_rate(struct logical_volume *lv)
static int _lvchange_recovery_rate(struct logical_volume *lv,
uint32_t *mr)
{
struct cmd_context *cmd = lv->vg->cmd;
struct lv_segment *raid_seg = first_seg(lv);
@@ -871,13 +909,14 @@ static int _lvchange_recovery_rate(struct logical_volume *lv)
return 0;
}
if (!lv_update_and_reload(lv))
return_0;
/* Request caller to commit and reload metadata */
*mr |= MR_RELOAD;
return 1;
}
static int _lvchange_profile(struct logical_volume *lv)
static int _lvchange_profile(struct logical_volume *lv,
uint32_t *mr)
{
const char *old_profile_name, *new_profile_name;
struct profile *new_profile;
@@ -900,15 +939,13 @@ static int _lvchange_profile(struct logical_volume *lv)
log_verbose("Changing configuration profile for LV %s: %s -> %s.",
display_lvname(lv), old_profile_name, new_profile_name);
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
backup(lv->vg);
/* Request caller to commit metadata */
*mr |= MR_COMMIT;
return 1;
}
static int _lvchange_activation_skip(struct logical_volume *lv)
static int _lvchange_activation_skip(struct logical_volume *lv, uint32_t *mr)
{
int skip = arg_int_value(lv->vg->cmd, setactivationskip_ARG, 0);
@@ -917,14 +954,78 @@ static int _lvchange_activation_skip(struct logical_volume *lv)
log_verbose("Changing activation skip flag to %s for LV %s.",
display_lvname(lv), skip ? "enabled" : "disabled");
if (!vg_write(lv->vg) || !vg_commit(lv->vg))
return_0;
backup(lv->vg);
/* Request caller to commit+backup metadata */
*mr |= MR_COMMIT;
return 1;
}
/* Update and reload or commit and/or backup metadata for @lv as requested by @mr */
static int _commit_reload(struct logical_volume *lv, uint32_t mr)
{
if (mr & MR_RELOAD) {
if (!lv_update_and_reload(lv))
return_0;
} else if ((mr & MR_COMMIT) &&
!_vg_write_commit(lv, NULL))
return 0;
return 1;
}
/* Helper: check @opt_num is listed in @opts array */
static int _is_option_listed(int opt_enum, int *options)
{
int i;
for (i = 0; options[i] != -1; i++)
if (opt_enum == options[i])
return 1;
return 0;
}
/* Check @opt_enum is an option allowing group commit/reload */
static int _option_allows_group_commit(int opt_enum)
{
int options[] = {
permission_ARG,
alloc_ARG,
contiguous_ARG,
errorwhenfull_ARG,
readahead_ARG,
persistent_ARG,
addtag_ARG,
deltag_ARG,
writemostly_ARG,
writebehind_ARG,
minrecoveryrate_ARG,
maxrecoveryrate_ARG,
profile_ARG,
metadataprofile_ARG,
detachprofile_ARG,
setactivationskip_ARG,
-1
};
return _is_option_listed(opt_enum, options);
}
/* Check @opt_enum requires direct commit/reload */
static int _option_requires_direct_commit(int opt_enum)
{
int options[] = {
discards_ARG,
zero_ARG,
cachemode_ARG,
cachepolicy_ARG,
cachesettings_ARG,
-1
};
return _is_option_listed(opt_enum, options);
}
/*
* For each lvchange command definintion:
*
@@ -938,91 +1039,106 @@ static int _lvchange_activation_skip(struct logical_volume *lv)
* . (or all the code could live in the _single fn)
*/
/*
* Process 2 types of options differently
* minimizing metadata commits and table reloads:
*
* 1. process group of options not requiring metadata commit(, reload)
* for each option and commit(, reload) metadata for the whole group
*
* 2. process the options requiring metadata commit+reload per option
*/
static int _lvchange_properties_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
{
int doit = 0, docmds = 0;
int docmds = 0, doit = 0, doit_total = 0, change_msg = 1, second_group = 0;
int i, opt_enum;
uint32_t mr = 0;
/*
* If a persistent lv lock already exists from activation
* (with the needed mode or higher), this will be a no-op.
* Otherwise, the lv lock will be taken as non-persistent
* and released when this command exits.
*/
if (!lockd_lv(cmd, lv, "ex", 0)) {
stack;
return ECMD_FAILED;
}
/* If LV is inactive here, ensure it's not active elsewhere. */
if (!lockd_lv(cmd, lv, "ex", 0))
return_ECMD_FAILED;
/* First group of options which allow for one metadata commit/update for the whole group */
for (i = 0; i < cmd->command->ro_count; i++) {
opt_enum = cmd->command->required_opt_args[i].opt;
if (!arg_is_set(cmd, opt_enum))
continue;
/*
* Skip options requiring direct commit/reload
* to process them in the second step.
*/
if (_option_requires_direct_commit(opt_enum)) {
second_group++;
continue;
}
/* Archive will only happen once per run. */
if (!archive(lv->vg))
return_ECMD_FAILED;
docmds++;
/*
* Process the following options and to a single
* metadata commit/reload for the whole group.
*/
switch (opt_enum) {
case permission_ARG:
doit += _lvchange_permission(cmd, lv);
docmds++;
doit += _lvchange_permission(cmd, lv, &mr);
break;
case alloc_ARG:
case contiguous_ARG:
doit += _lvchange_alloc(cmd, lv);
docmds++;
doit += _lvchange_alloc(cmd, lv, &mr);
break;
case errorwhenfull_ARG:
doit += _lvchange_errorwhenfull(cmd, lv);
docmds++;
doit += _lvchange_errorwhenfull(cmd, lv, &mr);
break;
case readahead_ARG:
doit += _lvchange_readahead(cmd, lv);
docmds++;
doit += _lvchange_readahead(cmd, lv, &mr);
break;
case persistent_ARG:
doit += _lvchange_persistent(cmd, lv);
break;
case discards_ARG:
case zero_ARG:
doit += _lvchange_pool_update(cmd, lv);
docmds++;
doit += _lvchange_persistent(cmd, lv, &mr);
break;
case addtag_ARG:
case deltag_ARG:
doit += _lvchange_tag(cmd, lv, opt_enum);
docmds++;
doit += _lvchange_tag(cmd, lv, opt_enum, &mr);
break;
case writemostly_ARG:
case writebehind_ARG:
doit += _lvchange_writemostly(lv);
docmds++;
doit += _lvchange_writemostly(lv, &mr);
break;
case minrecoveryrate_ARG:
case maxrecoveryrate_ARG:
doit += _lvchange_recovery_rate(lv);
docmds++;
doit += _lvchange_recovery_rate(lv, &mr);
break;
case profile_ARG:
case metadataprofile_ARG:
case detachprofile_ARG:
doit += _lvchange_profile(lv);
docmds++;
doit += _lvchange_profile(lv, &mr);
break;
case setactivationskip_ARG:
doit += _lvchange_activation_skip(lv);
break;
case cachemode_ARG:
case cachepolicy_ARG:
case cachesettings_ARG:
doit += _lvchange_cache(cmd, lv);
docmds++;
doit += _lvchange_activation_skip(lv, &mr);
break;
default:
@@ -1031,12 +1147,88 @@ static int _lvchange_properties_single(struct cmd_context *cmd,
}
}
if (doit)
log_print_unless_silent("Logical volume %s changed.", display_lvname(lv));
/* Any options of the first group processed? */
if (docmds) {
doit_total = doit;
doit = 0;
if (doit != docmds)
/* Display any logical volume change */
if (doit_total) {
log_print_unless_silent("Logical volume %s changed.", display_lvname(lv));
change_msg = 0;
/* Commit(, reload) metadata once for whole processed group of options */
if (!_commit_reload(lv, mr))
return_ECMD_FAILED;
}
/* Bail out if any processing of an option in the first group failed */
if (docmds != doit_total)
return_ECMD_FAILED;
/* Do backup if processing the first group of options went ok */
backup(lv->vg);
} else if (!second_group)
return_ECMD_FAILED;
/* Second group of options which need per option metadata commit+reload(s) */
for (i = 0; i < cmd->command->ro_count; i++) {
opt_enum = cmd->command->required_opt_args[i].opt;
if (!arg_is_set(cmd, opt_enum))
continue;
/* Skip any of the already processed options which allowed for group commit/reload */
if (_option_allows_group_commit(opt_enum))
continue;
/* Archive will only happen once per run */
if (!archive(lv->vg))
return_ECMD_FAILED;
mr = 0;
/* Run commit and reload after processing each of the following options */
switch (opt_enum) {
case discards_ARG:
case zero_ARG:
docmds++;
doit += _lvchange_pool_update(cmd, lv, &mr);
break;
case cachemode_ARG:
case cachepolicy_ARG:
case cachesettings_ARG:
docmds++;
doit += _lvchange_cache(cmd, lv, &mr);
break;
default:
log_error(INTERNAL_ERROR "Failed to check for option %s",
arg_long_option_name(i));
}
/* Display any logical volume change unless already displayed in step 1. */
if (doit && change_msg) {
log_print_unless_silent("Logical volume %s changed.", display_lvname(lv));
change_msg = 0;
}
/* Commit(,reload) metadata per processed option */
if (!_commit_reload(lv, mr))
return_ECMD_FAILED;
}
doit_total += doit;
/* Bail out if no options wwre found or any processing of an option in the second group failed */
if (!docmds || docmds != doit_total)
return_ECMD_FAILED;
/* Do backup if processing the second group of options went ok */
backup(lv->vg);
return ECMD_PROCESSED;
}
@@ -1068,6 +1260,7 @@ int lvchange_properties_cmd(struct cmd_context *cmd, int argc, char **argv)
* A command def rule allows only some options when LV is partial,
* so handles_missing_pvs will only affect those.
*/
init_background_polling(arg_is_set(cmd, sysinit_ARG) ? 0 : arg_int_value(cmd, poll_ARG, DEFAULT_BACKGROUND_POLLING));
cmd->handles_missing_pvs = 1;
ret = process_each_lv(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE,
NULL, &_lvchange_properties_check, &_lvchange_properties_single);
@@ -1092,6 +1285,9 @@ int lvchange_properties_cmd(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, activate_ARG)) {
log_warn("WARNING: Combining activation change with other commands is not advised.");
ret = lvchange_activate_cmd(cmd, argc, argv);
} else if (arg_is_set(cmd, monitor_ARG) || arg_is_set(cmd, poll_ARG)) {
ret = lvchange_monitor_poll_cmd(cmd, argc, argv);
}
return ret;
@@ -1167,6 +1363,9 @@ static int _lvchange_activate_check(struct cmd_context *cmd,
int lvchange_activate_cmd(struct cmd_context *cmd, int argc, char **argv)
{
int ret;
init_background_polling(arg_is_set(cmd, sysinit_ARG) ? 0 : arg_int_value(cmd, poll_ARG, DEFAULT_BACKGROUND_POLLING));
cmd->handles_missing_pvs = 1;
cmd->lockd_vg_default_sh = 1;
@@ -1181,8 +1380,16 @@ int lvchange_activate_cmd(struct cmd_context *cmd, int argc, char **argv)
if (is_change_activating((activation_change_t)arg_uint_value(cmd, activate_ARG, CHANGE_AY)))
cmd->lockd_vg_enforce_sh = 1;
return process_each_lv(cmd, argc, argv, NULL, NULL, 0,
NULL, &_lvchange_activate_check, &_lvchange_activate_single);
ret = process_each_lv(cmd, argc, argv, NULL, NULL, 0,
NULL, &_lvchange_activate_check, &_lvchange_activate_single);
if (ret != ECMD_PROCESSED)
return ret;
if (arg_is_set(cmd, monitor_ARG) || arg_is_set(cmd, poll_ARG))
ret = lvchange_monitor_poll_cmd(cmd, argc, argv);
return ret;
}
static int _lvchange_refresh_single(struct cmd_context *cmd,
@@ -1202,6 +1409,10 @@ static int _lvchange_refresh_single(struct cmd_context *cmd,
!_lvchange_background_polling(cmd, lv))
return_ECMD_FAILED;
if (arg_is_set(cmd, monitor_ARG) &&
!_lvchange_monitoring(cmd, lv))
return_ECMD_FAILED;
return ECMD_PROCESSED;
}
@@ -1221,6 +1432,7 @@ static int _lvchange_refresh_check(struct cmd_context *cmd,
int lvchange_refresh_cmd(struct cmd_context *cmd, int argc, char **argv)
{
init_background_polling(arg_is_set(cmd, sysinit_ARG) ? 0 : arg_int_value(cmd, poll_ARG, DEFAULT_BACKGROUND_POLLING));
cmd->handles_missing_pvs = 1;
cmd->lockd_vg_default_sh = 1;
@@ -1232,6 +1444,10 @@ static int _lvchange_resync_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
{
/* If LV is inactive here, ensure it's not active elsewhere. */
if (!lockd_lv(cmd, lv, "ex", 0))
return_ECMD_FAILED;
if (!_lvchange_resync(cmd, lv))
return_ECMD_FAILED;
@@ -1283,6 +1499,10 @@ static int _lvchange_syncaction_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
{
/* If LV is inactive here, ensure it's not active elsewhere. */
if (!lockd_lv(cmd, lv, "ex", 0))
return_ECMD_FAILED;
if (!lv_raid_message(lv, arg_str_value(cmd, syncaction_ARG, NULL)))
return_ECMD_FAILED;
@@ -1313,6 +1533,10 @@ static int _lvchange_rebuild_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
{
/* If LV is inactive here, ensure it's not active elsewhere. */
if (!lockd_lv(cmd, lv, "ex", 0))
return_ECMD_FAILED;
if (!_lvchange_rebuild(lv))
return_ECMD_FAILED;
@@ -1370,6 +1594,7 @@ static int _lvchange_monitor_poll_check(struct cmd_context *cmd,
int lvchange_monitor_poll_cmd(struct cmd_context *cmd, int argc, char **argv)
{
init_background_polling(arg_is_set(cmd, sysinit_ARG) ? 0 : arg_int_value(cmd, poll_ARG, DEFAULT_BACKGROUND_POLLING));
cmd->handles_missing_pvs = 1;
return process_each_lv(cmd, argc, argv, NULL, NULL, 0,
NULL, &_lvchange_monitor_poll_check, &_lvchange_monitor_poll_single);
@@ -1379,7 +1604,16 @@ static int _lvchange_persistent_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
{
if (!_lvchange_persistent(cmd, lv))
uint32_t mr = 0;
/* If LV is inactive here, ensure it's not active elsewhere. */
if (!lockd_lv(cmd, lv, "ex", 0))
return_ECMD_FAILED;
if (!_lvchange_persistent(cmd, lv, &mr))
return_ECMD_FAILED;
if (!_commit_reload(lv, mr))
return_ECMD_FAILED;
return ECMD_PROCESSED;
@@ -1401,9 +1635,27 @@ static int _lvchange_persistent_check(struct cmd_context *cmd,
int lvchange_persistent_cmd(struct cmd_context *cmd, int argc, char **argv)
{
int ret;
init_background_polling(arg_is_set(cmd, sysinit_ARG) ? 0 : arg_int_value(cmd, poll_ARG, DEFAULT_BACKGROUND_POLLING));
cmd->handles_missing_pvs = 1;
return process_each_lv(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE,
NULL, &_lvchange_persistent_check, &_lvchange_persistent_single);
ret = process_each_lv(cmd, argc, argv, NULL, NULL, READ_FOR_UPDATE,
NULL, &_lvchange_persistent_check, &_lvchange_persistent_single);
if (ret != ECMD_PROCESSED)
return ret;
/* See comment in lvchange_properties about needing to allow these. */
if (arg_is_set(cmd, activate_ARG)) {
log_warn("WARNING: Combining activation change with other commands is not advised.");
ret = lvchange_activate_cmd(cmd, argc, argv);
} else if (arg_is_set(cmd, monitor_ARG) || arg_is_set(cmd, poll_ARG)) {
ret = lvchange_monitor_poll_cmd(cmd, argc, argv);
}
return ret;
}
int lvchange(struct cmd_context *cmd, int argc, char **argv)
@@ -1412,4 +1664,3 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
cmd->command->command_index, cmd->command->command_id);
return ECMD_FAILED;
}

View File

@@ -1685,6 +1685,10 @@ static int _lvconvert_raid_types(struct cmd_context *cmd, struct logical_volume
struct lv_segment *seg = first_seg(lv);
int ret = 0;
/* If LV is inactive here, ensure it's not active elsewhere. */
if (!lockd_lv(cmd, lv, "ex", 0))
return_ECMD_FAILED;
/* Set up segtype either from type_str or else to match the existing one. */
if (!*lp->type_str)
lp->segtype = seg->segtype;
@@ -2654,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)
@@ -2734,6 +2743,10 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
return 0;
}
/* If LV is inactive here, ensure it's not active elsewhere. */
if (!lockd_lv(cmd, lv, "ex", 0))
return 0;
/*
* If an existing LV is to be used as the metadata LV,
* verify that it's in a usable state. These checks are
@@ -2742,6 +2755,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;
@@ -2760,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));
@@ -2789,6 +2813,10 @@ static int _lvconvert_to_pool(struct cmd_context *cmd,
display_lvname(metadata_lv));
return 0;
}
/* If LV is inactive here, ensure it's not active elsewhere. */
if (!lockd_lv(cmd, metadata_lv, "ex", 0))
return 0;
}
if (!get_pool_params(cmd, pool_segtype,
@@ -3135,6 +3163,10 @@ static int _lvconvert_to_cache_vol(struct cmd_context *cmd,
struct dm_config_tree *policy_settings = NULL;
int r = 0;
/* If LV is inactive here, ensure it's not active elsewhere. */
if (!lockd_lv(cmd, lv, "ex", 0))
return_0;
if (!validate_lv_cache_create_pool(cachepool_lv))
return_0;
@@ -3744,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;
@@ -3794,7 +3826,13 @@ 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 (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));
goto out;
@@ -3892,7 +3930,13 @@ 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 (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));
goto out;
@@ -3958,6 +4002,12 @@ static int _lvconvert_swap_pool_metadata_single(struct cmd_context *cmd,
struct logical_volume *metadata_lv;
const char *metadata_name;
if (is_lockd_type(lv->vg->lock_type)) {
/* FIXME: need to swap locks betwen LVs? */
log_error("Unable to swap pool metadata in VG with lock_type %s", lv->vg->lock_type);
goto out;
}
if (!(metadata_name = arg_str_value(cmd, poolmetadata_ARG, NULL)))
goto_out;
@@ -4039,7 +4089,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;
@@ -4133,6 +4183,10 @@ static int _lvconvert_split_cachepool_single(struct cmd_context *cmd,
return ECMD_FAILED;
}
/* If LV is inactive here, ensure it's not active elsewhere. */
if (!lockd_lv(cmd, cache_lv, "ex", 0))
return_0;
switch (cmd->command->command_enum) {
case lvconvert_split_and_keep_cachepool_CMD:
ret = _lvconvert_split_and_keep_cachepool(cmd, cache_lv, cachepool_lv);

View File

@@ -1154,7 +1154,7 @@ static void _set_valid_args_for_command_name(int ci)
int num_args = 0;
int opt_enum; /* foo_ARG from args.h */
int opt_syn;
int i, ro, oo;
int i, ro, oo, io;
/*
* all_args is indexed by the foo_ARG enum vals
@@ -1173,6 +1173,10 @@ static void _set_valid_args_for_command_name(int ci)
opt_enum = commands[i].optional_opt_args[oo].opt;
all_args[opt_enum] = 1;
}
for (io = 0; io < commands[i].io_count; io++) {
opt_enum = commands[i].ignore_opt_args[io].opt;
all_args[opt_enum] = 1;
}
}
for (i = 0; i < ARG_COUNT; i++) {
@@ -1334,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;
@@ -1621,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;
}
@@ -1691,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;
}
@@ -1826,15 +1855,18 @@ static int _usage(const char *name, int longhelp, int skip_notes)
if ((_cmdline.commands[i].cmd_flags & CMD_FLAG_SECONDARY_SYNTAX) && !show_full)
continue;
print_usage(&_cmdline.commands[i], show_full, 1);
log_very_verbose("Command definition index %d enum %d id %s",
_cmdline.commands[i].command_index,
_cmdline.commands[i].command_enum,
_cmdline.commands[i].command_id);
print_usage(&_cmdline.commands[i], 1, 1);
cmd = &_cmdline.commands[i];
}
/* Common options are printed once for all variants of a command name. */
if (show_full) {
print_usage_common_cmd(cname, cmd);
print_usage_common_lvm(cname, cmd);
}
print_usage_common_cmd(cname, cmd);
print_usage_common_lvm(cname, cmd);
if (skip_notes)
return 1;

View File

@@ -38,8 +38,8 @@ static int _vgrename_single(struct cmd_context *cmd, const char *vg_name,
struct volume_group *vg, struct processing_handle *handle)
{
struct vgrename_params *vp = (struct vgrename_params *) handle->custom_handle;
char old_path[NAME_LEN];
char new_path[NAME_LEN];
char old_path[PATH_MAX];
char new_path[PATH_MAX];
struct id id;
const char *name;
char *dev_dir;
@@ -136,8 +136,12 @@ static int _vgrename_single(struct cmd_context *cmd, const char *vg_name,
goto error;
}
sprintf(old_path, "%s%s", dev_dir, vg_name);
sprintf(new_path, "%s%s", dev_dir, vp->vg_name_new);
if ((dm_snprintf(old_path, sizeof(old_path), "%s%s", dev_dir, vg_name) < 0) ||
(dm_snprintf(new_path, sizeof(new_path), "%s%s", dev_dir, vp->vg_name_new) < 0)) {
log_error("Renaming path is too long %s/%s %s/%s",
dev_dir, vg_name, dev_dir, vp->vg_name_new);
goto error;
}
if (activation() && dir_exists(old_path)) {
log_verbose("Renaming \"%s\" to \"%s\"", old_path, new_path);