summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Kozina <okozina@redhat.com>2016-03-10 11:54:27 +0100
committerOndrej Kozina <okozina@redhat.com>2016-03-10 12:21:11 +0100
commit33437c2939f23c9fb7720b6d6198ea1bccab2295 (patch)
tree7f83c2225ad7ff179c6929342ce31ae77b5d7dd2
parent215421e0dab58b139fc47bf9010e1083f25db712 (diff)
downloadlvm2-33437c2939f23c9fb7720b6d6198ea1bccab2295.tar.gz
lvmpolld: implement simple list-all-active request
protocol version bump included
-rw-r--r--daemons/lvmpolld/lvmpolld-core.c34
-rw-r--r--daemons/lvmpolld/lvmpolld-data-utils.c23
-rw-r--r--daemons/lvmpolld/lvmpolld-data-utils.h2
-rw-r--r--daemons/lvmpolld/lvmpolld-protocol.h3
4 files changed, 61 insertions, 1 deletions
diff --git a/daemons/lvmpolld/lvmpolld-core.c b/daemons/lvmpolld/lvmpolld-core.c
index c6f02a4de..530fa53cc 100644
--- a/daemons/lvmpolld/lvmpolld-core.c
+++ b/daemons/lvmpolld/lvmpolld-core.c
@@ -798,6 +798,38 @@ static response dump_state(client_handle h, struct lvmpolld_state *ls, request r
return res;
}
+static response list_active(client_handle h, struct lvmpolld_state *ls, request req)
+{
+ response res = { 0 };
+ const char *sysdir = daemon_request_str(req, LVMPD_PARM_SYSDIR, NULL);
+ struct buffer *b = &res.buffer;
+
+ buffer_init(b);
+
+ /* lvid, vg/lv_name, type, cmd */
+
+ _lvmpolld_global_lock(ls);
+
+ if (sysdir) {
+ buffer_append(b, "# Listing for LVM_SYSTEM_DIR=");
+ buffer_append(b, sysdir);
+ buffer_append(b, "\n");
+ }
+
+ buffer_append(b, "# Active polling operations\n\n");
+ buffer_append(b, "poll {\n");
+ pdst_locked_list_active(ls->id_to_pdlv_poll, b, sysdir);
+ buffer_append(b, "}\n\n");
+
+ buffer_append(b, "# Active abort operations\n\n");
+ buffer_append(b, "abort {\n");
+ pdst_locked_list_active(ls->id_to_pdlv_abort, b, sysdir);
+ buffer_append(b, "}");
+ _lvmpolld_global_unlock(ls);
+
+ return res;
+}
+
static response _handler(struct daemon_state s, client_handle h, request r)
{
struct lvmpolld_state *ls = s.private;
@@ -815,6 +847,8 @@ static response _handler(struct daemon_state s, client_handle h, request r)
return progress_info(h, ls, r);
else if (!strcmp(rq, LVMPD_REQ_DUMP))
return dump_state(h, ls, r);
+ else if (!strcmp(rq, LVMPD_REQ_LIST_ACTIVE))
+ return list_active(h, ls, r);
else
return reply(LVMPD_RESP_EINVAL, REASON_REQ_NOT_IMPLEMENTED);
}
diff --git a/daemons/lvmpolld/lvmpolld-data-utils.c b/daemons/lvmpolld/lvmpolld-data-utils.c
index 57f06aa7f..d1599f4eb 100644
--- a/daemons/lvmpolld/lvmpolld-data-utils.c
+++ b/daemons/lvmpolld/lvmpolld-data-utils.c
@@ -308,6 +308,29 @@ void pdst_locked_dump(const struct lvmpolld_store *pdst, struct buffer *buff)
_pdlv_locked_dump(buff, dm_hash_get_data(pdst->store, n));
}
+void pdst_locked_list_active(const struct lvmpolld_store *pdst,
+ struct buffer *buff, const char *sysdir)
+{
+ const struct lvmpolld_lv *pdlv;
+ struct dm_hash_node *n;
+
+ dm_hash_iterate(n, pdst->store) {
+ pdlv = dm_hash_get_data(pdst->store, n);
+
+ /* match sysdir component of lvmpolld_if */
+ if (sysdir && strncmp(pdlv->lvmpolld_id, sysdir, strlen(sysdir)))
+ continue;
+ if (!sysdir && *pdlv->lvm_system_dir_env)
+ continue;
+
+ /* list active only */
+ if (pdlv->polling_finished || pdlv->error)
+ continue;
+
+ _pdlv_locked_dump(buff, pdlv);
+ }
+}
+
void pdst_locked_send_cancel(const struct lvmpolld_store *pdst)
{
struct lvmpolld_lv *pdlv;
diff --git a/daemons/lvmpolld/lvmpolld-data-utils.h b/daemons/lvmpolld/lvmpolld-data-utils.h
index 215886516..90522b328 100644
--- a/daemons/lvmpolld/lvmpolld-data-utils.h
+++ b/daemons/lvmpolld/lvmpolld-data-utils.h
@@ -173,6 +173,8 @@ void pdst_locked_lock_all_pdlvs(const struct lvmpolld_store *pdst);
void pdst_locked_unlock_all_pdlvs(const struct lvmpolld_store *pdst);
void pdst_locked_destroy_all_pdlvs(const struct lvmpolld_store *pdst);
void pdst_locked_send_cancel(const struct lvmpolld_store *pdst);
+void pdst_locked_list_active(const struct lvmpolld_store *pdst,
+ struct buffer *buff, const char *sysdir);
static inline void pdst_lock(struct lvmpolld_store *pdst)
{
diff --git a/daemons/lvmpolld/lvmpolld-protocol.h b/daemons/lvmpolld/lvmpolld-protocol.h
index 4e6ae9e41..95853902c 100644
--- a/daemons/lvmpolld/lvmpolld-protocol.h
+++ b/daemons/lvmpolld/lvmpolld-protocol.h
@@ -18,10 +18,11 @@
#include "polling_ops.h"
#define LVMPOLLD_PROTOCOL "lvmpolld"
-#define LVMPOLLD_PROTOCOL_VERSION 1
+#define LVMPOLLD_PROTOCOL_VERSION 2
#define LVMPD_REQ_CONVERT CONVERT_POLL
#define LVMPD_REQ_DUMP "dump"
+#define LVMPD_REQ_LIST_ACTIVE "list_active"
#define LVMPD_REQ_MERGE MERGE_POLL
#define LVMPD_REQ_MERGE_THIN MERGE_THIN_POLL
#define LVMPD_REQ_PROGRESS "progress_info"