From 0e0a6eb6cfb0c724b0738c34521abdffeb634a98 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 18 Jan 2008 22:02:37 +0000 Subject: [PATCH] Fix lvcreate --nosync not to wait for non-happening sync. --- WHATS_NEW | 1 + lib/metadata/metadata-exported.h | 1 + lib/metadata/mirror.c | 9 ++++++--- tools/lvcreate.c | 3 ++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 67c30552f..fc31bb061 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.31 - =================================== + Fix lvcreate --nosync not to wait for non-happening sync. (2.02.30) Add very_verbose lvconvert messages. Avoid error message when using default setting of lvcreate -M1. (2.02.30) diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index b8a8fbee9..7c90be3c9 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -95,6 +95,7 @@ struct pv_segment; /* Mirror conversion type flags */ #define MIRROR_BY_SEG 0x00000001U /* segment-by-segment mirror */ #define MIRROR_BY_LV 0x00000002U /* mirror using whole mimage LVs */ +#define MIRROR_SKIP_INIT_SYNC 0x00000010U /* skip initial sync */ /* Ordered list - see lv_manip.c */ typedef enum { diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c index 4b299329a..1f068285b 100644 --- a/lib/metadata/mirror.c +++ b/lib/metadata/mirror.c @@ -1356,8 +1356,8 @@ int add_mirror_images(struct cmd_context *cmd, struct logical_volume *lv, * create and initialize mirror log */ if (log_count && - !(log_lv = _set_up_mirror_log(cmd, ah, lv, log_count, - region_size, alloc, 0))) + !(log_lv = _set_up_mirror_log(cmd, ah, lv, log_count, region_size, + alloc, mirror_in_sync()))) return_0; /* The log initialization involves vg metadata commit. @@ -1427,7 +1427,10 @@ int lv_add_mirrors(struct cmd_context *cmd, struct logical_volume *lv, * the global mirror_in_sync status. As we are adding * a new mirror, it should be set as 'out-of-sync' * so that the sync starts. */ - if (!log_count) + /* However, MIRROR_SKIP_INIT_SYNC even overrides it. */ + if (flags & MIRROR_SKIP_INIT_SYNC) + init_mirror_in_sync(1); + else if (!log_count) init_mirror_in_sync(0); if (flags & MIRROR_BY_SEG) { diff --git a/tools/lvcreate.c b/tools/lvcreate.c index 0c8a421a5..7b7b123cd 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -789,7 +789,8 @@ static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg, lv->le_count, lp->region_size), lp->corelog ? 0U : 1U, pvh, lp->alloc, - MIRROR_BY_LV)) { + MIRROR_BY_LV | + (lp->nosync ? MIRROR_SKIP_INIT_SYNC : 0))) { stack; goto revert_new_lv; }