]> sourceware.org Git - lvm2.git/commitdiff
dev_manager: add dev_manager_vdo_pool_status
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 29 Jun 2018 09:15:54 +0000 (11:15 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 9 Jul 2018 13:28:35 +0000 (15:28 +0200)
lib/activate/activate.c
lib/activate/activate.h
lib/activate/dev_manager.c
lib/activate/dev_manager.h

index 4facb7c03d34ff1172db549acc1d8c68c06b0c0f..0435139f2211645ec47e525b6c0ebf7fd08687d8 100644 (file)
@@ -1313,6 +1313,46 @@ int lv_thin_device_id(const struct logical_volume *lv, uint32_t *device_id)
        return r;
 }
 
+/*
+ * lv_vdo_pool_status  obtains  status information about VDO pool
+ *
+ * If the 'params' string has been already retrieved, use it.
+ * If the mempool already exists, use it.
+ *
+ */
+int lv_vdo_pool_status(const struct logical_volume *lv, int flush,
+                      struct lv_status_vdo **vdo_status)
+{
+       int r = 0;
+       struct dev_manager *dm;
+       struct lv_status_vdo *status;
+       char *params;
+
+       if (!lv_info(lv->vg->cmd, lv, 0, NULL, 0, 0))
+               return 0;
+
+       log_debug_activation("Checking VDO pool status for LV %s.",
+                            display_lvname(lv));
+
+       if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, !lv_is_pvmove(lv))))
+               return_0;
+
+       if (!dev_manager_vdo_pool_status(dm, lv, flush, &params, &status))
+               goto_out;
+
+       if (!parse_vdo_pool_status(status->mem, lv, params, status))
+               goto_out;
+
+       /* User is responsible to dm_pool_destroy memory pool! */
+       *vdo_status = status;
+       r = 1;
+out:
+       if (!r)
+               dev_manager_destroy(dm);
+
+       return r;
+}
+
 static int _lv_active(struct cmd_context *cmd, const struct logical_volume *lv)
 {
        struct lvinfo info;
index 6d70f64fabe528160768eb0411a86bae523d959c..cca25040c5abae87b8bfef27329f0c6d5898e1a7 100644 (file)
@@ -193,6 +193,8 @@ int lv_thin_percent(const struct logical_volume *lv, int mapped,
 int lv_thin_pool_transaction_id(const struct logical_volume *lv,
                                uint64_t *transaction_id);
 int lv_thin_device_id(const struct logical_volume *lv, uint32_t *device_id);
+int lv_vdo_pool_status(const struct logical_volume *lv, int flush,
+                      struct lv_status_vdo **status);
 
 /*
  * Return number of LVs in the VG that are active.
index 25d5e697261f687ea18d5f5d423fff96bee1735a..43dba8c169f3adfad51b38d44afdbfe2f352d66c 100644 (file)
@@ -1640,6 +1640,65 @@ out:
        return r;
 }
 
+int dev_manager_vdo_pool_status(struct dev_manager *dm,
+                               const struct logical_volume *lv,
+                               int flush,
+                               char **vdo_params,
+                               struct lv_status_vdo **vdo_status)
+{
+       struct lv_status_vdo *status;
+       const char *dlid;
+       struct dm_info info;
+       uint64_t start, length;
+       struct dm_task *dmt = NULL;
+       char *type = NULL;
+       char *params = NULL;
+       int r = 0;
+
+       *vdo_params = NULL;
+       *vdo_status = NULL;
+
+       if (!(status = dm_pool_zalloc(dm->mem, sizeof(struct lv_status_vdo)))) {
+               log_error("Cannot allocate VDO status structure.");
+               return 0;
+       }
+
+       if (!(dlid = build_dm_uuid(dm->mem, lv, lv_layer(lv))))
+               return_0;
+
+       if (!(dmt = _setup_task_run(DM_DEVICE_STATUS, &info, NULL, dlid, 0, 0, 0, 0, flush, 0)))
+               return_0;
+
+       if (!info.exists)
+               goto_out;
+
+       if (dm_get_next_target(dmt, NULL, &start, &length, &type, &params)) {
+               log_error("More then one table line found for %s.",
+                         display_lvname(lv));
+               goto out;
+       }
+
+       if (!type || strcmp(type, TARGET_NAME_VDO)) {
+               log_error("Expected %s segment type but got %s instead.",
+                         TARGET_NAME_VDO, type ? type : "NULL");
+               goto out;
+       }
+
+       if (!(*vdo_params = dm_pool_strdup(dm->mem, params))) {
+               log_error("Cannot duplicate VDO status params.");
+               goto out;
+       }
+
+       status->mem = dm->mem;
+       *vdo_status =  status;
+
+       r = 1;
+out:
+       dm_task_destroy(dmt);
+
+       return r;
+}
+
 
 /*************************/
 /*  NEW CODE STARTS HERE */
index 809fd048c0dccf2892ded4771158051c2f31169d..bd96832e46852337b65b75f4904b39775a7fae13 100644 (file)
@@ -79,6 +79,11 @@ int dev_manager_thin_percent(struct dev_manager *dm,
 int dev_manager_thin_device_id(struct dev_manager *dm,
                               const struct logical_volume *lv,
                               uint32_t *device_id);
+int dev_manager_vdo_pool_status(struct dev_manager *dm,
+                               const struct logical_volume *lv,
+                               int flush,
+                               char **vdo_params,
+                               struct lv_status_vdo **vdo_status);
 int dev_manager_suspend(struct dev_manager *dm, const struct logical_volume *lv,
                        struct lv_activate_opts *laopts, int lockfs, int flush_required);
 int dev_manager_activate(struct dev_manager *dm, const struct logical_volume *lv,
This page took 0.047906 seconds and 5 git commands to generate.