1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-10-28 11:55:55 +03:00
Commit Graph

49 Commits

Author SHA1 Message Date
Alasdair Kergon
2b82bd79f5 Rename vg_release to free_vg. 2010-12-08 20:50:48 +00:00
Petr Rockai
55429cde3c Add lvm2app function to query pvseg properties.
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-17 20:12:39 +00:00
Petr Rockai
5de70620ef Add lvm2app function to query lvseg properties.
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-17 20:09:42 +00:00
Petr Rockai
eeaf3ba70a Implement lvm_vg_set_property() by calling internal 'set' property function.
Signed-off-by: Dave Wysochanski <wysochanski@pobox.com>
Reviewed-by: Petr Rockai <prockai@redhat.com>
2010-11-17 19:16:05 +00:00
Dave Wysochanski
3c1febe0a8 Add lvm_vg_get_property() generic vg property function.
Add a generic VG property function to lvm2app.  Call the internal library
vg_get_property() function.  Strings are dup'd internally.
Rework lvm_vg_get_property to return lvm_property_value and require caller
to check 'is_valid' flag.  If !is_valid, the caller can check lvm_errno()
for the specific error.

Create a 'get_property' function, local to lvm2app, that factors out
most of the common code that copies the components of lvm_property_type
into lvm_property_value.  This allows for a 1-line function for each
of the generic property functions exported by lvm2app.
2010-10-25 14:08:43 +00:00
Dave Wysochanski
254d672dcc Add pv_uuid_dup, vg_uuid_dup, and lv_uuid_dup, and call id_format_and_copy.
Add supporting functions for pv_uuid, vg_uuid, and lv_uuid.
Call new function id_format_and_copy.  Use 'const' where appropriate.
Add "_dup" suffix to indicate memory is being allocated.
Call {pv|vg|lv}_uuid_dup from lvm2app uuid functions.
2010-09-30 14:07:47 +00:00
Dave Wysochanski
d01a6a2c5c Remove unnecessary list of includes in liblvm files.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-07-09 16:57:34 +00:00
Alasdair Kergon
08f1ddea6c Use __attribute__ consistently throughout. 2010-07-09 15:34:40 +00:00
Dave Wysochanski
40b4d1c3ae Refactor vg_remove_check to place pv removal into separate function. 2010-06-30 18:03:52 +00:00
Dave Wysochanski
298ec21e29 Use vg->vgmem to allocate vg/lv/pv string properties instead of dm_malloc/fr
Everywhere else in the API the caller can rely on lvm2app taking care of
memory allocation and free, so make the 'name' and 'uuid' properties of a
vg/lv/pv use the vg handle to allocate memory.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-04-19 15:22:24 +00:00
Alasdair Kergon
b8175c33da Use INTERNAL_ERROR definition consistently in internal error messages. 2010-03-25 18:22:04 +00:00
Alasdair Kergon
38220f9fe9 Remove unnecessary full_scan parameter from get_vgids and get_vgnames calls. 2010-03-16 16:57:03 +00:00
Dave Wysochanski
a8ab586770 Add lvm_vg_get_tags(), lvm_vg_add_tag(), and lvm_vg_remove_tag().
Add lvm2app functions to manage VG tags.
For lvm_vg_get_tags(), we return a list of tags, similar to other
functions that return lists.  An empty list is returned if there
are no VG tags.  NULL is returned if there is a problem obtaining
the list of tags.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-24 18:16:18 +00:00
Alasdair Kergon
9e7b0091bb post-release 2010-02-16 00:27:01 +00:00
Dave Wysochanski
ed3329eb45 Fix off by 512 sizes for lvm2app.
Internally we store sizes in sectors, but lvm2app exports sizes
in bytes.  We could get fancier and allow units configuration but
this fix should do for now.

Fixes rhbz561422.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2010-02-14 03:21:06 +00:00
Peter Rajnoha
04fa77c3be This is related to liblvm and its lvm_list_vg_names() and lvm_list_vg_uuids() functions
where we should not expose internal VG names/uuids (the ones with "#" prefix )through the
interface. Otherwise, we could end up with library users opening internal VGs which will
initiate locking mechanism that won't be cleaned up properly.

"#orphans_{lvm1, lvm2, pool}" names are treated in a special way, they are truncated first
to "orphans" and this is used as a part of the lock name then (e.g. while calling lvm_vg_open()).
When library user calls lvm_vg_close(), the original name "orphans_{lvm1, lvm2, pool}"
is used directly and therefore no unlock occurs.

We should exclude internal VG names and uuids in the lists provided by lvmcache:
lvmcache_get_vgids() and lvmcache_get_vgnames().
2010-02-03 14:08:39 +00:00
Dave Wysochanski
accb17389c Rename pvcreate_params processing functions to better match <object><action>.
Rename fill_default_pvcreate_params to pvcreate_params_set_defaults.
Rename pvcreate_validate_restore_params to pvcreate_restore_params_validate.
Rename pvcreate_validate_params to pvcreate_params_validate.
2009-11-01 19:51:54 +00:00
Dave Wysochanski
c24a4ff2cc Allow calling fill_default_pvcreate_params from tools.
We need defaults for pvcreate_params at a higher level - this will
allow us to use a common function from the tools to take defaults,
then fill in any non-defaults from the commandline.

Future patches will refactor vgcreate/vgextend to call this function
if one or more pvcreate parameters are given on the commandline.
2009-10-05 20:03:08 +00:00
Dave Wysochanski
29123aa652 Add pvcreate_params to vg_extend.
Another refactoring for implicit pvcreate support.  We need to get
the pvcreate parameters somehow to the vg_extend routine.  Options
seemed to be:
1. Attach the parameters to struct volume_group.  I personally
did not like this idea in most cases, though one could make an
agrument why it might be ok at least for some of the parameters
(e.g. metadatacopies).
2. Pass them in to the extend routine.  This second route seemed
to be the best approach given the constraints.

Future patches will parse the command line and fill in the actual
values for the pvcreate_single call.
Should be no functional change.
2009-10-05 20:02:48 +00:00
Dave Wysochanski
fca434258a Add most relevant vg_attr fields as lvm2app 'get' functions.
Of the vgs field vg_attr, a few of the most likely to be used attributes
are clustered, exported, and partial.  This patch adds the following 3
functions:
uint64_t lvm_vg_is_clustered(const vg_t vg)
uint64_t lvm_vg_is_exported(const vg_t vg)
uint64_t lvm_vg_is_partial(const vg_t vg)
2009-09-14 19:43:11 +00:00
Dave Wysochanski
8c7946664c Add max_pv and max_lv vg 'get' lvm2app exports. 2009-09-14 15:45:23 +00:00
Dave Wysochanski
a5609e3086 Update lvm_vg_write() to handle the deferred commit of lvm_vg_write().
Now that we've refactored the internal library functions that do the
vg_remove, we can handle the deferred commit of a lvm_vg_remove() inside
lvm_vg_write().  This makes the VG create/remove API more consistent in
terms of disk commits - they now both require an lvm_vg_write() to commit
the create or remove to disk.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:40:10 +00:00
Dave Wysochanski
d50795ed09 Split vg_remove_single into 2 functions - the second part commits to disk.
Split vg_remove_single into vg_remove_check (mandatory checks before
vgremove) and vg_remove (do actual remove by committing to disk).

In liblvm, we'd like to provide an consistent API that allows multiple
changes in memory, then let lvm_vg_write() control the commit to disk.  In
some cases (for example, lvresize calls fsadm) this may not be possible.
However, since we are using an object model and dividing things into small
operations, the most logical model seems to be the lvm_vg_write model, and
handling the special cases as they arrive.  So as best as possible
we move towards this end.

A possible optimization would be to consolidate vg_remove (committing)
code with vgreduce code.  A second possible optimization is making vgreduce
of the last device equivalent to vgremove.  Today, lvm_vg_reduce fails if
vgreduce is called with the last device, but from an object model perspective
we could view this as equivalent to vgremove and allow it.  My gut feel is
we do not want to do this though.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-09-02 21:39:29 +00:00
Dave Wysochanski
7510963fbf Make lvm2app vg_t handle definition consistent with lvm_t.
This patch update vg_t handle to be consistent with lvm_t - define as a pointer
to internal struct volume_group.

Author: Dave Wysochanski <dwysocha@redhat.com>
2009-08-13 12:16:45 +00:00
Dave Wysochanski
5e82475490 Move FIXME from user visible lvm2app.h to lvm_vg.c
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-08-03 12:11:45 +00:00
Alasdair Kergon
9e813cc93b Remove pv_t, vg_t & lv_t handles from lib. Only liblvm uses them.
Rename lvm.h to lvm2app.h for now.
2009-07-29 13:26:01 +00:00
Dave Wysochanski
afcd9399a9 Add an open_mode to the vg struct for liblvm - enforce read / write semantics.
For now, a simple way to enforce the read/write semantics is to just save the
open mode of the VG.  If the caller uses lvm_vg_create, the mode is write.
The caller using lvm_vg_open can use either read or write to open the VG.
Once we have this, we enforce the permissions on each API call and don't allow
a caller to modify a VG that has not been opened properly.

This may be better combined with the locking mode, but I view that as future
cleanup, past this initial release.  The intial release should enforce the
basic object semantics though, as described in the lvm.h file.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-28 15:14:56 +00:00
Dave Wysochanski
9ac1af7160 Add lvm_vg_get_seqno, updating lvm.h and unit test.
Adding the ability to get the seqno is important for an application to
determine if something has changed in a VG.  Otherwise, the only way to
know is to open the VG with write permission and hold the handle.
2009-07-28 13:17:04 +00:00
Dave Wysochanski
98418e2b6e Use dm_malloc and dm_free in liblvm instead of malloc/free. 2009-07-28 09:56:48 +00:00
Dave Wysochanski
df621aa30b Remove unnecessary \n's from log_error in liblvm. 2009-07-27 21:03:15 +00:00
Dave Wysochanski
dfe213f804 Add lvm_vg_reduce to liblvm2app
Extend lvm_vg_write to remove pvs removed in lvm_vg_reduce. The lvm
volume_group internal structure removed_pvs is used for that. The list is
empty afterwards.

Add new test for vg->pvs emptyness to lvm_vg_write to prevent to write empty
vgs. This is needed because of lvm_vg_reduce and lv_vg_create, which creates
empty vgs.

Signed-off-by: Thomas Woerner <twoerner@redhat.com>
Acked-by: Dave Wysochanski <dwysocha@redhat.com>


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 17:44:29 +00:00
Dave Wysochanski
0589e19fd7 Update error return and comments for lvm_list_vg_names/uuids.
The two liblvm functions that return a list of vgnames and vguuids use
cmd->mem to allocate the list.  Make it clear to the caller that this
memory will be freed when the LVM handle is freed.

Clean up and clarify the return value of the functions.  In the
case of a memory allocation error, add a couple log_errnos to the internal
code, and make it clear that memory allocation returns a NULL pointer.
If there are no VGs in the system, the list returned is an empty list.

Make a note of the fact that currently we return hidden VG names, how
these can be detected (always start with "#"), and that they should
not be used.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-27 11:00:17 +00:00
Dave Wysochanski
a57262a7ee Update a few liblvm calls with log_errno.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 20:29:28 +00:00
Dave Wysochanski
f864285b3a Update liblvm status return codes to be consistent.
For now, we use the following scheme.
For APIs that return an int, success is 0, fail is -1.
APIs that return handles, success is non-NULL, fail is NULL.
At this early stage, liblvm error handling mechanism is subject to change,
but for now we go with this simple scheme consistent with system
programming.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 20:28:59 +00:00
Dave Wysochanski
2572832e0c Rename lvm_scan_vgs to lvm_scan.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:44:05 +00:00
Dave Wysochanski
4e57aae3a7 Rename lvm_vg_get_free to lvm_vg_get_free_size.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:06:46 +00:00
Dave Wysochanski
1efda0fbb9 Rename lvm_list_vg_ids to lvm_list_vg_uuids.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:06:21 +00:00
Dave Wysochanski
0185663b88 Rename lvm_vg_get_free_count to lvm_vg_get_free_extent_count.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 16:05:49 +00:00
Dave Wysochanski
83f25cd121 Add most all liblvm 'get' functions needed for anaconda.
Add the most straightforward 'get' functions required for anaconda.
These are the ones that return simple uint64_t values.
The other more complex ones involve the lv_attr bits.  These will
come in a separate patch series since each lv_attr bit will be returned
in a separate API instred of returning the string and requiring the
user to parse it.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 13:06:59 +00:00
Dave Wysochanski
bae6bc62bd Update lvm_vg_extend to do an implicit pvcreate on the device.
Although the tools do not currently do this, we update lvm_vg_extend
to do an implicit pvcreate on an uninitialized device.  The tools will
soon be refactored to do this as well, but more work is needed in the
tools.  For now we update lvm_vg_extend since this is the behavior
required by liblvm.
With this change, the simple liblvm unit test, test/api/vgtest.c
should pass whether or not the device is initialized.


Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-26 01:54:40 +00:00
Dave Wysochanski
0b7cc76a9d Update lvm_vg_extend() to obtain VG_ORPHAN.
vg_extend() no longer obtains VG_OPHAN so we must do so in liblvm function.
We still have the race in liblvm but we will address this problem later.
2009-07-24 15:12:50 +00:00
Dave Wysochanski
fe63e644d9 Add lvm_scan_vgs liblvm fn to scan the system for LVM metadata.
The lvm_list_vg_{names|ids} functions do not do a scan so we provide
a liblvm function that does a scan.

Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-24 12:48:21 +00:00
Dave Wysochanski
122ccd0d04 Add lvm_list_vg_names and lvm_list_vg_ids liblvm functions.
These functions provide the capability of enumerating all vgnames and
vgids in the system.  They do not do a scan of the system.

Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-24 12:47:15 +00:00
Dave Wysochanski
f032ed7498 Add lvm_{pv|vg|lv}_get_{uuid|name}.
Caller must free the memory of the uuid / name returned.
This may not be the best memory management policy since it may lead to
memory leaks if the caller has code like this:
if (!lvm_vg_get_name(vg))

Maybe we don't care - if we do we can use pools tied to handles later
or some other scheme.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Thomas Woerner <twoerner@redhat.com>
2009-07-23 23:40:05 +00:00
Dave Wysochanski
6c6c821445 Add lvm_vg_list_{pvs|lvs} - return lists of pv/lv handles for a vg.
- Use vgmem pool to allocate a list of lvm_*_list structs
- Allocate a new list each call (list may have changed since last call)
- Add to liblvm's exported symbols

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Thomas Woerner <twoerner@redhat.com>
2009-07-23 23:39:02 +00:00
Dave Wysochanski
f6ffb81bf8 Update lvm_vg_create to use NULL / non-NULL return for the time being.
Some of the error interface is still TBD.  Rather than exporting a lot
of codes, etc, just use a simple pass / fail.  The allows our unit test
to not segfault if trying to create a VG that already exists.
2009-07-23 01:20:22 +00:00
Dave Wysochanski
729f472c04 Add lvm_vg_open() to open an existing VG for reading or writing.
lvm_vg_open() calls internal vg_read() function which is the entry point
for reading an existing VG.  In addition to the mode, we include a 'flags'
parameter for future extensions.

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
2009-07-22 22:24:16 +00:00
Dave Wysochanski
8a68d95466 Fix lvm_vg_close() when locking fails.
Author: Dave Wysochanski <dwysocha@redhat.com>
2009-07-22 03:13:35 +00:00
Dave Wysochanski
930a1434ac Add lvm_vg_* APIs to create and modify VGs.
Add some liblvm APIs for VGs.  Most of these APIs simply call into the internal
liblvm library.  Ideally we should call the liblvm functions directly from
the tools.  However, until we convert more of the code to liblvm functions,
things like the cmd_context will get in the way.  For now just implement the
liblvm functions as wrappers around the internal functions, with a little
error checking and return code handling.  We put all these vg APIs into a
new file, lvm_vg.c

The following APIs are implemented:
lvm_vg_create, lvm_vg_extend, lvm_vg_set_extent_size, lvm_vg_write,
lvm_vg_remove, lvm_vg_close.

Still TODO:
- cleanup error handling by using lvm_errno() and related APIs
- cleanup naming / clarify which functions commit to disk vs not
- implement more 'set' functions
- decide on 'set' / 'change' nomenclature

Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Acked-by: Alasdair G Kergon <agk@redhat.com>
2009-07-14 03:02:14 +00:00