1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
Commit Graph

215 Commits

Author SHA1 Message Date
Tony Asleson
91f737383c lvm2app: Add signed numerical property values
Currently lvm2app properties have the following structure:

typedef struct lvm_property_value {
        uint32_t is_settable:1;
        uint32_t is_string:1;
        uint32_t is_integer:1;
        uint32_t is_valid:1;
        uint32_t padding:28;
        union {
                const char *string;
                uint64_t integer;
        } value;
} lvm_property_value_t;

which assumes that numerical values were in the range of 0 to 2**64-1.  However,
some of the properties were 'signed', like LV major/minor numbers and some
reserved values for properties that represent percentages.  Thus when the
values were retrieved they were in two's complement notation.  So for a -1
major number the API user would get a value of 18446744073709551615.  The
API user could cast the returned value to an int64_t to handle this, but that
requires the API developer to look at the source code and determine when it
should be done.

This change modifies the return property structure to:

typedef struct lvm_property_value {
        uint32_t is_settable:1;
        uint32_t is_string:1;
        uint32_t is_integer:1;
        uint32_t is_valid:1;
        uint32_t is_signed:1;
        uint32_t padding:27;
        union {
                const char *string;
                uint64_t integer;
                int64_t signed_integer;
        } value;
} lvm_property_value_t;

With this addition the API user can interrogate that the value is numerical,
(is_integer = 1) and subsequently check if it's signed (is_signed = 1) too.
If signed, then the API developer should use the union's signed_integer to
avoid casting.

This change maintains backwards compatibility as the structure size remains
unchanged and integer value remains unchanged.  Only the additional bit
taken from the pad is utilized.

Bugzilla reference:
https://bugzilla.redhat.com/show_bug.cgi?id=838257

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2015-05-06 08:51:04 -05:00
Zdenek Kabelac
74a81a4577 lvm2app: call fin_locking in lvm_quit
lvm_quit() function should also close locking.
Fixes unclosed socket connecting clvmd.
2015-05-03 00:43:13 +02:00
Petr Rockai
e97023804a pvremove: Avoid metadata re-reads & related error messages. 2015-01-06 14:27:30 +01:00
Zdenek Kabelac
cb931eed72 cleanup: rename virtual_extents
Use standard 'virtual_extents' naming.
Move virtual_size into  'lcp' struct out of lvcreate_params.
2014-11-03 14:19:33 +01:00
Zdenek Kabelac
618d818c0d lvm2app: update to new lv_create_single API
lv_create_single is more type based.
2014-10-26 18:37:13 +01:00
Zdenek Kabelac
d13239b054 lvcreate: new validation code
Refactor lvcreate code.

Prefer to use arg_outside_list_is_set() so we get automatic 'white-list'
validation of supported options with different segment types.

Drop used lp->cache, lp->cache and use seg_is_cache(), seg_is_thin()

Draw clear border where is the last moment we could change create
segment type.

When segment type is given with --type - do not allow it to be changed
later.

Put together tests related to individual segment types.

Finish cache conversion at proper part of lv_manip code after
the vg_metadata are written - so we could correcly clean-up created
stripe LV for cache volume.
2014-10-24 16:39:32 +02:00
Zdenek Kabelac
27ff61d012 cleanup: rename _name, _lv and _size
Use some standard names for lv char * names, logical_volume * lv
and sizes internally.
2014-10-07 15:51:53 +02:00
Peter Rajnoha
00d8ab8492 refactor: make it possible to select what to check exactly when calling device_is_usable fn
Currently, there are 5 things that device_is_usable function checks
(for DM devices only, of course):
  - is device empty?
  - is device blocked? (mirror)
  - is device suspended?
  - is device composed of an error target?
  - is device name/uuid reserved?

If answer to any of these questions is "yes", then the device is not usable.
This patch just adds possibility to choose what to check for exactly - the
device_is_usable function now accepts struct dev_usable_check_params make
this selection possible. This is going to be used by subsequent patches.
2014-09-30 13:11:58 +02:00
Alasdair G Kergon
2360ce3551 cleanup: Use lv_is_ macros.
Use lv_is_* macros throughout the code base, introducing
lv_is_pvmove, lv_is_locked, lv_is_converting and lv_is_merging.

lv_is_mirror_type no longer includes pvmove.
2014-09-15 21:33:53 +01:00
Zdenek Kabelac
13fb02ff1f cleanup: ignore vg_name in /lib
Since  vg_name inside /lib function has already been ignored mostly
except for a few debug prints - make it and official internal API
feature.

vg_name is used only in  /tools while the VG is not yet openned,
and when  lvresize/lvcreate /lib function is called with VG pointer
already being used, then vg_name becomes irrelevant (it's not been
validated anyway).

So any internal user of lvcreate_params and lvresize_params does not
need to set vg_name pointer and may leave it NULL.
2014-06-30 12:21:36 +02:00
Peter Rajnoha
cfed0d09e8 report: select: refactor: move percent handling code to libdm for reuse 2014-06-17 16:27:21 +02:00
Peter Rajnoha
5abdb52fdc report: select: refactor: move str_list to libdm
The list of strings is used quite frequently and we'd like to reuse
this simple structure for report selection support too. Make it part
of libdevmapper for general reuse throughout the code.

This also simplifies the LVM code a bit since we don't need to
include and manage lvm-types.h anymore (the string list was the
only structure defined there).
2014-06-17 16:27:20 +02:00
Peter Rajnoha
1c4fe47308 lvm_init: don't use name mangling for LVM
LVM has restricter character set that is allowed for VG-LV names
and the dm names constructed do not contain any blacklisted characters
that would require name mangling.

Also, when any other device-mapper device is scanned that could
possibly contain such blacklisted characters, we reference the
device by its major:minor instead of dm name (e.g. _device_is_usable fn).
2014-05-22 10:00:19 +02:00
Zdenek Kabelac
c1faa4048a lvm2app: access params after its checked
Since params is checked for NULL, move code that dereferences
params after its check.
2014-02-11 18:50:37 +01:00
Jonathan Brassow
998af1a4fb Misc: Change name of lvcreate_params field - s/create_thin_pool/create_pool/
In preparation for other segment types that create and use "pools", we
s/create_thin_pool/create_pool/.  This way it is not awkward when creating
a cachepool, for example, to use "create_thin_pool".
2014-01-22 10:30:55 -06:00
Zdenek Kabelac
5f246bf768 liblvm: mark constant as unsigned 2014-01-08 12:04:41 +01:00
Tony Asleson
eaeb33abd4 liblvm: Save off and restore umask values
lvm has a default umask value in the config file that defaults
to 0077 which lvm changes to during normal operation.  This
causes a problem when the code is used as a library with
liblvm as it is changing the umask for the process.  This
patch saves off the current umask, sets to what is specified
in the config file and restores it what it was on library
function call exit.

The user is now free to change the umask in their application at
anytime including between library calls.

This fix address BZ:
https://bugzilla.redhat.com/show_bug.cgi?id=1012113

Tested by setting umask to 0777 and running the python unit
test and verifying that umask is still same value as expected
at the test completion and with a successful run.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-12-20 13:36:22 -06:00
Zdenek Kabelac
5a6794a2ce lv_remove_single: add silent arg
Support silence for removal message.
2013-12-04 14:30:25 +01:00
Peter Rajnoha
9bfc0be493 configure: add --enable-blkid_wiping 2013-11-27 15:48:16 +01:00
Peter Rajnoha
169b4c1586 lvcreate: recognize --wipesignatures arg
Recognize the new --wipesignatures arg in lvcreate that is supposed
to wipe known signatures if found on newly created LV.
2013-11-27 15:48:15 +01:00
Zdenek Kabelac
6ebbf19828 cleanup: drop unused header
Header is not used here.
2013-11-22 21:00:56 +01:00
Tony Asleson
12d5e53953 lvm2app: Remove forward declarations.
Remove the forward struct declaration.  This isn't needed for
implementing opaque data pointers.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-11-19 14:40:44 -06:00
Tony Asleson
fe5b538c14 lvm2app: Reset buffer after retrieving error message
The error buffer will stack error messages which is fine.  However,
once you retrieve the error messages it doesn't make sense to keep
appending for each additional error message when running in the
context of a library call.

This patch clears and resets the buffer after the user retrieves
the error message.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-11-19 14:40:42 -06:00
Tony Asleson
0dd247502a lvm2app: Add VG/LV name validation
C library portion for
https://bugzilla.redhat.com/show_bug.cgi?id=883689

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-11-19 14:40:39 -06:00
Tony Asleson
04304ba735 lvm2app: Add ability to create PV with args
Add a PV create which takes a paramters object that
has get/set method to configure PV creation.

Current get/set operations include:
- size
- pvmetadatacopies
- pvmetadatasize
- data_alignment
- data_alignment_offset
- zero

Reference: https://bugzilla.redhat.com/show_bug.cgi?id=880395

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-11-19 14:40:34 -06:00
Tony Asleson
c29c64f20d lvm2app: lvm_list_pvs_free seg. fault when no PVs
When the system has no PVs we don't have access to
the cmd pointer and it remains NULL which causes
a seg. fault when we try to free the VG lock.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-08-14 15:17:39 -05:00
Alasdair G Kergon
cf09cf0cd3 Revert "lvm2app: lvm_vg_list_lvs filter hidden LVs"
This reverts commit a2b5147600.

The function has behaved like this for a long time so let's
not change this part of the API.
2013-07-24 01:49:18 +01:00
Tony Asleson
a2b5147600 lvm2app: lvm_vg_list_lvs filter hidden LVs
The function lvm_vg_list_lvs was returning all logical
volumes, including *_tmeta and *_tdata.  Added check
to verify that LV is visible before including in list
of returned logical volumes.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-23 14:01:20 -05:00
Zdenek Kabelac
e0856393c8 cleanup: add explicit cast to proper enum type 2013-07-23 14:53:29 +02:00
Zdenek Kabelac
baada4316d liblvm: check lvmetad cache return values
Missing error path.
2013-07-22 12:41:21 +02:00
Zdenek Kabelac
dedec81d7b cleanup: do not return stack content
Return initialized struct in error path.
2013-07-22 12:41:21 +02:00
Zdenek Kabelac
90bdbcc201 liblvm: check extents_from_size
Since the function may fail, check for error.
(in release fix)
2013-07-22 12:41:21 +02:00
Zdenek Kabelac
ea68f08501 cleanup: remove unused headers 2013-07-22 12:41:21 +02:00
Tony Asleson
5b213492f8 lvm2api: Add missing files from prev commit.
Missing files for commit 0a048d5274612049467a3defd13de7aca2419137

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-12 17:46:15 -05:00
Tony Asleson
5227b65588 lvm2app: Add thin and thin pool lv creation
Add thin and thin pool lv creation support to lvm library

This is Mohan's thinp patch, re-worked to include suggestions
from Zdenek and Mohan.

Rework of commit 4d5de8322b
which uses refactored properties handling.

Based on work done by M. Mohan Kumar <mohan@in.ibm.com>

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-12 16:52:16 -05:00
Petr Rockai
8e4a3dd9cb lvm2api: Make the vg_list_* functions work with lvmetad (+ test). 2013-07-11 09:38:46 +02:00
Alasdair G Kergon
aaa9a68b2f metadata: cleanup comments and formatting 2013-07-09 12:34:48 +01:00
Alasdair G Kergon
8adddbf101 pvcreate: remove metadata.h header
Files in tools/ should only use metadata-exported.h not metadata.h.
Rename pvcreate_locked to pvcreate_single.
2013-07-09 02:37:56 +01:00
Alasdair G Kergon
dd302daf64 report: remove LV_CREATE_PARAMS report type
Remove LV_CREATE_PARAMS from lib/report as it is not a type of metadata.
Added by 4d5de8322b
2013-07-09 02:06:29 +01:00
Alasdair G Kergon
7c6526aae2 lvresize: separate validation from action
Start separating the validation from the action in the basic lvresize
code moved to the library.
Remove incorrect use of command line error codes from lvresize library
functions.  Move errors.h to tools directory to reinforce this,
exporting public versions of the error codes in lvm2cmd.h for dmeventd
plugins to use.
2013-07-06 03:28:21 +01:00
Zdenek Kabelac
9e79cca9e7 python: update coding style
Update code to match lvm coding standards
Disable/skip test - since it's accessing VGs available in the system.
Before reenable - validate it's not touching any PV outside those
created during test.
2013-07-05 17:20:57 +02:00
Tony Asleson
50db109e20 liblvm: Moved additional pv resize code
The pv resize code required that a lvm_vg_write be done
to commit the change.  When the method to add the ability
to list all PVs, including ones that are not assocated with
a VG we had no way for the user to make the change persistent.
Thus additional resize code was move and now liblvm calls into
a resize function that does indeed write the changes out, thus
not requiring the user to explicitly write out he changes.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:34 -05:00
Tony Asleson
40feaa7bbe python-lvm: Bug fixes from unit tests.
After the last rebase, existing unit test case was
run which uncovered a number of errors that required
attention.

Uninitialized variables and changes to type of numeric
return type were addressed.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:34 -05:00
Tony Asleson
49e3eecc33 lvm2app: Add thinp snapshot functionality
Added parameter object constructor for thinp and
changed the shapshot function to use it.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:34 -05:00
Tony Asleson
a7f3dbf904 lvm2app: Add function to retrieve the origin.
Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:34 -05:00
Tony Asleson
952605a8ea lvm2app: Add method to retrieve attr from lv.
Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:34 -05:00
Tony Asleson
6d6ccded35 lib2app: Added PV create. V2
V2: Correct call to lock_vol

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:34 -05:00
Tony Asleson
d079411051 lib2app: Fix warnings in lvm_list_pvs_free
Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:34 -05:00
Tony Asleson
bfa265f198 lvm2app: Set suppress to 1
Removes printing to stdout/stderr etc.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:34 -05:00
Tony Asleson
e33ac7b1ed lvm2app: Implement lvm_pv_remove V2
Code move and changes to support calling code from
command line and from library interface.

V2 Change lock_vol call

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2013-07-02 14:24:34 -05:00