dev-prajnoha-pv-ext-flag-used - metadata: add_pv_to_vg: add 'new_pv' arg to state if the PV is about to be created
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7fcc36bf94943a...
Commit: 7fcc36bf94943ab9b5dc5b295c925d790f1fb081
Parent: a0d8be98af3a4fb6fdb18e7d78bb955d00ef6586
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Mar 12 14:37:50 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Aug 21 11:15:53 2015 +0200
metadata: add_pv_to_vg: add 'new_pv' arg to state if the PV is about to be created
---
lib/metadata/metadata.c | 11 +++++++----
lib/metadata/metadata.h | 3 ++-
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 058c312..4efd47a 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -177,7 +177,8 @@ void del_pvl_from_vgs(struct volume_group *vg, struct pv_list *pvl)
* FIXME: remove pv_name - obtain safely from pv
*/
int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
- struct physical_volume *pv, struct pvcreate_params *pp)
+ struct physical_volume *pv, struct pvcreate_params *pp,
+ int new_pv)
{
struct pv_to_write *pvw;
struct pv_list *pvl;
@@ -280,7 +281,7 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
return 0;
}
pvw->pv = pv;
- pvw->pp = pp;
+ pvw->pp = new_pv ? pp : NULL;
dm_list_add(&vg->pvs_to_write, &pvw->list);
}
@@ -676,6 +677,7 @@ static int vg_extend_single_pv(struct volume_group *vg, char *pv_name,
unsigned int *max_phys_block_size)
{
struct physical_volume *pv;
+ int new_pv = 0;
pv = find_pv_by_name(vg->cmd, pv_name, 1, 1);
@@ -686,13 +688,14 @@ static int vg_extend_single_pv(struct volume_group *vg, char *pv_name,
} else if (!pv && pp) {
if (!(pv = pvcreate_vol(vg->cmd, pv_name, pp, 0)))
return_0;
+ new_pv = 1;
}
if (!(check_dev_block_size_for_vg(pv->dev, (const struct volume_group *) vg,
max_phys_block_size)))
goto_bad;
- if (!add_pv_to_vg(vg, pv_name, pv, pp))
+ if (!add_pv_to_vg(vg, pv_name, pv, pp, new_pv))
goto_bad;
return 1;
@@ -1573,7 +1576,7 @@ void pvcreate_params_set_defaults(struct pvcreate_params *pp)
static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_write *pvw)
{
- int zero = pvw->pp->zero;
+ int zero = pvw->pp ? pvw->pp->zero : 1;
struct physical_volume *pv = pvw->pv;
struct device *dev = pv->dev;
const char *pv_name = dev_name(dev);
diff --git a/lib/metadata/metadata.h b/lib/metadata/metadata.h
index 1a5306b..15f9c77 100644
--- a/lib/metadata/metadata.h
+++ b/lib/metadata/metadata.h
@@ -497,7 +497,8 @@ const struct format_type *pv_format_type(const struct physical_volume *pv);
struct id pv_vgid(const struct physical_volume *pv);
int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
- struct physical_volume *pv, struct pvcreate_params *pp);
+ struct physical_volume *pv, struct pvcreate_params *pp,
+ int new_pv);
uint64_t find_min_mda_size(struct dm_list *mdas);
char *tags_format_and_copy(struct dm_pool *mem, const struct dm_list *tagsl);
8 years, 9 months
dev-prajnoha-pv-ext-flag-used - pv: format-text: store PV_EXT_USED flag if PV is used and unset it otherwise
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a0d8be98af3a4f...
Commit: a0d8be98af3a4fb6fdb18e7d78bb955d00ef6586
Parent: 7c39bd6743bda43216f53e7b300a73bddd40bd4d
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Tue Mar 10 10:47:47 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Aug 21 11:15:53 2015 +0200
pv: format-text: store PV_EXT_USED flag if PV is used and unset it otherwise
When adding a PV to VG, set the PV_EXT_USED flag in PV header and
vice versa - if the PV is no longer in a VG, unset the flag.
---
lib/format_text/format-text.c | 14 ++++++++++++++
lib/metadata/metadata-exported.h | 3 +++
2 files changed, 17 insertions(+), 0 deletions(-)
diff --git a/lib/format_text/format-text.c b/lib/format_text/format-text.c
index 4544f26..3d8329f 100644
--- a/lib/format_text/format-text.c
+++ b/lib/format_text/format-text.c
@@ -1319,6 +1319,18 @@ static int _write_single_mda(struct metadata_area *mda, void *baton)
return 1;
}
+static void _set_ext_flags(struct physical_volume *pv, struct lvmcache_info *info)
+{
+ uint32_t ext_flags = lvmcache_ext_flags(info);
+
+ if (is_orphan_vg(pv->vg_name))
+ ext_flags &= ~PV_EXT_USED;
+ else
+ ext_flags |= PV_EXT_USED;
+
+ lvmcache_set_ext_flags(info, ext_flags);
+}
+
/* Only for orphans - FIXME That's not true any more */
static int _text_pv_write(const struct format_type *fmt, struct physical_volume *pv)
{
@@ -1401,6 +1413,8 @@ static int _text_pv_write(const struct format_type *fmt, struct physical_volume
if (!lvmcache_foreach_mda(info, _write_single_mda, &baton))
return_0;
+ _set_ext_flags(pv, info);
+
if (!label_write(pv->dev, label)) {
stack;
if (!dev_close(pv->dev))
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index fff24f0..a30a73f 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -40,6 +40,9 @@
/* Layer suffix */
#define MIRROR_SYNC_LAYER "_mimagetmp"
+/* PV extension flags */
+#define PV_EXT_USED UINT32_C(0x00000001)
+
/* Various flags */
/* Note that the bits no longer necessarily correspond to LVM1 disk format */
8 years, 9 months
dev-prajnoha-pv-ext-flag-used - lvmcache/lvmetad: cache PV extension flags
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7c39bd6743bda4...
Commit: 7c39bd6743bda43216f53e7b300a73bddd40bd4d
Parent: 9c278cc106c7f5d2ae94caaa23e168200808724b
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Mar 9 12:52:07 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Aug 21 11:15:53 2015 +0200
lvmcache/lvmetad: cache PV extension flags
Store PV extension flags in lvmcache/lvmetad for use throughout the code.
---
lib/cache/lvmcache.c | 9 +++++++++
lib/cache/lvmcache.h | 3 +++
lib/cache/lvmetad.c | 5 +++++
lib/format_text/text_label.c | 5 ++++-
4 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/lib/cache/lvmcache.c b/lib/cache/lvmcache.c
index cfa1d5f..b7261cf 100644
--- a/lib/cache/lvmcache.c
+++ b/lib/cache/lvmcache.c
@@ -42,6 +42,7 @@ struct lvmcache_info {
const struct format_type *fmt;
struct device *dev;
uint64_t device_size; /* Bytes */
+ uint32_t ext_flags; /* Extension flags */
uint32_t status;
};
@@ -2278,6 +2279,14 @@ struct device *lvmcache_device(struct lvmcache_info *info) {
return info->dev;
}
+void lvmcache_set_ext_flags(struct lvmcache_info *info, uint32_t flags) {
+ info->ext_flags = flags;
+}
+
+uint32_t lvmcache_ext_flags(struct lvmcache_info *info) {
+ return info->ext_flags;
+}
+
int lvmcache_is_orphan(struct lvmcache_info *info) {
if (!info->vginfo)
return 1; /* FIXME? */
diff --git a/lib/cache/lvmcache.h b/lib/cache/lvmcache.h
index 76b9b10..471530c 100644
--- a/lib/cache/lvmcache.h
+++ b/lib/cache/lvmcache.h
@@ -149,6 +149,9 @@ int lvmcache_add_mda(struct lvmcache_info *info, struct device *dev,
int lvmcache_add_da(struct lvmcache_info *info, uint64_t start, uint64_t size);
int lvmcache_add_ba(struct lvmcache_info *info, uint64_t start, uint64_t size);
+void lvmcache_set_ext_flags(struct lvmcache_info *info, uint32_t flags);
+uint32_t lvmcache_ext_flags(struct lvmcache_info *info);
+
const struct format_type *lvmcache_fmt(struct lvmcache_info *info);
struct label *lvmcache_get_label(struct lvmcache_info *info);
diff --git a/lib/cache/lvmetad.c b/lib/cache/lvmetad.c
index 856b30f..b07ba50 100644
--- a/lib/cache/lvmetad.c
+++ b/lib/cache/lvmetad.c
@@ -295,6 +295,7 @@ static int _pv_populate_lvmcache(struct cmd_context *cmd,
dev_t devt = dm_config_find_int(cn->child, "device", 0);
uint64_t devsize = dm_config_find_int64(cn->child, "dev_size", 0),
label_sector = dm_config_find_int64(cn->child, "label_sector", 0);
+ uint32_t ext_flags = (uint32_t) dm_config_find_int64(cn->child, "ext_flags", 0);
if (!fmt && fmt_name)
fmt = get_format_by_name(cmd, fmt_name);
@@ -400,6 +401,9 @@ static int _pv_populate_lvmcache(struct cmd_context *cmd,
}
lvmcache_set_preferred_duplicates((const char *)&vgid);
+
+ lvmcache_set_ext_flags(info, ext_flags);
+
return 1;
}
@@ -911,6 +915,7 @@ int lvmetad_pv_found(const struct id *pvid, struct device *dev, const struct for
"format = %s", fmt->name,
"label_sector = %"PRId64, (int64_t) label_sector,
"id = %s", uuid,
+ "ext_flags = %"PRId64, (int64_t) lvmcache_ext_flags(info),
NULL))
{
dm_config_destroy(pvmeta);
diff --git a/lib/format_text/text_label.c b/lib/format_text/text_label.c
index 4ad2ccd..1bdff02 100644
--- a/lib/format_text/text_label.c
+++ b/lib/format_text/text_label.c
@@ -124,7 +124,7 @@ static int _text_write(struct label *label, void *buf)
*/
pvhdr_ext = (struct pv_header_extension *) ((char *) baton.pvh_dlocn_xl);
pvhdr_ext->version = xlate32(PV_HEADER_EXTENSION_VSN);
- pvhdr_ext->flags = 0; /* no flags yet */
+ pvhdr_ext->flags = xlate32(lvmcache_ext_flags(info));
/* List of bootloader area locations */
baton.pvh_dlocn_xl = &pvhdr_ext->bootloader_areas_xl[0];
@@ -421,6 +421,9 @@ static int _text_read(struct labeller *l, struct device *dev, void *buf,
log_debug_metadata("%s: PV header extension version %" PRIu32 " found",
dev_name(dev), ext_version);
+ /* Extension flags */
+ lvmcache_set_ext_flags(info, xlate32(pvhdr_ext->flags));
+
/* Bootloader areas */
dlocn_xl = pvhdr_ext->bootloader_areas_xl;
while ((offset = xlate64(dlocn_xl->offset))) {
8 years, 9 months
dev-prajnoha-pv-ext-flag-used - refactor: rename struct pv_to_create --> struct pv_to_write
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=9c278cc106c7f5...
Commit: 9c278cc106c7f5d2ae94caaa23e168200808724b
Parent: 1fae121b222927584a7a88cd3f4f1ba2aadb4931
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Mar 9 12:29:30 2015 +0100
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Aug 21 11:15:52 2015 +0200
refactor: rename struct pv_to_create --> struct pv_to_write
We'll use this struct in subsequent patches for PVs which should
be rewritten, not just created. So rename struct pv_to_create to
struct pv_to_write for clarity.
---
lib/metadata/metadata.c | 32 ++++++++++++++++----------------
lib/metadata/vg.c | 2 +-
lib/metadata/vg.h | 4 ++--
3 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index 8757331..058c312 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -179,7 +179,7 @@ void del_pvl_from_vgs(struct volume_group *vg, struct pv_list *pvl)
int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
struct physical_volume *pv, struct pvcreate_params *pp)
{
- struct pv_to_create *pvc;
+ struct pv_to_write *pvw;
struct pv_list *pvl;
struct format_instance *fid = vg->fid;
struct dm_pool *mem = vg->vgmem;
@@ -275,13 +275,13 @@ int add_pv_to_vg(struct volume_group *vg, const char *pv_name,
}
if (pv->status & UNLABELLED_PV) {
- if (!(pvc = dm_pool_zalloc(mem, sizeof(*pvc)))) {
- log_error("pv_to_create allocation for '%s' failed", pv_name);
+ if (!(pvw = dm_pool_zalloc(mem, sizeof(*pvw)))) {
+ log_error("pv_to_write allocation for '%s' failed", pv_name);
return 0;
}
- pvc->pv = pv;
- pvc->pp = pp;
- dm_list_add(&vg->pvs_to_create, &pvc->list);
+ pvw->pv = pv;
+ pvw->pp = pp;
+ dm_list_add(&vg->pvs_to_write, &pvw->list);
}
return 1;
@@ -1571,10 +1571,10 @@ void pvcreate_params_set_defaults(struct pvcreate_params *pp)
}
-static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_create *pvc)
+static int _pvcreate_write(struct cmd_context *cmd, struct pv_to_write *pvw)
{
- int zero = pvc->pp->zero;
- struct physical_volume *pv = pvc->pv;
+ int zero = pvw->pp->zero;
+ struct physical_volume *pv = pvw->pv;
struct device *dev = pv->dev;
const char *pv_name = dev_name(dev);
@@ -1725,10 +1725,10 @@ struct physical_volume *pvcreate_vol(struct cmd_context *cmd, const char *pv_nam
pv->status |= UNLABELLED_PV;
if (write_now) {
- struct pv_to_create pvc;
- pvc.pp = pp;
- pvc.pv = pv;
- if (!_pvcreate_write(cmd, &pvc))
+ struct pv_to_write pvw;
+ pvw.pp = pp;
+ pvw.pv = pv;
+ if (!_pvcreate_write(cmd, &pvw))
goto bad;
}
@@ -3010,7 +3010,7 @@ out:
int vg_write(struct volume_group *vg)
{
struct dm_list *mdah;
- struct pv_to_create *pv_to_create;
+ struct pv_to_write *pv_to_write;
struct metadata_area *mda;
struct lv_list *lvl;
int revert = 0, wrote = 0;
@@ -3066,8 +3066,8 @@ int vg_write(struct volume_group *vg)
memlock_unlock(vg->cmd);
vg->seqno++;
- dm_list_iterate_items(pv_to_create, &vg->pvs_to_create) {
- if (!_pvcreate_write(vg->cmd, pv_to_create))
+ dm_list_iterate_items(pv_to_write, &vg->pvs_to_write) {
+ if (!_pvcreate_write(vg->cmd, pv_to_write))
return 0;
}
diff --git a/lib/metadata/vg.c b/lib/metadata/vg.c
index ca2bf96..ebbaf90 100644
--- a/lib/metadata/vg.c
+++ b/lib/metadata/vg.c
@@ -60,7 +60,7 @@ struct volume_group *alloc_vg(const char *pool_name, struct cmd_context *cmd,
}
dm_list_init(&vg->pvs);
- dm_list_init(&vg->pvs_to_create);
+ dm_list_init(&vg->pvs_to_write);
dm_list_init(&vg->pvs_outdated);
dm_list_init(&vg->lvs);
dm_list_init(&vg->tags);
diff --git a/lib/metadata/vg.h b/lib/metadata/vg.h
index a21af8b..46cf169 100644
--- a/lib/metadata/vg.h
+++ b/lib/metadata/vg.h
@@ -32,7 +32,7 @@ typedef enum {
ALLOC_INHERIT
} alloc_policy_t;
-struct pv_to_create {
+struct pv_to_write {
struct dm_list list;
struct physical_volume *pv;
struct pvcreate_params *pp;
@@ -90,7 +90,7 @@ struct volume_group {
* a PV label yet. They need to be pvcreate'd at vg_write time.
*/
- struct dm_list pvs_to_create;
+ struct dm_list pvs_to_write;
/*
* List of physical volumes that carry outdated metadata that belongs
8 years, 9 months
dev-prajnoha-pv-ext-flag-used - lvmlockd: fix sending debug info to lvmlockctl
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1fae121b222927...
Commit: 1fae121b222927584a7a88cd3f4f1ba2aadb4931
Parent: 180f92d3dc9891d4536a69de25dcb285979cd9e4
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Aug 20 14:00:12 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Aug 20 14:07:11 2015 -0500
lvmlockd: fix sending debug info to lvmlockctl
Single messages sent over unix sockets are limited in
size to /proc/sys/net/core/wmem_max, so send the 1MB
debug buffer in smaller chunks to avoid EMSGSIZE.
Also look for EAGAIN and retry sending for a limited
time when the reader is slower than the writer.
Also shift the location of that code so it's the same
as other requests.
---
daemons/lvmlockd/lvmlockctl.c | 9 +++-
daemons/lvmlockd/lvmlockd-core.c | 114 ++++++++++++++++++++++++++------------
2 files changed, 86 insertions(+), 37 deletions(-)
diff --git a/daemons/lvmlockd/lvmlockctl.c b/daemons/lvmlockd/lvmlockctl.c
index e2ad9c5..14be4fc 100644
--- a/daemons/lvmlockd/lvmlockctl.c
+++ b/daemons/lvmlockd/lvmlockctl.c
@@ -379,6 +379,7 @@ static int setup_dump_socket(void)
rv = bind(s, (struct sockaddr *) &dump_addr, dump_addrlen);
if (rv < 0) {
+ rv = -errno;
if (!close(s))
log_error("failed to close dump socket");
return rv;
@@ -392,6 +393,7 @@ static int do_dump(const char *req_name)
daemon_reply reply;
int result;
int fd, rv = 0;
+ int count = 0;
fd = setup_dump_socket();
if (fd < 0) {
@@ -422,13 +424,18 @@ static int do_dump(const char *req_name)
memset(dump_buf, 0, sizeof(dump_buf));
- rv = recvfrom(fd, dump_buf, dump_len, MSG_WAITALL,
+retry:
+ rv = recvfrom(fd, dump_buf + count, dump_len - count, MSG_WAITALL,
(struct sockaddr *)&dump_addr, &dump_addrlen);
if (rv < 0) {
log_error("recvfrom error %d %d", rv, errno);
rv = -errno;
goto out;
}
+ count += rv;
+
+ if (count < dump_len)
+ goto retry;
rv = 0;
if ((info && dump) || !strcmp(req_name, "dump"))
diff --git a/daemons/lvmlockd/lvmlockd-core.c b/daemons/lvmlockd/lvmlockd-core.c
index 666f340..b99cb0b 100644
--- a/daemons/lvmlockd/lvmlockd-core.c
+++ b/daemons/lvmlockd/lvmlockd-core.c
@@ -265,6 +265,10 @@ static int alloc_new_structs; /* used for initializing in setup_structs */
static int add_lock_action(struct action *act);
static int str_to_lm(const char *str);
static int clear_lockspace_inactive(char *name);
+static int setup_dump_socket(void);
+static void send_dump_buf(int fd, int dump_len);
+static int dump_info(int *dump_len);
+static int dump_log(int *dump_len);
static int _syslog_name_to_num(const char *name)
{
@@ -739,6 +743,10 @@ static const char *op_str(int x)
return "kill_vg";
case LD_OP_DROP_VG:
return "drop_vg";
+ case LD_OP_DUMP_LOG:
+ return "dump_log";
+ case LD_OP_DUMP_INFO:
+ return "dump_info";
default:
return "op_unknown";
};
@@ -3414,6 +3422,8 @@ static void client_send_result(struct client *cl, struct action *act)
{
response res;
char result_flags[128];
+ int dump_len = 0;
+ int dump_fd = -1;
if (cl->dead) {
log_debug("client send %d skip dead", cl->id);
@@ -3498,6 +3508,33 @@ static void client_send_result(struct client *cl, struct action *act)
"lv_lock_args = %s", lv_args,
"result_flags = %s", result_flags[0] ? result_flags : "none",
NULL);
+
+ } else if (act->op == LD_OP_DUMP_LOG || act->op == LD_OP_DUMP_INFO) {
+ /*
+ * lvmlockctl creates the unix socket then asks us to write to it.
+ * FIXME: move processing this to a new dedicated query thread to
+ * avoid having a large data dump interfere with normal operation
+ * of the client thread?
+ */
+
+ dump_fd = setup_dump_socket();
+ if (dump_fd < 0)
+ act->result = dump_fd;
+ else if (act->op == LD_OP_DUMP_LOG)
+ act->result = dump_log(&dump_len);
+ else if (act->op == LD_OP_DUMP_INFO)
+ act->result = dump_info(&dump_len);
+ else
+ act->result = -EINVAL;
+
+ log_debug("send %s[%d.%u] dump result %d dump_len %d",
+ cl->name[0] ? cl->name : "client", cl->pid, cl->id,
+ act->result, dump_len);
+
+ res = daemon_reply_simple("OK",
+ "result = %d", act->result,
+ "dump_len = %d", dump_len,
+ NULL);
} else {
/*
* A normal reply.
@@ -3521,6 +3558,12 @@ static void client_send_result(struct client *cl, struct action *act)
buffer_destroy(&res.buffer);
client_resume(cl);
+
+ if (dump_fd >= 0) {
+ /* To avoid deadlock, send data here after the reply. */
+ send_dump_buf(dump_fd, dump_len);
+ close(dump_fd);
+ }
}
/* called from client_thread */
@@ -3894,23 +3937,43 @@ static int setup_dump_socket(void)
return s;
}
-static int send_dump_buf(int fd, int dump_len)
+#define MAX_SEND_LEN 65536
+#define RESEND_DELAY_US 1000
+#define RESEND_DELAY_US_MAX 500000
+
+static void send_dump_buf(int fd, int dump_len)
{
int pos = 0;
int ret;
+ int send_len;
+ int delay = 0;
-retry:
- ret = sendto(fd, dump_buf + pos, dump_len - pos, MSG_DONTWAIT | MSG_NOSIGNAL,
+ if (!dump_len)
+ return;
+repeat:
+ if (dump_len - pos < MAX_SEND_LEN)
+ send_len = dump_len - pos;
+ else
+ send_len = MAX_SEND_LEN;
+
+ ret = sendto(fd, dump_buf + pos, send_len, MSG_NOSIGNAL | MSG_DONTWAIT,
(struct sockaddr *)&dump_addr, dump_addrlen);
- if (ret <= 0)
- return ret;
+ if (ret < 0) {
+ if ((errno == EAGAIN || errno == EINTR) && (delay < RESEND_DELAY_US_MAX)) {
+ usleep(RESEND_DELAY_US);
+ delay += RESEND_DELAY_US;
+ goto repeat;
+ }
+ log_error("send_dump_buf delay %d errno %d", delay, errno);
+ return;
+ }
pos += ret;
if (pos < dump_len)
- goto retry;
+ goto repeat;
- return 0;
+ log_debug("send_dump_buf delay %d total %d", delay, pos);
}
static int print_structs(const char *prefix, int pos, int len)
@@ -4193,8 +4256,7 @@ static void client_recv_action(struct client *cl)
return;
}
- if (op == LD_OP_HELLO || op == LD_OP_QUIT ||
- op == LD_OP_DUMP_INFO || op == LD_OP_DUMP_LOG) {
+ if (op == LD_OP_HELLO || op == LD_OP_QUIT) {
/*
* FIXME: add the client command name to the hello messages
@@ -4215,37 +4277,11 @@ static void client_recv_action(struct client *cl)
buffer_init(&res.buffer);
- if (op == LD_OP_DUMP_INFO || op == LD_OP_DUMP_LOG) {
- int dump_len = 0;
- int fd;
-
- fd = setup_dump_socket();
- if (fd < 0)
- result = fd;
- else if (op == LD_OP_DUMP_INFO)
- result = dump_info(&dump_len);
- else if (op == LD_OP_DUMP_LOG)
- result = dump_log(&dump_len);
- else
- result = -EINVAL;
-
- res = daemon_reply_simple("OK",
- "result = %d", result,
- "dump_len = %d", dump_len,
- NULL);
- if (fd >= 0) {
- send_dump_buf(fd, dump_len);
- close(fd);
- }
-
- } else {
- res = daemon_reply_simple("OK",
+ res = daemon_reply_simple("OK",
"result = %d", result,
"protocol = %s", lvmlockd_protocol,
"version = %d", lvmlockd_protocol_version,
NULL);
- }
-
buffer_write(cl->fd, &res.buffer);
buffer_destroy(&res.buffer);
dm_config_destroy(req.cft);
@@ -4362,6 +4398,12 @@ static void client_recv_action(struct client *cl)
case LD_OP_STOP:
rv = rem_lockspace(act);
break;
+ case LD_OP_DUMP_LOG:
+ case LD_OP_DUMP_INFO:
+ /* The client thread reply will copy and send the dump. */
+ add_client_result(act);
+ rv = 0;
+ break;
case LD_OP_INIT:
case LD_OP_START_WAIT:
case LD_OP_STOP_ALL:
8 years, 9 months
dev-prajnoha-pv-ext-flag-used - WHATS_NEW: Update.
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=180f92d3dc9891...
Commit: 180f92d3dc9891d4536a69de25dcb285979cd9e4
Parent: 5476ee865597e7f2fcc189412aaaccdc15cc3db9
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Tue Aug 18 17:38:57 2015 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu Aug 20 19:06:47 2015 +0200
WHATS_NEW: Update.
---
WHATS_NEW | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 25cea03..3916acc 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,7 @@
Version 2.02.129 -
===================================
+ Fix debug buffer overflows in cmirrord logging.
+ Add --foreground and --help to cmirrord.
Version 2.02.128 - 17th August 2015
===================================
8 years, 9 months
dev-prajnoha-pv-ext-flag-used - cmirrord: avoid resync buffer overflow in LOG_SPRINT
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=5476ee865597e7...
Commit: 5476ee865597e7f2fcc189412aaaccdc15cc3db9
Parent: 3c396cf1e1efd179c37ddd71a144deab4b9b806c
Author: Ferenc Wágner <wferi(a)niif.hu>
AuthorDate: Wed Jul 8 14:41:27 2015 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu Aug 20 19:06:47 2015 +0200
cmirrord: avoid resync buffer overflow in LOG_SPRINT
Use snprintf() instead of sprintf() to exclude the possibility of
overflowing the resync history buffers.
---
daemons/cmirrord/functions.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/daemons/cmirrord/functions.c b/daemons/cmirrord/functions.c
index f6e0918..61b3e11 100644
--- a/daemons/cmirrord/functions.c
+++ b/daemons/cmirrord/functions.c
@@ -32,12 +32,13 @@
#define LOG_OFFSET 2
#define RESYNC_HISTORY 50
+#define RESYNC_BUFLEN 128
//static char resync_history[RESYNC_HISTORY][128];
//static int idx = 0;
#define LOG_SPRINT(_lc, f, arg...) do { \
lc->idx++; \
lc->idx = lc->idx % RESYNC_HISTORY; \
- sprintf(lc->resync_history[lc->idx], f, ## arg); \
+ snprintf(lc->resync_history[lc->idx], RESYNC_BUFLEN, f, ## arg); \
} while (0)
struct log_header {
@@ -88,7 +89,7 @@ struct log_c {
size_t disk_size; /* size of disk_buffer in bytes */
void *disk_buffer; /* aligned memory for O_DIRECT */
int idx;
- char resync_history[RESYNC_HISTORY][128];
+ char resync_history[RESYNC_HISTORY][RESYNC_BUFLEN];
};
struct mark_entry {
8 years, 9 months
dev-prajnoha-pv-ext-flag-used - cmirrord: avoid debugging buffer overflow in LOG_SPRINT
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=3c396cf1e1efd1...
Commit: 3c396cf1e1efd179c37ddd71a144deab4b9b806c
Parent: 1ea1cb6dc972868d89ff17cb03f65ce3088009b3
Author: Ferenc Wágner <wferi(a)niif.hu>
AuthorDate: Wed Jul 8 14:41:26 2015 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu Aug 20 19:06:47 2015 +0200
cmirrord: avoid debugging buffer overflow in LOG_SPRINT
Use snprintf() instead of sprintf() to exclude the possibility of
overflowing the debugging history buffers.
---
daemons/cmirrord/cluster.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/daemons/cmirrord/cluster.c b/daemons/cmirrord/cluster.c
index 4a4bdab..2850d9b 100644
--- a/daemons/cmirrord/cluster.c
+++ b/daemons/cmirrord/cluster.c
@@ -104,10 +104,11 @@ static SaVersionT version = { 'B', 1, 1 };
#endif
#define DEBUGGING_HISTORY 100
+#define DEBUGGING_BUFLEN 128
#define LOG_SPRINT(cc, f, arg...) do { \
cc->idx++; \
cc->idx = cc->idx % DEBUGGING_HISTORY; \
- sprintf(cc->debugging[cc->idx], f, ## arg); \
+ snprintf(cc->debugging[cc->idx], DEBUGGING_BUFLEN, f, ## arg); \
} while (0)
static int log_resp_rec = 0;
@@ -150,7 +151,7 @@ struct clog_cpg {
uint32_t checkpoint_requesters[MAX_CHECKPOINT_REQUESTERS];
struct checkpoint_data *checkpoint_list;
int idx;
- char debugging[DEBUGGING_HISTORY][128];
+ char debugging[DEBUGGING_HISTORY][DEBUGGING_BUFLEN];
};
static struct dm_list clog_cpg_list;
8 years, 9 months
dev-prajnoha-pv-ext-flag-used - cmirrord: fix stack smashing
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1ea1cb6dc97286...
Commit: 1ea1cb6dc972868d89ff17cb03f65ce3088009b3
Parent: 8821cc416e8a295f47c49cad060727a69769eaf5
Author: Ferenc Wágner <wferi(a)niif.hu>
AuthorDate: Wed Jul 8 14:41:25 2015 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu Aug 20 19:06:47 2015 +0200
cmirrord: fix stack smashing
With clusters larger than 3 nodes, the 32-byte debug buffer in
cpg_join_callback() is too small to contain all the node IDs, because
32-bit identifiers are generally rendered in 10 decimal digits. No fixed
size is good in all cases, but this is conditionally logged debug info,
so we can simply truncate it. Double the size, nevertheless.
---
daemons/cmirrord/cluster.c | 18 ++++++++++++++----
1 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/daemons/cmirrord/cluster.c b/daemons/cmirrord/cluster.c
index 3fd5d23..4a4bdab 100644
--- a/daemons/cmirrord/cluster.c
+++ b/daemons/cmirrord/cluster.c
@@ -1294,7 +1294,9 @@ static void cpg_join_callback(struct clog_cpg *match,
uint32_t my_pid = (uint32_t)getpid();
uint32_t lowest = match->lowest_id;
struct clog_request *rq;
- char dbuf[32] = { 0 };
+ char dbuf[64] = { 0 };
+ char *dbuf_p = dbuf;
+ size_t dbuf_rem = sizeof dbuf;
/* Assign my_cluster_id */
if ((my_cluster_id == 0xDEAD) && (joined->pid == my_pid))
@@ -1310,9 +1312,17 @@ static void cpg_join_callback(struct clog_cpg *match,
if (joined->nodeid == my_cluster_id)
goto out;
- for (i = 0; i < member_list_entries - 1; i++)
- sprintf(dbuf+strlen(dbuf), "%u-", member_list[i].nodeid);
- sprintf(dbuf+strlen(dbuf), "(%u)", joined->nodeid);
+ for (i = 0; i < member_list_entries - 1; i++) {
+ int written = snprintf(dbuf_p, dbuf_rem, "%u-", member_list[i].nodeid);
+ if (written < 0) continue; /* impossible */
+ if ((unsigned)written >= dbuf_rem) {
+ dbuf_rem = 0;
+ break;
+ }
+ dbuf_rem -= written;
+ dbuf_p += written;
+ }
+ snprintf(dbuf_p, dbuf_rem, "(%u)", joined->nodeid);
LOG_COND(log_checkpoint, "[%s] Joining node, %u needs checkpoint [%s]",
SHORT_UUID(match->name.value), joined->nodeid, dbuf);
8 years, 9 months
dev-prajnoha-pv-ext-flag-used - cmirrord manual: add --foreground and --help options
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=8821cc416e8a29...
Commit: 8821cc416e8a295f47c49cad060727a69769eaf5
Parent: 92a4b5cc3c83e1ef24092b826722ffa0e90eb697
Author: Ferenc Wágner <wferi(a)niif.hu>
AuthorDate: Wed Jul 8 14:41:24 2015 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Thu Aug 20 19:06:47 2015 +0200
cmirrord manual: add --foreground and --help options
---
man/cmirrord.8.in | 8 +++++++-
1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/man/cmirrord.8.in b/man/cmirrord.8.in
index 8ef6794..383db65 100644
--- a/man/cmirrord.8.in
+++ b/man/cmirrord.8.in
@@ -3,7 +3,7 @@
cmirrord \(em cluster mirror log daemon
.SH SYNOPSIS
-.B cmirrord
+\fBcmirrord\fR [\fB\-f\fR] [\fB\-h\fR]
.SH DESCRIPTION
cmirrord is the daemon that tracks mirror log information in a cluster.
@@ -24,6 +24,12 @@ there are still active cluster mirrors, however, the signal will be
ignored. Active cluster mirrors should be shutdown before stopping the
cluster mirror log daemon.
+.SH OPTIONS
+.IP "\fB\-f\fR, \fB\-\-foreground\fR" 4
+Do not fork and log to the terminal.
+.IP "\fB\-h\fR, \fB\-\-help\fR" 4
+Print usage.
+
.SH SEE ALSO
.BR lvm (8)
.BR clvmd (8)
8 years, 9 months