summaryrefslogtreecommitdiff
path: root/lib/activate
Commit message (Collapse)AuthorAgeFilesLines
* fix dev_name use in add_areas_lineDavid Teigland2023-04-241-16/+29
| | | | | This function was relying on dev_name() returning NULL to indicate no device, but dev_name never returns NULL.
* cache: fix snapshot of cache with cachevolDavid Teigland2023-04-101-0/+2
| | | | | Creating a snapshot of a cache LV with a cachevol would fail because cache_check was not being skipped.
* vdo: use fixed size vdopool wrapperZdenek Kabelac2023-04-061-1/+1
| | | | | | | | | | | | | | Instead of using size of 'empty header' in vdopool use fixed size 4K for a 'wrappeing' vdo-pool device. This fixes the issue when user tried to activate vdo-pool after a conversion from vdo managed device with 'vgchange -ay' - where this command activated all LVs with 'vdo-pool' wrapping device as well, but this converted pool uses 0-length header. This 4k size should usually prevent other tools like 'blkid' recognize such device as anything - so it shouldn't cause any problems with duplicate indentification of devices.
* cleanup: rename functionZdenek Kabelac2023-04-061-2/+2
| | | | | Rename _thin_lv_has_device_id and use common function naming with _lv_has_thin_device_id().
* cov: avoid using strcpyZdenek Kabelac2023-02-171-2/+3
| | | | | | | Coverity is complaining about unchecked strcpy here, which is irelevant as we preallocate buffer to fit in copied string, however we could actually reuse these size and use just memcpy(). So lets make some simple conversions.
* vdo: read live vdo size configurationZdenek Kabelac2023-01-164-0/+101
| | | | | | | | Introduce struct vdo_pool_size_config usable to calculate necessary memory size for active VDO volume. Function lv_vdo_pool_size_config() is able to read out this configuration out of runtime DM table line.
* dev_manager: accept misalined vdo pools.Zdenek Kabelac2022-11-021-3/+5
| | | | | Since lvm2 may create VDO pool virtual size aligned only on extent size while VDO itself is just 4K aligned - we need to support such misalign.
* lvresize: add new options and defaults for fs handlingDavid Teigland2022-09-132-0/+77
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The new option "--fs String" for lvresize/lvreduce/lvextend controls the handling of file systems before/after resizing the LV. --resizefs is the same as --fs resize. The new option "--fsmode String" can be used to control mounting and unmounting of the fs during resizing. Possible --fs values: checksize Only applies to reducing size; does nothing for extend. Check the fs size and reduce the LV if the fs is not using the affected space, i.e. the fs does not need to be shrunk. Fail the command without reducing the fs or LV if the fs is using the affected space. resize Resize the fs using the fs-specific resize command. This may include mounting, unmounting, or running fsck. See --fsmode to control mounting behavior, and --nofsck to disable fsck. resize_fsadm Use the old method of calling fsadm to handle the fs (deprecated.) Warning: this option does not prevent lvreduce from destroying file systems that are unmounted (or mounted if prompts are skipped.) ignore Resize the LV without checking for or handling a file system. Warning: using ignore when reducing the LV size may destroy the file system. Possible --fsmode values: manage Mount or unmount the fs as needed to resize the fs, and attempt to restore the original mount state at the end. nochange Do not mount or unmount the fs. If mounting or unmounting is required to resize the fs, then do not resize the fs or the LV and fail the command. offline Unmount the fs if it is mounted, and resize the fs while it is unmounted. If mounting is required to resize the fs, then do not resize the fs or the LV and fail the command. Notes on lvreduce: When no --fs or --resizefs option is specified: . lvextend default behavior is fs ignore. . lvreduce default behavior is fs checksize (includes activating the LV.) With the exception of --fs resize_fsadm|ignore, lvreduce requires the recent libblkid fields FSLASTBLOCK and FSBLOCKSIZE. FSLASTBLOCK*FSBLOCKSIZE is the last byte used by the fs on the LV, which determines if reducing the fs is necessary.
* thin: rename internal functionZdenek Kabelac2022-08-301-1/+1
| | | | | | | | Names matching internal code layout. Functionc in thin_manip.c uses thin_pool in its name. Keep 'pool' only for function working for both cache and thin pools. No change of functionality.
* vdo: extend volume and pool without flushZdenek Kabelac2022-08-192-1/+7
| | | | | | | | | | | | When the volume size is extended, there is no need to flush IO operations (nothing can be targeting new space yet). VDO target is supported as target that can safely work with this condition. Such support is also needed, when extending VDOPOOL size while the pool is reaching its capacity - since this allows to continue working without reaching 'out-of-space' condition due to flushing of all in flight IO.
* cov: restore disable_dm_devs also for error pathZdenek Kabelac2022-07-111-3/+4
| | | | | Keep the structure correct for failing error path, alhtough likely this particual var will not be used.
* devices: fix dev_name assumptionsDavid Teigland2022-02-241-1/+8
| | | | | | | | | | dev_name(dev) returns "[unknown]" if there are no names on dev->aliases. It's meant mainly for log messages. Many places assume a valid path name is returned, and use it directly. A caller that wants to use the path from dev_name() must first check if the dev has any paths with dm_list_empty(&dev->aliases).
* dev_manager: use list info for preset devsZdenek Kabelac2022-02-161-8/+14
| | | | | In some cases we can also use cached info obtained from DM_DEVICE_LIST also to avoid extra ioctl check for present devices.
* dev_manager: do not query for open_countZdenek Kabelac2022-02-161-1/+1
| | | | Oepn count is not used along this code path.
* dev_manager: failing status is not internal errorZdenek Kabelac2022-02-161-1/+1
| | | | | | | Different target type for LV it's not an internal error. i.e. when target type is replaced with 'error' type - it should be reported as regular warning and not cause interruption of command with internall error.
* dev_manager: fix dm_task_get_device_listZdenek Kabelac2022-02-161-1/+7
| | | | | | | | | With very old version of DM target driver we have to avoid trying to use newuuid setting - otherwise we get error during ioctl preparation phase. Patch is fixing regression from commit: 988ea0e94c79a496f2619eab878fd9db6168711d
* label: cache dm device listZdenek Kabelac2021-12-202-0/+35
| | | | | | | | | | | | | | Since we check for present DM devices - cache result for futher use of checking presence of such device. lvm2 uses cache result for label scan, but also when it tries to activate or deactivate LV - however only simple target 'striped' is reasonably supported. Use disable_dm_devs to be able to control when lv_info() get cache or uncached results. TODO: support more type, however this is getting very complicated.
* activate: add get_device_listZdenek Kabelac2021-12-204-1/+43
| | | | | Add funtion get_device_list() to get list of active DM devices. Handled through new dm_task_get_device_list().
* activate: device_is_usableZdenek Kabelac2021-12-203-52/+65
| | | | | Move checking of usable uuid into separate function and pass in also cmd context.
* activate: cache driver_version resultZdenek Kabelac2021-12-201-1/+9
|
* make: replace legacy use rindex with strrchrZdenek Kabelac2021-09-271-1/+1
| | | | | | Seems already dropped by some systems. Reported-by: adamboardman of gemian
* gcc: use more zero length arraysZdenek Kabelac2021-09-221-1/+1
| | | | Define last array struct member with zero size.
* cov: initialize attrZdenek Kabelac2021-09-131-1/+1
|
* vdo: read new sysfs pathZdenek Kabelac2021-09-091-3/+4
| | | | | | | | | New versions of kvdo module exposes statistics at new location: /sys/block/dm-XXX/vdo/statistics/... Enhance lvm2 to access this location first. Also if the statistic info is missing - make it 'debug' level info, so it is not failing 'lvs' command.
* cov: clean up pvid and vgid usageDavid Teigland2021-08-161-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pvid and vgid are sometimes a null-terminated string, and other times a 'struct id', and the two types were often cast between each other. When a struct id was cast to a char pointer, the resulting string would not necessarily be null terminated. Casting a null-terminated string id to a struct id is fine, but is still avoided when possible. A struct id is: int8_t uuid[ID_LEN] A string id is: char pvid[ID_LEN + 1] A convention is introduced to help distinguish them: - variables and struct fields named "pvid" or "vgid" should be null-terminated strings. - variables and struct fields named "pv_id" or "vg_id" should be struct id's. - examples: char pvid[ID_LEN + 1]; char vgid[ID_LEN + 1]; struct id pv_id; struct id vg_id; Function names also attempt to follow this convention. Avoid casting between the two types as much as possible, with limited exceptions when known to be safe and clearly commented. Avoid using variations of strcpy and strcmp, and instead use memcpy/memcmp with ID_LEN (with similar limited exceptions possible.)
* cov: guard indexZdenek Kabelac2021-07-281-1/+1
| | | | Analyzer wants explicit protect to not underflow index.
* thin: fix component detection of external originZdenek Kabelac2021-07-141-1/+4
| | | | | | When check active componet of thinLV with external origin, we need to check if the external origin isn't already active. For this however we need to use layered check for -real device.
* vdo: fix preload of kvdoZdenek Kabelac2021-05-261-7/+3
| | | | | Commit 5bf1dba9eb8a8b77410e386e59dadeb27801b14e broke load of kvdo kernel module - correct it by loading kvdo instead of trying dm-vdo.
* mirror_percent: support interruptible checkZdenek Kabelac2021-04-061-8/+28
| | | | | When checking for mirror percentage with WAITEVENT (i.e. during pvmove) handle intrruption (^C) of such wait.
* raid: move non dm functions from DEVMAPPER ifdefZdenek Kabelac2021-03-191-16/+20
| | | | | | When lvm is compiled without device-mapper - this functions do not need this kernel support so move them from ifdef DEVMAPPER sections.
* dev_manager: skip also zero targetsZdenek Kabelac2021-03-181-5/+7
| | | | | | Devices made only from 'error' target cannot be used, but if the device is also combined from 'zero' target the same rule can be applied as such device cannot be used.
* dev_manager: add lv_raid_statusZdenek Kabelac2021-03-184-73/+83
| | | | | | | | | | | | Just like with other segtype use this function to get whole raid status info available per a single ioctl call. Also it nicely simplifies read of percentage info about in_sync portion of raid volume. TODO: drop use of other calls then lv_raid_status call, since all such calls could already use status - so it just adds unnecessary duplication.
* dev_manager: status check with info check includedZdenek Kabelac2021-03-183-90/+80
| | | | | | | | | | | | Reduce ioctl count and avoid separate info check, when we can get the same info from status ioctl. When devmanager calls return 0, then the exists value 0 means the reason of failure is missing device in table. In such case we avoid stack trace. Swap the flush parameter for the vdo status function to match thin pool status.
* cleanup: use dm_strncpyZdenek Kabelac2021-03-171-2/+1
| | | | Use own function.
* device_is_usable: minor improveZdenek Kabelac2021-03-171-36/+41
| | | | | | | Replace allocated buffer with local vg_name which doesn't pass pointer to allocation. Join some conditions together.
* activation: use interruptible_usleepZdenek Kabelac2021-03-141-13/+13
| | | | Support interruption while waiting on device close.
* lv_check_not_in_use: correct checkZdenek Kabelac2021-03-101-2/+4
| | | | | Since lv_info() may return 0 without setting info struct, make the test correct and even more readable.
* cov: defined flvZdenek Kabelac2021-03-101-2/+2
|
* debug: change sys_error to sys_debugZdenek Kabelac2021-03-101-5/+5
| | | | | These messages do not cause command error - so changing logging level to just 'sys_debug' (so visible only with -vvvv)
* lvm-file: remove duplication of dm_is_empty_dirZdenek Kabelac2021-03-101-1/+1
|
* cleanup: move codeZdenek Kabelac2021-03-081-6/+6
| | | | just evaluate later in code path.
* deactivation: reduce ioctl countZdenek Kabelac2021-03-081-33/+37
| | | | | | | | | | | | When LV is deactivativate, we check for presence, and later for some LV types also for being in use. We can however do this check in 1 step for them a remove extra ioctl. Add return value '2' to lv_check_not_in_use() to recognize LV is not present. Existing users were just testing for 0, so no change for them.
* filters: better message for excluding LVDavid Teigland2021-03-033-4/+6
| | | | | | Make the generic "device is not usable" message from filter-usable more specific in case the device is not usable because it's an LV. (i.e. when scan_lvs=0)
* lvcreate: use lv_passes_readonly_filterZdenek Kabelac2021-02-022-0/+7
| | | | | | Check if created LV is going to be activated read-only because such LV cannot be zeroed (equals to use option '-pr').
* thin: improve 16g support for thin pool metadataZdenek Kabelac2021-02-011-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Initial support for thin-pool used slightly smaller max size 15.81GiB for thin-pool metadata. However the real limit later settled at 15.88GiB (difference is ~64MiB - 16448 4K blocks). lvm2 could not simply increase the size as it has been using hard cropping of the loaded metadata device to avoid warnings printing warning of kernel when the size was bigger (i.e. due to bigger extent_size). This patch adds the new lvm.conf configurable setting: allocation/thin_pool_crop_metadata which defaults to 0 -> no crop of metadata beyond 15.81GiB. Only user with these sizes of metadata will be affected. Without cropping lvm2 now limits metadata allocation size to 15.88GiB. Any space beyond is currently not used by thin-pool target. Even if i.e. bigger LV is used for metadata via lvconvert, or allocated bigger because of to large extent size. With cropping enabled (=1) lvm2 preserves the old limitation 15.81GiB and should allow to work in the evironement with older lvm2 tools (i.e. older distribution). Thin-pool metadata with size bigger then 15.81G is now using CROP_METADATA flag within lvm2 metadata, so older lvm2 recognizes an incompatible thin-pool and cannot activate such pool! Users should use uncropped version as it is not suffering from various issues between thin_repair results and allocated metadata LV as thin_repair limit is 15.88GiB Users should use cropping only when really needed! Patch also better handles resize of thin-pool metadata and prevents resize beoyond usable size 15.88GiB. Resize beyond 15.81GiB automatically switches pool to no-crop version. Even with existing bigger thin-pool metadata command 'lvextend -l+1 vg/pool_tmeta' does the change. Patch gives better controls 'coverted' metadata LV and reports less confusing message during conversion. Patch set also moves the code for updating min/max into pool_manip.c for better sharing with cache_pool code.
* cache: activation cache_check on cachevolDavid Teigland2020-12-091-12/+24
| | | | | | | | When using cache with a cachevol, the cache_check tool was not being run on the cache metadata during activation. cache_check clears the needs_check flag in the cache metadata, so if the flag was set due to an unclean shutdown, the activation would fail.
* writecache: disallow partial or degraded activationDavid Teigland2020-10-261-0/+8
| | | | when either main or fast lvs are incomplete
* debug: update debug messageZdenek Kabelac2020-09-291-2/+1
|
* active: fix compilation without devmapperZdenek Kabelac2020-09-291-14/+17
| | | | Better support for compilation without device-mapper.
* thin: use lv_status_thin and lv_status_thin_poolZdenek Kabelac2020-09-294-118/+109
| | | | | | | | | | | | | | | | | | Introduce structures lv_status_thin_pool and lv_status_thin (pair to lv_status_cache, lv_status_vdo) Convert lv_thin_percent() -> lv_thin_status() and lv_thin_pool_percent() + lv_thin_pool_transaction_id() -> lv_thin_pool_status(). This way a function user can see not only percentages, but also other important status info about thin-pool. TODO: This patch tries to not change too many other things, but pool_below_threshold() now uses new thin-pool info to return failure if thin-pool cannot be actually modified. This should be handle separately in a better way.