Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c95f17ea64e3faee…
Commit: c95f17ea64e3faee3d36be95544c907b5e89c073
Parent: b15278c3dca14d7ee09a2ebcca4b91cbdf8428af
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Wed Aug 7 17:42:26 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Aug 7 17:42:26 2013 -0500
Mirror: Fix issue preventing PV creation on mirror LVs
Commit b248ba0a396d7fc9a459eea02cfdc70b33ce3441 attempted to
prevent mirror devices which had a failed device in their
mirrored log from being usable/readable by LVM. This was to
protect against circular dependancies where one LVM command
could be blocked trying to read one of these affected mirrors
while the LVM command to fix/unblock that mirror was stuck
behind the currently running command.
The above commit went wrong when it used 'device_is_usable()' to
recurse on the mirrored log device to check if it was suspended
or blocked. The 'device_is_usable' function also contains a check
for reserved names - like *_mlog, etc. This last check always
triggered when checking a mirror's log simply because of the name,
not because it was suspended or blocked - a false positive.
The solution is to create a new function like 'device_is_usable',
but without the check for reserved names. Using this new function
(device_is_suspended_or_blocked), we can check the status of a
mirror's log device properly.
---
lib/activate/activate.h | 10 +++++++++-
lib/activate/dev_manager.c | 34 +++++++++++++++++++++++++++++++---
2 files changed, 40 insertions(+), 4 deletions(-)
diff --git a/lib/activate/activate.h b/lib/activate/activate.h
index 80733fe..f34d376 100644
--- a/lib/activate/activate.h
+++ b/lib/activate/activate.h
@@ -167,11 +167,19 @@ int pv_uses_vg(struct physical_volume *pv,
struct volume_group *vg);
/*
- * Returns 1 if mapped device is not suspended.
+ * Returns 1 if mapped device is not suspended, blocked or
+ * is using a reserved name.
*/
int device_is_usable(struct device *dev);
/*
+ * Returns 1 if the device is suspended or blocking.
+ * (Does not perform check on the LV name of the device.)
+ * N.B. This is !device_is_usable() without the name check.
+ */
+int device_is_suspended_or_blocking(struct device *dev);
+
+/*
* Declaration moved here from fs.h to keep header fs.h hidden
*/
void fs_unlock(void);
diff --git a/lib/activate/dev_manager.c b/lib/activate/dev_manager.c
index 6a68653..294606c 100644
--- a/lib/activate/dev_manager.c
+++ b/lib/activate/dev_manager.c
@@ -275,7 +275,7 @@ static int _ignore_blocked_mirror_devices(struct device *dev,
goto_out;
tmp_dev->dev = log_dev;
- if (!device_is_usable(tmp_dev))
+ if (device_is_suspended_or_blocking(tmp_dev))
goto_out;
}
}
@@ -329,7 +329,24 @@ out:
return r;
}
-int device_is_usable(struct device *dev)
+/*
+ * _device_is_usable
+ * @dev
+ * @check_lv_names
+ *
+ * A device is considered not usable if it is:
+ * 1) An empty device (no targets)
+ * 2) A blocked mirror (i.e. a mirror with a failure and block_on_error set)
+ * 3) ignore_suspended_devices is set and
+ * a) the device is suspended
+ * b) it is a snapshot origin
+ * 4) an error target
+ * And optionally, if 'check_lv_names' is set
+ * 5) the LV name is a reserved name.
+ *
+ * Returns: 1 if usable, 0 otherwise
+ */
+static int _device_is_usable(struct device *dev, int check_lv_names)
{
struct dm_task *dmt;
struct dm_info info;
@@ -416,7 +433,8 @@ int device_is_usable(struct device *dev)
/* FIXME Also check dependencies? */
/* Check internal lvm devices */
- if (uuid && !strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1)) {
+ if (check_lv_names &&
+ uuid && !strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1)) {
if (!(vgname = dm_strdup(name)) ||
!dm_split_lvm_name(NULL, NULL, &vgname, &lvname, &layer))
goto_out;
@@ -436,6 +454,16 @@ int device_is_usable(struct device *dev)
return r;
}
+int device_is_usable(struct device *dev)
+{
+ return _device_is_usable(dev, 1);
+}
+
+int device_is_suspended_or_blocking(struct device *dev)
+{
+ return !_device_is_usable(dev, 0);
+}
+
static int _info(const char *dlid, int with_open_count, int with_read_ahead,
struct dm_info *info, uint32_t *read_ahead)
{
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b15278c3dca14d7e…
Commit: b15278c3dca14d7ee09a2ebcca4b91cbdf8428af
Parent: ea4c0ea34f4c4cba53f4426dbbff39bee475a2f5
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Wed Aug 7 16:01:45 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Wed Aug 7 16:01:45 2013 -0500
Mirror/RAID1: When up|down-converting default to segtype of current LV
If there is no RAID support in the kernel but the default mirror
segtype is "raid1", converting legacy mirrors can be problematic.
For example, changing the log type or converting a mirror to a linear
LV does not require the RAID modules to be present. However, because
lp->segtype is set to be RAID1 by the configuration file, the command
fails.
We should only be setting lp->segtype when converting mirrors if it is
going to change (e.g. to linear or between mirror types).
---
WHATS_NEW | 1 +
tools/lvconvert.c | 14 ++++++++++----
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 3590e64..4515be7 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.100 -
================================
+ When converting mirrors, default segtype should be the same unless specified.
Make "raid1" the default mirror segment type.
Fix clogd descriptor leak when daemonizing.
Fix clvmd descriptor leak on restart.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 5d796e7..6a243c3 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -518,10 +518,16 @@ static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
if (!get_stripe_params(cmd, &lp->stripes, &lp->stripe_size))
return_0;
- lp->segtype = get_segtype_from_string(cmd, arg_str_value(cmd, type_ARG,
- find_config_tree_str(cmd, global_mirror_segtype_default_CFG, NULL)));
- if (!lp->segtype)
- return_0;
+ if (arg_count(cmd, mirrors_ARG) && !lp->mirrors) {
+ /* down-converting to linear/stripe? */
+ if (!(lp->segtype =
+ get_segtype_from_string(cmd, "striped")))
+ return_0;
+ } else if (arg_count(cmd, type_ARG)) {
+ /* changing mirror type? */
+ if (!(lp->segtype = get_segtype_from_string(cmd, arg_str_value(cmd, type_ARG, find_config_tree_str(cmd, global_mirror_segtype_default_CFG, NULL)))))
+ return_0;
+ } /* else segtype will default to current type */
}
/* TODO: default in lvm.conf ? */
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c13d1b11b2eb30c2…
Commit: c13d1b11b2eb30c215a4233d6f641d0d1c62114b
Parent: 7e1083c985fd130b240c2471643350cc5c0f05cf
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Tue Aug 6 14:15:08 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Tue Aug 6 14:15:08 2013 -0500
RAID: Make "raid10" the default striped + mirror segment type
When both the '-i' and '-m' arguments are specified on the command
line, use the "raid10" segment type. This way, the native RAID10
personality is used through dm-raid rather than layering a mirror
on striped LVs. If the old behavior is desired, the '--type'
argument to use would be "mirror" rather than "raid10".
---
conf/example.conf.in | 2 +-
lib/config/defaults.h | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index c3ba2b9..78c69e5 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -529,7 +529,7 @@ global {
# this setting is not advised.
# Specify the '--type <raid10|mirror>' option to override this default
# setting.
- raid10_segtype_default = "mirror"
+ raid10_segtype_default = "raid10"
# The default format for displaying LV names in lvdisplay was changed
# in version 2.02.89 to show the LV name and path separately.
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 59282c5..5a456cf 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -56,7 +56,7 @@
#define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
#define DEFAULT_MIRROR_IMAGE_FAULT_POLICY "remove"
#define DEFAULT_MIRROR_MAX_IMAGES 8 /* limited by kernel DM_KCOPYD_MAX_REGIONS */
-#define DEFAULT_RAID10_SEGTYPE "mirror"
+#define DEFAULT_RAID10_SEGTYPE "raid10"
#define DEFAULT_RAID_FAULT_POLICY "warn"
#define DEFAULT_DMEVENTD_RAID_LIB "libdevmapper-event-lvm2raid.so"
#define DEFAULT_DMEVENTD_MIRROR_LIB "libdevmapper-event-lvm2mirror.so"
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7e1083c985fd130b…
Commit: 7e1083c985fd130b240c2471643350cc5c0f05cf
Parent: f74e8fe04471a44fe1ab0645e48c9cb06ef6fb4f
Author: Jonathan Brassow <jbrassow(a)redhat.com>
AuthorDate: Tue Aug 6 14:13:55 2013 -0500
Committer: Jonathan Brassow <jbrassow(a)redhat.com>
CommitterDate: Tue Aug 6 14:13:55 2013 -0500
RAID: Make "raid1" the default mirror segment type
---
WHATS_NEW | 1 +
conf/example.conf.in | 2 +-
lib/config/defaults.h | 2 +-
man/lvconvert.8.in | 7 ++++++-
man/lvcreate.8.in | 17 ++++++++++++-----
5 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index fd7e39f..3590e64 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.100 -
================================
+ Make "raid1" the default mirror segment type.
Fix clogd descriptor leak when daemonizing.
Fix clvmd descriptor leak on restart.
Add pipe_open/close() to replace less secure popen() glibc call.
diff --git a/conf/example.conf.in b/conf/example.conf.in
index 0e313c8..c3ba2b9 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -512,7 +512,7 @@ global {
#
# Specify the '--type <mirror|raid1>' option to override this default
# setting.
- mirror_segtype_default = "mirror"
+ mirror_segtype_default = "raid1"
# 'raid10_segtype_default' determines the segment types used by default
# when the '--stripes/-i' and '--mirrors/-m' arguments are both specified
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 5af0f00..59282c5 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -51,7 +51,7 @@
#define DEFAULT_METADATA_READ_ONLY 0
#define DEFAULT_LVDISPLAY_SHOWS_FULL_DEVICE_PATH 0
-#define DEFAULT_MIRROR_SEGTYPE "mirror"
+#define DEFAULT_MIRROR_SEGTYPE "raid1"
#define DEFAULT_MIRRORLOG "disk"
#define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
#define DEFAULT_MIRROR_IMAGE_FAULT_POLICY "remove"
diff --git a/man/lvconvert.8.in b/man/lvconvert.8.in
index d4faf27..0fe5ab3 100644
--- a/man/lvconvert.8.in
+++ b/man/lvconvert.8.in
@@ -141,7 +141,12 @@ Run the daemon in the background.
Specifies the degree of the mirror you wish to create.
For example, "\fB-m 1\fP" would convert the original logical
volume to a mirror volume with 2-sides; that is, a
-linear volume plus one copy.
+linear volume plus one copy. There are two implementations of mirroring
+which correspond to the "raid1" and "mirror" segment types. The default
+mirroring segment type is "raid1". If the legacy "mirror" segment type
+is desired, the \fB\-\-type\fP argument must be used to explicitly
+select the desired type. The \fB\-\-mirrorlog\fP and \fB\-\-corelog\fP
+options below are only relevant to the legacy "mirror" segment type.
.TP
.IR \fB\-\-mirrorlog " {" disk | core | mirrored }
Specifies the type of log to use.
diff --git a/man/lvcreate.8.in b/man/lvcreate.8.in
index 681ff68..4a29720 100644
--- a/man/lvcreate.8.in
+++ b/man/lvcreate.8.in
@@ -232,16 +232,23 @@ afterwards will be mirrored, but the original contents will not be
copied. This is useful for skipping a potentially long and resource
intensive initial sync of an empty device.
-The optional argument \fB\-\-mirrorlog\fP specifies the type of log to be used.
+There are two implementations of mirroring which can be used and correspond
+to the "raid1" and "mirror" segment types. The default is "raid1". See the
+\fB\-\-type\fP option for more information if you would like to use the
+legacy "mirror" segment type. The \fB\-\-mirrorlog\fP and \fB\-\-corelog\fP
+options apply to the "mirror" segment type only.
+
+The optional argument \fB\-\-mirrorlog\fP specifies the type of log to be
+used for logical volumes utilizing the legacy "mirror" segment type.
The default is \fIdisk\fP, which is persistent and requires
a small amount of storage space, usually on a separate device from the
data being mirrored. Using \fIcore\fP means the mirror is regenerated
-by copying the data from the first device again each time the
-device is activated, for example, after every reboot. Using \fImirrored\fP
+by copying the data from the first device each time the logical
+volume is activated, like after every reboot. Using \fImirrored\fP
will create a persistent log that is itself mirrored.
-The optional argument \fB\-\-corelog\fP is equivalent
-to \fB\-\-mirrorlog\fP \fIcore\fP.
+When the legacy "mirror" segment type is used, the optional argument
+\fB\-\-corelog\fP is equivalent to \fB\-\-mirrorlog\fP \fIcore\fP.
.TP
.IR \fB\-M ", " \fB\-\-persistent " {" y | n }
Set to \fIy\fP to make the minor number specified persistent.