summaryrefslogtreecommitdiff
path: root/tools/lvmdevices.c
Commit message (Collapse)AuthorAgeFilesLines
* device_id: handle duplicate serial numbersDavid Teigland2022-11-071-2/+8
| | | | | | | | | Handle multiple devices using the same serial number as their device id. After matching devices to devices file entries, if there is a discrepency between the ondisk PVID and the devices file PVID, then rematch devices to devices file entries using PVID, looking at all disks on the system with the same serial number.
* lvmdevices: use deviceidtype option strictlyDavid Teigland2022-10-101-3/+3
| | | | | Only use the device id type specified by --deviceidtype, and fail if that type is not available for the device.
* lvmdevices: --deldev using device idDavid Teigland2022-04-061-1/+46
| | | | | When used with --deviceidtype, --deldev can specify a device id to remove.
* change messages about filtered devicesDavid Teigland2022-04-011-2/+2
| | | | | | Change messages that refer to devices being "excluded by filters" to say just "excluded". This will avoid mistaking the word "filters" with the lvm.conf filter setting.
* lvmdevices update: correct multipath entriesDavid Teigland2022-04-011-0/+43
| | | | | Remove multipath components. Add multipath devs that have multipath components listed.
* lvmdevices: make deldev work for missing deviceDavid Teigland2022-02-031-17/+16
|
* lvmdevices check: error exit if update is neededDavid Teigland2022-01-141-21/+16
| | | | | | | | . error exit means that lvmdevices --update would make a change. . remove check of PART field from --check because it isn't used. . unlink searched_devnames file to ensure check|update will search
* lvmdevices: increase open file limitDavid Teigland2021-11-031-0/+3
|
* lvmdevices: allow deviceidtype with addpvidDavid Teigland2021-09-131-2/+3
| | | | in addition to using with adddev
* cov: make it aware we need these headers for muslCZdenek Kabelac2021-09-131-0/+1
|
* add missing sys/file.h includeAlex Xu (Hello71)2021-08-231-0/+2
| | | | required for LOCK_EX etc on musl
* skip indexing devices used by LVs in more commandsDavid Teigland2021-07-091-2/+3
| | | | | | | | | | | | | | | | | | | | | expands commit d5a06f9a7df5a43b2e2311db62ff8d3011217d74 "pvscan: skip indexing devices used by LVs" The dev cache index is expensive and slow, so limit it to commands that are used to observe the state of lvm. The index is only used to print warnings about incorrect device use by active LVs, e.g. if an LV is using a multipath component device instead of the multipath device. Commands that continue to use the index and print the warnings: fullreport, lvmdiskscan, vgs, lvs, pvs, vgdisplay, lvdisplay, pvdisplay, vgscan, lvscan, pvscan (excluding --cache) A couple other commands were borrowing the DEV_USED_FOR_LV flag to just check if a device was actively in use by LVs. These are converted to the new dev_is_used_by_active_lv().
* pvscan: skip indexing devices used by LVsDavid Teigland2021-07-061-1/+1
| | | | | | | | | | | | | | | dev_cache_index_devs() is taking a large amount of time when there are many PVs. The index keeps track of devices that are currently in use by active LVs. This info is used to print warnings for users in some limited cases. The checks/warnings that are enabled by the index are not needed by pvscan --cache, so disable it in this case. This may be expanded to other cases in future commits. dev_cache_index_devs should also be improved in another commit to avoid the extreme delays with many devices.
* lvmdevices: add deviceidtype optionDavid Teigland2021-06-111-2/+5
| | | | | | | | | | | When adding a device to the devices file with --adddev, lvm by default chooses the best device ID type for the new device. The new --deviceidtype option allows the user to override the built in preference. This is useful if there's a problem with the default type, or if a secondary type is preferrable. If the specified deviceidtype does not produce a device ID, then lvm falls back to the preference it would otherwise use.
* label_read_pvid: separate error and no-pvidDavid Teigland2021-04-231-3/+11
| | | | | | | | | | | error reading dev and no pvid on dev were both returning 0. make it easier for callers to know which, if they care. return 1 if the device could be read, regardless of whether a pvid was found or not. set has_pvid=1 if a pvid is found and 0 if no pvid is found.
* Revert "cov: check label_read_pvid return value"David Teigland2021-04-231-4/+2
| | | | | | | This reverts commit bf461b99c6d26e550835b77eaffe2204cbc9bed3. label_read_pvid returns 0 for non-PVs and these callers want to handle non-PVs.
* cov: check label_read_pvid return valueZdenek Kabelac2021-04-231-2/+4
| | | | Command can early exit when function returns 0.
* cov: remove unnecessary headersZdenek Kabelac2021-03-101-1/+0
|
* cleanup: no backtraces needed after log_errorZdenek Kabelac2021-03-101-3/+3
| | | | Reduce double backtracing.
* device usage based on devices fileDavid Teigland2021-02-231-0/+465
The LVM devices file lists devices that lvm can use. The default file is /etc/lvm/devices/system.devices, and the lvmdevices(8) command is used to add or remove device entries. If the file does not exist, or if lvm.conf includes use_devicesfile=0, then lvm will not use a devices file. When the devices file is in use, the regex filter is not used, and the filter settings in lvm.conf or on the command line are ignored. LVM records devices in the devices file using hardware-specific IDs, such as the WWID, and attempts to use subsystem-specific IDs for virtual device types. These device IDs are also written in the VG metadata. When no hardware or virtual ID is available, lvm falls back using the unstable device name as the device ID. When devnames are used, lvm performs extra scanning to find devices if their devname changes, e.g. after reboot. When proper device IDs are used, an lvm command will not look at devices outside the devices file, but when devnames are used as a fallback, lvm will scan devices outside the devices file to locate PVs on renamed devices. A config setting search_for_devnames can be used to control the scanning for renamed devname entries. Related to the devices file, the new command option --devices <devnames> allows a list of devices to be specified for the command to use, overriding the devices file. The listed devices act as a sort of devices file in terms of limiting which devices lvm will see and use. Devices that are not listed will appear to be missing to the lvm command. Multiple devices files can be kept in /etc/lvm/devices, which allows lvm to be used with different sets of devices, e.g. system devices do not need to be exposed to a specific application, and the application can use lvm on its own set of devices that are not exposed to the system. The option --devicesfile <filename> is used to select the devices file to use with the command. Without the option set, the default system devices file is used. Setting --devicesfile "" causes lvm to not use a devices file. An existing, empty devices file means lvm will see no devices. The new command vgimportdevices adds PVs from a VG to the devices file and updates the VG metadata to include the device IDs. vgimportdevices -a will import all VGs into the system devices file. LVM commands run by dmeventd not use a devices file by default, and will look at all devices on the system. A devices file can be created for dmeventd (/etc/lvm/devices/dmeventd.devices) If this file exists, lvm commands run by dmeventd will use it. Internal implementaion: - device_ids_read - read the devices file . add struct dev_use (du) to cmd->use_devices for each devices file entry - dev_cache_scan - get /dev entries . add struct device (dev) to dev_cache for each device on the system - device_ids_match - match devices file entries to /dev entries . match each du on cmd->use_devices to a dev in dev_cache, using device ID . on match, set du->dev, dev->id, dev->flags MATCHED_USE_ID - label_scan - read lvm headers and metadata from devices . filters are applied, those that do not need data from the device . filter-deviceid skips devs without MATCHED_USE_ID, i.e. skips /dev entries that are not listed in the devices file . read lvm label from dev . filters are applied, those that use data from the device . read lvm metadata from dev . add info/vginfo structs for PVs/VGs (info is "lvmcache") - device_ids_find_renamed_devs - handle devices with unstable devname ID where devname changed . this step only needed when devs do not have proper device IDs, and their dev names change, e.g. after reboot sdb becomes sdc. . detect incorrect match because PVID in the devices file entry does not match the PVID found when the device was read above . undo incorrect match between du and dev above . search system devices for new location of PVID . update devices file with new devnames for PVIDs on renamed devices . label_scan the renamed devs - continue with command processing