summaryrefslogtreecommitdiffstats
path: root/super-intel.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* mdadm: add xmalloc.hMariusz Tkaczyk2024-09-271-0/+2
| | | | | | | | | | Move memory declaration helpers outside mdadm.h. They seems to be useful so keep them but include separatelly. Rework them to not reffer to Name[] declared internally in mdadm/mdmon. This is first step to start decomplexing mdadm.h. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: save checkpoint prior to exitMateusz Kusiak2024-09-041-2/+3
| | | | | | | | | | | | If reshape (eg. chunksize migration) is gracefully stopped via SIGTERM the checkpoint is not saved and reshape cannot be resumed due to "data being present in copy area". This is because UNIT_SRC_NORMAL isn't set if SIGTERM occurred. Move SIGTERM handling at the end of the loop to allow saving checkpoint (and state) so reshapes can be properly resumed. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
* imsm: add IMSM_OROM_CAPABILITIES_TPV to nvme oromMariusz Tkaczyk2024-08-301-39/+37
| | | | | | | | | | | | | | Add it to avoid excluding. It has some value for users even if it is always true for nvme virtual orom. Rework detail-platform printing code, move printing 3rd party nvmes to print_imsm_capability (as it should be), but keep it meaningful only for nvme controllers (NVME and VMD hba types). Pass whole orom_entry instead of orom there. Squash code responsible for printing NVME and VMD hbas. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: Remove warning and refactor add_to_super_imsm codeMariusz Tkaczyk2024-08-301-63/+39
| | | | | | | Intel x8 drives are not supported, remove unnecessary warning and refactor add_to_super_imsm code. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* platform-intel: refactor path_attached_to_hba()Mateusz Kusiak2024-08-301-4/+4
| | | | | | | dprintf() call in path_attached_to_hba() is too noisy. Remove the call and refactor the function. Remove obsolete env variables check. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com>
* super-intel: add define for migr_stateKinga Stefaniuk2024-08-061-7/+9
| | | | | | | Represent migr_state with the define, which helps in code readability. Add new values for Normal and Migration states. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* super-intel: fix compilation errorKinga Stefaniuk2024-08-061-0/+6
| | | | | | | | | | | | | | | | | Fix compilation error: super-intel.c: In function ‘end_migration’: super-intel.c:4360:29: error: writing 2 bytes into a region of size 0 [-Werror=stringop-overflow=] 4360 | dev->vol.migr_state = 0; | ~~~~~~~~~~~~~~~~~~~~^~~ cc1: note: destination object is likely at address zero cc1: all warnings being treated as errors make: *** [Makefile:232: super-intel.o] Error 1 reported, when GCC 14 is used. Return when dev is NULL, to avoid it. Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* imsm: refactor chunk size printBlazej Kucman2024-07-311-43/+49
| | | | | | | | - add imsm_chunk_ops struct for better code readability, - move chunk size mapping to string into array, - add function to print supported chunk sizes by IMSM controller. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com>
* mdstat: Rework mdstat external arrays handlingMariusz Tkaczyk2024-07-301-6/+3
| | | | | | | | | | | | To avoid repeating mdstat_read() in IncrementalRemove(), new function mdstat_find_by_member_name() has been proposed. With that, IncrementalRemove() handles own copy of mdstat content and there is no need to repeat reading for external stop. Additionally, It proposed few helper to avoid repeating mdstat_ent->metadata_version checks across code. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: add indent for encryption detailsMariusz Tkaczyk2024-07-161-1/+1
| | | | | | Improve readability of the output. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: make freesize required to volume autolayoutKinga Stefaniuk2024-06-111-4/+6
| | | | | | | | | | | | | Autolayout_imsm() shall be executed when IMSM_NO_PLATFORM=1 is set. It was fixed by listed commit, checking super->orom was removed, but also checking freesize. Freesize is not set for operations on RAID volume with no size update, that's why it is not required to have this value and always run autolayout_imsm(). Fix it by making autolayout_imsm() dependent on freesize. Fixes: 46f192 ("imsm: fix first volume autolayout with IMSM_NO_PLATFORM") Signed-off-by: Kinga Stefaniuk <kinga.stefaniuk@intel.com>
* imsm: fix first volume autolayout with IMSM_NO_PLATFORMMariusz Tkaczyk2024-05-281-9/+9
| | | | | | | | | | | | | Autolayout_imsm() is not executed if IMSM_NO_PLATFORM=1 is set. This causes that first volume cannot be created. Disk for new volume are never configured. Fix it by making autolayout_imsm() independent from super->orom because NULL there means that IMSM_NO_PLATFORM=1 is set. There are not platform restrictions to create volume, we just analyze drives. It is safe. Fixes: 6d4d9ab295de ("imsm: use same slot across container") Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: super-intel fix bad shiftNigel Croxon2024-05-231-5/+6
| | | | | | | | In the expression "1 << i", left shifting by more than 31 bits has undefined behavior. The shift amount, "i", is as much as 63. The operand has type "int" (32 bits) and will be shifted as an "int". The fix is to change to a 64 bit int. Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* mdadm: super-intel remove dead codeNigel Croxon2024-05-231-9/+0
| | | | | | | | | Execution cannot reach this statement: "while (devlist) { dv = de...". Local variable "err" is assigned only once, to a constant value, making it effectively constant throughout its scope. Remove dead code. Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* super-intel: fix typo in error msgBlazej Kucman2024-05-221-1/+1
| | | | | | Fix typo in encryption policy error msg. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com>
* add checking of return status on fstat callsNigel Croxon2024-05-211-2/+6
| | | | | | | | There are a few places we don't check the return status when calling fstat for success. Clean up the calls by adding a check before continuing. Signed-off-by: Nigel Croxon <ncroxon@redhat.com>
* imsm: support RAID 10 with more than 4 drivesMateusz Kusiak2024-05-071-2/+12
| | | | | | | | | | | | | | | | | VROC UEFI driver does not support RAID 10 with more than 4 drives. Add user prompts if such layout is being created and for R0->R10 reshapes. Refactor ask() function: - simplify the code, - remove dialog reattempts, - do no pass '?' sign on function calls, - highlight default option on output. This patch completes adding support for R10D4+ to IMSM. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: simplify imsm_check_attributes()Mateusz Kusiak2024-05-071-90/+16
| | | | | | | | | | imsm_check_attributes() is too complex for that it really does. Remove repeating code and simplify the function. Fix function calls. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: define RAID_10 attributeMateusz Kusiak2024-05-071-0/+5
| | | | | | | | | | | | | Add MPB_ATTRIB_RAID10_EXT attribute to support RAID 10 with more than 4 drives. Allow more than 4 drives in imsm_orom_support_raid_disks_raid10(). This is one of last patches for introducing R10D4+ to imsm. Only small adjustments in reshape behaviours are needed. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: bump minimal versionMateusz Kusiak2024-05-071-49/+38
| | | | | | | | | | | | | | | | | IMSM version 1.3 (called ATTRIBS) brought attributes used to define array properties which require support in driver. The goal of this change was to avoid changing version when adding new features. For some reasons migration has never been completed and currently (after 10 years of implementing) IMSM can use older versions. It is right time to finally switch it. There is no point in using old versions, use 1.3.00 as minimal one. Define JD_VERSION used by Windows driver. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: refactor RAID level handlingMateusz Kusiak2024-05-071-44/+67
| | | | | | | | | | | | | | | | | Add imsm_level_ops struct for better handling and unifying raid level support. Add helper methods and move "orom_has_raid[...]" methods from header to source file. RAID 1e is not supported under Linux, remove RAID 1e associated code. Refactor imsm_analyze_change() and is_raid_level_supported(). Remove hardcoded check for 4 drives and make devNumChange a multiplier for RAID 10. Refactor printing supported raid levels. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: add support for literal RAID 10Mateusz Kusiak2024-05-071-19/+48
| | | | | | | | | | | | | | | As for now, IMSM supports only 4 drive RAID 1+0. This patch is first in series to add support for literal RAID 10 (with more than 4 drives) to imsm. Allow setting RAID 10 as raid level for imsm arrays. Add update_imsm_raid_level() to handle raid level updates. Set RAID10 as default level for imsm R0 to R10 migrations. Replace magic numbers with defined values for RAID level checks/assigns. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: use struct context in reshape_super()Mateusz Kusiak2024-05-071-16/+27
| | | | | | | | | | | | | | reshape_super() takes too many arguments. Change passing params in favor of single struct. Add devname pointer and change direction members to struct shape and use it for reshape_super(). Create reshape_array_size() and reshape_array_non_size() to handle reshape_super() calls. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: pass struct context for external reshapesMateusz Kusiak2024-05-071-4/+2
| | | | | | | | | | | | This patch alters mutiple functions calls so the context is passed to external reshape functions. There are two main reasons behind it: - reduces number of arguments passed and unifies them, - imsm code will make use of context in incoming patches. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: drive encryption policy implementationBlazej Kucman2024-04-021-0/+73
| | | | | | | | | | | | | | IMSM cares about drive encryption state. It is not allowed to mix disks with different encryption state within one md device. This policy will verify that attempt to use disks with different encryption states will fail. Verification is performed for devices NVMe/SATA Opal and SATA. There is one exception, Opal SATA drives encryption is not checked when ENCRYPTION_NO_VERIFY key with "sata_opal" value is set in conf, for this reason such drives are treated as without encryption support. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: print disk encryption informationBlazej Kucman2024-04-021-4/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Print SATA/NVMe disk encryption information in --detail-platform. Encryption Ability and Status will be printed for each disk. There is one exception, Opal SATA drives encryption is not checked when ENCRYPTION_NO_VERIFY key with "sata_opal" value is set in conf, for this reason such drives are treated as without encryption support. To test this feature, drives SATA/NVMe with Opal support or SATA drives with encryption support have to be used. Example outputs of --detail-platform: Non Opal, encryption enabled, SATA drive: Port0 : /dev/sdc (CVPR050600G3120LGN) Encryption(Ability|Status): Other|Unlocked NVMe drive without Opal support: NVMe under VMD : /dev/nvme2n1 (PHLF737302GB1P0GGN) Encryption(Ability|Status): None|Unencrypted Unencrypted SATA drive with OPAL support: - default allow_tpm, we will get an error from mdadm: Port6 : /dev/sdi (CVTS4246015V180IGN) mdadm: Detected SATA drive /dev/sdi with Trusted Computing support. mdadm: Cannot verify encryption state. Requires libata.tpm_enabled=1. mdadm: Failed to get drive encrytpion information. - default "allow_tpm" and config entry "ENCRYPTION_NO_VERIFY sata_opal": Port6 : /dev/sdi (CVTS4246015V180IGN) Encryption(Ability|Status): None|Unencrypted - added "libata.allow_tpm=1" to boot parameters(requires reboot), the status will be read correctly: Port6 : /dev/sdi (CVTS4246015V180IGN) Encryption(Ability|Status): SED|Unencrypted Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: Move pr_vrb define to mdadm.hBlazej Kucman2024-04-021-2/+0
| | | | | | | | Move pr_vrb define from super-intel.c to mdadm.h to make it widely available. This change will be used in the next patches. Signed-off-by: Blazej Kucman <blazej.kucman@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: fix grow segfault for IMSMMariusz Tkaczyk2024-03-221-2/+7
| | | | | | | | | | | If sc is not initialized, there is possibility that sc.pols is not zeroed and it causes segfault. Add missing initialization. Add missing dev_policy_free() in two places. Fixes: f656201188d7 ("mdadm: drop get_required_spare_criteria()") Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: Fix native --detail --exportMariusz Tkaczyk2024-03-221-8/+8
| | | | | | | | | | | | | | | | Mentioned commit (see Fixes) causes that UUID is not swapped as expected for native superblock. Fix this problem. For detail, we should avoid superblock calls, we can have information about supertype from map, use that. Simplify fname_from_uuid() by removing dependencies to metadata handler, it is not needed. Decision is taken at compile time, expect super1 but this function is not used by super1. Add warning about that. Remove separator, it is always ':'. Fixes: 60c19530dd7c ("Detail: remove duplicated code") Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: set swapuuid in all handlersMariusz Tkaczyk2024-03-221-0/+1
| | | | | | | | | | | | It is not set, so it should be 0 but it may vary on compilation settings. Set it always to 0. metadata should care to set UUID and read in proper endianness so it doesn't follow super1 concept of swapuuid to depend on endianness. It is not an attempt to fix endianness issues. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* imsm: test_and_add_device_policies() implementationMariusz Tkaczyk2024-03-111-33/+90
| | | | | | | | This patch removes get_disk_controller_domain_imsm() in favour of test_and_add_device_policies_imsm(). It is used by create, add and mdmonitor. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: drop get_required_spare_criteria()Mariusz Tkaczyk2024-03-111-41/+79
| | | | | | | | | | | | | | | | | | | | | Only IMSM implements get_spare_criteria, so load_super() in get_required_spare_criteria() is dead code. It is moved inside metadata handler, because only IMSM implements it. Give possibility to provide devnode to be opened. With that we can hide load_container() used only to fill spare criteria inside handler and simplify implementation in generic code. Add helper function for testing spare criteria in Incremental and error messages. File descriptor in get_spare_criteria_imsm() is always opened on purpose. New functionality added in next patches will require it. For the same reason, function is moved to other place. No functional changes. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: Add functions for spare criteria verificationMariusz Tkaczyk2024-03-111-3/+1
| | | | | | | | | | | | | | | | | It is done similar way in few places. As a result, two almost identical functions (dev_size_from_id() and dev_sector_size_from_id()) are removed. Now, it uses same file descriptor to send two ioctls. Two extern functions are added, in next patches disk_fd_matches_criteria() is used. Next optimization is inline zeroing struct spare_criteria. With that, we don't need to reset values in get_spare_criteria_imsm(). Dedicated boolean field for checking if criteria are filled is added. We don't need to execute the code if it is not set. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* super-intel: respect IMSM_DEVNAME_AS_SERIAL flagKinga Tanska2024-02-291-6/+6
| | | | | | | | | | IMSM_DEVNAME_AS_SERIAL flag was respected only when searching serial using nvme or scsi device wasn't successful. This flag shall be applied first, to have user settings with the highest priority. Signed-off-by: Kinga Tanska <kinga.tanska@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Super-intel: Fix first checkpoint restartMateusz Kusiak2024-02-201-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | When imsm based array is stopped after reaching first checkpoint and then assembled, first checkpoint is reported as 0. This behaviour is valid only for initial checkpoint, if the array was stopped while performing some action. Last checkpoint value is not taken from metadata but always starts with 0 and it's incremented when sync_completed in sysfs changes. In simplification, read_and_act() is responsible for checkpoint updates and is executed each time sysfs checkpoint update happens. For first checkpoint it is executed twice and due to marking checkpoint before triggering any action on the array, it is impossible to read sync_completed from sysfs in just two iterations. The workaround to this is not marking any checkpoint for first sysfs checkpoint after RAID assembly, to preserve checkpoint value stored in metadata. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Revert "mdadm: remove container_enough logic"Mariusz Tkaczyk2024-02-091-1/+31
| | | | | | | | | | | | | | | | | | | | | | | | | Mentioned patch changes way of IMSM member arrays assembling, they are updated by every new drive incremental processes. Previously, member arrays were created and filled once, by last drive incremental process. We determined regressions with various impact. Unfortunately, initial testing didn't show them. Regressions are connected to drive appearance order and may not be reproducible on every configuration, there are at least two know issues for now: - sysfs attributes are filled using old metadata if there is outdated drive and it is enumerated first. - rebuild may be aborted and started from beginning after reboot, if drive under rebuild is enumerated as the last one. This reverts commit 4dde420fc3e24077ab926f79674eaae1b71de10b. It fixes checkpatch issues and reworks logic to remove empty "if" branch in Incremental. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* super-intel: Remove inaccessible codeMateusz Kusiak2024-01-241-17/+0
| | | | | | | Remove inaccessible "if" statement from imsm_set_array_state(). Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Replace "none" with macroMateusz Kusiak2024-01-241-2/+2
| | | | | | | | | | | String "none" is used many times throughout the code. Replace "none" strings with predefined macro. Add str_is_none() for comparing strings with "none". Replace str(n)cmp calls with function. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Define sysfs max buffer sizeMateusz Kusiak2024-01-241-7/+7
| | | | | | | | | | | sysfs_get_str() usages have inconsistant buffer size. This results in wild buffer declarations and redundant memory usage. Define maximum buffer size for sysfs strings. Replace wild sysfs string buffer sizes for globaly defined value. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* Remove all "if zeros"Mateusz Kusiak2023-12-191-28/+0
| | | | | | | | No more random encounters of "if zeros". Remove all "if 0" code blocks. Signed-off-by: Mateusz Kusiak <mateusz.kusiak@intel.com> Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com>
* mdadm: remove container_enough logicPawel Piatkowski2023-10-261-31/+1
| | | | | | | | | | | | | | | | Arrays without enough disk count will be assembled but not started. Now RAIDs will be assembled always (even if they are failed). RAID devices in all states will be assembled and exposed to mdstat. This change affects only IMSM (for ddf it wasn't used, container_enough was set to true always). Removed this logic from incremental_container as well with runstop checking because runstop condition is being verified in assemble_container_content function. Signed-off-by: Pawel Piatkowski <pawel.piatkowski@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* mdadm: Follow POSIX Portable Character SetMariusz Tkaczyk2023-10-261-24/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the user creates a device with a name that contains whitespace, mdadm timeouts and throws an error. This issue is caused by udev, which truncates /dev/md link until the first whitespace. This patch introduces prohibition of characters other than A-Za-z0-9.-_ in the device name. Also, it prohibits using leading "-" in device name, so name won't be confused with cli parameter. Set of allowed characters is taken from POSIX 3.280 Portable Character Set. Also, device name length now is limited to NAME_MAX. In some places, there are other requirements for string length (e.g. size up to MD_NAME_MAX for device name). This routine is made to follow POSIX and other, more strict limitations should be checked separately. We are aware of the risk of regression in exceptional cases (as escape_devname function is removed) that should be fixed by updating the array name. The POSIX validation is added for: - 'name' parameter in every mode. - first devlist entry, for Build, Create, Assemble, Manage, Grow. - config entries, both devname and "name=". Additionally, some manual cleanups are made. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* imsm: Add reading vmd register for finding imsm capabilityMateusz Grzonka2023-09-011-3/+8
| | | | | | | | | | | | Currently mdadm does not find imsm capability when running inside VM. This patch adds the possibility to read from vmd register and check for capability, effectively allowing to use mdadm with imsm inside virtual machines. Additionally refactor find_imsm_capability() to make assignments in new lines. Signed-off-by: Mateusz Grzonka <mateusz.grzonka@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* Fix unsafe string functionsKinga Tanska2023-09-011-3/+3
| | | | | | | | Add string length limitations where necessary to avoid buffer overflows. Signed-off-by: Kinga Tanska <kinga.tanska@intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* imsm: fix free space calculationsMariusz Tkaczyk2023-09-011-20/+30
| | | | | | | | | | | | | | | | | | | | | | | Between two volumes or between last volume and metadata at least IMSM_RESERVED_SECTORS gap must exist. Currently the gap can be doubled because metadata reservation contains IMSM_RESERVED_SECTORS too. Divide reserve variable into pre_reservation and post_reservation to be more flexible and decide separately if each reservation is needed. Pre_reservation is needed only when a volume is created and it is not a real first volume in a container (we can check that by extent_idx). This type of reservation is not needed for expand. Post_reservation is not needed only if real last volume is created or expanded because reservation is done with the metadata. The volume index in metadata cannot be trusted, because the real volume order can be reversed. It is safer to use extent table, it is sorted by start position. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* imsm: return free space after volume for expandMariusz Tkaczyk2023-09-011-34/+37
| | | | | | | | | | | | | | | | merge_extends() routine searches for the biggest free space. For expand, it works only in standard cases where the last volume is expanded and the free space is determined after the last volume. Add volume index to extent struct and use that do determine size after super->current_vol during expand. Limitation to last volume is no longer needed. It unblocks scenarios where kill-subarray is used to remove first volume and later it is recreated (now it is the second volume, even if it is placed before existing one). Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* imsm: move expand verification code into new functionMariusz Tkaczyk2023-09-011-86/+101
| | | | | | | | The code here is too complex. Move it to separate function and simplify it. Add more error messages. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* imsm: introduce round_member_size_to_mb()Mariusz Tkaczyk2023-09-011-10/+21
| | | | | | | Extract rounding logic to separate function. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* imsm: imsm_get_free_size() refactor.Mariusz Tkaczyk2023-09-011-13/+14
| | | | | | | Move minsize calculations up. Add error message if free size is too small. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>
* imsm: move sum_extents calculations to merge_extents()Mariusz Tkaczyk2023-09-011-18/+19
| | | | | | | | This logic is only used by merge_extents() code, there is no need to pass it as parameter. Move it up. Add proper description. Signed-off-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Jes Sorensen <jes@trained-monkey.org>