1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-09 01:18:39 +03:00

lvmpolld: implement simple list-all-active request

protocol version bump included
This commit is contained in:
Ondrej Kozina 2016-03-10 11:54:27 +01:00
parent 215421e0da
commit 33437c2939
4 changed files with 61 additions and 1 deletions

View File

@ -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);
}

View File

@ -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;

View File

@ -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)
{

View File

@ -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"