summaryrefslogtreecommitdiff
path: root/tools/pvresize.c
Commit message (Collapse)AuthorAgeFilesLines
* exported vg handlingDavid Teigland2019-06-251-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The exported VG checking/enforcement was scattered and inconsistent. This centralizes it and makes it consistent, following the existing approach for foreign and shared VGs/PVs, which are very similar to exported VGs/PVs. The access policy that now applies to foreign/shared/exported VGs/PVs, is that if a foreign/shared/exported VG/PV is named on the command line (i.e. explicitly requested by the user), and the command is not permitted to operate on it because it is foreign/shared/exported, then an access error is reported and the command exits with an error. But, if the command is processing all VGs/PVs, and happens to come across a foreign/shared/exported VG/PV (that is not explicitly named on the command line), then the command silently skips it and does not produce an error. A command using tags or --select handles inaccessible VGs/PVs the same way as a command processing all VGs/PVs, and will not report/return errors if these inaccessible VGs/PVs exist. The new policy fixes the exit codes on a somewhat random set of commands that previously exited with an error if they were looking at all VGs/PVs and an exported VG existed on the system. There should be no change to which commands are allowed/disallowed on exported VGs/PVs. Certain LV commands (lvs/lvdisplay/lvscan) would previously not display LVs from an exported VG (for unknown reasons). This has not changed. The lvm fullreport command would previously report info about an exported VG but not about the LVs in it. This has changed to include all info from the exported VG.
* locking: unify global lock for flock and lockdDavid Teigland2019-04-291-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There have been two file locks used to protect lvm "global state": "ORPHANS" and "GLOBAL". Commands that used the ORPHAN flock in exclusive mode: pvcreate, pvremove, vgcreate, vgextend, vgremove, vgcfgrestore Commands that used the ORPHAN flock in shared mode: vgimportclone, pvs, pvscan, pvresize, pvmove, pvdisplay, pvchange, fullreport Commands that used the GLOBAL flock in exclusive mode: pvchange, pvscan, vgimportclone, vgscan Commands that used the GLOBAL flock in shared mode: pvscan --cache, pvs The ORPHAN lock covers the important cases of serializing the use of orphan PVs. It also partially covers the reporting of orphan PVs (although not correctly as explained below.) The GLOBAL lock doesn't seem to have a clear purpose (it may have eroded over time.) Neither lock correctly protects the VG namespace, or orphan PV properties. To simplify and correct these issues, the two separate flocks are combined into the one GLOBAL flock, and this flock is used from the locking sites that are in place for the lvmlockd global lock. The logic behind the lvmlockd (distributed) global lock is that any command that changes "global state" needs to take the global lock in ex mode. Global state in lvm is: the list of VG names, the set of orphan PVs, and any properties of orphan PVs. Reading this global state can use the global lock in sh mode to ensure it doesn't change while being reported. The locking of global state now looks like: lockd_global() previously named lockd_gl(), acquires the distributed global lock through lvmlockd. This is unchanged. It serializes distributed lvm commands that are changing global state. This is a no-op when lvmlockd is not in use. lockf_global() acquires an flock on a local file. It serializes local lvm commands that are changing global state. lock_global() first calls lockf_global() to acquire the local flock for global state, and if this succeeds, it calls lockd_global() to acquire the distributed lock for global state. Replace instances of lockd_gl() with lock_global(), so that the existing sites for lvmlockd global state locking are now also used for local file locking of global state. Remove the previous file locking calls lock_vol(GLOBAL) and lock_vol(ORPHAN). The following commands which change global state are now serialized with the exclusive global flock: pvchange (of orphan), pvresize (of orphan), pvcreate, pvremove, vgcreate, vgextend, vgremove, vgreduce, vgrename, vgcfgrestore, vgimportclone, vgmerge, vgsplit Commands that use a shared flock to read global state (and will be serialized against the prior list) are those that use process_each functions that are based on processing a list of all VG names, or all PVs. The list of all VGs or all PVs is global state and the shared lock prevents those lists from changing while the command is processing them. The ORPHAN lock previously attempted to produce an accurate listing of orphan PVs, but it was only acquired at the end of the command during the fake vg_read of the fake orphan vg. This is not when orphan PVs were determined; they were determined by elimination beforehand by processing all real VGs, and subtracting the PVs in the real VGs from the list of all PVs that had been identified during the initial scan. This is fixed by holding the single global lock in shared mode while processing all VGs to determine the list of orphan PVs.
* pvresize: update messageZdenek Kabelac2018-06-081-1/+1
| | | | | | There is always at least PV header update even if the size of PV remains same (so it's not really resized). Try to make it a slightly less confusing.
* pvcreate: add prompt when setting dev sizeDavid Teigland2017-04-271-2/+2
| | | | | | | | | | If the device size does not match the size requested by --setphysicalvolumesize, then prompt the user. Make the pvcreate checking/prompting code handle multiple prompts for the same device, since the new prompt can be in addition to the existing prompt when the PV is in a VG.
* pvresize: Prompt when non-default size supplied.Alasdair G Kergon2017-04-271-1/+1
| | | | | Seek confirmation before changing the PV size to one that differs from the underlying block device.
* toollib: add 'parent' field to processing_handle; init report format only if ↵Peter Rajnoha2016-06-201-1/+1
| | | | | | | | | | | | | there's no parent If there's parent processing handle, we don't need to create completely new report group and status report - we'll just reuse the one already initialized for the parent. Currently, the situation where this matter is when doing internal report to do the selection for processing commands where we have parent processing handle for the command itself and processing handle for the selection part (that is selection for non-reporting tools).
* pvchange, pvresize: move exported VG checkDavid Teigland2016-03-101-2/+6
| | | | | | | | | | | | | Allow pvchange and pvresize to process exported VGs, and have them check for the exported state in their single function. Previously, the exported VG state would trigger a failure in vg_read()/ignore_vg() because the VGs are being read with READ_FOR_UPDATE. Because these commands read all VGs to search for the intended PVs, any exported VG would trigger a failure, even if it was not related to the intended PV.
* dbus: add notification from commandsDavid Teigland2016-03-071-0/+2
| | | | | | | When a command modifies a PV or VG, or changes the activation state of an LV, it will send a dbus notification when the command is finished. This can be enabled/disabled with a config setting.
* toollib: add two phase pv processing codeDavid Teigland2016-02-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is common code for handling PV create/remove that can be shared by pvcreate/vgcreate/vgextend/pvremove. This does not change any commands to use the new code. - Pull out the hidden equivalent of process_each_pv into an actual top level process_each_pv. - Pull the prompts to the top level, and do not run any prompts while locks are held. The orphan lock is reacquired after any prompts are done, and the devices being created are checked for any change made while the lock was not held. Previously, pvcreate_vol() was the shared function for creating a PV for pvcreate, vgcreate, vgextend. Now, it will be toollib function pvcreate_each_device(). pvcreate_vol() was called effectively as a helper, from within vgcreate and vgextend code paths. pvcreate_each_device() will be called at the same level as other process_each functions. One of the main problems with pvcreate_vol() is that it included a hidden equivalent of process_each_pv for each device being created: pvcreate_vol() -> _pvcreate_check() -> find_pv_by_name() -> get_pvs() -> get_pvs_internal() -> _get_pvs() -> get_vgids() -> /* equivalent to process_each_pv */ dm_list_iterate_items(vgids) vg = vg_read_internal() dm_list_iterate_items(&vg->pvs) pvcreate_each_device() reorganizes the code so that each-VG-each-PV loop is done once, and uses the standard process_each_pv function at the top level of the function.
* doc: change fsf addressZdenek Kabelac2016-01-211-1/+1
| | | | | Hmm rpmlint suggest fsf is using a different address these days, so lets keep it up-to-date
* pvchange, pvresize: fix lockd_gl() usageDavid Teigland2016-01-181-2/+5
| | | | | | | | When an orphan PV is changed/resized, the lvmlockd global lock is converted from sh to ex. If the command is changing two orphan PVs, the conversion to ex should be done only once.
* Add lvmlockddev-dct-lvmlockd-AZDavid Teigland2015-07-021-0/+8
|
* cleanup: drop unused value assignZdenek Kabelac2015-02-191-1/+1
| | | | | | | | | | | | | Dop unused value assignments. Unknown is detected via other combination (!linear && !striped). Also change the log_error() message into a warning, since the function is not really returning error, but still keep the INTERNAL_ERROR. Ret value is always set later.
* cleanup: remove deallocate_handle_root arg from destroy_procesing_handle fnwPeter Rajnoha2015-02-131-1/+1
|
* cleanup: replace static struct processing_handle initializer with common ↵Peter Rajnoha2015-02-131-5/+11
| | | | | | | | | | | | | | init_processing_handle It's cleaner this way - do not mix static and dynamic (init_processing_handle) initializers. Use the dynamic one everywhere. This makes it easier to manage the code - there are no "exceptions" then and we don't need to take care about two ways of initializing the same thing - just use one common initializer throughout and it's clear. Also, add more comments, mainly in the report_for_selection fn explaining what is being done and why with respect to the processing_handle and selection_handle.
* toollib: initialize handles (including reporting for selection) for ↵Peter Rajnoha2015-02-101-4/+7
| | | | | | | | _select_match_* used in process_each_* fns Call _init_processing_handle, _init_selection_handle and _destroy_processing_handle in process_each_* and related functions to set up and destroy handles used while processing items.
* toollib: replace void *handle with struct processing_handle for use in ↵Peter Rajnoha2015-02-101-3/+6
| | | | | | | | | | | | | | | | | | processing functions (process_each_*/process_single_* and related) This patch replaces "void *handle" with "struct processing_handle *handle" in process_each_*, process_single_* and related functions. The struct processing_handle consists of two handles inside now: - the "struct selection_handle *selection_handle" used for applying selection criteria while processing process_each_*, process_single_* and related functions (patches using this logic will follow) - the "void* custom_handle" (this is actually the original handle used before this patch - a pointer to custom data passed into process_each_*, process_single_* and related functions).
* cleanup: validate pointersZdenek Kabelac2014-11-131-0/+4
| | | | Mostly on almost impossible to happen paths - but stay safe.
* toollib: Rewrite process_each_pv.David Teigland2014-10-071-1/+1
| | | | | | | | Process PVs by iterating through VGs, then iterating through devices if the command needs to process non-PV devices. The process_single function can always use the VG and PV args. [Committed by agk with cosmetic changes and tweaks.]
* pvresize: fail exit code for negative sizeZdenek Kabelac2014-03-251-1/+1
| | | | Pvresize with negative value retuns invalid cmd line exit code.
* tools: remove metadata-exported.hAlasdair G Kergon2013-07-091-1/+0
| | | | metadata-exported.h is included by tools.h
* tools: remove metadata.h from pvresize/vgckAlasdair G Kergon2013-07-091-1/+0
|
* liblvm: Moved additional pv resize codeTony Asleson2013-07-021-110/+2
| | | | | | | | | | | | 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>
* cleanup: introduce return_ECMD_FAILED macroZdenek Kabelac2013-07-011-5/+3
| | | | | | Use shortening macro for common code sequence stack; return ECMD_FAILED;
* locking: Make it possible to pass down an LV to activation code.Petr Rockai2013-06-101-1/+1
| | | | | | | Previously, we have relied on UUIDs alone, and on lvmcache to make getting a "new copy" of VG metadata fast. If the code which triggers the activation has the correct VG metadata at hand (the version which is currently on disk), it can now hand it to the activation code directly.
* config: add silent modeAlasdair G Kergon2012-08-251-3/+3
| | | | | | | | | | | | | | | | Accept -q as the short form of --quiet. Suppress non-essential standard output if -q is given twice. Treat log/silent in lvm.conf as equivalent to -qq. Review all log_print messages and change some to log_print_unless_silent. When silent, the following commands still produce output: dumpconfig, lvdisplay, lvmdiskscan, lvs, pvck, pvdisplay, pvs, version, vgcfgrestore -l, vgdisplay, vgs. [Needs checking.] Non-essential messages are shifted from log level 4 to log level 5 for syslog and lvm2_log_fn purposes.
* Using enum types for enumsZdenek Kabelac2012-02-281-1/+1
| | | | alloc_policy_t, dm_string_mangling_t, percent_range_t, sign_t
* Replace free_vg with release_vgZdenek Kabelac2011-08-101-2/+2
| | | | | | | | Move the free_vg() to vg.c and replace free_vg with release_vg and make the _free_vg internal. Patch is needed for sharing VG in vginfo cache so the release_vg function name is a better fit here.
* Defer writing PV labels to vg_write.Alasdair Kergon2011-06-011-1/+1
| | | | Store label_sector only in struct physical_volume.
* Add new free_pv_fid fn and use it throughout to free all attached fids.Peter Rajnoha2011-03-111-0/+2
| | | | | | | | Since format instances will use own memory pool, it's necessary to properly deallocate it. For now, only fid is deallocated. The PV structure itself still uses cmd mempool mostly, but anytime we'd like to add a mempool in the struct physical_volume, we can just rename this fn to free_pv and add the code (like we have free_vg fn for VGs).
* Add a hint for manual revert if there's an error in pv_write, vg_write, ↵Peter Rajnoha2011-02-281-1/+6
| | | | vg_commit for pvresize.
* Allow non-orphan PVs with two metadata areas to be resized.Peter Rajnoha2011-02-281-4/+11
| | | | | | | | | We allow writing non-orphan PVs only for resize now. The "orphan PV" assert in pv_write fn uses the "allow_non_orphan" parameter to control this assert. However, we should find a more elaborate solution so we can remove this restriction altogether (pv_write together with vg_write is not atomic, we need to find a safe mechanism so there's an easy revert possible in case of an error).
* Change pvresize code to work with new metadata handling interface and allowPeter Rajnoha2011-02-211-50/+3
| | | | resizing a PV with two metadata areas.
* Change pv_write code to work with the changes in metadata handling interfacePeter Rajnoha2011-02-211-1/+1
| | | | and changes in format_instance.
* Remove useless mdas parameter for pv_read (from now on, we store mdas in aPeter Rajnoha2011-02-211-5/+3
| | | | format instance)
* Replace PV_MIN_SIZE with function pv_min_size()Zdenek Kabelac2011-02-181-3/+3
| | | | | | | | | | | | | | | | | Add configurable option to define minimal size of of block device usable as a PV. pv_min_size() is added to lvm-globals and it's being initialized through _process_config. Macro PV_MIN_SIZE is unused and removed. New define DEFAULT_PV_MIN_SIZE_KB is added to lvm-global and unlike PV_MIN_SIZE it uses KB units. Should help users with various slow devices attached to the system, which cannot be easily filtered out (like FDD on /dev/sdX): https://bugzilla.redhat.com/show_bug.cgi?id=644578
* Rename vg_release to free_vg.Alasdair Kergon2010-12-081-2/+2
|
* Print vg_name and do not to access vg->nameZdenek Kabelac2010-10-251-1/+1
| | | | | Reported by clang as: Logic error Dereference of null pointer Replace pointer dereference with vg_name.
* Accept orphan VG names as parameters to lock_vol() and related functions.Alasdair Kergon2010-05-191-19/+16
|
* Fix unlocking vg in some pvresize and toollib error paths.Zdenek Kabelac2009-12-111-2/+6
|
* Add lots of missing stack debug messages to tools.Alasdair Kergon2009-09-141-1/+3
| | | | | Make readonly locking available as locking type 4. Fix readonly locking to permit writeable global locks (for vgscan). (2.02.49)
* Port process_each_pv to new vg_read.Petr Rockai2009-07-151-1/+1
|
* Fix vg_read() error paths to properly release upon vg_read_error().Dave Wysochanski2009-07-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | Fix vg_read() error paths to properly release upon vg_read_error(). Note that in the iterator paths (process_each_*()), we release inside the iterator so no individual cleanup is needed. However there are a number of other places we missed the cleanup. Proper cleanup when vg_read_error() is true should be calling vg_release(vg), since there should be no locks held if we get an error (except in certain special cases, which IMO we should work to remove from the code). Unfortunately the testsuite is unable to detect these types of memory leaks. Most of them can be easily seen if you try an operation (e.g. lvcreate) with a volume group that does not exist. Error message looks like this: Volume group "vg2" not found You have a memory leak (not released memory pool): [0x1975eb8] You have a memory leak (not released memory pool): [0x1975eb8] Author: Dave Wysochanski <dwysocha@redhat.com>
* Convert the straight instances of vg_lock_and_read to new vg_read(_for_update).Dave Wysochanski2009-07-011-13/+2
| | | | | | | Sun May 3 11:40:51 CEST 2009 Petr Rockai <me@mornfall.net> * Convert the straight instances of vg_lock_and_read to new vg_read(_for_update). Rebased 6/26/09 by Dave W.
* revert last patch - let's do a release firstAlasdair Kergon2009-06-261-2/+13
|
* Convert the straight instances of vg_lock_and_read to new vg_read(_for_update).Dave Wysochanski2009-06-261-13/+2
| | | | | | | | | Sun May 3 11:40:51 CEST 2009 Petr Rockai <me@mornfall.net> * Convert the straight instances of vg_lock_and_read to new vg_read(_for_update). Author: Petr Rockai <prockai@redhat.com> Committer: Dave Wysochanski <dwysocha@redhat.com>
* Properly release VG memory pool in all CLI tools.Milan Broz2009-04-101-37/+27
|
* Try to avoid full rescan if label scan is enough.Milan Broz2009-02-251-1/+1
|
* Separate PV label attributes which do not need parse metadata when reporting.Milan Broz2009-02-091-1/+1
| | | | | | | | | | When reporting explicitly label attributes (pv_uuid for example), we do not need to read metadata. This patch separate the label fileds and removes scan_vgs_for_pvs in process_each_pv() if not needed. (There should be no user visible change in output.)
* Rename vg_read() to vg_read_internal(). (mornfall)Alasdair Kergon2009-01-261-1/+1
|