]> sourceware.org Git - lvm2.git/commitdiff
Add Thin API for parsing thin status
authorZdenek Kabelac <zkabelac@redhat.com>
Wed, 21 Dec 2011 12:52:38 +0000 (12:52 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Wed, 21 Dec 2011 12:52:38 +0000 (12:52 +0000)
Add dm_get_status_thin_pool and dm_get_status_thin functions to
parse 'params' argument which is received via dm_get_next_target.

Returns filed structure allocated from given mempool.

libdm/libdevmapper.h
libdm/libdm-deptree.c

index 1975c349c4ecdd0b83ce8c794d005e555563c6bc..8c282cec78b3b3f7069bf34113bee5a93857ccf0 100644 (file)
@@ -238,6 +238,29 @@ void *dm_get_next_target(struct dm_task *dmt,
                         void *next, uint64_t *start, uint64_t *length,
                         char **target_type, char **params);
 
+/* Parse params from STATUS call for thin_pool target */
+struct dm_pool;
+
+struct dm_status_thin_pool {
+       uint64_t transaction_id;
+       uint64_t used_meta_blocks;
+       uint64_t total_meta_blocks;
+       uint64_t used_data_blocks;
+       uint64_t total_data_blocks;
+};
+
+int dm_get_status_thin_pool(struct dm_pool *mem, const char *params,
+                           struct dm_status_thin_pool **status);
+
+/* Parse params from STATUS call for thin target */
+struct dm_status_thin {
+       uint64_t mapped_sectors;
+       uint64_t highest_mapped_sector;
+};
+
+int dm_get_status_thin(struct dm_pool *mem, const char *params,
+                      struct dm_status_thin **status);
+
 /*
  * Call this to actually run the ioctl.
  */
index 9beb792aa42a8cdef7b11b45e75c52ceda4dd0f3..9531fb96787d5dd0885fe705a3aa39db4e8b5103 100644 (file)
@@ -3030,6 +3030,54 @@ int dm_tree_node_add_thin_target(struct dm_tree_node *node,
        return 1;
 }
 
+
+int dm_get_status_thin_pool(struct dm_pool *mem, const char *params,
+                           struct dm_status_thin_pool **status)
+{
+       struct dm_status_thin_pool *s;
+
+       if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_thin_pool)))) {
+               log_error("Failed to allocate thin_pool status structure.");
+               return 0;
+       }
+
+       if (sscanf(params, "%" PRIu64 " %" PRIu64 "/%" PRIu64 " %" PRIu64 "/%" PRIu64,
+                  &s->transaction_id,
+                  &s->used_meta_blocks,
+                  &s->total_meta_blocks,
+                  &s->used_data_blocks,
+                  &s->total_data_blocks) != 5) {
+               log_error("Failed to parse thin pool params: %s.", params);
+               return 0;
+       }
+
+       *status = s;
+
+       return 1;
+}
+
+int dm_get_status_thin(struct dm_pool *mem, const char *params,
+                      struct dm_status_thin **status)
+{
+       struct dm_status_thin *s;
+
+       if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_thin)))) {
+               log_error("Failed to allocate thin status structure.");
+               return 0;
+       }
+
+       if (sscanf(params, "%" PRIu64 " %" PRIu64,
+                  &s->mapped_sectors,
+                  &s->highest_mapped_sector) != 2) {
+               log_error("Failed to parse thin params: %s.", params);
+               return 0;
+       }
+
+       *status = s;
+
+       return 1;
+}
+
 static int _add_area(struct dm_tree_node *node, struct load_segment *seg, struct dm_tree_node *dev_node, uint64_t offset)
 {
        struct seg_area *area;
This page took 0.036422 seconds and 5 git commands to generate.