public inbox for lvm2-cvs@sourceware.org help / color / mirror / Atom feed
From: wysochanski@sourceware.org To: lvm-devel@redhat.com, lvm2-cvs@sourceware.org Subject: LVM2 lib/metadata/metadata-exported.h lib/meta ... Date: Sun, 14 Feb 2010 03:21:00 -0000 [thread overview] Message-ID: <20100214032139.8655.qmail@sourceware.org> (raw) CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2010-02-14 03:21:38 Modified files: lib/metadata : metadata-exported.h metadata.c lib/report : columns.h report.c liblvm : .exported_symbols lvm2app.h lvm_pv.c Log message: Export lvm_pv_get_size(), lvm_pv_get_free(), lvm_pv_get_dev_size in lvm2app. 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> Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.130&r2=1.131 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.313&r2=1.314 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/columns.h.diff?cvsroot=lvm2&r1=1.37&r2=1.38 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.111&r2=1.112 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.22&r2=1.23 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm2app.h.diff?cvsroot=lvm2&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_pv.c.diff?cvsroot=lvm2&r1=1.7&r2=1.8 --- LVM2/lib/metadata/metadata-exported.h 2010/02/14 03:21:06 1.130 +++ LVM2/lib/metadata/metadata-exported.h 2010/02/14 03:21:37 1.131 @@ -726,6 +726,9 @@ 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); --- LVM2/lib/metadata/metadata.c 2010/02/03 14:08:40 1.313 +++ LVM2/lib/metadata/metadata.c 2010/02/14 03:21:37 1.314 @@ -3603,6 +3603,38 @@ 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); --- LVM2/lib/report/columns.h 2009/05/21 03:04:53 1.37 +++ LVM2/lib/report/columns.h 2010/02/14 03:21:38 1.38 @@ -78,7 +78,7 @@ 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.") --- LVM2/lib/report/report.c 2010/01/13 01:55:44 1.111 +++ LVM2/lib/report/report.c 2010/02/14 03:21:38 1.112 @@ -767,10 +767,7 @@ (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 @@ (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 @@ 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); } --- LVM2/liblvm/.exported_symbols 2009/07/28 13:17:04 1.22 +++ LVM2/liblvm/.exported_symbols 2010/02/14 03:21:38 1.23 @@ -3,6 +3,9 @@ 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 --- LVM2/liblvm/lvm2app.h 2009/09/14 19:43:12 1.9 +++ LVM2/liblvm/lvm2app.h 2010/02/14 03:21:38 1.10 @@ -868,6 +868,40 @@ 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. * * NOTE: This function is currently not implemented. --- LVM2/liblvm/lvm_pv.c 2009/08/13 12:18:15 1.7 +++ LVM2/liblvm/lvm_pv.c 2010/02/14 03:21:38 1.8 @@ -43,6 +43,21 @@ 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 */
next reply other threads:[~2010-02-14 3:21 UTC|newest] Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-02-14 3:21 wysochanski [this message] -- strict thread matches above, loose matches on Subject: below -- 2011-02-21 12:29 prajnoha 2010-10-12 16:41 mornfall 2010-06-30 20:03 agk 2010-06-30 18:03 wysochanski 2010-06-29 21:32 wysochanski 2010-06-28 20:40 wysochanski 2010-02-24 18:15 wysochanski 2010-02-24 18:15 wysochanski 2010-02-14 3:21 wysochanski 2009-11-01 20:05 wysochanski 2009-11-01 19:51 wysochanski 2009-10-31 17:30 wysochanski 2009-10-05 20:03 wysochanski 2009-10-05 20:02 wysochanski 2009-10-01 1:04 agk 2009-09-14 15:45 wysochanski 2009-09-02 21:39 wysochanski 2009-09-02 21:39 wysochanski 2009-07-28 15:14 wysochanski 2009-07-28 13:17 wysochanski 2009-07-26 2:34 wysochanski 2009-07-26 1:53 wysochanski 2009-07-15 5:50 mornfall 2009-07-14 2:15 wysochanski 2009-07-10 20:07 wysochanski 2009-07-10 20:05 wysochanski 2009-07-09 10:09 wysochanski 2009-07-09 10:08 wysochanski 2009-07-09 10:07 wysochanski 2009-07-09 10:06 wysochanski 2009-07-09 10:04 wysochanski 2009-07-09 10:03 wysochanski 2009-07-08 14:33 wysochanski 2009-07-01 17:01 wysochanski 2008-06-24 20:10 wysochanski 2008-01-16 19:54 wysochanski 2008-01-15 22:56 wysochanski 2007-12-22 2:13 agk 2007-11-15 22:11 agk 2007-07-23 21:03 wysochanski
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20100214032139.8655.qmail@sourceware.org \ --to=wysochanski@sourceware.org \ --cc=lvm-devel@redhat.com \ --cc=lvm2-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).