diff --git a/lvm2-2_02_75-support-uuid-rename.patch b/lvm2-2_02_75-support-uuid-rename.patch new file mode 100644 index 0000000..5d4b47e --- /dev/null +++ b/lvm2-2_02_75-support-uuid-rename.patch @@ -0,0 +1,255 @@ +--- LVM2.2.02.73/libdm/ioctl/libdm-iface.c 2010-08-18 14:11:57.000000000 +0100 ++++ LVM2.2.02.73-new/libdm/ioctl/libdm-iface.c 2010-10-15 18:39:48.000000000 +0100 +@@ -826,6 +826,11 @@ static int _dm_task_run_v1(struct dm_tas + if (dmt->type == DM_DEVICE_TABLE) + dmi->flags |= DM_STATUS_TABLE_FLAG; + ++ if (dmt->new_uuid) { ++ log_error("Changing UUID is not supported by kernel."); ++ goto bad; ++ } ++ + log_debug("dm %s %s %s%s%s [%u]", _cmd_data_v1[dmt->type].name, + dmi->name, dmi->uuid, dmt->newname ? " " : "", + dmt->newname ? dmt->newname : "", +@@ -1185,6 +1190,22 @@ int dm_task_suppress_identical_reload(st + return 1; + } + ++int dm_task_set_newuuid(struct dm_task *dmt, const char *newuuid) ++{ ++ if (strlen(newuuid) >= DM_UUID_LEN) { ++ log_error("Uuid \"%s\" too long", newuuid); ++ return 0; ++ } ++ ++ if (!(dmt->newname = dm_strdup(newuuid))) { ++ log_error("dm_task_set_newuuid: strdup(%s) failed", newuuid); ++ return 0; ++ } ++ dmt->new_uuid = 1; ++ ++ return 1; ++} ++ + int dm_task_set_newname(struct dm_task *dmt, const char *newname) + { + if (strchr(newname, '/')) { +@@ -1201,6 +1222,7 @@ int dm_task_set_newname(struct dm_task * + log_error("dm_task_set_newname: strdup(%s) failed", newname); + return 0; + } ++ dmt->new_uuid = 0; + + return 1; + } +@@ -1399,7 +1421,7 @@ static struct dm_ioctl *_flatten(struct + } + + if (count && dmt->newname) { +- log_error("targets and newname are incompatible"); ++ log_error("targets and rename are incompatible"); + return NULL; + } + +@@ -1409,12 +1431,12 @@ static struct dm_ioctl *_flatten(struct + } + + if (dmt->newname && (dmt->sector || dmt->message)) { +- log_error("message and newname are incompatible"); ++ log_error("message and rename are incompatible"); + return NULL; + } + + if (dmt->newname && dmt->geometry) { +- log_error("geometry and newname are incompatible"); ++ log_error("geometry and rename are incompatible"); + return NULL; + } + +@@ -1514,6 +1536,14 @@ static struct dm_ioctl *_flatten(struct + "by kernel. It will use live table."); + dmi->flags |= DM_QUERY_INACTIVE_TABLE_FLAG; + } ++ if (dmt->new_uuid) { ++ if (_dm_version_minor < 19) { ++ log_error("WARNING: Setting UUID unsupported by " ++ "kernel. Aborting operation."); ++ goto bad; ++ } ++ dmi->flags |= DM_NEW_UUID_FLAG; ++ } + + dmi->target_count = count; + dmi->event_nr = dmt->event_nr; +@@ -1910,9 +1940,10 @@ static struct dm_ioctl *_do_dm_ioctl(str + } + } + +- log_debug("dm %s %s %s%s%s %s%.0d%s%.0d%s" ++ log_debug("dm %s %s%s %s%s%s %s%.0d%s%.0d%s" + "%s%c%c%s%s %.0" PRIu64 " %s [%u]", + _cmd_data_v4[dmt->type].name, ++ dmt->new_uuid ? "UUID " : "", + dmi->name, dmi->uuid, dmt->newname ? " " : "", + dmt->newname ? dmt->newname : "", + dmt->major > 0 ? "(" : "", +@@ -2044,7 +2075,7 @@ repeat_ioctl: + + case DM_DEVICE_RENAME: + /* FIXME Kernel needs to fill in dmi->name */ +- if (dmt->dev_name && !udev_only) ++ if (!dmt->new_uuid && dmt->dev_name && !udev_only) + rename_dev_node(dmt->dev_name, dmt->newname, + check_udev); + break; +--- LVM2.2.02.73/libdm/ioctl/libdm-targets.h 2009-11-06 00:43:09.000000000 +0000 ++++ LVM2.2.02.73-new/libdm/ioctl/libdm-targets.h 2010-10-15 18:39:48.000000000 +0100 +@@ -62,6 +62,7 @@ struct dm_task { + int suppress_identical_reload; + uint64_t existing_table_size; + int cookie_set; ++ int new_uuid; + + char *uuid; + }; +--- LVM2.2.02.73/libdm/libdevmapper.h 2010-07-21 14:40:22.000000000 +0100 ++++ LVM2.2.02.73-new/libdm/libdevmapper.h 2010-10-15 18:39:48.000000000 +0100 +@@ -167,6 +167,7 @@ struct dm_versions *dm_task_get_versions + + int dm_task_set_ro(struct dm_task *dmt); + int dm_task_set_newname(struct dm_task *dmt, const char *newname); ++int dm_task_set_newuuid(struct dm_task *dmt, const char *newuuid); + int dm_task_set_minor(struct dm_task *dmt, int minor); + int dm_task_set_major(struct dm_task *dmt, int major); + int dm_task_set_major_minor(struct dm_task *dmt, int major, int minor, int allow_default_major_fallback); +--- LVM2.2.02.73/libdm/libdm-common.c 2010-08-03 14:06:36.000000000 +0100 ++++ LVM2.2.02.73-new/libdm/libdm-common.c 2010-10-15 18:39:48.000000000 +0100 +@@ -194,6 +194,7 @@ struct dm_task *dm_task_create(int type) + dmt->event_nr = 0; + dmt->cookie_set = 0; + dmt->query_inactive_table = 0; ++ dmt->new_uuid = 0; + + return dmt; + } +--- LVM2.2.02.73/libdm/misc/dm-ioctl.h 2010-06-01 17:08:14.000000000 +0100 ++++ LVM2.2.02.73-new/libdm/misc/dm-ioctl.h 2010-10-15 18:39:48.000000000 +0100 +@@ -46,7 +46,7 @@ + * Remove a device, destroy any tables. + * + * DM_DEV_RENAME: +- * Rename a device. ++ * Rename a device or set its uuid if none was previously supplied. + * + * DM_SUSPEND: + * This performs both suspend and resume, depending which flag is +@@ -269,9 +269,9 @@ enum { + #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) + + #define DM_VERSION_MAJOR 4 +-#define DM_VERSION_MINOR 17 ++#define DM_VERSION_MINOR 19 + #define DM_VERSION_PATCHLEVEL 0 +-#define DM_VERSION_EXTRA "-ioctl (2010-03-05)" ++#define DM_VERSION_EXTRA "-ioctl (2010-10-14)" + + /* Status bits */ + #define DM_READONLY_FLAG (1 << 0) /* In/Out */ +@@ -324,4 +324,10 @@ enum { + */ + #define DM_UEVENT_GENERATED_FLAG (1 << 13) /* Out */ + ++/* ++ * If set, rename changes the uuid not the name. Only permitted ++ * if no uuid was previously supplied: an existing uuid cannot be changed. ++ */ ++#define DM_NEW_UUID_FLAG (1 << 14) /* In */ ++ + #endif /* _LINUX_DM_IOCTL_H */ +--- LVM2.2.02.73/man/dmsetup.8.in 2010-05-27 20:00:20.000000000 +0100 ++++ LVM2.2.02.73-new/man/dmsetup.8.in 2010-10-15 18:39:48.000000000 +0100 +@@ -33,6 +33,9 @@ dmsetup \- low level logical volume mana + .B dmsetup rename + .I device_name new_name + .br ++.B dmsetup rename ++.I device_name --setuuid uuid ++.br + .B dmsetup message + .I device_name sector message + .br +@@ -285,6 +288,11 @@ process to be killed. This also runs \f + .I device_name new_name + .br + Renames a device. ++.IP \fBrename ++.I device_name --setuuid uuid ++.br ++Sets the uuid of a device that was created without a uuid. ++After a uuid has been set it cannot be changed. + .IP \fBresume + .I device_name + .br +--- LVM2.2.02.73/tools/dmsetup.c 2010-08-03 14:04:32.000000000 +0100 ++++ LVM2.2.02.73-new/tools/dmsetup.c 2010-10-15 18:39:48.000000000 +0100 +@@ -140,6 +140,7 @@ enum { + READAHEAD_ARG, + ROWS_ARG, + SEPARATOR_ARG, ++ SETUUID_ARG, + SHOWKEYS_ARG, + SORT_ARG, + TABLE_ARG, +@@ -665,7 +666,10 @@ static int _rename(int argc, char **argv + if (!_set_task_device(dmt, (argc == 3) ? argv[1] : NULL, 0)) + goto out; + +- if (!dm_task_set_newname(dmt, argv[argc - 1])) ++ if (_switches[SETUUID_ARG]) { ++ if (!dm_task_set_newuuid(dmt, argv[argc - 1])) ++ goto out; ++ } else if (!dm_task_set_newname(dmt, argv[argc - 1])) + goto out; + + if (_switches[NOOPENCOUNT_ARG] && !dm_task_no_open_count(dmt)) +@@ -2701,7 +2705,7 @@ static struct command _commands[] = { + {"load", " []", 0, 2, _load}, + {"clear", "", 0, 1, _clear}, + {"reload", " []", 0, 2, _load}, +- {"rename", " ", 1, 2, _rename}, ++ {"rename", " [--setuuid] ", 1, 2, _rename}, + {"message", " ", 2, -1, _message}, + {"ls", "[--target ] [--exec ] [--tree [-o options]]", 0, 0, _ls}, + {"info", "[]", 0, 1, _info}, +@@ -3108,6 +3112,7 @@ static int _process_switches(int *argc, + {"readahead", 1, &ind, READAHEAD_ARG}, + {"rows", 0, &ind, ROWS_ARG}, + {"separator", 1, &ind, SEPARATOR_ARG}, ++ {"setuuid", 0, &ind, SETUUID_ARG}, + {"showkeys", 0, &ind, SHOWKEYS_ARG}, + {"sort", 1, &ind, SORT_ARG}, + {"table", 1, &ind, TABLE_ARG}, +@@ -3280,6 +3285,8 @@ static int _process_switches(int *argc, + } + if ((ind == ROWS_ARG)) + _switches[ROWS_ARG]++; ++ if ((ind == SETUUID_ARG)) ++ _switches[SETUUID_ARG]++; + if ((ind == SHOWKEYS_ARG)) + _switches[SHOWKEYS_ARG]++; + if ((ind == TABLE_ARG)) { +--- LVM2.2.02.73/WHATS_NEW_DM 2010-08-18 21:57:10.000000000 +0100 ++++ LVM2.2.02.73-new/WHATS_NEW_DM 2010-10-15 18:41:19.000000000 +0100 +@@ -1,3 +1,11 @@ ++Version 1.02.56 - ++===================================== ++ Add --setuuid to dmsetup rename. ++ Add dm_task_set_newuuid to set uuid of mapped device post-creation. ++ ++Version 1.02.55 - 24th September 2010 ++===================================== ++ + Version 1.02.54 - 18th August 2010 + ================================== + Fix dm-mod autoloading logic to not assume control node is set correctly. diff --git a/lvm2.spec b/lvm2.spec index 58fdad7..ec7136b 100644 --- a/lvm2.spec +++ b/lvm2.spec @@ -30,13 +30,14 @@ Summary: Userland logical volume management tools Name: lvm2 Version: 2.02.73 -Release: 2%{?dist}.1 +Release: 3%{?dist} License: GPLv2 Group: System Environment/Base URL: http://sources.redhat.com/lvm2 Source0: ftp://sources.redhat.com/pub/lvm2/LVM2.%{version}.tgz Patch0: lvm2-set-default-preferred_names.patch Patch1: lvm2-2_02_74-default-data-alignment.patch +Patch2: lvm2-2_02_75-support-uuid-rename.patch BuildRequires: libselinux-devel >= 1.30.19-4, libsepol-devel BuildRequires: ncurses-devel @@ -68,6 +69,7 @@ or more physical volumes and creating one or more logical volumes %setup -q -n LVM2.%{version} %patch0 -p1 -b preferred_names %patch1 -p1 -b data_alignment +%patch2 -p1 -b uuid_rename %build %define _exec_prefix "" @@ -466,6 +468,10 @@ the device-mapper event library. %changelog +* Fri Oct 15 2010 Alasdair Kergon - 2.02.73-3 +- Add --setuuid to dmsetup rename. +- Add dm_task_set_newuuid to set uuid of mapped device post-creation. + * Wed Sep 29 2010 jkeating - 2.02.73-2.1 - Rebuilt for gcc bug 634757