]> sourceware.org Git - lvm2.git/commitdiff
Refactor and add code for (lv) 'origin_size' get function.
authorDave Wysochanski <dwysocha@redhat.com>
Tue, 12 Oct 2010 16:11:48 +0000 (16:11 +0000)
committerDave Wysochanski <dwysocha@redhat.com>
Tue, 12 Oct 2010 16:11:48 +0000 (16:11 +0000)
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Reviewed-By: Petr Rockai <prockai@redhat.com>
lib/metadata/lv.c
lib/metadata/lv.h
lib/report/properties.c
lib/report/report.c

index d63ce29570a787c58ae6cc2458164c2ba2b5e4a5..48707ff84c742d28f52b3df6f325cf59ef986316 100644 (file)
 #include "activate.h"
 #include "toolcontext.h"
 
+uint64_t lv_origin_size(const struct logical_volume *lv)
+{
+       if (lv_is_cow(lv))
+               return (uint64_t) find_cow(lv)->len * lv->vg->extent_size;
+       if (lv_is_origin(lv))
+               return lv->size;
+       return 0;
+}
+
 char *lv_path_dup(struct dm_pool *mem, const struct logical_volume *lv)
 {
        char *repstr;
index eee281150a99c9598447a13eb1dae682217f9d96..69c4077ac69b1e4dd1004bd0807b6c5974c92c77 100644 (file)
@@ -53,5 +53,6 @@ char *lv_attr_dup(struct dm_pool *mem, const struct logical_volume *lv);
 char *lv_uuid_dup(const struct logical_volume *lv);
 char *lv_tags_dup(const struct logical_volume *lv);
 char *lv_path_dup(struct dm_pool *mem, const struct logical_volume *lv);
+uint64_t lv_origin_size(const struct logical_volume *lv);
 
 #endif
index 8890e273e870d54e4908759b01b081d790bb5249..27503a95f0c4e836793b72dde12fe921e1d91608 100644 (file)
@@ -123,7 +123,7 @@ GET_LV_NUM_PROPERTY_FN(seg_count, dm_list_size(&lv->segments))
 #define _seg_count_set _not_implemented_set
 #define _origin_get _not_implemented_get
 #define _origin_set _not_implemented_set
-#define _origin_size_get _not_implemented_get
+GET_LV_NUM_PROPERTY_FN(origin_size, lv_origin_size(lv))
 #define _origin_size_set _not_implemented_set
 #define _snap_percent_get _not_implemented_get
 #define _snap_percent_set _not_implemented_set
index 32559b8986750088a62743ea97fa580ac9ea6e94..83216b28aa988e1cf148cf208121720078f6edd4 100644 (file)
@@ -570,12 +570,7 @@ static int _originsize_disp(struct dm_report *rh, struct dm_pool *mem,
        const struct logical_volume *lv = (const struct logical_volume *) data;
        uint64_t size;
 
-       if (lv_is_cow(lv))
-               size = (uint64_t) find_cow(lv)->len * lv->vg->extent_size;
-       else if (lv_is_origin(lv))
-               size = lv->size;
-       else
-               size = UINT64_C(0);
+       size = lv_origin_size(lv);
 
        return _size64_disp(rh, mem, field, &size, private);
 }
This page took 0.044993 seconds and 5 git commands to generate.