master - pvscan: add --activate ay option (autoactivate)
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d2df8dddc8c049...
Commit: d2df8dddc8c04973a3e23b7a19e9bfbf8c45f79e
Parent: 215a314f195ea4af5265e37999502462fcf2a341
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jun 27 09:35:11 2012 -0400
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Jun 28 09:44:03 2012 -0400
pvscan: add --activate ay option (autoactivate)
Define auto_activation_handler that activates VGs/LVs automatically
based on the activation/auto_activation_volume_list (activating all
volumes by default if the list is not defined).
The autoactivation is done within the pvscan call in 69-dm-lvmetad.rules
that watches for udev events (device appearance/removal).
For now, this works for non-clustered and complete VGs only.
---
WHATS_NEW | 1 +
tools/commands.h | 4 +++-
tools/pvscan.c | 27 +++++++++++++++++++++++++++
udev/69-dm-lvm-metad.rules.in | 2 +-
4 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index fb3279e..481e8e3 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.97 -
===============================
+ Add --activate ay to pvscan.
Add --activate ay to vgchange.
Add support for volume autoactivation using lvmetad.
Add --activate synonym for --available arg and prefer --activate.
diff --git a/tools/commands.h b/tools/commands.h
index 8bec092..21791f7 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -671,6 +671,7 @@ xx(pvscan,
"List all physical volumes",
PERMITTED_READ_ONLY,
"pvscan " "\n"
+ "\t[-a|--activate ay]\n"
"\t[--cache [ DevicePath | --major major --minor minor]...]\n"
"\t[-d|--debug] " "\n"
"\t{-e|--exported | -n|--novolumegroup} " "\n"
@@ -682,7 +683,8 @@ xx(pvscan,
"\t[-v|--verbose] " "\n"
"\t[--version]\n",
- cache_ARG, exported_ARG, ignorelockingfailure_ARG, major_ARG, minor_ARG,
+ activate_ARG, available_ARG, cache_ARG, exported_ARG,
+ ignorelockingfailure_ARG, major_ARG, minor_ARG,
novolumegroup_ARG, partial_ARG, short_ARG, uuid_ARG)
xx(segtypes,
diff --git a/tools/pvscan.c b/tools/pvscan.c
index beba174..a040899 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -97,6 +97,20 @@ static void _pvscan_display_single(struct cmd_context *cmd,
pv_pe_size(pv)));
}
+static int _auto_activation_handler(struct volume_group *vg, int partial, int activate)
+{
+ /* TODO: add support for partial and clustered VGs */
+ if (partial || vg_is_clustered(vg))
+ return 1;
+
+ if (!vgchange_activate(vg->cmd, vg, activate)) {
+ log_error("%s: autoactivation failed.", vg->name);
+ return 0;
+ }
+
+ return 1;
+}
+
static int _pvscan_lvmetad_all_devs(struct cmd_context *cmd, activation_handler handler)
{
struct dev_iter *iter;
@@ -136,6 +150,14 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
char *buf;
activation_handler handler = NULL;
+ if (arg_count(cmd, activate_ARG)) {
+ if (arg_uint_value(cmd, activate_ARG, CHANGE_AAY) != CHANGE_AAY) {
+ log_error("Only --activate ay allowed with pvscan.");
+ return 0;
+ }
+ handler = _auto_activation_handler;
+ }
+
if (arg_count(cmd, major_ARG) + arg_count(cmd, minor_ARG))
devno_args = 1;
@@ -241,6 +263,11 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
if (arg_count(cmd, cache_ARG))
return _pvscan_lvmetad(cmd, argc, argv);
+ if (arg_count(cmd, activate_ARG)) {
+ log_error("--activate is only valid with --cache.");
+ return EINVALID_CMD_LINE;
+ }
+
if (arg_count(cmd, major_ARG) + arg_count(cmd, minor_ARG)) {
log_error("--major and --minor are only valid with --cache.");
return EINVALID_CMD_LINE;
diff --git a/udev/69-dm-lvm-metad.rules.in b/udev/69-dm-lvm-metad.rules.in
index 26309de..706c03b 100644
--- a/udev/69-dm-lvm-metad.rules.in
+++ b/udev/69-dm-lvm-metad.rules.in
@@ -21,6 +21,6 @@ SUBSYSTEM!="block", GOTO="lvm_end"
KERNEL=="dm-[0-9]*", ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="lvm_end"
# Only process devices already marked as a PV - this requires blkid to be called before.
-ENV{ID_FS_TYPE}=="LVM2_member|LVM1_member", RUN+="(LVM_EXEC)/lvm pvscan --cache --major $major --minor $minor"
+ENV{ID_FS_TYPE}=="LVM2_member|LVM1_member", RUN+="(LVM_EXEC)/lvm pvscan --cache --activate ay --major $major --minor $minor"
LABEL="lvm_end"
10 years, 7 months
master - vgchange: add --activate ay option (autoactivate)
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=215a314f195ea4...
Commit: 215a314f195ea4af5265e37999502462fcf2a341
Parent: 95ced7a7be26499fed2ffa03d71002e73c2d3ca9
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jun 27 10:21:15 2012 -0400
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Jun 28 09:42:48 2012 -0400
vgchange: add --activate ay option (autoactivate)
Normally, the 'vgchange -ay' activates all volume groups (that pass
the activation/volume_list filter if set).
This call can appear in two scenarios:
- system boot (so activation within a script in general)
- manual call on command line (so activaton on user's direct request)
For the former one, we would like to select which VGs should be actually
activated. One can define the list of VGs directly to do that. But that
would require the same list to be provided in all the scripts.
The 'vgchange -aay' will check for the activation/auto_activation_volume_list
in adition and it will activate only those VGs/LVs that pass this
filter (assuming all to be activated if the list is not defined - the
same logic we already have for activation/volume_list).
Init/boot scripts should use this form of activation primarily
(which, anyway, becomes only a fallback now with autoactivation done
on PV appearance in tandem with lvmetad in place).
---
WHATS_NEW | 1 +
tools/commands.h | 2 +-
tools/vgchange.c | 6 ++++++
3 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 7e29cb0..fb3279e 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.97 -
===============================
+ Add --activate ay to vgchange.
Add support for volume autoactivation using lvmetad.
Add --activate synonym for --available arg and prefer --activate.
Never issue discards when LV extents are being reconfigured, not deleted.
diff --git a/tools/commands.h b/tools/commands.h
index a8c6587..8bec092 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -742,7 +742,7 @@ xx(vgchange,
"\t[-u|--uuid] " "\n"
"\t[-v|--verbose] " "\n"
"\t[--version]" "\n"
- "\t{-a|--activate [e|l]{y|n} |" "\n"
+ "\t{-a|--activate [a|e|l]{y|n} |" "\n"
"\t -c|--clustered {y|n} |" "\n"
"\t -x|--resizeable {y|n} |" "\n"
"\t -l|--logicalvolume MaxLogicalVolumes |" "\n"
diff --git a/tools/vgchange.c b/tools/vgchange.c
index 29562a5..ebabb08 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -131,6 +131,12 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
continue;
}
+ if (activate == CHANGE_AAY) {
+ if (!lv_passes_auto_activation_filter(cmd, lv))
+ continue;
+ activate = CHANGE_ALY;
+ }
+
expected_count++;
if (activate == CHANGE_AN) {
10 years, 7 months
master - activate: add autoactivation hooks
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=95ced7a7be2649...
Commit: 95ced7a7be26499fed2ffa03d71002e73c2d3ca9
Parent: 2729720fd329f2c33cddeeded591a06fe4b6a147
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jun 27 08:59:34 2012 -0400
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Jun 28 09:42:47 2012 -0400
activate: add autoactivation hooks
Define an 'activation_handler' that gets called automatically on
PV appearance/disappearance while processing the lvmetad_pv_found
and lvmetad_pv_gone functions that are supposed to update the
lvmetad state based on PV availability state. For now, the actual
support is for PV appearance only, leaving room for PV disappearance
support as well (which is a more complex problem to solve as this
needs to count with possible device stack).
Add a new activation change mode - CHANGE_AAY exposed as
'--activate ay/-aay' argument ('activate automatically').
Factor out the vgchange activation functionality for use in other
tools (like pvscan...).
---
WHATS_NEW | 1 +
lib/activate/activate.c | 24 +++++++++++++++++-----
lib/activate/activate.h | 8 +++++++
lib/cache/lvmetad.c | 39 ++++++++++++++++++++++++++++++-------
lib/cache/lvmetad.h | 19 ++++++++++-------
lib/metadata/metadata-exported.h | 3 +-
lib/metadata/metadata.c | 3 +-
tools/lvmcmdline.c | 6 +++++
tools/pvremove.c | 2 +-
tools/pvscan.c | 13 ++++++-----
tools/tools.h | 3 ++
tools/vgchange.c | 31 +++++++++++++----------------
12 files changed, 104 insertions(+), 48 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0f90080..7e29cb0 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.97 -
===============================
+ Add support for volume autoactivation using lvmetad.
Add --activate synonym for --available arg and prefer --activate.
Never issue discards when LV extents are being reconfigured, not deleted.
Allow release_lv_segment_area to fail as functions it calls can fail.
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 1f21573..939de6c 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -328,10 +328,8 @@ int activation(void)
return _activation;
}
-static int _passes_volumes_filter(struct cmd_context *cmd,
- struct logical_volume *lv,
- const struct dm_config_node *cn,
- const char *config_path)
+int lv_passes_volumes_filter(struct cmd_context *cmd, struct logical_volume *lv,
+ const struct dm_config_node *cn, const char *config_path)
{
const struct dm_config_value *cv;
const char *str;
@@ -429,7 +427,7 @@ static int _passes_activation_filter(struct cmd_context *cmd,
return 0;
}
- return _passes_volumes_filter(cmd, lv, cn, "activation/volume_list");
+ return lv_passes_volumes_filter(cmd, lv, cn, "activation/volume_list");
}
static int _passes_readonly_filter(struct cmd_context *cmd,
@@ -440,7 +438,21 @@ static int _passes_readonly_filter(struct cmd_context *cmd,
if (!(cn = find_config_tree_node(cmd, "activation/read_only_volume_list")))
return 0;
- return _passes_volumes_filter(cmd, lv, cn, "activation/read_only_volume_list");
+ return lv_passes_volumes_filter(cmd, lv, cn, "activation/read_only_volume_list");
+}
+
+
+int lv_passes_auto_activation_filter(struct cmd_context *cmd, struct logical_volume *lv)
+{
+ const struct dm_config_node *cn;
+
+ if (!(cn = find_config_tree_node(cmd, "activation/auto_activation_volume_list"))) {
+ log_verbose("activation/auto_activation_volume_list configuration setting "
+ "not defined: All logical volumes will be auto-activated.");
+ return 1;
+ }
+
+ return lv_passes_volumes_filter(cmd, lv, cn, "activation/auto_activation_volume_list");
}
int library_version(char *version, size_t size)
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index 2b90a7b..f698fc9 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -93,6 +93,14 @@ int lv_check_not_in_use(struct cmd_context *cmd, struct logical_volume *lv,
*/
int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
int *activate_lv);
+int lv_passes_volumes_filter(struct cmd_context *cmd, struct logical_volume *lv,
+ const struct dm_config_node *cn, const char *config_path);
+
+/*
+ * Checks against the auto_activation_volume_list and
+ * returns 1 if the LV should be activated, 0 otherwise.
+ */
+int lv_passes_auto_activation_filter(struct cmd_context *cmd, struct logical_volume *lv);
int lv_check_transient(struct logical_volume *lv);
/*
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index d70e490..6ef30db 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -322,7 +322,7 @@ int lvmetad_vg_update(struct volume_group *vg)
/* NB. the PV fmt pointer is sometimes wrong during vgconvert */
if (pvl->pv->dev && !lvmetad_pv_found(pvl->pv->id, pvl->pv->dev,
vg->fid ? vg->fid->fmt : pvl->pv->fmt,
- pvl->pv->label_sector, NULL))
+ pvl->pv->label_sector, NULL, NULL))
return 0;
}
@@ -536,7 +536,7 @@ static const char *_print_mdas(struct lvmcache_info *info)
}
int lvmetad_pv_found(struct id pvid, struct device *device, const struct format_type *fmt,
- uint64_t label_sector, struct volume_group *vg)
+ uint64_t label_sector, struct volume_group *vg, activation_handler handler)
{
char uuid[64];
daemon_reply reply;
@@ -544,6 +544,7 @@ int lvmetad_pv_found(struct id pvid, struct device *device, const struct format_
const char *mdas = NULL;
char *pvmeta;
char *buf = NULL;
+ const char *status;
int result;
if (!_using_lvmetad)
@@ -603,12 +604,26 @@ int lvmetad_pv_found(struct id pvid, struct device *device, const struct format_
dm_free(pvmeta);
result = _lvmetad_handle_reply(reply, "update PV", uuid, NULL);
+
+ if (result && handler) {
+ status = daemon_reply_str(reply, "status", "<missing>");
+ if (!strcmp(status, "partial"))
+ handler(vg, 1, CHANGE_AAY);
+ else if (!strcmp(status, "complete"))
+ handler(vg, 0, CHANGE_AAY);
+ else if (!strcmp(status, "orphan"))
+ ;
+ else
+ log_error("Request to %s %s in lvmetad gave status %s.",
+ "update PV", uuid, status);
+ }
+
daemon_reply_destroy(reply);
return result;
}
-int lvmetad_pv_gone(dev_t device, const char *pv_name)
+int lvmetad_pv_gone(dev_t device, const char *pv_name, activation_handler handler)
{
daemon_reply reply;
int result;
@@ -617,6 +632,13 @@ int lvmetad_pv_gone(dev_t device, const char *pv_name)
if (!_using_lvmetad)
return 1;
+ /*
+ * TODO: automatic volume deactivation takes place here *before*
+ * all cached info is gone - call handler. Also, consider
+ * integrating existing deactivation script that deactivates
+ * the whole stack from top to bottom (not yet upstream).
+ */
+
reply = daemon_send_simple(_lvmetad, "pv_gone", "device = %d", device, NULL);
result = _lvmetad_handle_reply(reply, "drop PV", pv_name, &found);
@@ -627,9 +649,9 @@ int lvmetad_pv_gone(dev_t device, const char *pv_name)
return result;
}
-int lvmetad_pv_gone_by_dev(struct device *dev)
+int lvmetad_pv_gone_by_dev(struct device *dev, activation_handler handler)
{
- return lvmetad_pv_gone(dev->dev, dev_name(dev));
+ return lvmetad_pv_gone(dev->dev, dev_name(dev), handler);
}
int lvmetad_active(void)
@@ -665,7 +687,8 @@ static int _pvscan_lvmetad_single(struct metadata_area *mda, void *baton)
return 1;
}
-int pvscan_lvmetad_single(struct cmd_context *cmd, struct device *dev)
+int pvscan_lvmetad_single(struct cmd_context *cmd, struct device *dev,
+ activation_handler handler)
{
struct label *label;
struct lvmcache_info *info;
@@ -680,7 +703,7 @@ int pvscan_lvmetad_single(struct cmd_context *cmd, struct device *dev)
if (!label_read(dev, &label, 0)) {
log_print("No PV label found on %s.", dev_name(dev));
- if (!lvmetad_pv_gone_by_dev(dev))
+ if (!lvmetad_pv_gone_by_dev(dev, handler))
goto_bad;
return 1;
}
@@ -704,7 +727,7 @@ int pvscan_lvmetad_single(struct cmd_context *cmd, struct device *dev)
* sync needs to be killed.
*/
if (!lvmetad_pv_found(*(struct id *)dev->pvid, dev, lvmcache_fmt(info),
- label->sector, baton.vg)) {
+ label->sector, baton.vg, handler)) {
release_vg(baton.vg);
goto_bad;
}
diff --git a/lib/cache/lvmetad.h b/lib/cache/lvmetad.h
index 091ff5e..713c5a3 100644
--- a/lib/cache/lvmetad.h
+++ b/lib/cache/lvmetad.h
@@ -19,6 +19,8 @@ struct volume_group;
struct cmd_context;
struct dm_config_tree;
+typedef int (*activation_handler) (struct volume_group *vg, int partial, int activate);
+
#ifdef LVMETAD_SUPPORT
/*
* Initialise the communication with lvmetad. Normally called by
@@ -64,13 +66,13 @@ int lvmetad_vg_remove(struct volume_group *vg);
*/
int lvmetad_pv_found(struct id pvid, struct device *device,
const struct format_type *fmt, uint64_t label_sector,
- struct volume_group *vg);
+ struct volume_group *vg, activation_handler handler);
/*
* Inform the daemon that the device no longer exists.
*/
-int lvmetad_pv_gone(dev_t devno, const char *pv_name);
-int lvmetad_pv_gone_by_dev(struct device *dev);
+int lvmetad_pv_gone(dev_t devno, const char *pv_name, activation_handler handler);
+int lvmetad_pv_gone_by_dev(struct device *dev, activation_handler handler);
/*
* Request a list of all PVs available to lvmetad. If requested, this will also
@@ -102,7 +104,8 @@ struct volume_group *lvmetad_vg_lookup(struct cmd_context *cmd,
/*
* Scan a single device and update lvmetad with the result(s).
*/
-int pvscan_lvmetad_single(struct cmd_context *cmd, struct device *dev);
+int pvscan_lvmetad_single(struct cmd_context *cmd, struct device *dev,
+ activation_handler handler);
# else /* LVMETAD_SUPPORT */
@@ -111,15 +114,15 @@ int pvscan_lvmetad_single(struct cmd_context *cmd, struct device *dev);
# define lvmetad_active() (0)
# define lvmetad_vg_update(vg) (1)
# define lvmetad_vg_remove(vg) (1)
-# define lvmetad_pv_found(pvid, device, fmt, label_sector, vg) (1)
-# define lvmetad_pv_gone(devno, pv_name) (1)
-# define lvmetad_pv_gone_by_dev(dev) (1)
+# define lvmetad_pv_found(pvid, device, fmt, label_sector, vg, handler) (1)
+# define lvmetad_pv_gone(devno, pv_name, handler) (1)
+# define lvmetad_pv_gone_by_dev(dev, handler) (1)
# define lvmetad_pv_list_to_lvmcache(cmd) (1)
# define lvmetad_pv_lookup(cmd, pvid, found) (0)
# define lvmetad_pv_lookup_by_dev(cmd, dev, found) (0)
# define lvmetad_vg_list_to_lvmcache(cmd) (1)
# define lvmetad_vg_lookup(cmd, vgname, vgid) (NULL)
-# define pvscan_lvmetad_single(cmd, dev) (0)
+# define pvscan_lvmetad_single(cmd, dev, handler) (0)
# endif /* LVMETAD_SUPPORT */
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 403367e..8c655c7 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -567,7 +567,8 @@ typedef enum {
CHANGE_AN = 1, /* deactivate */
CHANGE_AE = 2, /* activate exclusively */
CHANGE_ALY = 3, /* activate locally */
- CHANGE_ALN = 4 /* deactivate locally */
+ CHANGE_ALN = 4, /* deactivate locally */
+ CHANGE_AAY = 5 /* automatic activation */
} activation_change_t;
/* FIXME: refactor and reduce the size of this struct! */
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 7c22785..c14125a 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -3800,7 +3800,8 @@ int pv_write(struct cmd_context *cmd __attribute__((unused)),
if (!pv->fmt->ops->pv_write(pv->fmt, pv))
return_0;
- if (!lvmetad_pv_found(pv->id, pv->dev, pv->fmt, pv->label_sector, NULL))
+ if (!lvmetad_pv_found(pv->id, pv->dev, pv->fmt, pv->label_sector,
+ NULL, NULL))
return_0;
return 1;
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 37b86da..16e15a1 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -188,6 +188,12 @@ int activation_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_v
av->ui_value = CHANGE_AY;
}
+ else if (!strcmp(av->value, "a") || !strcmp(av->value, "ay") ||
+ !strcmp(av->value, "ya")) {
+ av->i_value = CHANGE_AAY;
+ av->ui_value = CHANGE_AAY;
+ }
+
else if (!strcmp(av->value, "n") || !strcmp(av->value, "en") ||
!strcmp(av->value, "ne")) {
av->i_value = CHANGE_AN;
diff --git a/tools/pvremove.c b/tools/pvremove.c
index 0c06c7f..7d05758 100644
--- a/tools/pvremove.c
+++ b/tools/pvremove.c
@@ -128,7 +128,7 @@ static int pvremove_single(struct cmd_context *cmd, const char *pv_name,
goto out;
}
- if (!lvmetad_pv_gone_by_dev(dev))
+ if (!lvmetad_pv_gone_by_dev(dev, NULL))
goto_out;
log_print("Labels on physical volume \"%s\" successfully wiped",
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 62034c9..beba174 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -97,7 +97,7 @@ static void _pvscan_display_single(struct cmd_context *cmd,
pv_pe_size(pv)));
}
-static int _pvscan_lvmetad_all_devs(struct cmd_context *cmd)
+static int _pvscan_lvmetad_all_devs(struct cmd_context *cmd, activation_handler handler)
{
struct dev_iter *iter;
struct device *dev;
@@ -109,7 +109,7 @@ static int _pvscan_lvmetad_all_devs(struct cmd_context *cmd)
}
while ((dev = dev_iter_get(iter))) {
- if (!pvscan_lvmetad_single(cmd, dev)) {
+ if (!pvscan_lvmetad_single(cmd, dev, handler)) {
r = 0;
break;
}
@@ -134,6 +134,7 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
struct arg_value_group_list *current_group;
dev_t devno;
char *buf;
+ activation_handler handler = NULL;
if (arg_count(cmd, major_ARG) + arg_count(cmd, minor_ARG))
devno_args = 1;
@@ -150,7 +151,7 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
/* Scan everything? */
if (!argc && !devno_args) {
- if (!_pvscan_lvmetad_all_devs(cmd))
+ if (!_pvscan_lvmetad_all_devs(cmd, handler))
ret = ECMD_FAILED;
goto out;
}
@@ -167,7 +168,7 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
continue;
}
- if (!pvscan_lvmetad_single(cmd, dev)) {
+ if (!pvscan_lvmetad_single(cmd, dev, handler)) {
ret = ECMD_FAILED;
break;
}
@@ -192,7 +193,7 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
if (!dm_asprintf(&buf, "%" PRIi32 ":%" PRIi32, major, minor))
stack;
/* FIXME Filters? */
- if (!lvmetad_pv_gone(devno, buf ? : "")) {
+ if (!lvmetad_pv_gone(devno, buf ? : "", handler)) {
ret = ECMD_FAILED;
if (buf)
dm_free(buf);
@@ -206,7 +207,7 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
continue;
}
- if (!pvscan_lvmetad_single(cmd, dev)) {
+ if (!pvscan_lvmetad_single(cmd, dev, handler)) {
ret = ECMD_FAILED;
break;
}
diff --git a/tools/tools.h b/tools/tools.h
index 8ddd351..7a44651 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -185,4 +185,7 @@ int mirror_remove_missing(struct cmd_context *cmd,
struct logical_volume *lv, int force);
uint32_t percent_of_extents(uint32_t percents, uint32_t count, int roundup);
+
+int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
+ activation_change_t activate);
#endif
diff --git a/tools/vgchange.c b/tools/vgchange.c
index fdad81f..29562a5 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -81,8 +81,8 @@ static int _poll_lvs_in_vg(struct cmd_context *cmd,
return count;
}
-static int _activate_lvs_in_vg(struct cmd_context *cmd,
- struct volume_group *vg, int activate)
+static int _activate_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg,
+ activation_change_t activate)
{
struct lv_list *lvl;
struct logical_volume *lv;
@@ -211,35 +211,32 @@ static int _vgchange_background_polling(struct cmd_context *cmd, struct volume_g
return 1;
}
-static int _vgchange_activate(struct cmd_context *cmd, struct volume_group *vg)
+int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
+ activation_change_t activate)
{
- int lv_open, active, monitored = 0;
- int activate_arg, r = 1;
- int activate = 1;
+ int lv_open, active, monitored = 0, r = 1, do_activate = 1;
+
+ if ((activate == CHANGE_AN) || (activate == CHANGE_ALN))
+ do_activate = 0;
/*
* Safe, since we never write out new metadata here. Required for
* partial activation to work.
*/
- cmd->handles_missing_pvs = 1;
-
- activate_arg = arg_uint_value(cmd, activate_ARG, 0);
-
- if ((activate_arg == CHANGE_AN) || (activate_arg == CHANGE_ALN))
- activate = 0;
+ cmd->handles_missing_pvs = 1;
/* FIXME: Force argument to deactivate them? */
- if (!activate && (lv_open = lvs_in_vg_opened(vg))) {
+ if (!do_activate && (lv_open = lvs_in_vg_opened(vg))) {
log_error("Can't deactivate volume group \"%s\" with %d open "
"logical volume(s)", vg->name, lv_open);
return 0;
}
/* FIXME Move into library where clvmd can use it */
- if (activate)
+ if (do_activate)
check_current_backup(vg);
- if (activate && (active = lvs_in_vg_activated(vg))) {
+ if (do_activate && (active = lvs_in_vg_activated(vg))) {
log_verbose("%d logical volume(s) in volume group \"%s\" "
"already active", active, vg->name);
if (dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) {
@@ -252,7 +249,7 @@ static int _vgchange_activate(struct cmd_context *cmd, struct volume_group *vg)
}
}
- if (!_activate_lvs_in_vg(cmd, vg, activate_arg))
+ if (!_activate_lvs_in_vg(cmd, vg, activate))
r = 0;
/* Print message only if there was not found a missing VG */
@@ -509,7 +506,7 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
}
if (arg_count(cmd, activate_ARG)) {
- if (!_vgchange_activate(cmd, vg))
+ if (!vgchange_activate(cmd, vg, arg_uint_value(cmd, activate_ARG, CHANGE_AY)))
return ECMD_FAILED;
}
10 years, 7 months
master - args: add --activate synonym for --available arg
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2729720fd329f2...
Commit: 2729720fd329f2c33cddeeded591a06fe4b6a147
Parent: 07a25c249b3ed449ca9f678c19ddb320967adaa9
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Wed Jun 27 07:48:31 2012 -0400
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Thu Jun 28 09:42:44 2012 -0400
args: add --activate synonym for --available arg
We're refererring to 'activation' all over the code and we're talking
about 'LVs being activated' all the time so let's use 'activation/activate'
everywhere for clarity and consistency (still providing the old
'available' keyword as a synonym for backward compatibility with
existing environments).
---
WHATS_NEW | 1 +
lib/metadata/metadata-exported.h | 10 ++++----
man/lvchange.8.in | 4 +-
man/lvcreate.8.in | 4 +-
man/vgchange.8.in | 4 +-
tools/args.h | 3 +-
tools/commands.h | 40 +++++++++++++++++++-------------------
tools/lvchange.c | 25 +++++++++++------------
tools/lvcreate.c | 4 +-
tools/lvmcmdline.c | 5 ++-
tools/toollib.c | 2 +-
tools/tools.h | 2 +-
tools/vgchange.c | 26 ++++++++++++------------
13 files changed, 66 insertions(+), 64 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 0eac530..0f90080 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.97 -
===============================
+ Add --activate synonym for --available arg and prefer --activate.
Never issue discards when LV extents are being reconfigured, not deleted.
Allow release_lv_segment_area to fail as functions it calls can fail.
Open device read-only to obtain readahead value.
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index f42ec33..403367e 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -563,11 +563,11 @@ int update_pool_lv(struct logical_volume *lv, int activate);
* Activation options
*/
typedef enum {
- CHANGE_AY = 0,
- CHANGE_AN = 1,
- CHANGE_AE = 2,
- CHANGE_ALY = 3,
- CHANGE_ALN = 4
+ CHANGE_AY = 0, /* activate */
+ CHANGE_AN = 1, /* deactivate */
+ CHANGE_AE = 2, /* activate exclusively */
+ CHANGE_ALY = 3, /* activate locally */
+ CHANGE_ALN = 4 /* deactivate locally */
} activation_change_t;
/* FIXME: refactor and reduce the size of this struct! */
diff --git a/man/lvchange.8.in b/man/lvchange.8.in
index 927be25..9494ba7 100644
--- a/man/lvchange.8.in
+++ b/man/lvchange.8.in
@@ -7,7 +7,7 @@ lvchange \- change attributes of a logical volume
.IR Tag ]
.RB [ \-A | \-\-autobackup
.RI { y | n }]
-.RB [ \-a | \-\-available
+.RB [ \-a | \-\-activate
.RI [ e | l ]{ y | n }]
.RB [ \-\-alloc
.IR AllocationPolicy ]
@@ -46,7 +46,7 @@ including making them known to the kernel ready for use.
.SH OPTIONS
See \fBlvm\fP(8) for common options.
.TP
-.BR \-a ", " \-\-available " [" \fIe | \fIl ]{ \fIy | \fIn }
+.BR \-a ", " \-\-activate " [" \fIe | \fIl ]{ \fIy | \fIn }
Controls the availability of the logical volumes for use.
Communicates with the kernel device-mapper driver via
libdevmapper to activate (\-ay) or deactivate (\-an) the
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index 97fe624..4b393e1 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -7,7 +7,7 @@ lvcreate \- create a logical volume in an existing volume group
.IR Tag ]
.RB [ \-\-alloc
.IR AllocationPolicy ]
-.RB [ \-a | \-\-available
+.RB [ \-a | \-\-activate
.RI [ e | l ]{ y | n }]
.RB [ \-A | \-\-autobackup
.RI { y | n }]
@@ -107,7 +107,7 @@ See
.BR lvm (8)
for common options.
.TP
-.IR \fB\-a ", " \fB\-\-available " {" y | n | ey | en | ly | ln }
+.IR \fB\-a ", " \fB\-\-activate " {" y | n | ey | en | ly | ln }
Controls the availability of the Logical Volumes for immediate use after
the command finishes running.
By default, new Logical Volumes are activated automatically (\fB-a\fIy\fR).
diff --git a/man/vgchange.8.in b/man/vgchange.8.in
index d43f79a..056acb4 100644
--- a/man/vgchange.8.in
+++ b/man/vgchange.8.in
@@ -9,7 +9,7 @@ vgchange \- change attributes of a volume group
.IR AllocationPolicy ]
.RB [ \-A | \-\-autobackup
.RI { y | n }]
-.RB [ \-a | \-\-available
+.RB [ \-a | \-\-activate
.RI [ e | l ]
.RI { y | n }]
.RB [ \-\-monitor
@@ -64,7 +64,7 @@ Controls automatic backup of metadata after the change. See
.BR vgcfgbackup (8).
Default is yes.
.TP
-.BR \-a ", " \-\-available " [" \fIe | \fIl ]{ \fIy | \fIn }
+.BR \-a ", " \-\-activate " [" \fIe | \fIl ]{ \fIy | \fIn }
Controls the availability of the logical volumes in the volume
group for input/output.
In other words, makes the logical volumes known/unknown to the kernel.
diff --git a/tools/args.h b/tools/args.h
index f2fa14b..2ce3c36 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -79,11 +79,12 @@ arg(thinpool_ARG, '\0', "thinpool", string_arg, 0)
/* Allow some variations */
arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)
arg(allocation_ARG, '\0', "allocation", yes_no_arg, 0)
+arg(available_ARG, '\0', "available", activation_arg, 0)
/*
* ... and now the short args.
*/
-arg(available_ARG, 'a', "available", yes_no_excl_arg, 0)
+arg(activate_ARG, 'a', "activate", activation_arg, 0)
arg(all_ARG, 'a', "all", NULL, 0)
arg(autobackup_ARG, 'A', "autobackup", yes_no_arg, 0)
arg(activevolumegroups_ARG, 'A', "activevolumegroups", NULL, 0)
diff --git a/tools/commands.h b/tools/commands.h
index a008a7b..a8c6587 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -61,7 +61,7 @@ xx(lvchange,
CACHE_VGMETADATA | PERMITTED_READ_ONLY,
"lvchange\n"
"\t[-A|--autobackup y|n]\n"
- "\t[-a|--available [e|l]y|n]\n"
+ "\t[-a|--activate [e|l]y|n]\n"
"\t[--addtag Tag]\n"
"\t[--alloc AllocationPolicy]\n"
"\t[-C|--contiguous y|n]\n"
@@ -87,11 +87,11 @@ xx(lvchange,
"\t[--version]" "\n"
"\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
- alloc_ARG, autobackup_ARG, available_ARG, contiguous_ARG, force_ARG,
- ignorelockingfailure_ARG, ignoremonitoring_ARG, major_ARG, minor_ARG,
- monitor_ARG, noudevsync_ARG, partial_ARG, permission_ARG, persistent_ARG,
- poll_ARG, readahead_ARG, resync_ARG, refresh_ARG, addtag_ARG, deltag_ARG,
- sysinit_ARG, test_ARG, yes_ARG)
+ alloc_ARG, autobackup_ARG, activate_ARG, available_ARG, contiguous_ARG,
+ force_ARG, ignorelockingfailure_ARG, ignoremonitoring_ARG, major_ARG,
+ minor_ARG, monitor_ARG, noudevsync_ARG, partial_ARG, permission_ARG,
+ persistent_ARG, poll_ARG, readahead_ARG, resync_ARG, refresh_ARG,
+ addtag_ARG, deltag_ARG, sysinit_ARG, test_ARG, yes_ARG)
xx(lvconvert,
"Change logical volume layout",
@@ -159,7 +159,7 @@ xx(lvcreate,
0,
"lvcreate " "\n"
"\t[-A|--autobackup {y|n}]\n"
- "\t[-a|--available [e|l]y|n]\n"
+ "\t[-a|--activate [e|l]y|n]\n"
"\t[--addtag Tag]\n"
"\t[--alloc AllocationPolicy]\n"
"\t[-C|--contiguous {y|n}]\n"
@@ -214,13 +214,13 @@ xx(lvcreate,
"\t[PhysicalVolumePath...]\n\n",
- addtag_ARG, alloc_ARG, autobackup_ARG, available_ARG, chunksize_ARG,
- contiguous_ARG, corelog_ARG, extents_ARG, ignoremonitoring_ARG, major_ARG,
- minor_ARG, mirrorlog_ARG, mirrors_ARG, monitor_ARG, name_ARG, nosync_ARG,
- noudevsync_ARG, permission_ARG, persistent_ARG, readahead_ARG,
- regionsize_ARG, size_ARG, snapshot_ARG, stripes_ARG, stripesize_ARG,
- test_ARG, thin_ARG, thinpool_ARG, type_ARG, virtualoriginsize_ARG,
- poolmetadatasize_ARG, virtualsize_ARG, zero_ARG)
+ addtag_ARG, alloc_ARG, autobackup_ARG, activate_ARG, available_ARG,
+ chunksize_ARG, contiguous_ARG, corelog_ARG, extents_ARG,
+ ignoremonitoring_ARG, major_ARG, minor_ARG, mirrorlog_ARG, mirrors_ARG,
+ monitor_ARG, name_ARG, nosync_ARG, noudevsync_ARG, permission_ARG,
+ persistent_ARG, readahead_ARG, regionsize_ARG, size_ARG, snapshot_ARG,
+ stripes_ARG, stripesize_ARG, test_ARG, thin_ARG, thinpool_ARG, type_ARG,
+ virtualoriginsize_ARG, poolmetadatasize_ARG, virtualsize_ARG, zero_ARG)
xx(lvdisplay,
"Display information about a logical volume",
@@ -742,7 +742,7 @@ xx(vgchange,
"\t[-u|--uuid] " "\n"
"\t[-v|--verbose] " "\n"
"\t[--version]" "\n"
- "\t{-a|--available [e|l]{y|n} |" "\n"
+ "\t{-a|--activate [e|l]{y|n} |" "\n"
"\t -c|--clustered {y|n} |" "\n"
"\t -x|--resizeable {y|n} |" "\n"
"\t -l|--logicalvolume MaxLogicalVolumes |" "\n"
@@ -752,11 +752,11 @@ xx(vgchange,
"\t --deltag Tag}\n"
"\t[VolumeGroupName...]\n",
- addtag_ARG, alloc_ARG, allocation_ARG, autobackup_ARG, available_ARG,
- clustered_ARG, deltag_ARG, ignorelockingfailure_ARG, ignoremonitoring_ARG,
- logicalvolume_ARG, maxphysicalvolumes_ARG, monitor_ARG, noudevsync_ARG,
- metadatacopies_ARG, vgmetadatacopies_ARG, partial_ARG,
- physicalextentsize_ARG, poll_ARG, refresh_ARG, resizeable_ARG,
+ addtag_ARG, alloc_ARG, allocation_ARG, autobackup_ARG, activate_ARG,
+ available_ARG, clustered_ARG, deltag_ARG, ignorelockingfailure_ARG,
+ ignoremonitoring_ARG, logicalvolume_ARG, maxphysicalvolumes_ARG,
+ monitor_ARG, noudevsync_ARG, metadatacopies_ARG, vgmetadatacopies_ARG,
+ partial_ARG, physicalextentsize_ARG, poll_ARG, refresh_ARG, resizeable_ARG,
resizable_ARG, sysinit_ARG, test_ARG, uuid_ARG)
xx(vgck,
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 2ed8c16..4d040be 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -127,12 +127,11 @@ static int lvchange_background_polling(struct cmd_context *cmd,
return 1;
}
-static int lvchange_availability(struct cmd_context *cmd,
- struct logical_volume *lv)
+static int _lvchange_activate(struct cmd_context *cmd, struct logical_volume *lv)
{
int activate;
- activate = arg_uint_value(cmd, available_ARG, 0);
+ activate = arg_uint_value(cmd, activate_ARG, 0);
if (lv_is_cow(lv) && !lv_is_virtual_origin(origin_from_cow(lv)))
lv = origin_from_cow(lv);
@@ -556,7 +555,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
}
if (lv_is_cow(lv) && !lv_is_virtual_origin(origin = origin_from_cow(lv)) &&
- arg_count(cmd, available_ARG)) {
+ arg_count(cmd, activate_ARG)) {
if (origin->origin_count < 2)
snaps_msg[0] = '\0';
else if (dm_snprintf(snaps_msg, sizeof(snaps_msg),
@@ -577,7 +576,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
if (lv->status & PVMOVE) {
log_error("Unable to change pvmove LV %s", lv->name);
- if (arg_count(cmd, available_ARG))
+ if (arg_count(cmd, activate_ARG))
log_error("Use 'pvmove --abort' to abandon a pvmove");
return ECMD_FAILED;
}
@@ -594,7 +593,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
}
/* If LV is sparse, activate origin instead */
- if (arg_count(cmd, available_ARG) && lv_is_cow(lv) &&
+ if (arg_count(cmd, activate_ARG) && lv_is_cow(lv) &&
lv_is_virtual_origin(origin = origin_from_cow(lv)))
lv = origin;
@@ -696,9 +695,9 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
return ECMD_FAILED;
}
- /* availability change */
- if (arg_count(cmd, available_ARG)) {
- if (!lvchange_availability(cmd, lv)) {
+ /* activation change */
+ if (arg_count(cmd, activate_ARG)) {
+ if (!_lvchange_activate(cmd, lv)) {
stack;
return ECMD_FAILED;
}
@@ -710,7 +709,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
return ECMD_FAILED;
}
- if (!arg_count(cmd, available_ARG) &&
+ if (!arg_count(cmd, activate_ARG) &&
!arg_count(cmd, refresh_ARG) &&
arg_count(cmd, monitor_ARG)) {
if (!lvchange_monitoring(cmd, lv)) {
@@ -719,7 +718,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
}
}
- if (!arg_count(cmd, available_ARG) &&
+ if (!arg_count(cmd, activate_ARG) &&
!arg_count(cmd, refresh_ARG) &&
arg_count(cmd, poll_ARG)) {
if (!lvchange_background_polling(cmd, lv)) {
@@ -745,7 +744,7 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
arg_count(cmd, resync_ARG) || arg_count(cmd, alloc_ARG);
if (!update &&
- !arg_count(cmd, available_ARG) && !arg_count(cmd, refresh_ARG) &&
+ !arg_count(cmd, activate_ARG) && !arg_count(cmd, refresh_ARG) &&
!arg_count(cmd, monitor_ARG) && !arg_count(cmd, poll_ARG)) {
log_error("Need 1 or more of -a, -C, -M, -p, -r, "
"--resync, --refresh, --alloc, --addtag, --deltag, "
@@ -753,7 +752,7 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- if (arg_count(cmd, available_ARG) && arg_count(cmd, refresh_ARG)) {
+ if (arg_count(cmd, activate_ARG) && arg_count(cmd, refresh_ARG)) {
log_error("Only one of -a and --refresh permitted.");
return EINVALID_CMD_LINE;
}
diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index 28d4dbf..a81e39d 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -560,11 +560,11 @@ static int _read_activation_params(struct lvcreate_params *lp, struct cmd_contex
unsigned pagesize;
lp->activate = (activation_change_t)
- arg_uint_value(cmd, available_ARG, CHANGE_AY);
+ arg_uint_value(cmd, activate_ARG, CHANGE_AY);
if (lp->activate == CHANGE_AN || lp->activate == CHANGE_ALN) {
if (lp->zero && !seg_is_thin(lp)) {
- log_error("--available n requires --zero n");
+ log_error("--activate n requires --zero n");
return 0;
}
}
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 2c3bb39..37b86da 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -172,7 +172,7 @@ int yes_no_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_value
return 1;
}
-int yes_no_excl_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av)
+int activation_arg(struct cmd_context *cmd __attribute__((unused)), struct arg_values *av)
{
av->sign = SIGN_NONE;
av->percent = PERCENT_NONE;
@@ -889,7 +889,8 @@ static int _get_settings(struct cmd_context *cmd)
if (!_merge_synonym(cmd, resizable_ARG, resizeable_ARG) ||
!_merge_synonym(cmd, allocation_ARG, allocatable_ARG) ||
!_merge_synonym(cmd, allocation_ARG, resizeable_ARG) ||
- !_merge_synonym(cmd, virtualoriginsize_ARG, virtualsize_ARG))
+ !_merge_synonym(cmd, virtualoriginsize_ARG, virtualsize_ARG) ||
+ !_merge_synonym(cmd, available_ARG, activate_ARG))
return EINVALID_CMD_LINE;
if ((!strncmp(cmd->command->name, "pv", 2) &&
diff --git a/tools/toollib.c b/tools/toollib.c
index 361052b..142de55 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -129,7 +129,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd,
/* Skip availability change for non-virt snaps when processing all LVs */
/* FIXME: pass process_all to process_single_lv() */
- if (process_all && arg_count(cmd, available_ARG) &&
+ if (process_all && arg_count(cmd, activate_ARG) &&
lv_is_cow(lvl->lv) && !lv_is_virtual_origin(origin_from_cow(lvl->lv)))
continue;
diff --git a/tools/tools.h b/tools/tools.h
index b467e4b..8ddd351 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -138,7 +138,7 @@ void usage(const char *name);
/* the argument verify/normalise functions */
int yes_no_arg(struct cmd_context *cmd, struct arg_values *av);
-int yes_no_excl_arg(struct cmd_context *cmd, struct arg_values *av);
+int activation_arg(struct cmd_context *cmd, struct arg_values *av);
int size_kb_arg(struct cmd_context *cmd, struct arg_values *av);
int size_mb_arg(struct cmd_context *cmd, struct arg_values *av);
int int_arg(struct cmd_context *cmd, struct arg_values *av);
diff --git a/tools/vgchange.c b/tools/vgchange.c
index dc06ac9..fdad81f 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -211,10 +211,10 @@ static int _vgchange_background_polling(struct cmd_context *cmd, struct volume_g
return 1;
}
-static int _vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
+static int _vgchange_activate(struct cmd_context *cmd, struct volume_group *vg)
{
int lv_open, active, monitored = 0;
- int available, r = 1;
+ int activate_arg, r = 1;
int activate = 1;
/*
@@ -223,9 +223,9 @@ static int _vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
*/
cmd->handles_missing_pvs = 1;
- available = arg_uint_value(cmd, available_ARG, 0);
+ activate_arg = arg_uint_value(cmd, activate_ARG, 0);
- if ((available == CHANGE_AN) || (available == CHANGE_ALN))
+ if ((activate_arg == CHANGE_AN) || (activate_arg == CHANGE_ALN))
activate = 0;
/* FIXME: Force argument to deactivate them? */
@@ -252,7 +252,7 @@ static int _vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
}
}
- if (!_activate_lvs_in_vg(cmd, vg, available))
+ if (!_activate_lvs_in_vg(cmd, vg, activate_arg))
r = 0;
/* Print message only if there was not found a missing VG */
@@ -508,8 +508,8 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
log_print("Volume group \"%s\" successfully changed", vg->name);
}
- if (arg_count(cmd, available_ARG)) {
- if (!_vgchange_available(cmd, vg))
+ if (arg_count(cmd, activate_ARG)) {
+ if (!_vgchange_activate(cmd, vg))
return ECMD_FAILED;
}
@@ -519,7 +519,7 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
return ECMD_FAILED;
}
- if (!arg_count(cmd, available_ARG) &&
+ if (!arg_count(cmd, activate_ARG) &&
!arg_count(cmd, refresh_ARG) &&
arg_count(cmd, monitor_ARG)) {
/* -ay* will have already done monitoring changes */
@@ -551,7 +551,7 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
arg_count(cmd, vgmetadatacopies_ARG);
if (!update &&
- !arg_count(cmd, available_ARG) &&
+ !arg_count(cmd, activate_ARG) &&
!arg_count(cmd, monitor_ARG) &&
!arg_count(cmd, poll_ARG) &&
!arg_count(cmd, refresh_ARG)) {
@@ -562,7 +562,7 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- if (arg_count(cmd, available_ARG) && arg_count(cmd, refresh_ARG)) {
+ if (arg_count(cmd, activate_ARG) && arg_count(cmd, refresh_ARG)) {
log_error("Only one of -a and --refresh permitted.");
return EINVALID_CMD_LINE;
}
@@ -573,9 +573,9 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- if (arg_count(cmd, available_ARG) &&
+ if (arg_count(cmd, activate_ARG) &&
(arg_count(cmd, monitor_ARG) || arg_count(cmd, poll_ARG))) {
- int activate = arg_uint_value(cmd, available_ARG, 0);
+ int activate = arg_uint_value(cmd, activate_ARG, 0);
if (activate == CHANGE_AN || activate == CHANGE_ALN) {
log_error("Only -ay* allowed with --monitor or --poll.");
return EINVALID_CMD_LINE;
@@ -587,7 +587,7 @@ int vgchange(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- if (arg_count(cmd, available_ARG) == 1
+ if (arg_count(cmd, activate_ARG) == 1
&& arg_count(cmd, autobackup_ARG)) {
log_error("-A option not necessary with -a option");
return EINVALID_CMD_LINE;
10 years, 7 months
master - discards: don't discard reconfigured extents
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=07a25c249b3ed4...
Commit: 07a25c249b3ed449ca9f678c19ddb320967adaa9
Parent: e59f6981e6547fcffc8bd86b435dac3e805b9fc0
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Jun 27 21:53:02 2012 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Jun 27 22:12:01 2012 +0100
discards: don't discard reconfigured extents
Update release_lv_segment_area not to discard any PV extents,
as it also gets used when moving extents between LVs.
Instead, call a new function release_and_discard_lv_segment_area() in
the two places where data should be discarded - lv_reduce() and
remove_mirrors_from_segments().
---
WHATS_NEW | 1 +
lib/metadata/lv_alloc.h | 1 +
lib/metadata/lv_manip.c | 21 ++++++++++++++++++---
lib/metadata/mirror.c | 2 +-
4 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index bc9cea7..0eac530 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.97 -
===============================
+ Never issue discards when LV extents are being reconfigured, not deleted.
Allow release_lv_segment_area to fail as functions it calls can fail.
Open device read-only to obtain readahead value.
Fix lvconvert error path NULL pointer dereference.
diff --git a/lib/metadata/lv_alloc.h b/lib/metadata/lv_alloc.h
index 71ca1ab..9f8e0e3 100644
--- a/lib/metadata/lv_alloc.h
+++ b/lib/metadata/lv_alloc.h
@@ -42,6 +42,7 @@ int move_lv_segment_area(struct lv_segment *seg_to, uint32_t area_to,
struct lv_segment *seg_from, uint32_t area_from);
int release_lv_segment_area(struct lv_segment *seg, uint32_t s,
uint32_t area_reduction);
+int release_and_discard_lv_segment_area(struct lv_segment *seg, uint32_t s, uint32_t area_reduction);
struct alloc_handle;
struct alloc_handle *allocate_extents(struct volume_group *vg,
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index bdcc925..a0be887 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -299,17 +299,22 @@ struct lv_segment *alloc_snapshot_seg(struct logical_volume *lv,
return seg;
}
-int release_lv_segment_area(struct lv_segment *seg, uint32_t s,
- uint32_t area_reduction)
+static int _release_and_discard_lv_segment_area(struct lv_segment *seg, uint32_t s,
+ uint32_t area_reduction, int with_discard)
{
if (seg_type(seg, s) == AREA_UNASSIGNED)
return 1;
if (seg_type(seg, s) == AREA_PV) {
+ if (with_discard && !discard_pv_segment(seg_pvseg(seg, s), area_reduction))
+ return_0;
+
if (!release_pv_segment(seg_pvseg(seg, s), area_reduction))
return_0;
+
if (seg->area_len == area_reduction)
seg_type(seg, s) = AREA_UNASSIGNED;
+
return 1;
}
@@ -365,6 +370,16 @@ int release_lv_segment_area(struct lv_segment *seg, uint32_t s,
return 1;
}
+int release_and_discard_lv_segment_area(struct lv_segment *seg, uint32_t s, uint32_t area_reduction)
+{
+ return _release_and_discard_lv_segment_area(seg, s, area_reduction, 1);
+}
+
+int release_lv_segment_area(struct lv_segment *seg, uint32_t s, uint32_t area_reduction)
+{
+ return _release_and_discard_lv_segment_area(seg, s, area_reduction, 0);
+}
+
/*
* Move a segment area from one segment to another
*/
@@ -501,7 +516,7 @@ static int _lv_segment_reduce(struct lv_segment *seg, uint32_t reduction)
area_reduction = reduction;
for (s = 0; s < seg->area_count; s++)
- if (!release_lv_segment_area(seg, s, area_reduction))
+ if (!release_and_discard_lv_segment_area(seg, s, area_reduction))
return_0;
seg->len -= reduction;
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index d943175..61e4b47 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -1469,7 +1469,7 @@ int remove_mirrors_from_segments(struct logical_volume *lv,
}
for (s = new_mirrors + 1; s < seg->area_count; s++)
- if (!release_lv_segment_area(seg, s, seg->area_len))
+ if (!release_and_discard_lv_segment_area(seg, s, seg->area_len))
return_0;
seg->area_count = new_mirrors + 1;
10 years, 7 months
master - discards: split discard from release_pv_segment
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e59f6981e6547f...
Commit: e59f6981e6547fcffc8bd86b435dac3e805b9fc0
Parent: a5ddb347e569a953d6732d8d9f72857a560b5bcd
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Jun 27 20:07:04 2012 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Jun 27 22:11:54 2012 +0100
discards: split discard from release_pv_segment
Separate discard_pv_segment out of release_pv_segment
---
lib/metadata/pv_alloc.h | 1 +
lib/metadata/pv_manip.c | 58 ++++++++++++++++++++++++++++------------------
2 files changed, 36 insertions(+), 23 deletions(-)
diff --git a/lib/metadata/pv_alloc.h b/lib/metadata/pv_alloc.h
index d894f31..2318473 100644
--- a/lib/metadata/pv_alloc.h
+++ b/lib/metadata/pv_alloc.h
@@ -23,6 +23,7 @@ struct pv_segment *assign_peg_to_lvseg(struct physical_volume *pv, uint32_t pe,
int pv_split_segment(struct dm_pool *mem,
struct physical_volume *pv, uint32_t pe,
struct pv_segment **pvseg_allocated);
+int discard_pv_segment(struct pv_segment *peg, uint32_t discard_area_reduction);
int release_pv_segment(struct pv_segment *peg, uint32_t area_reduction);
int check_pv_segments(struct volume_group *vg);
void merge_pv_segments(struct pv_segment *peg1, struct pv_segment *peg2);
diff --git a/lib/metadata/pv_manip.c b/lib/metadata/pv_manip.c
index 9eca9e7..e3fe272 100644
--- a/lib/metadata/pv_manip.c
+++ b/lib/metadata/pv_manip.c
@@ -189,14 +189,13 @@ struct pv_segment *assign_peg_to_lvseg(struct physical_volume *pv,
return peg;
}
-int release_pv_segment(struct pv_segment *peg, uint32_t area_reduction)
+int discard_pv_segment(struct pv_segment *peg, uint32_t discard_area_reduction)
{
uint64_t discard_offset_sectors;
uint64_t pe_start = peg->pv->pe_start;
- uint64_t discard_area_reduction = area_reduction;
if (!peg->lvseg) {
- log_error("release_pv_segment with unallocated segment: "
+ log_error("discard_pv_segment with unallocated segment: "
"%s PE %" PRIu32, pv_dev_name(peg->pv), peg->pe);
return 0;
}
@@ -205,26 +204,39 @@ int release_pv_segment(struct pv_segment *peg, uint32_t area_reduction)
* Only issue discards if enabled in lvm.conf and both
* the device and kernel (>= 2.6.35) supports discards.
*/
- if (find_config_tree_bool(peg->pv->fmt->cmd,
- "devices/issue_discards", DEFAULT_ISSUE_DISCARDS) &&
- dev_discard_max_bytes(peg->pv->fmt->cmd->sysfs_dir, peg->pv->dev) &&
- dev_discard_granularity(peg->pv->fmt->cmd->sysfs_dir, peg->pv->dev)) {
- discard_offset_sectors = (peg->pe + peg->lvseg->area_len - area_reduction) *
- (uint64_t) peg->pv->vg->extent_size + pe_start;
- if (!discard_offset_sectors) {
- /*
- * pe_start=0 and the PV's first extent contains the label.
- * Must skip past the first extent.
- */
- discard_offset_sectors = peg->pv->vg->extent_size;
- discard_area_reduction--;
- }
- log_debug("Discarding %" PRIu64 " extents offset %" PRIu64 " sectors on %s.",
- discard_area_reduction, discard_offset_sectors, dev_name(peg->pv->dev));
- if (discard_area_reduction &&
- !dev_discard_blocks(peg->pv->dev, discard_offset_sectors << SECTOR_SHIFT,
- discard_area_reduction * (uint64_t) peg->pv->vg->extent_size * SECTOR_SIZE))
- return_0;
+ if (!find_config_tree_bool(peg->pv->fmt->cmd,
+ "devices/issue_discards", DEFAULT_ISSUE_DISCARDS) ||
+ !dev_discard_max_bytes(peg->pv->fmt->cmd->sysfs_dir, peg->pv->dev) ||
+ !dev_discard_granularity(peg->pv->fmt->cmd->sysfs_dir, peg->pv->dev))
+ return 1;
+
+ discard_offset_sectors = (peg->pe + peg->lvseg->area_len - discard_area_reduction) *
+ (uint64_t) peg->pv->vg->extent_size + pe_start;
+ if (!discard_offset_sectors) {
+ /*
+ * pe_start=0 and the PV's first extent contains the label.
+ * Must skip past the first extent.
+ */
+ discard_offset_sectors = peg->pv->vg->extent_size;
+ discard_area_reduction--;
+ }
+
+ log_debug("Discarding %" PRIu32 " extents offset %" PRIu64 " sectors on %s.",
+ discard_area_reduction, discard_offset_sectors, dev_name(peg->pv->dev));
+ if (discard_area_reduction &&
+ !dev_discard_blocks(peg->pv->dev, discard_offset_sectors << SECTOR_SHIFT,
+ discard_area_reduction * (uint64_t) peg->pv->vg->extent_size * SECTOR_SIZE))
+ return_0;
+
+ return 1;
+}
+
+int release_pv_segment(struct pv_segment *peg, uint32_t area_reduction)
+{
+ if (!peg->lvseg) {
+ log_error("release_pv_segment with unallocated segment: "
+ "%s PE %" PRIu32, pv_dev_name(peg->pv), peg->pe);
+ return 0;
}
if (peg->lvseg->area_len == area_reduction) {
10 years, 7 months
master - allocation: allow release_lv_segment_area to fail
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a5ddb347e569a9...
Commit: a5ddb347e569a953d6732d8d9f72857a560b5bcd
Parent: 5723db017ab62c40697329e1725ecb3b32b4d217
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Wed Jun 27 19:37:54 2012 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Wed Jun 27 22:11:49 2012 +0100
allocation: allow release_lv_segment_area to fail
Allow release_lv_segment_area to fail as functions it calls can fail.
---
WHATS_NEW | 1 +
lib/metadata/lv_alloc.h | 4 +-
lib/metadata/lv_manip.c | 49 +++++++++++++++++++++++++++-------------------
lib/metadata/mirror.c | 10 +++++---
4 files changed, 38 insertions(+), 26 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 9479d6d..bc9cea7 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.97 -
===============================
+ Allow release_lv_segment_area to fail as functions it calls can fail.
Open device read-only to obtain readahead value.
Fix lvconvert error path NULL pointer dereference.
Check for create_instance() fail in pvscan_lvmetad_single().
diff --git a/lib/metadata/lv_alloc.h b/lib/metadata/lv_alloc.h
index 2ec0030..71ca1ab 100644
--- a/lib/metadata/lv_alloc.h
+++ b/lib/metadata/lv_alloc.h
@@ -40,8 +40,8 @@ int set_lv_segment_area_lv(struct lv_segment *seg, uint32_t area_num,
uint64_t status);
int move_lv_segment_area(struct lv_segment *seg_to, uint32_t area_to,
struct lv_segment *seg_from, uint32_t area_from);
-void release_lv_segment_area(struct lv_segment *seg, uint32_t s,
- uint32_t area_reduction);
+int release_lv_segment_area(struct lv_segment *seg, uint32_t s,
+ uint32_t area_reduction);
struct alloc_handle;
struct alloc_handle *allocate_extents(struct volume_group *vg,
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 5c715a8..bdcc925 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -299,24 +299,25 @@ struct lv_segment *alloc_snapshot_seg(struct logical_volume *lv,
return seg;
}
-void release_lv_segment_area(struct lv_segment *seg, uint32_t s,
- uint32_t area_reduction)
+int release_lv_segment_area(struct lv_segment *seg, uint32_t s,
+ uint32_t area_reduction)
{
if (seg_type(seg, s) == AREA_UNASSIGNED)
- return;
+ return 1;
if (seg_type(seg, s) == AREA_PV) {
- if (release_pv_segment(seg_pvseg(seg, s), area_reduction) &&
- seg->area_len == area_reduction)
+ if (!release_pv_segment(seg_pvseg(seg, s), area_reduction))
+ return_0;
+ if (seg->area_len == area_reduction)
seg_type(seg, s) = AREA_UNASSIGNED;
- return;
+ return 1;
}
if ((seg_lv(seg, s)->status & MIRROR_IMAGE) ||
(seg_lv(seg, s)->status & THIN_POOL_DATA)) {
if (!lv_reduce(seg_lv(seg, s), area_reduction))
- stack; /* FIXME: any upper level reporting */
- return;
+ return_0; /* FIXME: any upper level reporting */
+ return 1;
}
if (seg_lv(seg, s)->status & RAID_IMAGE) {
@@ -328,12 +329,12 @@ void release_lv_segment_area(struct lv_segment *seg, uint32_t s,
*/
if (area_reduction != seg->area_len) {
log_error("Unable to reduce RAID LV - operation not implemented.");
- return;
+ return_0;
} else {
if (!lv_remove(seg_lv(seg, s))) {
log_error("Failed to remove RAID image %s",
seg_lv(seg, s)->name);
- return;
+ return 0;
}
}
@@ -343,10 +344,10 @@ void release_lv_segment_area(struct lv_segment *seg, uint32_t s,
seg_metalv(seg, s)->le_count)) {
log_error("Failed to remove RAID meta-device %s",
seg_metalv(seg, s)->name);
- return;
+ return 0;
}
}
- return;
+ return 1;
}
if (area_reduction == seg->area_len) {
@@ -360,6 +361,8 @@ void release_lv_segment_area(struct lv_segment *seg, uint32_t s,
seg_le(seg, s) = 0;
seg_type(seg, s) = AREA_UNASSIGNED;
}
+
+ return 1;
}
/*
@@ -377,9 +380,11 @@ int move_lv_segment_area(struct lv_segment *seg_to, uint32_t area_to,
pv = seg_pv(seg_from, area_from);
pe = seg_pe(seg_from, area_from);
- release_lv_segment_area(seg_from, area_from,
- seg_from->area_len);
- release_lv_segment_area(seg_to, area_to, seg_to->area_len);
+ if (!release_lv_segment_area(seg_from, area_from, seg_from->area_len))
+ return_0;
+
+ if (!release_lv_segment_area(seg_to, area_to, seg_to->area_len))
+ return_0;
if (!set_lv_segment_area_pv(seg_to, area_to, pv, pe))
return_0;
@@ -390,9 +395,11 @@ int move_lv_segment_area(struct lv_segment *seg_to, uint32_t area_to,
lv = seg_lv(seg_from, area_from);
le = seg_le(seg_from, area_from);
- release_lv_segment_area(seg_from, area_from,
- seg_from->area_len);
- release_lv_segment_area(seg_to, area_to, seg_to->area_len);
+ if (!release_lv_segment_area(seg_from, area_from, seg_from->area_len))
+ return_0;
+
+ if (!release_lv_segment_area(seg_to, area_to, seg_to->area_len))
+ return_0;
if (!set_lv_segment_area_lv(seg_to, area_to, lv, le, 0))
return_0;
@@ -400,7 +407,8 @@ int move_lv_segment_area(struct lv_segment *seg_to, uint32_t area_to,
break;
case AREA_UNASSIGNED:
- release_lv_segment_area(seg_to, area_to, seg_to->area_len);
+ if (!release_lv_segment_area(seg_to, area_to, seg_to->area_len))
+ return_0;
}
return 1;
@@ -493,7 +501,8 @@ static int _lv_segment_reduce(struct lv_segment *seg, uint32_t reduction)
area_reduction = reduction;
for (s = 0; s < seg->area_count; s++)
- release_lv_segment_area(seg, s, area_reduction);
+ if (!release_lv_segment_area(seg, s, area_reduction))
+ return_0;
seg->len -= reduction;
seg->area_len -= area_reduction;
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index 236edea..d943175 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -645,8 +645,8 @@ static int _split_mirror_images(struct logical_volume *lv,
sub_lv = seg_lv(mirrored_seg, mirrored_seg->area_count);
sub_lv->status &= ~MIRROR_IMAGE;
- release_lv_segment_area(mirrored_seg, mirrored_seg->area_count,
- mirrored_seg->area_len);
+ if (!release_lv_segment_area(mirrored_seg, mirrored_seg->area_count, mirrored_seg->area_len))
+ return_0;
log_very_verbose("%s assigned to be split", sub_lv->name);
@@ -906,7 +906,8 @@ static int _remove_mirror_images(struct logical_volume *lv,
}
lvl->lv = seg_lv(mirrored_seg, m);
dm_list_add(&tmp_orphan_lvs, &lvl->list);
- release_lv_segment_area(mirrored_seg, m, mirrored_seg->area_len);
+ if (!release_lv_segment_area(mirrored_seg, m, mirrored_seg->area_len))
+ return_0;
}
mirrored_seg->area_count = new_area_count;
@@ -1468,7 +1469,8 @@ int remove_mirrors_from_segments(struct logical_volume *lv,
}
for (s = new_mirrors + 1; s < seg->area_count; s++)
- release_lv_segment_area(seg, s, seg->area_len);
+ if (!release_lv_segment_area(seg, s, seg->area_len))
+ return_0;
seg->area_count = new_mirrors + 1;
10 years, 7 months
master - configure: autoreconf
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5723db017ab62c...
Commit: 5723db017ab62c40697329e1725ecb3b32b4d217
Parent: e6f8d86409e54300aeda05a82aad9b072d22ed4d
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Jun 21 08:43:38 2012 -0400
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jun 27 12:12:08 2012 +0200
configure: autoreconf
---
configure | 144 ++++++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 110 insertions(+), 34 deletions(-)
diff --git a/configure b/configure
index 1bddccc..e54efd3 100755
--- a/configure
+++ b/configure
@@ -605,9 +605,11 @@ kernelvsn
missingkernel
kerneldir
interface
+LVMETAD_PIDFILE
DMEVENTD_PIDFILE
WRITE_INSTALL
UDEV_HAS_BUILTIN_BLKID
+UDEV_RULE_EXEC_DETECTION
UDEV_SYNC
UDEV_RULES
UDEV_PC
@@ -659,6 +661,7 @@ DMEVENTD
DL_LIBS
DEVMAPPER
DEFAULT_RUN_DIR
+DEFAULT_DM_RUN_DIR
DEFAULT_LOCK_DIR
DEFAULT_DATA_ALIGNMENT
DEFAULT_CACHE_SUBDIR
@@ -814,6 +817,9 @@ enable_readline
enable_realtime
enable_ocf
with_ocfdir
+with_default_pid_dir
+with_default_dm_run_dir
+with_default_run_dir
with_clvmd
with_clvmd_pidfile
enable_cmirrord
@@ -825,8 +831,10 @@ enable_testing
enable_valgrind_pool
enable_devmapper
enable_lvmetad
+with_lvmetad_pidfile
enable_udev_sync
enable_udev_rules
+enable_udev_rule_exec_detection
enable_compat
enable_units_compat
enable_ioctl
@@ -850,7 +858,6 @@ with_systemdsystemunitdir
with_tmpfilesdir
with_dmeventd_pidfile
with_dmeventd_path
-with_default_run_dir
with_default_system_dir
with_default_archive_subdir
with_default_backup_subdir
@@ -1525,6 +1532,8 @@ Optional Features:
--enable-lvmetad enable the LVM Metadata Daemon
--enable-udev_sync enable synchronisation with udev processing
--enable-udev_rules install rule files needed for udev synchronisation
+ --enable-udev-rule-exec-detection
+ enable executable path detection in udev rules
--enable-compat enable support for old device-mapper versions
--enable-units-compat enable output compatibility with old versions that
that do not use KiB-style unit suffixes
@@ -1571,6 +1580,12 @@ Optional Packages:
--with-thin-check=PATH thin_check tool: [[autodetect]]
--with-ocfdir=DIR install OCF files in DIR
[[PREFIX/lib/ocf/resource.d/lvm2]]
+ --with-default-pid-dir=PID_DIR
+ Default directory to keep PID files in. [[/var/run]]
+ --with-default-dm-run-dir=DM_RUN_DIR
+ Default DM run directory. [[/var/run]]
+ --with-default-run-dir=RUN_DIR
+ Default LVM run directory. [[/var/run/lvm]]
--with-clvmd=TYPE build cluster LVM Daemon
The following cluster manager combinations are valid:
* cman (RHEL5 or equivalent)
@@ -1580,10 +1595,12 @@ Optional Packages:
* none (disable build)
[TYPE=none]
--with-clvmd-pidfile=PATH
- clvmd pidfile [[/var/run/clvmd.pid]]
+ clvmd pidfile [[PID_DIR/clvmd.pid]]
--with-cmirrord-pidfile=PATH
- cmirrord pidfile [[/var/run/cmirrord.pid]]
+ cmirrord pidfile [[PID_DIR/cmirrord.pid]]
--with-optimisation=OPT C optimisation flag [[OPT=-O2]]
+ --with-lvmetad-pidfile=PATH
+ lvmetad pidfile [[PID_DIR/lvmetad.pid]]
--with-localedir=DIR translation files in DIR [[PREFIX/share/locale]]
--with-confdir=DIR configuration files in DIR [[/etc]]
--with-staticdir=DIR static binaries in DIR [[EPREFIX/sbin]]
@@ -1598,10 +1615,9 @@ Optional Packages:
volatile files and directories in DIR
[[SYSCONFDIR/tmpfiles.d]]
--with-dmeventd-pidfile=PATH
- dmeventd pidfile [[/var/run/dmeventd.pid]]
+ dmeventd pidfile [[PID_DIR/dmeventd.pid]]
--with-dmeventd-path=PATH
dmeventd path [[EPREFIX/sbin/dmeventd]]
- --with-default-run-dir=DIR Default run directory [/var/run/lvm]
--with-default-system-dir=DIR
default LVM system directory [[/etc/lvm]]
--with-default-archive-subdir=SUBDIR
@@ -7315,6 +7331,52 @@ fi
}
################################################################################
+
+
+# Check whether --with-default-pid-dir was given.
+if test "${with_default_pid_dir+set}" = set; then :
+ withval=$with_default_pid_dir; DEFAULT_PID_DIR="$withval"
+else
+ DEFAULT_PID_DIR="/var/run"
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_PID_DIR "$DEFAULT_PID_DIR"
+_ACEOF
+
+
+
+
+# Check whether --with-default-dm-run-dir was given.
+if test "${with_default_dm_run_dir+set}" = set; then :
+ withval=$with_default_dm_run_dir; DEFAULT_DM_RUN_DIR="$withval"
+else
+ DEFAULT_DM_RUN_DIR="/var/run"
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_DM_RUN_DIR "$DEFAULT_DM_RUN_DIR"
+_ACEOF
+
+
+
+
+# Check whether --with-default-run-dir was given.
+if test "${with_default_run_dir+set}" = set; then :
+ withval=$with_default_run_dir; DEFAULT_RUN_DIR="$withval"
+else
+ DEFAULT_RUN_DIR="/var/run/lvm"
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_RUN_DIR "$DEFAULT_RUN_DIR"
+_ACEOF
+
+
+################################################################################
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build cluster LVM daemon" >&5
$as_echo_n "checking whether to build cluster LVM daemon... " >&6; }
@@ -8217,7 +8279,7 @@ if test "x$CLVMD" != xnone; then
if test "${with_clvmd_pidfile+set}" = set; then :
withval=$with_clvmd_pidfile; CLVMD_PIDFILE=$withval
else
- CLVMD_PIDFILE="/var/run/clvmd.pid"
+ CLVMD_PIDFILE="$DEFAULT_PID_DIR/clvmd.pid"
fi
@@ -8249,7 +8311,7 @@ if test "x$BUILD_CMIRRORD" = xyes; then
if test "${with_cmirrord_pidfile+set}" = set; then :
withval=$with_cmirrord_pidfile; CMIRRORD_PIDFILE=$withval
else
- CMIRRORD_PIDFILE="/var/run/cmirrord.pid"
+ CMIRRORD_PIDFILE="$DEFAULT_PID_DIR/cmirrord.pid"
fi
@@ -8801,6 +8863,20 @@ if test x$BUILD_LVMETAD = xyes; then
$as_echo "#define LVMETAD_SUPPORT 1" >>confdefs.h
+
+
+# Check whether --with-lvmetad-pidfile was given.
+if test "${with_lvmetad_pidfile+set}" = set; then :
+ withval=$with_lvmetad_pidfile; LVMETAD_PIDFILE=$withval
+else
+ LVMETAD_PIDFILE="$DEFAULT_PID_DIR/lvmetad.pid"
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define LVMETAD_PIDFILE "$LVMETAD_PIDFILE"
+_ACEOF
+
fi
################################################################################
@@ -8928,18 +9004,28 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $UDEV_RULES" >&5
$as_echo "$UDEV_RULES" >&6; }
-if test x$UDEV_RULES = xyes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether udev supports builtin blkid" >&5
-$as_echo_n "checking whether udev supports builtin blkid... " >&6; }
- udev_version=$(udevadm info --version 2>/dev/null)
- if test -n "$udev_version" && test "$udev_version" -ge 176; then
- UDEV_HAS_BUILTIN_BLKID=yes
- else
- UDEV_HAS_BUILTIN_BLKID=no
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $UDEV_HAS_BUILTIN_BLKID" >&5
-$as_echo "$UDEV_HAS_BUILTIN_BLKID" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable executable path detection in udev rules" >&5
+$as_echo_n "checking whether to enable executable path detection in udev rules... " >&6; }
+# Check whether --enable-udev_rule_exec_detection was given.
+if test "${enable_udev_rule_exec_detection+set}" = set; then :
+ enableval=$enable_udev_rule_exec_detection; UDEV_RULE_EXEC_DETECTION=$enableval
+else
+ UDEV_RULE_EXEC_DETECTION=no
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $UDEV_RULE_EXEC_DETECTION" >&5
+$as_echo "$UDEV_RULE_EXEC_DETECTION" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether udev supports built-in blkid" >&5
+$as_echo_n "checking whether udev supports built-in blkid... " >&6; }
+test x$PKGCONFIG_INIT != x1 && pkg_config_init
+if $($PKG_CONFIG --atleast-version=176 libudev); then
+ UDEV_HAS_BUILTIN_BLKID=yes
+else
+ UDEV_HAS_BUILTIN_BLKID=no
fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $UDEV_HAS_BUILTIN_BLKID" >&5
+$as_echo "$UDEV_HAS_BUILTIN_BLKID" >&6; }
################################################################################
# Check whether --enable-compat was given.
@@ -10211,7 +10297,7 @@ if test "$BUILD_DMEVENTD" = yes; then
if test "${with_dmeventd_pidfile+set}" = set; then :
withval=$with_dmeventd_pidfile; DMEVENTD_PIDFILE=$withval
else
- DMEVENTD_PIDFILE="/var/run/dmeventd.pid"
+ DMEVENTD_PIDFILE="$DEFAULT_PID_DIR/dmeventd.pid"
fi
@@ -10237,20 +10323,6 @@ _ACEOF
fi
-
-
-# Check whether --with-default-run-dir was given.
-if test "${with_default_run_dir+set}" = set; then :
- withval=$with_default_run_dir; DEFAULT_RUN_DIR="$withval"
-else
- DEFAULT_RUN_DIR="/var/run/lvm"
-fi
-
-cat >>confdefs.h <<_ACEOF
-#define DEFAULT_RUN_DIR "$DEFAULT_RUN_DIR"
-_ACEOF
-
-
################################################################################
# Check whether --with-default-system-dir was given.
@@ -10491,8 +10563,11 @@ LVM_LIBAPI=`echo "$VER" | $AWK -F '[()]' '{print $2}'`
+
+
+
################################################################################
-ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/dmeventd/plugins/thin/Makefile daemons/lvmetad/Makefile doc/Makefile doc/example.conf include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/replicator/Makefile lib/misc/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/Makefile libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_monitoring_init_red_hat scripts/dm_event_systemd_red_hat.service scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_tmpfiles_red_hat.conf scripts/Makefile test/Makefile test/api/Makefile test/unit/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile unit-tests/mm/Makefile"
+ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/raid/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile daemons/dmeventd/plugins/thin/Makefile daemons/lvmetad/Makefile doc/Makefile doc/example.conf include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/replicator/Makefile lib/misc/lvm-version.h lib/raid/Makefile lib/snapshot/Makefile lib/thin/Makefile libdaemon/Makefile libdaemon/client/Makefile libdaemon/server/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_lvmetad_init_red_hat scripts/lvm2_lvmetad_systemd_red_hat.socket scripts/lvm2_lvmetad_systemd_red_hat.service scripts/lvm2_monitoring_init_red_hat scripts/dm_event_systemd_red_hat.socket scripts/dm_event_systemd_red_hat.service scripts/lvm2_monitoring_systemd_red_hat.service scripts/lvm2_tmpfiles_red_hat.conf scripts/Makefile test/Makefile test/api/Makefile test/unit/Makefile tools/Makefile udev/Makefile unit-tests/datastruct/Makefile unit-tests/regex/Makefile unit-tests/mm/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
@@ -11224,6 +11299,7 @@ do
"scripts/lvm2_lvmetad_systemd_red_hat.socket") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmetad_systemd_red_hat.socket" ;;
"scripts/lvm2_lvmetad_systemd_red_hat.service") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_lvmetad_systemd_red_hat.service" ;;
"scripts/lvm2_monitoring_init_red_hat") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_monitoring_init_red_hat" ;;
+ "scripts/dm_event_systemd_red_hat.socket") CONFIG_FILES="$CONFIG_FILES scripts/dm_event_systemd_red_hat.socket" ;;
"scripts/dm_event_systemd_red_hat.service") CONFIG_FILES="$CONFIG_FILES scripts/dm_event_systemd_red_hat.service" ;;
"scripts/lvm2_monitoring_systemd_red_hat.service") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_monitoring_systemd_red_hat.service" ;;
"scripts/lvm2_tmpfiles_red_hat.conf") CONFIG_FILES="$CONFIG_FILES scripts/lvm2_tmpfiles_red_hat.conf" ;;
10 years, 7 months
master - udev: udev rules cleanup
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e6f8d86409e543...
Commit: e6f8d86409e54300aeda05a82aad9b072d22ed4d
Parent: 9a96f930a762418f1014f6a9da9546cb1f501f04
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Jun 22 05:50:02 2012 -0400
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jun 27 12:11:56 2012 +0200
udev: udev rules cleanup
Remove executable path detection in udev rules and use sbindir that
is configured, but still provide the original functionality by means
of 'configure --enable-udev-rule-exec-detection'.
Normally, the exec path for the tools called in udev rules should
not differ from the sbindir used, however, there are cases this is
necessary. For example different environments could be assembled
in a way that these path differ for some reason (distribution installer,
initrd ...).
This functionality is kept for compatibility only. Any environment
moving the binaries around and using different paths should be fixed
eventually!
---
WHATS_NEW_DM | 2 ++
configure.in | 25 ++++++++++++++++---------
udev/10-dm.rules.in | 12 ++++--------
udev/11-dm-lvm.rules | 37 -------------------------------------
udev/11-dm-lvm.rules.in | 37 +++++++++++++++++++++++++++++++++++++
udev/69-dm-lvm-metad.rules | 30 ------------------------------
udev/69-dm-lvm-metad.rules.in | 26 ++++++++++++++++++++++++++
udev/95-dm-notify.rules | 12 ------------
udev/95-dm-notify.rules.in | 12 ++++++++++++
udev/Makefile.in | 33 ++++++++++++++++++++++-----------
10 files changed, 119 insertions(+), 107 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index f6596c1..711104b 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,7 @@
Version 1.02.76 -
===============================
+ Add configure --enable-udev-rule-exec-detection to detect exec path in rules.
+ Use sbindir in udev rules by default and remove executable path detection.
Remove hard-coded paths for dmeventd fifos and use default-dm-run-dir.
Add configure --with-lvmetad-pidfile to remove hard-coded value.
Add configure --with-default-pid-dir for common directory with pid files.
diff --git a/configure.in b/configure.in
index 814c0bd..6c27324 100644
--- a/configure.in
+++ b/configure.in
@@ -934,16 +934,22 @@ AC_ARG_ENABLE(udev_rules,
UDEV_RULES=$enableval, UDEV_RULES=$UDEV_SYNC)
AC_MSG_RESULT($UDEV_RULES)
-if test x$UDEV_RULES = xyes; then
- AC_MSG_CHECKING(whether udev supports builtin blkid)
- udev_version=$(udevadm info --version 2>/dev/null)
- if test -n "$udev_version" && test "$udev_version" -ge 176; then
- UDEV_HAS_BUILTIN_BLKID=yes
- else
- UDEV_HAS_BUILTIN_BLKID=no
- fi
- AC_MSG_RESULT($UDEV_HAS_BUILTIN_BLKID)
+AC_MSG_CHECKING(whether to enable executable path detection in udev rules)
+AC_ARG_ENABLE(udev_rule_exec_detection,
+ AC_HELP_STRING([--enable-udev-rule-exec-detection],
+ [enable executable path detection in udev rules]),
+ UDEV_RULE_EXEC_DETECTION=$enableval, UDEV_RULE_EXEC_DETECTION=no)
+AC_MSG_RESULT($UDEV_RULE_EXEC_DETECTION)
+
+dnl -- Check support for built-in blkid against target udev version
+AC_MSG_CHECKING(whether udev supports built-in blkid)
+test x$PKGCONFIG_INIT != x1 && pkg_config_init
+if $($PKG_CONFIG --atleast-version=176 libudev); then
+ UDEV_HAS_BUILTIN_BLKID=yes
+else
+ UDEV_HAS_BUILTIN_BLKID=no
fi
+AC_MSG_RESULT($UDEV_HAS_BUILTIN_BLKID)
################################################################################
dnl -- Compatibility mode
@@ -1528,6 +1534,7 @@ AC_SUBST(UDEV_LIBS)
AC_SUBST(UDEV_PC)
AC_SUBST(UDEV_RULES)
AC_SUBST(UDEV_SYNC)
+AC_SUBST(UDEV_RULE_EXEC_DETECTION)
AC_SUBST(UDEV_HAS_BUILTIN_BLKID)
AC_SUBST(CUNIT_LIBS)
AC_SUBST(CUNIT_CFLAGS)
diff --git a/udev/10-dm.rules.in b/udev/10-dm.rules.in
index 605e088..29af467 100644
--- a/udev/10-dm.rules.in
+++ b/udev/10-dm.rules.in
@@ -18,11 +18,7 @@ KERNEL=="device-mapper", NAME="(DM_DIR)/control"
SUBSYSTEM!="block", GOTO="dm_end"
KERNEL!="dm-[0-9]*", GOTO="dm_end"
-
-# Set proper sbin path, /sbin has higher priority than /usr/sbin.
-ENV{DM_SBIN_PATH}="/sbin"
-TEST!="$env{DM_SBIN_PATH}/dmsetup", ENV{DM_SBIN_PATH}="/usr/sbin"
-TEST!="$env{DM_SBIN_PATH}/dmsetup", GOTO="dm_end"
+(DM_EXEC_RULE)
# Device created, major and minor number assigned - "add" event generated.
# Table loaded - no event generated.
@@ -40,7 +36,7 @@ ACTION!="add|change", GOTO="dm_end"
# These flags are encoded in DM_COOKIE variable that was introduced in
# kernel version 2.6.31. Therefore, we can use this feature with
# kernels >= 2.6.31 only. Cookie is not decoded for remove event.
-ENV{DM_COOKIE}=="?*", IMPORT{program}="$env{DM_SBIN_PATH}/dmsetup udevflags $env{DM_COOKIE}"
+ENV{DM_COOKIE}=="?*", IMPORT{program}="(DM_EXEC)/dmsetup udevflags $env{DM_COOKIE}"
# Rule out easy-to-detect inappropriate events first.
ENV{DISK_RO}=="1", GOTO="dm_disable"
@@ -91,8 +87,8 @@ ACTION=="add", ENV{DM_UDEV_RULES_VSN}!="1", ENV{DM_UDEV_PRIMARY_SOURCE_FLAG}!="1
# so we also have to call dmsetup if the kernel version used
# is in between these releases.
TEST=="dm", ENV{DM_NAME}="$attr{dm/name}", ENV{DM_UUID}="$attr{dm/uuid}", ENV{DM_SUSPENDED}="$attr{dm/suspended}"
-TEST!="dm", IMPORT{program}="$env{DM_SBIN_PATH}/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o name,uuid,suspended"
-ENV{DM_SUSPENDED}!="?*", IMPORT{program}="$env{DM_SBIN_PATH}/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o suspended"
+TEST!="dm", IMPORT{program}="(DM_EXEC)/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o name,uuid,suspended"
+ENV{DM_SUSPENDED}!="?*", IMPORT{program}="(DM_EXEC)/dmsetup info -j %M -m %m -c --nameprefixes --noheadings --rows -o suspended"
# dmsetup tool provides suspended state information in textual
# form with values "Suspended"/"Active". We translate it to
diff --git a/udev/11-dm-lvm.rules b/udev/11-dm-lvm.rules
deleted file mode 100644
index 8244464..0000000
--- a/udev/11-dm-lvm.rules
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2009 Red Hat, Inc. All rights reserved.
-#
-# This file is part of LVM2.
-
-# Udev rules for LVM.
-#
-# These rules create symlinks for LVM logical volumes in
-# /dev/VG directory (VG is an actual VG name). Some udev
-# environment variables are set (they can be used in later
-# rules as well):
-# DM_LV_NAME - logical volume name
-# DM_VG_NAME - volume group name
-# DM_LV_LAYER - logical volume layer (blank if not set)
-
-# "add" event is processed on coldplug only!
-ACTION!="add|change", GOTO="lvm_end"
-ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="lvm_end"
-ENV{DM_UUID}!="LVM-?*", GOTO="lvm_end"
-
-# Use DM name and split it up into its VG/LV/layer constituents.
-IMPORT{program}="$env{DM_SBIN_PATH}/dmsetup splitname --nameprefixes --noheadings --rows $env{DM_NAME}"
-
-ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}=="1", GOTO="lvm_end"
-
-# Do not create symlinks for inappropriate subdevices.
-ENV{DM_LV_NAME}=="pvmove?*|?*_vorigin", GOTO="lvm_disable"
-ENV{DM_LV_LAYER}=="?*", GOTO="lvm_disable"
-
-# Create symlinks for top-level devices only.
-ENV{DM_VG_NAME}=="?*", ENV{DM_LV_NAME}=="?*", SYMLINK+="$env{DM_VG_NAME}/$env{DM_LV_NAME}", GOTO="lvm_end"
-
-LABEL="lvm_disable"
-ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="1"
-ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
-OPTIONS:="nowatch"
-
-LABEL="lvm_end"
diff --git a/udev/11-dm-lvm.rules.in b/udev/11-dm-lvm.rules.in
new file mode 100644
index 0000000..58ef210
--- /dev/null
+++ b/udev/11-dm-lvm.rules.in
@@ -0,0 +1,37 @@
+# Copyright (C) 2009 Red Hat, Inc. All rights reserved.
+#
+# This file is part of LVM2.
+
+# Udev rules for LVM.
+#
+# These rules create symlinks for LVM logical volumes in
+# /dev/VG directory (VG is an actual VG name). Some udev
+# environment variables are set (they can be used in later
+# rules as well):
+# DM_LV_NAME - logical volume name
+# DM_VG_NAME - volume group name
+# DM_LV_LAYER - logical volume layer (blank if not set)
+
+# "add" event is processed on coldplug only!
+ACTION!="add|change", GOTO="lvm_end"
+ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="lvm_end"
+ENV{DM_UUID}!="LVM-?*", GOTO="lvm_end"
+
+# Use DM name and split it up into its VG/LV/layer constituents.
+IMPORT{program}="(DM_EXEC)/dmsetup splitname --nameprefixes --noheadings --rows $env{DM_NAME}"
+
+ENV{DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG}=="1", GOTO="lvm_end"
+
+# Do not create symlinks for inappropriate subdevices.
+ENV{DM_LV_NAME}=="pvmove?*|?*_vorigin", GOTO="lvm_disable"
+ENV{DM_LV_LAYER}=="?*", GOTO="lvm_disable"
+
+# Create symlinks for top-level devices only.
+ENV{DM_VG_NAME}=="?*", ENV{DM_LV_NAME}=="?*", SYMLINK+="$env{DM_VG_NAME}/$env{DM_LV_NAME}", GOTO="lvm_end"
+
+LABEL="lvm_disable"
+ENV{DM_UDEV_DISABLE_DISK_RULES_FLAG}="1"
+ENV{DM_UDEV_DISABLE_OTHER_RULES_FLAG}="1"
+OPTIONS:="nowatch"
+
+LABEL="lvm_end"
diff --git a/udev/69-dm-lvm-metad.rules b/udev/69-dm-lvm-metad.rules
deleted file mode 100644
index d272e6e..0000000
--- a/udev/69-dm-lvm-metad.rules
+++ /dev/null
@@ -1,30 +0,0 @@
-# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
-#
-# This file is part of LVM2.
-
-# Udev rules for LVM.
-#
-# Scan all block devices having a PV label for LVM metadata.
-# Store this information in LVMetaD (the LVM metadata daemon) and maintain LVM
-# metadata state for improved performance by avoiding further scans while
-# running subsequent LVM commands or while using lvm2app library.
-# Also, notify LVMetaD about any relevant block device removal.
-#
-# This rule is essential for having the information in LVMetaD up-to-date.
-# It also requires blkid to be called on block devices before so only devices
-# used as LVM PVs are processed (ID_FS_TYPE="LVM2_member" or "LVM1_member").
-
-SUBSYSTEM!="block", GOTO="lvm_end"
-
-# Device-mapper devices are processed only on change event or on supported synthesized event.
-KERNEL=="dm-[0-9]*", ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="lvm_end"
-
-# Set proper sbin path, /sbin has higher priority than /usr/sbin.
-ENV{LVM_SBIN_PATH}="/sbin"
-TEST!="$env{LVM_SBIN_PATH}/lvm", ENV{LVM_SBIN_PATH}="/usr/sbin"
-TEST!="$env{LVM_SBIN_PATH}/lvm", GOTO="lvm_end"
-
-# Only process devices already marked as a PV - this requires blkid to be called before.
-ENV{ID_FS_TYPE}=="LVM2_member|LVM1_member", RUN+="$env{LVM_SBIN_PATH}/lvm pvscan --cache --major $major --minor $minor"
-
-LABEL="lvm_end"
diff --git a/udev/69-dm-lvm-metad.rules.in b/udev/69-dm-lvm-metad.rules.in
new file mode 100644
index 0000000..26309de
--- /dev/null
+++ b/udev/69-dm-lvm-metad.rules.in
@@ -0,0 +1,26 @@
+# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
+#
+# This file is part of LVM2.
+
+# Udev rules for LVM.
+#
+# Scan all block devices having a PV label for LVM metadata.
+# Store this information in LVMetaD (the LVM metadata daemon) and maintain LVM
+# metadata state for improved performance by avoiding further scans while
+# running subsequent LVM commands or while using lvm2app library.
+# Also, notify LVMetaD about any relevant block device removal.
+#
+# This rule is essential for having the information in LVMetaD up-to-date.
+# It also requires blkid to be called on block devices before so only devices
+# used as LVM PVs are processed (ID_FS_TYPE="LVM2_member" or "LVM1_member").
+
+SUBSYSTEM!="block", GOTO="lvm_end"
+(LVM_EXEC_RULE)
+
+# Device-mapper devices are processed only on change event or on supported synthesized event.
+KERNEL=="dm-[0-9]*", ENV{DM_UDEV_RULES_VSN}!="?*", GOTO="lvm_end"
+
+# Only process devices already marked as a PV - this requires blkid to be called before.
+ENV{ID_FS_TYPE}=="LVM2_member|LVM1_member", RUN+="(LVM_EXEC)/lvm pvscan --cache --major $major --minor $minor"
+
+LABEL="lvm_end"
diff --git a/udev/95-dm-notify.rules b/udev/95-dm-notify.rules
deleted file mode 100644
index 72cc609..0000000
--- a/udev/95-dm-notify.rules
+++ /dev/null
@@ -1,12 +0,0 @@
-# Copyright (C) 2009 Red Hat, Inc. All rights reserved.
-#
-# This file is part of LVM2.
-
-# Udev rules for device-mapper devices.
-#
-# These rules are responsible for sending a notification to a process
-# waiting for completion of udev rules. The process is identified by
-# a cookie value sent within "change" and "remove" events (the cookie
-# value is set before by that process for every action requested).
-
-ENV{DM_COOKIE}=="?*", RUN+="$env{DM_SBIN_PATH}/dmsetup udevcomplete $env{DM_COOKIE}"
diff --git a/udev/95-dm-notify.rules.in b/udev/95-dm-notify.rules.in
new file mode 100644
index 0000000..80d59d3
--- /dev/null
+++ b/udev/95-dm-notify.rules.in
@@ -0,0 +1,12 @@
+# Copyright (C) 2009 Red Hat, Inc. All rights reserved.
+#
+# This file is part of LVM2.
+
+# Udev rules for device-mapper devices.
+#
+# These rules are responsible for sending a notification to a process
+# waiting for completion of udev rules. The process is identified by
+# a cookie value sent within "change" and "remove" events (the cookie
+# value is set before by that process for every action requested).
+
+ENV{DM_COOKIE}=="?*", RUN+="(DM_EXEC)/dmsetup udevcomplete $env{DM_COOKIE}"
diff --git a/udev/Makefile.in b/udev/Makefile.in
index 4ace910..5c15bdb 100644
--- a/udev/Makefile.in
+++ b/udev/Makefile.in
@@ -15,28 +15,39 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
+include $(top_builddir)/make.tmpl
+vpath %.rules $(srcdir)
+
DM_RULES=10-dm.rules 13-dm-disk.rules 95-dm-notify.rules
LVM_RULES=11-dm-lvm.rules
-DM_DIR=$(shell grep "\#define DM_DIR" $(top_srcdir)/libdm/misc/dm-ioctl.h | awk '{print $$3}')
-
ifeq ("@BUILD_LVMETAD@", "yes")
LVM_RULES+=69-dm-lvm-metad.rules
endif
-ifeq ("@UDEV_HAS_BUILTIN_BLKID@", "yes")
- BLKID_RULE=IMPORT{builtin}=\"blkid\"
+DM_DIR=$(shell grep "\#define DM_DIR" $(top_srcdir)/libdm/misc/dm-ioctl.h | awk '{print $$3}')
+
+ifeq ("@UDEV_RULE_EXEC_DETECTION@", "yes")
+SBIN=\$$env{DM_SBIN_PATH}
+DM_EXEC_RULE=ENV{DM_SBIN_PATH}=\"\/sbin\"\\nTEST!=\"\$$env{DM_SBIN_PATH}\/dmsetup\", ENV{DM_SBIN_PATH}=\"\/usr\/sbin\"
+DM_EXEC=\$$env{DM_SBIN_PATH}
+LVM_EXEC_RULE=ENV{LVM_SBIN_PATH}=\"\/sbin\"\\nTEST!=\"\$$env{LVM_SBIN_PATH}\/lvm\", ENV{LVM_SBIN_PATH}=\"\/usr\/sbin\"
+LVM_EXEC=\$$env{LVM_SBIN_PATH}
else
- BLKID_RULE=IMPORT{program}=\"\$$env{DM_SBIN_PATH}\/blkid -o udev -p \$$tempnode\"
+SBIN="@sbindir@"
+DM_EXEC_RULE=""
+DM_EXEC=${SBIN}
+LVM_EXEC_RULE=""
+LVM_EXEC=${SBIN}
endif
-CLEAN_TARGETS = 10-dm.rules 13-dm-disk.rules
-
-include $(top_builddir)/make.tmpl
-
-vpath %.rules $(srcdir)
+ifeq ("@UDEV_HAS_BUILTIN_BLKID@", "yes")
+BLKID_RULE=IMPORT{builtin}=\"blkid\"
+else
+BLKID_RULE=IMPORT{program}=\"${SBIN}\/blkid -o udev -p \$$tempnode\"
+endif
%.rules: %.rules.in
- $(SED) -e "s/(DM_DIR)/$(DM_DIR)/" -e "s/(BLKID_RULE)/$(BLKID_RULE)/" $< >$@
+ $(SED) -e "s+(DM_DIR)+$(DM_DIR)+;s+(BLKID_RULE)+$(BLKID_RULE)+;s+(DM_EXEC_RULE)+$(DM_EXEC_RULE)+;s+(DM_EXEC)+$(DM_EXEC)+;s+(LVM_EXEC_RULE)+$(LVM_EXEC_RULE)+;s+(LVM_EXEC)+$(LVM_EXEC)+;" $< >$@
%_install: %.rules
$(INSTALL_DATA) -D $< $(udevdir)/$(<F)
10 years, 7 months
master - configure: run directory configuration cleanup
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9a96f930a76241...
Commit: 9a96f930a762418f1014f6a9da9546cb1f501f04
Parent: c8591b2ac7c99ea43e7f94f3dfb183019c2fed6e
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Jun 21 08:41:52 2012 -0400
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Wed Jun 27 12:11:47 2012 +0200
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)
---
WHATS_NEW_DM | 4 ++
configure.in | 56 +++++++++++++++++-----
daemons/dmeventd/dmeventd.h | 4 +-
daemons/lvmetad/lvmetad-core.c | 2 +-
lib/misc/configure.h.in | 11 ++++-
scripts/Makefile.in | 8 ++-
scripts/dm_event_systemd_red_hat.socket | 12 -----
scripts/dm_event_systemd_red_hat.socket.in | 11 +++++
scripts/lvm2_lvmetad_init_red_hat.in | 2 +-
scripts/lvm2_lvmetad_systemd_red_hat.service.in | 2 +-
10 files changed, 78 insertions(+), 34 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 33f8515..f6596c1 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,9 @@
Version 1.02.76 -
===============================
+ Remove hard-coded paths for dmeventd fifos and use default-dm-run-dir.
+ Add configure --with-lvmetad-pidfile to remove hard-coded value.
+ Add configure --with-default-pid-dir for common directory with pid files.
+ Add configure --with-default-dm-run-dir to set run directory for dm tools.
Add documentation references in systemd units.
Remove veritysetup. Now maintained with cryptsetup.
diff --git a/configure.in b/configure.in
index f55a505..814c0bd 100644
--- a/configure.in
+++ b/configure.in
@@ -470,6 +470,32 @@ pkg_config_init() {
}
################################################################################
+dnl -- Set up pidfile and run directory
+AH_TEMPLATE(DEFAULT_PID_DIR)
+AC_ARG_WITH(default-pid-dir,
+ AC_HELP_STRING([--with-default-pid-dir=PID_DIR],
+ [Default directory to keep PID files in. [[/var/run]]]),
+ DEFAULT_PID_DIR="$withval", DEFAULT_PID_DIR="/var/run")
+AC_DEFINE_UNQUOTED(DEFAULT_PID_DIR, ["$DEFAULT_PID_DIR"],
+ [Default directory to keep PID files in.])
+
+AH_TEMPLATE(DEFAULT_DM_RUN_DIR, [Name of default DM run directory.])
+AC_ARG_WITH(default-dm-run-dir,
+ AC_HELP_STRING([--with-default-dm-run-dir=DM_RUN_DIR],
+ [ Default DM run directory. [[/var/run]]]),
+ DEFAULT_DM_RUN_DIR="$withval", DEFAULT_DM_RUN_DIR="/var/run")
+AC_DEFINE_UNQUOTED(DEFAULT_DM_RUN_DIR, ["$DEFAULT_DM_RUN_DIR"],
+ [Default DM run directory.])
+
+AH_TEMPLATE(DEFAULT_RUN_DIR, [Name of default LVM run directory.])
+AC_ARG_WITH(default-run-dir,
+ AC_HELP_STRING([--with-default-run-dir=RUN_DIR],
+ [Default LVM run directory. [[/var/run/lvm]]]),
+ DEFAULT_RUN_DIR="$withval", DEFAULT_RUN_DIR="/var/run/lvm")
+AC_DEFINE_UNQUOTED(DEFAULT_RUN_DIR, ["$DEFAULT_RUN_DIR"],
+ [Default LVM run directory.])
+
+################################################################################
dnl -- Build cluster LVM daemon
AC_MSG_CHECKING(whether to build cluster LVM daemon)
AC_ARG_WITH(clvmd,
@@ -721,9 +747,9 @@ dnl -- clvmd pidfile
if test "x$CLVMD" != xnone; then
AC_ARG_WITH(clvmd-pidfile,
AC_HELP_STRING([--with-clvmd-pidfile=PATH],
- [clvmd pidfile [[/var/run/clvmd.pid]]]),
+ [clvmd pidfile [[PID_DIR/clvmd.pid]]]),
CLVMD_PIDFILE=$withval,
- CLVMD_PIDFILE="/var/run/clvmd.pid")
+ CLVMD_PIDFILE="$DEFAULT_PID_DIR/clvmd.pid")
AC_DEFINE_UNQUOTED(CLVMD_PIDFILE, ["$CLVMD_PIDFILE"],
[Path to clvmd pidfile.])
fi
@@ -744,9 +770,9 @@ dnl -- cmirrord pidfile
if test "x$BUILD_CMIRRORD" = xyes; then
AC_ARG_WITH(cmirrord-pidfile,
AC_HELP_STRING([--with-cmirrord-pidfile=PATH],
- [cmirrord pidfile [[/var/run/cmirrord.pid]]]),
+ [cmirrord pidfile [[PID_DIR/cmirrord.pid]]]),
CMIRRORD_PIDFILE=$withval,
- CMIRRORD_PIDFILE="/var/run/cmirrord.pid")
+ CMIRRORD_PIDFILE="$DEFAULT_PID_DIR/cmirrord.pid")
AC_DEFINE_UNQUOTED(CMIRRORD_PIDFILE, ["$CMIRRORD_PIDFILE"],
[Path to cmirrord pidfile.])
fi
@@ -872,6 +898,14 @@ BUILD_LVMETAD=$LVMETAD
if test x$BUILD_LVMETAD = xyes; then
AC_DEFINE([LVMETAD_SUPPORT], 1, [Define to 1 to include code that uses lvmetad.])
+
+ AC_ARG_WITH(lvmetad-pidfile,
+ AC_HELP_STRING([--with-lvmetad-pidfile=PATH],
+ [lvmetad pidfile [[PID_DIR/lvmetad.pid]]]),
+ LVMETAD_PIDFILE=$withval,
+ LVMETAD_PIDFILE="$DEFAULT_PID_DIR/lvmetad.pid")
+ AC_DEFINE_UNQUOTED(LVMETAD_PIDFILE, ["$LVMETAD_PIDFILE"],
+ [Path to lvmetad pidfile.])
fi
################################################################################
@@ -1302,9 +1336,9 @@ dnl -- dmeventd pidfile and executable path
if test "$BUILD_DMEVENTD" = yes; then
AC_ARG_WITH(dmeventd-pidfile,
AC_HELP_STRING([--with-dmeventd-pidfile=PATH],
- [dmeventd pidfile [[/var/run/dmeventd.pid]]]),
+ [dmeventd pidfile [[PID_DIR/dmeventd.pid]]]),
DMEVENTD_PIDFILE=$withval,
- DMEVENTD_PIDFILE="/var/run/dmeventd.pid")
+ DMEVENTD_PIDFILE="$DEFAULT_PID_DIR/dmeventd.pid")
AC_DEFINE_UNQUOTED(DMEVENTD_PIDFILE, ["$DMEVENTD_PIDFILE"],
[Path to dmeventd pidfile.])
fi
@@ -1319,13 +1353,6 @@ if test "$BUILD_DMEVENTD" = yes; then
[Path to dmeventd binary.])
fi
-AH_TEMPLATE(DEFAULT_RUN_DIR, [Name of default run directory.])
-AC_ARG_WITH(default-run-dir,
- [ --with-default-run-dir=DIR Default run directory [[/var/run/lvm]] ],
- [ DEFAULT_RUN_DIR="$withval" ],
- [ DEFAULT_RUN_DIR="/var/run/lvm" ])
-AC_DEFINE_UNQUOTED(DEFAULT_RUN_DIR,["$DEFAULT_RUN_DIR"] )
-
################################################################################
dnl -- various defaults
AC_ARG_WITH(default-system-dir,
@@ -1437,6 +1464,7 @@ AC_SUBST(DEFAULT_BACKUP_SUBDIR)
AC_SUBST(DEFAULT_CACHE_SUBDIR)
AC_SUBST(DEFAULT_DATA_ALIGNMENT)
AC_SUBST(DEFAULT_LOCK_DIR)
+AC_SUBST(DEFAULT_DM_RUN_DIR)
AC_SUBST(DEFAULT_RUN_DIR)
AC_SUBST(DEVMAPPER)
AC_SUBST(DLM_CFLAGS)
@@ -1505,6 +1533,7 @@ AC_SUBST(CUNIT_LIBS)
AC_SUBST(CUNIT_CFLAGS)
AC_SUBST(WRITE_INSTALL)
AC_SUBST(DMEVENTD_PIDFILE)
+AC_SUBST(LVMETAD_PIDFILE)
AC_SUBST(interface)
AC_SUBST(kerneldir)
AC_SUBST(missingkernel)
@@ -1564,6 +1593,7 @@ scripts/lvm2_lvmetad_init_red_hat
scripts/lvm2_lvmetad_systemd_red_hat.socket
scripts/lvm2_lvmetad_systemd_red_hat.service
scripts/lvm2_monitoring_init_red_hat
+scripts/dm_event_systemd_red_hat.socket
scripts/dm_event_systemd_red_hat.service
scripts/lvm2_monitoring_systemd_red_hat.service
scripts/lvm2_tmpfiles_red_hat.conf
diff --git a/daemons/dmeventd/dmeventd.h b/daemons/dmeventd/dmeventd.h
index 81056e9..e21cf45 100644
--- a/daemons/dmeventd/dmeventd.h
+++ b/daemons/dmeventd/dmeventd.h
@@ -17,8 +17,8 @@
/* FIXME This stuff must be configurable. */
-#define DM_EVENT_FIFO_CLIENT "/var/run/dmeventd-client"
-#define DM_EVENT_FIFO_SERVER "/var/run/dmeventd-server"
+#define DM_EVENT_FIFO_CLIENT DEFAULT_DM_RUN_DIR "/dmeventd-client"
+#define DM_EVENT_FIFO_SERVER DEFAULT_DM_RUN_DIR "/dmeventd-server"
#define DM_EVENT_DEFAULT_TIMEOUT 10
diff --git a/daemons/lvmetad/lvmetad-core.c b/daemons/lvmetad/lvmetad-core.c
index 5b34e21..d41a905 100644
--- a/daemons/lvmetad/lvmetad-core.c
+++ b/daemons/lvmetad/lvmetad-core.c
@@ -1094,7 +1094,7 @@ int main(int argc, char *argv[])
s.socket_path = getenv("LVM_LVMETAD_SOCKET");
if (!s.socket_path)
s.socket_path = DEFAULT_RUN_DIR "/lvmetad.socket";
- s.pidfile = DEFAULT_RUN_DIR "/lvmetad.pid";
+ s.pidfile = LVMETAD_PIDFILE;
s.log_level = 0;
s.protocol = "lvmetad";
s.protocol_version = 1;
diff --git a/lib/misc/configure.h.in b/lib/misc/configure.h.in
index 6d904f2..c1d1218 100644
--- a/lib/misc/configure.h.in
+++ b/lib/misc/configure.h.in
@@ -44,10 +44,16 @@
/* Define default name mangling behaviour */
#undef DEFAULT_DM_NAME_MANGLING
+/* Default DM run directory. */
+#undef DEFAULT_DM_RUN_DIR
+
/* Name of default locking directory. */
#undef DEFAULT_LOCK_DIR
-/* Name of default run directory. */
+/* Default directory to keep PID files in. */
+#undef DEFAULT_PID_DIR
+
+/* Default LVM run directory. */
#undef DEFAULT_RUN_DIR
/* Define to 0 to reinstate the pre-2.02.54 handling of unit suffixes. */
@@ -455,6 +461,9 @@
/* Define to 1 to include built-in support for LVM1 metadata. */
#undef LVM1_INTERNAL
+/* Path to lvmetad pidfile. */
+#undef LVMETAD_PIDFILE
+
/* Define to 1 to include code that uses lvmetad. */
#undef LVMETAD_SUPPORT
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index be012d6..53c85f5 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -75,7 +75,9 @@ install_tmpfiles_configuration:
$(INSTALL_DIR) $(tmpfiles_dir)
$(INSTALL_DATA) lvm2_tmpfiles_red_hat.conf $(tmpfiles_dir)/lvm2.conf
-DISTCLEAN_TARGETS += clvmd_init_red_hat cmirrord_init_red_hat lvm2_monitoring_init_red_hat \
- dm_event_systemd_red_hat.service lvm2_monitoring_systemd_red_hat.service \
+DISTCLEAN_TARGETS += clvmd_init_red_hat cmirrord_init_red_hat \
+ lvm2_monitoring_init_red_hat lvm2_lvmetad_init_red_hat \
+ dm_event_systemd_red_hat.socket dm_event_systemd_red_hat.service \
+ lvm2_monitoring_systemd_red_hat.service \
lvm2_lvmetad_systemd_red_hat.socket lvm2_lvmetad_systemd_red_hat.service \
- lvm2_lvmetad_init_red_hat lvm2_tmpfiles_red_hat.conf
+ lvm2_tmpfiles_red_hat.conf
diff --git a/scripts/dm_event_systemd_red_hat.socket b/scripts/dm_event_systemd_red_hat.socket
deleted file mode 100644
index bfc8ea1..0000000
--- a/scripts/dm_event_systemd_red_hat.socket
+++ /dev/null
@@ -1,12 +0,0 @@
-[Unit]
-Description=Device-mapper event daemon FIFOs
-Documentation=man:dmeventd(8)
-DefaultDependencies=no
-
-[Socket]
-ListenFIFO=/var/run/dmeventd-server
-ListenFIFO=/var/run/dmeventd-client
-SocketMode=0600
-
-[Install]
-WantedBy=sockets.target
diff --git a/scripts/dm_event_systemd_red_hat.socket.in b/scripts/dm_event_systemd_red_hat.socket.in
new file mode 100644
index 0000000..c6c480c
--- /dev/null
+++ b/scripts/dm_event_systemd_red_hat.socket.in
@@ -0,0 +1,11 @@
+[Unit]
+Description=Device-mapper event daemon FIFOs
+DefaultDependencies=no
+
+[Socket]
+ListenFIFO=@DEFAULT_DM_RUN_DIR@/dmeventd-server
+ListenFIFO=@DEFAULT_DM_RUN_DIR@/dmeventd-client
+SocketMode=0600
+
+[Install]
+WantedBy=sockets.target
diff --git a/scripts/lvm2_lvmetad_init_red_hat.in b/scripts/lvm2_lvmetad_init_red_hat.in
index 886944e..888c730 100644
--- a/scripts/lvm2_lvmetad_init_red_hat.in
+++ b/scripts/lvm2_lvmetad_init_red_hat.in
@@ -41,7 +41,7 @@ sbindir=@sbindir@
lvm_pvscan="${sbindir}/lvm pvscan --cache"
LOCK_FILE="/var/lock/subsys/$DAEMON"
-PID_FILE="@DEFAULT_RUN_DIR(a)/${DAEMON}.pid"
+PID_FILE="@LVMETAD_PIDFILE@"
rh_status() {
diff --git a/scripts/lvm2_lvmetad_systemd_red_hat.service.in b/scripts/lvm2_lvmetad_systemd_red_hat.service.in
index 7552240..e527369 100644
--- a/scripts/lvm2_lvmetad_systemd_red_hat.service.in
+++ b/scripts/lvm2_lvmetad_systemd_red_hat.service.in
@@ -14,7 +14,7 @@ ExecStartPost=@sbindir@/lvm pvscan --cache
ExecReload=@sbindir@/lvmetad -R
Environment=SD_ACTIVATION=1
Restart=on-abort
-PIDFile=@DEFAULT_RUN_DIR(a)/lvmetad.pid
+PIDFile=@LVMETAD_PIDFILE@
[Install]
WantedBy=sysinit.target
10 years, 7 months