From a927e401f13c846afb1b2824b54a709dae8930cc Mon Sep 17 00:00:00 2001 From: Jonathan Earl Brassow Date: Thu, 1 Dec 2011 00:09:34 +0000 Subject: [PATCH] Do not allow users to change the name of RAID sub-LVs or the name of the RAID LV if it is tracking changes for a split image. --- WHATS_NEW | 2 ++ lib/metadata/metadata-exported.h | 1 + lib/metadata/raid_manip.c | 16 ++++++++++++++++ tools/lvrename.c | 15 +++++++++++++++ 4 files changed, 34 insertions(+) diff --git a/WHATS_NEW b/WHATS_NEW index f0c988227..9c1f36413 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,7 @@ Version 2.02.89 - ================================== + Don't allow name change of RAID LV while tracking a split image. + Do not allow users to change the name of RAID sub-LVs Do not allow users to change permissions on RAID sub-LVs Support the ability to replace specific devices in a RAID array via lvconvert. Add activation/use_linear_target enabled by default. diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index f3cf55eaf..f516f3d0e 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -780,6 +780,7 @@ struct logical_volume *first_replicator_dev(const struct logical_volume *lv); /* -- metadata/replicator_manip.c */ /* ++ metadata/raid_manip.c */ +int lv_is_raid_with_tracking(const struct logical_volume *lv); uint32_t lv_raid_image_count(const struct logical_volume *lv); int lv_raid_change_image_count(struct logical_volume *lv, uint32_t new_count, struct dm_list *pvs); diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c index 864faf193..57611e101 100644 --- a/lib/metadata/raid_manip.c +++ b/lib/metadata/raid_manip.c @@ -26,6 +26,22 @@ #define RAID_REGION_SIZE 1024 +int lv_is_raid_with_tracking(const struct logical_volume *lv) +{ + uint32_t s; + struct lv_segment *seg; + + if (lv->status & RAID) { + seg = first_seg(lv); + + for (s = 0; s < seg->area_count; s++) + if (lv_is_visible(seg_lv(seg, s)) && + !(seg_lv(seg, s)->status & LVM_WRITE)) + return 1; + } + return 0; +} + uint32_t lv_raid_image_count(const struct logical_volume *lv) { struct lv_segment *seg = first_seg(lv); diff --git a/tools/lvrename.c b/tools/lvrename.c index 782f32b4f..ef67682d7 100644 --- a/tools/lvrename.c +++ b/tools/lvrename.c @@ -115,6 +115,21 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv) goto error; } + if (lvl->lv->status & (RAID_IMAGE | RAID_META)) { + log_error("Cannot rename a RAID %s directly", + (lvl->lv->status & RAID_IMAGE) ? "image" : + "metadata area"); + r = ECMD_FAILED; + goto error; + } + + if (lv_is_raid_with_tracking(lvl->lv)) { + log_error("Cannot rename %s while it is tracking a split image", + lvl->lv->name); + r = ECMD_FAILED; + goto error; + } + if (!lv_rename(cmd, lvl->lv, lv_name_new)) goto error; -- 2.43.5