summaryrefslogtreecommitdiff
path: root/lib/mm/memlock.c
Commit message (Collapse)AuthorAgeFilesLines
* debug: change message levelZdenek Kabelac2021-09-151-2/+2
| | | | These message do not cause command error - switch to debug.
* cov: initialize valueZdenek Kabelac2021-03-111-1/+1
| | | | Coverity can't understand conditions together, so just keep it quiet.
* memlock: allocate at most halve of rlimit stackZdenek Kabelac2020-10-201-4/+7
| | | | | | Touch of stack allocation validated given size with rlimit and if the reserved_stack was above rlimit, its been completely ignored - now we will always touch stack upto rlimit/2 size.
* lvm: add readline alternative editlineBastian Germann2020-09-291-0/+1
| | | | | | | | | | | | | LVM2 is distributed under GPLv2 only. The readline library changed its license long ago to GPLv3. Given that those licenses are incompatible and you follow the FSF in their interpretation that dynamically linking creates a derivative work, distributing LVM2 linked against a current readline version might be legally problematic. Add support for the BSD licensed editline library as an alternative for readline. Link: https://thrysoee.dk/editline
* gcc: use apropriate type for reading and printing valuesZdenek Kabelac2020-08-281-1/+1
|
* memlock: extend exception listZdenek Kabelac2018-07-021-6/+13
| | | | | | Amound of linked libraries grows. Most of them we don't need to lock in, since we are not using them in locked section, so skip locking them in memory.
* locking: memory locking ONLY with suspending reasonZdenek Kabelac2018-07-021-2/+1
| | | | | | | | | | It's important to lock memory beforo running SUSPEND ioctl - but whole lvm preload runs in memory unlocked environment - as in this phase memory allocation is allowed and is meant to happen. Once all targets are preload and ready (confirmed from all targets) we start suspending tree - and here the memory allocation (or i.e. opening files) is no longer allowed - as it may cause kernel deadlock.
* device_mapper: remove dbg_malloc.Joe Thornber2018-06-081-2/+2
| | | | | I wrote dbg_malloc before we had valgrind. These days there's just no need.
* build: Don't generate symlinks in include/ dirJoe Thornber2018-05-141-5/+5
| | | | | | | As we start refactoring the code to break dependencies (see doc/refactoring.txt), I want us to use full paths in the includes (eg, #include "base/data-struct/list.h"). This makes it more obvious when we're breaking abstraction boundaries, eg, including a file in metadata/ from base/
* activation: separate prioritized counterZdenek Kabelac2018-03-151-1/+7
| | | | | | | While prioritized_section() based on raised priority works nicely for standard lvm comman - separate counter is actually needed when it's used in daemons like clvmd/dmeventd where priority stays raised all the time.
* locking: introduce prioritized_sectionZdenek Kabelac2018-03-151-0/+5
| | | | | | | | | | | | | | Introduce prioritized_section() as a closer match to previous logic of critical_section() that has been held over longer sequence of ioctl commands - essentially it's matching operation on a single cookie. While 'critical_section()' now corresponds to locked memory - we hold this memory only between suspend/resume thus notion of 'cookie' was lost. This patch restores some logic unintentionaly lost with dropping memory locking for just activation/deactivation calls.
* activation: keep priority till memlock_unlockZdenek Kabelac2017-12-081-2/+1
| | | | | | | | | | Although it doesn't look like it can be a measurable problem and costs some time to flip priorities outside of activation window. So just like with memory locking preserve priority until call memlock_unlock() appears. (addition to commit c086dfadc389551b9a2d7b4c26931e5e74ada8d6).
* activation: also lock memory for clustered lockingZdenek Kabelac2017-12-041-1/+3
| | | | | Commit c086dfadc389551b9a2d7b4c26931e5e74ada8d6 missed to lock memory for clustering suspend part since it's using differnt locking reason.
* activation: split priority from memory lockingZdenek Kabelac2017-12-011-33/+66
| | | | | | | | | | | | | | When entering any critical section, lvm2 used to lock process memory and raised task priority to avoid problem with page swapping and minimize time of having non-resumed devices in table. With this patch, memory locking which which is expensive is only used when entering 'suspending' section as only in this section there is risk lvm could be suspending a device which later can be needed for paging. Raised priority is still kept for all section entrances as this is low-cost operation and may accelerate table resumes - although the real impact can be still considered later.
* tidy: Add missing underscores to statics.Alasdair G Kergon2017-10-181-3/+3
|
* cleanup: compile fixes for --disable-devmapperZdenek Kabelac2016-06-031-2/+7
| | | | Make lvm2 compilable when configured with: --disable-devmapper.
* doc: change fsf addressZdenek Kabelac2016-01-211-1/+1
| | | | | Hmm rpmlint suggest fsf is using a different address these days, so lets keep it up-to-date
* memlock: add more libs on ignore listZdenek Kabelac2015-11-231-0/+8
| | | | | | Udev recently start to 'link-in' major amount of useless libs. (Seem to be faulty 'systemd' link-in all issue) Anyway - avoid locking those libs in RAM.
* cleanup: gcc warning for old-styleZdenek Kabelac2015-10-231-1/+1
|
* memlock: report memlock daemon counterZdenek Kabelac2015-10-221-0/+5
| | | | | | | Add internal memlock_count_daemon(). Function can be used to recognize it's being executed from daemon restricted execution inside /lib code.
* config: use find_config_tree_array for all arraysPeter Rajnoha2015-07-151-1/+1
| | | | | | | | Use find_config_tree_array for all config arrays. Also, add INTERNAL_ERROR in case there should have been at least default value defined for a setting but it was not returned for some reason (either config_settings.h misconfiguration or other config tree error printed by functions called by find_config_tree_array).
* memory: disable check with valgrind pool buildZdenek Kabelac2015-02-121-1/+3
| | | | | | When lvm2 is build with valgrind pool detection - always disable memcheck, since pool memory allocation are unconditionaly passed into valgrind library.
* memlock: Do not check memory balance if RUNNING_ON_VALGRIND.Petr Rockai2015-02-051-2/+7
|
* cleanup: drop unused varZdenek Kabelac2014-11-181-2/+1
|
* memlock: Make malloc reserve more robust against glibc tricks.Petr Rockai2014-11-181-4/+44
|
* valgrind: don't eat mem with valgrindZdenek Kabelac2014-09-281-0/+3
| | | | | | | | | When compiled with valgrind pool support - don't waste time with preallocation of memory - it just waste of CPU cycles to trace access to this memory. We also may get slightly better estimation about real memory usage during command processing.
* debug: enhance mmap catch codeZdenek Kabelac2014-09-191-17/+12
| | | | | | | Use nice instruction_HLT macro Use log_debug_mem() Don't actually log things after we prohibit 'mmap'. Move initialization of strerror & udev before blocking mmap.
* memlock: ensure memory is allocation before lockingZdenek Kabelac2014-09-191-3/+3
| | | | | strerror may mmap ram if it was not yet used. dm_udev_get_sync_support may initilize udev if it was still not used.
* debug: mmap traps mmap and mmap64 on i386Zdenek Kabelac2014-09-191-16/+46
| | | | | | | Add code to trap both mmap implementation on 32bit arch. Use dlsym() Use hlt instraction instead of int3 - generates usable stack trace when problem is catched.
* debug: enhance trap of mmapZdenek Kabelac2014-09-181-11/+12
| | | | | | Don't install trap for mlockall case Add another code path for -fPIE compilation, in this case the address of mmap function is 'plt' address.
* debug: catch mmap with -DDEBUG_MEMLOCKZdenek Kabelac2014-09-181-0/+68
|
* memlock: skip more entriesZdenek Kabelac2014-06-201-1/+3
| | | | | Add more entries for memlock skipping - since those are never used by lvm code in critical section (suspend state).
* config: differentiate command and metadata profiles and consolidate profile ↵Peter Rajnoha2014-05-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | handling code - When defining configuration source, the code now uses separate CONFIG_PROFILE_COMMAND and CONFIG_PROFILE_METADATA markers (before, it was just CONFIG_PROFILE that did not make the difference between the two). This helps when checking the configuration if it contains correct set of options which are all in either command-profilable or metadata-profilable group without mixing these groups together - so it's a firm distinction. The "command profile" can't contain "metadata profile" and vice versa! This is strictly checked and if the settings are mixed, such profile is rejected and it's not used. So in the end, the CONFIG_PROFILE_COMMAND set of options and CONFIG_PROFILE_METADATA are mutually exclusive sets. - Marking configuration with one or the other marker will also determine the way these configuration sources are positioned in the configuration cascade which is now: CONFIG_STRING -> CONFIG_PROFILE_COMMAND -> CONFIG_PROFILE_METADATA -> CONFIG_FILE/CONFIG_MERGED_FILES - Marking configuration with one or the other marker will also make it possible to issue a command context refresh (will be probably a part of a future patch) if needed for settings in global profile set. For settings in metadata profile set this is impossible since we can't refresh cmd context in the middle of reading VG/LV metadata and for each VG/LV separately because each VG/LV can have a different metadata profile assinged and it's not possible to change these settings at this level. - When command profile is incorrect, it's rejected *and also* the command exits immediately - the profile *must* be correct for the command that was run with a profile to be executed. Before this patch, when the profile was found incorrect, there was just the warning message and the command continued without profile applied. But it's more correct to exit immediately in this case. - When metadata profile is incorrect, we reject it during command runtime (as we know the profile name from metadata and not early from command line as it is in case of command profiles) and we *do continue* with the command as we're in the middle of operation. Also, the metadata profile is applied directly and on the fly on find_config_tree_* fn call and even if the metadata profile is found incorrect, we still need to return the non-profiled value as found in the other configuration provided or default value. To exit immediately even in this case, we'd need to refactor existing find_config_tree_* fns so they can return error. Currently, these fns return only config values (which end up with default values in the end if the config is not found). - To check the profile validity before use to be sure it's correct, one can use : lvm dumpconfig --commandprofile/--metadataprofile ProfileName --validate (the --commandprofile/--metadataprofile for dumpconfig will come as part of the subsequent patch) - This patch also adds a reference to --commandprofile and --metadataprofile in the cmd help string (which was missing before for the --profile for some commands). We do not mention --profile now as people should use --commandprofile or --metadataprofile directly. However, the --profile is still supported for backward compatibility and it's translated as: --profile == --metadataprofile for lvcreate, vgcreate, lvchange and vgchange (as these commands are able to attach profile to metadata) --profile == --commandprofile for all the other commands (--metadataprofile is not allowed there as it makes no sense) - This patch also contains some cleanups to make the code handling the profiles more readable...
* cleanup: corrent indent levelZdenek Kabelac2014-04-141-17/+17
|
* memlock: ignore more librariesZdenek Kabelac2014-04-141-1/+7
| | | | | Extend the list of ignored libraries. Since we do not use those libraries during suspend, skip their locking.
* cleanup: update commentsZdenek Kabelac2014-04-081-2/+2
| | | | Fix cut&paste comments
* cleanup: use DM_ARRAY_SIZEZdenek Kabelac2014-04-081-2/+2
| | | | More use of libdevmapper macro
* cleanup: memlock line indentZdenek Kabelac2014-03-211-1/+1
|
* memlock: drop locked mem in critical sectionZdenek Kabelac2014-03-211-0/+5
| | | | | | | | | | | | | | | When daemon releases memory and it is still in critical section, issue an error message and drop memory. We cannot do anything better for now and we at least release allocated resource. FIXME: This code is triggered when i.e. clvmd is killed while some LVs are suspend - in this case suspended devices leak, so if this happens during i.e. clvmd upgrade we have unresolved problem - even locked rootfs...
* config: add profile arg to find_config_tree_boolPeter Rajnoha2013-07-021-1/+1
|
* config: add profile arg to find_config_tree_intPeter Rajnoha2013-07-021-3/+3
|
* config: add profile arg to find_config_tree_nodePeter Rajnoha2013-07-021-1/+1
|
* config: add support for loading profilesPeter Rajnoha2013-07-021-0/+7
| | | | | | | | | | | | | | | | | | | | | | This patch adds --profile arg to lvm cmds and adds config/profile_dir configuration setting to select the directory where profiles are stored By default it's /etc/lvm/profile. The profiles are added by using new "add_profile" fn and then loaded using the "load_profile" fn. All profiles are stored in a cmd context within the new "struct profile_params": struct profile_params { const char *dir; struct profile *global_profile; struct dm_list profiles_to_load; struct dm_list profiles; }; ...where "dir" is the directory with profiles, "global_profile" is the profile that is set globally via the --profile arg (IOW, not set per VG/LV basis based on metadata record) and the "profiles" is the list with loaded profiles.
* mm: fix leak in fail pathZdenek Kabelac2013-05-131-8/+11
| | | | | | | | | If the dm_realloc would fail, the already allocate _maps_buffer memory would have been lost (overwritten with NULL). Fix this by using temporary line buffer. Also add a minor cleanup to set end of buffer to '\0', only when we really know the file size fits the preallocated buffer.
* config: refer to config nodes using assigned IDsPeter Rajnoha2013-03-061-10/+5
| | | | | | | | | | | | | | | For example, the old call and reference: find_config_tree_str(cmd, "devices/dir", DEFAULT_DEV_DIR) ...now becomes: find_config_tree_str(cmd, devices_dir_CFG) So we're referring to the named configuration ID instead of passing the configuration path and the default value is taken from central config definition in config_settings.h automatically.
* logging: classify log_debug messagesAlasdair G Kergon2013-01-071-22/+22
| | | | Place most log_debug() messages into a class.
* mm: skip mlocking [vectors]Zdenek Kabelac2012-11-201-0/+1
| | | | | | Somehow forgotten: https://www.redhat.com/archives/linux-lvm/2012-June/msg00019.html Need for arm architecture support.
* comments: misc updatesAlasdair G Kergon2012-08-071-0/+1
| | | | Miscellaneous clarifications to comments.
* fix: limit preallocate stack sizeZdenek Kabelac2012-06-221-1/+5
| | | | | | | | If the user would set bigger reserved stack size then what is allowed in resources (ulimit -s), then he would get coredump So avoid coredump and ignore creation of such large stack size (lvm should work properly, with just 64KB, so the option could be eliminated).
* fix: use 64bit math for reserved memoryZdenek Kabelac2012-06-221-4/+4
| | | | | | | | If the user specifies number in the range of [4G/1024, 4G>, the used value would wrap around (32bit math). So keep the math 64bit. Note, using such large lvm.conf values is pointless with lvm2.