Dave Wysochanski [Sun, 26 Jul 2009 20:29:56 +0000 (20:29 +0000)]
Update test/api/*.c to use consistent liblvm error returns.
For now, liblvm will return -1 (fail) / 0 (success) or
NULL (fail) / non-NULL (success). Upon failure, lvm_errno and
lvm_errmsg should be used to determine the precise error.
Dave Wysochanski [Sun, 26 Jul 2009 20:28:59 +0000 (20:28 +0000)]
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.
Dave Wysochanski [Sun, 26 Jul 2009 16:35:57 +0000 (16:35 +0000)]
Update lvm.h - comments describing function behavior, divide into sections.
Hard to divide into smaller patches because of the moving around and
commenting, so just put in the new file diffs. We will review and can
update as necessary.
Dave Wysochanski [Sun, 26 Jul 2009 14:36:52 +0000 (14:36 +0000)]
Add lvm_vg_remove_lv liblvm function.
Add a very simple version of lvm_vg_remove_lv.
Since we currently can only create linear LVs, this simple remove function
is adequate. We must refactor lvremove_single a bit.
Dave Wysochanski [Sun, 26 Jul 2009 13:06:59 +0000 (13:06 +0000)]
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.
Dave Wysochanski [Sun, 26 Jul 2009 12:41:09 +0000 (12:41 +0000)]
Refactor a few report field calculations into separate functions.
For liblvm 'get' functions, we should share code with the reporting functions.
This means we need common code to return the values for the fields.
In this patch we refactor a few of the fields needed in liblvm.
Unfortunately, for the simple fields that do derefernces of structure
members (for example, vg_extent_count), we cannot call the common function
from the reporting infrastructure without more refactoring. The reason is
that the dereference of the simple fields is done deep inside the reporting
code (to get the generic "data" pointer), and the display function is a
generic 'size32' function. We can fix these issues later with more
refactoring.
Should be no functional change and the testsuite should cover any possible
regressions. The only fields in the report affected by this patch are:
vg_size, vg_free, and pv_mda_count.
Dave Wysochanski [Sun, 26 Jul 2009 02:33:35 +0000 (02:33 +0000)]
Move _lvcreate into the internal library and rename to lv_create_single.
After some refactorings, we can now move the bulk of _lvcreate into the
internal library, and we can call from liblvm. In the future, we should
refactor lv_create_single further, probably by segtype, to reduce the
size of struct lvcreate_params. For now this is a reasonable refactor
and allows us to re-use the function from liblvm.
Dave Wysochanski [Sun, 26 Jul 2009 02:31:41 +0000 (02:31 +0000)]
Move percent_t from struct lvcreate_params to struct lvcreate_cmdline_params.
Create a new structure, lvcreate_cmdline_params, to store parameters only
relevant for the cmdline, not the library call to lvcreate.
Should be no functional change.
Dave Wysochanski [Sun, 26 Jul 2009 02:31:18 +0000 (02:31 +0000)]
Refactor extents calculations / updates in _lvcreate.
Move extents calculation adjustments into their own local functions
right after we read the vg. This calculation really is not part of
the LV create function but is rather an adjustment to the parameters
based on what is given on the cmdline. So we move it outside the main
_lvcreate.
Dave Wysochanski [Sun, 26 Jul 2009 02:30:57 +0000 (02:30 +0000)]
Refactor _lvcreate - move *_ARG into _lvcreate_params and get 'cmd' from 'vg'.
A couple simple refactorings of _lvcreate - should be no functional change.
Move tags_ARG parsing into _lvcreate_params. Also use lp->voriginsize
instread of arg_count(). These refactorings make it easier to move the
bulk of _lvcreate into the library.
Dave Wysochanski [Sun, 26 Jul 2009 01:54:40 +0000 (01:54 +0000)]
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.
Dave Wysochanski [Sun, 26 Jul 2009 01:54:20 +0000 (01:54 +0000)]
Move ORPHAN_VG lock outside pvcreate_single.
The implicit pvcreate require either moving the ORPHAN_VG lock outside
pvcreate_single or somehow having the function know or detect whether
the ORPHAN_VG lock is already held.
With this change we now have vgcreate/vgextend liblvm functions.
Note that this changes the lock order of the following functions as the
orphan lock is now obtained first. With our policy of non-blocking
second locks, this should not be a problem.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Dave Wysochanski [Thu, 23 Jul 2009 23:40:05 +0000 (23:40 +0000)]
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>
Dave Wysochanski [Thu, 23 Jul 2009 23:39:02 +0000 (23:39 +0000)]
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>
Dave Wysochanski [Thu, 23 Jul 2009 23:37:24 +0000 (23:37 +0000)]
Add list structure definitions for liblvm objects.
- pv_t, vg_t, lv_t
- include libdevmapper.h: needed for struct dm_list
These list structures will be needed in later APIs to return a list of
handles to one object, given another object. For example, lvm_vg_list_lvs()
will return a list of LV handles (lv_t's) given a VG handle (vg_t). We
need a structure to do this so we define the LV structure, as well as the
other structures at this point.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Dave Wysochanski [Thu, 23 Jul 2009 01:20:22 +0000 (01:20 +0000)]
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.
Dave Wysochanski [Wed, 22 Jul 2009 22:24:16 +0000 (22:24 +0000)]
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>
Dave Wysochanski [Wed, 22 Jul 2009 16:49:54 +0000 (16:49 +0000)]
Update api/test/vgtest.c error handling.
Reverts some of my 'cleanup' from last night. For now we will use pass/fail
on API calls (either 'int' return or NULL/non-NULL handle), then use
lvm_errno() to get more specific errors.
After rebasing the cluster logging code, adjustments need to be
made to compensate for the changes in the kernel-side component
that recently went upstream. (Things like: renamed structures,
removal of structure fields, and changes to arguments passed
between userspace and kernel.)
Rebasing the cluster log daemon code from the most current
sources in the 'cluster' tree. There have been a number of
bug fixes and I don't want to loose them.
Dave Wysochanski [Tue, 21 Jul 2009 10:41:47 +0000 (10:41 +0000)]
Fix compile warnings in vgcreate liblvm api unit test case.
Use const and PRIu64.
Signed-off-by: Thomas Woerner <twoerner@redhat.com> Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Author: Thomas Woerner <twoerner@redhat.com>
Committer: Dave Wysochanski <dwysocha@redhat.com>
Dave Wysochanski [Thu, 16 Jul 2009 20:18:16 +0000 (20:18 +0000)]
Remove 'is already' message from vg_set_* functions.
These messages are unnecessary in the set functions. We check for this
condition and print a message in the vgchange tool but not the library
functions.
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Dave Wysochanski [Thu, 16 Jul 2009 03:25:26 +0000 (03:25 +0000)]
Remove extraneous messages for extent_size and alloc_policy upon vgcreate.
When converting to the new liblvm functions, the vgcreate code path
changed to create a new vg, then set values. As a result of this
change, and the fact that we give a user a message if they try to
set the same value of a VG attribute (extent_size, alloc_policy, etc),
you'll see these 2 extraneous "is already" messages with vgcreate:
tools/lvm vgcreate vg2 /dev/loop2
Physical extent size of VG vg2 is already 4.00 MB
Volume group allocation policy is already normal
Volume group "vg2" successfully created
Signed-off-by: Dave Wysochanski <dwysocha@redhat.com>
Author: Dave Wysochanski <dwysocha@redhat.com>
Dave Wysochanski [Thu, 16 Jul 2009 03:07:45 +0000 (03:07 +0000)]
Change default errno value to 0 (no error) and add prototypes in lvm.h
Since we are using errno values, we should use '0' as a default value
which indicates a non-error, rather than defining some made-up default
value that is not defined in errno. If we need to deviate from errno
values, this will most likely indicate a flaw in our design.
Add prototypes for lvm_errno and lvm_errmsg inside lvm.h and provide
a basic description of their function. This fixes a couple compile
warnings.
Add lvm_errno and lvm_errmsg to liblvm to obtain failure information.
Change create_toolcontext to still return an object if it fails part-way.
Add EUNCLASSIFIED (-1) as the default LVM errno code.
Store any errno and error messages issued while processing each command.
(Enabled by default while we test it, but in due course we'll only store
the error messages when we need to.)