master - lvchange: reject writemostly/writebehind on raid1 during resync
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8ab072507706fb826eee05eb369429ad0a7a406a Commit: 8ab072507706fb826eee05eb369429ad0a7a406a Parent: 3f4ecaf8c2b3146e81bcb32bd4f0321beee1192a Author: Heinz Mauelshagen <[email protected]> AuthorDate: Thu Feb 23 15:09:29 2017 +0100 Committer: Heinz Mauelshagen <[email protected]> CommitterDate: Thu Feb 23 15:09:29 2017 +0100
lvchange: reject writemostly/writebehind on raid1 during resync
The MD kernel raid1 personality does no use any writemostly leg as the primary.
In case a previous linear LV holding data gets upconverted to raid1 it becomes the primary leg of the new raid1 LV and a full resynchronization is started to update the new legs.
No writemostly and/or writebehind setting may be allowed during this initial, full synchronization period of this new raid1 LV (using the lvchange(8) command), because that would change the primary (i.e the previous linear LV) thus causing data loss.
lvchange has a bug not preventing this scenario.
Fix rejects setting writemostly and/or writebehind on resychronizing raid1 LVs.
Once we have status in the lvm2 metadata about the linear -> raid upconversion, we may relax this constraint for other types of resynchronization (e.g. for user requested "lvchange --resync ").
New lvchange-raid1-writemostly.sh test is added to the test suite.
Resolves: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=855895
--- WHATS_NEW | 1 + lib/metadata/metadata-exported.h | 1 + lib/metadata/raid_manip.c | 8 +++++- test/shell/lvchange-raid1-writemostly.sh | 41 ++++++++++++++++++++++++++++++ tools/lvchange.c | 15 +++++++++++ 5 files changed, 65 insertions(+), 1 deletions(-)
WHATS_NEW +1 -0
@@ -1,5 +1,6 @@ Version 2.02.169 - ===================================== + Reject writemostly/writebehind in lvchange during resynchronization. Deactivate active origin first before removal for improved workflow. Fix regression of accepting options --type and -m with lvresize (2.02.158). Add lvconvert --swapmetadata, new specific way to swap pool metadata LVs.
lib/metadata/metadata-exported.h +1 -0
@@ -1232,6 +1232,7 @@ uint32_t raid_rimage_extents(const struct segment_type *segtype,uint32_t raid_ensure_min_region_size (const struct logical_volume *lv,uint64_t raid_size,uint32_t region_size);int lv_raid_change_region_size (struct logical_volume *lv,int yes,int force,uint32_t new_region_size); +int lv_raid_in_sync (const struct logical_volume *lv);/* -- metadata/raid_manip.c */ /* ++ metadata/cache_manip.c */
lib/metadata/raid_manip.c +7 -1
@@ -238,7 +238,7 @@ static int _deactivate_and_remove_lvs(struct volume_group *vg, struct dm_list *r* Returns: 1 if in-sync, 0 otherwise. */ #define _RAID_IN_SYNC_RETRIES 6 -static int _raid_in_sync (struct logical_volume *lv) +static int _raid_in_sync (const struct logical_volume *lv) {int retries = _RAID_IN_SYNC_RETRIES;dm_percent_t sync_percent;
@@ -269,6 +269,12 @@ static int _raid_in_sync(struct logical_volume *lv)return (sync_percent ==DM_PERCENT_100 ) ?1 :0 ; } +/* External interface to raid in-sync check */ +int lv_raid_in_sync (const struct logical_volume *lv) +{ +return _raid_in_sync (lv); +} +/* Check if RaidLV @lv is synced or any raid legs of @lv are not synced */ static int _raid_devs_sync_healthy (struct logical_volume *lv) {
test/shell/lvchange-raid1-writemostly.sh new file +41 -0
41 lines not on this page · raw message
tools/lvchange.c +15 -0
@@ -739,6 +739,21 @@ static int _lvchange_writemostly(struct logical_volume *lv)struct cmd_context *cmd = lv->vg->cmd;struct lv_segment *raid_seg =first_seg (lv); +/* +* Prohibit writebehind and writebehind during synchronization. +* +* FIXME: we can do better once we can distingush between +* an initial sync after a linear -> raid1 upconversion +* and any later additions of legs, requested resyncs +* via lvchange or leg repairs/replacements. +*/ +if (!lv_raid_in_sync (lv)) { +log_error ("Unable to change write%s on %s while it is not in-sync." , +arg_is_set (cmd, writemostly_ARG) ?"mostly" :"behind" , +display_lvname (lv)); +return 0 ; + } +if (arg_is_set (cmd, writebehind_ARG)) raid_seg->writebehind =arg_uint_value (cmd, writebehind_ARG,0 );