summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* improve some warning messagesdev-dct-read-14David Teigland2019-04-112-6/+24
|
* remove unused or moved codeDavid Teigland2019-04-111-375/+2
| | | | | this would have been done as part of the prior commit, but 'diff' was becoming confused and made as mess.
* improve reading and repairing vg metadataDavid Teigland2019-04-1127-1287/+1332
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The fact that vg repair is implemented as a part of vg read has led to a messy and complicated implementation of vg_read, and limited and uncontrolled repair capability. This splits read and repair apart. Summary ------- - take all kinds of various repairs out of vg_read - vg_read no longer writes anything - vg_read now simply reads and returns vg metadata - vg_read ignores bad or old copies of metadata - vg_read proceeds with a single good copy of metadata - improve error checks and handling when reading - keep track of bad (corrupt) copies of metadata in lvmcache - keep track of old (seqno) copies of metadata in lvmcache - keep track of outdated PVs in lvmcache - vg_write will do basic repairs - new command vgck --updatemetdata will do all repairs Details ------- - In scan, do not delete dev from lvmcache if reading/processing fails; the dev is still present, and removing it makes it look like the dev is not there. Records are now kept about the problems with each PV so they be fixed/repaired in the appropriate places. - In scan, record a bad mda on failure, and delete the mda from mda in use list so it will not be used by vg_read or vg_write, only by repair. - In scan, succeed if any good mda on a device is found, instead of failing if any is bad. The bad/old copies of metadata should not interfere with normal usage while good copies can be used. - In scan, add a record of old mdas in lvmcache for later, do not repair them while reading, and do not let them prevent us from finding and using a good copy of metadata from elsewhere. One result is that "inconsistent metadata" is no longer a read error, but instead a record in lvmcache that can be addressed separate from the read. - Treat a dev with no good mdas like a dev with no mdas, which is an existing case we already handle. - Don't use a fake vg "handle" for returning an error from vg_read, or the vg_read_error function for getting that error number; just return null if the vg cannot be read or used, and an error_flags arg with flags set for the specific kind of error (which can be used later for determining the kind of repair.) - Saving an original copy of the vg metadata, for purposes of reverting a write, is now done explicitly in vg_read instead of being hidden in the vg_make_handle function. - When a vg is not accessible due to "access restrictions" but is otherwise fine, return the vg through the new error_vg arg so that process_each_pv can skip the PVs in the VG while processing. (This is a temporary accomodation for the way process_each_pv tracks which devs have been looked at, and can be dropped later when process_each_pv implementation dev tracking is changed.) - vg_read does not try to fix or recover a vg, but now just reads the metadata, checks access restrictions and returns it. (Checking access restrictions might be better done outside of vg_read, but this is a later improvement.) - Move vg_read/_vg_read and its helper functions to read.c (mainly so that the diff is cleaner and more readable.) - helper functions moved to read.c remain largley unchanged: _is_foreign_vg _check_pv_ext _check_devs_used_correspond_with_lv _check_devs_used_correspond_with_vg _destroy_fid _access_vg_clustered _allow_extra_system_id _access_vg_lock_type is_system_id_allowed _access_vg_systemid - _vg_read now simply makes one attempt to read metadata from each mda, and uses the most recent copy to return to the caller in the form of a 'vg' struct. (bad mdas were excluded during the scan and are not retried) (old mdas were not excluded during scan and are retried here) - vg_read uses _vg_read to get the latest copy of metadata from mdas, and then makes various checks against it to produce warnings, and to check if VG access is allowed (access restrictions include: writable, foreign, shared, clustered, missing pvs). - Things that were previously silently/automatically written by vg_read that are now done by vg_write, based on the records made in lvmcache during the scan and read: . clearing the missing flag . updating old copies of metadata . clearing outdated pvs . updating pv header flags - Bad/corrupt metadata are now repaired; they were not before. Test changes ------------ - A read command no longer writes the VG to repair it, so add a write command to do a repair. (inconsistent-metadata, unlost-pv) - When a missing PV is removed from a VG, and then the device is enabled again, vgck --updatemetadata is needed to clear the outdated PV before it can be used again, where it wasn't before. (lvconvert-repair-policy, lvconvert-repair-raid, lvconvert-repair, mirror-vgreduce-removemissing, pv-ext-flags, unlost-pv) Reading bad/old metadata ------------------------ - "bad metadata": the mda_header or metadata text has invalid fields or can't be parsed by lvm. This is a form of corruption that would not be caused by known failure scenarios. A checksum error is typically included among the errors reported. - "old metadata": a valid copy of the metadata that has a smaller seqno than other copies of the metadata. This can happen if the device failed, or io failed, or lvm failed while commiting new metadata to all the metadata areas. Old metadata on a PV that has been removed from the VG is the "outdated" case below. When a VG has some PVs with bad/old metadata, lvm can simply ignore the bad/old copies, and use a good copy. This is why there are multiple copies of the metadata -- so it's available even when some of the copies cannot be used. The bad/old copies do not have to be repaired before the VG can be used (the repair can happen later.) A PV with no good copies of the metadata simply falls back to being treated like a PV with no mdas; a common and harmless configuration. When bad/old metadata exists, lvm warns the user about it, and suggests repairing it using a new metadata repair command. Bad metadata in particular is something that users will want to investigate and repair themselves, since it should not happen and may indicate some other problem that needs to be fixed. PVs with bad/old metadata are not the same as missing devices. Missing devices will block various kinds of VG modification or activation, but bad/old metadata will not. Previously, lvm would attempt to repair bad/old metadata whenever it was read. This was unnecessary since lvm does not require every copy of the metadata to be used. It would also hide potential problems that should be investigated by the user. It was also dangerous in cases where the VG was on shared storage. The user is now allowed to investigate potential problems and decide how and when to repair them. Repairing bad/old metadata -------------------------- When label scan sees bad metadata in an mda, that mda is removed from the lvmcache info->mdas list. This means that vg_read will skip it, and not attempt to read/process it again. If it was the only in-use mda on a PV, that PV is treated like a PV with no mdas. It also means that vg_write will also skip the bad mda, and not attempt to write new metadata to it. The only way to repair bad metadata is with the metadata repair command. When label scan sees old metadata in an mda, that mda is kept in the lvmcache info->mdas list. This means that vg_read will read/process it again, and likely see the same mismatch with the other copies of the metadata. Like the label_scan, the vg_read will simply ignore the old copy of the metadata and use the latest copy. If the command is modifying the vg (e.g. lvcreate), then vg_write, which writes new metadata to every mda on info->mdas, will write the new metadata to the mda that had the old version. If successful, this will resolve the old metadata problem (without needing to run a metadata repair command.) Outdated PVs ------------ An outdated PV is a PV that has an old copy of VG metadata that shows it is a member of the VG, but the latest copy of the VG metadata does not include this PV. This happens if the PV is disconnected, vgreduce --removemissing is run to remove the PV from the VG, then the PV is reconnected. In this case, the outdated PV needs have its outdated metadata removed and the PV used flag needs to be cleared. This repair will be done by the subsequent repair command. It is also done if vgremove is run on the VG. MISSING PVs ----------- When a device is missing, most commands will refuse to modify the VG. This is the simple case. More complicated is when a command is allowed to modify the VG while it is missing a device. When a VG is written while a device is missing for one of it's PVs, the VG metadata includes the MISSING_PV flag on the PV with the missing device. When the VG is next used, it needs to be treated as if this PV with the MISSING flag is still missing, even if the device has reappeared. vgreduce --removemissing will remove PVs with missing devices, or PVs with the MISSING flag where the device has reappeared. vgextend --restoremissing will clear the MISSING flag on PVs where the device has reappeared, allowing the VG to be used normally. This must be done with caution since the reappeared device may have old data that is inconsistent with data on other PVs. Bad mda repair -------------- The new command: vgck --updatemetadata VG first uses vg_write to repair old metadata, and other basic issues mentioned above (old metadata, outdated PVs, pv_header flags, MISSING_PV flags). It will also go further and repair bad metadata: . text metadata that has a bad checksum . text metadata that is not parsable . corrupt mda_header checksum and version fields
* add a warning message when updating old metadataDavid Teigland2019-04-111-0/+21
| | | | in an mda that had previously not been updated
* vgcfgbackup add error messagesDavid Teigland2019-04-111-0/+17
|
* vgck --updatemetadata is a new commandDavid Teigland2019-04-117-0/+149
| | | | | | uses vg_write to correct more common or less severe issues, and also adds the ability to repair some metadata corruption that couldn't be handled previously.
* move pv header repairs to vg_writeDavid Teigland2019-04-112-148/+34
| | | | | Correct PV header in-use or version fields from vg_write instead of vg_read.
* process_each_pv handle outdated pvsDavid Teigland2019-04-111-0/+10
| | | | | process_each_pv should account for outdated pvs in the list of all devices it is processing.
* move wipe_outdated_pvs to vg_writeDavid Teigland2019-04-115-53/+109
| | | | | | | | | | and implement it based on a device, not based on a pv struct (which is not available when the device is not a part of the vg.) currently only the vgremove command wipes outdated pvs until more advanced recovery is added in a subsequent commit
* create separate lvmcache update functions for read and writeDavid Teigland2019-04-113-5/+130
| | | | | | | | | The vg read and vg write cases need to update lvmcache differently, so create separate functions for them. The read case now handles checking for outdated mdas and moves them aside into a new list to be repaired in a subsequent commit.
* fix vg_commit return valueDavid Teigland2019-04-111-6/+11
| | | | | | | The existing comment was desribing the correct behavior, but the code didn't match. The commit is successful if one mda was committed. Making it depend on the result of the internal lvmcache update was wrong.
* change args for text label read functionDavid Teigland2019-04-116-26/+70
| | | | | | | | | | | | Have the caller pass the label_sector to the read function so the read function can set the sector field in the label struct, instead of having the read function return a pointer to the label for the caller to set the sector field. Also have the read function return a flag indicating to the caller that the scanned device was identified as a duplicate pv.
* add mda arg to add_mdaDavid Teigland2019-04-115-7/+13
| | | | | Allow the caller of lvmcache_add_mda() to have the new mda returned.
* keep track of which mdas have old metadata in lvmcacheDavid Teigland2019-04-112-31/+138
| | | | | This will be used for more advanced repair in a subsequent commit.
* ability to keep track of outdated pvs in lvmcacheDavid Teigland2019-04-112-0/+96
| | | | | | | | Outdated PVs hold metadata for VG from which they have been removed. Add the ability to keep track of these in lvmcache. This will be used for more advanced repair in a subsequent commit.
* ability to keep track of bad mdas in lvmcacheDavid Teigland2019-04-113-0/+62
| | | | | | | mda's that cannot be processed by lvm because of some corruption can be kept on a separate list. These will be used for more advanced repair in a subsequent commit.
* add flags to keep track of bad metadataDavid Teigland2019-04-114-18/+67
| | | | | | | When reading metadata headers and text, use a new set of flags to identify specific errors that are seen. These will be used for more advanced repair in a subsequent commit.
* separate code for setting devices from metadata parsingDavid Teigland2019-04-116-42/+87
| | | | | Pull the code that sets devs for PVs out of the metadata parsing code and call it separately.
* hints: fix non-empty hints list when not using hintsDavid Teigland2019-04-112-12/+19
| | | | | | | | When hints are invalid and ignored, the list of hints could be non-empty (from additions before an invalid hint was found). This confused the calling code which was checking for an empty list to see if hints were used. Ensure the list is empty when hints are not used.
* hints: fix case of error getting device sizeDavid Teigland2019-04-111-1/+3
| | | | | | When checking hints, if there's an error getting the device size, that should be equivalent to seeing zero size.
* systemd: put back DefaultDependencies=no for lvmpolld socket unitPeter Rajnoha2019-04-111-0/+2
| | | | | | Previous commit 0cab341e1d0e8f9089d3c62d3adbec24dfd5e124 removed this by mistake - we have to keep the DefaultDependencies=no - the sockets.target is after sysinit.target.
* systemd: add missing Before=shutdown.target to LVM2 services to fix shutdown ↵Peter Rajnoha2019-04-097-4/+7
| | | | | | | | | | ordering We already used Conflicts=shutdown target to stop LVM2 services on shutdown. But we still missed the ordering - the shutdown.target should be reached only after all the services are really stopped. Reported here: https://github.com/lvmteam/lvm2/issues/17
* WHATS_NEW: add several recent changesDavid Teigland2019-04-081-0/+6
|
* pvscan: ignore device with incorrect sizeDavid Teigland2019-04-051-0/+30
| | | | | | | If a device looks like a PV, but its size does not match the PV size in the metadata, then skip it for purposes of autoactivation. It's probably not wrong device for the PV.
* pvscan: print more reasons for ignoring devicesDavid Teigland2019-04-054-9/+31
|
* tests: update pvscan-autoactivate for init changeDavid Teigland2019-04-051-48/+8
|
* pvscan: don't print warning about lvmlockd not runningDavid Teigland2019-04-051-0/+7
| | | | | pvscan --cache ignores shared VGs, so it doesn't need to consider lvmlockd, and shouldn't include a warning about it.
* pvscan: remove initialization caseDavid Teigland2019-04-051-128/+0
| | | | | | | | | | | | | | In the past, the first 'pvscan --cache -aay dev' command to run on the system would initialize the pvs_online dir by scanning all devs and creating online files for all pvs it found, and then autoactivating the VG (if complete) for the named dev. The idea was that the system may not have been able to run pvscan commands for early devices, so the first pvscan to run would need to "make up" for any devices that had appeared previously, which the system was unable to scan. The problem or idea of making up for missed scans is historical and should no longer be needed, so remove this special init case.
* pvscan: for init only autoactivate vg for named devDavid Teigland2019-04-051-3/+1
| | | | | | | | | When pvscan is run for the initialization case (the first pvscan run on the system), it scans all devs and creates online files for all PVs it finds. Previously it would then autoactivate every complete VG, but change this to only autoactive the (complete) VG corresponding to the named device arg(s).
* pvscan: reorganize codeDavid Teigland2019-04-051-137/+148
| | | | | to simplify and prepare for subsequent change. Should be no change in behavior.
* man: updates to lvmlockdDavid Teigland2019-04-041-64/+28
| | | | | | | | | | - remove reference to locking_type which is no longer used - remove references to adopting locks which has been disabled - move some sanlock-specific info out of a general section - remove info about doing automatic lockstart by the system since this was never used (the resource agent does it) - replace info about lvextend and manual refresh under gfs2 with a description about the automatic remote refresh
* lvmlockd: do not allow mirror LV to be activated sharedDavid Teigland2019-04-045-60/+2
| | | | | | | | This reverts 518a8e8cfbb672c2bf5e3455f1fe7cd8d94eb5b0 "lvmlockd: activate mirror LVs in shared mode with cmirrord" because while activating a mirror LV with cmirrord worked, changes to the active cmirror did not work.
* lvextend: refresh shared LV without using selectDavid Teigland2019-04-041-3/+2
| | | | | Using select instead of normal args did not end up being a help, so remove it.
* tests: check auto-growth of thin-pool metaZdenek Kabelac2019-04-031-1/+7
|
* thin: fix maintenance of _pmspareZdenek Kabelac2019-04-032-0/+5
| | | | When metadata grows lvm2 may need to extend also _pmspare volume.
* thin: resize metadata with dataZdenek Kabelac2019-04-032-0/+19
| | | | | | | | | | When data are growing, adapt also size of metadata. As we get way too many reports from users doing huge growths of data portion while keep metadata small and avoiding using monitoring. So to enhance the user-experience in case user requests grown of thin-pool (without passing PV list for growth) - lvm2 will automaticaly grown also the metadata part of thin-pool (if possible).
* thin: introduce estimate_thin_pool_metadata_sizeZdenek Kabelac2019-04-032-0/+13
| | | | | | Add function for estimation of thin-pool metadata size for given size of data. Function is using already existing internal API so it can be reused for resize of thin-pool data.
* filter: fix mpath testZdenek Kabelac2019-04-031-1/+1
| | | | | | Fix bug which leaked into commit dc6dea40331687b8740cc48833f4c7c42a2db1a1, where the testing code got mistakenly commited.
* lvresize: fix when compiled without lvmlockdDavid Teigland2019-04-021-1/+1
| | | | The no-op result of lockd_lv_resize should be success.
* lvextend: refresh shared LV with vgname as argDavid Teigland2019-03-221-1/+2
| | | | | | | Update the previous commit to leave the vgname as an arg instead of moving it into the select option, (the compound select option rule is confusing the dlm arg processing.)
* lvextend: refresh shared LV using select optionDavid Teigland2019-03-221-1/+33
| | | | | | | | Using --select 'lvname=LV && vgname=VG' avoids the problem of the lvchange exit code not distinguishing an actual error result vs the VG or LV not existing. (This is in case there is an odd dlm/gfs2 setup where some nodes are running the dlm but do not have access to the VG.)
* lvextend: refresh shared LV remotely using dlm/corosyncDavid Teigland2019-03-2111-16/+324
| | | | | | | | | When lvextend extends an LV that is active with a shared lock, use this as a signal that other hosts may also have the LV active, with gfs2 mounted, and should have the LV refreshed to reflect the new size. Use the libdlmcontrol run api, which uses dlm_controld/corosync to run an lvchange --refresh command on other cluster nodes.
* lvextend: allow on LV active with a shared lockDavid Teigland2019-03-215-2/+25
| | | | | Detect when a shared lock exists, don't require the normal exclusive lock, and allow the lvextend.
* warn about changes to an active lv with shared lockDavid Teigland2019-03-213-3/+123
| | | | | | | | | | When an LV is active with a shared lock, a command can be run to change the LV with --lockopt skiplv (to override the exclusive lock the command ordinarily requires which is not compatible with the outstanding shared lock.) In this case, other commands may have the LV active and may need to refresh the LV, so print warning stating this.
* tests: vdo caching testsZdenek Kabelac2019-03-202-0/+116
|
* tests: vdo dmevent autoresizeZdenek Kabelac2019-03-201-0/+121
|
* man: dmeventd vdo pluginZdenek Kabelac2019-03-201-2/+37
|
* man: basic vdo stacking supportZdenek Kabelac2019-03-202-4/+46
| | | | Document some basic lvconvert stacking posibilities.
* activation: synchronize before removing devicesZdenek Kabelac2019-03-203-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | Udev is running udev-rule action upon 'resume'. However lvm2 in special case is doing replacement of 'soon-to-be-removed' device with 'error' target for resuming and then follows actual removal - the sequence is usually quick, so when udev start action - it can result in 'strange' error message in kernel log like: Process '/usr/sbin/dmsetup info -j 253 -m 17 -c --nameprefixes --noheadings --rows -o name,uuid,suspended' failed with exit code 1. To avoid this - we need to ensure there is synchronization wait for udev between 'resume' and 'remove' part of this process. However existing code put strict requirement to avoid synchronizing with udev inside critical section - but this originally came from requirement to not do anything special while there could be devices in suspend-state. Now we are able to see differnce between critical section with or without suspended devices. For udev synchronization only suspended devices are prohibited to be there - so slightly relax condition and allow calling and using 'fs_sync()' even inside critical section - but there must not be any suspended device.
* vdo: enable caching for vdopool LV and vdo LVZdenek Kabelac2019-03-206-9/+22
| | | | | | | Allow using caching with VDO. User can either cache a single vdopool or a vdo LV - difference when the caching is put-in depends on a use-case and it's upto user to decide which kind of speed is expected.