summaryrefslogtreecommitdiffstats
path: root/lib/device
Commit message (Collapse)AuthorAgeFilesLines
* cleanup: add __attribute__ ((nonnull(1)))Zdenek Kabelac2012-08-231-0/+1
|
* cleanup: use static char[] arrayZdenek Kabelac2012-08-231-1/+1
|
* cleanup: keep MKNOD type cast cleanZdenek Kabelac2012-08-231-1/+1
| | | | Setup major already a dev_t type before it gets shifted.
* cleanup: drop unneeded included header filesZdenek Kabelac2012-08-231-2/+0
| | | | | This headers were not resolving anything used for compiled .c files. Remove unused util.c file.
* dev-io: open device read-only to obtain readahead valuePeter Rajnoha2012-06-251-1/+1
| | | | | | | | | | | | | | | | | | | There's no need to have the device open RW while obtaining the readahead value. The RW open used before caused the CHANGE udev event to be generated if the WATCH udev rule was set for the underlying device (and that is normally the case both for non-dm and dm devices by default). This did not cause any problems before since we were not interested in *underlying* devices. However, with upcoming changes (autoactivation), we're watching for events on underlying devices marked as PVs and such a spurious event could cause the autoactivation code to be triggered. So when trying to deactivate the volume, we could end up with immediate activation just after that because of the CHANGE event originated in the WATCH udev rule since the underlying device was open RW during the deactivation process. Though maybe a better solution would be to completely filter such spurious events out of the autoactivation process somehow, it's still useful if there are as least spurious events generated as possible in the system itself.
* Change message severity to log_very_verbose for missing dev info in udev db.Peter Rajnoha2012-04-111-5/+19
| | | | | | | | | | | | | | | | | | | | | Libudev does not provide transactions when querying udev database - once we get the list of block devices (devices/obtain_device_list_from_udev=1) and we iterate over the list to get more detailed information about device node and symlink names used etc., the device could be removed just in between we get the list and put a query for more info. In this case, libudev returns NULL value as the device does not exist anymore. Recently, we've added a warning message to reveal such situations. However, this could be misleading if the device is not related to the LVM action we're just processing - the non-related block device could be removed in parallel and this is not an error but a possible and normal operation. (N.B. This "missing info" should not happen when devices are related to the LVM action we're just processing since all such processing should be synchronized with udev and the udev db must always be in consistent state after the sync point. But we can't filter this situation out from others, non-related devices, so we have to lower the message verbosity here for a general solution.)
* Better structure layout for device_infoZdenek Kabelac2012-03-121-1/+1
| | | | | | Save some relocation entries and use directly char[]. Since we do not need yes more then 127 partitions per device, use just int8_t. Move lvm_type_filter_destroy into local static function.
* re-word warnings to be clearer to userAlasdair Kergon2012-03-061-3/+3
|
* Validate udev structuresZdenek Kabelac2012-03-041-5/+12
| | | | | | Avoid using NULL pointers from udev. It seems like some older versions of udev were improperly returning NULL in some case, so do not silently break here, and give at least a warning to the user.
* The lvmetad client-side integration. Only active when use_lvmetad = 1 is set inPetr Rockai2012-02-233-0/+38
| | | | lvm.conf *and* lvmetad is running.
* Move lvmcache data structures behind an API (making the structures private toPetr Rockai2012-02-101-5/+1
| | | | lvmcache.c). No functional change.
* Move close few linesZdenek Kabelac2012-02-081-4/+4
| | | | | | | Since the function dev_close() has code path, which really could close file (for unlocked vg) and destroy dev handler, stay on safe side and move the close few lines later, even our current use case shouldn't trigger such scenario.
* Ensure strncpy() function always ends with '\0'Zdenek Kabelac2012-02-081-2/+4
| | | | | Since last character needs to be \0 for string, pass buffer size smaller by 1 byte.
* Minor cleanupZdenek Kabelac2012-01-201-2/+2
| | | | Simplier and more readable char pointer math.
* Drop extra stat before open of deviceZdenek Kabelac2011-12-211-11/+0
| | | | | | Since the !(dev->flags & DEV_REGULAR) code path just called dev_name_confirmed() which has just called 'stat()' inside, remove duplicate second stat() call here.
* Do not lstat common path prefixZdenek Kabelac2011-12-211-0/+7
| | | | | | | | When both path have identical prefix i.e. /dev/disk/by-id skip 2 x lstat() for /dev /dev/disk /dev/disk/by-id and directly lstat() only different part of the path. Reduces amount of lstat calls on system with lots of devices.
* Add common initialization code for struct deviceZdenek Kabelac2011-12-211-23/+16
| | | | | Avoid duplicate code and add _dev_init() where all common member values are initialized.
* Always zalloc device structureZdenek Kabelac2011-12-211-9/+9
| | | | | | Since there is zalloc behind the macro, put 'z' into the name. Make the 'use_malloc' code path also using zalloc() call, so it also give zeroed area.
* Move the core of the lib/config/config.c functionality into libdevmapper,Petr Rockai2011-08-301-4/+4
| | | | | | | leaving behind the LVM-specific parts of the code (convenience wrappers that handle `struct device` and `struct cmd_context`, basically). A number of functions have been renamed (in addition to getting a dm_ prefix) -- namely, all of the config interface now has a dm_config_ prefix.
* Fix warning for pvcreate over MD linear.Milan Broz2011-07-081-4/+10
| | | | | | | If MD linear device has set rounding (overload chunk size attribute), the pvcreate command prints this warning: /dev/md0 sysfs attr level not in expected format: linear
* Use new dev_open_readonly fn to prevent opening devices for read-write when ↵Peter Rajnoha2011-05-284-16/+7
| | | | | | | | | | | | | | | | | | | not necessary. Before, we used vg_write_lock_held call to determnine the way a device is opened. Unfortunately, this opened many devices in RW mode when it was not really necessary. With the OPTIONS+="watch" rule used in the udev rules, this could fire numerous events while closing such devices (and it caused useless scans from within udev rules in return). A common bug we hit with this was with the lvremove command which was unable to remove the LV since it was being opened from within the udev rules. This patch should minimize such situations (at least with respect to LVM handling of devices). Though there's still a possibility someone will open a device 'outside' in parallel and fire the event based on the watch rule when closing a device once opened for RW.
* Add and use dev_open_readonly and variations.Alasdair Kergon2011-05-242-0/+18
|
* Missing space in debug messageZdenek Kabelac2011-04-281-1/+1
|
* Obtain device list from udev by default if LVM2 is compiled with udev support.Peter Rajnoha2011-04-222-11/+116
| | | | | | | | | | | | | | Also, add a new 'obtain_device_list_from_udev' setting to lvm.conf with which we can turn this feature on or off if needed. If set, the cache of block device nodes with all associated symlinks will be constructed out of the existing udev database content. This avoids using and opening any inapplicable non-block devices or subdirectories found in the device directory. This setting is applied to udev-managed device directory only, other directories will be scanned fully. LVM2 needs to be compiled with udev support for this setting to take effect. N.B. Any device node or symlink not managed by udev in udev directory will be ignored with this setting on.
* Add "devices/issue_discards" to lvm.conf.Mike Snitzer2011-04-123-0/+74
| | | | Issue discards on lvremove if enabled and both storage and kernel have support.
* Fix some unmatching sign comparation gcc warningsZdenek Kabelac2011-04-081-1/+2
| | | | Simple replacement for unsigned type - usually in for() loops.
* Remove double bracesZdenek Kabelac2011-03-291-1/+1
| | | | | Clang gives notice about possible confusion as commonly double bracces are used when some assignment is done inside them.
* Fix usage of readlinkZdenek Kabelac2011-03-131-2/+4
| | | | | | Return value of readlink limits valid string size. Characters after returned size present some garbage to printf. Fix it by placing '\0' on the return size value.
* Handle decimal digits with --units instead of ignoring them silently.Alasdair Kergon2011-02-182-8/+8
| | | | Fix remaining warnings and compile with -Wpointer-arith.
* Critical sectionZdenek Kabelac2011-02-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | New strategy for memory locking to decrease the number of call to to un/lock memory when processing critical lvm functions. Introducing functions for critical section. Inside the critical section - memory is always locked. When leaving the critical section, the memory stays locked until memlock_unlock() is called - this happens with sync_local_dev_names() and sync_dev_names() function call. memlock_reset() is needed to reset locking numbers after fork (polldaemon). The patch itself is mostly rename: memlock_inc -> critical_section_inc memlock_dec -> critical_section_dec memlock -> critical_section Daemons (clmvd, dmevent) are using memlock_daemon_inc&dec (mlockall()) thus they will never release or relock memory they've already locked memory. Macros sync_local_dev_names() and sync_dev_names() are functions. It's better for debugging - and also we do not need to add memlock.h to locking.h header (for memlock_unlock() prototyp).
* Do not scan devices unnecessarily for reseting error counterZdenek Kabelac2011-01-171-9/+5
| | | | | For reseting error counter use directly btree cached elements and do not create whole dev_iterator.
* Use const char* const * for dm_regex_create()Zdenek Kabelac2010-12-201-2/+2
| | | | | | | Change API interface to accept even completely const array patterns. This should present no change for libdm users and allows to pass pattern arrays without cast to const char **.
* Add more strict const pointers around config treeZdenek Kabelac2010-12-201-1/+1
| | | | | | To have better control were the config tree could be modified use more const pointers and very carefully downcast them back to non-const (for config tree merge).
* Fix device.c #include to ensure 64-bit fopen64 use. (2.02.51) (robbat2)Alasdair Kergon2010-12-151-1/+2
|
* Fix strict-aliasing compile warning in partition table scanningZdenek Kabelac2010-10-201-9/+9
|
* Limit repeated accesses to broken devices.Petr Rockai2010-10-134-2/+55
| | | | | Signed-off-by: Takahiro Yasui <takahiro.yasui@hds.com> Reviewed-by: Petr Rockai <prockai@redhat.com>
* drop an unnecessary 'stack'Alasdair Kergon2010-09-271-2/+4
|
* Replace alloca with dm_malloc in _aligned_io.Alasdair Kergon2010-09-221-6/+12
| | | | (This section of code dates from 2.4 and could be written more efficiently nowadays.)
* Track recursive filter iteration to avoid refreshing while in use. (2.02.56)Alasdair Kergon2010-09-222-0/+3
|
* Detect LUKS signature in pvcreateMilan Broz2010-08-192-0/+44
| | | | | | | One shiny day we should use libblkid here. But now using LUKS is very common together with LVM and pvcreate destroys LUKS completely. So for user's convenience, try to detect LUKS signature and allow abort.
* Fix file descriptor leak in swap signature detectionMilan Broz2010-08-191-7/+5
|
* Recognise and give preference to md device partitions (blkext major).Peter Rajnoha2010-08-112-2/+2
| | | | | | | We can already detect MD devices internally. But when using MD partitions, these have "block extended major" (blkext) assigned (259). Blkext major is also used in general, so we need to check whether the original device is an MD device actually.
* Use built-in rules for device aliases: block/ < dm- < disk/ < mapper/ < other.Peter Rajnoha2010-08-031-17/+69
|
* Use __attribute__ consistently throughout.Alasdair Kergon2010-07-092-5/+5
|
* Avoid selecting names under /dev/block if there is an alternative.Alasdair Kergon2010-05-241-0/+20
|
* Suppress duplicate error messages about read failures and missing devices.Petr Rockai2010-05-051-6/+6
|
* Fix is_partitioned_dev not to attempt to reopen device.Alasdair Kergon2010-04-061-10/+1
|
* temporarily downgrade the 'open while suspended' error till we fix it properlyAlasdair Kergon2010-04-011-1/+2
|
* Change most remaining log_error WARNING messages to log_warn.Alasdair Kergon2010-04-011-4/+4
|
* Fix pvcreate on a partition (regressed in 2.02.51).Mike Snitzer2009-08-191-5/+7
| | | | | | | | | | | Eliminate busy loop during pvcreate of a "normal" partition. _md_sysfs_attribute_snprintf() would busy loop if the device it was given was not a blkext-based MD partition. Rather than being cute with a busy-loop prone 'goto check_md_major' in _md_sysfs_attribute_snprintf(): explicitly check if the provided device is a blkext-based partition (blkext_major()); and then check that the get_primary_dev() determined parent is an MD device (md_major()).