summaryrefslogtreecommitdiff
Commit message (Collapse)AuthorAgeFilesLines
* tests: add missing-pv missing-pv-unuseddev-dct-read-18David Teigland2019-05-212-0/+238
|
* vgck: dumpmetadata to dump metadata from diskDavid Teigland2019-05-217-0/+304
| | | | | | | vgck --dumpmetadata dumps the exact metadata text from the mda to stdout or file. Specific PVs can be selected. This is useful for debugging, testing, and recovery.
* improve some warning messagesDavid Teigland2019-05-212-6/+24
|
* remove unused or moved codeDavid Teigland2019-05-211-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-05-2127-1279/+1318
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 is written to disk with the MISSING flag on the PV with the missing device. When the VG is next used, it is treated as if the PV with the MISSING flag still has a missing device, even if that device has reappeared. If all LVs that were using a PV with the MISSING flag are removed or repaired so that the MISSING PV is no longer used, then the next time the VG metadata is written, the MISSING flag will be dropped. Alternative methods of clearing the MISSING flag are: 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-05-211-0/+21
| | | | in an mda that had previously not been updated
* vgcfgbackup add error messagesDavid Teigland2019-05-211-0/+17
|
* vgck --updatemetadata is a new commandDavid Teigland2019-05-217-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-05-212-148/+34
| | | | | Correct PV header in-use or version fields from vg_write instead of vg_read.
* process_each_pv handle outdated pvsDavid Teigland2019-05-211-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-05-215-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-05-213-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-05-211-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-05-216-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-05-215-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-05-212-31/+138
| | | | | This will be used for more advanced repair in a subsequent commit.
* ability to keep track of outdated pvs in lvmcacheDavid Teigland2019-05-212-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-05-213-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-05-214-18/+66
| | | | | | | 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-05-216-54/+87
| | | | | Pull the code that sets devs for PVs out of the metadata parsing code and call it separately.
* tests: fsadm-crypt.sh update mkfs parameterDavid Teigland2019-05-211-5/+5
| | | | mkfs.xfs was rejecting previously working value
* tests: pvscan-autoactivate.sh switch system_id_sourceDavid Teigland2019-05-211-1/+1
| | | | | to machineid instead of uname which would break if the test system had no proper uname set.
* tests: hints check if strace existsDavid Teigland2019-05-211-0/+3
| | | | | avoid test failure if test system does not have strace
* scan: expand and update label scan commentsDavid Teigland2019-05-211-28/+61
|
* hints: exclude md componentsDavid Teigland2019-05-214-3/+16
| | | | | | In some cases md components could be included in the hints, so add a check to hint creation to make sure they are excluded.
* move the setting of use_full_md_check flagDavid Teigland2019-05-214-9/+18
| | | | | from each command to one location in command init. No functional change.
* devs: rename dev_is_md dev_is_md_componentDavid Teigland2019-05-215-11/+24
| | | | | | The naming was confusing and misleading since it it's testing if a device is an md component, not an md device.
* tests: check accepting out-of-range creation_timeZdenek Kabelac2019-05-101-0/+40
|
* metadata: allow reading metadata with invalid creation_timeZdenek Kabelac2019-05-102-6/+30
| | | | | | | | | | | | | | | | lvm2 till version 2.02.169 (commit 78d004efa8a1809cea68283e6204edfa9d7c1091) was printing invalid creation_time argument into metadata on 32bit arch. However with commit ba9820b14223b731125c83dbc9709aa44fdcdbf1 we started to properly validate all input numbers and thus we refused to accept invalid metadata with 'garbage' string - but this results in the situation where metadata produced on older lvm2 on 32 bit architecture will become unreadable after upgrade. To fix this case - extend libdm parser in a way, that whenever we find error integer value, we also check if the parsed value is not for creation_time node and in this case we let the metadata pass through with made-up date 2018-05-24 (release date of 2.02.169).
* tests: split argsZdenek Kabelac2019-05-061-1/+1
| | | | Here we want args to be splited into individual strings.
* tests: drop call of wipefsZdenek Kabelac2019-05-041-4/+0
| | | | | | wipefs might not be present on test system. Devices are also already zeroed by cleanup_md_dev (which 'fakes' missing wipefs eventually)
* pvscan: fix segfault in recent commitDavid Teigland2019-05-031-1/+5
| | | | | | | | | commit aa75b31db5478 "pvscan: handle case of scanning PV without metadata last" failed to recognize that an arg may be null in the case of 'pvscan --cache' (without -aay) which does not keep track of complete VGs because it does not need to activate them.
* pvs: remove unnecessary label scanDavid Teigland2019-05-031-14/+1
| | | | | | | The scanning rework missed removing this instance of label scan. It's no longer needed because of the way that label scan is always run once from the start of the command. This unnecessary scan would be triggered by running 'pvs @tag'.
* tests: expand lvm-on-mdDavid Teigland2019-05-031-15/+136
| | | | test both md raid0 and raid1
* pvscan: don't record PV online after error reading metadataDavid Teigland2019-05-031-2/+18
|
* add md component check in vg_read based on sizeDavid Teigland2019-05-031-0/+12
| | | | | | | If an md component is not excluded by other means and vg_read is used to read metadata from it, then this new check compares the device size with the PV size, and runs a full md check on the device if the sizes don't match.
* tests: use luks1 for testZdenek Kabelac2019-05-031-1/+8
| | | | | | Since we do not need anywhere luks2 - pick older format which does not require password for resize to keep the rest of test unmodified.
* tests: update resize valueZdenek Kabelac2019-05-031-1/+1
| | | | | Since we now properly extend also _pmspare - there was not enough free space to add 8extents to both volumes.
* cleanup: use unsigned typeZdenek Kabelac2019-05-031-1/+1
|
* build: fix compilation without lvmlockdZdenek Kabelac2019-05-031-1/+2
|
* locking: validate locking modeZdenek Kabelac2019-05-031-0/+3
| | | | Ensure 'ret' is always defined and validate 'mode'.
* clean: avoid cleaning iterator on error pathZdenek Kabelac2019-05-031-2/+2
| | | | Return error dirrectly instead of using 'out' code path.
* scan: remove comments about lvmetadDavid Teigland2019-05-021-14/+4
|
* lvmlockd: fix snprintf warningsDavid Teigland2019-05-023-12/+24
|
* use memcpy for constant ondisk stringsDavid Teigland2019-05-023-9/+9
| | | | | | Use memcpy/memcmp for on disk strings which are not null terminated: FMTT_MAGIC, LVM2_LABEL and LABEL_ID. Quiets compile warnings.
* remove unused string writecacheDavid Teigland2019-05-011-2/+0
|
* lvmcache: remove unused flagDavid Teigland2019-04-301-9/+0
| | | | | The new label scan design is never called recursively, so we don't need a flag to check for that.
* vgcreate: remove the lvmcache locking workaroundDavid Teigland2019-04-301-15/+0
| | | | | | Recent cleanups and simplifications to lvmcache and locking mean that the odd locking to workaround other issues is now unnecessary.
* pvcreate: call label scan prior to pvcreate_each_deviceDavid Teigland2019-04-304-11/+10
| | | | | | 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.)
* pvscan: remove fixme comment that is fixedDavid Teigland2019-04-291-12/+0
| | | | | | Remove the fixme comment describing the case that was fixed by aa75b31db54782fb24b6b7e3c681a61b3579117c "pvscan: handle case of scanning PV without metadata last"