From: agk@sourceware.org <agk@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2 lib/metadata/metadata-exported.h lib/meta ...
Date: 22 Dec 2007 02:13:01 -0000 [thread overview]
Message-ID: <20071222021301.25123.qmail@sourceware.org> (raw)
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk at sourceware.org 2007-12-22 02:13:00
Modified files:
lib/metadata : metadata-exported.h mirror.c
lib/report : report.c
man : lvs.8
tools : lvconvert.c lvcreate.c toollib.c
Log message:
a few more changes/fixes to recent code
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.28&r2=1.29
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.49&r2=1.50
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.69&r2=1.70
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvs.8.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.164&r2=1.165
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.121&r2=1.122
--- LVM2/lib/metadata/metadata-exported.h 2007/12/20 22:37:42 1.28
+++ LVM2/lib/metadata/metadata-exported.h 2007/12/22 02:12:59 1.29
@@ -41,6 +41,9 @@
#define PV_MIN_SIZE ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */
#define MAX_RESTRICTED_LVS 255 /* Used by FMT_RESTRICTED_LVIDS */
+/* Layer suffix */
+#define MIRROR_SYNC_LAYER "_mimagetmp"
+
/* Various flags */
/* Note that the bits no longer necessarily correspond to LVM1 disk format */
--- LVM2/lib/metadata/mirror.c 2007/12/20 23:12:27 1.49
+++ LVM2/lib/metadata/mirror.c 2007/12/22 02:12:59 1.50
@@ -1030,7 +1030,8 @@
static struct logical_volume *_create_mirror_log(struct logical_volume *lv,
struct alloc_handle *ah,
alloc_policy_t alloc,
- const char *lv_name)
+ const char *lv_name,
+ const char *suffix)
{
struct logical_volume *log_lv;
char *log_name;
@@ -1042,7 +1043,7 @@
return NULL;
}
- if (dm_snprintf(log_name, len, "%s_mlog", lv->name) < 0) {
+ if (dm_snprintf(log_name, len, "%s%s", lv->name, suffix) < 0) {
log_error("log_name allocation failed.");
return NULL;
}
@@ -1075,7 +1076,9 @@
return NULL;
}
- if (!(log_lv = _create_mirror_log(lv, ah, alloc, lv->name))) {
+ if (!(log_lv = _create_mirror_log(lv, ah, alloc, lv->name,
+ strstr(lv->name, MIRROR_SYNC_LAYER)
+ ? "_mlogtmp_%d" : "_mlog"))) {
log_error("Failed to create mirror log.");
return NULL;
}
--- LVM2/lib/report/report.c 2007/12/20 16:49:37 1.69
+++ LVM2/lib/report/report.c 2007/12/22 02:12:59 1.70
@@ -272,6 +272,24 @@
return dm_report_field_uint64(rh, field, &_minusone);
}
+static int _lv_mimage_in_sync(struct logical_volume *lv)
+{
+ float percent;
+ struct lv_segment *seg = first_seg(lv);
+
+ if (!(lv->status & MIRROR_IMAGE) || !seg->mirror_seg)
+ return_0;
+
+ if (!lv_mirror_percent(lv->vg->cmd, seg->mirror_seg->lv, 0,
+ &percent, NULL))
+ return_0;
+
+ if (percent >= 100.0)
+ return 1;
+
+ return 0;
+}
+
static int _lvstatus_disp(struct dm_report *rh __attribute((unused)), struct dm_pool *mem,
struct dm_report_field *field,
const void *data, void *private __attribute((unused)))
@@ -294,7 +312,10 @@
else
repstr[0] = 'm';
}else if (lv->status & MIRROR_IMAGE)
- repstr[0] = 'i';
+ if (_lv_mimage_in_sync(lv))
+ repstr[0] = 'i';
+ else
+ repstr[0] = 'I';
else if (lv->status & MIRROR_LOG)
repstr[0] = 'l';
else if (lv->status & VIRTUAL)
--- LVM2/man/lvs.8 2007/03/27 13:35:33 1.6
+++ LVM2/man/lvs.8 2007/12/22 02:12:59 1.7
@@ -47,7 +47,7 @@
.RS
.IP 1 3
Volume type: (m)irrored, (M)irrored without initial sync, (o)rigin, (p)vmove, (s)napshot,
-invalid (S)napshot, (v)irtual
+invalid (S)napshot, (v)irtual, mirror (i)mage, mirror (I)mage out-of-sync
.IP 2 3
Permissions: (w)riteable, (r)ead-only
.IP 3 3
--- LVM2/tools/lvconvert.c 2007/12/21 01:08:18 1.50
+++ LVM2/tools/lvconvert.c 2007/12/22 02:13:00 1.51
@@ -227,6 +227,50 @@
return 1;
}
+static int _insert_lvconvert_layer(struct cmd_context *cmd,
+ struct logical_volume *lv)
+{
+ char *format, *layer_name;
+ size_t len;
+ int i;
+
+ /*
+ * We would like to give the same number for this layer
+ * and the newly added mimage.
+ * However, LV name of newly added mimage is determined *after*
+ * the LV name of this layer is determined.
+ *
+ * So, use generate_lv_name() to generate mimage name first
+ * and take the number from it.
+ */
+
+ len = strlen(lv->name) + 32;
+ if (!(format = alloca(len)) ||
+ !(layer_name = alloca(len)) ||
+ dm_snprintf(format, len, "%s_mimage_%%d", lv->name) < 0) {
+ log_error("lvconvert: layer name allocation failed.");
+ return 0;
+ }
+
+ if (!generate_lv_name(lv->vg, format, layer_name, len) ||
+ sscanf(layer_name, format, &i) != 1) {
+ log_error("lvconvert: layer name generation failed.");
+ return 0;
+ }
+
+ if (dm_snprintf(layer_name, len, MIRROR_SYNC_LAYER "_%d", i) < 0) {
+ log_error("layer name allocation failed.");
+ return 0;
+ }
+
+ if (!insert_layer_for_lv(cmd, lv, 0, layer_name)) {
+ log_error("Failed to insert resync layer");
+ return 0;
+ }
+
+ return 1;
+}
+
static int lvconvert_mirrors(struct cmd_context * cmd, struct logical_volume * lv,
struct lvconvert_params *lp)
{
@@ -376,9 +420,14 @@
return 1;
}
} else if (lp->mirrors > existing_mirrors) {
+ if (lv->status & MIRROR_NOTSYNCED) {
+ log_error("Not adding mirror to mirrored LV "
+ "without initial resync");
+ return 0;
+ }
/* FIXME: can't have multiple mlogs. force corelog. */
corelog = 1;
- if (!insert_layer_for_lv(cmd, lv, 0, "_resync%d")) {
+ if (!_insert_lvconvert_layer(cmd, lv)) {
log_error("Failed to insert resync layer");
return 0;
}
--- LVM2/tools/lvcreate.c 2007/12/20 15:42:55 1.164
+++ LVM2/tools/lvcreate.c 2007/12/22 02:13:00 1.165
@@ -525,7 +525,7 @@
uint32_t status = 0;
uint64_t tmp_size;
struct logical_volume *lv, *org = NULL;
- struct list *pvh, tags;
+ struct list *pvh;
const char *tag = NULL;
int origin_active = 0;
char lv_name_buf[128];
@@ -744,6 +744,16 @@
}
}
+ if (lp->mirrors > 1) {
+ init_mirror_in_sync(lp->nosync);
+
+ if (lp->nosync) {
+ log_warn("WARNING: New mirror won't be synchronised. "
+ "Don't read what you didn't write!");
+ status |= MIRROR_NOTSYNCED;
+ }
+ }
+
if (!(lv = lv_create_empty(lv_name ? lv_name : "lvol%d", NULL,
status, lp->alloc, 0, vg))) {
stack;
@@ -774,18 +784,6 @@
return_0;
if (lp->mirrors > 1) {
- init_mirror_in_sync(lp->nosync);
-
- if (lp->nosync) {
- log_warn("WARNING: New mirror won't be synchronised. "
- "Don't read what you didn't write!");
- status |= MIRROR_NOTSYNCED;
- }
-
- list_init(&tags);
- if (tag)
- str_list_add(cmd->mem, &tags, tag);
-
if (!lv_add_mirrors(cmd, lv, lp->mirrors - 1, lp->stripes,
adjusted_mirror_region_size(
vg->extent_size,
--- LVM2/tools/toollib.c 2007/12/20 22:37:42 1.121
+++ LVM2/tools/toollib.c 2007/12/22 02:13:00 1.122
@@ -1222,12 +1222,6 @@
return 0;
}
- if (strstr(name, "_resync")) {
- log_error("Names including \"_resync\" are reserved. "
- "Please choose a different LV name.");
- return 0;
- }
-
return 1;
}
next reply other threads:[~2007-12-22 2:13 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-22 2:13 agk [this message]
-- strict thread matches above, loose matches on Subject: below --
2011-02-21 12:29 LVM2 lib/metadata/metadata-exported.h lib/meta prajnoha
2010-10-12 16:41 mornfall
2010-06-30 20:03 agk
2010-06-30 18:03 wysochanski
2010-06-29 21:32 wysochanski
2010-06-28 20:40 wysochanski
2010-02-24 18:15 wysochanski
2010-02-24 18:15 wysochanski
2010-02-14 3:21 wysochanski
2010-02-14 3:21 wysochanski
2009-11-01 20:05 wysochanski
2009-11-01 19:51 wysochanski
2009-10-31 17:30 wysochanski
2009-10-05 20:03 wysochanski
2009-10-05 20:02 wysochanski
2009-10-01 1:04 agk
2009-09-14 15:45 wysochanski
2009-09-02 21:39 wysochanski
2009-09-02 21:39 wysochanski
2009-07-28 15:14 wysochanski
2009-07-28 13:17 wysochanski
2009-07-26 2:34 wysochanski
2009-07-26 1:53 wysochanski
2009-07-15 5:50 mornfall
2009-07-14 2:15 wysochanski
2009-07-10 20:07 wysochanski
2009-07-10 20:05 wysochanski
2009-07-09 10:09 wysochanski
2009-07-09 10:08 wysochanski
2009-07-09 10:07 wysochanski
2009-07-09 10:06 wysochanski
2009-07-09 10:04 wysochanski
2009-07-09 10:03 wysochanski
2009-07-08 14:33 wysochanski
2009-07-01 17:00 wysochanski
2008-06-24 20:10 wysochanski
2008-01-16 19:54 wysochanski
2008-01-15 22:56 wysochanski
2007-11-15 22:11 agk
2007-07-23 21:03 wysochanski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071222021301.25123.qmail@sourceware.org \
--to=agk@sourceware.org \
--cc=lvm-devel@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.