1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
Commit Graph

435 Commits

Author SHA1 Message Date
Vratislav Podzimek
3e31f51869 dbus: fix the systemd service providing the DBus service
Correct name is lvm2-lvmdbusd.service not lvmdbusd.service.
This makes the bus-activation (auto-activation) work.

Signed-off-by: Vratislav Podzimek <vpodzime@redhat.com>
2016-02-26 10:20:08 +01:00
Alasdair G Kergon
5987562cf9 lvmdbus: Add new daemon. 2016-02-17 23:53:35 +00:00
Peter Rajnoha
55056c2d16 vgimportclone: fix VG name variable reference in error message after failed PV uuid change 2016-01-21 14:47:48 +01:00
Zdenek Kabelac
fcbef05aae doc: change fsf address
Hmm rpmlint suggest fsf is using a different address these days,
so lets keep it up-to-date
2016-01-21 12:11:37 +01:00
Peter Rajnoha
4304a95dfd lvmdump: also add lvm2-activation{-early,-net}.service systemd status for lvmdump -s
The lvm2-activation{-early,-net}.service systemd unit statuses were missing
in dump gathered by lvmdump -s. These are quite important when debugging
scenarios with systemd environment and where lvmetad is not used.
2016-01-04 15:12:25 +01:00
Zdenek Kabelac
bbef4edd06 makefiles: switch to rpath-link
Plain rpath is to invasive and gets into binary.
We only want to provide hint for linker.
2015-10-14 00:51:55 +02:00
Zdenek Kabelac
a91fbe9d27 makefiles: older gcc needs hint with rpath
gcc 4.3 seems not to be able to find linked library without
specifying -rpath to linker  (plain -L) is not enough.
2015-10-13 22:02:17 +02:00
Zdenek Kabelac
83f00e9156 makefiles: drop explicit linking
Nothing in /sscripts needs devmapper-event library so drop its linking.
2015-10-13 16:02:20 +02:00
Peter Rajnoha
75420282e1 vgimportclone: make sure there's no prefix in VG name list
Make sure log/prefix is set to "" when getting the list of VG names.
We need this for the format to be correct so it's properly searched
through later on.
2015-10-12 12:54:59 +02:00
Peter Rajnoha
38df48d108 vgimportclone: fix vgimportclone with -n to not add number unnecessarily to base VG name
$ vgcreate vgA /dev/sda
  Volume group "vgA" successfully created

$ dd if=/dev/sda of=/dev/sdb bs=1M
$ dd if=/dev/sda of=/dev/sdc bs=1M

(the new VG name is prefix of existing VG name)
$ vgimportclone -n vg /dev/sdb

(the new VG name is suffix of existing VG name)
$ vgimportclone -n gA /dev/sdc

Before this patch:
------------------
(we end up with "vg1" and "gA1" names with the "1" suffix which is not needed)
$ vgs -o vg_name
  VG
  gA1
  vg1
  vgA

With this patch applied:
------------------------
(we end up with "vg" and "gA" names as they're unique already and no extra suffix is added)
$ # vgs -o vg_name
  VG
  gA
  vg
  vgA

Of course, if the name supplied is not unique, the number is added correctly:
$ dd if=/dev/sda of=/dev/sdb bs=1M
$ vgimportclone -n vgA /dev/sdb
$ vgs -o vg_name
  VG
  vgA
  vgA1
2015-10-12 11:11:34 +02:00
Peter Rajnoha
1f30ba6178 vgimportclone: cleanup the script and remove dependency on awk, grep, cut and tr
We can replace the expressions with awk/grep/cut/tr with --select now and
more suitable reporting options and modes. Also, we don't need to check
the temporary lvm.conf generated within vgimportclone script since we're
generating it ourselves now using lvmconfig, not using sed anymore like
it was before (so we can be pretty sure it's correct - we use lvmconfig
now even for generating the lvm.conf itself).
2015-10-09 16:31:02 +02:00
Zdenek Kabelac
4b1cadbd87 man: fsadm 2015-10-06 15:21:36 +02:00
Peter Rajnoha
5f7a94a03e blkdeactivate: recognize and deactivate MD devices too 2015-10-06 13:25:41 +02:00
Peter Rajnoha
cb82919b0d systemd: use {local,remote}-fs-pre.target instead of {local,remote}-fs.target
We want most of our units to be started before any local/remote mount
points are mounted - we used {local,remote}-fs.target for this purpose
before, but it was not 100% correct as there's even {local,remote}-fs-pre.target
special systemd unit reserved for this exact purpose.

See also man 7 systemd.special and "local-fs-pre.target"/"remote-fs-pre.target"
description.
2015-09-23 13:30:51 +02:00
Peter Rajnoha
001f747963 lvmconf: set locking_type=2 if external library is requested
Also, set safe use_lvmetad=0 for external locking (locking_type=2)
similarly to locking_type=3.
2015-09-22 13:33:12 +02:00
Zdenek Kabelac
e42ee69988 vgimporeclone: use correct cache dir path
Commit 00b36ef06a had a typo
and missed '{' for shell variable, thus command used slightly
different 'tmp' dir name for cache dir (with extra '}').

Such change was unnoticed until a recent fix in persistent
filter, lvm2 missed to update cache file when --config
was specified.

The result was, /tmp dir was accumulating snap.XXXXX} dirs when
running vgimportclose  script.
2015-09-14 09:31:26 +02:00
Zdenek Kabelac
fd3d795b93 makefiles: distclean missing files 2015-09-11 21:52:27 +02:00
Alasdair G Kergon
3934ade5a2 gitignore: Update for in-place build. 2015-07-27 13:18:35 +01:00
Peter Rajnoha
cb305b9fc0 lvmconf: fix ignored --startstopservices in lvmconf ... --mirrorservice on systemd
If running lvmconf ... --startstopservice --mirrorservice in systemd
environment, handle lvm2-cmirrord accordingly. A typo in the script
caused the lvm2-cmirrord to not start/stop immediately, it was
only enabled/disabled (so the --startstopservice was ignored in this
case).
2015-07-09 10:40:14 +02:00
David Teigland
fe70b03de2 Add lvmlockd 2015-07-02 15:42:26 -05:00
Zdenek Kabelac
9c86d33e68 cleanup: avoid printing gcc warning
Casting to (void) with gcc doesn't remove unused_result warning.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25509
2015-06-23 11:06:02 +02:00
Peter Rajnoha
ba68aed836 scripts: activation generator: do not use --sysinit if lvmpolld used
If lvmetad is not used, we generate lvm2-activation{-early,-net}.service
systemd services to activate any VGs found on the system. So far we used
--sysinit during this activation as polling was still forked off of the
lvm activation command.

This has changed with lvmpolld - we have proper lvmpolld systemd
service now (activated via its socket unit). As such, we don't need
to use --sysinit anymore during activation in systemd environment
as polling was the only barrier to remove the need for --sysinit.
2015-05-21 12:20:30 +02:00
Ondrej Kozina
2bbf0425e7 lvmdump.sh: print out lvmpolld service status 2015-05-11 19:07:47 +02:00
Ondrej Kozina
e587b0677b lvmpolld: Add standalone polldaemon.
See doc/lvmpolld_overview.txt
2015-05-09 00:59:18 +01:00
Alasdair G Kergon
3f0434057b config: Introduce lvmconfig.
'lvm dumpconfig' now does a lot more than just dumping configuration
information and is no longer only a support tool.  Users now need
to run it to find out about configuration information that has been
removed from the lvm.conf man page so we need to promote this to full
command line status as 'lvmconfig'.  Also accept 'lvm config' and mention
it in the usage information of lvmconf (which should also get merged in
eventually).
2015-04-28 17:00:37 +01:00
Peter Rajnoha
375ed98ae9 make: move blkdeactivate script and blkdeactivate.8 man page installation from install_lvm2 to install_device-mapper target
This completes commit 7a4e27eee5.
2015-04-14 15:24:37 +02:00
Peter Rajnoha
7a4e27eee5 blkdeactivate: check for lvm binary and skip LVM processing if not present
This removes dependency on lvm binary - if it's not present, all LVM
processing is skipped (shouldn't normally happen because if lvm binary
is missing then there's obviously nothing that would activate it, but
let's make sure).

Without this tight dependency on lvm, the blkdeactivate script can
be packaged with libdevmapper/dmsetup (in contrast to lvm as it was
before) and as such the script can still be used to handle other DM
devices.
2015-04-14 13:35:11 +02:00
Peter Rajnoha
f814d763c6 lvmconf: add --enable-halvm, --disable-halvm, --services, --mirrorservice, --startstopservices options and use proper global/use_lvmetad default value
This patch adds new options to lvmconf:

  --enable-halvm (just like --enable-cluster, but configure LVM
                  for use in HA LVM - meaning disabling lvmetad and
                  making sure we have locking_type=1)

  --disable-halvm (just like --disable-cluster, but configure LVM
                   back from HA LVM - meaning enabling lvmetad if
                   it's enabled by default and making sure we have
                   default locking type set)

  --services (causes clvmd and lvmetad services to be enabled or
              disabled appropriately and conforming to the changes
              in lvm configuration we've just made with lvmconf)

  --mirrorservice (in addition to clvmd and lvmetad services, also
                   enable or disable cmirrord service appropriately;
                   this is a separate option because cmirrord is
                   optional and it doesn't need to be always enabled
                   when clvmd is enabled)

  --startstopservices (in addition to enabling or disabling services,
                       start and stop these services immediately)

These options are supposed to help users to make their system ready
for cluster with clvmd (active-active) or HA LVM (active-passive) use
while lvmconf script can handle services as well so users don't need
to bother about setting them manually.

Also, before this patch, we hardcoded global/use_lvmetad=0 as default
value in lvmconf script. Howeverm this default may change by just
flipping the value in config_settings.h and we may forget to edit
the lvmconf. It's better to use lvm dumpconfig --type default global/use_lvmetad
to get the actual default value and use this one instead of hardcoded one.
2015-04-13 15:27:17 +02:00
Peter Rajnoha
20c6192fbb systemd: stop lvm2-monitor.service before dm-event.service 2015-03-31 15:50:16 +02:00
Michael Lass
666738d57a systemd: stop lvm2-pvscan@.service before lvm2-lvmetad.service
When lvm2-pvscan@.service and lvm2-lvmetad.service are scheduled to be
stopped lvm2-pvscan@.service should be stopped first since pvscan uses
lvmetad.

This is especially important if lvm2-lvmetad.socket is also scheduled to
be stopped as in this case connection requests are suppressed causing
pvscan to fail.
2015-03-31 15:47:01 +02:00
Peter Rajnoha
05f23e7763 systemd: blk-availability.service: add After=iscsi-shutdown.service
The iscsi-shutdown.service is the one responsible for logging out
iscsi sessions so blk-availability.service (running the blkdeactivate
script) should be run before that on shutdown (so we need to use
After=iscsi-shutdown.service because "After" relates to starting
the service and the opposite order is automatically applied on
stopping the service at shutdown).
2015-03-13 12:08:20 +01:00
Peter Rajnoha
e09f8a82f1 initscripts: lvm2-monitor: use @DMEVENTD_PIDFILE@ instead of hardcoded /var/run/dmeventd.pid 2015-02-27 15:48:10 +01:00
Jose Castillo
57e9e76da4 initscripts: lvm2-monitor: implement status action
Two new functions added in the init script: rh_status and rh_status_q.
First one to be used in status() and second one to be used in start(),
stop(), force_stop(). Check for 'dmeventd' added and print list of
lvs being monitored in status().
2015-02-27 15:38:34 +01:00
David Teigland
a164d603d3 vgimportclone: remove arg check that uses pvs
The arg check using pvs is unnecessary.  If the arg is not a PV,
the command will just fail later.  Using the pvs command at this
point in the command is a problem when lvmetad is running, because
the pvs command does not report duplicate PVs when using lvmetad.
(Alternatively, use_lvmetad could be disabled by adding a --config
override to this pvs command.)
2015-01-20 13:08:22 -06:00
Alasdair G Kergon
8f90f632f5 vgimportclone: Say safe to ignore lvmetad message. 2015-01-17 11:29:38 +00:00
Peter Rajnoha
6a77b6f43c scripts: clvmd: replace awk functionality with LVM's selection
No need to use awk now to get appropriate VGs/LVs, use LVM's
own --select - it's quicker, it removes a need for external
dependency on awk and it's also more readable.
2015-01-09 16:41:07 +01:00
Peter Rajnoha
b21a8412c4 vgimportclone: also notify lvmetad about changes if it's used
All the LVM commands are run in mode without lvmetad use (since lvmetad
can't handle duplicates). When we're finished with vgimportclone, we
need to notify lvmetad about changes.

Before this patch (/dev/sda and /dev/sdb contains a copy VG called "vg"):
$ vgimportclone --basevgname vg_snap /dev/sdb
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  WARNING: Activation disabled. No device-mapper interaction will be attempted.
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  Physical volume "/tmp/snap.zcJ8LCmj/vgimport0" changed  1 physical volume changed / 0 physical volumes not changed
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  WARNING: Activation disabled. No device-mapper interaction will be attempted.
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  Volume group "vg" successfully changed
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  Volume group "vg" successfully renamed to "vg_snap"
  Reading all physical volumes.  This may take a while...
  Found volume group "vg" using metadata type lvm2
  Found volume group "fedora" using metadata type lvm2

$ vgs
  VG     #PV #LV #SN Attr   VSize   VFree
  fedora   1   2   0 wz--n-   9.50g      0
  vg       1   1   0 wz--n- 124.00m 120.00m

(...lvmetad doesn't see the new "vg_snap"!)

With this patch applied:
$ vgimportclone --basevgname vg_snap /dev/sdb
  ...
  WARNING: lvmetad is running but disabled. Restart lvmetad before enabling it!
  Volume group "vg" successfully renamed to "vg_snap"
Notifying lvmetad about changes since it was disabled temporarily.
  Reading all physical volumes.  This may take a while...
  Found volume group "vg_snap" using metadata type lvm2
  Found volume group "fedora" using metadata type lvm2
  Found volume group "vg" using metadata type lvm2

$ vgs
  VG      #PV #LV #SN Attr   VSize   VFree
  fedora    1   2   0 wz--n-   9.50g      0
  vg        1   1   0 wz--n- 124.00m 120.00m
  vg_snap   1   1   0 wz--n- 124.00m 120.00m

The "restart lvmetad before enabling it" message is a bit misleading
here - we should probably suppress this one, but we can't suppress
warning messages selectively at the moment and we don't want to lose
other warning/error messages printed...
2014-12-10 14:00:56 +01:00
Peter Rajnoha
00b36ef06a vgimportclone: replace awk with dumpconfig to generate temporary lvm.conf for vgimportclone
With current dumpconfig, we can generate lvm.conf easily - we can merge
current lvm.conf with the config given on cmd line:
  lvm dumpconfig --mergedconfig --config "..."

This is a bit simpler than using awk and it also avoids problems when some of
the configuration is missing in existing lvm.conf file and hardcoded defaults
are used instead. The dumpconfig handles this transparently.
2014-12-10 13:59:38 +01:00
Peter Rajnoha
13e2049c32 initscripts: fix typo in clvmd initscript causing CLVMD_STOP_TIMEOUT variable to be ignored 2014-11-25 15:19:11 +01:00
Peter Rajnoha
a61c5c5b3a revert: 7639eae and 4a52a92
Revert 7639eae891 and
4a52a9212c. We need a better fix here.
2014-11-20 08:22:34 +01:00
Peter Rajnoha
4a52a9212c systemd: clvmd and cmirrord systemd unit - use usrsbindir instead of sbindir 2014-11-19 16:06:05 +01:00
Peter Rajnoha
02628413ca systemd: remove workaround for lvm2-monitor.service's ExecStop line
Bug https://bugzilla.redhat.com/show_bug.cgi?id=843587 is handled better
now - the hang does not occur anymore. There are still error messages
issued though during shutdown if someone stops lvm2-lvmetad.service
manually that lvm2-monitor.service depends on (even during shutdown).
These errors are correct though and will point to incorrect
configuration (still having use_lvmetad=1 in lvm.conf and stopping
lvm2-lvmetad.service manually).

The workaround to prevent the hang is not needed now. So the
'--config "global{use_lvmetad=0}"' is now removed from the
lvm2-monitor.service's ExecStop line.
2014-10-14 10:08:23 +02:00
Zdenek Kabelac
6f6900d457 fsadm: avoid using -a in test 2014-07-02 10:45:41 +02:00
Peter Rajnoha
fea8abe56a systemd: use RemoveOnStop for dm-event.socket and lvm2-lvmetad.socket
Systemd version 214 introduced new "RemoveOnStop" option for socket
units to remove the socket/FIFO when the particular unit is stopped.

Also https://bugzilla.redhat.com/show_bug.cgi?id=802748.
2014-06-13 15:45:25 +02:00
Dongmao Zhang
e9db11f387 systemd: use umask 022 for generated systemd units by lvm2-activation-generator 2014-05-21 10:12:02 +02:00
Peter Rajnoha
7d7c1f2025 systemd: install lvm2-cluster-activation script as executable 2014-05-21 09:45:29 +02:00
Peter Rajnoha
9d64573da1 make: fix commit 1756bf6
"DIST_TARGET" should be "DISTCLEAN_TARGET"
2014-05-07 12:13:36 +02:00
Peter Rajnoha
239ba5bb04 systemd: use lvm binary insetad of command symlink in lvm2-pvscan.service 2014-04-30 15:21:25 +02:00
Peter Rajnoha
81b096af34 systemd: make sysinit.target to pull in lvm2-lvmetad.socket, not sockets.target
The sysinit.target is ordered even before sockets.target and there
may be situations in which the lvmetad is needed early, for example
in rescue.target to activate some LVs on which mountpoints reside.
Also, like in the case of rescue.target, the sockets.target is not
pulled in (unless some other service pulls it in explicitly).

See also: https://bugzilla.redhat.com/show_bug.cgi?id=1087586#c26
for the summary of the problem.
2014-04-30 14:52:10 +02:00
Zdenek Kabelac
1756bf6c63 makefile: fix regression
Commit 1af05a7a16 was incorrect.
Generated files from configure could be only distclean-ed.
(in-release fix)
2014-04-30 10:26:29 +02:00
Zdenek Kabelac
1af05a7a16 makefiles: clear targets in with make clean
Make clean usually cleans all compiled files.
Make distclean cleans configure generated files
2014-04-18 16:38:48 +02:00
Peter Rajnoha
18caa562fe lvmdump: list also inactive units for lvmdump -s 2014-04-15 15:43:20 +02:00
Peter Rajnoha
a6763c64a7 lvmdump: add -s to gather system info and context (currently systemd-related only)
This is sort of info we always ask people to retrieve when
inspecting problems in systemd environment so let's have this
as part of lvmdump directly.

The -s option does not need to be bound to systemd only. We could
add support for initscripts or any other system-wide/service tracking
info that can help us with debugging problems.
2014-04-15 15:27:30 +02:00
Peter Rajnoha
ce78cb58eb lvmdump: add lvm dumpconfig --type diff/missing
For a quick overview of config when debugging and to quickly check
which values are different from defaults and which are not defined
in the config and for which defaults are used.
2014-03-25 13:06:59 +01:00
Peter Rajnoha
031666ef66 man: add man page for lvm2-activation-generator 2014-03-13 13:01:06 +01:00
Peter Rajnoha
f33a224ef0 scripts: use --ignoreskippedcluster in lvm2-monitor initscript/systemd unit
When clustered VG is available in the system but we don't have
clustering set up for whatever reason, the lvm2-monitor scripts should
not fail completely just because these clustered VGs are skipped during
vgs/vgchange calls in lvm2-monitor initscript/systemd unit.
2014-02-17 16:29:49 +01:00
Peter Rajnoha
554159d519 systemd: do not use default dependencies for clvmd/cmirrord units
Do not use default dependencies that systemd adds to the units
so we have better control of when the service is started/stopped
and we don't end up with unexpected behaviour.
2014-02-14 14:37:19 +01:00
Peter Rajnoha
4210219a8b systemd: Use --ignoreskippedcluster in generated activation systemd units
When the activation units are generated if use_lvmetad=0 (no
autoactivation), use --ignoreskippedcluster option for vgchange calls
since the cluster with cLVM is set up by separate units.

This avoids a situation in which the generated activation units are
improperly in failed state just because of the vgchange return value
when clustered VGs are encountered while the activation of non-clustered
VGs does proceed normally.
2014-02-14 11:59:12 +01:00
Peter Rajnoha
1a5062c9a7 cleanup: clarify man pages about lvchange/vgchange -aay, use -aay in lvm2-cluster-activation script 2014-02-11 13:48:04 +01:00
Peter Rajnoha
a092cd33be systemd: rename lvm2-cluster-activation and lvm2-clvmd services to follow existing naming
lvm2_cluster_activation_red_hat.service.in -> lvm2_cluster_activation_systemd_red_hat.service.in
lvm2_clvmd_red_hat.service.in -> lvm2_clvmd_red_hat.service.in

Edit lvm2-cluster-activation reference on cmirror - take new
lvm2-cmirrord.service, it was just cmirrord(.service) before
as the old initscript was used in compatibility mode.

Also, use WantedBy=multi-user.target instead of sysinit.target
in lvm2-cluster-activation.service.
2014-02-11 10:12:39 +01:00
Peter Rajnoha
ef91de2a0c systemd: add systemd unit for cmirrord 2014-02-11 10:06:19 +01:00
Ondrej Kozina
fd41dd8f9c Add systemd native service for clvmd and cluster activation
The commit splits original clvmd service in two new native services
for systemd enabled systems while original init scripts remain unaltered.

New systemd native services:

  1) clvmd daemon itself (lvm2_clvmd_red_hat.service.in)
  2) (de)activation of clustered VGs (lvm2_cluster_activation_red_hat.service.in)

There're several reasons to split it. First, there's no support for conditional
stop in systemd and AFAIK they don't plan to support it. In other words:
if the deactivation fails for some reason, systemd doesn't care and will simply
kill all remaining processes in original cgroup (by default). Killing the
remaining procs can be suppressed however it doesn't solve the following problem:

You can't repeat the stop command of a failed service. The repeated stop command
is simply not propagated to the service in a failed state. You would have to start
and then try to stop the service again. Unfortunately, this can't be done while
the daemon is still running (and we need the daemon to stay active until all
clustered VGs are deactivated properly).

In a separated setup we need only to restart the failed activation service and
that's fine.
2014-02-10 17:13:49 +01:00
Peter Rajnoha
ffa623c53d systemd: cleanup for lvmetad systemd unit
No need to fork lvmetad when running under systemd.
Also, the "lvmetad -R" support has been removed in lvm2 v2.02.98
so remove the ExecReload line that called it on "systemctl reload".
2014-02-10 16:20:45 +01:00
Peter Rajnoha
8a8abc5ed9 dmeventd: fix dmeventd -R to work properly with systemd
Trying to restart dmeventd as a reload action is causing problems
under systemd environment. The systemd loses track of new dmeventd
this way. See also https://bugzilla.redhat.com/show_bug.cgi?id=1060134
for more info.

We need to call dmeventd -R directly instead of "systemctl reload dm-event.service"
that was used before (the reload is aimed at configuration reload anyway,
not stateful restart of the daemon - we did this before just because
there's no ExecRestart in systemd and there's only ExecStart and
ExecStop with which we'd lose the state).

Also, use ExecStart="dmeventd -f" to run dmeventd in foreground
(and let's rely on systemd to daemonize it) and change the
service type from "forking" to "simple".
2014-02-06 17:15:19 +01:00
Zdenek Kabelac
59336a2a06 fsadm: use xfs_repair when available
Since support for xfs_check is going to be obsoleted,
replace its usage with xfs_repair -n tool.

However this tool needs further intrumentation, since for really small
xfs devices (having just 1 allocation group) it needs to pass in
flag: "-o force_geometry". As we run the tool with '-n', it should
be safe to pass this flag always.

FIXME: figure way without always passing this flag.
2014-01-20 11:57:39 +01:00
Peter Rajnoha
359291b41c systemd: use only major:minor for pvscan in lvm2-pvscan@.service
When using filters for the pvscan --cache (the global_filter),
there's a difference between:

  pvscan --cache -aay /dev/block/<major>:<minor>

and

  pvscan --cache -aay <major>:<minor> (or --major <major> --minor <minor>)

In the first case, we need to be sure to have an exact matching line
in the filter for the device to be used, no aliases are considered
So for example even if we have accept rule for "/dev/sda" present,
this won't apply for "/dev/block/8:0" even though it's the same device!
This is because we're comparing the path used on command line directly
with the path written in the rule.

For the second one, any alias mentioned in the filter will apply
as we're comparing the major and minor pair, not looking at actual
device names - so any alias mentioned in the rules will suffice for
the filtering rule to apply.

For the global_filter to be properly used, we need to call the
second one in the lvm2-pvscan@.service - nobody is able to tell
what value of major:minor the kernel assignes next time, hence
this bug makes the use of global_filter quite unusable!
2013-12-18 12:23:59 +01:00
Peter Rajnoha
a8b5dce997 systemd: make sure lvm2-lvmetad.socket is available for lvm2-pvscan@.service 2013-12-17 10:40:32 +01:00
Peter Rajnoha
73a109d434 lvmdump: follow symbolic links in /etc/lvm 2013-12-05 16:36:45 +01:00
Peter Rajnoha
481edce41f compile/link: use RELRO/PIE compiler/linker options for executables 2013-12-05 14:03:10 +01:00
Peter Rajnoha
1dd6626696 cleanup: for commit 546db1c
- properly clean lvm2-pvscan@.service on distclean
 - use @sbindir@ for sbin path in ExecStop
2013-10-23 09:48:33 +02:00
Peter Rajnoha
b109bfc1ef blkdeactivate: fix endless loop if device(s) given and unable to umount/deactivate
The blkdeactivate script iterates over the list of devices if they're
given as an argument and it tries to umount/deactivate them one by one.

This iteration failed to proceed if any of the umount/deactivation
was unsuccessful - there was a missing "shift" call to move to the
next argument (device) for processing. As a result of this, the same
device was tried again and again, causing an endless loop, never
proceeding to the next device given.
2013-10-22 16:24:39 +02:00
Peter Rajnoha
3fee661028 udev+systemd: refine lvm2-pvscan@.service to better track device existence
When using ENV{SYSTEMD_WANTS}=lvm2-pvscan@... to instantiate a service
for lvmetad scan when the new PV appears in the system, the service
is started and executed. However, to track device removal, we need
to bind it (the "BindsTo" systemd directive) to a certain .device
systemd unit.

In default systemd setup, the device is tracked by it's name and
sysfs path (there's normally a sysfs path .device systemd unit for
a device and then the device name .device unit as an alias for it).
Neither of these two is useful for lvmetad update as we need to bind
it to device's <major>:<minor> pair.

The /dev/block/<major>:<minor> is the essential symlink under /dev
that exists for each block device (created by default udev rules
provided by udev directly). So let's use this as an alias for
the device's .device unit as well by means of "ENV{SYSTEMD_ALIAS}"
declaration within udev rules which systemd understands (this will
create a new alias "dev-block-<major>:<minor>.device".

Then we can easily bind the "dev-block-<major>:<minor>" device
systemd unit with instantiated lvm2-pvscan@<major>:<minor>.service.
So once the device is removed from the systemd, the
lvm-pvscan@<major>:<minor>.service executes it's ExecStop action
(which in turn notifies lvmetad about the device being gone).

This completes the udev-systemd-lvmetad interaction then.
2013-10-22 14:22:40 +02:00
Mike Snitzer
65456a4a29 vgimportclone: remove 2>/dev/null from three lvm commands
There is no point eating stderr for these commands.  In fact the
redirect causes confusion and hurts dubugging.

Also reword an error message if the pvs command fails so as not be
certain that a device is not a PV.  Coupled with removing the stderr
redirect this will improve the user experience in the face of errors.
2013-10-21 18:04:14 -04:00
Peter Rajnoha
546db1c4be udev+systemd: make pvscan --cache -aay run as systemd background job from udev
The new lvm2-pvscan@.service is responsible for on-demand execution
of "pvscan --cache --activate ay" which causes lvmetad to be
updated and LVM activation done if the VG is complete.

Also, use udev-systemd mechanism to instantiate the job as the
lvm2-pvscan@$devnode.service on each newly appeared PV in the system.
This prevents the background job to be killed (that would happen
if it was directly forked from udev rule - this behaviour is seen
in recent versions of udev with the help of systemd that can track
detached processes - the detached process would still be in the same
cgroup).

To enable this official udev-systemd protocol for instantiating
background jobs, use new --enable-udev-systemd-background-jobs
configure switch (it's disabled by default). This option is highly
recommended wherever systemd is used!
2013-10-18 11:38:49 +02:00
Peter Rajnoha
6553f86818 lvmconf: use_lvmetad=0 on --enable-cluster, reset to default on --disable-cluster
lvmetad is not yet supported in clustered environment so
disable it automatically if using lvmconf --enable-cluster
and reset it to default value if using lvmconf --disable-cluster.

Also, add a few comments in lvm.conf about locking_type vs. use_lvmetad
if setting it for clustered environment.
2013-09-24 14:03:42 +02:00
Peter Rajnoha
9742c5192e systemd: run lvm2-activation-net.service after lvm2-activation.service
The lvm2-activation-net.service was ordered only with respect to iscsi
and fcoe service before. In addition to that, we also need ordering
with respect to lvm2-activation.service to prevent parallel vgchange -aay
runs which may cause some problems during activation.
See also https://bugs.gentoo.org/show_bug.cgi?id=480066.

With this patch, the ordering is firmly set to:
lvm2-activation-early.service -> lvm2-activation.service -> lvm2-activation-net.service

Thanks to Alexander Tsoy for the original patch (modified a bit here):
https://www.redhat.com/archives/lvm-devel/2013-September/msg00049.html
2013-09-16 11:47:09 +02:00
Peter Rajnoha
0acd7173d1 systemd: lvm2-activation-generator: remove default dir if args not specified and require all args to be given
Remove default "/tmp" as destination directory if no args
specified for lvm2-activation-generator. Require all the
args to be specified directly for proper functionality.
2013-08-28 16:06:51 +02:00
Peter Rajnoha
99fe3b88d2 systemd: lvm2-activation-generator: report only error otherwise be silent
Do not print success status for lvm2-activation-generator:

  "LVM: Activation generator successfully completed."
  "LVM: Logical Volume autoactivation enabled." (if use_lvmetad=1)

Though this information is quite useful during boot, it may
be confusing for users if it happens anytime later and it
actually happens if systemd reloads. This is usually on package
update to update the systemd state and load any new units that are
newly installed in the system. The systemd reload is global and
so any existing generators are rerun at that moment too.
2013-08-22 08:27:51 +02:00
Michael Stapelberg
8cbbe851a8 systemd: use LVM_PATH instead of hardcoded value in activation generator 2013-08-15 09:59:19 +02:00
Peter Rajnoha
268b370e24 blkdeactivate: add support for bind mounts
Recent version of util-linux/umount (v2.23+) provides
umount --all-targets that can unmount all the mount targets of
the same device (the bind mounts). Use this if available when
calling the umount blkdeactivate.

Otherwise, for older versions of util-linux, use findmnt
(that is also a part of the util-linux) to iterate over all
mount targets of the same device - this is the manual way.
2013-08-13 17:51:40 +02:00
Peter Rajnoha
a854398764 blkdeactivate: change the way blkdeactivate reports status
The blkdeactivate now suppresses error messages from external
tools that are called. Instead, only a summary message "done"
or "skipped" is issued by blkdeactivate as any error in calling
the external tool (e.g. unmounting or deactivating a device) causes
the device to be skipped and the blkdeactivate continues with the
next device in the tree.

Add new -e/--errors switch to display any error messages from
external tools.

Also, suppress any output given by the external tools and add
new -v/--verbose switch to display it including the verbose
output of the tools called (this will enable error reporting
as well).

Also add blkdeactivate -vv for even more debug (the script's debug).
2013-08-13 17:51:23 +02:00
Peter Rajnoha
a03609dee4 systemd: udevadm settle for lvm2-activation-net.service
In case lvmetad is not used, we need to wait for udev to complete
after net-attached storage is initialized (after iscsi/fcoe service).
N.B. This also requires the storage to be attached synchronously
in the kernel itself.
2013-07-24 11:06:38 +02:00
Peter Rajnoha
ea333a894e systemd: lvm2-activation-generator: use LOG_DEBUG/ERR severity for kmsg 2013-07-22 14:04:12 +02:00
Peter Rajnoha
8606bf316a systemd: generator: add lvm2-activation-net.service
The new lvm2-activation-net.service activates LVM volumes
after network-attached devices are set up (iSCSI and FCoE)
if lvmetad is disabled and hence the autoactivation is not
used.
2013-07-17 16:54:52 +02:00
Alasdair G Kergon
c2dc21d89f text: miscellaneous comments & message tweaks 2013-06-15 01:28:54 +01:00
Peter Rajnoha
56ee1de7e4 distclean: add missing items
These were missing in distclean target under scripts dir:
  blk_availability_init_red_hat
  blk_availability_systemd_red_hat.service
  blkdeactivate.sh
2013-06-12 13:14:49 +02:00
Peter Rajnoha
a9fc137fd1 initscripts: add pidfile reference in chkconfig header for clvmd and cmirrord
When the init scripts are run from within systemd, the systemd
needs to know the pidfile for it to work correctly when the
daemon itself is killed. Otherwise, systemd keeps these services
in "active" and "exited state" at the same time
(it assumes RemainAfterExit=yes without the pidfile reference in
chkconfig header).

See also https://bugzilla.redhat.com/show_bug.cgi?id=971819#c5.
2013-06-07 14:07:56 +02:00
Petr Rockai
05bf4b8cc3 vgimportclone: override global_filter in lvm.conf
The global filter in system's lvm.conf may conflict with the custom filter we
set up in vgimportclone (they can easily fail to intersect). Since we explicitly
avoid talking to lvmetad in vgimportclone, it is safe and reasonable to do so.
2013-06-02 00:47:17 +02:00
Jonathan Brassow
2e0740f7ef RAID: Add writemostly/writebehind support for RAID1
'lvchange' is used to alter a RAID 1 logical volume's write-mostly and
write-behind characteristics.  The '--writemostly' parameter takes a
PV as an argument with an optional trailing character to specify whether
to set ('y'), unset ('n'), or toggle ('t') the value.  If no trailing
character is given, it will set the flag.
Synopsis:
        lvchange [--writemostly <PV>:{t|y|n}] [--writebehind <count>] vg/lv
Example:
        lvchange --writemostly /dev/sdb1:y --writebehind 512 vg/raid1_lv

The last character in the 'lv_attr' field is used to show whether a device
has the WriteMostly flag set.  It is signified with a 'w'.  If the device
has failed, the 'p'artial flag has priority.

Example ("nosync" raid1 with mismatch_cnt and writemostly):
[~]# lvs -a --segment vg
  LV                VG   Attr      #Str Type   SSize
  raid1             vg   Rwi---r-m    2 raid1  500.00m
  [raid1_rimage_0]  vg   Iwi---r--    1 linear 500.00m
  [raid1_rimage_1]  vg   Iwi---r-w    1 linear 500.00m
  [raid1_rmeta_0]   vg   ewi---r--    1 linear   4.00m
  [raid1_rmeta_1]   vg   ewi---r--    1 linear   4.00m

Example (raid1 with mismatch_cnt, writemostly - but failed drive):
[~]# lvs -a --segment vg
  LV                VG   Attr      #Str Type   SSize
  raid1             vg   rwi---r-p    2 raid1  500.00m
  [raid1_rimage_0]  vg   Iwi---r--    1 linear 500.00m
  [raid1_rimage_1]  vg   Iwi---r-p    1 linear 500.00m
  [raid1_rmeta_0]   vg   ewi---r--    1 linear   4.00m
  [raid1_rmeta_1]   vg   ewi---r-p    1 linear   4.00m

A new reportable field has been added for writebehind as well.  If
write-behind has not been set or the LV is not RAID1, the field will
be blank.
Example (writebehind is set):
[~]# lvs -a -o name,attr,writebehind vg
  LV            Attr      WBehind
  lv            rwi-a-r--     512
  [lv_rimage_0] iwi-aor-w
  [lv_rimage_1] iwi-aor--
  [lv_rmeta_0]  ewi-aor--
  [lv_rmeta_1]  ewi-aor--

Example (writebehind is not set):
[~]# lvs -a -o name,attr,writebehind vg
  LV            Attr      WBehind
  lv            rwi-a-r--
  [lv_rimage_0] iwi-aor-w
  [lv_rimage_1] iwi-aor--
  [lv_rmeta_0]  ewi-aor--
  [lv_rmeta_1]  ewi-aor--
2013-04-15 13:59:46 -05:00
Zdenek Kabelac
d3b8f270ea headers: add headers for musl libc
On glibc, those are erroneously (namespace pollution) pulled in via
other headers. this doesn't work with conformant libcs (musl libc in
this case), we simply need to include all needed headers.

Signed-Off-By: John Spencer <maillist-lvm@barfooze.de>
2013-02-05 14:27:25 +01:00
Peter Rajnoha
2be83f4543 blkdeactivate: prevent trying to unmount the same mountpoint more times
An addendum to previous commit 1052863a1b35f7488758c78b3a9ebef5c63392bc.
2013-01-23 16:57:44 +01:00
Peter Rajnoha
f7da1caf8d blkdeactivate: fix handling of nested mountpoints and mangled mount paths.
If there was a nested mountpoint inside an existing mount path,
blkdeactivate could fail to unmount such a mountpoint as it
needs to deactivate the deepest path first and continue upwards.

For example the simplest reproducer:

[root@rhel6-a ~]# lsblk
NAME                        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                           8:0    0    4G  0 disk
|-vg-lvol0 (dm-2)           253:2    0   32M  0 lvm  /mnt/a
`-vg-lvol1 (dm-3)           253:3    0   32M  0 lvm  /mnt/a/b

Before this patch:

[root@rhel6-a ~]# blkdeactivate -u
Deactivating block devices:
  UMOUNT: unmounting vg-lvol0 (dm-2) mounted on /mnt/a
umount: /mnt/a: device is busy.
        (In some cases useful info about processes that use
         the device is found by lsof(8) or fuser(1))
  UMOUNT: unmounting vg-lvol1 (dm-3) mounted on /mnt/a/b
  LVM: deactivating Logical Volume vg/lvol1

(deactivation of vg/lvol0 is skipped as /mnt/a that is on lvol0
can't be unmounted - it still has /mnt/a/b as nested mountpoint!)

With this patch applied:

[root@rhel6-a ~]# blkdeactivate -u
Deactivating block devices:
  UMOUNT: unmounting vg-lvol1 (dm-3) mounted on /mnt/a/b
  UMOUNT: unmounting vg-lvol0 (dm-2) mounted on /mnt/a
  LVM: deactivating Logical Volume vg/lvol0
  LVM: deactivating Logical Volume vg/lvol1

===

Also, this patch contains a fix for processing mangled mount paths:

[root@rhel6-a ~]# lsblk
NAME                        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                           8:0    0    4G  0 disk
`-vg-lvol0 (dm-2)           253:2    0   32M  0 lvm  /mnt/x y z

[root@rhel6-a ~]# lsblk -r
vg-lvol0 253:2 0 32M 0 lvm /mnt/x\x20y\x20z

(the mount path is mangled with \xNN that is visible in raw
lsblk output only and which is used in blkdeactive as well)

Before this patch:

[root@rhel6-a ~]# blkdeactivate -u
Deactivating block devices:
  umount: /mnt/x\x20y\x20z: not found

After this patch applied:

[root@rhel6-a ~]# blkdeactivate -u
Deactivating block devices:
  UMOUNT: unmounting vg-lvol0 (dm-2) mounted on /mnt/x\x20y\x20z
  LVM: deactivating Logical Volume vg/lvol0
2013-01-23 14:45:41 +01:00
Zdenek Kabelac
8bcc1da2f3 locales: use higher prio LC_ALL variable
For reseting locale environment into significantly less memory
consuming version 'C' - use LC_ALL instead of LANG since it has
higher priority in locale settings.

Otherwise we may observe whole locale-archive which might be
over 100MB on i.e. Fedora systems locked in memory with
some daemons.
2013-01-22 11:25:02 +01:00
Peter Rajnoha
7c7672b3c0 systemd: remove quotes in lvm2-monitor.service ExecStop 2012-11-02 20:32:28 +01:00
Peter Rajnoha
aa07de5a50 systemd: do not remove lvm2-activation.service
Fix previous commit 360c569ce8.
Remove only fedora-storage-init/fedora-storage-init-late.service, but
not lvm2-activation.service.
fedora-storage-init.service fedora-storage-init-late.service
2012-11-01 13:33:49 +01:00
Peter Rajnoha
360c569ce8 systemd: various updates and fixes
Don't use lvmetad in lvm2-monitor.service ExecStop to avoid a systemd issue.
 - a systemd design issue while processing dependencies
   with socket-based activation that ends up with a hang
 - https://bugzilla.redhat.com/show_bug.cgi?id=843587
   (also tracker bug https://bugzilla.redhat.com/show_bug.cgi?id=871527)
 - not using lvmetad in this case is just a workaround, once the bug
   above is resolved, we should enable the lvmetad in that specific case

Remove dependency on fedora-storage-init.service in lvm2 systemd units.
 - fedora-storage-init.service and fedora-storage-init-late.service is
   going to be separated into respective units that belong to each block
   device subsystem:
     - mpath + mdraid activated via udev solely
     - dmraid with its own dmraid-activation.service unit
     - lvm2 with the lvm2-activation-generator to generate the
       activation units runtime if lvmetad disabled
       (global/use_lvmetad=0 set in lvm.conf) and activation done
       via udev+lvmetad if lvmetad enabled (global/use_lvmetad=1 set
       in lvm.conf)

Depend on lvm2-lvmetad.socket in lvm2-monitor.service systemd unit.
 - as lvm2-monitor uses lvmetad if lvmetad is enabled
2012-10-30 20:55:50 +01:00
Peter Rajnoha
5afa2ffcaa scripts: blk-availability - use full name for clarity
"Stopping blk-availability" -> "Stopping block device availability:"
2012-10-15 16:10:58 +02:00
Peter Rajnoha
d365bfe7e9 scripts: blk-availability should be stopped before FCoE 2012-10-15 15:00:12 +02:00
Peter Rajnoha
c93659e0e0 scripts: blk-availability - use the same name for lock file 2012-10-15 13:22:36 +02:00
Peter Rajnoha
4dace48f51 Remove pvscan --cache from lvm2-lvmetad init script.
This is not needed anymore as the scan is called transparently
within the first LVM command that queries lvmetad.
2012-10-15 12:58:23 +02:00
Zdenek Kabelac
7c7ab99843 cleanup: add gcc printf __attribute__ 2012-10-13 19:14:41 +02:00
Peter Rajnoha
4d7a4554f4 blkdeactivate: fix long form of options
Actually, long form for -d and -l option is --dmoption and --lvmoption respectively.
2012-10-12 15:42:24 +02:00
Peter Rajnoha
c698ee14bb scripts: introduce blkdeactivate
blkdeactivate - utility to deactivate block devices

Traverses the tree of block devices and tries to deactivate them.
Currently, it supports device-mapper-based devices together with LVM.
See man/blkdeactivate.8 for more info.

It is targeted for use during shutdown to properly deactivate the
whole block device stack - systemd and init scripts are provided as
well. However, it might be used directly on command line too.

Please, see the commentary at the top of the blkdeactivate script
for dependencies and versions of other utilities required.
2012-10-12 14:44:24 +02:00
Peter Rajnoha
f8781ea6a0 systemd: add deps to order units more properly
lvm2-activation-early.service (generated by activation generator) should
be ordered before cryptsetup.target.

lvm2-monitor.service should be ordered after lvm2-activation.service,
if used. The lvm2-activation.service will replace fedora-storage-init.service
and fedora-storage-init-late.service in the end, but let's have it
prepared now.
2012-10-12 14:24:54 +02:00
Petr Rockai
4022fd3e79 lvmdump: Add -l, to collect a state dump from lvmetad. 2012-10-11 22:42:20 +02:00
Petr Rockai
8557b412f6 lvmdump: Fix systems with tr on PATH outside of /usr/bin. 2012-10-11 22:40:58 +02:00
Peter Rajnoha
7a64fff948 systemd: remove ExecStartPost from lvm2-lvmetad.service.
The ExecStartPost with pvscan --cache in lvm2-lvmetad.service
is not needed now as this is called transparently within the
first LVM command that queries lvmetad.
2012-10-08 16:49:54 +02:00
Peter Rajnoha
6d75ff138c systemd: depend on systemd-udev-settle unit in activation unit
The "fedora-wait-storage.service" that the "lvm2-activation.service"
had as a dependency (which was fedora-specific solution anyway)
is obsolete now as this unit called "modprobe scsi_wait_scan"
which is not used anymore.

The "fedora-wait-storage.service" had "systemd-udev-settle" as
its dependency, so let's depend on this one directly now,
bypassing the out-dated "fedora-wait-storage.service".
2012-09-12 11:30:13 +02:00
Zdenek Kabelac
c8ad1f3e3a cleanup: ignore write/close output
Intentionaly ignore write and close errors.
2012-08-23 14:37:37 +02:00
Peter Rajnoha
9952331d5d make: fix make in scripts dir for --disable-applib 2012-08-01 15:48:53 +02:00
Peter Rajnoha
e309586aeb systemd: O_CLOEXEC not needed in activation generator
O_CLOEXEC not actually needed, this is just a simple program,
it is not supposed to fork/exec anywhere and anytime in the future.
2012-08-01 08:57:12 +02:00
Peter Rajnoha
c6cc871df8 make: use proper libs to make scripts subdir 2012-08-01 08:42:49 +02:00
Peter Rajnoha
fa68466e90 systemd: integrate lvm2 activation generator with conf+make 2012-07-31 16:46:24 +02:00
Peter Rajnoha
d3e67ba8ca systemd: add lvm2 activation generator
The lvm2 activation generator generates systemd units conditionally
based on the global/use_lvmetad lvm.conf setting.

If use_lvmetad=0, the lvm2-activation-early.service and lvm2-activation.service
units will be generated. These units are responsible for direct volume activation
by calling "vgchange -aay --sysinit" (this is actually the original on-boot
activation as it was used before). If use_lvmetad=1, no units will be generated
as we're relying on autoactivation.

Important thing to note is that the lvm2-activation units normally bring
in the udev-settle ("storage-wait") service that waits for udev to settle
(with block devices). We don't need this if lvmetad is used in conjunction
with autoactivation feature... but systemd units can't be enabled or disabled
(or dependencies added/removed) dynamically based on external configuration.

Therefore, we need the unit generator which adds support for such situations:
the units as a whole either exist or not based on the external configuration.
2012-07-31 16:20:24 +02:00
Peter Rajnoha
9161308252 systemd: ensure monitoring is handled after lvmetad
Monitoring is handled using "vgchange --monitor" call. Ensure that lvmetad is up
and running at the time of this call to prevent any fallback to direct scan
within the vgchange. The same applies for shutdown sequence but the other way
round - switch monitoring off and lvmetad afterwards.
2012-07-26 11:30:27 +02:00
Peter Rajnoha
d84e1ae5f2 systemd: add doc reference in dm-event.socket 2012-06-29 13:54:35 +02:00
Peter Rajnoha
2d5adc5823 initscript: call vgchange -aay instead of -aly
The clmvd init script called "vgchange -aly" before to activate
all VGs in cluster environment. This activated all VGs, no matter
if it was clustered or not.

Auto activation for clustered VGs is not supported yet so the behaviour
of -aay is still the same as before for clustered VGs. However, for
non-clustered VGs, we need to check with the activation/auto_activation_volume_list
whether the VG/LV should be activated on boot or not.
2012-06-28 09:44:07 -04:00
Peter Rajnoha
9a96f930a7 configure: run directory configuration cleanup
There were several hard-coded values for run directory around the code.
Also, some tools are DM specific only, others are LVM specific and there
was no distinction made here before. With this patch applied, we have
this cleaned up a bit (subsystem in brackets, defaults in parentheses):

          [common] configurable PID_DIR     (/var/run)

 lvm      [lvm]    configurable RUN_DIR     (/var/run/lvm)
                   configurable locking dir (/var/lock/lvm)

 clvmd    [lvm]    configurable pid file    (PID_DIR/clvmd.pid)
                   socket                   (RUN_DIR/clvmd.sock)

 lvmetad  [lvm]    configurable pid file    (PID_DIR/lvmetad.pid)
                   socket                   (RUN_DIR/lvmetad.socket)

 dm       [dm]     configurable DM_RUN_DIR  (/var/run)

 cmirrord [dm]     configurable pid file    (PID_DIR/cmirrord.pid)

 dmeventd [dm]     configurable pid file    (PID_DIR/dmeventd.pid)
                   server fifo              (DM_RUN_DIR/dmeventd-server)
                   client fifo              (DM_RUN_DIR/dmeventd-client)

The changes briefly:
  - added configure --with-default-pid-dir
  - added configure --with-default-dm-run-dir
  - added configure --with-lvmetad-pidfile
  - by default, using one common pid directory for everything
    (only lvmetad was not following this before)
2012-06-27 12:11:47 +02:00
Peter Rajnoha
e77803edc9 systemd: Add Documentation references
These documentation references show up in "systemctl status" output.
2012-06-20 14:23:50 +02:00
Alasdair G Kergon
a2a37f8fee More .gitignore files for an in-source-tree build.
Tell git to ignore files generated by a build inside the source tree.
2012-06-08 16:34:43 +01:00
Alasdair G Kergon
d644d4e14e Add .gitignore files for an in-source-tree build.
Tell git to ignore files generated by a build inside the source tree.
2012-06-08 16:26:21 +01:00
Alasdair G Kergon
bb2a2bb3ff Remove obsolete CVS helper script.
Remove last_cvs_update.sh now that we're using git.
2012-06-07 14:06:01 +01:00
Alasdair Kergon
0efcdc3ad9 . 2012-04-19 13:47:38 +00:00
Alasdair Kergon
8ae2ca5ff7 . 2012-04-19 13:47:11 +00:00
Peter Rajnoha
973cfb19b7 Add udev info and context to lvmdump.
--------------------------------------------------------------------
2012-04-18 15:26:02 +00:00
Jonathan Earl Brassow
68d84fa3eb Add a couple new functions to gdbinit file and decode a couple lv->status flags
New functions:
 - seg_pvs: Print a list of PVs in a seg_pvs list
 - pv_dev_name: print name of a PV
2012-04-10 23:24:00 +00:00
Peter Rajnoha
d837eebdcc Use pvscan --cache instead of vgscan in lvmetad init script and systemd unit. 2012-03-16 15:12:04 +00:00
Zdenek Kabelac
a9382908ae Fix string parsing
Fix propagation of -e option - pass it via internal shell variable.
Fix parsing of /proc/mounts files (don't check for substrings).
 as reported by O.Mangold with suggested patch:
 https://www.redhat.com/archives/linux-lvm/2012-February/msg00030.html
Properly pass arguments with spaces ("$@")
Add validation for YES and EXTOFF variable content.
2012-03-16 12:53:05 +00:00
Peter Rajnoha
93945bb616 Use SD_ACTIVATION env. var. in systemd units to better detect systemd in use.
LISTEN_PID and LISTEN_FDS environment variables are defined only during systemd
"start" action. But we still need to know whether we're activated during
"reload" action as well - we use the reload action to call "dmeventd -R"/"lvmetad -R"
for statefull daemon restart. We can't use normal "restart" as that is simply
composed of "stop" and "start" and we would lose any state the daemon has.
2012-03-14 15:51:51 +00:00
Peter Rajnoha
aeb7a93796 Add 'Restart: on-abort' for lvmetad systemd service.
Restart lvmetad automatically if it exits due to reception of uncaught signal,
leaving a track in systemd log/syslog.
2012-03-08 09:49:09 +00:00
Peter Rajnoha
9e23089757 LVMetaD socket operates in non-blocking mode. 2012-02-28 13:07:03 +00:00
Peter Rajnoha
792343a694 lvmetad.socket 2012-02-27 15:45:49 +00:00
Peter Rajnoha
56ca71bd8e Use 'killproc' fn in lvmetad init script (fn provided by 'functions' init script library). 2012-02-27 08:56:46 +00:00
Peter Rajnoha
e6fa4a095e Also remove intermediate lvmetad init script file. 2012-02-24 15:07:00 +00:00
Peter Rajnoha
8c3c020a56 Use '-p PID_FILE' for the status call since the pidfile is in its own lvm subdir and return proper status code. 2012-02-24 13:45:37 +00:00
Peter Rajnoha
97c2309e19 The daemon as well as the first scan must be both executed properly, otherwise it's an error! 2012-02-24 13:11:57 +00:00
Peter Rajnoha
a30491b25f Add LVMetaD init script. 2012-02-24 13:03:50 +00:00
Peter Rajnoha
f84d6048cf Use 'd' instead of 'D' in tmpfiles configuration to not overwrite any existing directory.
...that happens when systemd creates it first (e.g. based on a .socket unit)
before the tmpfiles.d content is executed.
2012-02-23 14:24:30 +00:00
Peter Rajnoha
840bc23ee1 Remove the old systemd socket file, we're using the .in template now. 2012-02-23 13:39:08 +00:00
Peter Rajnoha
dac3c36feb Use DEFAULT_RUN_DIR instead of hardcoded value in lvmetad systemd units
and add ExecStartPost=vgscan to actually run the first scan that will
fill the metadata daemon with metadata information.
2012-02-23 13:31:49 +00:00
Petr Rockai
dae0822698 The lvmetad client-side integration. Only active when use_lvmetad = 1 is set in
lvm.conf *and* lvmetad is running.
2012-02-23 13:11:07 +00:00
Peter Rajnoha
da532741c9 Add LVMetaD systemd units. 2012-02-23 11:24:07 +00:00
Peter Rajnoha
2c893455ad Install lvm2 monitoring init script and systemd units only if dmeventd is built. 2012-02-23 11:13:18 +00:00
Peter Rajnoha
7044863afc Clean intermediate files. 2012-02-23 10:01:12 +00:00
Peter Rajnoha
0da6c851bd Add lvm2 tmpfiles.d configuration file. 2012-02-22 18:02:31 +00:00
Peter Rajnoha
4417a8bd40 Add configure --with-tmpfilesdir and lvm2 tmpfiles.d configuration file itself.
/etc/tmpfiles.d directory holds configuration files for temporary/volatile
files and directories that should be automatically managed. For example,
if we have some parts of the fs hierarchy on tmpfs, we'd like to recreate
some files or directories on every boot so they're always prepared for use.

Systemd can read such configuration files. For now, the lock and run directory
are the ones that are most probably placed on tmpfs. If this is the case, we
can install the configuration by 'make install_tmpfiles_configuration'.
2012-02-22 17:55:10 +00:00
Peter Rajnoha
b627165a75 Clean up systemd unit ordering and requirements. 2012-02-01 13:08:39 +00:00
Peter Rajnoha
32e53e506d Use also normalized output for vgchange command in lvm2-monitor init script. 2011-12-16 11:42:56 +00:00
Peter Rajnoha
0644371f09 Fix lvm2-monitor init script to use normalized output when using vgs. 2011-12-07 12:29:41 +00:00
Alasdair Kergon
630b4c2111 Move gentoo MAKEDEV to /sbin in lvm2create_initrd. (James Le Cuirot) 2011-11-12 17:03:53 +00:00
Peter Rajnoha
8626490ca7 Add "ExecReload" to dm-event.service for systemd to reload dmeventd properly.
Normally, restart simply means "stop and start" for systemd. However, if
we're installing new versions of the dmeventd binary/libdevmapper, we need
to restart dmeventd. This fails if we have some devices monitored - we need
to call "dmeventd -R" instead.

The "ExecReload" did not work quite well in some old versions of systemd,
systemd assumed that only the configuration is reloaded on "ExecReload",
not the whole binary itself so it lost track of dmeventd daemon (it lost new
dmeventd PID). This is fixed and seems to be working fine now with recent
versions of dmeventd.
2011-10-31 12:22:49 +00:00
Jonathan Earl Brassow
9aedb1431f New handy gdb debugging function, "dm_list_size"
Example:
(gdb) dm_list_size &split_images
1 list items
2011-09-28 16:32:22 +00:00
Zdenek Kabelac
00e72fcfee Fix install_ocf
When builddir is different from srcdir install_ocf: has not been able to find
files for installation.
2011-09-24 21:05:03 +00:00
Zdenek Kabelac
8f8c5580fd Add support for DM_DEV_DIR
Follow other commands support this directory setting.
Useful for test suite.
2011-09-19 19:36:52 +00:00
Zdenek Kabelac
13e3c25ade Add support for non /dev devices
Since test suite is not using /dev - add support for such dirs into fsadm.
2011-09-19 14:52:33 +00:00
Zdenek Kabelac
53c09bce42 Support different PATH setting
When fsadm is test - it needs to execute lvm and fsadm from non-standard path
setting.   So adding a support in fsadm script when user set LVM_BINARY, then
the lvm command invoced from fsadm will have the same PATH setting as before
entering  fsadm command.

Needed for testing.
2011-09-19 13:51:09 +00:00
Zdenek Kabelac
d2010960c9 Surround all executed commands with quotes
In case someone would use filename paths with spaces when changing
this script surround commands with '"'.

With default settings there is no change in behavior.
2011-09-19 13:47:37 +00:00
Zdenek Kabelac
dd96ceda43 Fix missing '$' in test 2011-09-19 13:43:50 +00:00
Jonathan Earl Brassow
08c50a291e reorder some status flag printing in gdbinit file. 2011-09-13 13:57:02 +00:00
Jonathan Earl Brassow
4c259ae945 Adjust gdbinit script to new RAID status flag values. 2011-09-08 22:19:45 +00:00
Zdenek Kabelac
77f771ebc3 Replace char class :space: with explicit chars
Some major distributions are still using 'mawk' and they are not using
the latest version - we end here with hidden dependency on the latest
version of mawk (1.3.4) while i.e. Debian Lenny seems to stay with 1.3.3.
So we end with completely broken  vgimportclone script on such system.

We would need to check for proper support of :space: and abort build if
it doesn't work or simplier replace [:space:] with [ \t] which seems
sufficient to make it work (as can be seen in this patch)

A better fix would be to use command line parameter override - leaving
as FIXME comment.

This patch makes t-vgimportclone.sh test passing on Lenny.
2011-09-07 08:31:16 +00:00
Jonathan Earl Brassow
673c8d01e6 Updates to gdbinit file
1) Add more status flags for printing
2) Fix bug in lv_status_r processing for mirror segment type
2011-09-01 21:01:12 +00:00
Peter Rajnoha
d183554c72 Suppress locking error messages in monitoring init scripts. 2011-08-11 15:27:46 +00:00
Peter Rajnoha
395d204d9c Configure and makefile changes for newly added systemd unit files. 2011-07-28 12:57:26 +00:00
Peter Rajnoha
5071d9eceb Add systemd unit files for dmeventd. 2011-07-28 12:54:28 +00:00
Jonathan Earl Brassow
075658c066 RAID updates for gdbinit file 2011-07-01 16:15:25 +00:00
Milan Broz
fc7ff7647f Use append but except query for dlm locks:-) 2011-06-02 09:08:16 +00:00
Milan Broz
69ff428151 Always use append to file in lvmdump (selinux policy - no file truncation).
Workaround dmsetup ls --tree (terminal ioctl for width).
(Until isatty() will be allowed by selinux policy.)
2011-06-02 09:02:03 +00:00
Jonathan Earl Brassow
2d1175a895 gdbinit update
When doing lv_status_r on a sub_lv, do not climb the tree up past the
starting point.
2011-03-29 12:53:13 +00:00
Jonathan Earl Brassow
547d3f13ab Watch out for collisions in GDB global namespace.
Better 'lv_status_r' printing.
2011-03-14 18:05:56 +00:00
Jonathan Earl Brassow
0b1a79bf1f lv_status_r now prints out status of attached log LVs
(Print layout could be nicer... :(
2011-03-11 22:25:36 +00:00
Jonathan Earl Brassow
ab999c86cc lv_status_r has been fixed-up so that it supports infinite LV stacking
(It does not yet follow 'log_lv' or 'origin' links.)
2011-03-11 22:16:38 +00:00
Jonathan Earl Brassow
1e094d3428 detect RAID* LV and segment flags. 2011-03-11 18:22:39 +00:00
Jonathan Earl Brassow
0a1d29b1d3 gdbinit - A GDB init file to help while debugging LVM.
Copy this file as '.gdbinit' to your home directory or your working
directory.  It adds the following commands to gdb:
 - first_seg
 - lv_status
 - lv_status_r
 - lv_is_mirrored
 - seg_item
 - seg_status
 - segs_using_this_lv

You can get a list of these user-defined commands by typing:
(gdb) help user-defined

You can get more information on each command by typing:
(gdb) help <command>
2011-03-10 13:45:12 +00:00
Dave Wysochanski
bc773e60e1 Add "dmsetup ls --tree" output to lvmdump.
It would be most useful to add "dmsetup ls --tree" to the commands run.
This command helps in answering the question "which devices are actually
underneath a given LV?"

Although the info is available with other existing dmsetup commands,
adding this command gives a much clearer summary of complex setups.

Here's an example of an LVM mirror, with mirror images on partitions
created on top of multipath devices.  The multipath devices are on
simple block devices.  As you can see, it is easy to see the stacking
from the "dmsetup ls --tree" output:

vgmpathtest-lvmpathmir (253:14)
 ├─vgmpathtest-lvmpathmir_mimage_1 (253:13)
 │  └─mpath5p1 (253:5)
 │     └─mpath5 (253:2)
 │        ├─ (8:16)
 │        └─ (8:0)
 ├─vgmpathtest-lvmpathmir_mimage_0 (253:12)
 │  └─mpath6p1 (253:6)
 │     └─mpath6 (253:3)
 │        ├─ (8:48)
 │        └─ (8:32)
 └─vgmpathtest-lvmpathmir_mlog (253:11)
    └─mpath7 (253:4)
       ├─ (8:80)
       └─ (8:64)
VolGroup00-LogVol01 (253:1)
 └─ (202:2)
vgtest-lvmir (253:10)
 ├─vgtest-lvmir_mimage_1 (253:9)
 │  └─ (7:1)
 ├─vgtest-lvmir_mimage_0 (253:8)
 │  └─ (7:0)
 └─vgtest-lvmir_mlog (253:7)
    └─ (7:3)
VolGroup00-LogVol00 (253:0)
 └─ (202:2)

But it is much harder to see the stacking with only the commands today
("dmsetup info", "dmsetup status", and "dmsetup table").  We could
piece together the stacking from "dmsetup table" but it requires
further processing (take output from "dmsetup info to get
map name to major/minor, then parse "dmsetup table", etc).
2011-02-01 21:39:15 +00:00
Jonathan Earl Brassow
f25f57ae75 Fix bug 632681: cmirrord shouldn't fail 'start' if already started
Return 0 from the cmirrord init script if the daemon is already
running.

http://refspecs.freestandards.org/LSB_3.1.1/LSB-Core-generic/LSB-Core-generic/iniscrptact.html
2011-01-04 21:16:54 +00:00
Zdenek Kabelac
f0fffb8c6f Add date configurable variable DATE
Follow the rule to run every command through variable dereference.
Add a runtime check of translated date to seconds.
2010-11-11 12:17:15 +00:00
Zdenek Kabelac
a9d6333bd6 fsadm fix for downsize of unmounted fs
Fix for the last commit as $MOUNTED is not only used as bool flag,
but also store mounted location for remount - so parsing output
from mount differently then from /proc/mounts.

Prefix calls of 'tunefs' tools with LANG=C to be sure we always do get
some nonlocalized strings.

Avoid using forced 'resize2fs' for cleanly unmounted filesystems and
run regular fsck -f for this case as required by resize2fs.

'fsadm check' uses date difference for extX filesystems between
the last mount and last check of 'fsck -f' execution and if the mount
was later run 'fsck' with -f so resize2fs is happy and user does not
need to pass '-f' flag.
2010-11-10 16:14:02 +00:00
Zdenek Kabelac
b500eddad1 Scan also 'mount' output for mounted filesystem.
As util-linux package seems to give all the time different names,
try harder to figure out, where is the given lv possible mounted
and scan /proc/mounts and if not found there, test also 'mount' output.

/dev/dm-xxx
/dev/mapper/vg-lv
/dev/vg/lv

All of them could be used different combination in /proc/mount and mount output.

Patch fixes regression for older systems where new detection code failed to
find valid combination.
2010-11-10 10:03:07 +00:00
Zdenek Kabelac
e40d44be8d Add OCF support
Updated patch from Florian Haas from Linux-HA project.

User needs to 'configure --enable-ocf' to get file installed
by 'make install' target by default.
User can also use 'make install_ocf' to get only ocf files installed.
With disabled (default) ocf support - no ocf files are installed.

FIXME: ocf installation path needs to be kept in sync with pacemaker.
find better way and possible also better location.
2010-11-05 16:18:38 +00:00
Zdenek Kabelac
afcae0664e Add given user prefix to make target install_initscripts
Avoid files to be written into the live system if lvm was
configured with different --prefix.

Use initdir for install target path.
2010-11-05 16:13:18 +00:00
Zdenek Kabelac
4886fa2105 Return different status code for fsadm check of mounted filesystem
Return status code 3 for fsadm check of mounted filesystem - used later with
lvresize update patch to better support online filesystem resize.

Also makes a more consistent user interruption and returns status code 2
in this case.
2010-11-01 14:08:51 +00:00
Zdenek Kabelac
bd79af9f05 Add support for noninterctive shell execution
Try to distinguish between the case of  using interactive shell and non
interactive running - different combinations of  '-y' and '-p' option
needs to be used for fsck.
2010-10-08 15:02:05 +00:00
Zdenek Kabelac
01143a9313 Fix usage of --yes flag for ReiserFS resize
Put 'dry' before resize command - using dry for echo had no use.
2010-10-08 15:00:06 +00:00
Zdenek Kabelac
55b94bf393 Fix detection of mounted filesystem.
Update the way how fsadm detects mounted filesystem.
With udev /dev/dm-XXX paths are now returned - but mount or /proc/mounts
prints names in form of /dev/mapper/vg-lv - so the match was not found.
Fixex RHBZ #638050.

Current solution uses same trick as mount and detects vg-lv name through
/sys where available - this should be reasonable safe.

Instead of calling mount without parameter to get actual mount table,
switch to use /proc/mounts directly.
2010-10-08 14:55:19 +00:00
Zdenek Kabelac
0d9ed7ade3 Fix assignment of default LVM variable
Fix a typo which does not work in case LVM_BINARY is empty string.
Using proper :-  syntax.
2010-10-08 14:49:25 +00:00
Zdenek Kabelac
685940c01c Support for passing --yes flag recursively. 2010-10-08 13:49:20 +00:00
Zdenek Kabelac
fd86754329 Correctly respect --dry-run option for fsadm
Fix missing 'dry' execution of lvresize - fixing problem where resize
command were 'dry-run' executed - but lvresize has been executed for real.

Also adapt code slightly to support better recursive execution of fsadm
through lvresize call.
2010-10-08 13:47:10 +00:00
Zdenek Kabelac
829fe014a5 Fix a serious bug in the behavior of fasdm tool when breaked.
Under certain conditions it was possible to break (^C) fsadm before actually
resizing filesystem, but lvresize which executed fsadm will think resize
was succesful and shrinks partitions with unresized filesystem on it.

Fix by returning error (1) for this case - this stops lvresize from futher
proceding in resize operation.
2010-10-08 12:35:56 +00:00
Zdenek Kabelac
3a6e5f36f9 Replace "can not" with "cannot" 2010-10-08 11:18:29 +00:00
Fabio M. Di Nitto
34b6075d68 Based on auto-detection or user requested cluster managers for clvmd,
set appropriate Required-Start and Required-Stop at configure time.

Reorder the checks for user selected cluster managers to match auto
detected ones, to be consistent in the output.

Add special case for qdiskd that´s started after cman/lock_gulmd for
RHEL-4/RHEL-5.
2010-08-23 11:37:02 +00:00
Fabio M. Di Nitto
2565ffad25 Fix clvmd init script return code when executed as non-root user.
clvmd daemon itself does the right thing when invoked as non-root, by
returning 4.

The patch removes the use daemon function from
/etc/rc.d/init.d/functions that´s unnecessary and has th bad habit to
mask the return codes from the real daemon.

Add a simple and generic check to see if clvmd is executed by root or not.

Our stop/reload/restart paths in the init script are complex and not all
the tools involved in the process are guaranteed to return 4 if executed
by non-root against a process that´s running as root (for example kill
-TERM will return -1 and parsing the output to catch the error is
suboptimal at best).

https://bugzilla.redhat.com/show_bug.cgi?id=553381
2010-08-12 09:14:59 +00:00
Milan Broz
be2d9395c7 Fix clvmd init script status
- s/Active clustred VG/clustered VG/ (only LV can be active)

- print only active LVs (not all) in status command
(In the lvdisplay form /dev/vg/lv.)

For now, still use awk (already used in clustered_vgs).

https://bugzilla.redhat.com/show_bug.cgi?id=598495
2010-06-23 16:24:13 +00:00
Milan Broz
850fa8233f Fix clvmd initscript restart command to start clvmd if not yet running. 2010-06-03 21:03:53 +00:00
Mikulas Patocka
3ed801fb95 Fix scripts/relpath.awk to work with mawk
length(array) is specific to GNU awk and doesn't work in mawk.
Use a return value of "split" function to indicate array size, this is
supported in both gawk and mawk.

This patch fixes the following errors during "make install" when mawk is
installed as a default awk.

mawk: scripts/relpath.awk: line 25: illegal reference to array from
mawk: scripts/relpath.awk: line 25: illegal reference to array to
mawk: scripts/relpath.awk: line 27: illegal reference to array from
mawk: scripts/relpath.awk: line 32: illegal reference to array to

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
2010-05-21 15:28:16 +00:00
Alasdair Kergon
3e730d4769 Add make install_initscripts 2010-05-20 14:45:14 +00:00
Alasdair Kergon
52edfba95b Install lvmconf script by default.
Remove unnecessary versioned dmeventd plugin symlinks.
2010-05-20 11:20:35 +00:00
Fabio M. Di Nitto
3ab04a088c Fix clvmd init script stop function to not deactive non-clustered volume groups.
https://bugzilla.redhat.com/show_bug.cgi?id=592362
2010-05-17 03:18:27 +00:00
Zdenek Kabelac
7515338726 Use /bin/bash for scripts with bashisms 2010-05-14 11:33:20 +00:00
Alasdair Kergon
3ceb76089c pre-release 2010-04-30 14:49:42 +00:00