]> sourceware.org Git - lvm2.git/commitdiff
Export lvm_pv_get_size(), lvm_pv_get_free(), lvm_pv_get_dev_size in lvm2app.
authorDave Wysochanski <dwysocha@redhat.com>
Sun, 14 Feb 2010 03:21:37 +0000 (03:21 +0000)
committerDave Wysochanski <dwysocha@redhat.com>
Sun, 14 Feb 2010 03:21:37 +0000 (03:21 +0000)
We add these exports to show the pv_size and pv_free and dev_size
fields.
Fixes rhbz561423.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
lib/metadata/metadata-exported.h
lib/metadata/metadata.c
lib/report/columns.h
lib/report/report.c
liblvm/.exported_symbols
liblvm/lvm2app.h
liblvm/lvm_pv.c

index acb7b52a65b4a0c31f0cc394669073f79beb380c..164ce36d616b220fd991d34153b103886667a5d7 100644 (file)
@@ -726,6 +726,9 @@ struct device *pv_dev(const struct physical_volume *pv);
 const char *pv_vg_name(const struct physical_volume *pv);
 const char *pv_dev_name(const struct physical_volume *pv);
 uint64_t pv_size(const struct physical_volume *pv);
+uint64_t pv_size_field(const struct physical_volume *pv);
+uint64_t pv_dev_size(const struct physical_volume *pv);
+uint64_t pv_free(const struct physical_volume *pv);
 uint64_t pv_status(const struct physical_volume *pv);
 uint32_t pv_pe_size(const struct physical_volume *pv);
 uint64_t pv_pe_start(const struct physical_volume *pv);
index 28c7c47766977344456ed23d6e08dd76b5d65195..b3b3778c053b08863e4fb36d3dff4cdd320bb31c 100644 (file)
@@ -3603,6 +3603,38 @@ uint64_t pv_size(const struct physical_volume *pv)
        return pv_field(pv, size);
 }
 
+uint64_t pv_dev_size(const struct physical_volume *pv)
+{
+       uint64_t size;
+
+       if (!dev_get_size(pv->dev, &size))
+               size = 0;
+       return size;
+}
+
+uint64_t pv_size_field(const struct physical_volume *pv)
+{
+       uint64_t size;
+
+       if (!pv->pe_count)
+               size = pv->size;
+       else
+               size = (uint64_t) pv->pe_count * pv->pe_size;
+       return size;
+}
+
+uint64_t pv_free(const struct physical_volume *pv)
+{
+       uint64_t freespace;
+
+       if (!pv->pe_count)
+               freespace = pv->size;
+       else
+               freespace = (uint64_t)
+                       (pv->pe_count - pv->pe_alloc_count) * pv->pe_size;
+       return freespace;
+}
+
 uint64_t pv_status(const struct physical_volume *pv)
 {
        return pv_field(pv, status);
index 49ebab49e1e67203ac92b996b353dae6749d4083..141497151871d205354ace88fdbc212c5470c6c3 100644 (file)
@@ -78,7 +78,7 @@ FIELD(LVS, lv, STR, "Modules", lvid, 7, modules, "modules", "Kernel device-mappe
 
 FIELD(LABEL, pv, STR, "Fmt", id, 3, pvfmt, "pv_fmt", "Type of metadata.")
 FIELD(LABEL, pv, STR, "PV UUID", id, 38, uuid, "pv_uuid", "Unique identifier.")
-FIELD(LABEL, pv, NUM, "DevSize", dev, 7, devsize, "dev_size", "Size of underlying device in current units.")
+FIELD(LABEL, pv, NUM, "DevSize", id, 7, devsize, "dev_size", "Size of underlying device in current units.")
 FIELD(LABEL, pv, STR, "PV", dev, 10, dev_name, "pv_name", "Name.")
 FIELD(LABEL, pv, NUM, "PMdaFree", id, 9, pvmdafree, "pv_mda_free", "Free metadata area space on this device in current units.")
 FIELD(LABEL, pv, NUM, "PMdaSize", id, 9, pvmdasize, "pv_mda_size", "Size of smallest metadata area on this device in current units.")
index 2cceedd985922dd66e81cefdf43ed3587246ff7d..6bcab55bf0bd6345d0837c9179a6293d81871908 100644 (file)
@@ -767,10 +767,7 @@ static int _pvfree_disp(struct dm_report *rh, struct dm_pool *mem,
            (const struct physical_volume *) data;
        uint64_t freespace;
 
-       if (!pv->pe_count)
-               freespace = pv->size;
-       else
-               freespace = (uint64_t) (pv->pe_count - pv->pe_alloc_count) * pv->pe_size;
+       freespace = pv_free(pv);
 
        return _size64_disp(rh, mem, field, &freespace, private);
 }
@@ -783,10 +780,7 @@ static int _pvsize_disp(struct dm_report *rh, struct dm_pool *mem,
            (const struct physical_volume *) data;
        uint64_t size;
 
-       if (!pv->pe_count)
-               size = pv->size;
-       else
-               size = (uint64_t) pv->pe_count * pv->pe_size;
+       size = pv_size_field(pv);
 
        return _size64_disp(rh, mem, field, &size, private);
 }
@@ -795,11 +789,11 @@ static int _devsize_disp(struct dm_report *rh, struct dm_pool *mem,
                         struct dm_report_field *field,
                         const void *data, void *private)
 {
-       const struct device *dev = *(const struct device **) data;
+       const struct physical_volume *pv =
+           (const struct physical_volume *) data;
        uint64_t size;
 
-       if (!dev_get_size(dev, &size))
-               size = 0;
+       size = pv_dev_size(pv);
 
        return _size64_disp(rh, mem, field, &size, private);
 }
index 1e6d4c41c4908bd4ef9f6454645d1ee491cefabc..c184a889f8cf9ded0f12f2fff33bfa09d2c3bd0b 100644 (file)
@@ -3,6 +3,9 @@ lvm_init
 lvm_quit
 lvm_config_reload
 lvm_config_override
+lvm_pv_get_dev_size
+lvm_pv_get_size
+lvm_pv_get_free
 lvm_pv_get_name
 lvm_pv_get_uuid
 lvm_pv_get_mda_count
index aeadd7490938a824d0ae332300657667f4a7196c..442a591a1d7afb7dbb683a7e5a33e635697efe6a 100644 (file)
@@ -867,6 +867,40 @@ char *lvm_pv_get_name(const pv_t pv);
  */
 uint64_t lvm_pv_get_mda_count(const pv_t pv);
 
+/**
+ * Get the current size in bytes of a device underlying a
+ * physical volume.
+ *
+ * \param   pv
+ * Physical volume handle.
+ *
+ * \return
+ * Size in bytes.
+ */
+uint64_t lvm_pv_get_dev_size(const pv_t pv);
+
+/**
+ * Get the current size in bytes of a physical volume.
+ *
+ * \param   pv
+ * Physical volume handle.
+ *
+ * \return
+ * Size in bytes.
+ */
+uint64_t lvm_pv_get_size(const pv_t pv);
+
+/**
+ * Get the current unallocated space in bytes of a physical volume.
+ *
+ * \param   pv
+ * Physical volume handle.
+ *
+ * \return
+ * Free size in bytes.
+ */
+uint64_t lvm_pv_get_free(const pv_t pv);
+
 /**
  * Resize physical volume to new_size bytes.
  *
index 854859717de09106ba88183e5355793bd03b8eac..a97f26fe43bf4a0603d1bf39353bdc625385de55 100644 (file)
@@ -43,6 +43,21 @@ uint64_t lvm_pv_get_mda_count(const pv_t pv)
        return (uint64_t) pv_mda_count(pv);
 }
 
+uint64_t lvm_pv_get_dev_size(const pv_t pv)
+{
+       return (uint64_t) SECTOR_SIZE*pv_dev_size(pv);
+}
+
+uint64_t lvm_pv_get_size(const pv_t pv)
+{
+       return (uint64_t) SECTOR_SIZE*pv_size_field(pv);
+}
+
+uint64_t lvm_pv_get_free(const pv_t pv)
+{
+       return (uint64_t) SECTOR_SIZE*pv_free(pv);
+}
+
 int lvm_pv_resize(const pv_t pv, uint64_t new_size)
 {
        /* FIXME: add pv resize code here */
This page took 0.048891 seconds and 5 git commands to generate.