From b69ba36c2de059113d300f34d90bf50d9ba33908 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Thu, 11 May 2006 20:03:40 +0000 Subject: [PATCH] Add --nosync to lvcreate with LV flag NOTSYNCED. --- WHATS_NEW | 1 + lib/format_text/flags.c | 1 + lib/metadata/metadata.h | 5 +++-- tools/commands.h | 7 ++++--- tools/lvconvert.c | 4 ++++ tools/lvcreate.c | 17 ++++++++++++++++- tools/lvmcmdline.c | 2 ++ 7 files changed, 31 insertions(+), 6 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index 48984dc47..4913b9a87 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.06 - ================================= + Add --nosync to lvcreate with LV flag NOTSYNCED. Use mirror's uuid for a core log. Add mirror log fault-handling policy. Improve mirror warning messages and tidy dmeventd syslog output. diff --git a/lib/format_text/flags.c b/lib/format_text/flags.c index 82cbf06c9..8e42911a6 100644 --- a/lib/format_text/flags.c +++ b/lib/format_text/flags.c @@ -53,6 +53,7 @@ static struct flag _lv_flags[] = { {VISIBLE_LV, "VISIBLE"}, {PVMOVE, "PVMOVE"}, {LOCKED, "LOCKED"}, + {MIRROR_NOTSYNCED, "NOTSYNCED"}, {MIRROR_IMAGE, NULL}, {MIRROR_LOG, NULL}, {MIRRORED, NULL}, diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h index ade86c70c..95a5ae62c 100644 --- a/lib/metadata/metadata.h +++ b/lib/metadata/metadata.h @@ -58,8 +58,9 @@ #define VIRTUAL 0x00010000U /* LV - internal use only */ #define MIRROR_LOG 0x00020000U /* LV */ #define MIRROR_IMAGE 0x00040000U /* LV */ -#define ACTIVATE_EXCL 0x00080000U /* LV - internal use only */ -#define PRECOMMITTED 0x00100000U /* VG - internal use only */ +#define MIRROR_NOTSYNCED 0x00080000U /* LV */ +#define ACTIVATE_EXCL 0x00100000U /* LV - internal use only */ +#define PRECOMMITTED 0x00200000U /* VG - internal use only */ #define LVM_READ 0x00000100U /* LV VG */ #define LVM_WRITE 0x00000200U /* LV VG */ diff --git a/tools/commands.h b/tools/commands.h index f2724c51c..ac079ef9f 100644 --- a/tools/commands.h +++ b/tools/commands.h @@ -115,7 +115,7 @@ xx(lvcreate, "\t{-l|--extents LogicalExtentsNumber |\n" "\t -L|--size LogicalVolumeSize[kKmMgGtT]}\n" "\t[-M|--persistent {y|n}] [--major major] [--minor minor]\n" - "\t[-m|--mirrors Mirrors [--corelog]]\n" + "\t[-m|--mirrors Mirrors [--nosync] [--corelog]]\n" "\t[-n|--name LogicalVolumeName]\n" "\t[-p|--permission {r|rw}]\n" "\t[-r|--readahead ReadAheadSectors]\n" @@ -149,8 +149,9 @@ xx(lvcreate, addtag_ARG, alloc_ARG, autobackup_ARG, chunksize_ARG, contiguous_ARG, corelog_ARG, extents_ARG, major_ARG, minor_ARG, mirrors_ARG, name_ARG, - permission_ARG, persistent_ARG, readahead_ARG, regionsize_ARG, size_ARG, - snapshot_ARG, stripes_ARG, stripesize_ARG, test_ARG, type_ARG, zero_ARG) + nosync_ARG, permission_ARG, persistent_ARG, readahead_ARG, regionsize_ARG, + size_ARG, snapshot_ARG, stripes_ARG, stripesize_ARG, test_ARG, type_ARG, + zero_ARG) xx(lvdisplay, "Display information about a logical volume", diff --git a/tools/lvconvert.c b/tools/lvconvert.c index 963bf6f46..2a3a39aa8 100644 --- a/tools/lvconvert.c +++ b/tools/lvconvert.c @@ -308,6 +308,8 @@ static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * l if (sync_percent >= 100.0) init_mirror_in_sync(1); + else + init_mirror_in_sync(0); if (!(log_lv = create_mirror_log(cmd, lv->vg, ah, lp->alloc, lv->name, @@ -328,6 +330,8 @@ static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * l if (sync_percent >= 100.0) init_mirror_in_sync(1); + else + init_mirror_in_sync(0); if (!remove_mirror_images(seg, lp->mirrors, lp->pv_count ? diff --git a/tools/lvcreate.c b/tools/lvcreate.c index fdc74bc22..476ba4041 100644 --- a/tools/lvcreate.c +++ b/tools/lvcreate.c @@ -25,6 +25,7 @@ struct lvcreate_params { int major; int minor; int corelog; + int nosync; char *origin; const char *vg_name; @@ -293,6 +294,7 @@ static int _read_mirror_params(struct lvcreate_params *lp, } lp->corelog = arg_count(cmd, corelog_ARG) ? 1 : 0; + lp->nosync = arg_count(cmd, nosync_ARG) ? 1 : 0; return 1; } @@ -385,6 +387,11 @@ static int _lvcreate_params(struct lvcreate_params *lp, struct cmd_context *cmd, log_error("--corelog is only available with mirrors"); return 0; } + + if (arg_count(cmd, nosync_ARG)) { + log_error("--nosync is only available with mirrors"); + return 0; + } } if (activation() && lp->segtype->ops->target_present && @@ -653,8 +660,16 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp) lp->extents, lp->region_size); + init_mirror_in_sync(lp->nosync); + + if (lp->nosync) { + log_print("WARNING: New mirror won't be synchronised. " + "Don't read what you didn't write!"); + status |= MIRROR_NOTSYNCED; + } + if (!(log_lv = create_mirror_log(cmd, vg, ah, lp->alloc, - lv_name, 0))) { + lv_name, lp->nosync))) { log_error("Failed to create mirror log."); return 0; } diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index 39a2af9bd..8310db8bf 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -713,6 +713,8 @@ static int _get_settings(struct cmd_context *cmd) !_merge_synonym(cmd, allocation_ARG, resizeable_ARG)) return EINVALID_CMD_LINE; + init_mirror_in_sync(0); + /* Zero indicates success */ return 0; }