]> sourceware.org Git - lvm2.git/commitdiff
Thin add lv_thin_pool_transaction_id
authorZdenek Kabelac <zkabelac@redhat.com>
Wed, 25 Jan 2012 08:48:42 +0000 (08:48 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Wed, 25 Jan 2012 08:48:42 +0000 (08:48 +0000)
Easy function to get transaction_id status value.

WHATS_NEW
lib/activate/activate.c
lib/activate/activate.h
lib/activate/dev_manager.c
lib/activate/dev_manager.h

index 3c962fdca98e7898c168c333af36ec493a7036c7..2c08d6215b856fe47f3450245ccf9d20c729226d 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.89 - 
 ==================================
+  Add lv_thin_pool_transaction_id to read the transaction_id value.
   Use suspend|resume_origin_only when up-converting RAID, as mirrors do.
   Fix the way RAID meta LVs are added to the dependency tree.
   Change exclusive LV activation logic to try local node before remote nodes.
index b647407757715736277ecd480dcfc4193d873938..67d0cc3ce3d62c9ff828a6abcc305ffc5d662138 100644 (file)
@@ -762,6 +762,35 @@ int lv_thin_percent(const struct logical_volume *lv,
        return r;
 }
 
+/*
+ * Returns 1 if transaction_id set, else 0 on failure.
+ */
+int lv_thin_pool_transaction_id(const struct logical_volume *lv,
+                               uint64_t *transaction_id)
+{
+       int r;
+       struct dev_manager *dm;
+       struct dm_status_thin_pool *status;
+
+       if (!activation())
+               return 0;
+
+       log_debug("Checking thin percent for LV %s/%s",
+                 lv->vg->name, lv->name);
+
+       if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name, 1)))
+               return_0;
+
+       if (!(r = dev_manager_thin_pool_status(dm, lv, &status)))
+               stack;
+       else
+               *transaction_id = status->transaction_id;
+
+       dev_manager_destroy(dm);
+
+       return r;
+}
+
 static int _lv_active(struct cmd_context *cmd, struct logical_volume *lv)
 {
        struct lvinfo info;
index d053eefd869875ec52365bee7a482307288e4971..9029b8da42608937c869f3d685b1555a5ffccd3a 100644 (file)
@@ -105,6 +105,8 @@ int lv_thin_pool_percent(const struct logical_volume *lv, int metadata,
                         percent_t *percent);
 int lv_thin_percent(const struct logical_volume *lv, int mapped,
                    percent_t *percent);
+int lv_thin_pool_transaction_id(const struct logical_volume *lv,
+                               uint64_t *transaction_id);
 
 /*
  * Return number of LVs in the VG that are active.
index f1744d9385994f3248c9dc861f896bf57fea1ddb..3b8bd5855c47fbd06622db80edc352086742ef81 100644 (file)
@@ -882,6 +882,48 @@ static int _belong_to_vg(const char *vgname, const char *name)
 
 #endif
 
+int dev_manager_thin_pool_status(struct dev_manager *dm,
+                                const struct logical_volume *lv,
+                                struct dm_status_thin_pool **status)
+{
+       const char *dlid;
+       struct dm_task *dmt;
+       struct dm_info info;
+       uint64_t start, length;
+       char *type = NULL;
+       char *params = NULL;
+       int r = 0;
+
+       /* Build dlid for the thin pool layer */
+       if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, _thin_layer)))
+               return_0;
+
+       log_debug("Getting thin pool device status for %s.", lv->name);
+
+       if (!(dmt = _setup_task(NULL, dlid, 0, DM_DEVICE_STATUS, 0, 0)))
+               return_0;
+
+       if (!dm_task_no_open_count(dmt))
+               log_error("Failed to disable open_count.");
+
+       if (!dm_task_run(dmt))
+               goto_out;
+
+       if (!dm_task_get_info(dmt, &info) || !info.exists)
+               goto_out;
+
+       dm_get_next_target(dmt, NULL, &start, &length, &type, &params);
+
+       if (!dm_get_status_thin_pool(dm->mem, params, status))
+               goto_out;
+
+       r = 1;
+out:
+       dm_task_destroy(dmt);
+
+       return r;
+}
+
 int dev_manager_thin_pool_percent(struct dev_manager *dm,
                                  const struct logical_volume *lv,
                                  int metadata, percent_t *percent)
index e3c73493e1375a3d2c6f8f89da64f06b40621996..2d1b7451c4becedb820b934450d7b7aa2beb8c1c 100644 (file)
@@ -54,6 +54,9 @@ int dev_manager_snapshot_percent(struct dev_manager *dm,
 int dev_manager_mirror_percent(struct dev_manager *dm,
                               const struct logical_volume *lv, int wait,
                               percent_t *percent, uint32_t *event_nr);
+int dev_manager_thin_pool_status(struct dev_manager *dm,
+                                const struct logical_volume *lv,
+                                struct dm_status_thin_pool **status);
 int dev_manager_thin_pool_percent(struct dev_manager *dm,
                                  const struct logical_volume *lv,
                                  int metadata, percent_t *percent);
This page took 0.038363 seconds and 5 git commands to generate.