1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 11:55:55 +03:00
Commit Graph

1523 Commits

Author SHA1 Message Date
Dave Wysochanski
a375ced300 Move code into pv_change_metadataignore library function.
In preparation to call this from both pvcreate as well as pvchange,
move the guts of metadataignore into a library function.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-29 21:32:44 +00:00
Dave Wysochanski
18787def0b Fix compile warning in vgchange.c regarding mda_copies initialization. 2010-06-28 21:35:00 +00:00
Dave Wysochanski
a9d8bf269a Allow 'all' and 'unmanaged' values for --vgmetadatacopies.
Allowing an 'all' and 'unmanaged' value is more intuitive, and
provides a simple way for users to get back to original LVM behavior
of metadata written to all PVs in the volume group.

If the user requests "--vgmetadatacopies unmanaged", this instructs
LVM not to manage the ignore bits to achieve a specific number of
metadata copies in the volume group.  The user is free to use
"pvchange --metadataignore" to control the mdas on a per-PV basis.
If the user requests "--vgmetadatacopies all", this instructs LVM
to do 2 things: 1) clear all ignore bits, and 2) set the "unmanaged"
policy going forward.

Internally, we use the special MAX_UINT32 value to indicate 'all'.
This 'just' works since it's the largest value possible for the
field and so all 'ignore' bits on all mdas in the VG will get
cleared inside _vg_metadata_balance().  However, after we've
called the _vg_metadata_balance function, we check for the special
'all' value, and if set, we write the "unmanaged" value into the
metadata.  As such, the 'all' value is never written to disk.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:40:01 +00:00
Dave Wysochanski
7088fb9260 Ensure --metadatacopies parameter gets interpreted based on command.
Now that we have both --pvmetadatacopies and --vgmetadatacopies,
we need to make sure --metadatacopies gets interpreted correctly.

For pv commands, --metadatacopies should imply --pvmetadatacopies,
and for vg commands, --vgmetadatacopies.

Note: this will change the behavior of vgcreate with --metadatacopies
to be a synonym for --vgmetadatacopies.  Previously, --metadatacopies
would apply to any PVs given with vgcreate that needed an implicit
pvcreate.  As a result, one small change is needed to one of the nightly
tests - t-vgcreate-usage.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:39:39 +00:00
Dave Wysochanski
458a107e86 Add --vgmetadatacopies to vgsplit man page and command.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:39:24 +00:00
Dave Wysochanski
c6c031e4a1 Update _vgmerge_single() to move fid->metadata_areas_ignored.
When vgmerge is called we move the mdas from the source to the
destination.  With metadata balancing we now have another mda
list, fid->metadata_areas_ignored, so move the mdas on this list
as well.

This patch should not matter as the code is written today.  However
we include it for completeness in the case that _vgmerge_single()
is refactored and/or moved into a library function.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:39:08 +00:00
Dave Wysochanski
9e111ef67a Add --vgmetadatacopies to vgcreate man page, command, and lvm.conf.
Allow parsing of --vgmetadatacopies for vgcreate.  Accept
--metadatacopies as a synonym for --vgmetadatacopies.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:38:23 +00:00
Dave Wysochanski
60a5f61fc8 Set vg_mda_copies when pvchange --metadataignore is given.
When a user explicitly sets a new mda ignore value for a PV, we
should update vg_mda_copies accordingly.  When the VG is written
out, the user would not want the new ignore state to get lost as
a result of the vg_mda_copies value and logic in the vg_write
path.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:38:06 +00:00
Dave Wysochanski
1779cc34d1 Update vgchange tool to accept --vgmetadatacopies.
Update logic in vgchange to handle --vgmetadatacopies, allow
--metadatacopies as a synonym to --vgmetadatacopies,
and add these parameters to args.h and commands.h
Forbit both --vgmetadatacopies and --metadatacopies as only
one allowed.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:37:37 +00:00
Dave Wysochanski
88d7dc1af8 Add mda_copies to VG structures and initialization.
Add a field to struct volume_group to later implement metadata
balancing:
- mda_copies: target # of non-ignored mdas in the VG; default 0 (do
not control pv 'ignore mdas' bit.

This patch just adds the parameter to the structures with the default
values but does not modify any commands.  Should be no functional change.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:36:37 +00:00
Dave Wysochanski
88fc1b143e Add --metadataignore to pvchange, allowing for ignoring of metadata areas.
This patch just modifies pvchange to call the underlying ignore
functions for mdas.  Ensure special cases do not reflect changes
in metadata (PVs with 0 mdas, setting ignored when already ignored,
clearing ignored when not ignored).

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-06-28 20:33:58 +00:00
Dave Wysochanski
f55a20eb36 Rename fid->metadata_areas to fid->metadata_areas_in_use.
Rename the metadata_areas list to an 'in_use' list to prepare for
future 'ignored' list.
2010-06-28 20:32:44 +00:00
Petr Rockai
0da9500f13 Refactor the handles_missing_pv logic in lvchange. 2010-06-28 19:10:16 +00:00
Alasdair Kergon
e6f716f551 generate liblvm2cmd exported symbols too 2010-06-25 18:23:10 +00:00
Jonathan Earl Brassow
98f5d4ad4b Committing Taka's patch... He found a problem during
the failure of a device that contained both a image of
a mirror and an image of the mirrored log.  The order
of the handling of those faults was important (and
wrong), this patch corrects that.

Patch-From: Takahiro Yasui <tyasui@redhat.com>
2010-06-23 20:32:29 +00:00
Zdenek Kabelac
99cd5c7098 Fix typo: premitted -> permitted
Signed-off-by: Takahiro Yasui<tyasui@redhat.com>
2010-06-23 10:22:59 +00:00
Milan Broz
4df5235d15 Fix exit code when requesting help using documented -o help option.
IOW fix lvs -o help
...
  Command failed with status code 5.
2010-06-17 13:15:51 +00:00
Milan Broz
c9c7d25c35 Remove C++ private keyword from headers.
Add extern C definition for libdevmapper, lvm2app and lvm2cmd.
2010-06-16 13:01:25 +00:00
Zdenek Kabelac
cee2f123a4 Use "" instead of <> for configure.h and libdevmapper.h
Move configure.h as the first header for clvmd source files.
2010-06-15 11:00:44 +00:00
Zdenek Kabelac
0337d99198 Use INSTALL_DIR to create directories 2010-06-03 13:52:21 +00:00
Milan Broz
31943693c7 Require partial option in lvchange --refresh for partials LVs.
We must not refresh LV if some PVs are missing and partial activation
was not requested.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=598886
2010-06-03 12:45:05 +00:00
Petr Rockai
d345bf2cd3 Account for mirror transient status when doing lvconvert --repair. 2010-05-24 15:32:20 +00:00
Zdenek Kabelac
8eed925e17 Replicator: update activate code for vgchange
Activate only the first replicator-dev LV, that activates all other
related LVs from Replicator. In case of error during this activation,
it will not retry again for other heads (less confusing error log).
2010-05-24 09:03:39 +00:00
Zdenek Kabelac
df7edc00b8 Replicator: VG with cmd_missing_vgs does not generate output
Do not print message if missing VG is found.
2010-05-24 08:59:29 +00:00
Zdenek Kabelac
f467cd17a1 Replicator: use cmd_vg for process_each_lv_in_vg()
As for _process_one_vg() we need similar retry loop for
process_each_lv_in_vg(). This patch retries to process
failed LVs with reopened VGs.

Patch does not add any extra repeated invocations if there is not
found any missing VG during LV processing.
2010-05-21 14:15:39 +00:00
Zdenek Kabelac
2ad07c0716 Replicator: use cmd_vg list for _process_one_vg()
Patch modifes behavior of _process_one_vg().

In the first pass vg_read() collectis for replicator sorted list of
additional VGs during lock_vol().
If any other VG is needed by the replicator and it is not yet opened
then next iteration loop is taken with all collected VGs.

Flag vg->cmd_missing_vgs detects missing VGs.
2010-05-21 14:11:13 +00:00
Zdenek Kabelac
04a6dd7731 API change for args of process_each_lv_in_vg()
Patch adds failed_lvnames to the list of parameters for process_each_lv_in_vg().
If the list is not NULL it will be filled with LV names of failing LVs
during function execution.

Application could later reiterate only on failed LVs.
2010-05-21 12:21:51 +00:00
Zdenek Kabelac
0e83352280 Return ECMD_FAILED for break in process_each_lv() and process_each_segment_in_lv() 2010-05-21 12:19:22 +00:00
Dave Wysochanski
a5f0b044bf Remove another pvchange hack involving orphan VG names.
Unnecessary as a result of recent changes.
2010-05-19 15:34:10 +00:00
Dave Wysochanski
24a57a0b95 Remove hack in pvchange to unlock orphan VG.
With agk's recent changes, the lock/unlock APIs can properly handle
orphan VG names.
2010-05-19 13:21:09 +00:00
Dave Wysochanski
1a832398a7 Update pvchange to always obtain a vg handle for each pv to process.
Earlier patches added some infrastructure to lookup a vgname from
a pvname.  We now can cleanup some of the pvchange and other code
by requiring callers that want to modify some pv property:
1) lookup the vgname by the pvname
2) use the vgname to obtain a vg handle
3) get the pv handle from the vg handle

This should work going forward and be a much cleaner interface,
as we move away from pvs as standalone objects.
2010-05-19 11:53:00 +00:00
Alasdair Kergon
fa305e2ec6 Accept orphan VG names as parameters to lock_vol() and related functions. 2010-05-19 01:16:40 +00:00
Jonathan Earl Brassow
dfafb8fb20 If we are checking if '--nosync' was called with the mirror argument,
then let's also check if '--mirrorlog' was called with the mirror
argument.
2010-05-11 21:40:11 +00:00
Zdenek Kabelac
3806ab6f1f Link liblvm2cmd.so with devmapper-event and devmapper libs.
and remove generic %.so: %.a target.
2010-05-11 08:34:38 +00:00
Alasdair Kergon
1641fdf90c Fix truncated total size displayed by pvscan. 2010-05-07 15:24:17 +00:00
Peter Rajnoha
d50c6d4bf5 Add new --sysinit option for vgchange and lvchange.
A shortcut for --ignorelockingfailure, --ignoremonitoring, --poll n options
and LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES environment variable used all at
once in initialisation scripts (e.g. rc.sysinit or initrd).
2010-05-06 11:15:55 +00:00
Petr Rockai
9409998d71 Suppress duplicate error messages about read failures and missing devices. 2010-05-05 22:37:52 +00:00
Peter Rajnoha
c7fe469700 And be consistent with return code as well (previous commit). 2010-04-30 13:47:11 +00:00
Peter Rajnoha
5ff4274f9b Don't run any complex initialisation for the "version" lvm2 command.
We can use it even in read-only environment where a try to initialise
file-based locking fails (not to mention other processing related with
lvm2 init). Simply, we want to output the version only, nothing else.
And this should always work.
2010-04-30 13:28:44 +00:00
Alasdair Kergon
54d7741a3e Remove no-longer-used arg_ptr_value.
Fix -M and --type to use strings not pointers that change on config refresh.
2010-04-29 01:38:12 +00:00
Jonathan Earl Brassow
c64f9e63eb Don't attempt to convert the log type of an LV if the LV
is not a mirror.
2010-04-28 17:41:30 +00:00
Peter Rajnoha
942d6ef29f Add support for new IMPORT{db} udev rule.
This rule appeared in udev v152 and it helps us to support spurious events
where we didn't have any flags set (events originated in udevadm trigger
or the watch rule). These flags are important to direct the rule application.
Now, with the help of this rule, we can regenerate old udev db content.
To implement this correctly, we need to flag all proper DM udev events with
DM_UDEV_PRIMARY_SOURCE_FLAG. That happens automatically for all ioctls
generating events originated in libdevmapper.
2010-04-28 13:37:36 +00:00
Zdenek Kabelac
8b7fc0da11 Small indent change 2010-04-28 12:23:11 +00:00
Alasdair Kergon
21e2ab0e67 Fix lvconvert error message when existing mirrored LV is not found. 2010-04-26 18:31:58 +00:00
Alasdair Kergon
4ed099bafa add comments 2010-04-26 18:12:40 +00:00
Mike Snitzer
60267bdce8 Disallow the direct removal of a merging snapshot.
Allow lv_remove_with_dependencies() to know the top-level LV that was
requested to be removed (otherwise it recurses and we lose context).

A merging snapshot cannot be removed directly but the associated origin
can be.  Disallow removal of a merging snapshot unless the associated
origin is also being removed.
2010-04-23 19:27:10 +00:00
Mike Snitzer
d6d08486c8 Remove redundant check in _lvs_single now that the caller
(process_each_lv_in_vg) provides it.

Also, removing this check from _lvs_single now allows displaying hidden
LVs that are specifically named on the command line.
2010-04-23 19:10:20 +00:00
Peter Rajnoha
6ddb5ecd72 Set appropriate udev flags for reserved LVs.
There's no need for foreign udev rules to touch LVM reserved devices
(snapshot, pvmove, _mlog, _mimage, _vorigin) even if they happen to
be visible. The same applies for /dev/disk content - no need to create
any content for these devices (and so no need to run any "blkid" etc.).
This also prevents setting any inotify "watch" from udev rules on such
devices that is a source of race conditions (the rules need to honor
DM_UDEV_DISABLE_OTHER_RULES_FLAG for this to work though).
2010-04-23 14:16:32 +00:00
Jonathan Earl Brassow
3c76d9abaf Disallow the addition of mirror images while a mirror up-convert
is already occurring.  The addition of new legs can be retried
once the current conversion is complete.
2010-04-21 14:04:24 +00:00
Milan Broz
ff403ee29f Remove -n argument from vgcfgrestore.
This is old lvm1 syntax, because arguments changed
from PVs to VGs compatibility is broken already.

name_ARG is not used in code.
2010-04-20 18:17:56 +00:00
Alasdair Kergon
c3b712f8a0 typo in comment 2010-04-20 12:18:31 +00:00
Zdenek Kabelac
5227ae5388 Install symbolic .so links with relative paths between usrlibdir and libdir. 2010-04-15 15:12:20 +00:00
Petr Rockai
a86107dfb1 Allow incomplete mirror restore in lvconvert --repair upon insufficient space. 2010-04-14 13:51:58 +00:00
Peter Rajnoha
c6469d46dd Allow VGs with active LVs to be renamed. 2010-04-14 13:03:06 +00:00
Alasdair Kergon
e6f562ab77 Only pass visible LVs to tools in cmdline VG name/tag expansions without -a 2010-04-14 02:19:49 +00:00
Alasdair Kergon
6c4f65fecd Use typedefs for toollib process_each functions. 2010-04-13 23:57:41 +00:00
Dave Wysochanski
11647ad01c Use del_pvl_from_vgs() in vgreduce paths.
Somehow these got missed in earlier patches.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-13 17:26:20 +00:00
Dave Wysochanski
0adfbfd5ea Call add_pvl_to_vgs() and del_pvl_from_vgs() from more places.
Now that we have library functions to add/delete a pv from the vg->pvs
list, call them from everywhere.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-13 17:26:03 +00:00
Alasdair Kergon
68176be18e Add --stripes to lvconvert too. 2010-04-13 01:54:32 +00:00
Alasdair Kergon
59131572d5 Add activation/polling_interval to lvm.conf as --interval default. 2010-04-13 01:43:56 +00:00
Zdenek Kabelac
23b059e7b7 INSTALL rules updates
Patch is inspired by Debian's extra patch.

- removes OWNER & GROUP make vars they are parts of INSTALL command.
- adds INSTALL_PROGRAM for executable, uses $(INSTALL)
- adds INSTALL_DATA for non-executable data, uses ($INSTALL)
- adds INSTALL_WDATA for writable non-executable data, uses ($INSTALL)
- adds configure option --enable-write_install - to support
  installatin of writable files used by distribution
- replaces usage of ifeq @LIB_SUFFIX@ with $(LIB_SUFFIX)
- installs .a files from static builds without executable flag
- installs .a files to $(usrlibdir) instead of $(libdir)
- installs all static binaries to $(staticdir)
- create .so links for devel package in $(usrlibdir) instead of
  $(libdir)
- makes .so and .so.LIB_VERSION files within builddir
- removes VERSIONED_SHLIB and created versioned LIB_SHARED automagicaly
- install LIB_SHARED via install_lib_shared target
- install plugins via install_lib_shared_plugin target
- prints whole 'install' command during installation instead of less
  informative "Installing  $(something) $(somewhere)"
- install multiple man pages with one INSTALL command
- use DISTCLEAN_TARGETS instead of creating multiple distclean targets
2010-04-09 21:42:48 +00:00
Zdenek Kabelac
c737d34804 Use vpath instead of VPATH.
Usage of VPATH makes troubles when used within $(builddir).
Not only source files are being found through VPATH,
but targets as well. (make --debug=v)

Thus if user builds the code in $(srcdir) and also in some $(builddir)
he gets mangled results as some generated files (i.e. .export.sym)
are 'reused' from $(srcdir) instead of $(builddir).

This patch switches to use vpath were we could explicitly name
suffixes that should be looked via vpath - we must take care,
we do not generate files with these suffixes:
.c, .in, .po, .exported_symbols
2010-04-09 21:34:25 +00:00
Alasdair Kergon
1485ce69c4 Permit mimage LVs to be striped in lvcreate and lvresize. 2010-04-09 01:00:10 +00:00
Milan Broz
fb3bcb9f74 Wipe dm-ioctl parameters in memory after use. 2010-04-07 15:57:20 +00:00
Alasdair Kergon
258db3ad8e Change most remaining log_error WARNING messages to log_warn. 2010-04-01 10:34:09 +00:00
Alasdair Kergon
697f5db331 remove unused var 2010-03-31 20:39:51 +00:00
Zdenek Kabelac
975f35501a Use .commands created in builddir for symlink installation. 2010-03-31 07:37:16 +00:00
Mike Snitzer
b73c18242e Do not allow {vg|lv}change --ignoremonitoring if on clustered VG.
clvmd does not propagate DMEVENTD_MONITOR_IGNORE.

Update get_activation_monitoring_mode() to check if the VG that the
LV is being activated in is clustered.  If so, skip it.

Any get_activation_monitoring_mode() error will cause the associated LV
(or VG) to be skipped during activation.  Both vgchange_single() and
lvchange_single(), which call get_activation_monitoring_mode(), are
called by their respective process_each_..() method.
2010-03-29 16:09:40 +00:00
Zdenek Kabelac
b7be589ed0 Fixing another set of distclean problems where we left some generated files
in clvmd, dmevend, man, tests.

Don't include dependency files for clow and cscope.out targets

Improve dependency tracking for dmeventd and liblvm2cmd sources.
2010-03-29 14:17:59 +00:00
Zdenek Kabelac
b41f5924bf Update cflow file generation - support build dir and use $(top_srcdir)
to obtain sources. Create make.tmpl target for
simplier generation of cflow files with the help of
CFLOW_LIST, CFLOW_LIST_TARGET, CFLOW_TARGET.
Still cflow usage is not perfect.
2010-03-29 14:11:17 +00:00
Jonathan Earl Brassow
7a369d3704 Add ability to create mirrored logs for mirror LVs.
This check-in enables the 'mirrored' log type.  It can be specified
by using the '--mirrorlog' option as follows:
#> lvcreate -m1 --mirrorlog mirrored -L 5G -n lv vg

I've also included a couple updates to the testsuite.  These updates
include tests for the new log type, and some fixes to some of the
*lvconvert* tests.
2010-03-26 22:15:43 +00:00
Mike Snitzer
a6bc975a24 Improve activation monitoring option processing
. Add "monitoring" option to "activation" section of lvm.conf
. Have clvmd consult the lvm.conf "activation/monitoring" too.
. Introduce toollib.c:get_activation_monitoring_mode().
. Error out when both --monitor and --ignoremonitoring are provided.
. Add --monitor and --ignoremonitoring support to lvcreate.  Update
  lvcreate man page accordingly.
. Clarify that '--monitor' controls the start and stop of monitoring in
  the {vg,lv}change man pages.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-03-23 22:30:18 +00:00
Peter Rajnoha
310efa7b96 UDEV_SYNC_SUPPORT, not UDEV_SYNC! 2010-03-23 15:13:03 +00:00
Peter Rajnoha
91345610f8 Strictly require libudev if udev_sync is used.
This prevents some confusion when libudev was not found so udev_sync was disabled
automatically. Configure was successful though giving only a tiny warning.

Also, if "dmsetup udevcreatecookie" is used, never return 0x000000 as a result if
udev is not running and keep the output blank.
2010-03-23 14:43:18 +00:00
Zdenek Kabelac
7b45e46aa3 Remove const modifier for struct volume_group* from process_each_lv_in_vg().
Content of this pointer is not const during this function.
2010-03-23 14:24:04 +00:00
Mike Snitzer
fd817ff34a Don't allow resizing of internal logical volumes.
Prevent lvresize from being able to resize internal LVs: mirror legs
(*_mimage_*), mirror log (*_mlog), snapshot placeholder LVs (snapshot*)
and others.  Resizing these would leads to unexpected metadata and
sometimes crashes (in case of growing snapshot*).
2010-03-20 03:44:04 +00:00
Dave Wysochanski
15fdc8d3ee Avoid scanning all pvs in the system if operating on a device with mdas.
When we pv_read() a device that has an orphan vgname, we might need to scan
the system to be sure this is true.  However, if the PV has mdas, there's
no way possible for it to have an orphan vgname unless it is a true orphan.
Some areas of the code were optimized to take advantage of this fact, while
others were not (we would still do the expensive scan if a device had mdas
but had an orphan VG).

This patch unifies the code so that every place we are operating on such
a PV, we skip the expensive scan if there are mdas.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Petr Rockai <prockai@redhat.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2010-03-18 17:29:12 +00:00
Alasdair Kergon
38220f9fe9 Remove unnecessary full_scan parameter from get_vgids and get_vgnames calls. 2010-03-16 16:57:03 +00:00
Alasdair Kergon
11c289c27a replace existing_pv with existing_pvl 2010-03-16 15:48:27 +00:00
Alasdair Kergon
cccae7e633 Look up missing PVs by uuid not dev_name in _pvs_single to avoid invalid stat.
Make find_pv_in_vg_by_uuid() return same type as related functions.
2010-03-16 15:30:48 +00:00
Alasdair Kergon
770dc81b8e Introduce is_missing_pv(). 2010-03-16 14:37:38 +00:00
Milan Broz
c948101ccd Add --help dmsetup option as the synonym for help command. 2010-03-08 16:05:07 +00:00
Zdenek Kabelac
18b82048e4 mlockall() -> mlock()
This patch adds a new implementation of locking function instead
of mlockall() that may lock way too much memory (>100MB).
New function instead uses mlock() system call and selectively locks
memory areas from /proc/self/maps trying to avoid locking areas
unused during lock-ed state.

Patch also adds struct cmd_context to all memlock() calls to have
access to configuration.

For backward compatibility functionality of mlockall()
is preserved with "activation/use_mlockall" flag.

As a simple check, locking and unlocking counts the amount of memory
and compares whether values are matching.
2010-03-05 14:48:33 +00:00
Zdenek Kabelac
db724a449b Use UDEV_LIBS, and link -ludev only when needed. 2010-03-04 12:12:34 +00:00
Zdenek Kabelac
f8f6ec92b1 This patch add SELINUX_LIBS and STATIC_LIBS variables.
For static builds dependency for SELinux libs is not handled by 'ar'.
Till better solution is found, for static builds STATIC_LIBS is used.

Patch updates SELinux detection to use 3rd & 4th parameter for Success/Fail.
Also removes detection of pthread from this check as we know which
version of libdevmapper we are going to link with lvm after merge.

SELinux header check moved to the SELinux test code.
2010-03-04 12:08:26 +00:00
Zdenek Kabelac
9f0a5c1d26 Removes -rdynamic from linking of lvm.static and dmeventd.static. 2010-03-04 12:03:54 +00:00
Zdenek Kabelac
f30875dbc6 Pthread linking change
Create new substituted variable PTHREAD_LIBS and link this library
only with tools/libs which really needs it - i.e. dmeventd.

Check for libpthread only for builds with clvmd or dmeventd.

Remove variable LIB_PTHREAD
2010-03-04 11:21:05 +00:00
Zdenek Kabelac
539f4a7728 Readline linking update
Modify linking of readline library. Create new  substituted varible
READLINE_LIBS - readline library is linked ONLY with tools that really use
it - i.e. lvm. (Static lvm does not use readlin).
Previous behaviour put this library into the variable LIBS and thus
linked it with all created object files of lvm project (i.e. plugins...).

READLINE detection is simplified.

Termcap library is linked in only if readline library doesn't have its own
dependency (i.e. old distributions).
2010-03-04 11:19:15 +00:00
Zdenek Kabelac
f0f0b802d1 Introduce LVMINTERNAL_LIBS
Keep dependency libraries for liblvm-internal in one place.
2010-03-04 11:12:39 +00:00
Zdenek Kabelac
87d73a9b85 Replace CFLOW_CMD only in make.tmpl and use it as variable elsewhere. 2010-03-04 09:53:08 +00:00
Zdenek Kabelac
814aebc4e9 Use $(top_builddir) for inclusion of make.tmpl in Makefiles. 2010-03-04 09:51:37 +00:00
Milan Broz
65752052e1 Remove lvs_in_vg_activated_by_uuid_only call.
There is no difference from lvs_in_vg_activated now,
convert all users to this call.
2010-02-24 20:01:40 +00:00
Dave Wysochanski
cd69ee7453 Refactor lvchange_tag() to call lv_change_tag() library function.
Similar refactoring to vgchange - pull out common parts and put into
library function for reuse.  Should be no functional change.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-24 18:15:49 +00:00
Dave Wysochanski
aee205752a Refactor vgcreate to call new vg_change_tag() function.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-24 18:15:40 +00:00
Dave Wysochanski
e17bcc7432 Refactor _vgchange_tag() to vg_change_tag() library function.
Pull out common code to be called from tools as well as lvm2app.
Leave archive() at tool level so we can use from vgcreate
as well as vgchange.  Should be no functional change.
- add stack macro in vgchange

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-24 18:15:05 +00:00
Mike Snitzer
a5ec3e3827 Refactor snapshot-merge deptree and device removal to support info-by-uuid
Add a merging snapshot to the deptree, using the "error" target, rather
than avoid adding it entirely.  This allows proper cleanup of the -cow
device without having to rename the -cow to use the origin's name as a
prefix.

Move the preloading of the origin LV, after a merge, from
lv_remove_single() to vg_remove_snapshot().  Having vg_remove_snapshot()
preload the origin allows the -cow device to be released so that it can
be removed via deactivate_lv().  lv_remove_single()'s deactivate_lv()
reliably removes the -cow device because the associated snapshot LV,
that is to be removed when a snapshot-merge completes, is always added
to the deptree (and kernel -- via "error" target).

Now when the snapshot LV is removed both the -cow and -real devices
get removed using uuid rather than device name.  This paves the way
for us to switch over to info-by-uuid queries.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-02-17 22:59:46 +00:00
Peter Rajnoha
3c134e0165 Don't use LVM_UDEV_DISABLE_CHECKING environment variable anymore.
Set the state automatically based on udev and libdevmapper dev path comparison.
If these paths differ, disable udev checking.
2010-02-15 16:26:48 +00:00
Peter Rajnoha
f0e073fcdc Several changes in dmsetup and libdevmapper:
- add DM_UDEV_DISABLE_LIBRARY_FALLBACK udev flag to rely on udev only

 - export dm_udev_create_cookie function to create new cookies on demand

 - add --udevcookie, udevcreatecookie and udevreleasecookie for dmsetup
   (to support "udev transactions" where one cookie value can be used for
    several dmsetup calls)

 - don't use DM_UDEV_DISABLE_CHECKING env. var. anymore and set the state
   automatically (based on udev and libdevmapper dev path comparison)
2010-02-15 16:21:33 +00:00
Petr Rockai
57f5ec5d6c Make lvconvert --repair --use-policies exit with success when no action is needed. 2010-02-06 07:44:16 +00:00
Mike Snitzer
50ba52456e Switch lvconvert_single() over to using get_vg_lock_and_logical_volume()
This change was deferred to help ease the review of previous refactoring
related to using process_each_lv() for lvconvert's merge support.  Not
that doing so _really_ helped but...

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-02-05 22:47:22 +00:00
Mike Snitzer
234b12480e lvconvert --merge @tag support
Switch lvconvert's --merge code over to using process_each_lv().  Doing
so adds support for a single 'lvconvert --merge' to start merging
multiple LVs (which includes @tag expansion).

Add 'lvconvert --merge @tag' testing to test/t-snapshot-merge.sh

Adjust man/lvconvert.8.in to reflect these expanded capabilities.

The lvconvert.c implementation requires rereading the VG each iteration
of process_each_lv().  Otherwise a stale VG instance associated with
the LV passed to lvconvert_single_merge() would result in stale VG
metadata being written back out to disk.  This overwrote new metadata
that was written when a previous snapshot LV finished merging (via
lvconvert_poll).  This is only an issue when merging multiple LVs that
share the same VG (a single VG is typical for most LVM configurations on
system disks).

In the end this new support is very useful for performing a "system
rollback" that requires multiple snapshot LVs be merged to their
respective origin LV.

The yum-utils 'fs-snapshot' plugin tags all snapshot LVs that it creates
with a common 'snapshot_tag' that is unique to the yum transaction.
Rolling back a yum transaction, that created LVM snapshots with the tag
'yum_20100129133223', is as simple as:
  lvconvert --merge @yum_20100129133223

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-02-05 22:44:37 +00:00
Mike Snitzer
0ade9a8b37 Prepare for _get_lvconvert_vg() reuse as part of a larger lvconvert.c
refactoring.

Document the need to cleanup the "name" args passed around polldaemon,
lvconvert and pvmove.  It is quite a mess.

Annotate the unused nature of the existing poll_fns->get_copy_vg
methods' 'uuid' arg.
2010-02-05 22:40:49 +00:00
Jonathan Earl Brassow
abdd429f35 Adding a new mimage (leg/copy) to a mirror behaves differently
depending on if the mirror has a 'core' or 'disk' log.  When there
is a disk log, the new leg is added by stacking a new mirror on
top of the old (one leg is the old mirror and the other leg is the newly
added device).  When the log is a 'core' log, the new leg is simply added
to the existing mirror and all the devices are re-synced.

The logic that handles collapsing the stacked 'disk' log mirror was
having the effect of causing 'core' logged mirrors to begin resync'ing
for a second time.  I have used the 'CONVERTING' flag to indicate that
a mirror is converting by way of stacking.  This is no longer set for
up-converting core logs.  The final 'collapse' logic can safely be skipped
for 'core' log mirrors - getting rid of the second resync.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-02-05 21:49:16 +00:00
Peter Rajnoha
04fa77c3be This is related to liblvm and its lvm_list_vg_names() and lvm_list_vg_uuids() functions
where we should not expose internal VG names/uuids (the ones with "#" prefix )through the
interface. Otherwise, we could end up with library users opening internal VGs which will
initiate locking mechanism that won't be cleaned up properly.

"#orphans_{lvm1, lvm2, pool}" names are treated in a special way, they are truncated first
to "orphans" and this is used as a part of the lock name then (e.g. while calling lvm_vg_open()).
When library user calls lvm_vg_close(), the original name "orphans_{lvm1, lvm2, pool}"
is used directly and therefore no unlock occurs.

We should exclude internal VG names and uuids in the lists provided by lvmcache:
lvmcache_get_vgids() and lvmcache_get_vgnames().
2010-02-03 14:08:39 +00:00
Mike Snitzer
5bc2af2688 Add %ORIGIN support to lv{create,extend,reduce,resize} --extents option
Allow the number of logical extents to be expressed (for a snapshot) as
a percentage of the total space in the Origin Logical Volume with the
suffix %ORIGIN.

Update the relevant man pages accordingly.  Eliminate inconsistencies
between the man pages and tools/commands.h

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-02-03 03:58:08 +00:00
Milan Broz
a1b40be081 Fix pvmove abort when temporary mirror fails to be cluster-aware.
When activation of pvmove mirror fails on cluster, some nodes
still possibly succeeded in activation.

 - Explicitly deactivate that mirror to be sure
 - properly pair suspend/resume calls to not cause memory lock problems in clvmd

Code cannot simply call _finish_pvmove on cluster in this situation, because
changed LVs are suspended twice (causing memory inbalance) and also temporary
mirror is activated when it is not expected (and we know that it failed already).

Patch prepares special function which remove temporary mirror references from
metadata and then resumes changed LVs.
2010-01-27 13:29:11 +00:00
Milan Broz
e01bdd2fab Add some missing vg_revrts calls when pvmove aborts. 2010-01-26 08:01:18 +00:00
Mike Snitzer
43d99aab6c Default to checking LV's progress before waiting in _wait_for_single_lv.
Support "wait before testing" using '+' in pvmove and lvconvert
interval.  Doing so overrides the new default of sleeping after checking
the LV's progress.

Sleeping before checking progress can lead to extraneous polldaemons
being left running.  These polldaemons would have otherwise exited had
they checked before sleeping.  Checking progress before sleeping helps
workaround the subtly unreliable nature of "finished" state checking
in _percent_run.

Update test/t-mirror-names.sh to use '+' when providing its lvconvert
interval.
2010-01-22 21:59:42 +00:00
Milan Broz
98d85f25be Move error message to locking constructor and print
more descriptive message if locking fails instead of
"Locking type -1 initialisation failed."

Use read-only locking instead of misleading ignorelocking option
in message.
2010-01-22 09:45:29 +00:00
Zdenek Kabelac
d40821aabc Reset released pointer and counters.
DSO is currently not dl_close-ing pluing during it is unregister handling,
so clear structure and related counter, so there are no memory problems.
Futher fixes are needed.
2010-01-21 13:41:39 +00:00
Alasdair Kergon
f7729ec651 more build fixes 2010-01-19 01:10:46 +00:00
Mike Snitzer
6c1c02dc52 Change dev_manager_mirror_percent()'s 'struct logical_volume *' to be
'const'.  Be consistent with its use (and dev_manager_snapshot_percent()).

Pass 'lv' from dev_manager_snapshot_percent() to _percent() to
_percent_run().  _percent_run() always dereferenced 'lv' (when
initializing segh) even though it may have been NULL (as was the case
until now for dev_manager_snapshot_percent()).

If a "snapshot-origin" LV (snapshot-merge whose merge was deferred
becuase it was open) was passed to _percent_run() it would always return
100%.

Update _percent_run() to NOT return PERCENT_100 et. al. if
->target_percent() wasn't ever called and supplied 'lv' is a merging
origin.  A default return of 100% does not work for snapshot-merge.

Also tweak a related lvconvert log_error() to include "Aborting merge."
2010-01-15 22:58:25 +00:00
Zdenek Kabelac
04bde319a9 Cleanup gcc warning: cast discards qualifiers from pointer target type
API of the library should remain the same as the 'const' is not
mangled into the function name in C.
2010-01-14 10:15:23 +00:00
Mike Snitzer
c52678ee9b Rename segment and lv status flag from SNAPSHOT_MERGE to MERGING.
Eliminate 'merging_snapshot' from 'struct logical_volume' and just use
'snapshot' for origin lv's reference to the merging snapshot; also set
MERGING in the origin lv's status.
2010-01-13 01:56:18 +00:00
Mike Snitzer
c79b425135 Add snapshot merge wrappers to abstract the associations and flags used
to represent merging origin and snapshot volumes.
2010-01-13 01:55:43 +00:00
Mike Snitzer
c582e3c039 Merge on activate support.
If either the origin or snapshot that is to be merged is open the merge
will not start; only the merge metadata will be written.  The merge will
start on the next activation of the origin (or via lvchange --refresh)
IFF both the origin and snapshot are closed.

Merge on activate is particularly important if we want to merge over a
mounted filesystem that cannot be unmounted (until next boot) --- for
example root.
2010-01-13 01:54:34 +00:00
Mike Snitzer
df06d9ac7a Start background polling of merging stores on:
- lvchange -ay or vgchange -ay.
- lvchange --refresh or vgchange --refresh.
2010-01-13 01:50:34 +00:00
Mike Snitzer
a0be44c727 Background poll for lvconvert --merge command.
The merging snapshot is removed when the merge finishes.
2010-01-13 01:49:52 +00:00
Mike Snitzer
3869eff08d Do not allow merging over mounted logical volumes.
When preserving origin, check that the snapshot is not mounted.
2010-01-13 01:47:18 +00:00
Mike Snitzer
154b64d7a5 Add --merge support to lvconvert to start merging a snapshot into its
origin, example usage:  lvconvert --merge vg/snaplv
2010-01-13 01:45:15 +00:00
Alasdair Kergon
f3ac7d1b82 Revert so-called "redundant" log until after next release. 2010-01-12 14:00:51 +00:00
Jonathan Earl Brassow
673421ffc2 Testsuite updates and fixes for recently added features.
1. Found bug in 'redundant log' implementation that caused
   problems when converting a linear that spanned multiple
   devices to a mirror (wasn't checking for NULL value of
   provided parameter in _alloc_parallel_area)

2. Testsuite was failing to perform tests when 'not' modifier
   was used.  This allowed a couple issues to slip through.
   Added a 'not_sh' modifier that negates tests performed by
   functions defined in the shell source file.

3. Was initializing a variable to far down, which cause
   previously set value to be overridden.  (This was the
   result of the collision of the "redundant log" and
   lvconvert fix patches.)
2010-01-11 21:20:19 +00:00
Mike Snitzer
94d4a90f27 Only allow one return from poll_daemon(). If a child polldaemon was
successfully created it must _exit() once it completes.

Update _become_daemon() to differentiate between a failed fork() and a
successful fork().

Added lvm_return_code() to lvmcmdline.[ch]
2010-01-11 19:19:17 +00:00
Jonathan Earl Brassow
68427c03e9 Found 2 problems with my previous check-in:
date: 2010/01/07 20:42:55;  author: jbrassow;  state: Exp;  lines: +11 -0
 The patch fixes some lvconvert issues (WRT mirror <-> mirror).

1) 'exisiting_mirrors' and 'lp->mirrors' where taken to be in 'n-1'
   notation (i.e a 2-way mirror is '1' and a linear is '0'), but the
   variables were in 'n' notation.
2) After adding the redundant mirror log support, I was calculating
   log_count by looking at the mirror log LV, but didn't take into
   account the fact that there could be no mirror log!

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-01-11 17:13:45 +00:00
Peter Rajnoha
a750353641 Add support to disable udev checking: LVM_UDEV_DISABLE_CHECKING=1 env. var.
LVM_UDEV_DISABLE_CHECKING=1 applies for /dev/<vgname> content only.
We still need to define DM_UDEV_DISABLE_CHECKING=1 for /dev/mapper content.
2010-01-11 15:40:03 +00:00
Peter Rajnoha
d2b43c4b34 Add support to disable udev checking: DM_UDEV_DISABLE_CHECKING=1 env. variable.
Sometimes it is really needed to switch off udev checking and the warnings we show when
we detect that udev has not done its job right - the messages like "Udev should have done
this and that. Falling back to direct node creation/removal. " etc.

This would be especially handy while setting DM_DEV_DIR env var that could be set to a
different location than standard /dev (udev can't create nodes/symlinks out of that one
directory that is configured into udevd). The exact same situation happens while we're
running our tests.
2010-01-11 15:36:24 +00:00
Jonathan Earl Brassow
77dd1c0e5f Add the new mirror log type "redundant". The options are now:
--mirrorlog core: in-memory log
--mirrorlog disk: persistent log
--mirrorlog redundant: redundant persistent log

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-01-08 22:32:35 +00:00
Jonathan Earl Brassow
72e0743621 This patch adds the capability to split off a mirror legs.
It is pretty much the same as reducing the number of
mirror legs, but we just don't delete them afterwards.

The following command line interface is enforced:
  prompt> lvconvert --splitmirror <n> -n <name> <VG>/<LV>
where 'n' is the number of images to split off, and
where 'name' is the name of the newly split off logical volume.

If more than one leg is split off, a new mirror will be the
result.  The newly split off mirror will have a 'core' log.
Example:
[root@bp-01 LVM2]# !lvs
lvs -a -o name,copy_percent,devices
  LV            Copy%  Devices
  lv            100.00 lv_mimage_0(0),lv_mimage_1(0),lv_mimage_2(0),lv_mimage_3(0)
  [lv_mimage_0]        /dev/sdb1(0)
  [lv_mimage_1]        /dev/sdc1(0)
  [lv_mimage_2]        /dev/sdd1(0)
  [lv_mimage_3]        /dev/sde1(0)
  [lv_mlog]            /dev/sdi1(0)
[root@bp-01 LVM2]# lvconvert --splitmirrors 2 --name split vg/lv /dev/sd[ce]1
  Logical volume lv converted.
[root@bp-01 LVM2]# !lvs
lvs -a -o name,copy_percent,devices
  LV               Copy%  Devices
  lv               100.00 lv_mimage_0(0),lv_mimage_2(0)
  [lv_mimage_0]           /dev/sdb1(0)
  [lv_mimage_2]           /dev/sdd1(0)
  [lv_mlog]               /dev/sdi1(0)
  split            100.00 split_mimage_0(0),split_mimage_1(0)
  [split_mimage_0]        /dev/sde1(0)
  [split_mimage_1]        /dev/sdc1(0)

It can be seen that '--splitmirror <n>' is exactly the same
as '--mirrors -<n>' (note the minus sign), except there is the
additional notion to keep the image being detached from the
mirror instead of just throwing it away.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
2010-01-08 22:00:31 +00:00
Mike Snitzer
c9f27b1ca1 Change background polldaemon's process name to "(lvm2)".
Made .update_metadata optional in 'struct poll_functions' definitions;
eliminated _update_lvconvert_mirror() stub.

Tweak a mirror-specific error message in the generic polldaemon code.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-01-08 21:53:07 +00:00
Petr Rockai
5f6519758f Allow vgremove of a VG with PVs missing. 2010-01-08 14:03:54 +00:00
Petr Rockai
eaac0790f5 In lvconvert --repair --use-policies, for the allocate policies, return success
even if allocation fails, as long as the downconversion or corelog conversion
succeeded.
2010-01-08 13:04:10 +00:00
Jonathan Earl Brassow
77a4260fe8 The patch fixes some lvconvert issues (WRT mirror <-> mirror).
The default log option for a mirror is 'disk'.  If the log
type is not explicitly stated on the command line when
converting from an X-way mirror to a Y-way mirror, 'disk'
is chosen.  So, if you have a 'core' log mirror and you
convert, your result will contain a 'disk' log.

This patch remembers what the old log type was.  If the
user is merely trying to switch the number of mirror
images, the log type is now kept the same.

There is one historical behaviour I left in place...
If you have a 2-way, core-log mirror and you use lvconvert to
specify you want a 2-way mirror - without specifying the
log type - you will get a 2-way, disk-log mirror.

Signed-off-by: Jonathan Brassow <jbrassow@redhat.com>
Informal-IRC-ACK-by: agk
2010-01-07 20:42:55 +00:00
Peter Rajnoha
4998a0041f Add --noudevrules option for dmsetup to disable /dev node management by udev. 2010-01-07 19:45:12 +00:00
Mike Snitzer
f407c8afd0 . update documentation for --poll in the vgchange and lvchange man pages
. add high-level --poll FIXMEs to vgchange.c and lvchange.c
2010-01-06 19:08:58 +00:00
Milan Broz
03984e05a3 Rename mirror_device_fault_policy to mirror_image_fault policy 2010-01-06 13:27:06 +00:00
Milan Broz
bf8c8a6d61 Remove empty "repaired" devices if empty in lvconvert.
The logic was that lvconvert repair volumes, marking
PV as MISSING and following vgreduce --removemissing
removes these missing devices.

Previously dmeventd mirror DSO removed all LV and PV
from VG by simply relying on
vgreduce --removemissing --force.

Now, there are two subsequent calls:
lvconvert --repair --use-policies
vgreduce --removemissing

So the VG is locked twice, opening space for all races
between other running lvm processes. If the PV reappears
with old metadata on it (so the winner performs autorepair,
if locking VG for update) the situation is even worse.


Patch simply adds removemissing PV functionality into
lvconcert BUT ONLY if running with --repair and --use-policies
and removing only these empty missing PVs which are
involved in repair.
(This combination is expected to run only from dmeventd.)
2010-01-06 13:26:21 +00:00
Mike Snitzer
56b3d20462 Add missing 'stack;' for all activate_lv and deactivate_lv callers.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-01-05 21:08:34 +00:00
Mike Snitzer
df13cf08d5 Add missing 'stack;' for all suspend_lv and resume_lv callers.
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-01-05 21:07:31 +00:00
Mike Snitzer
7a8fa6aaab Add a [--poll {y|n}] flag to vgchange and lvchange to control whether
the background polldaemon is allowed to start.  It can be used
standalone or in conjunction with --refresh or --available y.

Control over when the background polldaemon starts will be particularly
important for snapshot-merge of a root filesystem.

Dracut will be updated to activate all LVs with: --poll n

The lvm2-monitor initscript will start polling with: --poll y

NOTE: Because we currently have no way of knowing if a background
polldaemon is active for a given LV the following limitations exist and
have been deemed acceptable:
1) it is not possible to stop an active polldaemon; so the lvm2-monitor
   initscript doesn't stop running polldaemon(s)
2) redundant polldaemon instances will be started for all specified LVs
   if vgchange or lvchange are repeatedly used with '--poll y'

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2010-01-05 20:56:51 +00:00
Milan Broz
eb75125539 Fix previous vgcreate commit to not call unpaired unlock. 2009-12-28 18:34:45 +00:00
Petr Rockai
3dfeaca59b Also clean up MISSING devices in --removemissing --force in vgreduce. 2009-12-17 13:54:46 +00:00
Petr Rockai
550cae2340 #define an INTERNAL_ERROR macro and use it throughout LVM. 2009-12-16 19:22:11 +00:00
Zdenek Kabelac
b1ebf028de Cleanup returns for void functions. 2009-12-11 13:16:37 +00:00
Zdenek Kabelac
685be1dc7a Fix unlocking vg in some pvresize and toollib error paths. 2009-12-11 13:11:56 +00:00
Zdenek Kabelac
c8d8f74188 Fix coredump and memory leak for 'dmsetup help -c' 2009-12-11 13:04:30 +00:00
Dave Wysochanski
6911c90074 Fix activated/deactivated log_verbose message
I see "Deactivated" message when I activate and "Activated" message when
I deactivate.  The code uses "activate" as boolean but it can be any one
of the enum values from CHANGE_AY, CHANGE_AN, CHANGE_AE, etc.

Signed-off-by: Malahal Naineni <malahal@us.ibm.com>
Acked-by: Dave Wysochanski <dwysocha@redhat.com>
2009-12-07 19:32:28 +00:00
Peter Rajnoha
7a3263f2a0 Give better message for pvmove when all data on source PV is skipped. 2009-12-04 14:03:18 +00:00
Milan Broz
29f011314d Fix pvmove test mode to not fail and do not poll.
Test mode should not fail nor try to poll non-existent devices.
2009-12-03 19:22:24 +00:00
Milan Broz
b917086464 Print error if VG already exist.
This test have to be moved because of new vg read error handling.
2009-12-03 19:20:48 +00:00
Milan Broz
fec4de9563 Fix tools to report error when stopped by user.
(And do not produce internal error message.)
2009-12-03 19:18:33 +00:00
Dave Wysochanski
c053fb62bc Fix setting of readahead in lvcreate.
The default comes from the configuration settings, with possible
commandline override.
2009-12-03 01:47:33 +00:00
Milan Broz
5800aa5c07 Do not allow creating mirrors of more than 8 images.
This is kernel limitation in all kernel versions,
so better detect this early.
2009-11-27 14:35:38 +00:00
Milan Broz
fed0e904f2 Add missing vg_release to pvs and pvdisplay to fix memory leak. 2009-11-24 17:07:09 +00:00
Milan Broz
0025670dc9 Do not try to unlock VG which is not locked.
If the vg_read() returned error, no lock was taken,
so always call vg_release().

Otherwise this can happen because of missing FAILED_*:

# vgchange -a y x --ignorelockingfailure
  Volume group "x" not found
  Internal error: Attempt to unlock unlocked VG x
2009-11-24 16:13:02 +00:00
Milan Broz
155c608cd3 Return error status if vgchange fails to activate some volume.
(on one node a storage connection failed):

# vgchange -a y vg_bar ; echo $?
  Error locking on node bar-02: Refusing activation of partial LV lv1. Use --partial to override.
    1 logical volume(s) in volume group "vg_bar" now active
    0

So activation fails on one node, error is correctly printed but
status code is wrong.

This patch fixes the top level (vgchange) to return proper code
(and print # of activated LVs).

(lvchange returns error properly here.)
2009-11-24 16:08:49 +00:00
Petr Rockai
4514bdcfa2 Fix another bug in memlock handling, this time the "global" dmeventd memlock
was preventing device scans in lvconvert --repair running from inside dmeventd.
2009-11-19 01:11:57 +00:00
Milan Broz
b9ac4b0cf8 Never activate hidden volumes directly in vgchange.
All hidden (not visible) volumes should be activated through
other visible volumes.

(There are already exceptions like snapshot, mirror log and image,
which should be cleaned one day...)

This solves problems for future types of hidden volumes,
which can have special meaning and must not be activated implicitly
(e.g. key store volume).
2009-11-18 17:20:18 +00:00
Peter Rajnoha
584d1fb7d1 Support udev flags even when udev_sync is disabled or not compiled in.
This provides better support for environments where udev rules are installed
but udev_sync is not compiled in (however, using udev_sync is highly
recommended). It also provides consistent and expected functionality even
when '--noudevsync' option is used.

There is still requirement for kernel >= 2.6.31 for the flags to work though
(it uses DM cookies to pass the flags into the kernel and set them in udev
event environment that we can read in udev rules).
2009-11-13 12:43:21 +00:00
Alasdair Kergon
9abf5e70be Add support for querying a device's inactive table.
Currently this data is invisible to userspace.
Requires dm >= 4.16 (likely to be in linux 2.6.33).
2009-11-06 00:43:08 +00:00
Milan Broz
ba3851fda6 Fix lvcreate processing of %PVS argument.
- fix missing unlocking of VG
lvcreate -l 100%PVS -n lv1 vg_test
  Please specify physical volume(s) with %PVS
  Internal error: Volume Group vg_test was not unlocked

- if no PVS specified, use all available

Fix segfault if %PVS in lvresize without PVs list.
2009-11-04 14:47:27 +00:00
Zdenek Kabelac
d2e3654f88 minor code comment update 2009-11-04 12:39:56 +00:00
Alasdair Kergon
a8fb89adaf Tidy some uses of arg_count and introduce arg_is_set. 2009-11-03 15:50:42 +00:00
Dave Wysochanski
a42efe6bdf Rename validate_vg_create_params to vgcreate_params_validate. 2009-11-01 20:05:17 +00:00
Dave Wysochanski
2a924b3eaf Rename fill_vg_create_params to vgcreate_params_set_from_args.
Rename fill_vg_create_params to vgcreate_params_set_from_args and remove
vg_name parameter from function (caller must set before calling function).
2009-11-01 20:03:24 +00:00
Dave Wysochanski
c6ea6bf5b7 Add vgcreate_params_set_defaults().
Add function to set default vgcreate parameters based on existing VG or
internal defaults.  Should be no functional change.
2009-11-01 20:02:32 +00:00
Dave Wysochanski
accb17389c Rename pvcreate_params processing functions to better match <object><action>.
Rename fill_default_pvcreate_params to pvcreate_params_set_defaults.
Rename pvcreate_validate_restore_params to pvcreate_restore_params_validate.
Rename pvcreate_validate_params to pvcreate_params_validate.
2009-11-01 19:51:54 +00:00
Dave Wysochanski
fc7ad9d4c7 Update vgsplit to call vg_set_clustered(). 2009-10-31 17:43:57 +00:00
Dave Wysochanski
dfe786c218 Update vgcreate to call vg_set_clustered(). 2009-10-31 17:39:22 +00:00
Dave Wysochanski
0e6c4e93da Add vg_set_clustered() - move logic from vgchange.
Similar to other vg_set_* functions, we create a vg_set_clustered() function
which does a few checks and sets a flag.  This is where we check for
any limitations of clusters.
2009-10-31 17:30:52 +00:00
Dave Wysochanski
7c638cc236 Document --all option in man pages, cleanup {pv|vg|lv}{s|display} man pages.
Option --all is only partially documented currently, so document in all
commands.  Also make {pv|vg|lv}{display|s} man pages consistent with help
output.  Remove ununsed 'disk_ARG' parameter.  Leave --trustcache out of
the man page output.  Update --units argument to show all possible units.
2009-10-26 14:37:09 +00:00
Peter Rajnoha
421671b1c2 Several changes to udev support code:
- we have these levels when the udev rules are processed:
   10-dm.rules --> [11-dm-<subsystem>.rules] --> [12-dm-permissions.rules] -->
   13-dm-disk.rules --> [...all the other foreign rules...] --> 95-dm-notify.rules

 - each level can be disabled now by
   DM_UDEV_DISABLE_{DM, SUBSYSTEM, DISK, OTHER}_RULES_FLAG

 - add DM_UDEV_DISABLE_DM_RULES_FLAG to disable 10-dm.rules

 - add DM_UDEV_DISABLE_OTHER_RULES_FLAG to disable all the other (non-dm) rules.
   We cutoff these rules by using the 'last_rule', so this one should really be
   used with great care and in well-founded situations. We use this for lvm's
   hidden and layer devices now.

 - add a parameter for add_dev_node, rm_dev_node and rename_dev_node so it's
   possible to switch on/off udev checks

 - use DM_UDEV_DISABLE_DM_RULES_FLAG and DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG
   if there's no cookie set and we have resume, remove and rename ioctl.
   This could happen when someone uses the libdevmapper that is compiled with
   udev_sync but the software does not make use of it. This way we can switch
   off the rules and fallback to libdevmapper node creation so there's no
   udev/libdevmapper race.
2009-10-26 14:29:33 +00:00
Alasdair Kergon
984abde146 Permit snapshots of mirrors. (brassow) 2009-10-26 10:01:56 +00:00
Alasdair Kergon
a3a02a2f42 Cleanup mimagetmp LV if allocation fails for new lvconvert mimage. 2009-10-23 01:24:17 +00:00
Peter Rajnoha
5f1f31f942 Add udev flags support in libdevmapper and provide 'dmsetup udevflags' command to decode them. 2009-10-22 12:55:47 +00:00
Jonathan Earl Brassow
1e2ed180ca Clarify message:
"  Mirror status: 1/2 images failed."

Half of an image?  Half of the images?  No, 1 of 2 images.
2009-10-21 22:19:39 +00:00
Petr Rockai
b4048242f5 Handle metadata with unknown segment types more gracefully. 2009-10-16 17:41:49 +00:00
Alasdair Kergon
902c4069dc More build cleanups (linker parameter ordering). 2009-10-13 01:31:10 +00:00
Dave Wysochanski
21e094d9df Cleanup comment and some whitespace. 2009-10-06 16:00:38 +00:00
Dave Wysochanski
0ddb66efba Add --pvmetadatacopies as a synonym for --metadatacopies in various commands.
Going forward, we would like to allow users to specify the total
number of metadatacopies in a VG rather than on a per-PV basis.  In
order to facilitate that, introduce --pvmetadatacopes to replace
--metadatacopies everywhere.  We still allow --metadatacopies for
pv commands, but require --pvmetadatacopies for vg commands.
Eventually we will introduce --vgmetadatacopies.  Once we do that,
we should either deprecate --metadatacopies or make it a synonym based
on the command (pvmetadatacopies for pv commands, and vgmetadatacopies
for vg commands).  The latter option would likely just require a simple
'strncpy' check against cmd->command->name to qualify the merge_synonym
call.

Update nightly tests to cover the pvmetadatacopies synonym.

Note that this patch is the result of an eariler review comment for
the implicit pvcreate patches.  Should apply cleanly on top of the
implicit pvcreate patches (I applied after patch 10/10 in that series).

NOTE: This patch will require --pvmetadatacopies for vgconvert as
--metadatacopies is no longer accepted.
2009-10-05 20:55:56 +00:00
Dave Wysochanski
a7dfe4f24d Update help messages for vgextend / vgcreate to mention PHYSICAL DEVICE OPTIONS. 2009-10-05 20:22:58 +00:00
Dave Wysochanski
2e201936e4 Add implicit pvcreate support to vgcreate and vgextend.
Adds implicit pvcreate support when calling vgcreate or vgextend with
device paths that are not yet PVs.  This changes the behavior of vgcreate
and vgextend from failing with an error message to implicitly pvcreating.
2009-10-05 20:04:08 +00:00
Dave Wysochanski
f900ba63fa Move pvcreate_validate_params into toollib to allow calling from mutiple tools.
For implicit pvcreate support, we need to call this from vgcreate and vgextend,
so move it into toollib.
2009-10-05 20:03:54 +00:00
Dave Wysochanski
879624f591 Refactor vgcreate/vgextend validation of vgname/pvname(s).
Decrement argc and increment argv in a consistent way to allow for later
code-sharing.  Should be no functional change.
2009-10-05 20:03:37 +00:00
Dave Wysochanski
36a1d8166c Refactor pvcreate - split pvcreate_validate_params into recovery/non-recovery.
Split pvcreate_validate_params into recovery and non-recovery parameters.
This is necessary so we can call the non-recovery validate function from
vgextend / vgcreate.  Note in the pvcreate tool case, we must call the
recovery validation function first (see treatment of pe_start and --zero),
and that we add a call to fill_default_pvcreate_params before the validation
functions.
2009-10-05 20:03:25 +00:00
Dave Wysochanski
29123aa652 Add pvcreate_params to vg_extend.
Another refactoring for implicit pvcreate support.  We need to get
the pvcreate parameters somehow to the vg_extend routine.  Options
seemed to be:
1. Attach the parameters to struct volume_group.  I personally
did not like this idea in most cases, though one could make an
agrument why it might be ok at least for some of the parameters
(e.g. metadatacopies).
2. Pass them in to the extend routine.  This second route seemed
to be the best approach given the constraints.

Future patches will parse the command line and fill in the actual
values for the pvcreate_single call.
Should be no functional change.
2009-10-05 20:02:48 +00:00
Alasdair Kergon
437219e27d More makefile cleaning up and fixing. (gentoo) 2009-10-05 13:46:00 +00:00
Alasdair Kergon
db8b5af9d9 Allow for a build directory separate from the source. 2009-10-02 19:10:31 +00:00
Alasdair Kergon
3d32c5f88b Add percent_range to copy_percent too. 2009-10-01 01:04:27 +00:00
Alasdair Kergon
78ad1549a5 Introduce percent_range_t and centralise snapshot full/mirror in-sync checks. 2009-10-01 00:35:29 +00:00
Alasdair Kergon
4b12fa1377 Make poll_mirror_progress a function that can be replaced. 2009-09-30 18:15:06 +00:00
Alasdair Kergon
42dd692bea Factor out poll_mirror_progress and introduce progress_t. 2009-09-30 17:43:51 +00:00
Peter Rajnoha
aad0d06cf9 Just a cleanup from previous commit. We don't need pvname local var in _activate_lvs_in_vg anymore... 2009-09-30 12:05:25 +00:00
Alasdair Kergon
5b6fad120f look up pvmove by pvmove LV when PVMOVE flag is set 2009-09-29 20:33:49 +00:00
Alasdair Kergon
93bbc31c83 Don't attempt to restart pvmoves when deactivating LVs in vgchange.
Restart lvconverts in vgchange by sharing lv_spawn_background_polling.
2009-09-29 20:22:35 +00:00
Alasdair Kergon
724de2791e Generalise polldaemon code by changing mirror-specific variable names. 2009-09-29 19:35:26 +00:00
Alasdair Kergon
c9b9c79b03 Fix log fn prototype. 2009-09-26 00:29:13 +00:00
Dave Wysochanski
68fac97a07 Add vg_is_resizeable() and cleanup references.
Clean up VG_RESIZEABLE flag by creating vg_is_resizeable().
Update comment - we no longer have ALLOW_RESIZEABLE.
Also use vg_is_exported() in one place missed by earlier patch.
Should be no functional change.
2009-09-15 18:35:13 +00:00
Alasdair Kergon
663bf8f7f6 pre-release cleanup 2009-09-15 13:49:10 +00:00
Dave Wysochanski
266214db84 Fix process_each_vg / _process_one_vg when vg_read() returns FAILED_LOCKING.
Remove the checks for vg_read_error() in most of the tools callback
functions and instead make the check in _process_one_vg() more general.

In all but vgcfgbackup, we do not want to proceed if we get any error
from vg_read().  In vgcfgbackup's case, we may proceed if the backup
is to proceed with inconsistent VGs.  This is a special case though,
and we mark it with the READ_ALLOW_INCONSISTENT flag passed to
process_each_vg (and subsequently to _process_one_vg).

NOTE: More cleanup is needed in the vg_read_error() path cases.
This patch is a start.
2009-09-15 01:38:59 +00:00
Alasdair Kergon
651ff9b328 Add lots of missing stack debug messages to tools.
Make readonly locking available as locking type 4.
Fix readonly locking to permit writeable global locks (for vgscan). (2.02.49)
2009-09-14 22:47:49 +00:00
Dave Wysochanski
905240f91d Use vg_is_exported(vg) macro everywhere.
This patch is all just cleanup and no other patch depends on it.
Replace explicit dereference and check with vg_is_exported().
Update a few copyrights and remove unnecessary whitespace.
Should be no functional change.
2009-09-14 19:44:15 +00:00
Peter Rajnoha
9a9026c29f Add y|--yes option for dmsetup to provide a default 'YES' answer to questions. 2009-09-11 15:53:57 +00:00
Peter Rajnoha
3649fa9e41 Fix Makefile to take into account dmsetup's reconfiguration. 2009-09-11 15:52:22 +00:00
Dave Wysochanski
d50795ed09 Split vg_remove_single into 2 functions - the second part commits to disk.
Split vg_remove_single into vg_remove_check (mandatory checks before
vgremove) and vg_remove (do actual remove by committing to disk).

In liblvm, we'd like to provide an consistent API that allows multiple
changes in memory, then let lvm_vg_write() control the commit to disk.  In
some cases (for example, lvresize calls fsadm) this may not be possible.
However, since we are using an object model and dividing things into small
operations, the most logical model seems to be the lvm_vg_write model, and
handling the special cases as they arrive.  So as best as possible
we move towards this end.

A possible optimization would be to consolidate vg_remove (committing)
code with vgreduce code.  A second possible optimization is making vgreduce
of the last device equivalent to vgremove.  Today, lvm_vg_reduce fails if
vgreduce is called with the last device, but from an object model perspective
we could view this as equivalent to vgremove and allow it.  My gut feel is
we do not want to do this though.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:39:29 +00:00
Dave Wysochanski
940077d030 Rename internal library function vg_remove to vg_remove_mdas.
Later patches should consolidate the vgremove / vgreduce functions but for
now let's clarify what vg_remove actually does by changing the name.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:39:07 +00:00
Dave Wysochanski
b40b65fb3c Update vgrename to take into account vgname lock ordering.
Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:29:40 +00:00
Dave Wysochanski
90aa7de640 Refactor vgrename into vg_rename_old and vg_rename_new.
Should be no functional change.
Will allow us to reorder lock obtaining if needed.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:29:23 +00:00
Dave Wysochanski
3d9c2d86b0 Change vgmerge behavior to open/lock first vg based on alphabetical ordering.
This enforces our alphabetical lock ordering rules for vgmerge.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:28:43 +00:00
Dave Wysochanski
7c86e3909c Refactor vgmerge - combine _vgmerge_to and _vgmerge_from into _vgmerge_vg_read.
These functions are identical so should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:28:27 +00:00
Dave Wysochanski
af9ded781d Refactor vgmerge - create _vgmerge_from and _vgmerge_to.
These functions are really identical but for clarity I made them separate
functions in this patch.

Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:28:10 +00:00
Dave Wysochanski
115bc65bae Refactor vgmerge - introduce lock_vg_from_first flag.
Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:27:55 +00:00
Dave Wysochanski
ae4ca998a3 Change vgsplit behavior to open/lock first vg based on alphabetical ordering.
If the destination vgname comes before the source vgname, we must open the
destination first because of the locking rules.  Thus, do a strcmp and set
the flag based on the comparison.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:27:39 +00:00
Dave Wysochanski
eb7c87e90d Refactor vgsplit - reorder _vgsplit_from and _vgsplit_to based on flag.
Slight functional change.  If we open the destination first, we cannot
know the 'fmt'.  In this case we use the default metadata type unless
the user has specified -M on the cmdline.  If not, in most cases this
is fine since we use the LVM2 default metadata type.  However, if the
user is specifying a non-default metadata type (e.g. lvm1) and the order
of the names is such that we have to open the destination (vg_to) first,
we have a problem.  So in this case, we require the use of -M and vgsplit
will fail with an error if not.  I've updated the man page to recommend
the usage of -M in this case.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:27:22 +00:00
Dave Wysochanski
392b185173 Refactor vgsplit: _vgsplit_from or _vgsplit_to failure cleanup depends on order.
Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:27:05 +00:00
Dave Wysochanski
d1c45aa74f Refactor vgsplit - create _vgsplit_from function to open source vg.
Should be no functional change and allows future reorder of source and dest
vgs.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:26:50 +00:00
Dave Wysochanski
501fda8056 Refactor vgsplit - create _vgsplit_to function which creates or opens dest vg.
Move the creating/opening of the destination vg into its own function so later
we can reorder the source / destination vg opening based on the alphabetical
lock order rule.

Should be no functional change but code is a bit tricky.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:26:34 +00:00
Dave Wysochanski
ab2d981a97 Refactor vgsplit - add 'lock_vg_from_first' flag.
Introduce 'lock_vg_from_first' flag to retain which vg was locked first.
Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:26:18 +00:00
Dave Wysochanski
9cc31e6dff Refactor vgsplit - remove bad2 label.
No functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:26:01 +00:00
Dave Wysochanski
5bad8ac847 Refactor vgsplit to move existing_vg logic in a separate 'if' statement.
This will aid in future refactorings and allow for us to reorder the source
and destination vg based on alphabetical names.
Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:25:44 +00:00
Milan Broz
3c0cfa8f3c Fix global locking in PV reporting commands (2.02.49). 2009-08-24 11:37:20 +00:00
Dave Wysochanski
cdc8e54e3d Fix error paths for vgcfgrestore when locking fails. 2009-08-13 17:16:38 +00:00
Petr Rockai
ea30184099 Make lvchange --refresh only take a read lock on volume group. 2009-08-13 14:27:32 +00:00
Dave Wysochanski
acac361359 Fix vgextend error path - if ORPHAN lock fails, unlock and release vg.
Full changes
- Fix vgextend error path when lock_vol(VG_ORPHANS) fails
- Move lock_vol(VG_ORPHANS) before archive(vg) - safe & simpler error paths
- Remove legacy comment/code that no longer applies

Found in review - Milan Broz <mbroz@redhat.com>
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-08-13 12:03:46 +00:00
Peter Rajnoha
b23fadb965 Fix semaphore includes in dmsetup for udev sync. 2009-08-06 15:56:50 +00:00
Peter Rajnoha
e637f732ed Add 'udevcookies' command for dmsetup. 2009-08-06 15:05:10 +00:00
Peter Rajnoha
f9ff23dffe Add 'udevcomplete_all' command for dmsetup. Export DM_COOKIE_MAGIC in libdevmapper.h. 2009-08-06 15:04:30 +00:00
Peter Rajnoha
49886d0982 Add --noudevsync option for relevant LVM tools. 2009-08-04 15:53:04 +00:00
Alasdair Kergon
cf8235e0aa Add activation/udev_sync to lvm.conf. 2009-08-04 15:36:13 +00:00
Alasdair Kergon
a74be32bf6 Manage without dm_udev_cleanup? 2009-08-03 18:01:45 +00:00
Alasdair Kergon
f86117e3d5 cleanup some ignored return values & 'stack's 2009-08-03 11:20:15 +00:00
Petr Rockai
f5cb304acb Make lvconvert honour log mirror options combined with downconversion.
(RHBZ 463272)
2009-08-02 21:59:21 +00:00
Petr Rockai
d25584e4fb Slightly refactor mirror log conversions in lvconvert. 2009-08-02 21:56:29 +00:00
Alasdair Kergon
2c0dfdf839 Add udevcomplete and --noudevwait to dmsetup. 2009-07-31 17:51:45 +00:00
Mike Snitzer
04b2a4bdcf Add --dataalignmentoffset to pvcreate to shift start of aligned data area
Adds pe_align_offset to 'struct physical_volume'; is initialized with
set_pe_align_offset().  After pe_start is established pe_align_offset is
added to it.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
2009-07-30 17:45:28 +00:00
Dave Wysochanski
9085c301e0 Rename _override_settings into override_config_tree_from_string and move.
Move _override_settings from tools/lvmcmdline.c into lib/config/config.c
and export so we can re-use in liblvm.
2009-07-27 21:01:56 +00:00
Dave Wysochanski
776ac1562e Refactor _override_settings to take the new config string as input.
We will re-use this function from liblvm.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 21:01:36 +00:00
Dave Wysochanski
9963d0710e Move extents_from_size from lvcreate into internal library so we can reuse.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:34:09 +00:00
Dave Wysochanski
c42b235610 Move _lvcreate into the internal library and rename to lv_create_single.
After some refactorings, we can now move the bulk of _lvcreate into the
internal library, and we can call from liblvm.  In the future, we should
refactor lv_create_single further, probably by segtype, to reduce the
size of struct lvcreate_params.  For now this is a reasonable refactor
and allows us to re-use the function from liblvm.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:33:35 +00:00
Dave Wysochanski
e6479dff9f Move pvs and pv_count fields from lvcreate_params to lvcreate_cmdline_params.
No functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:32:50 +00:00
Dave Wysochanski
81779abd54 Comment lvcreate_params struct.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:32:26 +00:00
Dave Wysochanski
7a0b0db17e Move 'size' from lvcreate_params into lvcreate_cmdline_params.
The main _lvcreate function should deal with extents - the 'size' parameter
is just an intermediate step.
Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:32:00 +00:00
Dave Wysochanski
8842d526b2 Move percent_t from struct lvcreate_params to struct lvcreate_cmdline_params.
Create a new structure, lvcreate_cmdline_params, to store parameters only
relevant for the cmdline, not the library call to lvcreate.
Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:31:41 +00:00
Dave Wysochanski
8675b317ff Refactor extents calculations / updates in _lvcreate.
Move extents calculation adjustments into their own local functions
right after we read the vg.  This calculation really is not part of
the LV create function but is rather an adjustment to the parameters
based on what is given on the cmdline.  So we move it outside the main
_lvcreate.

Should be no functional change.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:31:18 +00:00
Dave Wysochanski
9091827c46 Refactor _lvcreate - move *_ARG into _lvcreate_params and get 'cmd' from 'vg'.
A couple simple refactorings of _lvcreate - should be no functional change.
Move tags_ARG parsing into _lvcreate_params.  Also use lp->voriginsize
instread of arg_count().  These refactorings make it easier to move the
bulk of _lvcreate into the library.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 02:30:57 +00:00
Dave Wysochanski
aa496e4c23 Move ORPHAN_VG lock outside pvcreate_single.
The implicit pvcreate require either moving the ORPHAN_VG lock outside
pvcreate_single or somehow having the function know or detect whether
the ORPHAN_VG lock is already held.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 01:54:20 +00:00
Dave Wysochanski
d4b6a8aa2a Move bulk of pvcreate logic into library.
In preparation for implicit pvcreate during vgcreate / vgextend,
move bulk of pvcreate logic inside library.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 01:53:09 +00:00
Dave Wysochanski
e6923120b9 Revert previous patch that moved VG_ORPHAN lock inside vg_extend.
We must hold the VG_ORPHAN lock until we commit to disk.  Otherwise,
we risk a race condition on vgcreate / vgextend.  Reverts the following
commit:

commit 72a41480ba
Author: Dave Wysochanski <dwysocha@redhat.com>
Date:   Fri Jul 10 20:09:21 2009 +0000

    Move orphan lock obtain/release inside vg_extend().

    With this change we now have vgcreate/vgextend liblvm functions.
    Note that this changes the lock order of the following functions as the
    orphan lock is now obtained first.  With our policy of non-blocking
    second locks, this should not be a problem.

    Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-24 15:01:43 +00:00
Dave Wysochanski
fd443e0245 Remove redundant validate_name in vgreduce.
This check is now done in vg_read_for_update, thanks to mornfall.
Should be no functional change.

Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-24 11:13:36 +00:00
Alasdair Kergon
b68cc09932 Return EINVALID_CMD_LINE not success when invalid VG name format is used. 2009-07-21 11:10:49 +00:00
Alasdair Kergon
d917192f00 Add lvm_errno and lvm_errmsg to liblvm to obtain failure information.
Change create_toolcontext to still return an object if it fails part-way.
Add EUNCLASSIFIED (-1) as the default LVM errno code.
2009-07-16 00:36:59 +00:00