summaryrefslogtreecommitdiff
path: root/tools/pvremove.c
Commit message (Collapse)AuthorAgeFilesLines
* exit with error when --devicesfile name doesn't existDavid Teigland2022-07-061-1/+2
|
* pvcreate: call label scan prior to pvcreate_each_deviceDavid Teigland2019-04-301-0/+2
| | | | | | and don't call it from inside pvcreate_each_device. This avoids having to repeat it for users of pvcreate_each_device (pvcreate/pvremove/vgcreate/vgextend.)
* locking: unify global lock for flock and lockdDavid Teigland2019-04-291-12/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* add device hints to reduce scanningDavid Teigland2019-01-151-0/+2
| | | | | | | Save the list of PVs in /run/lvm/hints. These hints are used to reduce scanning in a number of commands to only the PVs on the system, or only the PVs in a requested VG (rather than all devices on the system.)
* pvremove: skip lvmlockd locks for forced clearingDavid Teigland2018-05-301-2/+11
| | | | | pvremove -ff to force clear a PV shouldn't care if lvmlockd locks fail.
* lvmetad: two phase vg_updateDavid Teigland2016-06-281-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, a command sent lvmetad new VG metadata in vg_commit(). In vg_commit(), devices are suspended, so any memory allocation done by the command while sending to lvmetad, or by lvmetad while updating its cache could deadlock if memory reclaim was triggered. Now lvmetad is updated in unlock_vg(), after devices are resumed. The new method for updating VG metadata in lvmetad is in two phases: 1. In vg_write(), before devices are suspended, the command sends lvmetad a short message ("set_vg_info") telling it what the new VG seqno will be. lvmetad sees that the seqno is newer than the seqno of its cached VG, so it sets the INVALID flag for the cached VG. If sending the message to lvmetad fails, the command fails before the metadata is committed and the change is not made. If sending the message succeeds, vg_commit() is called. 2. In unlock_vg(), after devices are resumed, the command sends lvmetad the standard vg_update message with the new metadata. lvmetad sees that the seqno in the new metadata matches the seqno it saved from set_vg_info, and knows it has the latest copy, so it clears the INVALID flag for the cached VG. If a command fails between 1 and 2 (after committing the VG on disk, but before sending lvmetad the new metadata), the cached VG retains the INVALID flag in lvmetad. A subsequent command will read the cached VG from lvmetad, see the INVALID flag, ignore the cached copy, read the VG from disk instead, update the lvmetad copy with the latest copy from disk, (this clears the INVALID flag in lvmetad), and use the correct VG metadata for the command. (This INVALID mechanism already existed for use by lvmlockd.)
* 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).
* replace pvcreate_params with pvcreate_each_paramsDavid Teigland2016-02-251-2/+2
| | | | | | | | | | "pvcreate_each_params" was a temporary name used to transition from the old "pvcreate_params". Remove the old pvcreate_params struct and rename the new pvcreate_each_params struct to pvcreate_params. Rename various pvcreate_each_params terms to simply pvcreate_params.
* pvremove: use common toollib processing codeDavid Teigland2016-02-251-15/+33
| | | | | Use the new pvcreate_each_device() function from toollib.
* 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
* Add lvmlockddev-dct-lvmlockd-AZDavid Teigland2015-07-021-0/+4
|
* pvremove: Avoid metadata re-reads & related error messages.Petr Rockai2015-01-061-7/+8
|
* cleanup: Remove metadata.h from tools dir.Alasdair G Kergon2014-09-171-1/+0
| | | | | metadata.h is meant to be internal to the library. metadata-exported.h contains the things needed by tools.
* pvremove: Catch CTRL-c during prompts.Alasdair G Kergon2014-04-291-0/+2
|
* pvremove: stack traceZdenek Kabelac2013-07-081-3/+5
| | | | | Stack trace error. Remove unused var.
* lvresize: separate validation from actionAlasdair G Kergon2013-07-061-4/+2
| | | | | | | | | 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.
* lvm2app: Implement lvm_pv_remove V2Tony Asleson2013-07-021-126/+7
| | | | | | | | | 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>
* cleanup: move string in the use-placeZdenek Kabelac2013-06-161-4/+3
|
* 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-2/+2
| | | | | | | | | | | | | | | | 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.
* activate: add autoactivation hooksPeter Rajnoha2012-06-281-1/+1
| | | | | | | | | | | | | | | | Define an 'activation_handler' that gets called automatically on PV appearance/disappearance while processing the lvmetad_pv_found and lvmetad_pv_gone functions that are supposed to update the lvmetad state based on PV availability state. For now, the actual support is for PV appearance only, leaving room for PV disappearance support as well (which is a more complex problem to solve as this needs to count with possible device stack). Add a new activation change mode - CHANGE_AAY exposed as '--activate ay/-aay' argument ('activate automatically'). Factor out the vgchange activation functionality for use in other tools (like pvscan...).
* Scan all devices for lvmetad if 'pvscan --cache' used without device list.Alasdair Kergon2012-03-031-2/+1
|
* Allow multiple device names with pvscan --lvmetad.Alasdair Kergon2012-03-021-1/+1
| | | | | | Hold global lock in pvscan --lvmetad. (This might need refinement.) Add PV name to "PV gone" messages. Adjust some log message severities. (More changes needed.)
* Reinstate error if e.g. daemon comms fails.Alasdair Kergon2012-03-021-1/+2
|
* Replace goto with just log_debugZdenek Kabelac2012-03-011-1/+1
| | | | | FIXME: temporal quick hack to make things green There might be a better reaction.
* Check return values after calling new lvmetad fnsAlasdair Kergon2012-02-281-6/+7
| | | | (Haven't checked error path handling though)
* The lvmetad client-side integration. Only active when use_lvmetad = 1 is set inPetr Rockai2012-02-231-0/+2
| | | | lvm.conf *and* lvmetad is running.
* Move the core of the lib/config/config.c functionality into libdevmapper,Petr Rockai2011-08-301-1/+1
| | | | | | | leaving behind the LVM-specific parts of the code (convenience wrappers that handle `struct device` and `struct cmd_context`, basically). A number of functions have been renamed (in addition to getting a dm_ prefix) -- namely, all of the config interface now has a dm_config_ prefix.
* Defer writing PV labels to vg_write.Alasdair Kergon2011-06-011-2/+2
| | | | 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-5/+13
| | | | | | | | 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).
* Improve pvremove error message when PV belongs to a VG.Alasdair Kergon2011-02-281-2/+2
|
* Remove useless mdas parameter for pv_read (from now on, we store mdas in aPeter Rajnoha2011-02-211-6/+4
| | | | format instance)
* Suppress 'No PV label' message when removing several PVs without mdas.Alasdair Kergon2010-11-231-1/+1
|
* Add escape sequence for ':' and '@' found in device names used as PVs.Peter Rajnoha2010-09-231-0/+1
|
* Remove assumption that --yes must be used only in --force modeMilan Broz2010-08-191-5/+0
| | | | | | | | This is not only undocumented but is is also in violation with --help documentation. Using --yes without --force is useful in pvcreate when it detects old signature.
* Use __attribute__ consistently throughout.Alasdair Kergon2010-07-091-1/+1
|
* Fix tools to report error when stopped by user.Milan Broz2009-12-031-1/+1
| | | | (And do not produce internal error message.)
* Try to avoid full rescan if label scan is enough.Milan Broz2009-02-251-2/+2
|
* Right, a simple build (without options) is working again.Alasdair Kergon2008-11-031-3/+3
|
* fix pvremove for pvs without mdasAlasdair Kergon2008-07-311-1/+23
|
* reinstate lost FIXMEAlasdair Kergon2008-07-241-0/+2
| | | | | - only if kernel gives the info, not to be worked out in userspace - with lvm.conf option to enable/disable the check
* Remove dead code, is_lvm_partition() - no functional change.Dave Wysochanski2008-07-231-7/+0
| | | | | This code does nothing. The function is #defined to 1 which ensures the only two if statements referencing it will never be true.
* FIXMEs for case where dm itself has device openAlasdair Kergon2007-11-221-0/+1
|
* Fix orphan-related locking in pvdisplay and pvs.Alasdair Kergon2007-11-021-5/+6
| | | | | | | | Fix missing VG unlocks in some pvchange error paths. Add some missing validation of VG names. Rename validate_vg_name() to validate_new_vg_name(). Change orphan lock to VG_ORPHANS. Change format1 to use ORPHAN as orphan VG name.
* Fix inconsistent licence notices: executables are GPLv2; libraries LGPLv2.1.Alasdair Kergon2007-08-201-3/+3
|
* Make warnings go to stderr. Change log_warn to that effect, log_printPetr Rockai2007-06-281-1/+1
| | | | continues to send messages to stdout.
* Remove get_ prefix from get_pv_* functionsDave Wysochanski2007-06-151-3/+3
|
* Fix inverted logic on last checkin for pvremoveDave Wysochanski2007-06-141-1/+1
|
* convert pv->vg_name[0] to \!is_orphan(pv)Dave Wysochanski2007-06-141-4/+4
|
* Convert pv->vg_name to get_pv_vg_nameDave Wysochanski2007-06-141-1/+1
|