mirror of
git://sourceware.org/git/lvm2.git
synced 2025-10-09 23:33:17 +03:00
Compare commits
1 Commits
dev-perf-1
...
dev-dct-pv
Author | SHA1 | Date | |
---|---|---|---|
|
f59cb6632b |
11
.gitignore
vendored
11
.gitignore
vendored
@@ -14,8 +14,6 @@
|
||||
*.so
|
||||
*.so.*
|
||||
*.sw*
|
||||
*.su
|
||||
*.patch
|
||||
*~
|
||||
|
||||
# gcov files:
|
||||
@@ -45,12 +43,6 @@ make.tmpl
|
||||
|
||||
coverity/coverity_model.xml
|
||||
|
||||
/.cache/
|
||||
/compile_commands.json
|
||||
|
||||
/doc/.ikiwiki
|
||||
/public
|
||||
|
||||
/libdm/.symver_check
|
||||
|
||||
daemons/clvmd
|
||||
@@ -58,6 +50,7 @@ daemons/dmfilemapd
|
||||
daemons/lvmetad/
|
||||
|
||||
tools/man-generator
|
||||
tools/man-generator.c
|
||||
|
||||
test/.lib-dir-stamp
|
||||
test/.tests-stamp
|
||||
@@ -151,8 +144,6 @@ test/lib/lvmchange
|
||||
test/lib/lvmdbusd.profile
|
||||
test/lib/lvmdevices
|
||||
test/lib/lvmetad
|
||||
test/lib/lvmlockctl
|
||||
test/lib/lvmlockd
|
||||
test/lib/lvmpolld
|
||||
test/lib/lvm_import_vdo
|
||||
test/lib/lvm_vdo_wrapper
|
||||
|
104
.gitlab-ci.yml
104
.gitlab-ci.yml
@@ -1,104 +0,0 @@
|
||||
stages:
|
||||
- approve
|
||||
- test
|
||||
|
||||
approve1:
|
||||
stage: approve
|
||||
script:
|
||||
- echo "Approved..."
|
||||
rules:
|
||||
# TODO: Filter only safe repositories, or user in developers
|
||||
- if: $CI_PROJECT_PATH != "csonto/lvm2" && $CI_PROJECT_PATH != "lvmteam/lvm2"
|
||||
when: manual
|
||||
# TODO: for other branches than main/rhel: run pipeline only when requested:
|
||||
- if: $CI_COMMIT_BRANCH != "main" && $CI_COMMIT_BRANCH !~ "^rhel.*"
|
||||
when: manual
|
||||
- when: on_success
|
||||
allow_failure: false
|
||||
|
||||
|
||||
pages:
|
||||
image: elecnix/ikiwiki
|
||||
stage: test
|
||||
script:
|
||||
- ikiwiki --setup ikiwiki.setup --libdir themes/ikistrap/lib
|
||||
artifacts:
|
||||
paths:
|
||||
- public
|
||||
only:
|
||||
refs:
|
||||
- main
|
||||
changes:
|
||||
- doc/**/*
|
||||
- ikiwiki.setup
|
||||
|
||||
|
||||
# TODO:
|
||||
# - check results of autoreconf and make generate - may need additional commit
|
||||
# - we need a particular setup (rawhide OR latest supported fedora?)
|
||||
# - do make rpm and publish results as artifacts - we will use packit/COPR for this eventually
|
||||
|
||||
# Run on any commits to main (master), rhel8, rhel9 branches
|
||||
test-job:
|
||||
stage: test
|
||||
parallel:
|
||||
matrix:
|
||||
- TAG: rhel8
|
||||
CONFIGURE: >
|
||||
--with-cluster=internal
|
||||
--enable-cmirrord
|
||||
- TAG: rhel9
|
||||
CONFIGURE: >
|
||||
--with-default-use-devices-file=1
|
||||
--enable-app-machineid
|
||||
--enable-editline
|
||||
--disable-readline
|
||||
artifacts:
|
||||
paths:
|
||||
- test/results/
|
||||
expire_in: 1 week
|
||||
tags:
|
||||
- ${TAG}
|
||||
timeout: 2h
|
||||
script:
|
||||
# Common options go here, diffs to the above matrix
|
||||
- >
|
||||
./configure ${CONFIGURE}
|
||||
--enable-fsadm
|
||||
--enable-write_install
|
||||
--enable-pkgconfig
|
||||
--enable-cmdlib
|
||||
--enable-dmeventd
|
||||
--enable-blkid_wiping
|
||||
--enable-udev_sync
|
||||
--with-thin=internal
|
||||
--with-cache=internal
|
||||
--enable-lvmpolld
|
||||
--enable-lvmlockd-dlm --enable-lvmlockd-dlmcontrol
|
||||
--enable-lvmlockd-sanlock
|
||||
--enable-dbus-service --enable-notify-dbus
|
||||
--enable-dmfilemapd
|
||||
--with-writecache=internal
|
||||
--with-vdo=internal --with-vdo-format=/usr/bin/vdoformat
|
||||
--with-integrity=internal
|
||||
--disable-silent-rules
|
||||
- make
|
||||
- rm -rf test/results
|
||||
- mkdir -p /dev/shm/lvm2-test
|
||||
- mount -o remount,dev /dev/shm
|
||||
# TODO: Need to distinguish failed test from failed harness
|
||||
# TODO: Also need a way to find if run is incomplete, e.g. full disk resulting in many skipped tests
|
||||
- VERBOSE=0 BATCH=1 LVM_TEST_DIR=/dev/shm/lvm2-test make check || true
|
||||
- rm -rf /dev/shm/lvm2-test
|
||||
- cut -d' ' -f2 test/results/list | sort | uniq -c
|
||||
# Filter artifacts - keep only logs from tests which are not pass
|
||||
- cd test/results && rm $(grep 'passed$' list | cut -d' ' -f1 | sed -e 's|/|_|g' -e 's|.*|\0.txt|')
|
||||
# TODO: Keep a list of known failures, and translate into regexp - or simply use python...
|
||||
- if grep failed test/results/list | grep -v '\\\(dbustest\|lvconvert-mirror\)\.sh' | sort; then false; else true; fi
|
||||
rules:
|
||||
# Filter only safe repositories, or user in developers:
|
||||
# NOTE: Already done in approve stage, may be more caution than necessary
|
||||
- if: $CI_PROJECT_PATH != "csonto/lvm2" && $CI_PROJECT_PATH != "lvmteam/lvm2"
|
||||
when: manual
|
||||
- when: on_success
|
||||
|
@@ -38,7 +38,7 @@ ifeq ($(MAKECMDGOALS),distclean)
|
||||
udev po
|
||||
tools.distclean: test.distclean
|
||||
endif
|
||||
DISTCLEAN_DIRS += lcov_reports* autom4te.cache
|
||||
DISTCLEAN_DIRS += lcov_reports*
|
||||
DISTCLEAN_TARGETS += config.cache config.log config.status make.tmpl
|
||||
|
||||
include make.tmpl
|
||||
@@ -55,7 +55,7 @@ po: tools daemons
|
||||
man: tools
|
||||
all_man: tools
|
||||
test: tools daemons
|
||||
unit-test run-unit-test: test libdm
|
||||
unit-test run-unit-test: test
|
||||
|
||||
daemons.device-mapper: libdm.device-mapper
|
||||
tools.device-mapper: libdm.device-mapper
|
||||
@@ -127,7 +127,6 @@ all_man:
|
||||
|
||||
install_system_dirs:
|
||||
$(INSTALL_DIR) $(DESTDIR)$(DEFAULT_SYS_DIR)
|
||||
$(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_SYS_DIR)/devices
|
||||
$(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_ARCHIVE_DIR)
|
||||
$(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_BACKUP_DIR)
|
||||
$(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_CACHE_DIR)
|
||||
@@ -172,7 +171,6 @@ help:
|
||||
@echo " lcov-dated Generate lcov with timedate suffix."
|
||||
@echo " lcov-reset Reset lcov counters"
|
||||
@echo " man Build man pages."
|
||||
@echo " print-VARIABLE Resolve make variable."
|
||||
@echo " rpm Build rpm."
|
||||
@echo " run-unit-test Run unit tests."
|
||||
@echo " tags Generate c/etags."
|
||||
|
29
README
29
README
@@ -1,5 +1,7 @@
|
||||
This tree contains the LVM2 and device-mapper tools and libraries.
|
||||
|
||||
This is development branch, for stable 2.02 release see stable-2.02 branch.
|
||||
|
||||
For more information about LVM2 read the changelog in the WHATS_NEW file.
|
||||
Installation instructions are in INSTALL.
|
||||
|
||||
@@ -10,30 +12,20 @@ Tarballs are available from:
|
||||
https://github.com/lvmteam/lvm2/releases
|
||||
|
||||
The source code is stored in git:
|
||||
https://gitlab.com/lvmteam/lvm2
|
||||
Clone:
|
||||
git clone git@gitlab.com:lvmteam/lvm2.git
|
||||
Anonymous access:
|
||||
git clone https://gitlab.com/lvmteam/lvm2.git
|
||||
Mirrored to:
|
||||
* https://github.com/lvmteam/lvm2
|
||||
https://sourceware.org/git/?p=lvm2.git
|
||||
git clone git://sourceware.org/git/lvm2.git
|
||||
mirrored to:
|
||||
https://github.com/lvmteam/lvm2
|
||||
git clone https://github.com/lvmteam/lvm2.git
|
||||
git clone git@github.com:lvmteam/lvm2.git
|
||||
* https://sourceware.org/git/?p=lvm2.git
|
||||
git clone https://sourceware.org/git/lvm2.git
|
||||
git clone git://sourceware.org/git/lvm2.git
|
||||
|
||||
Mailing list for general discussion related to LVM2:
|
||||
linux-lvm@lists.linux.dev
|
||||
Subscribe via email to: linux-lvm+subscribe@lists.linux.dev
|
||||
Archive https://lore.kernel.org/linux-lvm/
|
||||
Older archive https://listman.redhat.com/archives/linux-lvm/
|
||||
linux-lvm@redhat.com
|
||||
Subscribe from https://www.redhat.com/mailman/listinfo/linux-lvm
|
||||
|
||||
Mailing lists for LVM2 development, patches and commits:
|
||||
lvm-devel@lists.linux.dev
|
||||
Subscribe via email to: lvm-devel+subscribe@lists.linux.dev
|
||||
Archive https://lore.kernel.org/lvm-devel/
|
||||
Older archive https://listman.redhat.com/archives/lvm-devel/
|
||||
lvm-devel@redhat.com
|
||||
Subscribe from https://www.redhat.com/mailman/listinfo/lvm-devel
|
||||
|
||||
lvm2-commits@lists.fedorahosted.org (Read-only archive of commits)
|
||||
Subscribe from https://fedorahosted.org/mailman/listinfo/lvm2-commits
|
||||
@@ -49,7 +41,6 @@ Website:
|
||||
Report upstream bugs at:
|
||||
https://bugzilla.redhat.com/enter_bug.cgi?product=LVM%20and%20device-mapper
|
||||
or open issues at:
|
||||
https://gitlab.com/groups/lvmteam/-/issues
|
||||
https://github.com/lvmteam/lvm2/issues
|
||||
|
||||
The source code repository used until 7th June 2012 is accessible using CVS:
|
||||
|
5
TESTING
5
TESTING
@@ -21,11 +21,6 @@ You MUST disable (or mask) any LVM daemons:
|
||||
- clvmd
|
||||
- cmirrord
|
||||
|
||||
Some lvm.conf options should be set:
|
||||
|
||||
- global/event_activation = 0
|
||||
- activation/monitoring = 0
|
||||
|
||||
For running cluster tests, we are using singlenode locking. Pass
|
||||
`--with-clvmd=singlenode` to configure.
|
||||
|
||||
|
@@ -1 +1 @@
|
||||
1.02.202-git (2024-10-02)
|
||||
1.02.191-git (2022-12-22)
|
||||
|
301
WHATS_NEW
301
WHATS_NEW
@@ -1,148 +1,8 @@
|
||||
Version 2.03.28 -
|
||||
==================
|
||||
|
||||
Version 2.03.27 - 02nd October 2024
|
||||
===================================
|
||||
Fix swap device size detection using blkid for lvresize/lvreduce/lvextend.
|
||||
Detect GPT partition table and pass partition filter if no partitions defined.
|
||||
Add global/sanlock_align_size option to configure sanlock lease size.
|
||||
Disable mem locking when activation/reserved_stack or reserved_memory is 0.
|
||||
Fix locking issues in lvmlockd leaving thin pool locked.
|
||||
Deprecate vdo settings vdo_write_policy and vdo_write_policy.
|
||||
Lots of typo fixes across lvm2 code base (codespell).
|
||||
Corrected integrity parameter interleave_sectors for DM table line.
|
||||
Ignore -i|--stripes, -I|--stripesize for lvextend on raid0 LV, like raid10.
|
||||
Do not accept duplicate device names for pvcreate.
|
||||
|
||||
Version 2.03.26 - 23rd August 2024
|
||||
==================================
|
||||
Fix internal error reported by pvmove on a VG with single PV.
|
||||
Also accept --mknodes --refresh for vgscan.
|
||||
Fix vgmknodes --refresh to wait for udev before checking /dev content.
|
||||
Use log/report_command_log=1 config setting by default for JSON output format.
|
||||
Fix unreleased memory pools on RAID lvextend.
|
||||
Add --integritysettings option to manipulate dm-integrity settings.
|
||||
|
||||
Version 2.03.25 - 12nd July 2024
|
||||
================================
|
||||
Utilize more radix_tree instead of dm_hash and btree.
|
||||
Refactor DM uuid caching from device_mapper directory.
|
||||
Enhance checking for DM uuid device.
|
||||
Fix lvm shell command completion on tab key (2.03.24).
|
||||
Avoid lockd_vg call to lvmlockd for local VGs.
|
||||
Allow forced change of locktype from none.
|
||||
Handle OPTIONS defined in /etc/sysconfig/lvmlockd.
|
||||
|
||||
Version 2.03.24 - 16th May 2024
|
||||
===============================
|
||||
Lvconvert supports VDO options for thin-pool with vdo conversion.
|
||||
Improve placement to .data.rel.ro and .rodata sections.
|
||||
Fix support for -y and -W when creating thinpool with vdo.
|
||||
Better support for runtime valgrind detection.
|
||||
Allow command interruption when communicating with dmeventd.
|
||||
Fix resize of VDO volume used for thin pool data volume.
|
||||
Use -Wl,-z,now and -Wl,--as-needed for compilation by default.
|
||||
Require 3.7 as minimal version for sanlock.
|
||||
Share code for closing opened descriptors on program startup.
|
||||
Fix memleak in lvmcache.
|
||||
Add configure --with-default-event-activation=ON setting.
|
||||
Fix return value from reporter function when hitting internal error.
|
||||
Skip checking of pools for lvremove and vgremove commands.
|
||||
VDO modprobes dm-vdo for 6.9 kernel and kvdo for older kernel version.
|
||||
Fix lvs reporting for VDO volumes with new upstream kernel driver.
|
||||
Don't import DM_UDEV_DISABLE_OTHER_RULES_FLAG in LVM rules, DM rules cover it.
|
||||
Fix table line generation for cache snapshots using cachevol.
|
||||
Enhance lvconvert support for external origins stacking.
|
||||
When swapping LV names also swap properties like hostname, time and data.
|
||||
Fix removal of stacked external origins.
|
||||
Lock filesystem when converting volume to read-only external origin.
|
||||
Support external origin between different thin-pool.
|
||||
Improve validation of acceptable volumes for external origins.
|
||||
Reduce amount of preloaded devices for complex device trees.
|
||||
Avoid logging problems from monitoring snapshots with inactive origins.
|
||||
Check for cache policy module presence in kernel's builtin modules file.
|
||||
Add configure --with-modulesdir to select kernel modules directory.
|
||||
Support creation of thin-pool with VDO use for its data volume.
|
||||
|
||||
Version 2.03.23 - 21st November 2023
|
||||
version 2.03.19 -
|
||||
====================================
|
||||
Set the first lv_attr flag for raid integrity images to i or I.
|
||||
Add -A option for pvs and pvscan to show PVs outside devices file.
|
||||
Improve searched_devnames temp file usage to prevent redundant scanning.
|
||||
Change default search_for_devnames from auto to all.
|
||||
Add lvmdevices --refresh to search for missing PVIDs on all devices.
|
||||
Add comparison between old and new entries in lvmdevices --check.
|
||||
Fix device_id matching order - match non-devname first.
|
||||
Fix "lvconvert -m 0" when there is other than first in-sync leg.
|
||||
Use system.devices as default for dmeventd when dmeventd.devices is undefined.
|
||||
Accept WWIDs containing QEMU HARDDISK for device_id.
|
||||
Improve handling of non-standard WWID prefixes used for device_id.
|
||||
Configure automatically enables cmdlib for dmeventd and notify-dbus for dbus.
|
||||
Fix hint calculation for pools with zero or error segment.
|
||||
Configure supports --disable-shared to build only static binaries.
|
||||
Configure supports --without-{blkid|systemd|udev} for easier static build.
|
||||
Refresh device ids if the system changes.
|
||||
Fix pvmove when specifying raid components as moved LVs.
|
||||
Enhance error detection for lvm_import_vdo.
|
||||
Support PV lists with thin lvconvert.
|
||||
Fix support for lvm_import_vdo with SCSI VDO volumes.
|
||||
Fix locking issue leading to hanging concurrent vgchange --refresh.
|
||||
Recognise lvm.conf report/headings=2 for full column names in report headings.
|
||||
Add --headings none|abbrev|full cmd line option to set report headings type.
|
||||
Fix conversion to thin pool using lvmlockd.
|
||||
Fix conversion from thick into thin volume using lvmlockd.
|
||||
Require writable LV for conversion to vdo pool.
|
||||
Fix return value from lvconvert integrity remove.
|
||||
Preserve UUID for pool metadata spare.
|
||||
Preserve UUID for swapped pool metadata.
|
||||
Rewrite validation of device name entries used as device_id.
|
||||
|
||||
version 2.03.22 - 02nd August 2023
|
||||
==================================
|
||||
Fix pv_major/pv_minor report field types so they are integers, not strings.
|
||||
Add lvmdevices --delnotfound to delete entries for missing devices.
|
||||
Always use cachepool name for metadata backup LV for lvconvert --repair.
|
||||
Make metadata backup LVs read-only after pool's lvconvert --repair.
|
||||
Improve VDO and Thin support with lvmlockd.
|
||||
Handle 'lvextend --usepolicies' for pools for all activation variants.
|
||||
Fix memleak in vgchange autoactivation setup.
|
||||
Update py-compile building script.
|
||||
Support conversion from thick to fully provisioned thin LV.
|
||||
Cache/Thin-pool can use error and zero volumes for testing.
|
||||
Individual thin volume can be cached, but cannot take snapshot.
|
||||
Better internal support for handling error and zero target (for testing).
|
||||
Resize COW above trimmed maximal size is does not return error.
|
||||
Support parsing of vdo geometry format version 4.
|
||||
Add lvm.conf thin_restore and cache_restore settings.
|
||||
Handle multiple mounts while resizing volume with a FS.
|
||||
Handle leading/trailing spaces in sys_wwid and sys_serial used by device_id.
|
||||
Enhance lvm_import_vdo and use snapshot when converting VDO volume.
|
||||
Fix parsing of VDO metadata.
|
||||
Fix failing -S|--select for non-reporting cmds if using LV info/status fields.
|
||||
Allow snapshots of raid+integrity LV.
|
||||
Fix multisegment RAID1 allocator to prevent using single disk for more legs.
|
||||
|
||||
version 2.03.21 - 21st April 2023
|
||||
=================================
|
||||
Fix activation of vdo-pool for with 0 length headers (converted pools).
|
||||
Avoid printing internal init messages when creation integration devices.
|
||||
Allow (write)cache over raid+integrity LV.
|
||||
|
||||
version 2.03.20 - 21st March 2023
|
||||
=================================
|
||||
Fix segfault if using -S|--select with log/report_command_log=1 setting.
|
||||
Configure now fails when requested lvmlockd dependencies are missing.
|
||||
Add some configure Gentoo enhancements for static builds.
|
||||
|
||||
version 2.03.19 - 21st February 2023
|
||||
====================================
|
||||
Configure supports --with-systemd-run executed from udev rules.
|
||||
Enhancement for build with MuslC systemd and non-bash system shells (dash).
|
||||
Do not reset SYSTEMD_READY variable in udev for PVs on MD and loop devices.
|
||||
Ensure udev is processing origin LV before its thick snapshots LVs.
|
||||
Fix and improve runtime memory size detection for VDO volumes.
|
||||
|
||||
version 2.03.18 - 22nd December 2022
|
||||
version 2.03.18 - 22nd december 2022
|
||||
====================================
|
||||
Fix issues reported by coverity scan.
|
||||
Fix warning for thin pool overprovisioning on lvextend (2.03.17).
|
||||
@@ -157,7 +17,6 @@ Version 2.03.17 - 10th November 2022
|
||||
Switch to use mallinfo2 and use it only with glibc.
|
||||
Error out in lvm shell if using a cmd argument not supported in the shell.
|
||||
Fix lvm shell's lastlog command to report previous pre-command failures.
|
||||
Keep libaio locked in memory in critical section.
|
||||
Extend VDO and VDOPOOL without flushing and locking fs.
|
||||
Add --valuesonly option to lvmconfig to print only values without keys.
|
||||
Updates configure with recent autoconf tooling.
|
||||
@@ -177,7 +36,7 @@ Version 2.03.16 - 18th May 2022
|
||||
--deldev.
|
||||
Display writecache block size with lvs -o writecache_block_size.
|
||||
Improve cachesettings description in man lvmcache.
|
||||
Fix losing of delete message on thin-pool extension.
|
||||
Fix lossing of delete message on thin-pool extension.
|
||||
|
||||
Version 2.03.15 - 07th February 2022
|
||||
====================================
|
||||
@@ -264,8 +123,8 @@ Version 2.03.12 - 07th May 2021
|
||||
Fix problem with unbound variable usage within fsadm.
|
||||
Fix IMSM MD RAID detection on 4k devices.
|
||||
Check for presence of VDO target before starting any conversion.
|
||||
Support metadata profiles with volume VDO pool conversions.
|
||||
Support -Zn for conversion of already formatted VDO pools.
|
||||
Support metatadata profiles with volume VDO pool conversions.
|
||||
Support -Zn for conversion of already formated VDO pools.
|
||||
Avoid removing LVs on error path of lvconvert during creation volumes.
|
||||
Fix crashing lvdisplay when thin volume was waiting for merge.
|
||||
Support option --errorwhenfull when converting volume to thin-pool.
|
||||
@@ -295,7 +154,7 @@ Version 2.03.11 - 08th January 2021
|
||||
Enhance error handling for fsadm and handle correct fsck result.
|
||||
Dmeventd lvm plugin ignores higher reserved_stack lvm.conf values.
|
||||
Support using BLKZEROOUT for clearing devices.
|
||||
Support interruption when wiping LVs.
|
||||
Support interruption when wipping LVs.
|
||||
Support interruption for bcache waiting.
|
||||
Fix bcache when device has too many failing writes.
|
||||
Fix bcache waiting for IO completion with failing disks.
|
||||
@@ -422,7 +281,7 @@ Version 2.03.03 - 07th June 2019
|
||||
Ignore foreign and shared PVs for pvscan online files.
|
||||
Add config setting to control fields in debug file and verbose output.
|
||||
Add command[pid] and timestamp to debug file and verbose output.
|
||||
Fix missing growth of _pmspare volume when extending _tmeta volume.
|
||||
Fix missing growth of _pmsmare volume when extending _tmeta volume.
|
||||
Automatically grow thin metadata, when thin data gets too big.
|
||||
Add synchronization with udev before removing cached devices.
|
||||
Add support for caching VDO LVs and VDOPOOL LVs.
|
||||
@@ -435,14 +294,14 @@ Version 2.03.03 - 07th June 2019
|
||||
Change scan_lvs default to 0 so LVs are not scanned for PVs.
|
||||
Thin-pool selects power-of-2 chunk size by default.
|
||||
Cache selects power-of-2 chunk size by default.
|
||||
Support resizing for VDOPoolLV and VDOLV.
|
||||
Support reszing for VDOPoolLV and VDOLV.
|
||||
Improve -lXXX%VG modifier which improves cache segment estimation.
|
||||
Ensure migration_threshold for cache is at least 8 chunks.
|
||||
Restore missing man info lvcreate --zero for thin-pools.
|
||||
Drop misleading comment for metadata minimum_io_size for VDO segment.
|
||||
Drop misleadning comment for metadata minimum_io_size for VDO segment.
|
||||
Add device hints to reduce scanning.
|
||||
Introduce LVM_SUPPRESS_SYSLOG to suppress syslog usage by generator.
|
||||
Fix generator querying lvmconfig unpresent config option.
|
||||
Fix generator quering lvmconfig unpresent config option.
|
||||
Fix memleak on bcache error path code.
|
||||
Fix missing unlock on lvm2 dmeventd plugin error path initialization.
|
||||
Improve Makefile dependency tracking.
|
||||
@@ -504,7 +363,7 @@ Version 2.02.178-rc1 - 24th May 2018
|
||||
--with-cache switch for ./configure has been removed.
|
||||
Include new unit-test framework and unit tests.
|
||||
Extend validation of region_size for mirror segment.
|
||||
Reload whole device stack when reinitializing mirror log.
|
||||
Reload whole device stack when reinitilizing mirror log.
|
||||
Mirrors without monitoring are WARNING and not blocking on error.
|
||||
Detect too big region_size with clustered mirrors.
|
||||
Fix evaluation of maximal region size for mirror log.
|
||||
@@ -549,7 +408,7 @@ Version 2.02.178-rc1 - 24th May 2018
|
||||
Restore pvmove support for wide-clustered active volumes (2.02.177).
|
||||
Avoid non-exclusive activation of exclusive segment types.
|
||||
Fix trimming sibling PVs when doing a pvmove of raid subLVs.
|
||||
Preserve exclusive activation during thin snapshot merge.
|
||||
Preserve exclusive activation during thin snaphost merge.
|
||||
Avoid exceeding array bounds in allocation tag processing.
|
||||
Add --lockopt to common options and add option to skip selected locks.
|
||||
|
||||
@@ -565,7 +424,7 @@ Version 2.02.177 - 18th December 2017
|
||||
Fix lvmlockd to use pool lock when accessing _tmeta volume.
|
||||
Report expected sanlock_convert errors only when retries fail.
|
||||
Avoid blocking in sanlock_convert on SH to EX lock conversion.
|
||||
Deactivate missing raid LV legs (_rimage_X-missing_Y_Z) on deactivation.
|
||||
Deactivate missing raid LV legs (_rimage_X-missing_Y_Z) on decativation.
|
||||
Skip read-modify-write when entire block is replaced.
|
||||
Categorise I/O with reason annotations in debug messages.
|
||||
Allow extending of raid LVs created with --nosync after a failed repair.
|
||||
@@ -587,7 +446,7 @@ Version 2.02.177 - 18th December 2017
|
||||
Check raid reshape flags in vg_validate().
|
||||
Add support for pvmove of cache and snapshot origins.
|
||||
Avoid using precommitted metadata for suspending pvmove tree.
|
||||
Enhance pvmove locking.
|
||||
Ehnance pvmove locking.
|
||||
Deactivate activated LVs on error path when pvmove activation fails.
|
||||
Add "io" to log/debug_classes for logging low-level I/O.
|
||||
Eliminate redundant nested VG metadata in VG struct.
|
||||
@@ -677,13 +536,13 @@ Version 2.02.173 - 20th July 2017
|
||||
|
||||
Version 2.02.172 - 28th June 2017
|
||||
=================================
|
||||
Add missing NULL to argv array when splitting cmdline arguments.
|
||||
Add missing NULL to argv array when spliting cmdline arguments.
|
||||
Add display_percent helper function for printing percent values.
|
||||
lvconvert --repair handles failing raid legs (present but marked 'D'ead).
|
||||
Do not lvdisplay --maps unset settings of cache pool.
|
||||
Fix lvdisplay --maps for cache pool without policy settings.
|
||||
Support aborting of flushing cache LV.
|
||||
Re-enable conversion of data and metadata thin-pool volumes to raid.
|
||||
Reenable conversion of data and metadata thin-pool volumes to raid.
|
||||
Improve raid status reporting with lvs.
|
||||
No longer necessary to '--force' a repair for RAID1.
|
||||
Linear to RAID1 upconverts now use "recover" sync action, not "resync".
|
||||
@@ -751,7 +610,7 @@ Version 2.02.169 - 28th March 2017
|
||||
Support cache segment with configurable metadata format.
|
||||
Add allocation/cache_metadata_format profilable settings.
|
||||
Use function cache_set_params() for both lvcreate and lvconvert.
|
||||
Skip rounding on cache chunk size boundary when create cache LV.
|
||||
Skip rounding on cache chunk size boudary when create cache LV.
|
||||
Improve cache_set_params support for chunk_size selection.
|
||||
Fix metadata profile allocation/cache_[mode|policy] setting.
|
||||
Fix missing support for using allocation/cache_pool_chunk_size setting.
|
||||
@@ -801,8 +660,8 @@ Version 2.02.169 - 28th March 2017
|
||||
Extend metadata validation of external origin LV use count.
|
||||
Fix dm table when the last user of active external origin is removed.
|
||||
Improve reported lvs status for active external origin volume.
|
||||
Fix table load for split RAID LV and require explicit activation.
|
||||
Always active split RAID LV exclusively locally.
|
||||
Fix table load for splitted RAID LV and require explicit activation.
|
||||
Always active splitted RAID LV exclusively locally.
|
||||
Do not use LV RAID status bit for segment status.
|
||||
Check segtype directly instead of checking RAID in segment status.
|
||||
Reusing exiting code for raid image removal.
|
||||
@@ -865,7 +724,7 @@ Version 2.02.166 - 26th September 2016
|
||||
Use --alloc normal for mirror logs even if the mimages were stricter.
|
||||
Use O_DIRECT to gather metadata in lvmdump.
|
||||
Ignore creation_time when checking for matching metadata for lvmetad.
|
||||
Fix possible NULL pointer dereference when checking for monitoring.
|
||||
Fix possible NULL pointer derefence when checking for monitoring.
|
||||
Add lvmreport(7) man page.
|
||||
Don't install lvmraid(7) man page when raid excluded. (2.02.165)
|
||||
Report 0% as dirty (copy%) for cache without any used block.
|
||||
@@ -905,7 +764,7 @@ Version 2.02.164 - 15th August 2016
|
||||
Version 2.02.163 - 10th August 2016
|
||||
===================================
|
||||
Add profile for lvmdbusd which uses lvm shell json report output.
|
||||
Restrict in-command modification of some params in lvm shell.
|
||||
Restrict in-command modification of some parms in lvm shell.
|
||||
Apply LVM_COMMAND_PROFILE early for lvm shell.
|
||||
Refactor reporting so lvm shell log report collects whole of cmd execution.
|
||||
Support LVM_*_FD envvars to redirect output to file descriptors.
|
||||
@@ -1058,11 +917,11 @@ Version 2.02.152 - 30th April 2016
|
||||
==================================
|
||||
Use any inherited tags when wiping metadata sub LVs to ensure activation.
|
||||
Add str_list_wipe.
|
||||
Improve support for interrupting processing of volumes during lvchange.
|
||||
Improve support for interrupting procesing of volumes during lvchange.
|
||||
Use failed command return code when lvchanging read-only volume.
|
||||
Show creation transaction_id and zeroing state of pool with thin volume.
|
||||
Stop checking for dm_cache_mq policy with cache target 1.9 (alias to smq).
|
||||
Check first /sys/module/dm_* dir existence before using modprobe.
|
||||
Check first /sys/module/dm_* dir existance before using modprobe.
|
||||
Remove mpath from 10-dm.rules, superseded by 11-dm-mpath.rules (mpath>=0.6.0).
|
||||
|
||||
Version 2.02.151 - 23rd April 2016
|
||||
@@ -1087,7 +946,7 @@ Version 2.02.150 - 9th April 2016
|
||||
=================================
|
||||
Avoid using flushing dm status ioctl when checking for usable DM device.
|
||||
Check for devices without LVM- uuid prefix only with kernels < 3.X.
|
||||
Reuse %FREE size approximation with lvcreate -l%PVS thin-pool.
|
||||
Reuse %FREE size aproximation with lvcreate -l%PVS thin-pool.
|
||||
Allow the lvmdump directory to exist already provided it is empty.
|
||||
Show lvconverted percentage with 2 decimal digits.
|
||||
Fix regression in suspend when repairing --type mirror (2.02.133).
|
||||
@@ -1164,7 +1023,7 @@ Version 2.02.143 - 21st February 2016
|
||||
Fix error path when sending thin-pool message fails in update_pool_lv().
|
||||
Support reporting CheckNeeded and Fail state for thin-pool and thin LV.
|
||||
For failing thin-pool and thin volume correctly report percentage as INVALID.
|
||||
Report -1, not 'unknown' for lv_{snapshot_invalid,merge_failed} with --binary.
|
||||
Report -1, not 'unkown' for lv_{snapshot_invalid,merge_failed} with --binary.
|
||||
Add configure --enable-dbus-service for an LVM D-Bus service.
|
||||
Replace configure --enable-python_bindings with python2 and python3 versions.
|
||||
If PV belongs to some VG and metadata missing, skip it if system ID is used.
|
||||
@@ -1193,7 +1052,7 @@ Version 2.02.141 - 25th January 2016
|
||||
Restore support for command breaking in process_each_lv_in_vg() (2.02.118).
|
||||
Use correct mempool when process_each_lv_in_vg() (2.02.118).
|
||||
Fix lvm.8 man to show again prohibited suffixes.
|
||||
Fix configure to set proper use_blkid_wiping if autodetection as disabled.
|
||||
Fix configure to set proper use_blkid_wiping if autodetected as disabled.
|
||||
Initialise udev in clvmd for use in device scanning. (2.02.116)
|
||||
Add seg_le_ranges report field for common format when displaying seg devices.
|
||||
Honour report/list_item_separator for seg_metadata_le_ranges report field.
|
||||
@@ -1343,7 +1202,7 @@ Version 2.02.129 - 26th August 2015
|
||||
Fix shared library generation to stop exporting internal functions.(2.02.120)
|
||||
Accept --cachemode with lvconvert.
|
||||
Fix and improve reporting properties of cache-pool.
|
||||
Enable usage of --cachepolicy and --cachesettings with lvconvert.
|
||||
Enable usage of --cachepolicy and --cachesetting with lvconvert.
|
||||
Don't allow to reduce size of thin-pool metadata.
|
||||
Fix debug buffer overflows in cmirrord logging.
|
||||
Add --foreground and --help to cmirrord.
|
||||
@@ -1500,7 +1359,7 @@ Version 2.02.119 - 2nd May 2015
|
||||
Add --enable-halvm and --disable-halvm options to lvmconf script.
|
||||
Add --services, --mirrorservice and --startstopservices option to lvmconf.
|
||||
Use proper default value of global/use_lvmetad when processing lvmconf script.
|
||||
Respect allocation/cling_tag_list during initial contiguous allocation.
|
||||
Respect allocation/cling_tag_list during intial contiguous allocation.
|
||||
Add A_PARTITION_BY_TAGS set when allocated areas should not share tags.
|
||||
Make changes persist with python addTag/removeTag.
|
||||
Set correct vgid when updating cache when writing PV metadata.
|
||||
@@ -1578,7 +1437,7 @@ Version 2.02.116 - 30th January 2015
|
||||
Scan pools in for_each_sub_lv() and add for_each_sub_lv_except_pools().
|
||||
Fix lvm2app lvm_lv_get_property return value for fields with info/status ioctl.
|
||||
Fix lvm2app regression in lvm_lv_get_attr causing unknown values (2.02.115).
|
||||
Set default cache_mode to writethrough when missing in metadata.
|
||||
Set default cache_mode to writehrough when missing in metadata.
|
||||
Preserve chunk size with repair and metadata swap of a thin pool.
|
||||
Fix raid --splitmirror 1 functionality (2.02.112).
|
||||
Fix tree preload to handle splitting raid images.
|
||||
@@ -1644,13 +1503,13 @@ Version 2.02.112 - 11th November 2014
|
||||
Properly report error when taking snapshot of any cache type LV.
|
||||
Add basic thread debugging messages to dmeventd.
|
||||
Include threads being shutdown in dmeventd device registration responses.
|
||||
Initial support for external users of thin pools based on transaction_id.
|
||||
Inital support for external users of thin pools based on transaction_id.
|
||||
Report some basic percentage info for cache pools.
|
||||
Introduce size_mb_arg_with_percent() for advanced size arg reading.
|
||||
Add extra support for '.' as decimal point in size args.
|
||||
Add configure parameters for default segment type choices.
|
||||
Add global/sparse_segtype_default setting to use thin for --type sparse.
|
||||
Update and correct lvcreate and lvconvert man pages.
|
||||
Update and correct lvcreate and lvcovert man pages.
|
||||
Mark pools and snapshots as unzeroable volumes.
|
||||
Check for zeroing of volume after segment type is fully detected.
|
||||
Better support for persistent major and minor options with lvcreate.
|
||||
@@ -1703,7 +1562,7 @@ Version 2.02.112 - 11th November 2014
|
||||
Support DEBUG_MEMLOCK to trap unsupported mmap usage.
|
||||
Enable cache segment type by default.
|
||||
Ensure only supported volume types are used with cache segments.
|
||||
Fix inability to specify cachemode when 'lvconvert'ing to cache-pool.
|
||||
Fix inablility to specify cachemode when 'lvconvert'ing to cache-pool.
|
||||
Grab cluster lock for active LVs when setting clustered attribute.
|
||||
Use va_copy to properly pass va_list through functions.
|
||||
Add function to detect rotational devices.
|
||||
@@ -1771,7 +1630,7 @@ Version 2.02.108 - 23rd July 2014
|
||||
Enhance lvconvert thin, thinpool, cache and cachepool command line support.
|
||||
Display 'C' only for cache and cache-pool target types in lvs.
|
||||
Prompt for confirmation before change LV into a snapshot exception store.
|
||||
Return proper error codes for some failing lvconvert functions.
|
||||
Return proper error codes for some failing lvconvert funtions.
|
||||
Add initial code to use cache tools (cache_check|dump|repair|restore).
|
||||
Support lvdisplay --maps for raid.
|
||||
Add --activationmode degraded to activate degraded raid volumes by default.
|
||||
@@ -1790,7 +1649,7 @@ Version 2.02.108 - 23rd July 2014
|
||||
Support lvremove -ff to remove thin volumes from broken thin pools.
|
||||
Require --yes to skip raid repair prompt.
|
||||
Change makefile %.d generation to handle filename changes without make clean.
|
||||
Fix use of builddir in make pofile.
|
||||
Fix use of buildir in make pofile.
|
||||
Enhance private volumes UUIDs with suffixed for easier detection.
|
||||
Do not use reserved _[tc]meta volumes for temporary LVs.
|
||||
Leave backup pool metadata with _meta%d suffix instead of reserved _tmeta%d.
|
||||
@@ -1895,7 +1754,7 @@ Version 2.02.106 - 10th April 2014
|
||||
Include 'lvm dumpconfig --type missing' and '--type diff' output to lvmdump.
|
||||
Return failure when specifying negative size for pvresize.
|
||||
Fix memory corruption in cmd context refresh if clvmd leaks opened device.
|
||||
Reinitialize lvmcache properly on fork to fix premature polldaemon exit.
|
||||
Reinitialise lvmcache properly on fork to fix premature polldaemon exit.
|
||||
Add 'lvm dumpconfig --type diff' to show differences from defaults.
|
||||
Fix swap signature detection for devices smaller then 2MB.
|
||||
Use dm_malloc function in clvmd.c.
|
||||
@@ -1922,7 +1781,7 @@ Version 2.02.106 - 10th April 2014
|
||||
Don't print an error and accept empty value for global/thin_disabled_features.
|
||||
Update API for internal function build_dm_uuid().
|
||||
Do not try to check empty pool with scheduled messages.
|
||||
Fix return value in pool_has_message() when querying for any message.
|
||||
Fix return value in pool_has_message() when quering for any message.
|
||||
Cleanup all client resources on clvmd exit.
|
||||
Use dm_zalloc to clear members of clvmd client struct.
|
||||
Use BLKID_CFLAGS when compiling with blkid support.
|
||||
@@ -1964,7 +1823,7 @@ Version 2.02.106 - 10th April 2014
|
||||
Fix test when checking target version for available thin features.
|
||||
Detect thin feature external_origin_extend and limit extend when missing.
|
||||
Rename internal pool_can_resize_metadata() to thin_pool_feature_supported().
|
||||
Issue error if libblkid detects signature and fails to return offset/length.
|
||||
Issue error if libbblkid detects signature and fails to return offset/length.
|
||||
Update autoconf config.guess/sub to 2014-01-01.
|
||||
Online thin pool metadata resize requires 1.10 kernel thin pool target.
|
||||
|
||||
@@ -2037,7 +1896,7 @@ Version 2.02.104 - 13th November 2013
|
||||
=====================================
|
||||
Workaround VG refresh race during autoactivation by retrying the refresh.
|
||||
Handle failures in temporary mirror used when adding images to mirrors.
|
||||
Fix and improve logic for implicitly exclusive activations.
|
||||
Fix and improve logic for implicitely exclusive activations.
|
||||
Return success when LV cannot be activated because of volume_list filter.
|
||||
Return proper error state for remote exclusive activation.
|
||||
Fix missing lvmetad scan for PVs found on MD partitions.
|
||||
@@ -2200,11 +2059,11 @@ Version 2.02.99 - 24th July 2013
|
||||
Add support for persistent flagging of LVs to be skipped during activation.
|
||||
Add --type profilable to lvm dumpconfig to show profilable config settings.
|
||||
Add --mergedconfig to lvm dumpconfig for merged --config/--profile/lvm.conf.
|
||||
Release memory and unblock signals in lock_vol error path.
|
||||
Relase memory and unblock signals in lock_vol error path.
|
||||
Define LVM2_* command errors in lvm2cmd.h and use in dmeventd plugins.
|
||||
Move errors.h to tools dir.
|
||||
Add man page entries for profile configuration and related options.
|
||||
Improve error logging when user tries to interrupt commands.
|
||||
Improve error loging when user tries to interrupt commands.
|
||||
Rename _swap_lv to _swap_lv_identifiers and move to allow an additional user.
|
||||
Rename snapshot segment returning methods from find_*_cow to find_*_snapshot.
|
||||
liblvm/python API: Additions: PV create/removal/resize/listing
|
||||
@@ -2405,7 +2264,7 @@ Version 2.02.98 - 15th October 2012
|
||||
Do not start dmeventd for lvchange --resync when monitoring is off.
|
||||
Remove pvscan --cache from lvm2-lvmetad init script.
|
||||
Remove ExecStartPost with pvscan --cache from lvm2-lvmetad.service.
|
||||
Report invalid percentage for property snap_percent of non-snapshot LVs.
|
||||
Report invalid percentage for property snap_percent of non-snaphot LVs.
|
||||
Disallow conversion of thin LVs to mirrors.
|
||||
Fix lvm2api data_percent reporting for thin volumes.
|
||||
Do not allow RAID LVs in a clustered volume group.
|
||||
@@ -2455,7 +2314,7 @@ Version 2.02.98 - 15th October 2012
|
||||
|
||||
Version 2.02.97 - 7th August 2012
|
||||
=================================
|
||||
Improve documentation of allocation policies in lvm.8.
|
||||
Improve documention of allocation policies in lvm.8.
|
||||
Increase limit for major:minor to 4095:1048575 when using -My option.
|
||||
Add make install_systemd_generators.
|
||||
Add generator for lvm2 activation systemd units.
|
||||
@@ -2539,7 +2398,7 @@ Version 2.02.96 - 8th June 2012
|
||||
Check for buffer overwrite in get_cluster_type() in clvmd.
|
||||
Fix global/detect_internal_vg_cache_corruption config check.
|
||||
Update lcov Makefile target to support all dmeventd plugins.
|
||||
Fix initialization of thin monitoring. (2.02.92)
|
||||
Fix initializiation of thin monitoring. (2.02.92)
|
||||
Cope with improperly formatted device numbers in /proc/devices. (2.02.91)
|
||||
Exit if LISTEN_PID environment variable incorrect in lvmetad systemd handover.
|
||||
Use pvscan --cache instead of vgscan in lvmetad scripts.
|
||||
@@ -2552,7 +2411,7 @@ Version 2.02.96 - 8th June 2012
|
||||
Add --with-thin-check configure option for path to thin_check.
|
||||
Fix error message when pvmove LV activation fails with name already in use.
|
||||
Better structure layout for device_info in dev_subsystem_name().
|
||||
Change message severity for creation of VG over uninitialized devices.
|
||||
Change message severity for creation of VG over uninitialised devices.
|
||||
Fix error path for failed toolcontext creation.
|
||||
Detect lvm binary path in lvmetad udev rules.
|
||||
Don't unlink socket on lvmetad shutdown if instantiated from systemd.
|
||||
@@ -2587,7 +2446,7 @@ Version 2.02.94 - 3rd March 2012
|
||||
Add some close() and dev_close() error path backtraces.
|
||||
Set stdin/stdout/stderr to /dev/null for polldaemon.
|
||||
Limit the max size of processed clvmd message to ~8KB.
|
||||
Do not send uninitialized bytes in cluster error reply messages.
|
||||
Do not send uninitialised bytes in cluster error reply messages.
|
||||
Use unsigned type for bitmask instead of enum type for lvm properties.
|
||||
Add missing cleanup of excl_uuid hash on some exit paths of clvmd.
|
||||
Check for existence of vg_name in _format1/_pool_vg_read().
|
||||
@@ -2660,7 +2519,7 @@ Version 2.02.91 - 12th February 2012
|
||||
|
||||
Version 2.02.90 - 1st February 2012
|
||||
===================================
|
||||
sync_local_dev_names before (re)activating mirror log for initialization.
|
||||
sync_local_dev_names before (re)activating mirror log for initialisation.
|
||||
Disable partial activation for thin LVs and LVs with all missing segments.
|
||||
Do not print warning for pv_min_size between 512KB and 2MB.
|
||||
Clean up systemd unit ordering and requirements.
|
||||
@@ -2679,7 +2538,7 @@ Version 2.02.89 - 26th January 2012
|
||||
Add data_percent and metadata_percent for thin pools to lvs -v.
|
||||
Add data_lv & metadata_lv fields to lvs for thin pools.
|
||||
Add data_percent & pool_lv fields to lvs for thin volumes.
|
||||
Rename origin_only param to use_layer for lv_info and use with thin LVs.
|
||||
Rename origin_only parm to use_layer for lv_info and use with thin LVs.
|
||||
Add lv_thin_pool_transaction_id to read the transaction_id value.
|
||||
Use {suspend,resume}_origin_only when up-converting RAID, as mirrors do.
|
||||
Always add RAID metadata LVs to deptree (even when origin_only is set).
|
||||
@@ -2709,7 +2568,7 @@ Version 2.02.89 - 26th January 2012
|
||||
Add _dev_init to initialize common struct device members.
|
||||
Always zalloc struct device during initialization.
|
||||
Fix missing thread list manipulation protection in dmeventd.
|
||||
Do not dereference lv pointer in _percent_run() function before NULL check.
|
||||
Do not derefence lv pointer in _percent_run() function before NULL check.
|
||||
Allow empty strings for description and creation_host config fields.
|
||||
Issue deprecation warning when removing last lvm1-format snapshot.
|
||||
Reinstate support for snapshot removal with lvm1 format. (2.02.86)
|
||||
@@ -2780,11 +2639,11 @@ Version 2.02.89 - 26th January 2012
|
||||
Change vg_revert to void and remove superfluous calls after failed vg_commit.
|
||||
Use execvp for CLVMD restart to preserve environment settings.
|
||||
Restart CLVMD with same cluster manager.
|
||||
Fix log_error() usage in raid and unknown segtype initialization.
|
||||
Fix log_error() usage in raid and unknown segtype initialisation.
|
||||
Improve testing Makefile.
|
||||
Fix install_ocf make target when srcdir != builddir. (2.02.80)
|
||||
Support env vars LVM_CLVMD_BINARY and LVM_BINARY in clvmd.
|
||||
Fix restart of clvmd (preserve exclusive locks). (2.02.64)
|
||||
Fix restart of clvmd (preserve exlusive locks). (2.02.64)
|
||||
Add 'Volume Type' lv_attr characters for RAID and RAID_IMAGE.
|
||||
Add activation/retry_deactivation to lvm.conf to retry deactivation of an LV.
|
||||
Replace open_count check with holders/mounted_fs check on lvremove path.
|
||||
@@ -2850,13 +2709,13 @@ Version 2.02.87 - 12th August 2011
|
||||
Cache and share generated VG structs.
|
||||
Fix possible format instance memory leaks and premature releases in _vg_read.
|
||||
Suppress locking error messages in monitoring init scripts.
|
||||
If pipe in clvmd fails return busy instead of using uninitialized descriptors.
|
||||
If pipe in clvmd fails return busy instead of using uninitialised descriptors.
|
||||
Add ability to reduce the number of mirrors in raid1 arrays to lvconvert.
|
||||
Add dmeventd plugin for raid.
|
||||
Replace free_vg with release_vg and move it to vg.c.
|
||||
Remove INCONSISTENT_VG flag from the code.
|
||||
Remove lock from cache in _lock_vol even if unlock fails.
|
||||
Initialize clvmd locks before lvm context to avoid open descriptor leaks.
|
||||
Initialise clvmd locks before lvm context to avoid open descriptor leaks.
|
||||
Remove obsolete gulm clvmd cluster locking support.
|
||||
Suppress low-level locking errors and warnings while using --sysinit.
|
||||
Remove unused inconsistent_seqno variable in _vg_read().
|
||||
@@ -2929,7 +2788,7 @@ Version 2.02.85 - 29th April 2011
|
||||
Issue discards on lvremove and lvreduce etc. if enabled and supported.
|
||||
Add seg_pe_ranges and devices fields to liblvm.
|
||||
Fix incorrect tests for dm_snprintf() failure.
|
||||
Fix some unmatching sign comparison gcc warnings in the code.
|
||||
Fix some unmatching sign comparation gcc warnings in the code.
|
||||
Support lv_extend() on empty LVs.
|
||||
Avoid regenerating cache content when exported VG buffer is unchanged.
|
||||
Extend the set of memory regions that are not locked to memory.
|
||||
@@ -2955,7 +2814,7 @@ Version 2.02.85 - 29th April 2011
|
||||
Use only vg_set_fid and new pv_set_fid fn to assign the format instance.
|
||||
Make create_text_context fn static and move it inside create_instance fn.
|
||||
Add mem and ref_count fields to struct format_instance for own mempool use.
|
||||
Use new alloc_fid fn for common format instance initialization.
|
||||
Use new alloc_fid fn for common format instance initialisation.
|
||||
Optimise _get_token() and _eat_space().
|
||||
Add _lv_postorder_vg() to improve efficiency for all LVs in VG.
|
||||
Add gdbinit script for debugging.
|
||||
@@ -2964,10 +2823,10 @@ Version 2.02.85 - 29th April 2011
|
||||
Avoid possible endless loop in _free_vginfo when 4 or more VGs have same name.
|
||||
Use empty string instead of /dev// for LV path when there's no VG.
|
||||
Don't allocate unused VG mempool in _pvsegs_sub_single.
|
||||
Do not send uninitialized bytes in local clvmd messages.
|
||||
Do not send uninitialised bytes in local clvmd messages.
|
||||
Support --help option for clvmd and return error for unknown option.
|
||||
Avoid reading freed memory when printing LV segment type.
|
||||
Fix syslog initialization in clvmd to respect lvm.conf setting.
|
||||
Fix syslog initialisation in clvmd to respect lvm.conf setting.
|
||||
Fix possible overflow in maximum stripe size and physical extent size.
|
||||
Improve pvremove error message when PV belongs to a VG.
|
||||
Extend normal policy to allow mirror logs on same PVs as images if necessary.
|
||||
@@ -2981,7 +2840,7 @@ Version 2.02.85 - 29th April 2011
|
||||
Restructure existing pv_setup and pv_write and add pv_initialise.
|
||||
Add internal interface to support adding and removing metadata areas.
|
||||
Allow internal indexing of metadata areas (PV id + mda order).
|
||||
Generalise internal format_instance infrastructure for PV and VG use.
|
||||
Generalise internal format_instance infrastrusture for PV and VG use.
|
||||
Handle decimal digits with --units instead of ignoring them silently.
|
||||
Fix remaining warnings and compile with -Wpointer-arith.
|
||||
Fix gcc warnings for unused variables and const casts.
|
||||
@@ -2995,7 +2854,7 @@ Version 2.02.85 - 29th April 2011
|
||||
Make pv_min_size configurable and increase to 2048KB to exclude floppy drives.
|
||||
Add find_config_tree_int64 to read 64-bit ints from config.
|
||||
Ensure resuming exclusive cluster mirror continues to use local mirror target.
|
||||
Clear temporary postorder LV status flags to allow reuse with same LV struct.
|
||||
Clear temporary postorder LV status flags to allow re-use with same LV struct.
|
||||
Remove invalid snapshot umount mesg which floods syslog from dmeventd plugin.
|
||||
Add extended examples to pvmove man page.
|
||||
Support LVM_TEST_DEVDIR env var for private /dev during testing.
|
||||
@@ -3050,7 +2909,7 @@ Version 2.02.80 - 10th January 2011
|
||||
Speed up command processing by caching resolved config tree.
|
||||
Pass config_tree to renamed function import_vg_from_config_tree().
|
||||
Detect NULL handle in get_property().
|
||||
Fix superfluous /usr in ocf_scriptdir installation path.
|
||||
Fix superfluous /usr in ocf_scriptdir instalation path.
|
||||
Add --with-ocfdir configurable option.
|
||||
Add aclocal.m4 (for pkgconfig).
|
||||
Fix memory leak in persistent filter creation error path.
|
||||
@@ -3082,7 +2941,7 @@ Version 2.02.79 - 20th December 2010
|
||||
Add copy_percent and snap_percent to liblvm.
|
||||
Enhance vg_validate to ensure integrity of LV and PV structs referenced.
|
||||
Enhance vg_validate to check composition of pvmove LVs.
|
||||
Create /var/run/lvm directory during clvmd initialization if missing.
|
||||
Create /var/run/lvm directory during clvmd initialisation if missing.
|
||||
Use new dm_prepare_selinux_context instead of dm_set_selinux_context.
|
||||
Avoid revalidating the label cache immediately after scanning.
|
||||
Support scanning for a single VG in independent mdas.
|
||||
@@ -3351,7 +3210,7 @@ Version 2.02.68 - 23rd June 2010
|
||||
Add device name and offset to raw_read_mda_header error messages.
|
||||
Honour log argument when down-converting stacked mirror.
|
||||
Sleep to workaround clvmd -S race: socket closed early and server drops cmd.
|
||||
Use early udev synchronization and update of dev nodes for clustered mirrors.
|
||||
Use early udev synchronisation and update of dev nodes for clustered mirrors.
|
||||
Remove incorrect inclusion of kdev_t.h from cmirrord/functions.h.
|
||||
Add man pages for lvmconf and non-existent lvmsadc and lvmsar tools.
|
||||
Exit successfully when using -o help (but not -o +help) with LVM reports.
|
||||
@@ -3379,7 +3238,7 @@ Version 2.02.67 - 4th June 2010
|
||||
Avoid selecting names under /dev/block if there is an alternative.
|
||||
Update clustered log kernel module name to log-userspace for 2.6.31 onwards.
|
||||
Add replicators' LVs to dtree for activation.
|
||||
Suppress activation message if there is a missing replicator VG.
|
||||
Supress activation message if there is a missing replicator VG.
|
||||
Fix scripts/relpath.awk to work in mawk
|
||||
Extend lock_vol to check for missing replicator VGs first.
|
||||
Update _process_one_vg and process_each_lv_in_vg to populate cmd_vg.
|
||||
@@ -3430,7 +3289,7 @@ Version 2.02.65 - 17th May 2010
|
||||
|
||||
Version 2.02.64 - 30th April 2010
|
||||
=================================
|
||||
Avoid pointless initialization when the 'version' command is run directly.
|
||||
Avoid pointless initialisation when the 'version' command is run directly.
|
||||
Fix memory leak for invalid regex pattern input.
|
||||
Display invalid regex pattern for filter configuration in case of error.
|
||||
Remove no-longer-used arg_ptr_value.
|
||||
@@ -3589,7 +3448,7 @@ Version 2.02.60 - 23rd January 2010
|
||||
Disable memory debugging if dmeventd is configured. (Not thread-safe.)
|
||||
Fix first log message prefix in syslog for dmeventd plugins.
|
||||
Fix exported symbols names for dmeventd lvm2 wrapper plugin.
|
||||
Make failed locking initialization messages more descriptive.
|
||||
Make failed locking initialisation messages more descriptive.
|
||||
|
||||
Version 2.02.59 - 21st January 2010
|
||||
===================================
|
||||
@@ -3605,7 +3464,7 @@ Version 2.02.59 - 21st January 2010
|
||||
Fix detection of completed snapshot merge.
|
||||
Add Red Hat cmirror initscript (unfinished).
|
||||
Add cmirrord man page (incomplete).
|
||||
Make cluster log communication structures architecture independent.
|
||||
Make cluster log communication structures architecture independant.
|
||||
Fix cluster log in-memory bitmap handling.
|
||||
Improve snapshot merge metadata import validation.
|
||||
Improve target type compatibility checking in _percent_run().
|
||||
@@ -3681,7 +3540,7 @@ Version 2.02.57 - 12th January 2010
|
||||
Impose limit of 8 mirror images to match the in-kernel kcopyd restriction.
|
||||
Use locking_type 3 (compiled in) for lvmconf --enable-cluster.
|
||||
Remove list.c and list.h with no-longer-used dm_list macros and functions.
|
||||
Log failure type and recognize type 'F' (flush) in dmeventd mirror plugin.
|
||||
Log failure type and recognise type 'F' (flush) in dmeventd mirror plugin.
|
||||
Extend internal PV/VG/LV/segment status variables from 32-bit to 64-bit.
|
||||
|
||||
Version 2.02.56 - 24th November 2009
|
||||
@@ -3719,14 +3578,14 @@ Version 2.02.54 - 26th October 2009
|
||||
Fix clvmd segfault when refresh_toolcontext fails.
|
||||
Remember to clear 'global lock held during cache refresh' state after use.
|
||||
Use udev flags support in LVM and apply various fixes to udev rules.
|
||||
Delay announcing mirror monitoring to syslog until initialization succeeded.
|
||||
Delay announcing mirror monitoring to syslog until initialisation succeeded.
|
||||
Handle metadata with unknown segment types more gracefully.
|
||||
Set default owner and group to null.
|
||||
Add dmeventd.static to the build.
|
||||
Disable realtime support code by default.
|
||||
Make clvmd return 0 on success rather than 1.
|
||||
Add --pvmetadatacopies for pvcreate, vgcreate, vgextend, vgconvert.
|
||||
Add implicit pvcreate support to vgcreate and vgextend.
|
||||
Add implict pvcreate support to vgcreate and vgextend.
|
||||
Correct example.conf to indicate that lvm2 not lvm1 is the default format.
|
||||
Remove an unused stray LVM1_SUPPORT ifdef.
|
||||
Only include selinux libs in libdevmapper.pc when selinux build enabled.
|
||||
@@ -3906,7 +3765,7 @@ Version 2.02.48 - 30th June 2009
|
||||
Reinstate partial activation support in clustered mode. (2.02.40)
|
||||
Allow metadata correction even when PVs are missing.
|
||||
Use 'lvm lvresize' instead of 'lvresize' in fsadm.
|
||||
Do not use '-n' realine option in fsadm for busybox compatibility.
|
||||
Do not use '-n' realine option in fsadm for busybox compatiblity.
|
||||
Add vg_lock_newname() library function for vgrename, vgsplit and vgcreate.
|
||||
Round up requested readahead to at least one page and print warning.
|
||||
Try to repair vg before actual vgremove when force flag provided.
|
||||
@@ -3967,7 +3826,7 @@ Version 2.02.46 - 21st May 2009
|
||||
Fix first_seg() call for empty segment list.
|
||||
Add install_lvm2 makefile target to install only the LVM2 components.
|
||||
Reject missing PVs from allocation in toollib.
|
||||
Fix PV dataalignment for values starting prior to MDA area. (2.02.45)
|
||||
Fix PV datalignment for values starting prior to MDA area. (2.02.45)
|
||||
Add sparse devices: lvcreate -s --virtualoriginsize (hidden zero origin).
|
||||
Fix minimum width of devices column in reports.
|
||||
Add lvs origin_size field.
|
||||
@@ -4040,7 +3899,7 @@ Version 2.02.45 - 3rd March 2009
|
||||
Separate PV label attributes which do not need parse metadata when reporting.
|
||||
Remove external dependency on the 'cut' command from fsadm.
|
||||
Fix pvs segfault when pv mda attributes requested for not available PV.
|
||||
Add fsadm support for resizing ext4 filesystems.
|
||||
Add fsadm support for reszing ext4 filesysystems.
|
||||
Move locking_type reading inside init_locking().
|
||||
Rename get_vgs() to get_vgnames() and clarify related error messages.
|
||||
Allow clvmd to be built with all cluster managers & select one on cmdline.
|
||||
@@ -4217,7 +4076,7 @@ Version 2.02.37 - 6th June 2008
|
||||
Refactor some vginfo manipulation code.
|
||||
Add assertions to trap deprecated P_ and V_ lock usage.
|
||||
Add missing mutex around clvmd lvmcache_drop_metadata library call.
|
||||
Fix uninitialized mutex in clvmd if all daemons are not running at startup.
|
||||
Fix uninitialised mutex in clvmd if all daemons are not running at startup.
|
||||
Avoid using DLM locks with LCK_CACHE type P_ lock requests.
|
||||
When asked to drop cached committed VG metadata, invalidate cached PV labels.
|
||||
Drop metadata cache before writing precommitted metadata instead of after.
|
||||
@@ -4264,7 +4123,7 @@ Version 2.02.34 - 10th April 2008
|
||||
Mention default --clustered setting in vgcreate man page.
|
||||
Add config file overrides to clvmd when it reads the active LVs list.
|
||||
Fix vgreduce to use vg_split_mdas to check sufficient mdas remain.
|
||||
Add (empty) orphan VGs to lvmcache during initialization.
|
||||
Add (empty) orphan VGs to lvmcache during initialisation.
|
||||
Fix orphan VG name used for format_pool.
|
||||
Create a fid for internal orphan VGs.
|
||||
Update lvmcache VG lock state for all locking types now.
|
||||
@@ -4282,7 +4141,7 @@ Version 2.02.34 - 10th April 2008
|
||||
Fix redundant lvresize message if vg doesn't exist.
|
||||
Fix another allocation bug with clvmd and large node IDs.
|
||||
Add find_lv_in_lv_list() and find_pv_in_pv_list().
|
||||
Fix uninitialized variable in clvmd that could cause odd hangs.
|
||||
Fix uninitialised variable in clvmd that could cause odd hangs.
|
||||
Add vgmerge tests.
|
||||
Add pvseg_is_allocated() for identifying a PV segment allocated to a LV.
|
||||
Add list_move() for moving elements from one list to another.
|
||||
@@ -4290,7 +4149,7 @@ Version 2.02.34 - 10th April 2008
|
||||
Correct command name in lvmdiskscan man page.
|
||||
clvmd no longer crashes if it sees nodeids over 50.
|
||||
Fix potential deadlock in clvmd thread handling.
|
||||
Refactor text format initialization into _init_text_import.
|
||||
Refactor text format initialisation into _init_text_import.
|
||||
Escape double quotes and backslashes in external metadata and config data.
|
||||
Add functions for escaping double quotes in strings.
|
||||
Rename count_chars_len to count_chars.
|
||||
@@ -4340,7 +4199,7 @@ Version 2.02.31 - 19th January 2008
|
||||
|
||||
Version 2.02.30 - 17th January 2008
|
||||
===================================
|
||||
Set default readahead to twice maximum stripe size.
|
||||
Set default readahead to twice maximium stripe size.
|
||||
Reinstate VG extent size and stripe size defaults (halved). (2.02.29)
|
||||
Add lists of stacked LV segments using each LV to the internal metadata.
|
||||
Change vgsplit -l (for unimplemented --list) into --maxlogicalvolumes.
|
||||
@@ -4712,7 +4571,7 @@ Version 2.02.11 - 12th October 2006
|
||||
Capture error messages in clvmd and pass them back to the user.
|
||||
Remove unused #defines from filter-md.c.
|
||||
Make clvmd restart init script wait until clvmd has died before starting it.
|
||||
Add -R to clvmd which tells running clvmd to reload their device cache.
|
||||
Add -R to clvmd which tells running clvmds to reload their device cache.
|
||||
Add LV column to reports listing kernel modules needed for activation.
|
||||
Show available fields if report given invalid field. (e.g. lvs -o list)
|
||||
Add timestamp functions with --disable-realtime configure option.
|
||||
@@ -5039,7 +4898,7 @@ Version 2.01.08 - 22nd March 2005
|
||||
Improve detection of external changes affecting internal cache.
|
||||
Add 'already in device cache' debug message.
|
||||
Add -a to pvdisplay -C.
|
||||
Avoid rmdir opendir error messages when dir was already removed.
|
||||
Avoid rmdir opendir error messsages when dir was already removed.
|
||||
Tighten signal handlers.
|
||||
Avoid some compiler warnings.
|
||||
Additional rename failure error message.
|
||||
@@ -5270,7 +5129,7 @@ Version 2.00.17 - 20 June 2004
|
||||
fsadm support for fsck and resizing - needs testing.
|
||||
Add read-only GFS pool support.
|
||||
Add lvm2create_initrd script from http://poochiereds.net/svn/lvm2/
|
||||
Fix rounding of large displayed sizes.
|
||||
Fix rounding of large diplayed sizes.
|
||||
Suppress decimal point when using units of sectors/bytes.
|
||||
Additional kernel target checks before pvmove & snapshot creation.
|
||||
Add i2o_block.
|
||||
@@ -5485,5 +5344,3 @@ Display output. Some metadata information cannot yet be displayed.
|
||||
|
||||
Recovery tools to salvage "lost" metadata directly from the disks:
|
||||
but we hope the new format will mean such tools are hardly ever needed!
|
||||
|
||||
|
||||
|
96
WHATS_NEW_DM
96
WHATS_NEW_DM
@@ -1,59 +1,5 @@
|
||||
Version 1.02.202 -
|
||||
===================
|
||||
|
||||
Version 1.02.201 - 02nd October 2024
|
||||
====================================
|
||||
Cleanup udev sync semaphore if dm_{udev_create,task_set}_cookie fails.
|
||||
Improve error messages on failed udev cookie create/inc/dec operation.
|
||||
|
||||
Version 1.02.200 - 23rd August 2024
|
||||
===================================
|
||||
|
||||
Version 1.02.199 - 12nd July 2024
|
||||
=================================
|
||||
|
||||
Version 1.02.198 - 16th May 2024
|
||||
================================
|
||||
Fix static only compilation of libdevmapper.a and dmsetup tool.
|
||||
Use better code for closing opened descriptors when starting dmeventd.
|
||||
Correct dmeventd -R for systemd environment.
|
||||
Restart of dmeventd -R checks pid file to detect running dmeventd first.
|
||||
Query with dmeventd -i quickly ends when there is no running dmeventd.
|
||||
Enhance dm_get_status_raid to handle mismatching status or reported legs.
|
||||
Create /dev/disk/by-label symlinks for DM devs that have crypto as next layer.
|
||||
Persist udev db for DM devs on cleanup used in initrd to rootfs transition.
|
||||
Process synthetic udev events other than 'add/change' as 'change' events.
|
||||
Increase DM_UDEV_RULES_VSN to 3 to indicate changed udev rules.
|
||||
Rename DM_NOSCAN to .DM_NOSCAN so it's not stored in udev db.
|
||||
Rename DM_SUSPENDED to .DM_SUSPENDED so it's not stored in udev db.
|
||||
Do not import DM_UDEV_DISABLE_OTHER_RULES_FLAG from db in 10-dm-disk.rules.
|
||||
Test DISK_RO after importing properties from db in 10-dm.rules.
|
||||
Also import ID_FS_TYPE in 13-dm-disk.rules from db if needed.
|
||||
|
||||
Version 1.02.197 - 21st November 2023
|
||||
Version 1.02.191 -
|
||||
=====================================
|
||||
Fix invalid JSON report if using DM_REPORT_OUTPUT_MULTIPLE_TIMES and selection.
|
||||
Propagate ioctl errno from dm_task_run when creating new table line.
|
||||
Add support for group aliases in dmstats.
|
||||
Add support for exit-on file for dmeventd to reduce shutdown delays.
|
||||
Add configure option --with-dmeventd-exit-on-path to specify default path.
|
||||
Add dmsetup --headings none|abbrev|full to set report headings type.
|
||||
Add DM_REPORT_OUTPUT_FIELD_IDS_IN_HEADINGS to provide alternative headings.
|
||||
|
||||
Version 1.02.196 - 02nd August 2023
|
||||
===================================
|
||||
|
||||
Version 1.02.195 - 21st April 2023
|
||||
==================================
|
||||
|
||||
Version 1.02.193 - 21st March 2023
|
||||
==================================
|
||||
|
||||
Version 1.02.191 - 21st February 2023
|
||||
=====================================
|
||||
Improve parallel creation of /dev/mapper/control device node.
|
||||
Import previous ID_FS_* udev records in 13-dm-disk.rules for suspended DM dev.
|
||||
Remove NAME="mapper/control" rule from 10-dm.rules to avoid udev warnings.
|
||||
|
||||
Version 1.02.189 - 22nd December 2022
|
||||
=====================================
|
||||
@@ -96,7 +42,7 @@ Version 1.02.173 - 09th August 2020
|
||||
Version 1.02.171 - 26th March 2020
|
||||
==================================
|
||||
Try to remove all created devices on dm preload tree error path.
|
||||
Fix dm_list iterators with gcc 10 optimization (-ftree-pta).
|
||||
Fix dm_list interators with gcc 10 optimization (-ftree-pta).
|
||||
Dmeventd handles timer without looping on short intervals.
|
||||
|
||||
Version 1.02.169 - 11th February 2020
|
||||
@@ -127,7 +73,7 @@ Version 1.02.155 - 18th December 2018
|
||||
=====================================
|
||||
Include correct internal header inside libdm list.c.
|
||||
Enhance ioctl flattening and add parameters only when needed.
|
||||
Add DM_DEVICE_ARM_POLL for API completeness matching kernel.
|
||||
Add DM_DEVICE_ARM_POLL for API completness matching kernel.
|
||||
Do not add parameters for RESUME with DM_DEVICE_CREATE dm task.
|
||||
Fix dmstats report printing no output.
|
||||
|
||||
@@ -156,7 +102,7 @@ Version 1.02.147-rc1 - 24th May 2018
|
||||
Reuse uname() result for mirror target.
|
||||
Recognize also mounted btrfs through dm_device_has_mounted_fs().
|
||||
Add missing log_error() into dm_stats_populate() returning 0.
|
||||
Avoid calling dm_stats_populate() for DM devices without any stats regions.
|
||||
Avoid calling dm_stats_populat() for DM devices without any stats regions.
|
||||
Support DM_DEBUG_WITH_LINE_NUMBERS envvar for debug msg with source:line.
|
||||
Configured command for thin pool threshold handling gets whole environment.
|
||||
Fix tests for failing dm_snprintf() in stats code.
|
||||
@@ -205,7 +151,7 @@ Version 1.02.141 - 28th June 2017
|
||||
Add dm_percent_to_round_float for adjusted percentage rounding.
|
||||
Reset array with dead rimage devices once raid gets in sync.
|
||||
Drop unneeded --config option from raid dmeventd plugin.
|
||||
dm_get_status_raid() handle better some inconsistent md statuses.
|
||||
dm_get_status_raid() handle better some incosistent md statuses.
|
||||
Accept truncated files in calls to dm_stats_update_regions_from_fd().
|
||||
Restore Warning by 5% increment when thin-pool is over 80% (1.02.138).
|
||||
|
||||
@@ -400,7 +346,7 @@ Version 1.02.112 - 28th November 2015
|
||||
=====================================
|
||||
Show error message when trying to create unsupported raid type.
|
||||
Improve preloading sequence of an active thin-pool target.
|
||||
Drop extra space from cache target line to fix unneeded table reloads.
|
||||
Drop extra space from cache target line to fix unneded table reloads.
|
||||
|
||||
Version 1.02.111 - 23rd November 2015
|
||||
=====================================
|
||||
@@ -415,7 +361,7 @@ Version 1.02.110 - 30th October 2015
|
||||
Disable thin monitoring plugin when it fails too often (>10 times).
|
||||
Fix/restore parsing of empty field '-' when processing dmeventd event.
|
||||
Enhance dm_tree_node_size_changed() to recognize size reduction.
|
||||
Support exit on idle for dmeventd (1 hour).
|
||||
Support exit on idle for dmenventd (1 hour).
|
||||
Add support to allow unmonitor device from plugin itself.
|
||||
New design for thread co-operation in dmeventd.
|
||||
Dmeventd read device status with 'noflush'.
|
||||
@@ -588,7 +534,7 @@ Version 1.02.93 - 21st January 2015
|
||||
Version 1.02.92 - 24th November 2014
|
||||
====================================
|
||||
Fix memory corruption with sorting empty string lists (1.02.86).
|
||||
Fix man dmsetup.8 syntax warning of Groff.
|
||||
Fix man dmsetup.8 syntax warning of Groff
|
||||
Accept unquoted strings and / in place of {} when parsing configs.
|
||||
|
||||
Version 1.02.91 - 11th November 2014
|
||||
@@ -607,7 +553,7 @@ Version 1.02.90 - 1st September 2014
|
||||
Version 1.02.89 - 26th August 2014
|
||||
==================================
|
||||
Improve libdevmapper-event select() error handling.
|
||||
Add extra check for matching transaction_id after message submitting.
|
||||
Add extra check for matching transation_id after message submitting.
|
||||
Add dm_report_field_string_list_unsorted for str. list report without sorting.
|
||||
Support --deferred with dmsetup remove to defer removal of open devices.
|
||||
Update dm-ioctl.h to include DM_DEFERRED_REMOVE flag.
|
||||
@@ -694,7 +640,7 @@ Version 1.02.82 - 4th October 2013
|
||||
|
||||
Version 1.02.81 - 23rd September 2013
|
||||
=====================================
|
||||
Tidy dmeventd fifo initialization.
|
||||
Tidy dmeventd fifo initialisation.
|
||||
|
||||
Version 1.02.80 - 20th September 2013
|
||||
=====================================
|
||||
@@ -719,7 +665,7 @@ Version 1.02.78 - 24th July 2013
|
||||
Always return success on dmeventd -V command call.
|
||||
Fix parsing of 64bit snapshot status in dmeventd snapshot plugin.
|
||||
Add dm_get_status_snapshot() for parsing snapshot status.
|
||||
Detect mounted fs also via reading /proc/self/mountinfo.
|
||||
Detecte mounted fs also via reading /proc/self/mountinfo.
|
||||
Add dm_mountinfo_read() for parsing /proc/self/mountinfo.
|
||||
Report error for nonexisting devices in dmeventd communication.
|
||||
Prevent double free error after dmeventd call of _fill_device_data().
|
||||
@@ -816,7 +762,7 @@ Version 1.02.71 - 20th February 2012
|
||||
Add "watch" rule to 13-dm-disk.rules.
|
||||
Detect failing fifo and skip 20s retry communication period.
|
||||
Add DM_DEFAULT_NAME_MANGLING_MODE environment variable as an override.
|
||||
Add dm_lib_init to automatically initialize device-mapper library on load.
|
||||
Add dm_lib_init to automatically initialise device-mapper library on load.
|
||||
Replace any '\' char with '\\' in dm table specification on input.
|
||||
Add mangle command to dmsetup to provide renaming to correct mangled form.
|
||||
Add 'mangled_name' and 'unmangled_name' fields to dmsetup info -c -o.
|
||||
@@ -910,7 +856,7 @@ Version 1.02.66 - 12th August 2011
|
||||
Fix memory leak in dmsetup _message() memory allocation error path.
|
||||
Use new oom killer adjustment interface (oom_score_adj) when available.
|
||||
Add systemd unit files for dmeventd.
|
||||
Fix read-only identical table reload suppression.
|
||||
Fix read-only identical table reload supression.
|
||||
|
||||
Version 1.02.65 - 8th July 2011
|
||||
===============================
|
||||
@@ -925,7 +871,7 @@ Version 1.02.65 - 8th July 2011
|
||||
Add dm_get_suspended_counter() for number of devs in suspended state by lib.
|
||||
Fix "all" report field prefix matching to include label fields with pv_all.
|
||||
Delay resuming new preloaded mirror devices with core logs in deptree code.
|
||||
Accept new kernel version 3 uname formats in initialization.
|
||||
Accept new kernel version 3 uname formats in initialisation.
|
||||
|
||||
Version 1.02.64 - 29th April 2011
|
||||
==================================
|
||||
@@ -939,7 +885,7 @@ Version 1.02.64 - 29th April 2011
|
||||
Improve stack debug reporting in dm_task_create().
|
||||
Fallback to control node creation only if node doesn't exist yet.
|
||||
Change dm_hash binary functions to take void *key instead of char *.
|
||||
Fix uninitialized memory use with empty params in _reload_with_suppression_v4.
|
||||
Fix uninitialised memory use with empty params in _reload_with_suppression_v4.
|
||||
Lower severity of selabel_lookup and matchpathcon failure to log_debug.
|
||||
Add test for failed allocation from dm_task_set_uuid() in dmeventd.
|
||||
Add dm_event_get_version to dmeventd for use with -R.
|
||||
@@ -1108,7 +1054,7 @@ Version 1.02.44 - 15th February 2010
|
||||
|
||||
Version 1.02.43 - 21st January 2010
|
||||
===================================
|
||||
Remove bitset, hash and pool headers superseded by libdevmapper.h.
|
||||
Remove bitset, hash and pool headers superceded by libdevmapper.h.
|
||||
Fix off-by-one error causing bad cluster mirror table construction.
|
||||
|
||||
Version 1.02.42 - 14th January 2010
|
||||
@@ -1164,7 +1110,7 @@ Version 1.02.37 - 15th September 2009
|
||||
Version 1.02.36 - 6th August 2009
|
||||
=================================
|
||||
Add udevcookies, udevcomplete, udevcomplete_all and --noudevwait to dmsetup.
|
||||
Add libdevmapper functions to support synchronization with udev.
|
||||
Add libdevmapper functions to support synchronisation with udev.
|
||||
|
||||
Version 1.02.35 - 28th July 2009
|
||||
================================
|
||||
@@ -1232,7 +1178,7 @@ Version 1.02.27 - 25th June 2008
|
||||
|
||||
Version 1.02.26 - 6th June 2008
|
||||
===============================
|
||||
Initialize params buffer to empty string in _emit_segment.
|
||||
Initialise params buffer to empty string in _emit_segment.
|
||||
Skip add_dev_node when ioctls disabled.
|
||||
Make dm_hash_iter safe against deletion.
|
||||
Accept a NULL pointer to dm_free silently.
|
||||
@@ -1288,7 +1234,7 @@ Version 1.02.20 - 15th June 2007
|
||||
|
||||
Version 1.02.19 - 27th April 2007
|
||||
=================================
|
||||
Standardize protective include file #defines.
|
||||
Standardise protective include file #defines.
|
||||
Add regex functions to library.
|
||||
Avoid trailing separator in reports when there are hidden sort fields.
|
||||
Fix segfault in 'dmsetup status' without --showkeys against crypt target.
|
||||
@@ -1319,7 +1265,7 @@ Version 1.02.16 - 25th January 2007
|
||||
Streamline dm_report_field_* interface.
|
||||
Add cmdline debug & version options to dmeventd.
|
||||
Add DM_LIB_VERSION definition to configure.h.
|
||||
Suppress 'Unrecognized field' error if report field is 'help'.
|
||||
Suppress 'Unrecognised field' error if report field is 'help'.
|
||||
Add --separator and --sort to dmsetup (unused).
|
||||
Make alignment flag optional when specifying report fields.
|
||||
|
||||
@@ -1567,5 +1513,3 @@ Version 1.00.08 - 27 Feb 2004
|
||||
Fixed DESTDIR for make install/install_static_lib.
|
||||
Updated README/INSTALL to reflect move to sources.redhat.com.
|
||||
Updated autoconf files to 2003-06-17.
|
||||
|
||||
|
||||
|
18
acinclude.m4
18
acinclude.m4
@@ -62,24 +62,6 @@ AC_DEFUN([AC_TRY_LDFLAGS],
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
dnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
|
||||
dnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
|
||||
dnl -------------------------------------------
|
||||
dnl Since: 0.28
|
||||
dnl
|
||||
dnl Retrieves the value of the pkg-config variable for the given module.
|
||||
AC_DEFUN([PKG_CHECK_VAR],
|
||||
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
|
||||
AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
|
||||
|
||||
_PKG_CONFIG([$1], [variable="][$3]["], [$2])
|
||||
AS_VAR_COPY([$1], [pkg_cv_][$1])
|
||||
|
||||
AS_VAR_IF([$1], [""], [$5], [$4])dnl
|
||||
])dnl PKG_CHECK_VAR
|
||||
|
||||
|
||||
# ===========================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_gcc_builtin.html
|
||||
# ===========================================================================
|
||||
|
47
aclocal.m4
vendored
47
aclocal.m4
vendored
@@ -69,8 +69,8 @@ AC_DEFUN([AX_PYTHON_MODULE],[
|
||||
fi
|
||||
])
|
||||
|
||||
# pkg.m4 - Macros to locate and use pkg-config. -*- Autoconf -*-
|
||||
# serial 12 (pkg-config-0.29.2)
|
||||
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
|
||||
# serial 11 (pkg-config-0.29.1)
|
||||
|
||||
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
|
||||
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
|
||||
@@ -112,13 +112,13 @@ dnl
|
||||
dnl See the "Since" comment for each macro you use to see what version
|
||||
dnl of the macros you require.
|
||||
m4_defun([PKG_PREREQ],
|
||||
[m4_define([PKG_MACROS_VERSION], [0.29.2])
|
||||
[m4_define([PKG_MACROS_VERSION], [0.29.1])
|
||||
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
|
||||
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
|
||||
])dnl PKG_PREREQ
|
||||
|
||||
dnl PKG_PROG_PKG_CONFIG([MIN-VERSION], [ACTION-IF-NOT-FOUND])
|
||||
dnl ---------------------------------------------------------
|
||||
dnl PKG_PROG_PKG_CONFIG([MIN-VERSION])
|
||||
dnl ----------------------------------
|
||||
dnl Since: 0.16
|
||||
dnl
|
||||
dnl Search for the pkg-config tool and set the PKG_CONFIG variable to
|
||||
@@ -126,12 +126,6 @@ dnl first found in the path. Checks that the version of pkg-config found
|
||||
dnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is
|
||||
dnl used since that's the first version where most current features of
|
||||
dnl pkg-config existed.
|
||||
dnl
|
||||
dnl If pkg-config is not found or older than specified, it will result
|
||||
dnl in an empty PKG_CONFIG variable. To avoid widespread issues with
|
||||
dnl scripts not checking it, ACTION-IF-NOT-FOUND defaults to aborting.
|
||||
dnl You can specify [PKG_CONFIG=false] as an action instead, which would
|
||||
dnl result in pkg-config tests failing, but no bogus error messages.
|
||||
AC_DEFUN([PKG_PROG_PKG_CONFIG],
|
||||
[m4_pattern_forbid([^_?PKG_[A-Z_]+$])
|
||||
m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$])
|
||||
@@ -152,9 +146,6 @@ if test -n "$PKG_CONFIG"; then
|
||||
AC_MSG_RESULT([no])
|
||||
PKG_CONFIG=""
|
||||
fi
|
||||
fi
|
||||
if test -z "$PKG_CONFIG"; then
|
||||
m4_default([$2], [AC_MSG_ERROR([pkg-config not found])])
|
||||
fi[]dnl
|
||||
])dnl PKG_PROG_PKG_CONFIG
|
||||
|
||||
@@ -166,7 +157,7 @@ dnl Check to see whether a particular set of modules exists. Similar to
|
||||
dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
|
||||
dnl
|
||||
dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
|
||||
dnl only at the first occurrence in configure.ac, so if the first place
|
||||
dnl only at the first occurence in configure.ac, so if the first place
|
||||
dnl it's called might be skipped (such as if it is within an "if", you
|
||||
dnl have to call PKG_CHECK_EXISTS manually
|
||||
AC_DEFUN([PKG_CHECK_EXISTS],
|
||||
@@ -222,7 +213,7 @@ AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
|
||||
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
|
||||
|
||||
pkg_failed=no
|
||||
AC_MSG_CHECKING([for $2])
|
||||
AC_MSG_CHECKING([for $1])
|
||||
|
||||
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
|
||||
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
|
||||
@@ -232,17 +223,17 @@ and $1[]_LIBS to avoid the need to call pkg-config.
|
||||
See the pkg-config man page for more details.])
|
||||
|
||||
if test $pkg_failed = yes; then
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_RESULT([no])
|
||||
_PKG_SHORT_ERRORS_SUPPORTED
|
||||
if test $_pkg_short_errors_supported = yes; then
|
||||
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
|
||||
else
|
||||
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
|
||||
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
|
||||
else
|
||||
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
|
||||
fi
|
||||
# Put the nasty error message in config.log where it belongs
|
||||
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
|
||||
# Put the nasty error message in config.log where it belongs
|
||||
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
|
||||
|
||||
m4_default([$4], [AC_MSG_ERROR(
|
||||
m4_default([$4], [AC_MSG_ERROR(
|
||||
[Package requirements ($2) were not met:
|
||||
|
||||
$$1_PKG_ERRORS
|
||||
@@ -253,8 +244,8 @@ installed software in a non-standard prefix.
|
||||
_PKG_TEXT])[]dnl
|
||||
])
|
||||
elif test $pkg_failed = untried; then
|
||||
AC_MSG_RESULT([no])
|
||||
m4_default([$4], [AC_MSG_FAILURE(
|
||||
AC_MSG_RESULT([no])
|
||||
m4_default([$4], [AC_MSG_FAILURE(
|
||||
[The pkg-config script could not be found or is too old. Make sure it
|
||||
is in your PATH or set the PKG_CONFIG environment variable to the full
|
||||
path to pkg-config.
|
||||
@@ -264,10 +255,10 @@ _PKG_TEXT
|
||||
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
|
||||
])
|
||||
else
|
||||
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
|
||||
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
|
||||
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
|
||||
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
|
||||
AC_MSG_RESULT([yes])
|
||||
$3
|
||||
$3
|
||||
fi[]dnl
|
||||
])dnl PKG_CHECK_MODULES
|
||||
|
||||
|
@@ -1,9 +1,9 @@
|
||||
#!/bin/sh
|
||||
# py-compile - Compile a Python program
|
||||
|
||||
scriptversion=2023-03-30.00; # UTC
|
||||
scriptversion=2011-06-08.12; # UTC
|
||||
|
||||
# Copyright (C) 2000-2023 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2000-2014 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -16,7 +16,7 @@ scriptversion=2023-03-30.00; # UTC
|
||||
# GNU General Public License for more details.
|
||||
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
@@ -27,7 +27,7 @@ scriptversion=2023-03-30.00; # UTC
|
||||
# bugs to <bug-automake@gnu.org> or send patches to
|
||||
# <automake-patches@gnu.org>.
|
||||
|
||||
if test -z "$PYTHON"; then
|
||||
if [ -z "$PYTHON" ]; then
|
||||
PYTHON=python
|
||||
fi
|
||||
|
||||
@@ -62,19 +62,13 @@ while test $# -ne 0; do
|
||||
;;
|
||||
-h|--help)
|
||||
cat <<\EOF
|
||||
Usage: py-compile [options] FILES...
|
||||
Usage: py-compile [--help] [--version] [--basedir DIR] [--destdir DIR] FILES..."
|
||||
|
||||
Byte compile some python scripts FILES. Use --destdir to specify any
|
||||
leading directory path to the FILES that you don't want to include in the
|
||||
byte compiled file. Specify --basedir for any additional path information you
|
||||
do want to be shown in the byte compiled file.
|
||||
|
||||
Options:
|
||||
--basedir DIR Prefix all FILES with DIR, and include in error messages.
|
||||
--destdir DIR Prefix all FILES with DIR before compiling.
|
||||
-v, --version Display version information.
|
||||
-h, --help This help screen.
|
||||
|
||||
Example:
|
||||
py-compile --destdir /tmp/pkg-root --basedir /usr/share/test test.py test2.py
|
||||
|
||||
@@ -100,143 +94,77 @@ EOF
|
||||
shift
|
||||
done
|
||||
|
||||
if test $# -eq 0; then
|
||||
usage_error "no files given"
|
||||
files=$*
|
||||
if test -z "$files"; then
|
||||
usage_error "no files given"
|
||||
fi
|
||||
|
||||
# if basedir was given, then it should be prepended to filenames before
|
||||
# byte compilation.
|
||||
if test -z "$basedir"; then
|
||||
pathtrans="path = file"
|
||||
if [ -z "$basedir" ]; then
|
||||
pathtrans="path = file"
|
||||
else
|
||||
pathtrans="path = os.path.join('$basedir', file)"
|
||||
pathtrans="path = os.path.join('$basedir', file)"
|
||||
fi
|
||||
|
||||
# if destdir was given, then it needs to be prepended to the filename to
|
||||
# byte compile but not go into the compiled file.
|
||||
if test -z "$destdir"; then
|
||||
filetrans="filepath = path"
|
||||
if [ -z "$destdir" ]; then
|
||||
filetrans="filepath = path"
|
||||
else
|
||||
filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)"
|
||||
filetrans="filepath = os.path.normpath('$destdir' + os.sep + path)"
|
||||
fi
|
||||
|
||||
python_major=`$PYTHON -c 'import sys; print(sys.version_info[0])'`
|
||||
if test -z "$python_major"; then
|
||||
usage_error "could not determine $PYTHON major version"
|
||||
fi
|
||||
|
||||
case $python_major in
|
||||
[01])
|
||||
usage_error "python version 0.x and 1.x not supported"
|
||||
;;
|
||||
esac
|
||||
|
||||
python_minor=`$PYTHON -c 'import sys; print(sys.version_info[1])'`
|
||||
|
||||
# NB: When adding support for newer versions, prefer copying & adding new cases
|
||||
# rather than try to keep things merged with shell variables.
|
||||
|
||||
# First byte compile (no optimization) all the modules.
|
||||
# This works for all currently known Python versions.
|
||||
$PYTHON -c "
|
||||
import sys, os, py_compile
|
||||
import sys, os, py_compile, imp
|
||||
|
||||
try:
|
||||
import importlib
|
||||
except ImportError:
|
||||
importlib = None
|
||||
|
||||
# importlib.util.cache_from_source was added in 3.4
|
||||
if (
|
||||
hasattr(importlib, 'util')
|
||||
and hasattr(importlib.util, 'cache_from_source')
|
||||
):
|
||||
destpath = importlib.util.cache_from_source
|
||||
else:
|
||||
destpath = lambda filepath: filepath + 'c'
|
||||
files = '''$files'''
|
||||
|
||||
sys.stdout.write('Byte-compiling python modules...\n')
|
||||
for file in sys.argv[1:]:
|
||||
for file in files.split():
|
||||
$pathtrans
|
||||
$filetrans
|
||||
if (
|
||||
not os.path.exists(filepath)
|
||||
or not (len(filepath) >= 3 and filepath[-3:] == '.py')
|
||||
):
|
||||
continue
|
||||
sys.stdout.write(file + ' ')
|
||||
if not os.path.exists(filepath) or not (len(filepath) >= 3
|
||||
and filepath[-3:] == '.py'):
|
||||
continue
|
||||
sys.stdout.write(file)
|
||||
sys.stdout.flush()
|
||||
py_compile.compile(filepath, destpath(filepath), path)
|
||||
sys.stdout.write('\n')" "$@" || exit $?
|
||||
if hasattr(imp, 'get_tag'):
|
||||
py_compile.compile(filepath, imp.cache_from_source(filepath), path)
|
||||
else:
|
||||
py_compile.compile(filepath, filepath + 'c', path)
|
||||
sys.stdout.write('\n')" || exit $?
|
||||
|
||||
# Then byte compile w/optimization all the modules.
|
||||
# this will fail for python < 1.5, but that doesn't matter ...
|
||||
$PYTHON -O -c "
|
||||
import sys, os, py_compile
|
||||
import sys, os, py_compile, imp
|
||||
|
||||
try:
|
||||
import importlib
|
||||
except ImportError:
|
||||
importlib = None
|
||||
|
||||
# importlib.util.cache_from_source was added in 3.4
|
||||
if (
|
||||
hasattr(importlib, 'util')
|
||||
and hasattr(importlib.util, 'cache_from_source')
|
||||
):
|
||||
destpath = importlib.util.cache_from_source
|
||||
else:
|
||||
destpath = lambda filepath: filepath + 'o'
|
||||
|
||||
# pypy2 does not use .pyo optimization
|
||||
if sys.version_info.major <= 2 and hasattr(sys, 'pypy_translation_info'):
|
||||
# pypy does not use .pyo optimization
|
||||
if hasattr(sys, 'pypy_translation_info'):
|
||||
sys.exit(0)
|
||||
|
||||
files = '''$files'''
|
||||
sys.stdout.write('Byte-compiling python modules (optimized versions) ...\n')
|
||||
for file in sys.argv[1:]:
|
||||
for file in files.split():
|
||||
$pathtrans
|
||||
$filetrans
|
||||
if (
|
||||
not os.path.exists(filepath)
|
||||
or not (len(filepath) >= 3 and filepath[-3:] == '.py')
|
||||
):
|
||||
continue
|
||||
sys.stdout.write(file + ' ')
|
||||
if not os.path.exists(filepath) or not (len(filepath) >= 3
|
||||
and filepath[-3:] == '.py'):
|
||||
continue
|
||||
sys.stdout.write(file)
|
||||
sys.stdout.flush()
|
||||
py_compile.compile(filepath, destpath(filepath), path)
|
||||
sys.stdout.write('\n')" "$@" 2>/dev/null || exit $?
|
||||
|
||||
# Then byte compile w/more optimization.
|
||||
# Only do this for Python 3.5+, see https://bugs.gnu.org/38043 for background.
|
||||
case $python_major.$python_minor in
|
||||
2.*|3.[0-4])
|
||||
;;
|
||||
*)
|
||||
$PYTHON -OO -c "
|
||||
import sys, os, py_compile, importlib
|
||||
|
||||
sys.stdout.write('Byte-compiling python modules (more optimized versions)'
|
||||
' ...\n')
|
||||
for file in sys.argv[1:]:
|
||||
$pathtrans
|
||||
$filetrans
|
||||
if (
|
||||
not os.path.exists(filepath)
|
||||
or not (len(filepath) >= 3 and filepath[-3:] == '.py')
|
||||
):
|
||||
continue
|
||||
sys.stdout.write(file + ' ')
|
||||
sys.stdout.flush()
|
||||
py_compile.compile(filepath, importlib.util.cache_from_source(filepath), path)
|
||||
sys.stdout.write('\n')" "$@" 2>/dev/null || exit $?
|
||||
;;
|
||||
esac
|
||||
if hasattr(imp, 'get_tag'):
|
||||
py_compile.compile(filepath, imp.cache_from_source(filepath, False), path)
|
||||
else:
|
||||
py_compile.compile(filepath, filepath + 'o', path)
|
||||
sys.stdout.write('\n')" 2>/dev/null || :
|
||||
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# eval: (add-hook 'write-file-hooks 'time-stamp)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-time-zone: "UTC"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
@@ -31,10 +31,10 @@ CLEAN_TARGETS += $(BASE_DEPENDS) $(BASE_OBJECTS) \
|
||||
$(BASE_TARGET)
|
||||
|
||||
$(BASE_TARGET): $(BASE_OBJECTS)
|
||||
$(SHOW) " [AR] $@"
|
||||
@echo " [AR] $@"
|
||||
$(Q) $(RM) $@
|
||||
$(Q) $(AR) rsv $@ $(BASE_OBJECTS) > /dev/null
|
||||
|
||||
ifeq ("$(USE_TRACKING)","yes")
|
||||
ifeq ("$(DEPENDS)","yes")
|
||||
-include $(BASE_DEPENDS)
|
||||
endif
|
||||
|
@@ -30,10 +30,10 @@ struct dm_hash_table {
|
||||
unsigned num_nodes;
|
||||
unsigned num_hint;
|
||||
unsigned mask_slots; /* (slots - 1) -> used as hash mask */
|
||||
unsigned collisions; /* Collisions of hash keys */
|
||||
unsigned collisions; /* Collissions of hash keys */
|
||||
unsigned search; /* How many keys were searched */
|
||||
unsigned found; /* How many nodes were found */
|
||||
unsigned same_hash; /* Was there a collision with same masked hash and len ? */
|
||||
unsigned same_hash; /* Was there a colision with same masked hash and len ? */
|
||||
struct dm_hash_node **slots;
|
||||
};
|
||||
|
||||
@@ -41,7 +41,7 @@ struct dm_hash_table {
|
||||
static unsigned _hash(const void *key, unsigned len)
|
||||
{
|
||||
/* Permutation of the Integers 0 through 255 */
|
||||
static const unsigned char _nums[] = {
|
||||
static unsigned char _nums[] = {
|
||||
1, 14, 110, 25, 97, 174, 132, 119, 138, 170, 125, 118, 27, 233, 140, 51,
|
||||
87, 197, 177, 107, 234, 169, 56, 68, 30, 7, 173, 73, 188, 40, 36, 65,
|
||||
49, 213, 104, 190, 57, 211, 148, 223, 48, 115, 15, 2, 67, 186, 210, 28,
|
||||
@@ -348,7 +348,7 @@ int dm_hash_insert_allow_multiple(struct dm_hash_table *t, const char *key,
|
||||
|
||||
/*
|
||||
* Look through multiple entries with the same key for one that has a
|
||||
* matching val and return that. If none have matching val, return NULL.
|
||||
* matching val and return that. If none have maching val, return NULL.
|
||||
*/
|
||||
void *dm_hash_lookup_with_val(struct dm_hash_table *t, const char *key,
|
||||
const void *val, uint32_t val_len)
|
||||
|
@@ -19,7 +19,6 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
@@ -70,7 +69,7 @@ struct node48 {
|
||||
};
|
||||
|
||||
struct node256 {
|
||||
uint32_t nr_entries;
|
||||
uint32_t nr_entries;
|
||||
struct value values[256];
|
||||
};
|
||||
|
||||
@@ -100,7 +99,7 @@ struct radix_tree *radix_tree_create(radix_value_dtr dtr, void *dtr_context)
|
||||
static inline void _dtr(struct radix_tree *rt, union radix_value v)
|
||||
{
|
||||
if (rt->dtr)
|
||||
rt->dtr(rt->dtr_context, v);
|
||||
rt->dtr(rt->dtr_context, v);
|
||||
}
|
||||
|
||||
// Returns the number of values removed
|
||||
@@ -119,8 +118,8 @@ static unsigned _free_node(struct radix_tree *rt, struct value v)
|
||||
break;
|
||||
|
||||
case VALUE:
|
||||
_dtr(rt, v.value);
|
||||
nr = 1;
|
||||
_dtr(rt, v.value);
|
||||
nr = 1;
|
||||
break;
|
||||
|
||||
case VALUE_CHAIN:
|
||||
@@ -179,9 +178,9 @@ unsigned radix_tree_size(struct radix_tree *rt)
|
||||
return rt->nr_entries;
|
||||
}
|
||||
|
||||
static bool _insert(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv);
|
||||
static bool _insert(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv);
|
||||
|
||||
static bool _insert_unset(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
static bool _insert_unset(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
unsigned len = ke - kb;
|
||||
|
||||
@@ -208,7 +207,7 @@ static bool _insert_unset(struct radix_tree *rt, struct value *v, const uint8_t
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool _insert_value(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
static bool _insert_value(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
unsigned len = ke - kb;
|
||||
|
||||
@@ -235,7 +234,7 @@ static bool _insert_value(struct radix_tree *rt, struct value *v, const uint8_t
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool _insert_value_chain(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
static bool _insert_value_chain(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
struct value_chain *vc = v->value.ptr;
|
||||
return _insert(rt, &vc->child, kb, ke, rv);
|
||||
@@ -249,7 +248,7 @@ static unsigned min(unsigned lhs, unsigned rhs)
|
||||
return rhs;
|
||||
}
|
||||
|
||||
static bool _insert_prefix_chain(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
static bool _insert_prefix_chain(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
struct prefix_chain *pc = v->value.ptr;
|
||||
|
||||
@@ -314,7 +313,7 @@ static bool _insert_prefix_chain(struct radix_tree *rt, struct value *v, const u
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool _insert_node4(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
static bool _insert_node4(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
struct node4 *n4 = v->value.ptr;
|
||||
if (n4->nr_entries == 4) {
|
||||
@@ -344,7 +343,7 @@ static bool _insert_node4(struct radix_tree *rt, struct value *v, const uint8_t
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool _insert_node16(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
static bool _insert_node16(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
struct node16 *n16 = v->value.ptr;
|
||||
|
||||
@@ -383,7 +382,7 @@ static bool _insert_node16(struct radix_tree *rt, struct value *v, const uint8_t
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool _insert_node48(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
static bool _insert_node48(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
struct node48 *n48 = v->value.ptr;
|
||||
if (n48->nr_entries == 48) {
|
||||
@@ -418,20 +417,20 @@ static bool _insert_node48(struct radix_tree *rt, struct value *v, const uint8_t
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool _insert_node256(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
static bool _insert_node256(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
struct node256 *n256 = v->value.ptr;
|
||||
bool r, was_unset = n256->values[*kb].type == UNSET;
|
||||
|
||||
r = _insert(rt, n256->values + *kb, kb + 1, ke, rv);
|
||||
if (r && was_unset)
|
||||
n256->nr_entries++;
|
||||
n256->nr_entries++;
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
// FIXME: the tree should not be touched if insert fails (eg, OOM)
|
||||
static bool _insert(struct radix_tree *rt, struct value *v, const uint8_t *kb, const uint8_t *ke, union radix_value rv)
|
||||
static bool _insert(struct radix_tree *rt, struct value *v, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
if (kb == ke) {
|
||||
if (v->type == UNSET) {
|
||||
@@ -488,10 +487,10 @@ static bool _insert(struct radix_tree *rt, struct value *v, const uint8_t *kb, c
|
||||
|
||||
struct lookup_result {
|
||||
struct value *v;
|
||||
const uint8_t *kb;
|
||||
uint8_t *kb;
|
||||
};
|
||||
|
||||
static struct lookup_result _lookup_prefix(struct value *v, const uint8_t *kb, const uint8_t *ke)
|
||||
static struct lookup_result _lookup_prefix(struct value *v, uint8_t *kb, uint8_t *ke)
|
||||
{
|
||||
unsigned i;
|
||||
struct value_chain *vc;
|
||||
@@ -501,7 +500,7 @@ static struct lookup_result _lookup_prefix(struct value *v, const uint8_t *kb, c
|
||||
struct node48 *n48;
|
||||
struct node256 *n256;
|
||||
|
||||
if (kb == ke || !kb) /* extra check for !kb for coverity */
|
||||
if (kb == ke)
|
||||
return (struct lookup_result) {.v = v, .kb = kb};
|
||||
|
||||
switch (v->type) {
|
||||
@@ -556,10 +555,8 @@ static struct lookup_result _lookup_prefix(struct value *v, const uint8_t *kb, c
|
||||
return (struct lookup_result) {.v = v, .kb = kb};
|
||||
}
|
||||
|
||||
bool radix_tree_insert(struct radix_tree *rt, const void *key, size_t keylen, union radix_value rv)
|
||||
bool radix_tree_insert(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value rv)
|
||||
{
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
struct lookup_result lr = _lookup_prefix(&rt->root, kb, ke);
|
||||
return _insert(rt, lr.v, lr.kb, ke, rv);
|
||||
}
|
||||
@@ -567,14 +564,14 @@ bool radix_tree_insert(struct radix_tree *rt, const void *key, size_t keylen, un
|
||||
// Note the degrade functions also free the original node.
|
||||
static void _degrade_to_n4(struct node16 *n16, struct value *result)
|
||||
{
|
||||
struct node4 *n4 = zalloc(sizeof(*n4));
|
||||
struct node4 *n4 = zalloc(sizeof(*n4));
|
||||
|
||||
assert(n4 != NULL);
|
||||
|
||||
n4->nr_entries = n16->nr_entries;
|
||||
memcpy(n4->keys, n16->keys, n16->nr_entries * sizeof(*n4->keys));
|
||||
memcpy(n4->values, n16->values, n16->nr_entries * sizeof(*n4->values));
|
||||
free(n16);
|
||||
n4->nr_entries = n16->nr_entries;
|
||||
memcpy(n4->keys, n16->keys, n16->nr_entries * sizeof(*n4->keys));
|
||||
memcpy(n4->values, n16->values, n16->nr_entries * sizeof(*n4->values));
|
||||
free(n16);
|
||||
|
||||
result->type = NODE4;
|
||||
result->value.ptr = n4;
|
||||
@@ -583,20 +580,20 @@ static void _degrade_to_n4(struct node16 *n16, struct value *result)
|
||||
static void _degrade_to_n16(struct node48 *n48, struct value *result)
|
||||
{
|
||||
unsigned i, count = 0;
|
||||
struct node16 *n16 = zalloc(sizeof(*n16));
|
||||
struct node16 *n16 = zalloc(sizeof(*n16));
|
||||
|
||||
assert(n16 != NULL);
|
||||
|
||||
n16->nr_entries = n48->nr_entries;
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (n48->keys[i] < 48) {
|
||||
n16->keys[count] = i;
|
||||
n16->values[count] = n48->values[n48->keys[i]];
|
||||
count++;
|
||||
}
|
||||
}
|
||||
n16->nr_entries = n48->nr_entries;
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (n48->keys[i] < 48) {
|
||||
n16->keys[count] = i;
|
||||
n16->values[count] = n48->values[n48->keys[i]];
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
free(n48);
|
||||
free(n48);
|
||||
|
||||
result->type = NODE16;
|
||||
result->value.ptr = n16;
|
||||
@@ -604,13 +601,13 @@ static void _degrade_to_n16(struct node48 *n48, struct value *result)
|
||||
|
||||
static void _degrade_to_n48(struct node256 *n256, struct value *result)
|
||||
{
|
||||
unsigned i, count = 0;
|
||||
struct node48 *n48 = zalloc(sizeof(*n48));
|
||||
unsigned i, count = 0;
|
||||
struct node48 *n48 = zalloc(sizeof(*n48));
|
||||
|
||||
assert(n48 != NULL);
|
||||
|
||||
n48->nr_entries = n256->nr_entries;
|
||||
for (i = 0; i < 256; i++) {
|
||||
n48->nr_entries = n256->nr_entries;
|
||||
for (i = 0; i < 256; i++) {
|
||||
if (n256->values[i].type == UNSET)
|
||||
n48->keys[i] = 48;
|
||||
|
||||
@@ -619,9 +616,9 @@ static void _degrade_to_n48(struct node256 *n256, struct value *result)
|
||||
n48->values[count] = n256->values[i];
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(n256);
|
||||
free(n256);
|
||||
|
||||
result->type = NODE48;
|
||||
result->value.ptr = n48;
|
||||
@@ -635,14 +632,14 @@ static void _erase_elt(void *array, size_t obj_size, unsigned count, unsigned id
|
||||
return;
|
||||
|
||||
memmove(((uint8_t *) array) + (obj_size * idx),
|
||||
((uint8_t *) array) + (obj_size * (idx + 1)),
|
||||
obj_size * (count - idx - 1));
|
||||
((uint8_t *) array) + (obj_size * (idx + 1)),
|
||||
obj_size * (count - idx - 1));
|
||||
|
||||
// Zero the now unused last elt (set's v.type to UNSET)
|
||||
memset(((uint8_t *) array) + (count - 1) * obj_size, 0, obj_size);
|
||||
}
|
||||
|
||||
static bool _remove(struct radix_tree *rt, struct value *root, const uint8_t *kb, const uint8_t *ke)
|
||||
static bool _remove(struct radix_tree *rt, struct value *root, uint8_t *kb, uint8_t *ke)
|
||||
{
|
||||
bool r;
|
||||
unsigned i, j;
|
||||
@@ -654,27 +651,27 @@ static bool _remove(struct radix_tree *rt, struct value *root, const uint8_t *kb
|
||||
struct node256 *n256;
|
||||
|
||||
if (kb == ke) {
|
||||
if (root->type == VALUE) {
|
||||
root->type = UNSET;
|
||||
_dtr(rt, root->value);
|
||||
return true;
|
||||
if (root->type == VALUE) {
|
||||
root->type = UNSET;
|
||||
_dtr(rt, root->value);
|
||||
return true;
|
||||
|
||||
} else if (root->type == VALUE_CHAIN) {
|
||||
} else if (root->type == VALUE_CHAIN) {
|
||||
vc = root->value.ptr;
|
||||
_dtr(rt, vc->value);
|
||||
memcpy(root, &vc->child, sizeof(*root));
|
||||
free(vc);
|
||||
return true;
|
||||
|
||||
} else
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (root->type) {
|
||||
case UNSET:
|
||||
case VALUE:
|
||||
// this is a value for a prefix of the key
|
||||
return false;
|
||||
// this is a value for a prefix of the key
|
||||
return false;
|
||||
|
||||
case VALUE_CHAIN:
|
||||
vc = root->value.ptr;
|
||||
@@ -689,11 +686,11 @@ static bool _remove(struct radix_tree *rt, struct value *root, const uint8_t *kb
|
||||
case PREFIX_CHAIN:
|
||||
pc = root->value.ptr;
|
||||
if (ke - kb < pc->len)
|
||||
return false;
|
||||
return false;
|
||||
|
||||
for (i = 0; i < pc->len; i++)
|
||||
if (kb[i] != pc->prefix[i])
|
||||
return false;
|
||||
return false;
|
||||
|
||||
r = _remove(rt, &pc->child, kb + pc->len, ke);
|
||||
if (r && pc->child.type == UNSET) {
|
||||
@@ -708,12 +705,12 @@ static bool _remove(struct radix_tree *rt, struct value *root, const uint8_t *kb
|
||||
if (n4->keys[i] == *kb) {
|
||||
r = _remove(rt, n4->values + i, kb + 1, ke);
|
||||
if (r && n4->values[i].type == UNSET) {
|
||||
if (i < n4->nr_entries) {
|
||||
_erase_elt(n4->keys, sizeof(*n4->keys), n4->nr_entries, i);
|
||||
_erase_elt(n4->values, sizeof(*n4->values), n4->nr_entries, i);
|
||||
}
|
||||
if (i < n4->nr_entries) {
|
||||
_erase_elt(n4->keys, sizeof(*n4->keys), n4->nr_entries, i);
|
||||
_erase_elt(n4->values, sizeof(*n4->values), n4->nr_entries, i);
|
||||
}
|
||||
|
||||
n4->nr_entries--;
|
||||
n4->nr_entries--;
|
||||
if (!n4->nr_entries) {
|
||||
free(n4);
|
||||
root->type = UNSET;
|
||||
@@ -725,19 +722,19 @@ static bool _remove(struct radix_tree *rt, struct value *root, const uint8_t *kb
|
||||
return false;
|
||||
|
||||
case NODE16:
|
||||
n16 = root->value.ptr;
|
||||
n16 = root->value.ptr;
|
||||
for (i = 0; i < n16->nr_entries; i++) {
|
||||
if (n16->keys[i] == *kb) {
|
||||
r = _remove(rt, n16->values + i, kb + 1, ke);
|
||||
if (r && n16->values[i].type == UNSET) {
|
||||
if (i < n16->nr_entries) {
|
||||
_erase_elt(n16->keys, sizeof(*n16->keys), n16->nr_entries, i);
|
||||
_erase_elt(n16->values, sizeof(*n16->values), n16->nr_entries, i);
|
||||
}
|
||||
if (i < n16->nr_entries) {
|
||||
_erase_elt(n16->keys, sizeof(*n16->keys), n16->nr_entries, i);
|
||||
_erase_elt(n16->values, sizeof(*n16->values), n16->nr_entries, i);
|
||||
}
|
||||
|
||||
n16->nr_entries--;
|
||||
n16->nr_entries--;
|
||||
if (n16->nr_entries <= 4) {
|
||||
_degrade_to_n4(n16, root);
|
||||
_degrade_to_n4(n16, root);
|
||||
}
|
||||
}
|
||||
return r;
|
||||
@@ -749,18 +746,18 @@ static bool _remove(struct radix_tree *rt, struct value *root, const uint8_t *kb
|
||||
n48 = root->value.ptr;
|
||||
i = n48->keys[*kb];
|
||||
if (i < 48) {
|
||||
r = _remove(rt, n48->values + i, kb + 1, ke);
|
||||
if (r && n48->values[i].type == UNSET) {
|
||||
n48->keys[*kb] = 48;
|
||||
for (j = 0; j < 256; j++)
|
||||
if (n48->keys[j] < 48 && n48->keys[j] > i)
|
||||
n48->keys[j]--;
|
||||
r = _remove(rt, n48->values + i, kb + 1, ke);
|
||||
if (r && n48->values[i].type == UNSET) {
|
||||
n48->keys[*kb] = 48;
|
||||
for (j = 0; j < 256; j++)
|
||||
if (n48->keys[j] < 48 && n48->keys[j] > i)
|
||||
n48->keys[j]--;
|
||||
_erase_elt(n48->values, sizeof(*n48->values), n48->nr_entries, i);
|
||||
n48->nr_entries--;
|
||||
if (n48->nr_entries <= 16)
|
||||
_degrade_to_n16(n48, root);
|
||||
}
|
||||
return r;
|
||||
_degrade_to_n16(n48, root);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -770,7 +767,7 @@ static bool _remove(struct radix_tree *rt, struct value *root, const uint8_t *kb
|
||||
if (r && n256->values[*kb].type == UNSET) {
|
||||
n256->nr_entries--;
|
||||
if (n256->nr_entries <= 48)
|
||||
_degrade_to_n48(n256, root);
|
||||
_degrade_to_n48(n256, root);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@@ -778,14 +775,11 @@ static bool _remove(struct radix_tree *rt, struct value *root, const uint8_t *kb
|
||||
return false;
|
||||
}
|
||||
|
||||
bool radix_tree_remove(struct radix_tree *rt, const void *key, size_t keylen)
|
||||
bool radix_tree_remove(struct radix_tree *rt, uint8_t *key_begin, uint8_t *key_end)
|
||||
{
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
|
||||
if (_remove(rt, &rt->root, kb, ke)) {
|
||||
rt->nr_entries--;
|
||||
return true;
|
||||
if (_remove(rt, &rt->root, key_begin, key_end)) {
|
||||
rt->nr_entries--;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -793,25 +787,25 @@ bool radix_tree_remove(struct radix_tree *rt, const void *key, size_t keylen)
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
static bool _prefix_chain_matches(const struct lookup_result *lr, const uint8_t *ke)
|
||||
static bool _prefix_chain_matches(struct lookup_result *lr, uint8_t *ke)
|
||||
{
|
||||
// It's possible the top node is a prefix chain, and
|
||||
// the remaining key matches part of it.
|
||||
if (lr->v->type == PREFIX_CHAIN) {
|
||||
unsigned i, rlen = ke - lr->kb;
|
||||
const struct prefix_chain *pc = lr->v->value.ptr;
|
||||
if (rlen < pc->len) {
|
||||
for (i = 0; i < rlen; i++)
|
||||
if (pc->prefix[i] != lr->kb[i])
|
||||
return false;
|
||||
return true;
|
||||
// It's possible the top node is a prefix chain, and
|
||||
// the remaining key matches part of it.
|
||||
if (lr->v->type == PREFIX_CHAIN) {
|
||||
unsigned i, rlen = ke - lr->kb;
|
||||
struct prefix_chain *pc = lr->v->value.ptr;
|
||||
if (rlen < pc->len) {
|
||||
for (i = 0; i < rlen; i++)
|
||||
if (pc->prefix[i] != lr->kb[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool _remove_subtree(struct radix_tree *rt, struct value *root, const uint8_t *kb, const uint8_t *ke, unsigned *count)
|
||||
static bool _remove_subtree(struct radix_tree *rt, struct value *root, uint8_t *kb, uint8_t *ke, unsigned *count)
|
||||
{
|
||||
bool r;
|
||||
unsigned i, j, len;
|
||||
@@ -832,7 +826,7 @@ static bool _remove_subtree(struct radix_tree *rt, struct value *root, const uin
|
||||
case UNSET:
|
||||
case VALUE:
|
||||
// No entries with the given prefix
|
||||
return true;
|
||||
return true;
|
||||
|
||||
case VALUE_CHAIN:
|
||||
vc = root->value.ptr;
|
||||
@@ -849,7 +843,7 @@ static bool _remove_subtree(struct radix_tree *rt, struct value *root, const uin
|
||||
len = min(pc->len, ke - kb);
|
||||
for (i = 0; i < len; i++)
|
||||
if (kb[i] != pc->prefix[i])
|
||||
return true;
|
||||
return true;
|
||||
|
||||
r = _remove_subtree(rt, &pc->child, len < pc->len ? ke : (kb + pc->len), ke, count);
|
||||
if (r && pc->child.type == UNSET) {
|
||||
@@ -864,12 +858,12 @@ static bool _remove_subtree(struct radix_tree *rt, struct value *root, const uin
|
||||
if (n4->keys[i] == *kb) {
|
||||
r = _remove_subtree(rt, n4->values + i, kb + 1, ke, count);
|
||||
if (r && n4->values[i].type == UNSET) {
|
||||
if (i < n4->nr_entries) {
|
||||
_erase_elt(n4->keys, sizeof(*n4->keys), n4->nr_entries, i);
|
||||
_erase_elt(n4->values, sizeof(*n4->values), n4->nr_entries, i);
|
||||
}
|
||||
if (i < n4->nr_entries) {
|
||||
_erase_elt(n4->keys, sizeof(*n4->keys), n4->nr_entries, i);
|
||||
_erase_elt(n4->values, sizeof(*n4->values), n4->nr_entries, i);
|
||||
}
|
||||
|
||||
n4->nr_entries--;
|
||||
n4->nr_entries--;
|
||||
if (!n4->nr_entries) {
|
||||
free(n4);
|
||||
root->type = UNSET;
|
||||
@@ -881,19 +875,19 @@ static bool _remove_subtree(struct radix_tree *rt, struct value *root, const uin
|
||||
return true;
|
||||
|
||||
case NODE16:
|
||||
n16 = root->value.ptr;
|
||||
n16 = root->value.ptr;
|
||||
for (i = 0; i < n16->nr_entries; i++) {
|
||||
if (n16->keys[i] == *kb) {
|
||||
r = _remove_subtree(rt, n16->values + i, kb + 1, ke, count);
|
||||
if (r && n16->values[i].type == UNSET) {
|
||||
if (i < n16->nr_entries) {
|
||||
_erase_elt(n16->keys, sizeof(*n16->keys), n16->nr_entries, i);
|
||||
_erase_elt(n16->values, sizeof(*n16->values), n16->nr_entries, i);
|
||||
}
|
||||
if (i < n16->nr_entries) {
|
||||
_erase_elt(n16->keys, sizeof(*n16->keys), n16->nr_entries, i);
|
||||
_erase_elt(n16->values, sizeof(*n16->values), n16->nr_entries, i);
|
||||
}
|
||||
|
||||
n16->nr_entries--;
|
||||
n16->nr_entries--;
|
||||
if (n16->nr_entries <= 4)
|
||||
_degrade_to_n4(n16, root);
|
||||
_degrade_to_n4(n16, root);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@@ -904,18 +898,18 @@ static bool _remove_subtree(struct radix_tree *rt, struct value *root, const uin
|
||||
n48 = root->value.ptr;
|
||||
i = n48->keys[*kb];
|
||||
if (i < 48) {
|
||||
r = _remove_subtree(rt, n48->values + i, kb + 1, ke, count);
|
||||
if (r && n48->values[i].type == UNSET) {
|
||||
n48->keys[*kb] = 48;
|
||||
for (j = 0; j < 256; j++)
|
||||
if (n48->keys[j] < 48 && n48->keys[j] > i)
|
||||
n48->keys[j]--;
|
||||
r = _remove_subtree(rt, n48->values + i, kb + 1, ke, count);
|
||||
if (r && n48->values[i].type == UNSET) {
|
||||
n48->keys[*kb] = 48;
|
||||
for (j = 0; j < 256; j++)
|
||||
if (n48->keys[j] < 48 && n48->keys[j] > i)
|
||||
n48->keys[j]--;
|
||||
_erase_elt(n48->values, sizeof(*n48->values), n48->nr_entries, i);
|
||||
n48->nr_entries--;
|
||||
if (n48->nr_entries <= 16)
|
||||
_degrade_to_n16(n48, root);
|
||||
}
|
||||
return r;
|
||||
_degrade_to_n16(n48, root);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -928,7 +922,7 @@ static bool _remove_subtree(struct radix_tree *rt, struct value *root, const uin
|
||||
if (r && n256->values[*kb].type == UNSET) {
|
||||
n256->nr_entries--;
|
||||
if (n256->nr_entries <= 48)
|
||||
_degrade_to_n48(n256, root);
|
||||
_degrade_to_n48(n256, root);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
@@ -937,13 +931,11 @@ static bool _remove_subtree(struct radix_tree *rt, struct value *root, const uin
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned radix_tree_remove_prefix(struct radix_tree *rt, const void *prefix, size_t prefix_len)
|
||||
unsigned radix_tree_remove_prefix(struct radix_tree *rt, uint8_t *kb, uint8_t *ke)
|
||||
{
|
||||
const uint8_t *kb = prefix;
|
||||
const uint8_t *ke = kb + prefix_len;
|
||||
unsigned count = 0;
|
||||
unsigned count = 0;
|
||||
|
||||
if (_remove_subtree(rt, &rt->root, kb, ke, &count))
|
||||
if (_remove_subtree(rt, &rt->root, kb, ke, &count))
|
||||
rt->nr_entries -= count;
|
||||
|
||||
return count;
|
||||
@@ -951,11 +943,9 @@ unsigned radix_tree_remove_prefix(struct radix_tree *rt, const void *prefix, siz
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
bool radix_tree_lookup(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
union radix_value *result)
|
||||
bool radix_tree_lookup(struct radix_tree *rt,
|
||||
uint8_t *kb, uint8_t *ke, union radix_value *result)
|
||||
{
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
struct value_chain *vc;
|
||||
struct lookup_result lr = _lookup_prefix(&rt->root, kb, ke);
|
||||
if (lr.kb == ke) {
|
||||
@@ -978,58 +968,58 @@ bool radix_tree_lookup(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
}
|
||||
|
||||
// FIXME: build up the keys too
|
||||
static bool _iterate(struct radix_tree_iterator *it, const struct value *v)
|
||||
static bool _iterate(struct value *v, struct radix_tree_iterator *it)
|
||||
{
|
||||
unsigned i;
|
||||
const struct value_chain *vc;
|
||||
const struct prefix_chain *pc;
|
||||
const struct node4 *n4;
|
||||
const struct node16 *n16;
|
||||
const struct node48 *n48;
|
||||
const struct node256 *n256;
|
||||
struct value_chain *vc;
|
||||
struct prefix_chain *pc;
|
||||
struct node4 *n4;
|
||||
struct node16 *n16;
|
||||
struct node48 *n48;
|
||||
struct node256 *n256;
|
||||
|
||||
switch (v->type) {
|
||||
case UNSET:
|
||||
// can't happen
|
||||
// can't happen
|
||||
break;
|
||||
|
||||
case VALUE:
|
||||
return it->visit(it, NULL, 0, v->value);
|
||||
return it->visit(it, NULL, NULL, v->value);
|
||||
|
||||
case VALUE_CHAIN:
|
||||
vc = v->value.ptr;
|
||||
return it->visit(it, NULL, 0, vc->value) && _iterate(it, &vc->child);
|
||||
return it->visit(it, NULL, NULL, vc->value) && _iterate(&vc->child, it);
|
||||
|
||||
case PREFIX_CHAIN:
|
||||
pc = v->value.ptr;
|
||||
return _iterate(it, &pc->child);
|
||||
return _iterate(&pc->child, it);
|
||||
|
||||
case NODE4:
|
||||
n4 = (const struct node4 *) v->value.ptr;
|
||||
n4 = (struct node4 *) v->value.ptr;
|
||||
for (i = 0; i < n4->nr_entries; i++)
|
||||
if (!_iterate(it, n4->values + i))
|
||||
return false;
|
||||
return true;
|
||||
if (!_iterate(n4->values + i, it))
|
||||
return false;
|
||||
return true;
|
||||
|
||||
case NODE16:
|
||||
n16 = (const struct node16 *) v->value.ptr;
|
||||
n16 = (struct node16 *) v->value.ptr;
|
||||
for (i = 0; i < n16->nr_entries; i++)
|
||||
if (!_iterate(it, n16->values + i))
|
||||
return false;
|
||||
if (!_iterate(n16->values + i, it))
|
||||
return false;
|
||||
return true;
|
||||
|
||||
case NODE48:
|
||||
n48 = (const struct node48 *) v->value.ptr;
|
||||
n48 = (struct node48 *) v->value.ptr;
|
||||
for (i = 0; i < n48->nr_entries; i++)
|
||||
if (!_iterate(it, n48->values + i))
|
||||
return false;
|
||||
if (!_iterate(n48->values + i, it))
|
||||
return false;
|
||||
return true;
|
||||
|
||||
case NODE256:
|
||||
n256 = (const struct node256 *) v->value.ptr;
|
||||
n256 = (struct node256 *) v->value.ptr;
|
||||
for (i = 0; i < 256; i++)
|
||||
if (n256->values[i].type != UNSET && !_iterate(it, n256->values + i))
|
||||
return false;
|
||||
if (n256->values[i].type != UNSET && !_iterate(n256->values + i, it))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1037,14 +1027,12 @@ static bool _iterate(struct radix_tree_iterator *it, const struct value *v)
|
||||
return false;
|
||||
}
|
||||
|
||||
void radix_tree_iterate(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
struct radix_tree_iterator *it)
|
||||
void radix_tree_iterate(struct radix_tree *rt, uint8_t *kb, uint8_t *ke,
|
||||
struct radix_tree_iterator *it)
|
||||
{
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
struct lookup_result lr = _lookup_prefix(&rt->root, kb, ke);
|
||||
if (lr.kb == ke || _prefix_chain_matches(&lr, ke))
|
||||
(void) _iterate(it, lr.v);
|
||||
(void) _iterate(lr.v, it);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
@@ -1142,7 +1130,7 @@ static bool _check_nodes(struct value *v, unsigned *count)
|
||||
|
||||
if (ncount != n48->nr_entries) {
|
||||
fprintf(stderr, "incorrect number of entries in n48, n48->nr_entries = %u, actual = %u\n",
|
||||
n48->nr_entries, ncount);
|
||||
n48->nr_entries, ncount);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1178,7 +1166,7 @@ static bool _check_nodes(struct value *v, unsigned *count)
|
||||
|
||||
if (ncount != n256->nr_entries) {
|
||||
fprintf(stderr, "incorrect number of entries in n256, n256->nr_entries = %u, actual = %u\n",
|
||||
n256->nr_entries, ncount);
|
||||
n256->nr_entries, ncount);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1201,7 +1189,7 @@ bool radix_tree_is_well_formed(struct radix_tree *rt)
|
||||
|
||||
if (rt->nr_entries != count) {
|
||||
fprintf(stderr, "incorrect entry count: rt->nr_entries = %u, actual = %u\n",
|
||||
rt->nr_entries, count);
|
||||
rt->nr_entries, count);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1219,7 +1207,6 @@ static void _dump(FILE *out, struct value v, unsigned indent)
|
||||
struct node16 *n16;
|
||||
struct node48 *n48;
|
||||
struct node256 *n256;
|
||||
unsigned printable;
|
||||
|
||||
if (v.type == UNSET)
|
||||
return;
|
||||
@@ -1244,22 +1231,9 @@ static void _dump(FILE *out, struct value v, unsigned indent)
|
||||
|
||||
case PREFIX_CHAIN:
|
||||
pc = v.value.ptr;
|
||||
fprintf(out, "<prefix(%u): ", pc->len);
|
||||
printable = 1;
|
||||
fprintf(out, "<prefix: ");
|
||||
for (i = 0; i < pc->len; i++)
|
||||
if (!isprint(pc->prefix[i])) {
|
||||
printable = 0;
|
||||
break;
|
||||
}
|
||||
if (printable)
|
||||
fputc('"', out);
|
||||
for (i = 0; i < pc->len; i++)
|
||||
if (printable)
|
||||
fprintf(out, "%c", pc->prefix[i]);
|
||||
else
|
||||
fprintf(out, "%02x.", (unsigned) *(pc->prefix + i));
|
||||
if (printable)
|
||||
fputc('"', out);
|
||||
fprintf(out, "%x.", (unsigned) *(pc->prefix + i));
|
||||
fprintf(out, ">\n");
|
||||
_dump(out, pc->child, indent + 1);
|
||||
break;
|
||||
@@ -1268,7 +1242,7 @@ static void _dump(FILE *out, struct value v, unsigned indent)
|
||||
n4 = v.value.ptr;
|
||||
fprintf(out, "<n4: ");
|
||||
for (i = 0; i < n4->nr_entries; i++)
|
||||
fprintf(out, "%02x ", (unsigned) n4->keys[i]);
|
||||
fprintf(out, "%x ", (unsigned) n4->keys[i]);
|
||||
fprintf(out, ">\n");
|
||||
|
||||
for (i = 0; i < n4->nr_entries; i++)
|
||||
@@ -1279,7 +1253,7 @@ static void _dump(FILE *out, struct value v, unsigned indent)
|
||||
n16 = v.value.ptr;
|
||||
fprintf(out, "<n16: ");
|
||||
for (i = 0; i < n16->nr_entries; i++)
|
||||
fprintf(out, "%02x ", (unsigned) n16->keys[i]);
|
||||
fprintf(out, "%x ", (unsigned) n16->keys[i]);
|
||||
fprintf(out, ">\n");
|
||||
|
||||
for (i = 0; i < n16->nr_entries; i++)
|
||||
@@ -1291,7 +1265,7 @@ static void _dump(FILE *out, struct value v, unsigned indent)
|
||||
fprintf(out, "<n48: ");
|
||||
for (i = 0; i < 256; i++)
|
||||
if (n48->keys[i] < 48)
|
||||
fprintf(out, "%02x ", i);
|
||||
fprintf(out, "%x ", i);
|
||||
fprintf(out, ">\n");
|
||||
|
||||
for (i = 0; i < n48->nr_entries; i++) {
|
||||
@@ -1305,7 +1279,7 @@ static void _dump(FILE *out, struct value v, unsigned indent)
|
||||
fprintf(out, "<n256: ");
|
||||
for (i = 0; i < 256; i++)
|
||||
if (n256->values[i].type != UNSET)
|
||||
fprintf(out, "%02x ", i);
|
||||
fprintf(out, "%x ", i);
|
||||
fprintf(out, ">\n");
|
||||
|
||||
for (i = 0; i < 256; i++)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
// Copyright (C) 2018 Red Hat, Inc. All rights reserved.
|
||||
//
|
||||
//
|
||||
// This file is part of LVM2.
|
||||
//
|
||||
// This copyrighted material is made available to anyone wishing to use,
|
||||
@@ -18,7 +18,6 @@
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
//----------------------------------------------------------------
|
||||
// This implementation is based around nested binary trees. Very
|
||||
@@ -38,12 +37,12 @@ struct node {
|
||||
struct radix_tree {
|
||||
radix_value_dtr dtr;
|
||||
void *dtr_context;
|
||||
unsigned nr_entries;
|
||||
|
||||
struct node *root;
|
||||
};
|
||||
|
||||
struct radix_tree *radix_tree_create(radix_value_dtr dtr, void *dtr_context)
|
||||
struct radix_tree *
|
||||
radix_tree_create(radix_value_dtr dtr, void *dtr_context)
|
||||
{
|
||||
struct radix_tree *rt = zalloc(sizeof(*rt));
|
||||
|
||||
@@ -106,7 +105,7 @@ unsigned radix_tree_size(struct radix_tree *rt)
|
||||
return _count(rt->root);
|
||||
}
|
||||
|
||||
static struct node **_lookup(struct node **pn, const uint8_t *kb, const uint8_t *ke)
|
||||
static struct node **_lookup(struct node **pn, uint8_t *kb, uint8_t *ke)
|
||||
{
|
||||
struct node *n = *pn;
|
||||
|
||||
@@ -123,7 +122,7 @@ static struct node **_lookup(struct node **pn, const uint8_t *kb, const uint8_t
|
||||
return _lookup(&n->center, kb + 1, ke);
|
||||
}
|
||||
|
||||
static bool _insert(struct node **pn, const uint8_t *kb, const uint8_t *ke, union radix_value v)
|
||||
static bool _insert(struct node **pn, uint8_t *kb, uint8_t *ke, union radix_value v)
|
||||
{
|
||||
struct node *n = *pn;
|
||||
|
||||
@@ -152,51 +151,39 @@ static bool _insert(struct node **pn, const uint8_t *kb, const uint8_t *ke, unio
|
||||
return _insert(&n->center, kb + 1, ke, v);
|
||||
}
|
||||
|
||||
bool radix_tree_insert(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
union radix_value v)
|
||||
bool radix_tree_insert(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value v)
|
||||
{
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
|
||||
if (!_insert(&rt->root, kb, ke, v))
|
||||
return false;
|
||||
|
||||
rt->nr_entries++;
|
||||
return true;
|
||||
return _insert(&rt->root, kb, ke, v);
|
||||
}
|
||||
|
||||
bool radix_tree_remove(struct radix_tree *rt, const void *key, size_t keylen)
|
||||
bool radix_tree_remove(struct radix_tree *rt, uint8_t *kb, uint8_t *ke)
|
||||
{
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
struct node **pn = _lookup(&rt->root, kb, ke);
|
||||
struct node *n = *pn;
|
||||
|
||||
if (!n || !n->has_value)
|
||||
return false;
|
||||
|
||||
rt->nr_entries--;
|
||||
else {
|
||||
if (rt->dtr)
|
||||
rt->dtr(rt->dtr_context, n->value);
|
||||
|
||||
if (rt->dtr)
|
||||
rt->dtr(rt->dtr_context, n->value);
|
||||
if (n->left || n->center || n->right) {
|
||||
n->has_value = false;
|
||||
return true;
|
||||
|
||||
if (n->left || n->center || n->right) {
|
||||
n->has_value = false;
|
||||
return true;
|
||||
} else {
|
||||
// FIXME: delete parent if this was the last entry
|
||||
free(n);
|
||||
*pn = NULL;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIXME: delete parent if this was the last entry
|
||||
free(n);
|
||||
*pn = NULL;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned radix_tree_remove_prefix(struct radix_tree *rt, const void *key, size_t keylen)
|
||||
unsigned radix_tree_remove_prefix(struct radix_tree *rt, uint8_t *kb, uint8_t *ke)
|
||||
{
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
struct node **pn;
|
||||
unsigned count;
|
||||
|
||||
@@ -210,20 +197,17 @@ unsigned radix_tree_remove_prefix(struct radix_tree *rt, const void *key, size_t
|
||||
return count;
|
||||
}
|
||||
|
||||
bool radix_tree_lookup(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
union radix_value *result)
|
||||
bool
|
||||
radix_tree_lookup(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value *result)
|
||||
{
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
struct node **pn = _lookup(&rt->root, kb, ke);
|
||||
struct node *n = *pn;
|
||||
|
||||
if (n && n->has_value) {
|
||||
*result = n->value;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
static void _iterate(struct node *n, struct radix_tree_iterator *it)
|
||||
@@ -235,18 +219,15 @@ static void _iterate(struct node *n, struct radix_tree_iterator *it)
|
||||
|
||||
if (n->has_value)
|
||||
// FIXME: fill out the key
|
||||
it->visit(it, NULL, 0, n->value);
|
||||
it->visit(it, NULL, NULL, n->value);
|
||||
|
||||
_iterate(n->center, it);
|
||||
_iterate(n->right, it);
|
||||
}
|
||||
|
||||
void radix_tree_iterate(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
void radix_tree_iterate(struct radix_tree *rt, uint8_t *kb, uint8_t *ke,
|
||||
struct radix_tree_iterator *it)
|
||||
{
|
||||
const uint8_t *kb = key;
|
||||
const uint8_t *ke = kb + keylen;
|
||||
|
||||
if (kb == ke)
|
||||
_iterate(rt->root, it);
|
||||
|
||||
@@ -256,7 +237,7 @@ void radix_tree_iterate(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
|
||||
if (n) {
|
||||
if (n->has_value)
|
||||
it->visit(it, NULL, 0, n->value);
|
||||
it->visit(it, NULL, NULL, n->value);
|
||||
_iterate(n->center, it);
|
||||
}
|
||||
}
|
||||
@@ -267,32 +248,8 @@ bool radix_tree_is_well_formed(struct radix_tree *rt)
|
||||
return true;
|
||||
}
|
||||
|
||||
static void _dump(FILE *out, struct node *n, unsigned indent)
|
||||
{
|
||||
unsigned i;
|
||||
|
||||
if (!n)
|
||||
return;
|
||||
|
||||
_dump(out, n->left, indent + 1);
|
||||
|
||||
for (i = 0; i < 2 * indent; i++)
|
||||
fprintf(out, " ");
|
||||
|
||||
if (n->has_value) {
|
||||
fprintf(out, "value: %llu\n", n->value.n);
|
||||
} else {
|
||||
fprintf(out, "key: '%c' [0x%02x] %u\n",
|
||||
isprint(n->key) ? n->key : ' ', n->key, indent);
|
||||
}
|
||||
|
||||
_dump(out, n->center, indent + 1);
|
||||
_dump(out, n->right, indent + 1);
|
||||
}
|
||||
|
||||
void radix_tree_dump(struct radix_tree *rt, FILE *out)
|
||||
{
|
||||
_dump(out, rt->root, 0);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
@@ -19,45 +19,3 @@
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
||||
struct visitor {
|
||||
struct radix_tree_iterator it;
|
||||
unsigned pos, nr_entries;
|
||||
union radix_value *values;
|
||||
};
|
||||
|
||||
static bool _visitor(struct radix_tree_iterator *it,
|
||||
const void *key, size_t keylen,
|
||||
union radix_value v)
|
||||
{
|
||||
struct visitor *vt = container_of(it, struct visitor, it);
|
||||
|
||||
if (vt->pos >= vt->nr_entries)
|
||||
return false;
|
||||
|
||||
vt->values[vt->pos++] = v;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool radix_tree_values(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
union radix_value **values, unsigned *nr_values)
|
||||
{
|
||||
struct visitor vt = {
|
||||
.it.visit = _visitor,
|
||||
.nr_entries = rt->nr_entries,
|
||||
.values = calloc(rt->nr_entries + 1, sizeof(union radix_value)),
|
||||
};
|
||||
|
||||
if (vt.values) {
|
||||
// build set of all values in current radix tree
|
||||
radix_tree_iterate(rt, key, keylen, &vt.it);
|
||||
*nr_values = vt.pos;
|
||||
*values = vt.values;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
@@ -33,51 +33,32 @@ struct radix_tree *radix_tree_create(radix_value_dtr dtr, void *dtr_context);
|
||||
void radix_tree_destroy(struct radix_tree *rt);
|
||||
|
||||
unsigned radix_tree_size(struct radix_tree *rt);
|
||||
bool radix_tree_insert(struct radix_tree *rt, const void *key, size_t keylen, union radix_value v);
|
||||
bool radix_tree_remove(struct radix_tree *rt, const void *key, size_t keylen);
|
||||
bool radix_tree_insert(struct radix_tree *rt, uint8_t *kb, uint8_t *ke, union radix_value v);
|
||||
bool radix_tree_remove(struct radix_tree *rt, uint8_t *kb, uint8_t *ke);
|
||||
|
||||
// Returns the number of values removed
|
||||
unsigned radix_tree_remove_prefix(struct radix_tree *rt, const void *prefix, size_t prefix_len);
|
||||
unsigned radix_tree_remove_prefix(struct radix_tree *rt, uint8_t *prefix_b, uint8_t *prefix_e);
|
||||
|
||||
bool radix_tree_lookup(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
union radix_value *result);
|
||||
bool radix_tree_lookup(struct radix_tree *rt,
|
||||
uint8_t *kb, uint8_t *ke, union radix_value *result);
|
||||
|
||||
// The radix tree stores entries in lexicographical order. Which means
|
||||
// we can iterate entries, in order. Or iterate entries with a particular
|
||||
// prefix.
|
||||
struct radix_tree_iterator {
|
||||
// Returns false if the iteration should end.
|
||||
// Returns false if the iteration should end.
|
||||
bool (*visit)(struct radix_tree_iterator *it,
|
||||
const void *key, size_t keylen, union radix_value v);
|
||||
uint8_t *kb, uint8_t *ke, union radix_value v);
|
||||
};
|
||||
|
||||
void radix_tree_iterate(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
struct radix_tree_iterator *it);
|
||||
|
||||
// Alternative traversing radix_tree.
|
||||
// Builds whole set all radix_tree nr_values values.
|
||||
// After use, free(values).
|
||||
bool radix_tree_values(struct radix_tree *rt, const void *key, size_t keylen,
|
||||
union radix_value **values, unsigned *nr_values);
|
||||
void radix_tree_iterate(struct radix_tree *rt, uint8_t *kb, uint8_t *ke,
|
||||
struct radix_tree_iterator *it);
|
||||
|
||||
// Checks that some constraints on the shape of the tree are
|
||||
// being held. For debug only.
|
||||
bool radix_tree_is_well_formed(struct radix_tree *rt);
|
||||
void radix_tree_dump(struct radix_tree *rt, FILE *out);
|
||||
|
||||
// Shortcut for ptr value return
|
||||
// Note: if value would be NULL, it's same result for not/found case.
|
||||
static inline void *radix_tree_lookup_ptr(struct radix_tree *rt, const void *key, size_t keylen)
|
||||
{
|
||||
union radix_value v;
|
||||
return radix_tree_lookup(rt, key, keylen, &v) ? v.ptr : NULL;
|
||||
}
|
||||
|
||||
static inline bool radix_tree_insert_ptr(struct radix_tree *rt, const void *key, size_t keylen, void *ptr)
|
||||
{
|
||||
union radix_value v = { .ptr = ptr };
|
||||
return radix_tree_insert(rt, key, keylen, v);
|
||||
}
|
||||
//----------------------------------------------------------------
|
||||
|
||||
#endif
|
||||
|
@@ -49,7 +49,7 @@ install_localconf: $(CONFLOCAL)
|
||||
fi
|
||||
|
||||
install_profiles: $(PROFILES)
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
@echo " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_DIR) $(profiledir)
|
||||
$(Q) $(INSTALL_DATA) $(PROFILES) $(profiledir)/
|
||||
|
||||
|
@@ -122,7 +122,7 @@ devices {
|
||||
# Configuration option devices/use_devicesfile.
|
||||
# Enable or disable the use of a devices file.
|
||||
# When enabled, lvm will only use devices that
|
||||
# are listed in the devices file. A devices file will
|
||||
# are lised in the devices file. A devices file will
|
||||
# be used, regardless of this setting, when the --devicesfile
|
||||
# option is set to a specific file name.
|
||||
# This configuration option has an automatic default value.
|
||||
@@ -135,16 +135,6 @@ devices {
|
||||
# This configuration option has an automatic default value.
|
||||
# devicesfile = "system.devices"
|
||||
|
||||
# Configuration option devices/devicesfile_backup_limit.
|
||||
# The max number of backup files to keep in /etc/lvm/devices/backup.
|
||||
# LVM creates a backup of the devices file each time a new
|
||||
# version is created, or each time a modification is detected.
|
||||
# When the max number of backups is reached, the oldest are
|
||||
# removed to remain at the limit. Set to 0 to disable backups.
|
||||
# Only the system devices file is backed up.
|
||||
# This configuration option has an automatic default value.
|
||||
# devicesfile_backup_limit = 50
|
||||
|
||||
# Configuration option devices/search_for_devnames.
|
||||
# Look outside of the devices file for missing devname entries.
|
||||
# A devname entry is used for a device that does not have a stable
|
||||
@@ -159,27 +149,7 @@ devices {
|
||||
# at other devices, but only those that are likely to have the PV.
|
||||
# If "all", lvm will look at all devices on the system.
|
||||
# This configuration option has an automatic default value.
|
||||
# search_for_devnames = "all"
|
||||
|
||||
# Configuration option devices/device_ids_refresh.
|
||||
# Find PVs on new devices and update the device IDs in the devices file.
|
||||
# If PVs are restored or moved to a new system with new devices, but
|
||||
# an old system.devices remains with old device IDs, then search for
|
||||
# the PVIDs on new devices and update the device IDs in system.devices.
|
||||
# The original device IDs must also not be found on the new system.
|
||||
# See device_ids_refresh_check for conditions that trigger the refresh.
|
||||
# This configuration option has an automatic default value.
|
||||
# device_ids_refresh = 1
|
||||
|
||||
# Configuration option devices/device_ids_refresh_checks.
|
||||
# Conditions that trigger device_ids_refresh to locate PVIDs on new devices.
|
||||
# product_uuid: refresh if /sys/devices/virtual/dmi/id/product_uuid does not
|
||||
# match the value saved in system.devices.
|
||||
# hostname: refresh if hostname does not match the value saved in system.devices.
|
||||
# (hostname is used if product_uuid is not available.)
|
||||
# Remove values from this list to prevent lvm from using them.
|
||||
# This configuration option has an automatic default value.
|
||||
# device_ids_refresh_checks = [ "product_uuid", "hostname" ]
|
||||
# search_for_devnames = "auto"
|
||||
|
||||
# Configuration option devices/filter.
|
||||
# Limit the block devices that are used by LVM commands.
|
||||
@@ -241,12 +211,17 @@ devices {
|
||||
# sysfs_scan = 1
|
||||
|
||||
# Configuration option devices/scan_lvs.
|
||||
# Allow LVM LVs to be used as PVs. When enabled, LVM commands will
|
||||
# scan active LVs to look for other PVs. Caution is required to
|
||||
# avoid using PVs that belong to guest images stored on LVs.
|
||||
# When enabled, the LVs scanned should be restricted using the
|
||||
# devices file or the filter. This option does not enable autoactivation
|
||||
# of layered VGs, which requires editing LVM udev rules (see LVM_PVSCAN_ON_LVS.)
|
||||
# Scan LVM LVs for layered PVs, allowing LVs to be used as PVs.
|
||||
# When 1, LVM will detect PVs layered on LVs, and caution must be
|
||||
# taken to avoid a host accessing a layered VG that may not belong
|
||||
# to it, e.g. from a guest image. This generally requires excluding
|
||||
# the LVs with device filters. Also, when this setting is enabled,
|
||||
# every LVM command will scan every active LV on the system (unless
|
||||
# filtered), which can cause performance problems on systems with
|
||||
# many active LVs. When this setting is 0, LVM will not detect or
|
||||
# use PVs that exist on LVs, and will not allow a PV to be created on
|
||||
# an LV. The LVs are ignored using a built in device filter that
|
||||
# identifies and excludes LVs.
|
||||
# This configuration option has an automatic default value.
|
||||
# scan_lvs = 0
|
||||
|
||||
@@ -562,7 +537,7 @@ allocation {
|
||||
|
||||
# Configuration option allocation/cache_pool_max_chunks.
|
||||
# The maximum number of chunks in a cache pool.
|
||||
# For cache target v1.9 the recommended maximum is 1000000 chunks.
|
||||
# For cache target v1.9 the recommended maximumm is 1000000 chunks.
|
||||
# Using cache pool with more chunks may degrade cache performance.
|
||||
# This configuration option does not have a default value defined.
|
||||
|
||||
@@ -646,6 +621,13 @@ allocation {
|
||||
# This configuration option has an automatic default value.
|
||||
# vdo_use_deduplication = 1
|
||||
|
||||
# Configuration option allocation/vdo_use_metadata_hints.
|
||||
# Enables or disables whether VDO volume should tag its latency-critical
|
||||
# writes with the REQ_SYNC flag. Some device mapper targets such as dm-raid5
|
||||
# process writes with this flag at a higher priority.
|
||||
# This configuration option has an automatic default value.
|
||||
# vdo_use_metadata_hints = 1
|
||||
|
||||
# Configuration option allocation/vdo_minimum_io_size.
|
||||
# The minimum IO size for VDO volume to accept, in bytes.
|
||||
# Valid values are 512 or 4096. The recommended value is 4096.
|
||||
@@ -668,6 +650,11 @@ allocation {
|
||||
# This configuration option has an automatic default value.
|
||||
# vdo_block_map_period = 16380
|
||||
|
||||
# Configuration option allocation/vdo_check_point_frequency.
|
||||
# The default check point frequency for VDO volume.
|
||||
# This configuration option has an automatic default value.
|
||||
# vdo_check_point_frequency = 0
|
||||
|
||||
# Configuration option allocation/vdo_use_sparse_index.
|
||||
# Enables sparse indexing for VDO volume.
|
||||
# This configuration option has an automatic default value.
|
||||
@@ -744,6 +731,19 @@ allocation {
|
||||
# This configuration option has an automatic default value.
|
||||
# vdo_physical_threads = 1
|
||||
|
||||
# Configuration option allocation/vdo_write_policy.
|
||||
# Specifies the write policy:
|
||||
# auto - VDO will check the storage device and determine whether it supports flushes.
|
||||
# If it does, VDO will run in async mode, otherwise it will run in sync mode.
|
||||
# sync - Writes are acknowledged only after data is stably written.
|
||||
# This policy is not supported if the underlying storage is not also synchronous.
|
||||
# async - Writes are acknowledged after data has been cached for writing to stable storage.
|
||||
# Data which has not been flushed is not guaranteed to persist in this mode.
|
||||
# async-unsafe - Writes are handled like 'async' but there is no guarantee of the atomicity async provides.
|
||||
# This mode should only be used for better performance when atomicity is not required.
|
||||
# This configuration option has an automatic default value.
|
||||
# vdo_write_policy = "auto"
|
||||
|
||||
# Configuration option allocation/vdo_max_discard.
|
||||
# Specified the maximum size of discard bio accepted, in 4096 byte blocks.
|
||||
# I/O requests to a VDO volume are normally split into 4096-byte blocks,
|
||||
@@ -781,9 +781,6 @@ log {
|
||||
# to define fields to display and sort fields for the log report.
|
||||
# You can also use log/command_log_selection to define selection
|
||||
# criteria used each time the log is reported.
|
||||
# Note that if report/output_format (or --reportformat command line
|
||||
# option) is set to json or json_std, then log/report_command_log=1
|
||||
# is default.
|
||||
# This configuration option has an automatic default value.
|
||||
# report_command_log = 0
|
||||
|
||||
@@ -813,9 +810,8 @@ log {
|
||||
# define selection criteria for log report on command line directly
|
||||
# using <lvm command> --configreport log -S <selection criteria>
|
||||
# which has precedence over log/command_log_selection setting.
|
||||
# To make all the command log lines visible, use "all" value
|
||||
# for the command log selection. For more information about selection
|
||||
# criteria in general, see lvmreport(7) man page.
|
||||
# For more information about selection criteria in general, see
|
||||
# lvm(8) man page.
|
||||
# This configuration option has an automatic default value.
|
||||
# command_log_selection = "!(log_type=status && message=success)"
|
||||
|
||||
@@ -1016,7 +1012,7 @@ global {
|
||||
# Location of proc filesystem.
|
||||
# This configuration option is advanced.
|
||||
# This configuration option has an automatic default value.
|
||||
# proc = "@DEFAULT_PROC_DIR@"
|
||||
# proc = "/proc"
|
||||
|
||||
# Configuration option global/etc.
|
||||
# Location of /etc system configuration directory.
|
||||
@@ -1160,7 +1156,7 @@ global {
|
||||
# services (via the lvm2-activation-generator), but the autoactivation
|
||||
# services and generator have been removed.
|
||||
# This configuration option has an automatic default value.
|
||||
# event_activation = @DEFAULT_EVENT_ACTIVATION@
|
||||
# event_activation = 1
|
||||
|
||||
# Configuration option global/use_aio.
|
||||
# Use async I/O when reading and writing devices.
|
||||
@@ -1192,16 +1188,6 @@ global {
|
||||
# This configuration option has an automatic default value.
|
||||
# sanlock_lv_extend = 256
|
||||
|
||||
# Configuration option global/sanlock_align_size.
|
||||
# The sanlock lease size in MiB to use on disks with a 4K sector size.
|
||||
# Possible values are 1,2,4,8. The default is 8, which supports up to
|
||||
# 2000 hosts (and max host_id 2000.) Smaller values support smaller
|
||||
# numbers of max hosts (and max host_ids): 250, 500, 1000, 2000 for
|
||||
# lease sizes 1,2,4,8. Disks with 512 byte sectors always use 1MiB
|
||||
# leases and support 2000 hosts, and are not affected by this setting.
|
||||
# This configuration option has an automatic default value.
|
||||
# sanlock_align_size = 8
|
||||
|
||||
# Configuration option global/lvmlockctl_kill_command.
|
||||
# The command that lvmlockctl --kill should use to force LVs offline.
|
||||
# The lvmlockctl --kill command is run when a shared VG has lost
|
||||
@@ -1215,7 +1201,7 @@ global {
|
||||
|
||||
# Configuration option global/thin_check_executable.
|
||||
# The full path to the thin_check command.
|
||||
# LVM uses this command to check that a thin pool metadata device is in a
|
||||
# LVM uses this command to check that a thin metadata device is in a
|
||||
# usable state. When a thin pool is activated and after it is
|
||||
# deactivated, this command is run. Activation will only proceed if
|
||||
# the command has an exit status of 0. Set to "" to skip this check.
|
||||
@@ -1239,14 +1225,6 @@ global {
|
||||
# This configuration option has an automatic default value.
|
||||
# thin_repair_executable = "@THIN_REPAIR_CMD@"
|
||||
|
||||
# Configuration option global/thin_restore_executable.
|
||||
# The full path to the thin_restore command.
|
||||
# LVM uses this command to restore generated data for a thin pool metadata device.
|
||||
# Also see thin_restore_options.
|
||||
# (See package device-mapper-persistent-data or thin-provisioning-tools)
|
||||
# This configuration option has an automatic default value.
|
||||
# thin_restore_executable = "@THIN_RESTORE_CMD@"
|
||||
|
||||
# Configuration option global/thin_check_options.
|
||||
# List of options passed to the thin_check command.
|
||||
# With thin_check version 2.1 or newer you can add the option
|
||||
@@ -1261,11 +1239,6 @@ global {
|
||||
# This configuration option has an automatic default value.
|
||||
# thin_repair_options = [ "" ]
|
||||
|
||||
# Configuration option global/thin_restore_options.
|
||||
# List of options passed to the thin_restore command.
|
||||
# This configuration option has an automatic default value.
|
||||
# thin_restore_options = [ "" ]
|
||||
|
||||
# Configuration option global/thin_disabled_features.
|
||||
# Features to not use in the thin driver.
|
||||
# This can be helpful for testing, or to avoid using a feature that is
|
||||
@@ -1314,14 +1287,6 @@ global {
|
||||
# This configuration option has an automatic default value.
|
||||
# cache_repair_executable = "@CACHE_REPAIR_CMD@"
|
||||
|
||||
# Configuration option global/cache_restore_executable.
|
||||
# The full path to the cache_restore command.
|
||||
# LVM uses this command to restore generated data for a cache metadata device.
|
||||
# Also see cache_restore_options.
|
||||
# (See package device-mapper-persistent-data or thin-provisioning-tools)
|
||||
# This configuration option has an automatic default value.
|
||||
# cache_restore_executable = "@CACHE_RESTORE_CMD@"
|
||||
|
||||
# Configuration option global/cache_check_options.
|
||||
# List of options passed to the cache_check command.
|
||||
# With cache_check version 5.0 or newer you should include the option
|
||||
@@ -1334,11 +1299,6 @@ global {
|
||||
# This configuration option has an automatic default value.
|
||||
# cache_repair_options = [ "" ]
|
||||
|
||||
# Configuration option global/cache_restore_options.
|
||||
# List of options passed to the cache_restore command.
|
||||
# This configuration option has an automatic default value.
|
||||
# cache_restore_options = [ "" ]
|
||||
|
||||
# Configuration option global/vdo_format_executable.
|
||||
# The full path to the vdoformat command.
|
||||
# LVM uses this command to initial data volume for VDO type logical volume
|
||||
@@ -1353,10 +1313,10 @@ global {
|
||||
# Configuration option global/vdo_disabled_features.
|
||||
# Features to not use in the vdo driver.
|
||||
# This can be helpful for testing, or to avoid using a feature that is
|
||||
# causing problems. Features include: online_rename, version4
|
||||
# causing problems. Features include: online_rename
|
||||
#
|
||||
# Example
|
||||
# vdo_disabled_features = [ "online_rename", "version4" ]
|
||||
# vdo_disabled_features = [ "online_rename" ]
|
||||
#
|
||||
# This configuration option does not have a default value defined.
|
||||
|
||||
@@ -1386,9 +1346,8 @@ global {
|
||||
# Use an LVM-specific derivation of the local machine-id as the
|
||||
# system ID. See 'man machine-id'.
|
||||
# machineid
|
||||
# Use the contents of the machine-id file to set the system ID.
|
||||
# (appmachineid is recommended to avoid exposing the confidential
|
||||
# machine-id.)
|
||||
# Use the contents of the machine-id file to set the system ID
|
||||
# (appmachineid is recommended.)
|
||||
# file
|
||||
# Use the contents of another file (system_id_file) to set the
|
||||
# system ID.
|
||||
@@ -1505,14 +1464,12 @@ activation {
|
||||
# Configuration option activation/reserved_stack.
|
||||
# Stack size in KiB to reserve for use while devices are suspended.
|
||||
# Insufficient reserve risks I/O deadlock during device suspension.
|
||||
# Value 0 disables memory locking.
|
||||
# This configuration option has an automatic default value.
|
||||
# reserved_stack = 64
|
||||
|
||||
# Configuration option activation/reserved_memory.
|
||||
# Memory size in KiB to reserve for use while devices are suspended.
|
||||
# Insufficient reserve risks I/O deadlock during device suspension.
|
||||
# Value 0 disables memory locking.
|
||||
# This configuration option has an automatic default value.
|
||||
# reserved_memory = 8192
|
||||
|
||||
@@ -1833,7 +1790,7 @@ activation {
|
||||
# Configuration option activation/polling_interval.
|
||||
# Check pvmove or lvconvert progress at this interval (seconds).
|
||||
# When pvmove or lvconvert must wait for the kernel to finish
|
||||
# synchronizing or merging data, they check and report progress at
|
||||
# synchronising or merging data, they check and report progress at
|
||||
# intervals of this number of seconds. If this is set to 0 and there
|
||||
# is only one thing to wait for, there are no progress reports, but
|
||||
# the process is awoken immediately once the operation is complete.
|
||||
@@ -1861,7 +1818,7 @@ activation {
|
||||
# uses are present. Other PVs in the Volume Group may be missing.
|
||||
# degraded
|
||||
# Like complete, but additionally RAID LVs of segment type raid1,
|
||||
# raid4, raid5, raid6 and raid10 will be activated if there is no
|
||||
# raid4, raid5, radid6 and raid10 will be activated if there is no
|
||||
# data loss, i.e. they have sufficient redundancy to present the
|
||||
# entire addressable range of the Logical Volume.
|
||||
# partial
|
||||
@@ -1978,14 +1935,15 @@ activation {
|
||||
|
||||
# Configuration section report.
|
||||
# LVM report command output formatting.
|
||||
report {
|
||||
# This configuration section has an automatic default value.
|
||||
# report {
|
||||
|
||||
# Configuration option report/output_format.
|
||||
# Format of LVM command's report output.
|
||||
# If there is more than one report per command, then the format
|
||||
# is applied for all reports. You can also change output format
|
||||
# directly on command line using --reportformat option which
|
||||
# has precedence over report/output_format setting.
|
||||
# has precedence over log/output_format setting.
|
||||
# Accepted values:
|
||||
# basic
|
||||
# Original format with columns and rows. If there is more than
|
||||
@@ -1999,7 +1957,6 @@ report {
|
||||
# - it does not use double quotes around numeric values,
|
||||
# - it uses 'null' for undefined numeric values,
|
||||
# - it prints string list as proper JSON array of strings instead of a single string.
|
||||
# Note that if json or json_std output format is used, then log/command_log_report=1 is default.
|
||||
# This configuration option has an automatic default value.
|
||||
# output_format = "basic"
|
||||
|
||||
@@ -2039,11 +1996,7 @@ report {
|
||||
# buffered = 1
|
||||
|
||||
# Configuration option report/headings.
|
||||
# Format of LVM command's report output headings.
|
||||
# Accepted values:
|
||||
# 0 no headings,
|
||||
# 1 headings with column abbreviations,
|
||||
# 2 headings with full column names.
|
||||
# Show headings for columns on report.
|
||||
# This configuration option has an automatic default value.
|
||||
# headings = 1
|
||||
|
||||
@@ -2122,7 +2075,7 @@ report {
|
||||
# %F
|
||||
# Equivalent to %Y-%m-%d (the ISO 8601 date format).
|
||||
# %G
|
||||
# The ISO 8601 week-based year with century as a decimal number.
|
||||
# The ISO 8601 week-based year with century as adecimal number.
|
||||
# The 4-digit year corresponding to the ISO week number (see %V).
|
||||
# This has the same format and value as %Y, except that if the
|
||||
# ISO week number belongs to the previous or next year, that year
|
||||
@@ -2393,7 +2346,7 @@ report {
|
||||
# This is displayed when the device for a PV is not known.
|
||||
# This configuration option has an automatic default value.
|
||||
# two_word_unknown_device = 0
|
||||
}
|
||||
# }
|
||||
|
||||
# Configuration section dmeventd.
|
||||
# Settings for the LVM event daemon.
|
||||
|
@@ -49,10 +49,9 @@ local {
|
||||
# This configuration option does not have a default value defined.
|
||||
|
||||
# Configuration option local/host_id.
|
||||
# The sanlock host_id used by lvmlockd. This must be unique among all the hosts
|
||||
# using shared VGs with sanlock. Accepted values are 1-2000, except when sanlock_align_size
|
||||
# is configured to 1, 2 or 4, which correspond to max host_id values of 250, 500, or 1000.
|
||||
# Applicable only if LVM is compiled with support for lvmlockd+sanlock.
|
||||
# The lvmlockd sanlock host_id.
|
||||
# This must be unique among all hosts, and must be between 1 and 2000.
|
||||
# Applicable only if LVM is compiled with lockd support
|
||||
# This configuration option has an automatic default value.
|
||||
# host_id = 0
|
||||
}
|
||||
|
@@ -4,9 +4,11 @@
|
||||
allocation {
|
||||
vdo_use_compression=1
|
||||
vdo_use_deduplication=1
|
||||
vdo_use_metadata_hints=1
|
||||
vdo_minimum_io_size=4096
|
||||
vdo_block_map_cache_size_mb=128
|
||||
vdo_block_map_period=16380
|
||||
vdo_check_point_frequency=0
|
||||
vdo_use_sparse_index=0
|
||||
vdo_index_memory_size_mb=256
|
||||
vdo_slab_size_mb=2048
|
||||
@@ -17,5 +19,6 @@ allocation {
|
||||
vdo_hash_zone_threads=1
|
||||
vdo_logical_threads=1
|
||||
vdo_physical_threads=1
|
||||
vdo_write_policy="auto"
|
||||
vdo_max_discard=1
|
||||
}
|
||||
|
1523
configure.ac
1523
configure.ac
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,7 @@
|
||||
* compile (using outdir 'cov'):
|
||||
* cov-build --dir=cov make CC=gcc
|
||||
*
|
||||
* analyze (aggressively, using 'cov')
|
||||
* analyze (agressively, using 'cov')
|
||||
* cov-analyze --dir cov --wait-for-license --hfa --concurrency --enable-fnptr --enable-constraint-fpp --security --all --aggressiveness-level=high --field-offset-escape --user-model-file=coverity/coverity_model.xml
|
||||
*
|
||||
* generate html output (to 'html' from 'cov'):
|
||||
@@ -70,7 +70,7 @@ void *memccpy(void *dest, const void *src, int c, size_t n)
|
||||
}
|
||||
|
||||
/*
|
||||
* 2 lines below needs to be placed in coverity/config/user_nodefs.h
|
||||
* 2 lines bellow needs to be placed in coverity/config/user_nodefs.h
|
||||
* Not sure about any other way.
|
||||
* Without them, coverity shows warning since x86 system header files
|
||||
* are using inline assembly to reset fdset
|
||||
|
@@ -32,12 +32,12 @@ CFLAGS += $(CPG_CFLAGS) $(EXTRA_EXEC_CFLAGS)
|
||||
LDFLAGS += $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS)
|
||||
|
||||
cmirrord: $(OBJECTS)
|
||||
$(SHOW) " [CC] $@"
|
||||
@echo " [CC] $@"
|
||||
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) \
|
||||
$(LMLIBS) -L$(top_builddir)/libdm -ldevmapper $(LIBS)
|
||||
|
||||
install_cluster: $(TARGETS)
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
@echo " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_PROGRAM) -D $< $(usrsbindir)/$(<F)
|
||||
|
||||
install: install_cluster
|
||||
|
@@ -43,14 +43,14 @@ static void usage (FILE *dest)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foreground_mode = 0;
|
||||
static const struct option _long_options[] = {
|
||||
struct option longopts[] = {
|
||||
{ "foreground", no_argument, NULL, 'f' },
|
||||
{ "help" , no_argument, NULL, 'h' },
|
||||
{ 0, 0, 0, 0 }
|
||||
};
|
||||
int opt;
|
||||
|
||||
while ((opt = getopt_long (argc, argv, "fh", _long_options, NULL)) != -1) {
|
||||
while ((opt = getopt_long (argc, argv, "fh", longopts, NULL)) != -1) {
|
||||
switch (opt) {
|
||||
case 'f':
|
||||
foreground_mode = 1;
|
||||
|
@@ -279,7 +279,7 @@ static int handle_cluster_request(struct clog_cpg *entry __attribute__((unused))
|
||||
* With resumes, we only handle our own.
|
||||
* Resume is a special case that requires
|
||||
* local action (to set up CPG), followed by
|
||||
* a cluster action to coordinate reading
|
||||
* a cluster action to co-ordinate reading
|
||||
* the disk and checkpointing
|
||||
*/
|
||||
if (tmp->u_rq.request_type == DM_ULOG_RESUME) {
|
||||
@@ -1091,7 +1091,6 @@ static void cpg_message_callback(cpg_handle_t handle, const struct cpg_name *gna
|
||||
(rq->u_rq.request_type != DM_ULOG_RESUME) &&
|
||||
(rq->u_rq.request_type != DM_ULOG_CLEAR_REGION) &&
|
||||
(rq->u_rq.request_type != DM_ULOG_CHECKPOINT_READY)) {
|
||||
/* coverity[suspicious_sizeof] allocation is using varargs data @end */
|
||||
tmp_rq = malloc(DM_ULOG_REQUEST_SIZE);
|
||||
if (!tmp_rq) {
|
||||
/*
|
||||
@@ -1341,7 +1340,6 @@ static void cpg_join_callback(struct clog_cpg *match,
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* coverity[suspicious_sizeof] allocation is using varargs data @end */
|
||||
rq = malloc(DM_ULOG_REQUEST_SIZE);
|
||||
if (!rq) {
|
||||
LOG_ERROR("cpg_config_callback: "
|
||||
@@ -1634,7 +1632,7 @@ int create_cluster_cpg(char *uuid, uint64_t luid)
|
||||
|
||||
size = ((strlen(uuid) + 1) > CPG_MAX_NAME_LENGTH) ?
|
||||
CPG_MAX_NAME_LENGTH : (strlen(uuid) + 1);
|
||||
dm_strncpy(new->name.value, uuid, size);
|
||||
(void) dm_strncpy(new->name.value, uuid, size);
|
||||
new->name.length = (uint32_t)size;
|
||||
new->luid = luid;
|
||||
|
||||
|
@@ -67,7 +67,7 @@ struct log_c {
|
||||
uint32_t recoverer;
|
||||
uint64_t recovering_region; /* -1 means not recovering */
|
||||
uint64_t skip_bit_warning; /* used to warn if region skipped */
|
||||
unsigned sync_search;
|
||||
int sync_search;
|
||||
|
||||
int resume_override;
|
||||
|
||||
@@ -220,7 +220,7 @@ static int rw_log(struct log_c *lc, int do_write)
|
||||
if (r < 0)
|
||||
LOG_ERROR("[%s] rw_log: read failure: %s",
|
||||
SHORT_UUID(lc->uuid), strerror(errno));
|
||||
if ((unsigned) r != lc->disk_size)
|
||||
if (r != lc->disk_size)
|
||||
return -EIO; /* Failed disk read */
|
||||
return 0;
|
||||
}
|
||||
@@ -254,7 +254,7 @@ static int read_log(struct log_c *lc)
|
||||
bitset_size = lc->region_count / 8;
|
||||
bitset_size += (lc->region_count % 8) ? 1 : 0;
|
||||
|
||||
/* 'lc->clean_bits + 1' because dm_bitset_t leads with a uint32_t */
|
||||
/* 'lc->clean_bits + 1' becasue dm_bitset_t leads with a uint32_t */
|
||||
memcpy(lc->clean_bits + 1, (char *)lc->disk_buffer + 1024, bitset_size);
|
||||
|
||||
return 0;
|
||||
@@ -281,7 +281,7 @@ static int write_log(struct log_c *lc)
|
||||
bitset_size = lc->region_count / 8;
|
||||
bitset_size += (lc->region_count % 8) ? 1 : 0;
|
||||
|
||||
/* 'lc->clean_bits + 1' because dm_bitset_t leads with a uint32_t */
|
||||
/* 'lc->clean_bits + 1' becasue dm_bitset_t leads with a uint32_t */
|
||||
memcpy((char *)lc->disk_buffer + 1024, lc->clean_bits + 1, bitset_size);
|
||||
|
||||
if (rw_log(lc, 1)) {
|
||||
@@ -292,13 +292,13 @@ static int write_log(struct log_c *lc)
|
||||
}
|
||||
|
||||
/* FIXME Rewrite this function taking advantage of the udev changes (where in use) to improve its efficiency! */
|
||||
static int find_disk_path(char *major_minor_str, char *path_rtn, size_t sz, int *unlink_path __attribute__((unused)))
|
||||
static int find_disk_path(char *major_minor_str, char *path_rtn, int *unlink_path __attribute__((unused)))
|
||||
{
|
||||
int r;
|
||||
DIR *dp;
|
||||
struct dirent *dep;
|
||||
struct stat statbuf;
|
||||
unsigned major, minor;
|
||||
int major, minor;
|
||||
|
||||
if (!strstr(major_minor_str, ":")) {
|
||||
r = stat(major_minor_str, &statbuf);
|
||||
@@ -306,7 +306,7 @@ static int find_disk_path(char *major_minor_str, char *path_rtn, size_t sz, int
|
||||
return -errno;
|
||||
if (!S_ISBLK(statbuf.st_mode))
|
||||
return -EINVAL;
|
||||
dm_strncpy(path_rtn, major_minor_str, sz);
|
||||
sprintf(path_rtn, "%s", major_minor_str);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ static int find_disk_path(char *major_minor_str, char *path_rtn, size_t sz, int
|
||||
* wanted.
|
||||
*/
|
||||
|
||||
snprintf(path_rtn, sz, "/dev/mapper/%s", dep->d_name);
|
||||
sprintf(path_rtn, "/dev/mapper/%s", dep->d_name);
|
||||
if (stat(path_rtn, &statbuf) < 0) {
|
||||
LOG_DBG("Unable to stat %s", path_rtn);
|
||||
continue;
|
||||
@@ -394,7 +394,7 @@ static int _clog_ctr(char *uuid, uint64_t luid,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = find_disk_path(argv[0], disk_path, sizeof(disk_path), &unlink_path);
|
||||
r = find_disk_path(argv[0], disk_path, &unlink_path);
|
||||
if (r) {
|
||||
LOG_ERROR("Unable to find path to device %s", argv[0]);
|
||||
goto fail;
|
||||
@@ -452,7 +452,7 @@ static int _clog_ctr(char *uuid, uint64_t luid,
|
||||
lc->skip_bit_warning = region_count;
|
||||
lc->disk_fd = -1;
|
||||
lc->log_dev_failed = 0;
|
||||
if (!_dm_strncpy(lc->uuid, uuid, DM_UUID_LEN)) {
|
||||
if (!dm_strncpy(lc->uuid, uuid, DM_UUID_LEN)) {
|
||||
LOG_ERROR("Cannot use too long UUID %s.", uuid);
|
||||
r = -EINVAL;
|
||||
goto fail;
|
||||
@@ -927,7 +927,7 @@ int local_resume(struct dm_ulog_request *rq)
|
||||
*
|
||||
* Since this value doesn't change, the kernel
|
||||
* should not need to talk to server to get this
|
||||
* The function is here for completeness
|
||||
* The function is here for completness
|
||||
*
|
||||
* Returns: 0 on success, -EXXX on failure
|
||||
*/
|
||||
@@ -1018,7 +1018,7 @@ static int clog_in_sync(struct dm_ulog_request *rq)
|
||||
* happen for reads is that additional read attempts may be
|
||||
* taken.
|
||||
*
|
||||
* Further investigation may be required to determine if there are
|
||||
* Futher investigation may be required to determine if there are
|
||||
* similar possible outcomes when the mirror is in the process of
|
||||
* recovering. In that case, lc->in_sync would not have been set
|
||||
* yet.
|
||||
|
@@ -13,7 +13,6 @@
|
||||
#define _LVM_CLOG_FUNCTIONS_H
|
||||
|
||||
#include "libdm/libdevmapper.h"
|
||||
#include "libdm/dm-tools/util.h"
|
||||
#include "libdm/misc/dm-log-userspace.h"
|
||||
#include "cluster.h"
|
||||
|
||||
|
@@ -266,7 +266,7 @@ static int do_local_work(void *data __attribute__((unused)))
|
||||
RQ_TYPE(u_rq->request_type));
|
||||
break;
|
||||
}
|
||||
/* ELSE */ /* fall through */
|
||||
/* ELSE, fall through */
|
||||
case DM_ULOG_IS_CLEAN:
|
||||
case DM_ULOG_FLUSH:
|
||||
case DM_ULOG_MARK_REGION:
|
||||
|
@@ -11,7 +11,7 @@
|
||||
*/
|
||||
#include "logging.h"
|
||||
|
||||
const char * const __rq_types_off_by_one[] = {
|
||||
const char *__rq_types_off_by_one[] = {
|
||||
"DM_ULOG_CTR",
|
||||
"DM_ULOG_DTR",
|
||||
"DM_ULOG_PRESUSPEND",
|
||||
|
@@ -20,7 +20,7 @@
|
||||
/* SHORT_UUID - print last 8 chars of a string */
|
||||
#define SHORT_UUID(x) (strlen(x) > 8) ? ((x) + (strlen(x) - 8)) : (x)
|
||||
|
||||
extern const char * const __rq_types_off_by_one[];
|
||||
extern const char *__rq_types_off_by_one[];
|
||||
#define RQ_TYPE(x) __rq_types_off_by_one[(x) - 1]
|
||||
|
||||
extern int log_tabbing;
|
||||
|
@@ -70,13 +70,13 @@ plugins.device-mapper: $(LIB_SHARED)
|
||||
CFLAGS_dmeventd.o += $(EXTRA_EXEC_CFLAGS)
|
||||
|
||||
dmeventd: $(LIB_SHARED) dmeventd.o
|
||||
$(SHOW) " [CC] $@"
|
||||
@echo " [CC] $@"
|
||||
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) dmeventd.o \
|
||||
-o $@ $(DL_LIBS) $(DMEVENT_LIBS) $(LIBS)
|
||||
|
||||
dmeventd.static: $(LIB_STATIC) dmeventd.o
|
||||
$(SHOW) " [CC] $@"
|
||||
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(STATIC_LDFLAGS) -static dmeventd.o \
|
||||
@echo " [CC] $@"
|
||||
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -static dmeventd.o \
|
||||
-o $@ $(DL_LIBS) $(DMEVENT_LIBS) $(LIBS) $(STATIC_LIBS)
|
||||
|
||||
ifeq ("@PKGCONFIG@", "yes")
|
||||
@@ -84,27 +84,27 @@ ifeq ("@PKGCONFIG@", "yes")
|
||||
endif
|
||||
|
||||
install_include: $(srcdir)/libdevmapper-event.h
|
||||
$(SHOW) " [INSTALL] $(<F)"
|
||||
@echo " [INSTALL] $(<F)"
|
||||
$(Q) $(INSTALL_DATA) -D $< $(includedir)/$(<F)
|
||||
|
||||
install_pkgconfig: libdevmapper-event.pc
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
@echo " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_DATA) -D $< $(pkgconfigdir)/devmapper-event.pc
|
||||
|
||||
install_lib_dynamic: install_lib_shared
|
||||
|
||||
install_lib_static: $(LIB_STATIC)
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
@echo " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_DATA) -D $< $(usrlibdir)/$(<F)
|
||||
|
||||
install_lib: $(INSTALL_LIB_TARGETS)
|
||||
|
||||
install_dmeventd_dynamic: dmeventd
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
@echo " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
|
||||
|
||||
install_dmeventd_static: dmeventd.static
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
@echo " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_PROGRAM) -D $< $(staticdir)/$(<F)
|
||||
|
||||
install_dmeventd: $(INSTALL_DMEVENTD_TARGETS)
|
||||
|
@@ -23,12 +23,12 @@
|
||||
#include "libdm/misc/dm-logging.h"
|
||||
#include "base/memory/zalloc.h"
|
||||
|
||||
#include "libdaemon/server/daemon-stray.h"
|
||||
|
||||
#include <dlfcn.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/wait.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
#include <signal.h>
|
||||
#include <arpa/inet.h> /* for htonl, ntohl */
|
||||
@@ -92,10 +92,12 @@ static const size_t THREAD_STACK_SIZE = 300 * 1024;
|
||||
/* Default idle exit timeout 1 hour (in seconds) */
|
||||
static const time_t DMEVENTD_IDLE_EXIT_TIMEOUT = 60 * 60;
|
||||
|
||||
static int _debug_level = 0;
|
||||
static int _use_syslog = 1;
|
||||
static int _systemd_activation = 0;
|
||||
static int _foreground = 0;
|
||||
static int _restart = 0;
|
||||
static time_t _idle_since = 0;
|
||||
static const char *_exit_on = DEFAULT_DMEVENTD_EXIT_ON_PATH;
|
||||
static char **_initial_registrations = 0;
|
||||
|
||||
/* FIXME Make configurable at runtime */
|
||||
@@ -200,9 +202,9 @@ struct message_data {
|
||||
char *dso_name; /* Name of DSO. */
|
||||
char *device_uuid; /* Mapped device path. */
|
||||
char *events_str; /* Events string as fetched from message. */
|
||||
unsigned events_field; /* Events bitfield. */
|
||||
uint32_t timeout_secs;
|
||||
enum dm_event_mask events_field; /* Events bitfield. */
|
||||
char *timeout_str;
|
||||
uint32_t timeout_secs;
|
||||
struct dm_event_daemon_message *msg; /* Pointer to message buffer. */
|
||||
};
|
||||
|
||||
@@ -236,7 +238,7 @@ struct thread_status {
|
||||
int status; /* See DM_THREAD_{REGISTERING,RUNNING,DONE} */
|
||||
|
||||
int events; /* bitfield for event filter. */
|
||||
int current_events; /* bitfield for occurred events. */
|
||||
int current_events; /* bitfield for occured events. */
|
||||
struct dm_task *wait_task;
|
||||
int pending; /* Set when event filter change is pending */
|
||||
time_t next_time;
|
||||
@@ -427,7 +429,7 @@ static struct thread_status *_alloc_thread_status(const struct message_data *dat
|
||||
if (!(thread->device.name = strdup(data->device_uuid)))
|
||||
goto_out;
|
||||
|
||||
/* runs ioctl and may register lvm2 plugin */
|
||||
/* runs ioctl and may register lvm2 pluging */
|
||||
thread->processing = 1;
|
||||
thread->status = DM_THREAD_REGISTERING;
|
||||
|
||||
@@ -520,7 +522,7 @@ static int _fetch_string(char **ptr, char **src, const int delimiter)
|
||||
*p = delimiter;
|
||||
*src = p;
|
||||
}
|
||||
(*src)++; /* Skip delimiter, next field */
|
||||
(*src)++; /* Skip delmiter, next field */
|
||||
} else if ((len = strlen(*src))) {
|
||||
/* No delimiter, item ends with '\0' */
|
||||
if (!(*ptr = strdup(*src))) {
|
||||
@@ -721,18 +723,12 @@ static int _get_status(struct message_data *message_data)
|
||||
static int _get_parameters(struct message_data *message_data) {
|
||||
struct dm_event_daemon_message *msg = message_data->msg;
|
||||
int size;
|
||||
char idle_buf[32] = "";
|
||||
|
||||
if (_idle_since)
|
||||
(void)dm_snprintf(idle_buf, sizeof(idle_buf), " idle=%lu", (long unsigned) (time(NULL) - _idle_since));
|
||||
|
||||
free(msg->data);
|
||||
if ((size = dm_asprintf(&msg->data, "%s pid=%d daemon=%s exec_method=%s exit_on=\"%s\"%s",
|
||||
if ((size = dm_asprintf(&msg->data, "%s pid=%d daemon=%s exec_method=%s",
|
||||
message_data->id, getpid(),
|
||||
_foreground ? "no" : "yes",
|
||||
_systemd_activation ? "systemd" : "direct",
|
||||
_exit_on,
|
||||
idle_buf)) < 0) {
|
||||
_systemd_activation ? "systemd" : "direct")) < 0) {
|
||||
stack;
|
||||
return -ENOMEM;
|
||||
}
|
||||
@@ -991,7 +987,6 @@ static void _monitor_unregister(void *arg)
|
||||
DEBUGLOG("Unregistering monitor for %s.", thread->device.name);
|
||||
_unregister_for_timeout(thread);
|
||||
|
||||
/* coverity[missing_lock] no missing lock here */
|
||||
if ((thread->status != DM_THREAD_REGISTERING) &&
|
||||
!_do_unregister_device(thread))
|
||||
log_error("%s: %s unregister failed.", __func__,
|
||||
@@ -1002,8 +997,6 @@ static void _monitor_unregister(void *arg)
|
||||
_lock_mutex();
|
||||
thread->status = DM_THREAD_DONE; /* Last access to thread memory! */
|
||||
_unlock_mutex();
|
||||
if (_exit_now) /* Exit is already in-progress, wake-up sleeping select() */
|
||||
kill(getpid(), SIGINT);
|
||||
}
|
||||
|
||||
/* Device monitoring thread. */
|
||||
@@ -1050,9 +1043,9 @@ static void *_monitor_thread(void *arg)
|
||||
_unlock_mutex();
|
||||
|
||||
_do_process_event(thread);
|
||||
thread->current_events = 0; /* Current events processed */
|
||||
|
||||
_lock_mutex();
|
||||
thread->current_events = 0; /* Current events processed */
|
||||
thread->processing = 0;
|
||||
|
||||
/*
|
||||
@@ -1168,36 +1161,6 @@ static int _unregister_for_event(struct message_data *message_data)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void _unregister_all_threads(void)
|
||||
{
|
||||
struct thread_status *thread, *tmp;
|
||||
|
||||
_lock_mutex();
|
||||
|
||||
dm_list_iterate_items_safe(thread, tmp, &_thread_registry)
|
||||
_update_events(thread, 0);
|
||||
|
||||
_unlock_mutex();
|
||||
}
|
||||
|
||||
static void _wait_for_new_pid(void)
|
||||
{
|
||||
unsigned long st_ino = 0;
|
||||
struct stat st;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < 400000; ++i) {
|
||||
if (lstat(DMEVENTD_PIDFILE, &st) == 0) {
|
||||
if (!st_ino)
|
||||
st_ino = st.st_ino;
|
||||
else if (st_ino != st.st_ino)
|
||||
break; /* different pidfile */
|
||||
} else if (errno == ENOENT)
|
||||
break; /* pidfile is removed */
|
||||
usleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Register for an event.
|
||||
*
|
||||
@@ -1441,8 +1404,7 @@ static int _open_fifo(const char *path)
|
||||
} else if (!S_ISFIFO(st.st_mode) || st.st_uid ||
|
||||
(st.st_mode & (S_IEXEC | S_IRWXG | S_IRWXO))) {
|
||||
log_warn("WARNING: %s has wrong attributes: Replacing.", path);
|
||||
/* coverity[toctou] don't care, path is going to be recreated */
|
||||
if (unlink(path) && (errno != ENOENT)) {
|
||||
if (unlink(path)) {
|
||||
log_sys_error("unlink", path);
|
||||
return -1;
|
||||
}
|
||||
@@ -1450,7 +1412,6 @@ static int _open_fifo(const char *path)
|
||||
|
||||
/* Create fifo. */
|
||||
(void) dm_prepare_selinux_context(path, S_IFIFO);
|
||||
/* coverity[toctou] revalidating things again */
|
||||
if ((mkfifo(path, 0600) == -1) && errno != EEXIST) {
|
||||
log_sys_error("mkfifo", path);
|
||||
(void) dm_prepare_selinux_context(NULL, 0);
|
||||
@@ -1679,7 +1640,7 @@ static int _do_process_request(struct dm_event_daemon_message *msg)
|
||||
} else
|
||||
ret = _handle_request(msg, &message_data);
|
||||
|
||||
msg->cmd = (uint32_t)ret;
|
||||
msg->cmd = ret;
|
||||
if (!msg->data)
|
||||
msg->size = dm_asprintf(&(msg->data), "%s %s", message_data.id, strerror(-ret));
|
||||
|
||||
@@ -1716,9 +1677,9 @@ static void _process_request(struct dm_event_fifos *fifos)
|
||||
free(msg.data);
|
||||
|
||||
if (cmd == DM_EVENT_CMD_DIE) {
|
||||
_unregister_all_threads();
|
||||
_exit_now = DM_SCHEDULED_EXIT;
|
||||
log_info("dmeventd exiting for restart.");
|
||||
if (unlink(DMEVENTD_PIDFILE))
|
||||
log_sys_error("unlink", DMEVENTD_PIDFILE);
|
||||
_exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1765,7 +1726,7 @@ static void _cleanup_unused_threads(void)
|
||||
DEBUGLOG("Destroying Thr %x.", (int)thread->thread);
|
||||
|
||||
if (pthread_join(thread->thread, NULL))
|
||||
log_sys_debug("pthread_join", "");
|
||||
log_sys_error("pthread_join", "");
|
||||
|
||||
_free_thread_status(thread);
|
||||
_lock_mutex();
|
||||
@@ -1796,7 +1757,7 @@ static void _init_thread_signals(void)
|
||||
sigdelset(&my_sigset, SIGQUIT);
|
||||
|
||||
if (pthread_sigmask(SIG_BLOCK, &my_sigset, NULL))
|
||||
log_sys_debug("pthread_sigmask", "SIG_BLOCK");
|
||||
log_sys_error("pthread_sigmask", "SIG_BLOCK");
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1808,8 +1769,7 @@ static void _init_thread_signals(void)
|
||||
*/
|
||||
static void _exit_handler(int sig __attribute__((unused)))
|
||||
{
|
||||
if (!_exit_now)
|
||||
_exit_now = DM_SIGNALED_EXIT;
|
||||
_exit_now = DM_SIGNALED_EXIT;
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
@@ -1825,7 +1785,7 @@ static int _set_oom_adj(const char *oom_adj_path, int val)
|
||||
fprintf(fp, "%i", val);
|
||||
|
||||
if (dm_fclose(fp))
|
||||
log_sys_debug("fclose", oom_adj_path);
|
||||
log_sys_error("fclose", oom_adj_path);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1839,11 +1799,11 @@ static int _protect_against_oom_killer(void)
|
||||
|
||||
if (stat(OOM_ADJ_FILE, &st) == -1) {
|
||||
if (errno != ENOENT)
|
||||
log_sys_debug("stat", OOM_ADJ_FILE);
|
||||
log_sys_error("stat", OOM_ADJ_FILE);
|
||||
|
||||
/* Try old oom_adj interface as a fallback */
|
||||
if (stat(OOM_ADJ_FILE_OLD, &st) == -1) {
|
||||
log_sys_debug("stat", OOM_ADJ_FILE_OLD);
|
||||
log_sys_error("stat", OOM_ADJ_FILE_OLD);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1931,30 +1891,26 @@ out:
|
||||
|
||||
static void _remove_files_on_exit(void)
|
||||
{
|
||||
if (unlink(DMEVENTD_PIDFILE) && (errno != ENOENT))
|
||||
log_sys_debug("unlink", DMEVENTD_PIDFILE);
|
||||
if (unlink(DMEVENTD_PIDFILE))
|
||||
log_sys_error("unlink", DMEVENTD_PIDFILE);
|
||||
|
||||
if (!_systemd_activation) {
|
||||
if (unlink(DM_EVENT_FIFO_CLIENT) && (errno != ENOENT))
|
||||
log_sys_debug("unlink", DM_EVENT_FIFO_CLIENT);
|
||||
if (unlink(DM_EVENT_FIFO_CLIENT))
|
||||
log_sys_error("unlink", DM_EVENT_FIFO_CLIENT);
|
||||
|
||||
if (unlink(DM_EVENT_FIFO_SERVER) && (errno != ENOENT))
|
||||
log_sys_debug("unlink", DM_EVENT_FIFO_SERVER);
|
||||
if (unlink(DM_EVENT_FIFO_SERVER))
|
||||
log_sys_error("unlink", DM_EVENT_FIFO_SERVER);
|
||||
}
|
||||
}
|
||||
|
||||
static void _daemonize(void)
|
||||
{
|
||||
int child_status, null_fd;
|
||||
int child_status;
|
||||
int fd;
|
||||
pid_t pid;
|
||||
struct rlimit rlim;
|
||||
struct timeval tval;
|
||||
sigset_t my_sigset;
|
||||
struct custom_fds custom_fds = {
|
||||
/* Do not close fds preloaded by systemd! */
|
||||
.out = (_systemd_activation) ? SD_FD_FIFO_SERVER : -1,
|
||||
.err = -1,
|
||||
.report = (_systemd_activation) ? SD_FD_FIFO_CLIENT : -1,
|
||||
};
|
||||
|
||||
sigemptyset(&my_sigset);
|
||||
if (sigprocmask(SIG_SETMASK, &my_sigset, NULL) < 0) {
|
||||
@@ -1998,28 +1954,33 @@ static void _daemonize(void)
|
||||
if (chdir("/"))
|
||||
exit(EXIT_CHDIR_FAILURE);
|
||||
|
||||
daemon_close_stray_fds("dmeventd", 0, -1, &custom_fds);
|
||||
if (getrlimit(RLIMIT_NOFILE, &rlim) < 0)
|
||||
fd = 256; /* just have to guess */
|
||||
else
|
||||
fd = rlim.rlim_cur;
|
||||
|
||||
if ((null_fd = open("/dev/null", O_RDWR)) < 0)
|
||||
for (--fd; fd >= 0; fd--) {
|
||||
#ifdef __linux__
|
||||
/* Do not close fds preloaded by systemd! */
|
||||
if (_systemd_activation &&
|
||||
(fd == SD_FD_FIFO_SERVER || fd == SD_FD_FIFO_CLIENT))
|
||||
continue;
|
||||
#endif
|
||||
(void) close(fd);
|
||||
}
|
||||
|
||||
if ((open("/dev/null", O_RDONLY) < 0) ||
|
||||
(open("/dev/null", O_WRONLY) < 0) ||
|
||||
(open("/dev/null", O_WRONLY) < 0))
|
||||
exit(EXIT_DESC_OPEN_FAILURE);
|
||||
|
||||
if ((dup2(null_fd, STDIN_FILENO) == -1) ||
|
||||
(dup2(null_fd, STDOUT_FILENO) == -1) ||
|
||||
(dup2(null_fd, STDERR_FILENO) == -1))
|
||||
exit(EXIT_DESC_OPEN_FAILURE);
|
||||
|
||||
if ((null_fd > STDERR_FILENO) && close(null_fd))
|
||||
exit(EXIT_DESC_CLOSE_FAILURE);
|
||||
|
||||
setsid();
|
||||
|
||||
/* coverity[leaked_handle] 'null_fd' handle is not leaking */
|
||||
}
|
||||
|
||||
static int _reinstate_registrations(struct dm_event_fifos *fifos)
|
||||
{
|
||||
static const char _failed_parsing_msg[] = "Failed to parse existing event registration.\n";
|
||||
static const char _delim[] = " ";
|
||||
static const char *_delim = " ";
|
||||
struct dm_event_daemon_message msg = { 0 };
|
||||
char *endp, *dso_name, *dev_name, *mask, *timeout;
|
||||
unsigned long mask_value, timeout_value;
|
||||
@@ -2069,94 +2030,28 @@ static int _reinstate_registrations(struct dm_event_fifos *fifos)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _info_dmeventd(const char *name, struct dm_event_fifos *fifos)
|
||||
{
|
||||
struct dm_event_daemon_message msg = { 0 };
|
||||
int i, count = 0;
|
||||
char *line;
|
||||
int version;
|
||||
int ret = 0;
|
||||
|
||||
if (!dm_daemon_is_running(DMEVENTD_PIDFILE)) {
|
||||
fprintf(stderr, "No running dmeventd instance for status query.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Get the list of registrations from the running daemon. */
|
||||
if (!init_fifos(fifos)) {
|
||||
fprintf(stderr, "Could not initiate communication with existing dmeventd.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!dm_event_get_version(fifos, &version)) {
|
||||
fprintf(stderr, "Could not communicate with existing dmeventd.\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (version < 1) {
|
||||
fprintf(stderr, "The running dmeventd instance is too old.\n"
|
||||
"Protocol version %d (required: 1). Action cancelled.\n", version);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (daemon_talk(fifos, &msg, DM_EVENT_CMD_GET_STATUS, "-", "-", 0, 0)) {
|
||||
fprintf(stderr, "Failed to acquire status from existing dmeventd.\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
line = strchr(msg.data, ' ') + 1;
|
||||
for (i = 0; msg.data[i]; ++i)
|
||||
if (msg.data[i] == ';') {
|
||||
msg.data[i] = 0;
|
||||
if (!count)
|
||||
printf("%s is monitoring:\n", name);
|
||||
printf("%s\n", line);
|
||||
line = msg.data + i + 1;
|
||||
++count;
|
||||
}
|
||||
|
||||
free(msg.data);
|
||||
|
||||
if (!count)
|
||||
printf("%s does not monitor any device.\n", name);
|
||||
|
||||
if (version >= 2) {
|
||||
if (daemon_talk(fifos, &msg, DM_EVENT_CMD_GET_PARAMETERS, "-", "-", 0, 0)) {
|
||||
fprintf(stderr, "Failed to acquire parameters from existing dmeventd.\n");
|
||||
goto out;
|
||||
}
|
||||
printf("%s internal status: %s\n", name, msg.data);
|
||||
free(msg.data);
|
||||
}
|
||||
|
||||
ret = 1;
|
||||
out:
|
||||
fini_fifos(fifos);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Return 0 - fail, 1 - success, 2 - continue */
|
||||
static int _restart_dmeventd(struct dm_event_fifos *fifos)
|
||||
static void _restart_dmeventd(void)
|
||||
{
|
||||
struct dm_event_fifos fifos = {
|
||||
.client = -1,
|
||||
.server = -1,
|
||||
/* FIXME Make these either configurable or depend directly on dmeventd_path */
|
||||
.client_path = DM_EVENT_FIFO_CLIENT,
|
||||
.server_path = DM_EVENT_FIFO_SERVER
|
||||
};
|
||||
struct dm_event_daemon_message msg = { 0 };
|
||||
int i, count = 0;
|
||||
char *message;
|
||||
int version;
|
||||
const char *e;
|
||||
|
||||
if (!dm_daemon_is_running(DMEVENTD_PIDFILE)) {
|
||||
fprintf(stderr, "WARNING: Could not find running dmeventd associated with pid file %s.\n", DMEVENTD_PIDFILE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Get the list of registrations from the running daemon. */
|
||||
if (!init_fifos(fifos)) {
|
||||
if (!init_fifos(&fifos)) {
|
||||
fprintf(stderr, "WARNING: Could not initiate communication with existing dmeventd.\n");
|
||||
return 0;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!dm_event_get_version(fifos, &version)) {
|
||||
if (!dm_event_get_version(&fifos, &version)) {
|
||||
fprintf(stderr, "WARNING: Could not communicate with existing dmeventd.\n");
|
||||
goto bad;
|
||||
}
|
||||
@@ -2168,7 +2063,7 @@ static int _restart_dmeventd(struct dm_event_fifos *fifos)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
if (daemon_talk(fifos, &msg, DM_EVENT_CMD_GET_STATUS, "-", "-", 0, 0))
|
||||
if (daemon_talk(&fifos, &msg, DM_EVENT_CMD_GET_STATUS, "-", "-", 0, 0))
|
||||
goto bad;
|
||||
|
||||
message = strchr(msg.data, ' ') + 1;
|
||||
@@ -2192,7 +2087,7 @@ static int _restart_dmeventd(struct dm_event_fifos *fifos)
|
||||
}
|
||||
|
||||
if (version >= 2) {
|
||||
if (daemon_talk(fifos, &msg, DM_EVENT_CMD_GET_PARAMETERS, "-", "-", 0, 0)) {
|
||||
if (daemon_talk(&fifos, &msg, DM_EVENT_CMD_GET_PARAMETERS, "-", "-", 0, 0)) {
|
||||
fprintf(stderr, "Failed to acquire parameters from old dmeventd.\n");
|
||||
goto bad;
|
||||
}
|
||||
@@ -2212,7 +2107,7 @@ static int _restart_dmeventd(struct dm_event_fifos *fifos)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (daemon_talk(fifos, &msg, DM_EVENT_CMD_DIE, "-", "-", 0, 0)) {
|
||||
if (daemon_talk(&fifos, &msg, DM_EVENT_CMD_DIE, "-", "-", 0, 0)) {
|
||||
fprintf(stderr, "Old dmeventd refused to die.\n");
|
||||
goto bad;
|
||||
}
|
||||
@@ -2221,41 +2116,43 @@ static int _restart_dmeventd(struct dm_event_fifos *fifos)
|
||||
((e = getenv(SD_ACTIVATION_ENV_VAR_NAME)) && strcmp(e, "1")))
|
||||
_systemd_activation = 1;
|
||||
|
||||
fini_fifos(fifos);
|
||||
|
||||
/* Give a few seconds dmeventd to finish */
|
||||
_wait_for_new_pid();
|
||||
|
||||
if (!_systemd_activation)
|
||||
return 2; // continue with dmeventd start up
|
||||
|
||||
/* Reopen fifos. */
|
||||
if (!init_fifos(fifos)) {
|
||||
fprintf(stderr, "Could not initiate communication with new instance of dmeventd.\n");
|
||||
return 0;
|
||||
for (i = 0; i < 10; ++i) {
|
||||
if ((access(DMEVENTD_PIDFILE, F_OK) == -1) && (errno == ENOENT))
|
||||
break;
|
||||
usleep(10);
|
||||
}
|
||||
|
||||
if (!_reinstate_registrations(fifos)) {
|
||||
if (!_systemd_activation) {
|
||||
fini_fifos(&fifos);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Reopen fifos. */
|
||||
fini_fifos(&fifos);
|
||||
if (!init_fifos(&fifos)) {
|
||||
fprintf(stderr, "Could not initiate communication with new instance of dmeventd.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!_reinstate_registrations(&fifos)) {
|
||||
fprintf(stderr, "Failed to reinstate monitoring with new instance of dmeventd.\n");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
fini_fifos(fifos);
|
||||
return 1;
|
||||
fini_fifos(&fifos);
|
||||
exit(EXIT_SUCCESS);
|
||||
bad:
|
||||
fini_fifos(fifos);
|
||||
return 0;
|
||||
fini_fifos(&fifos);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static void _usage(char *prog, FILE *file)
|
||||
{
|
||||
fprintf(file, "Usage:\n"
|
||||
"%s [-d [-d [-d]]] [-e path] [-f] [-h] [i] [-l] [-R] [-V] [-?]\n\n"
|
||||
"%s [-d [-d [-d]]] [-f] [-h] [-l] [-R] [-V] [-?]\n\n"
|
||||
" -d Log debug messages to syslog (-d, -dd, -ddd)\n"
|
||||
" -e Select a file path checked on exit\n"
|
||||
" -f Don't fork, run in the foreground\n"
|
||||
" -h Show this help information\n"
|
||||
" -i Query running instance of dmeventd for info\n"
|
||||
" -l Log to stdout,stderr instead of syslog\n"
|
||||
" -? Show this help information on stderr\n"
|
||||
" -R Restart dmeventd\n"
|
||||
@@ -2265,10 +2162,6 @@ static void _usage(char *prog, FILE *file)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
signed char opt;
|
||||
int debug_level = 0;
|
||||
int info = 0;
|
||||
int restart = 0;
|
||||
int use_syslog = 1;
|
||||
struct dm_event_fifos fifos = {
|
||||
.client = -1,
|
||||
.server = -1,
|
||||
@@ -2276,58 +2169,39 @@ int main(int argc, char *argv[])
|
||||
.server_path = DM_EVENT_FIFO_SERVER
|
||||
};
|
||||
time_t now, idle_exit_timeout = DMEVENTD_IDLE_EXIT_TIMEOUT;
|
||||
opterr = 0;
|
||||
optind = 0;
|
||||
|
||||
optopt = optind = opterr = 0;
|
||||
optarg = (char*) "";
|
||||
while ((opt = getopt(argc, argv, ":?e:fhiVdlR")) != EOF) {
|
||||
while ((opt = getopt(argc, argv, "?fhVdlR")) != EOF) {
|
||||
switch (opt) {
|
||||
case 'h':
|
||||
_usage(argv[0], stdout);
|
||||
return EXIT_SUCCESS;
|
||||
exit(EXIT_SUCCESS);
|
||||
case '?':
|
||||
_usage(argv[0], stderr);
|
||||
return EXIT_SUCCESS;
|
||||
case 'i':
|
||||
info++;
|
||||
break;
|
||||
exit(EXIT_SUCCESS);
|
||||
case 'R':
|
||||
restart++;
|
||||
break;
|
||||
case 'e':
|
||||
if (strchr(optarg, '"')) {
|
||||
fprintf(stderr, "dmeventd: option -e does not accept path \"%s\" with '\"' character.\n", optarg);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
_exit_on=optarg;
|
||||
_restart++;
|
||||
break;
|
||||
case 'f':
|
||||
_foreground++;
|
||||
break;
|
||||
case 'd':
|
||||
debug_level++;
|
||||
_debug_level++;
|
||||
break;
|
||||
case 'l':
|
||||
use_syslog = 0;
|
||||
_use_syslog = 0;
|
||||
break;
|
||||
case 'V':
|
||||
printf("dmeventd version: %s\n", DM_LIB_VERSION);
|
||||
return EXIT_SUCCESS;
|
||||
case ':':
|
||||
fprintf(stderr, "dmeventd: option -%c requires an argument.\n", optopt);
|
||||
return EXIT_FAILURE;
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
}
|
||||
|
||||
if (info) {
|
||||
_foreground = 1;
|
||||
use_syslog = 0;
|
||||
}
|
||||
|
||||
if (!_foreground && !use_syslog) {
|
||||
if (!_foreground && !_use_syslog) {
|
||||
printf("WARNING: Ignoring logging to stdout, needs options -f\n");
|
||||
use_syslog = 1;
|
||||
_use_syslog = 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Switch to C locale to avoid reading large locale-archive file
|
||||
* used by some glibc (on some distributions it takes over 100MB).
|
||||
@@ -2336,29 +2210,21 @@ int main(int argc, char *argv[])
|
||||
if (setenv("LC_ALL", "C", 1))
|
||||
perror("Cannot set LC_ALL to C");
|
||||
|
||||
if (info)
|
||||
return _info_dmeventd(argv[0], &fifos) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
if (_restart)
|
||||
_restart_dmeventd();
|
||||
|
||||
#ifdef __linux__
|
||||
_systemd_activation = _systemd_handover(&fifos);
|
||||
#endif
|
||||
|
||||
dm_log_with_errno_init(_libdm_log);
|
||||
|
||||
if (restart) {
|
||||
dm_event_log_set(debug_level, 0);
|
||||
|
||||
if ((restart = _restart_dmeventd(&fifos)) < 2)
|
||||
return restart ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (!_foreground)
|
||||
_daemonize();
|
||||
|
||||
if (use_syslog)
|
||||
if (_use_syslog)
|
||||
openlog("dmeventd", LOG_PID, LOG_DAEMON);
|
||||
|
||||
dm_event_log_set(debug_level, use_syslog);
|
||||
dm_event_log_set(_debug_level, _use_syslog);
|
||||
dm_log_with_errno_init(_libdm_log);
|
||||
|
||||
(void) dm_prepare_selinux_context(DMEVENTD_PIDFILE, S_IFREG);
|
||||
if (dm_create_lockfile(DMEVENTD_PIDFILE) == 0)
|
||||
@@ -2419,28 +2285,15 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else
|
||||
switch (_exit_now) {
|
||||
case DM_SIGNALED_EXIT:
|
||||
_exit_now = DM_SCHEDULED_EXIT;
|
||||
/*
|
||||
* When '_exit_now' is set, signal has been received,
|
||||
* but can not simply exit unless all
|
||||
* threads are done processing.
|
||||
*/
|
||||
log_info("dmeventd received break, scheduling exit.");
|
||||
/* fall through */
|
||||
case DM_SCHEDULED_EXIT:
|
||||
/* While exit is scheduled, check for exit_on file */
|
||||
DEBUGLOG("Checking exit on file \"%s\".", _exit_on);
|
||||
if (_exit_on[0] && (access(_exit_on, F_OK) == 0)) {
|
||||
log_info("dmeventd detected exit on file %s, unregistering all monitored devices.",
|
||||
_exit_on);
|
||||
_unregister_all_threads();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (_exit_now == DM_SIGNALED_EXIT) {
|
||||
_exit_now = DM_SCHEDULED_EXIT;
|
||||
/*
|
||||
* When '_exit_now' is set, signal has been received,
|
||||
* but can not simply exit unless all
|
||||
* threads are done processing.
|
||||
*/
|
||||
log_info("dmeventd received break, scheduling exit.");
|
||||
}
|
||||
_process_request(&fifos);
|
||||
_cleanup_unused_threads();
|
||||
}
|
||||
@@ -2450,11 +2303,11 @@ int main(int argc, char *argv[])
|
||||
log_notice("dmeventd shutting down.");
|
||||
|
||||
if (fifos.client >= 0 && close(fifos.client))
|
||||
log_sys_debug("client close", fifos.client_path);
|
||||
log_sys_error("client close", fifos.client_path);
|
||||
if (fifos.server >= 0 && close(fifos.server))
|
||||
log_sys_debug("server close", fifos.server_path);
|
||||
log_sys_error("server close", fifos.server_path);
|
||||
|
||||
if (use_syslog)
|
||||
if (_use_syslog)
|
||||
closelog();
|
||||
|
||||
_exit_dm_lib();
|
||||
|
@@ -68,7 +68,7 @@ struct dm_event_fifos {
|
||||
int daemon_talk(struct dm_event_fifos *fifos,
|
||||
struct dm_event_daemon_message *msg, int cmd,
|
||||
const char *dso_name, const char *dev_name,
|
||||
unsigned evmask, uint32_t timeout);
|
||||
enum dm_event_mask evmask, uint32_t timeout);
|
||||
int init_fifos(struct dm_event_fifos *fifos);
|
||||
void fini_fifos(struct dm_event_fifos *fifos);
|
||||
int dm_event_get_version(struct dm_event_fifos *fifos, int *version);
|
||||
|
@@ -352,7 +352,7 @@ static int _daemon_write(struct dm_event_fifos *fifos,
|
||||
int daemon_talk(struct dm_event_fifos *fifos,
|
||||
struct dm_event_daemon_message *msg, int cmd,
|
||||
const char *dso_name, const char *dev_name,
|
||||
unsigned evmask, uint32_t timeout)
|
||||
enum dm_event_mask evmask, uint32_t timeout)
|
||||
{
|
||||
int msg_size;
|
||||
memset(msg, 0, sizeof(*msg));
|
||||
@@ -400,16 +400,25 @@ int daemon_talk(struct dm_event_fifos *fifos,
|
||||
return (int32_t) msg->cmd;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check for usable client fifo file
|
||||
* start_daemon
|
||||
*
|
||||
* Returns: 2 client path does not exists, dmeventd should be restarted
|
||||
* 1 on success, 0 otherwise
|
||||
* This function forks off a process (dmeventd) that will handle
|
||||
* the events. I am currently test opening one of the fifos to
|
||||
* ensure that the daemon is running and listening... I thought
|
||||
* this would be less expensive than fork/exec'ing every time.
|
||||
* Perhaps there is an even quicker/better way (no, checking the
|
||||
* lock file is _not_ a better way).
|
||||
*
|
||||
* Returns: 1 on success, 0 otherwise
|
||||
*/
|
||||
static int _check_for_usable_fifos(char *dmeventd_path, struct dm_event_fifos *fifos)
|
||||
static int _start_daemon(char *dmeventd_path, struct dm_event_fifos *fifos)
|
||||
{
|
||||
int pid, ret = 0;
|
||||
int status;
|
||||
struct stat statbuf;
|
||||
char default_dmeventd_path[] = DMEVENTD_PATH;
|
||||
char *args[] = { dmeventd_path ? : default_dmeventd_path, NULL };
|
||||
|
||||
/*
|
||||
* FIXME Explicitly verify the code's requirement that client_path is secure:
|
||||
@@ -420,7 +429,7 @@ static int _check_for_usable_fifos(char *dmeventd_path, struct dm_event_fifos *f
|
||||
if ((lstat(fifos->client_path, &statbuf) < 0)) {
|
||||
if (errno == ENOENT)
|
||||
/* Jump ahead if fifo does not already exist. */
|
||||
return 2;
|
||||
goto start_server;
|
||||
else {
|
||||
log_sys_error("stat", fifos->client_path);
|
||||
return 0;
|
||||
@@ -446,14 +455,12 @@ static int _check_for_usable_fifos(char *dmeventd_path, struct dm_event_fifos *f
|
||||
log_error("%s is no longer a secure root-owned fifo with mode 0600.", fifos->client_path);
|
||||
if (close(fifos->client))
|
||||
log_sys_debug("close", fifos->client_path);
|
||||
fifos->client = -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* server is running and listening */
|
||||
if (close(fifos->client))
|
||||
log_sys_debug("close", fifos->client_path);
|
||||
fifos->client = -1;
|
||||
return 1;
|
||||
}
|
||||
if (errno != ENXIO && errno != ENOENT) {
|
||||
@@ -462,36 +469,9 @@ static int _check_for_usable_fifos(char *dmeventd_path, struct dm_event_fifos *f
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* start_daemon
|
||||
*
|
||||
* This function forks off a process (dmeventd) that will handle
|
||||
* the events. I am currently test opening one of the fifos to
|
||||
* ensure that the daemon is running and listening... I thought
|
||||
* this would be less expensive than fork/exec'ing every time.
|
||||
* Perhaps there is an even quicker/better way (no, checking the
|
||||
* lock file is _not_ a better way).
|
||||
*
|
||||
* Returns: 1 on success, 0 otherwise
|
||||
*/
|
||||
static int _start_daemon(char *dmeventd_path, struct dm_event_fifos *fifos)
|
||||
{
|
||||
struct stat statbuf;
|
||||
char default_dmeventd_path[] = DMEVENTD_PATH;
|
||||
char *args[] = { dmeventd_path ? : default_dmeventd_path, NULL };
|
||||
int pid, ret = 0;
|
||||
int status;
|
||||
|
||||
switch (_check_for_usable_fifos(dmeventd_path, fifos)) {
|
||||
case 0: return_0;
|
||||
case 1: return 1; /* Already running dmeventd */
|
||||
}
|
||||
|
||||
start_server:
|
||||
/* server is not running */
|
||||
|
||||
if ((args[0][0] == '/') && stat(args[0], &statbuf)) {
|
||||
log_sys_error("stat", args[0]);
|
||||
return 0;
|
||||
@@ -512,17 +492,8 @@ static int _start_daemon(char *dmeventd_path, struct dm_event_fifos *fifos)
|
||||
strerror(errno));
|
||||
else if (WEXITSTATUS(status))
|
||||
log_error("Unable to start dmeventd.");
|
||||
else {
|
||||
/* Loop here till forked dmeventd is serving fifos */
|
||||
for (ret = 100; ret > 0; --ret)
|
||||
switch (_check_for_usable_fifos(dmeventd_path, fifos)) {
|
||||
case 0: return_0;
|
||||
case 1: return 1;
|
||||
case 2: usleep(1000); break;
|
||||
}
|
||||
/* ret == 0 */
|
||||
log_error("Dmeventd is not serving fifos.");
|
||||
}
|
||||
else
|
||||
ret = 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -542,7 +513,7 @@ int init_fifos(struct dm_event_fifos *fifos)
|
||||
/* Lock out anyone else trying to do communication with the daemon. */
|
||||
if (flock(fifos->server, LOCK_EX) < 0) {
|
||||
log_sys_error("flock", fifos->server_path);
|
||||
goto bad_no_unlock;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
/* if ((fifos->client = open(fifos->client_path, O_WRONLY | O_NONBLOCK)) < 0) {*/
|
||||
@@ -553,9 +524,6 @@ int init_fifos(struct dm_event_fifos *fifos)
|
||||
|
||||
return 1;
|
||||
bad:
|
||||
if (flock(fifos->server, LOCK_UN))
|
||||
log_sys_debug("flock unlock", fifos->server_path);
|
||||
bad_no_unlock:
|
||||
if (close(fifos->server))
|
||||
log_sys_debug("close", fifos->server_path);
|
||||
fifos->server = -1;
|
||||
@@ -584,8 +552,6 @@ void fini_fifos(struct dm_event_fifos *fifos)
|
||||
if (close(fifos->server))
|
||||
log_sys_debug("close", fifos->server_path);
|
||||
}
|
||||
|
||||
fifos->client = fifos->server = -1;
|
||||
}
|
||||
|
||||
/* Get uuid of a device */
|
||||
@@ -754,7 +720,7 @@ static char *_fetch_string(char **src, const int delimiter)
|
||||
|
||||
/* Parse a device message from the daemon. */
|
||||
static int _parse_message(struct dm_event_daemon_message *msg, char **dso_name,
|
||||
char **uuid, unsigned *evmask)
|
||||
char **uuid, enum dm_event_mask *evmask)
|
||||
{
|
||||
char *id;
|
||||
char *p = msg->data;
|
||||
@@ -779,7 +745,7 @@ int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next)
|
||||
int ret = 0;
|
||||
const char *uuid = NULL;
|
||||
char *reply_dso = NULL, *reply_uuid = NULL;
|
||||
unsigned reply_mask = 0;
|
||||
enum dm_event_mask reply_mask = 0;
|
||||
struct dm_task *dmt = NULL;
|
||||
struct dm_event_daemon_message msg = { 0 };
|
||||
struct dm_info info;
|
||||
@@ -878,7 +844,6 @@ int dm_event_get_registered_device(struct dm_event_handler *dmevh, int next)
|
||||
int dm_event_get_version(struct dm_event_fifos *fifos, int *version) {
|
||||
char *p;
|
||||
struct dm_event_daemon_message msg = { 0 };
|
||||
int ret = 0;
|
||||
|
||||
if (daemon_talk(fifos, &msg, DM_EVENT_CMD_HELLO, NULL, NULL, 0, 0))
|
||||
return 0;
|
||||
@@ -886,17 +851,13 @@ int dm_event_get_version(struct dm_event_fifos *fifos, int *version) {
|
||||
*version = 0;
|
||||
|
||||
if (!p || !(p = strchr(p, ' '))) /* Message ID */
|
||||
goto out;
|
||||
return 0;
|
||||
if (!(p = strchr(p + 1, ' '))) /* HELLO */
|
||||
goto out;
|
||||
return 0;
|
||||
if ((p = strchr(p + 1, ' '))) /* HELLO, once more */
|
||||
*version = atoi(p);
|
||||
|
||||
ret = 1;
|
||||
out:
|
||||
free(msg.data);
|
||||
|
||||
return ret;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void dm_event_log_set(int debug_log_level, int use_syslog)
|
||||
@@ -911,11 +872,11 @@ void dm_event_log(const char *subsys, int level, const char *file,
|
||||
{
|
||||
static int _abort_on_internal_errors = -1;
|
||||
static pthread_mutex_t _log_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
static long long _start = 0;
|
||||
static time_t start = 0;
|
||||
const char *indent = "";
|
||||
FILE *stream = log_stderr(level) ? stderr : stdout;
|
||||
int prio;
|
||||
long long now, now_nsec;
|
||||
time_t now;
|
||||
int log_with_debug = 0;
|
||||
|
||||
if (subsys[0] == '#') {
|
||||
@@ -962,28 +923,17 @@ void dm_event_log(const char *subsys, int level, const char *file,
|
||||
if (_use_syslog) {
|
||||
vsyslog(prio, format, ap);
|
||||
} else {
|
||||
if (_debug_level) {
|
||||
#define _NSEC_PER_SEC (1000000000LL)
|
||||
#ifdef HAVE_REALTIME
|
||||
struct timespec mono_time = { 0 };
|
||||
if (clock_gettime(CLOCK_MONOTONIC, &mono_time) == 0)
|
||||
now = mono_time.tv_sec * _NSEC_PER_SEC + mono_time.tv_nsec;
|
||||
else
|
||||
#endif
|
||||
now = time(NULL) * _NSEC_PER_SEC;
|
||||
|
||||
if (!_start)
|
||||
_start = now;
|
||||
now -= _start;
|
||||
now_nsec = now %_NSEC_PER_SEC;
|
||||
now /= _NSEC_PER_SEC;
|
||||
fprintf(stream, "[%2lld:%02lld.%06lld] %8x:%-6s%s",
|
||||
now / 60, now % 60, now_nsec / 1000,
|
||||
now = time(NULL);
|
||||
if (!start)
|
||||
start = now;
|
||||
now -= start;
|
||||
if (_debug_level)
|
||||
fprintf(stream, "[%2ld:%02ld] %8x:%-6s%s",
|
||||
(long)now / 60, (long)now % 60,
|
||||
// TODO: Maybe use shorter ID
|
||||
// ((int)(pthread_self()) >> 6) & 0xffff,
|
||||
(int)pthread_self(), subsys,
|
||||
(_debug_level > 3) ? "" : indent);
|
||||
}
|
||||
if (_debug_level > 3)
|
||||
fprintf(stream, "%28s:%4d %s", file, line, indent);
|
||||
vfprintf(stream, _(format), ap);
|
||||
@@ -1007,7 +957,7 @@ void dm_event_log(const char *subsys, int level, const char *file,
|
||||
|
||||
static char *_skip_string(char *src, const int delimiter)
|
||||
{
|
||||
src = strchr(src, delimiter);
|
||||
src = srtchr(src, delimiter);
|
||||
if (src && *(src + 1))
|
||||
return src + 1;
|
||||
return NULL;
|
||||
|
@@ -41,7 +41,7 @@ enum dm_event_mask {
|
||||
|
||||
DM_EVENT_STATUS_MASK = 0xFF0000,
|
||||
DM_EVENT_SYNC_STATUS = 0x010000, /* Mirror synchronization completed/failed. */
|
||||
DM_EVENT_TIMEOUT = 0x020000, /* Timeout has occurred */
|
||||
DM_EVENT_TIMEOUT = 0x020000, /* Timeout has occured */
|
||||
|
||||
DM_EVENT_REGISTRATION_PENDING = 0x1000000, /* Monitor thread is setting-up/shutting-down */
|
||||
};
|
||||
@@ -109,7 +109,7 @@ int dm_event_unregister_handler(const struct dm_event_handler *dmevh);
|
||||
/* Set debug level for logging, and whether to log on stdout/stderr or syslog */
|
||||
void dm_event_log_set(int debug_log_level, int use_syslog);
|
||||
|
||||
/* Log messages according to current debug level */
|
||||
/* Log messages acroding to current debug level */
|
||||
__attribute__((format(printf, 6, 0)))
|
||||
void dm_event_log(const char *subsys, int level, const char *file,
|
||||
int line, int dm_errno_or_class,
|
||||
|
@@ -87,7 +87,7 @@ int dmeventd_lvm2_init(void)
|
||||
lvm2_disable_dmeventd_monitoring(_lvm_handle);
|
||||
/* FIXME Temporary: move to dmeventd core */
|
||||
lvm2_run(_lvm_handle, "_memlock_inc");
|
||||
log_debug("lvm plugin initialized.");
|
||||
log_debug("lvm plugin initilized.");
|
||||
}
|
||||
|
||||
_register_count++;
|
||||
@@ -103,7 +103,7 @@ void dmeventd_lvm2_exit(void)
|
||||
pthread_mutex_lock(&_register_mutex);
|
||||
|
||||
if (!--_register_count) {
|
||||
log_debug("lvm plugin shutting down.");
|
||||
log_debug("lvm plugin shuting down.");
|
||||
lvm2_run(_lvm_handle, "_memlock_dec");
|
||||
dm_pool_destroy(_mem_pool);
|
||||
_mem_pool = NULL;
|
||||
@@ -123,7 +123,6 @@ struct dm_pool *dmeventd_lvm2_pool(void)
|
||||
|
||||
int dmeventd_lvm2_run(const char *cmdline)
|
||||
{
|
||||
/* coverity[missing_lock] no locking for run part */
|
||||
return (lvm2_run(_lvm_handle, cmdline) == LVM2_COMMAND_SUCCEEDED);
|
||||
}
|
||||
|
||||
|
@@ -38,7 +38,7 @@ static void _process_status_code(dm_status_mirror_health_t health,
|
||||
* A => Alive - No failures
|
||||
* D => Dead - A write failure occurred leaving mirror out-of-sync
|
||||
* F => Flush failed.
|
||||
* S => Sync - A synchronization failure occurred, mirror out-of-sync
|
||||
* S => Sync - A sychronization failure occurred, mirror out-of-sync
|
||||
* R => Read - A read failure occurred, mirror data unaffected
|
||||
* U => Unclassified failure (bug)
|
||||
*/
|
||||
|
@@ -17,7 +17,7 @@
|
||||
#include "daemons/dmeventd/libdevmapper-event.h"
|
||||
#include "lib/config/defaults.h"
|
||||
|
||||
/* Hold enough elements for the maximum number of RAID images */
|
||||
/* Hold enough elements for the mximum number of RAID images */
|
||||
#define RAID_DEVS_ELEMS ((DEFAULT_RAID_MAX_IMAGES + 63) / 64)
|
||||
|
||||
struct dso_state {
|
||||
|
@@ -87,7 +87,7 @@ static int _run_command(struct dso_state *state)
|
||||
log_verbose("Executing command: %s", state->cmd_str);
|
||||
|
||||
/* TODO:
|
||||
* Support parallel run of 'task' and it's waitpid maintenance
|
||||
* Support parallel run of 'task' and it's waitpid maintainence
|
||||
* ATM we can't handle signaling of SIGALRM
|
||||
* as signalling is not allowed while 'process_event()' is running
|
||||
*/
|
||||
@@ -245,7 +245,7 @@ void process_event(struct dm_task *dmt,
|
||||
/*
|
||||
* Trigger action when threshold boundary is exceeded.
|
||||
* Report 80% threshold warning when it's used above 80%.
|
||||
* Only 100% is exception as it cannot be surpassed so policy
|
||||
* Only 100% is exception as it cannot be surpased so policy
|
||||
* action is called for: >50%, >55% ... >95%, 100%
|
||||
*/
|
||||
state->metadata_percent = dm_make_percent(tps->used_metadata_blocks, tps->total_metadata_blocks);
|
||||
@@ -379,7 +379,7 @@ int register_device(const char *device,
|
||||
|
||||
state->argv[1] = str + 1; /* 1 argument - vg/lv */
|
||||
_init_thread_signals(state);
|
||||
} else /* Unsupported command format */
|
||||
} else /* Unuspported command format */
|
||||
goto inval;
|
||||
|
||||
state->pid = -1;
|
||||
|
@@ -19,7 +19,7 @@
|
||||
/*
|
||||
* Use parser from new device_mapper library.
|
||||
* Although during compilation we can see dm_vdo_status_parse()
|
||||
* in runtime we are linked against systems libdm 'older' library
|
||||
* in runtime we are linked agains systems libdm 'older' library
|
||||
* which does not provide this symbol and plugin fails to load
|
||||
*/
|
||||
/* coverity[unnecessary_header] used for parsing */
|
||||
@@ -78,7 +78,7 @@ static int _run_command(struct dso_state *state)
|
||||
log_verbose("Executing command: %s", state->cmd_str);
|
||||
|
||||
/* TODO:
|
||||
* Support parallel run of 'task' and it's waitpid maintenance
|
||||
* Support parallel run of 'task' and it's waitpid maintainence
|
||||
* ATM we can't handle signaling of SIGALRM
|
||||
* as signalling is not allowed while 'process_event()' is running
|
||||
*/
|
||||
@@ -227,7 +227,7 @@ void process_event(struct dm_task *dmt,
|
||||
/*
|
||||
* Trigger action when threshold boundary is exceeded.
|
||||
* Report 80% threshold warning when it's used above 80%.
|
||||
* Only 100% is exception as it cannot be surpassed so policy
|
||||
* Only 100% is exception as it cannot be surpased so policy
|
||||
* action is called for: >50%, >55% ... >95%, 100%
|
||||
*/
|
||||
if ((state->percent > WARNING_THRESH) &&
|
||||
@@ -354,7 +354,7 @@ int register_device(const char *device,
|
||||
_init_thread_signals(state);
|
||||
} else if (cmd[0] == 0) {
|
||||
state->name = "volume"; /* What to use with 'others?' */
|
||||
} else/* Unsupported command format */
|
||||
} else/* Unuspported command format */
|
||||
goto inval;
|
||||
|
||||
state->pid = -1;
|
||||
|
@@ -51,14 +51,18 @@ include $(top_builddir)/make.tmpl
|
||||
|
||||
.PHONY: install_lvmdbusd
|
||||
|
||||
all:
|
||||
$(Q) test -x $(LVMDBUSD) || chmod 755 $(LVMDBUSD)
|
||||
|
||||
install_lvmdbusd: $(LVMDBUSD)
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
@echo " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_DIR) $(sbindir)
|
||||
$(Q) $(INSTALL_SCRIPT) $(LVMDBUSD) $(sbindir)
|
||||
$(Q) $(INSTALL_DIR) $(lvmdbusdir) $(lvmdbusdir)/__pycache__
|
||||
$(Q) $(INSTALL_DIR) $(lvmdbusdir)
|
||||
$(Q) (cd $(srcdir); $(INSTALL_DATA) $(LVMDBUS_SRCDIR_FILES) $(lvmdbusdir))
|
||||
$(Q) $(INSTALL_DATA) $(LVMDBUS_BUILDDIR_FILES) $(lvmdbusdir)
|
||||
$(Q) PYTHON=$(PYTHON3) $(PYCOMPILE) --destdir "$(DESTDIR)" --basedir "$(lvmdbuspydir)" $(LVMDBUS_SRCDIR_FILES) $(LVMDBUS_BUILDDIR_FILES)
|
||||
$(Q) $(CHMOD) 755 $(lvmdbusdir)/__pycache__
|
||||
$(Q) $(CHMOD) 444 $(lvmdbusdir)/__pycache__/*.py[co]
|
||||
|
||||
install_lvm2: install_lvmdbusd
|
||||
|
@@ -44,10 +44,10 @@ class AutomatedProperties(dbus.service.Object):
|
||||
|
||||
def set_interface(self, interface):
|
||||
"""
|
||||
With inheritance, we can't easily tell what interfaces a class provides,
|
||||
With inheritance we can't easily tell what interfaces a class provides
|
||||
so we will have each class that implements an interface tell the
|
||||
base AutomatedProperties what it is they do provide. This is kind of
|
||||
clunky, and perhaps we can figure out a better way to do this later.
|
||||
clunky and perhaps we can figure out a better way to do this later.
|
||||
:param interface: An interface the object supports
|
||||
:return:
|
||||
"""
|
||||
|
@@ -62,7 +62,7 @@ def _move_callback(job_state, line_str):
|
||||
def _move_merge(interface_name, command, job_state):
|
||||
# We need to execute these command stand alone by forking & exec'ing
|
||||
# the command always as we will be getting periodic output from them on
|
||||
# the status of the long-running operation.
|
||||
# the status of the long running operation.
|
||||
|
||||
meta = LvmExecutionMeta(time.time(), 0, command)
|
||||
cfg.flightrecorder.add(meta)
|
||||
|
@@ -11,7 +11,6 @@ import os
|
||||
import multiprocessing
|
||||
import queue
|
||||
import itertools
|
||||
from lvmdbusd.utils import LvmDebugData
|
||||
|
||||
from lvmdbusd import path
|
||||
|
||||
@@ -19,10 +18,6 @@ LVM_CMD = os.getenv('LVM_BINARY', path.LVM_BINARY)
|
||||
|
||||
LOCK_FILE = os.getenv("LVM_DBUSD_LOCKFILE", "/var/lock/lvm/lvmdbusd")
|
||||
|
||||
# Save off the debug data needed for lvm team to debug issues
|
||||
# only used for 'fullreport' at this time.
|
||||
lvmdebug = LvmDebugData(os.getenv('LVM_DBUSD_COLLECT_LVM_DEBUG', False))
|
||||
|
||||
# This is the global object manager
|
||||
om = None
|
||||
|
||||
@@ -32,13 +27,13 @@ bus = None
|
||||
# Command line args
|
||||
args = None
|
||||
|
||||
# Set to true if we depend on external events for updates
|
||||
# Set to true if we are depending on external events for updates
|
||||
got_external_event = False
|
||||
|
||||
# Shared state variable across all processes
|
||||
run = multiprocessing.Value('i', 1)
|
||||
|
||||
# If this is set to true, the current setup support lvm shell, and we are
|
||||
# If this is set to true, the current setup support lvm shell and we are
|
||||
# running in that mode of operation
|
||||
SHELL_IN_USE = None
|
||||
|
||||
@@ -50,8 +45,6 @@ worker_q = queue.Queue()
|
||||
# Main event loop
|
||||
loop = None
|
||||
|
||||
G_LOOP_TMO = 0.5
|
||||
|
||||
# Used to instruct the daemon if we should ignore SIGTERM
|
||||
ignore_sigterm = False
|
||||
|
||||
@@ -121,4 +114,7 @@ def exit_daemon():
|
||||
loop.quit()
|
||||
|
||||
|
||||
# Debug data for lvm
|
||||
lvmdebug = None
|
||||
|
||||
systemd = False
|
||||
|
@@ -109,7 +109,7 @@ def call_lvm(command, debug=False, line_cb=None,
|
||||
stdin, CALL MUST EXECUTE QUICKLY and not *block*
|
||||
otherwise call_lvm function will fail to read
|
||||
stdin/stdout. Return value of call back is ignored
|
||||
:param cb_data: Supplied to call back to allow caller access to
|
||||
:param cb_data: Supplied to callback to allow caller access to
|
||||
its own data
|
||||
|
||||
# Callback signature
|
||||
@@ -136,7 +136,7 @@ def call_lvm(command, debug=False, line_cb=None,
|
||||
while True and cfg.run.value != 0:
|
||||
try:
|
||||
rd_fd = [process.stdout.fileno(), process.stderr.fileno()]
|
||||
ready = select.select(rd_fd, [], [], cfg.G_LOOP_TMO)
|
||||
ready = select.select(rd_fd, [], [], 2)
|
||||
|
||||
for r in ready[0]:
|
||||
if r == process.stdout.fileno():
|
||||
@@ -213,7 +213,7 @@ def _shell_cfg():
|
||||
def set_execution(shell):
|
||||
global _t_call
|
||||
with cmd_lock:
|
||||
# If the user requested lvm shell, and we are currently setup that
|
||||
# If the user requested lvm shell and we are currently setup that
|
||||
# way, just return
|
||||
if cfg.SHELL_IN_USE and shell:
|
||||
return True
|
||||
@@ -324,12 +324,10 @@ def vg_rename(vg_uuid, new_name, rename_options):
|
||||
return call(cmd)
|
||||
|
||||
|
||||
def vg_remove(vg_id, remove_options):
|
||||
def vg_remove(vg_name, remove_options):
|
||||
cmd = ['vgremove']
|
||||
cmd.extend(options_to_cli_args(remove_options))
|
||||
cmd.extend(['-f', vg_id])
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=2175220 is preventing us from doing the following
|
||||
# cmd.extend(['-f', "--select", "vg_uuid=%s" % vg_id])
|
||||
cmd.extend(['-f', vg_name])
|
||||
return call(cmd)
|
||||
|
||||
|
||||
@@ -628,18 +626,13 @@ def lvm_full_report_json():
|
||||
|
||||
# We are running the fullreport command, we will ask lvm to output the debug
|
||||
# data, so we can have the required information for lvm to debug the fullreport failures.
|
||||
# Note: this is disabled by default and can be enabled with env. var.
|
||||
# LVM_DBUSD_COLLECT_LVM_DEBUG=True
|
||||
fn = cfg.lvmdebug.setup()
|
||||
if fn is not None:
|
||||
add_config_option(cmd, "--config", "log {level=7 file=%s syslog=0}" % fn)
|
||||
add_config_option(cmd, "--config", "log {level=7 file=%s syslog=0}" % fn)
|
||||
|
||||
rc, out, err = call(cmd)
|
||||
# When we have an exported vg the exit code of lvs or fullreport will be 5
|
||||
if rc == 0 or rc == 5:
|
||||
if type(out) != dict:
|
||||
raise LvmBug("lvm likely returned invalid JSON, lvm exit code = %d, output = %s, err= %s" %
|
||||
(rc, str(out), str(err)))
|
||||
assert(type(out) == dict)
|
||||
return out
|
||||
raise LvmBug("'fullreport' exited with code '%d'" % rc)
|
||||
|
||||
@@ -787,10 +780,6 @@ def activate_deactivate(op, name, activate, control_flags, options):
|
||||
if (1 << 5) & control_flags:
|
||||
cmd.append('--ignoreactivationskip')
|
||||
|
||||
# Shared locking (Cluster)
|
||||
if (1 << 6) & control_flags:
|
||||
op += 's'
|
||||
|
||||
if activate:
|
||||
op += 'y'
|
||||
else:
|
||||
|
@@ -183,9 +183,9 @@ class StateUpdate(object):
|
||||
obj.deferred = False
|
||||
|
||||
if len(queued_requests) == 0 and wait:
|
||||
# Note: If we don't have anything for N seconds we will
|
||||
# Note: If we don't have anything for 2 seconds we will
|
||||
# get a queue.Empty exception raised here
|
||||
queued_requests.append(obj.queue.get(block=True, timeout=cfg.G_LOOP_TMO))
|
||||
queued_requests.append(obj.queue.get(block=True, timeout=2))
|
||||
|
||||
# Ok we have one or the deferred queue has some,
|
||||
# check if any others and grab them too
|
||||
@@ -228,17 +228,8 @@ class StateUpdate(object):
|
||||
self.queue = queue.Queue()
|
||||
self.deferred = False
|
||||
|
||||
# Do initial load, with retries. During error injection testing we can and do fail here.
|
||||
count = 0
|
||||
need_refresh = False # First attempt we are building from new, any subsequent will be true
|
||||
while count < 5:
|
||||
try:
|
||||
load(refresh=need_refresh, emit_signal=False, need_main_thread=False)
|
||||
break
|
||||
except LvmBug as bug:
|
||||
count += 1
|
||||
need_refresh = True
|
||||
log_error("We encountered an lvm bug on initial load, trying again %s" % str(bug))
|
||||
# Do initial load
|
||||
load(refresh=False, emit_signal=False, need_main_thread=False)
|
||||
|
||||
self.thread = threading.Thread(target=StateUpdate.update_thread,
|
||||
args=(self,),
|
||||
|
@@ -44,7 +44,7 @@ class WaitingClient(object):
|
||||
self.timer_id = GLib.timeout_add_seconds(
|
||||
tmo, WaitingClient._timeout, self)
|
||||
|
||||
# The job finished before the timer popped, and we are being notified that
|
||||
# The job finished before the timer popped and we are being notified that
|
||||
# it's done
|
||||
def notify(self):
|
||||
with self.rlock:
|
||||
@@ -71,7 +71,7 @@ class JobState(object):
|
||||
self._stderr = ''
|
||||
self._waiting_clients = []
|
||||
|
||||
# This is a lvm command that is just taking too long and doesn't
|
||||
# This is an lvm command that is just taking too long and doesn't
|
||||
# support background operation
|
||||
if self._request:
|
||||
# Faking the percentage when we don't have one
|
||||
@@ -138,7 +138,7 @@ class JobState(object):
|
||||
# If a waiting client timer pops before the job is done we will allow
|
||||
# the client to remove themselves from the list. As we have a lock
|
||||
# here and a lock in the waiting client too, and they can be obtained
|
||||
# in different orders, a deadlock can occur.
|
||||
# in different orders, a dead lock can occur.
|
||||
# As this remove is really optional, we will try to acquire the lock
|
||||
# and remove. If we are unsuccessful it's not fatal, we just delay
|
||||
# the time when the objects can be garbage collected by python
|
||||
|
@@ -42,7 +42,7 @@ def common(retrieve, o_type, search_keys,
|
||||
existing_paths = cfg.om.object_paths_by_type(o_type)
|
||||
|
||||
for o in objects:
|
||||
# Assume we need to add this one to dbus, unless we are refreshing,
|
||||
# Assume we need to add this one to dbus, unless we are refreshing
|
||||
# and it's already present
|
||||
return_object = True
|
||||
|
||||
|
@@ -25,8 +25,8 @@ from .utils import round_size, mt_remove_dbus_objects, lvm_column_key
|
||||
from .job import JobState
|
||||
|
||||
|
||||
# Try and build a key for a LV, so that we sort the LVs with the least dependencies
|
||||
# first. This may be error-prone because of the flexibility LVM
|
||||
# Try and build a key for a LV, so that we sort the LVs with least dependencies
|
||||
# first. This may be error prone because of the flexibility LVM
|
||||
# provides and what you can stack.
|
||||
def get_key(i):
|
||||
|
||||
@@ -65,13 +65,13 @@ def lvs_state_retrieve(selection, cache_refresh=True):
|
||||
if cache_refresh:
|
||||
cfg.db.refresh()
|
||||
|
||||
try:
|
||||
# When building up the model, it's best to process LVs with the least
|
||||
# dependencies to those that are dependent upon other LVs. Otherwise, when
|
||||
# we are trying to gather information we could be in a position where we
|
||||
# don't have information available yet.
|
||||
lvs = sorted(cfg.db.fetch_lvs(selection), key=get_key)
|
||||
# When building up the model, it's best to process LVs with the least
|
||||
# dependencies to those that are dependant upon other LVs. Otherwise, when
|
||||
# we are trying to gather information we could be in a position where we
|
||||
# don't have information available yet.
|
||||
lvs = sorted(cfg.db.fetch_lvs(selection), key=get_key)
|
||||
|
||||
try:
|
||||
for l in lvs:
|
||||
if cfg.vdo_support:
|
||||
rc.append(LvStateVdo(
|
||||
|
78
daemons/lvmdbusd/lvm_shell_proxy.py.in
Normal file → Executable file
78
daemons/lvmdbusd/lvm_shell_proxy.py.in
Normal file → Executable file
@@ -18,7 +18,6 @@ import pty
|
||||
import sys
|
||||
import tempfile
|
||||
import time
|
||||
import threading
|
||||
import select
|
||||
|
||||
try:
|
||||
@@ -66,7 +65,7 @@ class LVMShellProxy(object):
|
||||
self.parent_stdout_fd,
|
||||
self.report_stream.fileno(),
|
||||
self.parent_stderr_fd]
|
||||
ready = select.select(rd_fd, [], [], cfg.G_LOOP_TMO)
|
||||
ready = select.select(rd_fd, [], [], 2)
|
||||
|
||||
for r in ready[0]:
|
||||
if r == self.parent_stdout_fd:
|
||||
@@ -108,14 +107,11 @@ class LVMShellProxy(object):
|
||||
else:
|
||||
raise LvmBug(
|
||||
"lvm returned no JSON output!")
|
||||
except Exception as e:
|
||||
log_error("While reading from lvm shell we encountered an error %s" % str(e))
|
||||
log_error("stdout= %s\nstderr= %s\n" % (stdout, stderr))
|
||||
if self.lvm_shell.poll() is not None:
|
||||
log_error("Underlying lvm shell process unexpectedly exited: %d" % self.lvm_shell.returncode)
|
||||
else:
|
||||
log_error("Underlying lvm shell process is still present!")
|
||||
raise e
|
||||
|
||||
except IOError as ioe:
|
||||
log_debug(str(ioe))
|
||||
self.exit_shell()
|
||||
raise ioe
|
||||
|
||||
if keep_reading and cfg.run.value == 0:
|
||||
# We didn't complete as we are shutting down
|
||||
@@ -135,10 +131,6 @@ class LVMShellProxy(object):
|
||||
tmp_dir = tempfile.mkdtemp(prefix="lvmdbus_")
|
||||
tmp_file = "%s/lvmdbus_report" % (tmp_dir)
|
||||
|
||||
# Create a lock so that we don't step on each other when we are waiting for a command
|
||||
# to finish and some other request comes in concurrently, like to exit the shell.
|
||||
self.shell_lock = threading.RLock()
|
||||
|
||||
# Create a fifo for the report output
|
||||
os.mkfifo(tmp_file, 0o600)
|
||||
|
||||
@@ -154,8 +146,6 @@ class LVMShellProxy(object):
|
||||
|
||||
# If any env variables contain LVM we will propagate them too
|
||||
for k, v in os.environ.items():
|
||||
if "PATH" in k:
|
||||
local_env[k] = v
|
||||
if "LVM" in k:
|
||||
local_env[k] = v
|
||||
|
||||
@@ -198,8 +188,7 @@ class LVMShellProxy(object):
|
||||
os.unlink(tmp_file)
|
||||
os.rmdir(tmp_dir)
|
||||
|
||||
def _get_last_log(self):
|
||||
# Precondition, lock is held
|
||||
def get_last_log(self):
|
||||
self._write_cmd('lastlog\n')
|
||||
report_json = self._read_response()[1]
|
||||
return get_error_msg(report_json)
|
||||
@@ -220,29 +209,28 @@ class LVMShellProxy(object):
|
||||
cmd += "\n"
|
||||
|
||||
# run the command by writing it to the shell's STDIN
|
||||
with self.shell_lock:
|
||||
self._write_cmd(cmd)
|
||||
self._write_cmd(cmd)
|
||||
|
||||
# read everything from the STDOUT to the next prompt
|
||||
stdout, report_json, stderr = self._read_response()
|
||||
# read everything from the STDOUT to the next prompt
|
||||
stdout, report_json, stderr = self._read_response()
|
||||
|
||||
# Parse the report to see what happened
|
||||
if 'log' in report_json:
|
||||
ret_code = int(report_json['log'][-1:][0]['log_ret_code'])
|
||||
# If we have an exported vg we get a log_ret_code == 5 when
|
||||
# we do a 'fullreport'
|
||||
# Note: 0 == error
|
||||
if (ret_code == 1) or (ret_code == 5 and argv[0] == 'fullreport'):
|
||||
rc = 0
|
||||
else:
|
||||
# Depending on where lvm fails the command, it may not have anything
|
||||
# to report for "lastlog", so we need to check for a message in the
|
||||
# report json too.
|
||||
error_msg = self._get_last_log()
|
||||
# Parse the report to see what happened
|
||||
if 'log' in report_json:
|
||||
ret_code = int(report_json['log'][-1:][0]['log_ret_code'])
|
||||
# If we have an exported vg we get a log_ret_code == 5 when
|
||||
# we do a 'fullreport'
|
||||
# Note: 0 == error
|
||||
if (ret_code == 1) or (ret_code == 5 and argv[0] == 'fullreport'):
|
||||
rc = 0
|
||||
else:
|
||||
# Depending on where lvm fails the command, it may not have anything
|
||||
# to report for "lastlog", so we need to check for a message in the
|
||||
# report json too.
|
||||
error_msg = self.get_last_log()
|
||||
if error_msg is None:
|
||||
error_msg = get_error_msg(report_json)
|
||||
if error_msg is None:
|
||||
error_msg = get_error_msg(report_json)
|
||||
if error_msg is None:
|
||||
error_msg = 'No error reason provided! (missing "log" section)'
|
||||
error_msg = 'No error reason provided! (missing "log" section)'
|
||||
|
||||
if debug or rc != 0:
|
||||
log_error(("CMD= %s" % cmd))
|
||||
@@ -252,14 +240,12 @@ class LVMShellProxy(object):
|
||||
return rc, report_json, error_msg
|
||||
|
||||
def exit_shell(self):
|
||||
with self.shell_lock:
|
||||
try:
|
||||
if self.lvm_shell is not None:
|
||||
self._write_cmd('exit\n')
|
||||
self.lvm_shell.wait(1)
|
||||
self.lvm_shell = None
|
||||
except Exception as _e:
|
||||
log_error("exit_shell: %s" % (str(_e)))
|
||||
try:
|
||||
self._write_cmd('exit\n')
|
||||
self.lvm_shell.wait(1)
|
||||
self.lvm_shell = None
|
||||
except Exception as _e:
|
||||
log_error(str(_e))
|
||||
|
||||
def __del__(self):
|
||||
# Note: When we are shutting down the daemon and the main process has already exited
|
||||
|
@@ -351,7 +351,7 @@ class DataStore(object):
|
||||
else:
|
||||
rc = []
|
||||
for s in pv_name:
|
||||
# The user could be using a symlink instead of the actual
|
||||
# Ths user could be using a symlink instead of the actual
|
||||
# block device, make sure we are using actual block device file
|
||||
# if the pv name isn't in the lookup
|
||||
if s not in self.pv_path_to_uuid:
|
||||
@@ -437,8 +437,6 @@ class DataStore(object):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ["LC_ALL"] = "C"
|
||||
os.environ["LVM_COMMAND_PROFILE"] = "lvmdbusd"
|
||||
pp = prettyprint.PrettyPrinter(indent=4)
|
||||
|
||||
ds = DataStore()
|
||||
|
@@ -41,7 +41,7 @@ def process_request():
|
||||
while cfg.run.value != 0:
|
||||
# noinspection PyBroadException
|
||||
try:
|
||||
req = cfg.worker_q.get(True, cfg.G_LOOP_TMO)
|
||||
req = cfg.worker_q.get(True, 5)
|
||||
log_debug(
|
||||
"Method start: %s with args %s (callback = %s)" %
|
||||
(str(req.method), str(req.arguments), str(req.cb)))
|
||||
@@ -67,7 +67,7 @@ def check_fr_size(value):
|
||||
|
||||
def install_signal_handlers():
|
||||
# Because of the glib main loop stuff the python signal handler code is
|
||||
# apparently not usable, and we need to use the glib calls instead
|
||||
# apparently not usable and we need to use the glib calls instead
|
||||
signal_add = None
|
||||
|
||||
if hasattr(GLib, 'unix_signal_add'):
|
||||
@@ -133,7 +133,7 @@ def process_args():
|
||||
|
||||
def running_under_systemd():
|
||||
""""
|
||||
Checks to see if we are running under systemd, by checking daemon fd 0, 1
|
||||
Checks to see if we are running under systemd, by checking damon fd 0, 1
|
||||
systemd sets stdin to /dev/null and 1 & 2 are a socket
|
||||
"""
|
||||
base = "/proc/self/fd"
|
||||
@@ -154,6 +154,10 @@ def main():
|
||||
os.environ["LC_ALL"] = "C"
|
||||
os.environ["LVM_COMMAND_PROFILE"] = "lvmdbusd"
|
||||
|
||||
# Save off the debug data needed for lvm team to debug issues
|
||||
# only used for 'fullreport' at this time.
|
||||
cfg.lvmdebug = utils.LvmDebugData()
|
||||
|
||||
# Indicator if we are running under systemd
|
||||
cfg.systemd = running_under_systemd()
|
||||
|
||||
@@ -204,7 +208,7 @@ def main():
|
||||
thread_list.append(
|
||||
threading.Thread(target=process_request, name='process_request'))
|
||||
|
||||
# Have a single thread handling updating lvm and the dbus model, so we
|
||||
# Have a single thread handling updating lvm and the dbus model so we
|
||||
# don't have multiple threads doing this as the same time
|
||||
updater = StateUpdate()
|
||||
thread_list.append(updater.thread)
|
||||
@@ -214,7 +218,7 @@ def main():
|
||||
cfg.loop = GLib.MainLoop()
|
||||
|
||||
for thread in thread_list:
|
||||
thread.daemon = True
|
||||
thread.damon = True
|
||||
thread.start()
|
||||
|
||||
# In all cases we are going to monitor for udev until we get an
|
||||
|
@@ -13,7 +13,7 @@ import dbus
|
||||
import os
|
||||
import copy
|
||||
from . import cfg
|
||||
from .utils import log_debug, log_error, extract_stack_trace
|
||||
from .utils import log_debug, pv_obj_path_generate, log_error, extract_stack_trace
|
||||
from .automatedproperties import AutomatedProperties
|
||||
|
||||
|
||||
@@ -159,8 +159,8 @@ class ObjectManager(AutomatedProperties):
|
||||
# print('Registering object path %s for %s' %
|
||||
# (path, dbus_object.lvm_id))
|
||||
|
||||
# We want fast access to the object by a number of different ways,
|
||||
# so we use multiple hashes with different keys
|
||||
# We want fast access to the object by a number of different ways
|
||||
# so we use multiple hashs with different keys
|
||||
self._lookup_add(dbus_object, path, dbus_object.lvm_id,
|
||||
dbus_object.Uuid)
|
||||
|
||||
@@ -209,7 +209,7 @@ class ObjectManager(AutomatedProperties):
|
||||
|
||||
def get_object_by_lvm_id(self, lvm_id):
|
||||
"""
|
||||
Given a lvm identifier, return the object registered for it
|
||||
Given an lvm identifier, return the object registered for it
|
||||
:param lvm_id: The lvm identifier
|
||||
"""
|
||||
with self.rlock:
|
||||
@@ -220,7 +220,7 @@ class ObjectManager(AutomatedProperties):
|
||||
|
||||
def get_object_path_by_lvm_id(self, lvm_id):
|
||||
"""
|
||||
Given a lvm identifier, return the object path for it
|
||||
Given an lvm identifier, return the object path for it
|
||||
:param lvm_id: The lvm identifier
|
||||
:return: Object path or '/' if not found
|
||||
"""
|
||||
@@ -295,7 +295,7 @@ class ObjectManager(AutomatedProperties):
|
||||
if uuid == lvm_id:
|
||||
path = self._id_lookup(lvm_id)
|
||||
else:
|
||||
# We have an uuid and a lvm_id we can do sanity checks to ensure
|
||||
# We have a uuid and a lvm_id we can do sanity checks to ensure
|
||||
# that they are consistent
|
||||
|
||||
# If a PV is missing its device path is '[unknown]' or some
|
||||
@@ -305,7 +305,7 @@ class ObjectManager(AutomatedProperties):
|
||||
if cfg.db.pv_missing(uuid):
|
||||
lvm_id = None
|
||||
|
||||
# Let's check for the uuid first
|
||||
# Lets check for the uuid first
|
||||
path = self._id_lookup(uuid)
|
||||
if path:
|
||||
# Ensure table lookups are correct
|
||||
|
@@ -141,7 +141,7 @@ class RequestEntry(object):
|
||||
|
||||
mt_async_call(self.cb_error, error_exception)
|
||||
else:
|
||||
# We have a job, and it's complete, indicate that it's done.
|
||||
# We have a job and it's complete, indicate that it's done.
|
||||
self._job.Complete = True
|
||||
self._job = None
|
||||
|
||||
|
@@ -11,6 +11,7 @@ import xml.etree.ElementTree as Et
|
||||
import sys
|
||||
import inspect
|
||||
import collections
|
||||
import ctypes
|
||||
import errno
|
||||
import fcntl
|
||||
import os
|
||||
@@ -89,7 +90,7 @@ def init_class_from_arguments(
|
||||
nt = k
|
||||
|
||||
# If the current attribute has a value, but the incoming does
|
||||
# not, don't overwrite it. Otherwise, the default values on the
|
||||
# not, don't overwrite it. Otherwise the default values on the
|
||||
# property decorator don't work as expected.
|
||||
cur = getattr(obj_instance, nt, v)
|
||||
|
||||
@@ -109,7 +110,7 @@ def init_class_from_arguments(
|
||||
|
||||
def get_properties(f):
|
||||
"""
|
||||
Walks through an object instance, or it's parent class(es) and determines
|
||||
Walks through an object instance or it's parent class(es) and determines
|
||||
which attributes are properties and if they were created to be used for
|
||||
dbus.
|
||||
:param f: Object to inspect
|
||||
@@ -193,7 +194,7 @@ def add_properties(xml, interface, props):
|
||||
interface_element = c
|
||||
break
|
||||
|
||||
# Interface is not present, lets create it, so we have something to
|
||||
# Interface is not present, lets create it so we have something to
|
||||
# attach the properties too
|
||||
if interface_element is None:
|
||||
interface_element = Et.Element("interface", name=interface)
|
||||
@@ -304,16 +305,8 @@ class DebugMessages(object):
|
||||
self.queue.clear()
|
||||
|
||||
|
||||
def _get_tid():
|
||||
try:
|
||||
# Only 3.8 and later have this
|
||||
return threading.get_native_id()
|
||||
except:
|
||||
return -1
|
||||
|
||||
|
||||
def _format_log_entry(msg):
|
||||
tid = _get_tid()
|
||||
tid = ctypes.CDLL('libc.so.6').syscall(186)
|
||||
|
||||
if not cfg.systemd and STDOUT_TTY:
|
||||
msg = "%s: %d:%d - %s" % \
|
||||
@@ -330,17 +323,16 @@ def _format_log_entry(msg):
|
||||
|
||||
|
||||
def _common_log(msg, *attributes):
|
||||
msg = _format_log_entry(msg)
|
||||
|
||||
cfg.stdout_lock.acquire()
|
||||
msg = _format_log_entry(msg)
|
||||
|
||||
if STDOUT_TTY and attributes:
|
||||
print(color(msg, *attributes))
|
||||
else:
|
||||
print(msg)
|
||||
|
||||
sys.stdout.flush()
|
||||
cfg.stdout_lock.release()
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
# Serializes access to stdout to prevent interleaved output
|
||||
@@ -543,7 +535,7 @@ def round_size(size_bytes):
|
||||
return size_bytes + bs - remainder
|
||||
|
||||
|
||||
_ALLOWABLE_CH = string.ascii_letters + string.digits + '#+-.:=@_/%'
|
||||
_ALLOWABLE_CH = string.ascii_letters + string.digits + '#+-.:=@_\/%'
|
||||
_ALLOWABLE_CH_SET = set(_ALLOWABLE_CH)
|
||||
|
||||
_ALLOWABLE_VG_LV_CH = string.ascii_letters + string.digits + '.-_+'
|
||||
@@ -778,7 +770,6 @@ class LockFile(object):
|
||||
|
||||
def __enter__(self):
|
||||
try:
|
||||
os.makedirs(os.path.dirname(self.lock_file), exist_ok=True)
|
||||
self.fd = os.open(self.lock_file, os.O_CREAT | os.O_RDWR, stat.S_IRUSR | stat.S_IWUSR)
|
||||
|
||||
# Get and set the close on exec and lock the file
|
||||
@@ -828,12 +819,9 @@ class LvmBug(RuntimeError):
|
||||
|
||||
|
||||
class LvmDebugData:
|
||||
def __init__(self, do_collection):
|
||||
def __init__(self):
|
||||
self.fd = -1
|
||||
self.fn = None
|
||||
self.collect = do_collection
|
||||
if self.collect:
|
||||
log_msg("Collecting lvm debug data!")
|
||||
|
||||
def _remove_file(self):
|
||||
if self.fn is not None:
|
||||
@@ -847,10 +835,8 @@ class LvmDebugData:
|
||||
|
||||
def setup(self):
|
||||
# Create a secure filename
|
||||
if self.collect:
|
||||
self.fd, self.fn = tempfile.mkstemp(suffix=".log", prefix="lvmdbusd.lvm.debug.")
|
||||
return self.fn
|
||||
return None
|
||||
self.fd, self.fn = tempfile.mkstemp(suffix=".log", prefix="lvmdbusd.lvm.debug.")
|
||||
return self.fn
|
||||
|
||||
def lvm_complete(self):
|
||||
# Remove the file ASAP, so we decrease our odds of leaving it
|
||||
|
@@ -151,7 +151,6 @@ class Vg(AutomatedProperties):
|
||||
_AllocNormal_meta = ('b', VG_INTERFACE)
|
||||
_AllocAnywhere_meta = ('b', VG_INTERFACE)
|
||||
_Clustered_meta = ('b', VG_INTERFACE)
|
||||
_Shared_meta = ('b', VG_INTERFACE)
|
||||
_Name_meta = ('s', VG_INTERFACE)
|
||||
|
||||
# noinspection PyUnusedLocal,PyPep8Naming
|
||||
@@ -786,10 +785,6 @@ class Vg(AutomatedProperties):
|
||||
def Clustered(self):
|
||||
return self._attribute(5, 'c')
|
||||
|
||||
@property
|
||||
def Shared(self):
|
||||
return self._attribute(5, 's')
|
||||
|
||||
|
||||
class VgVdo(Vg):
|
||||
|
||||
|
@@ -15,61 +15,61 @@ srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
USE_SD_NOTIFY=yes
|
||||
|
||||
SOURCES = lvmlockd-core.c
|
||||
SOURCES2 = lvmlockctl.c
|
||||
|
||||
TARGETS = lvmlockd lvmlockctl
|
||||
|
||||
include $(top_builddir)/make.tmpl
|
||||
|
||||
ifeq ("@BUILD_LOCKDSANLOCK@", "yes")
|
||||
SOURCES += lvmlockd-sanlock.c
|
||||
CFLAGS += $(LIBSANLOCKCLIENT_CFLAGS)
|
||||
LOCK_LIBS += $(LIBSANLOCKCLIENT_LIBS)
|
||||
LOCK_LIBS += -lsanlock_client
|
||||
endif
|
||||
|
||||
ifeq ("@BUILD_LOCKDDLM@", "yes")
|
||||
SOURCES += lvmlockd-dlm.c
|
||||
CFLAGS += $(LIBDLM) $(LIBDLMCONTROL_CFLAGS)
|
||||
# LOCK_LIBS += $(LIBDLM_LIBS) $(LIBDLMCONTROL_LIBS)
|
||||
LOCK_LIBS += -ldlm_lt $(LIBDLMCONTROL_LIBS)
|
||||
LOCK_LIBS += -ldlm_lt
|
||||
LOCK_LIBS += -ldlmcontrol
|
||||
endif
|
||||
|
||||
ifeq ("@BUILD_LOCKDIDM@", "yes")
|
||||
SOURCES += lvmlockd-idm.c
|
||||
LOCK_LIBS += $(LIBSEAGATEILM_LIBS) $(BLKID_LIBS)
|
||||
LOCK_LIBS += -lseagate_ilm -lblkid
|
||||
endif
|
||||
|
||||
SOURCES2 = lvmlockctl.c
|
||||
|
||||
TARGETS = lvmlockd lvmlockctl
|
||||
|
||||
CFLOW_SOURCES = $(addprefix $(srcdir)/, $(SOURCES))
|
||||
CFLOW_TARGET = lvmlockd
|
||||
|
||||
.PHONY: install_lvmlockd install_lvmlockctl
|
||||
|
||||
include $(top_builddir)/make.tmpl
|
||||
|
||||
CFLAGS += $(EXTRA_EXEC_CFLAGS)
|
||||
INCLUDES += -I$(top_srcdir)/libdaemon/server
|
||||
LDFLAGS += -L$(top_builddir)/libdaemon/server $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS)
|
||||
LIBS += $(DAEMON_LIBS) $(PTHREAD_LIBS)
|
||||
|
||||
ifneq (,$(firstword $(LIBSYSTEMD_LIBS)))
|
||||
DEFS += -DUSE_SD_NOTIFY
|
||||
CFLAGS += $(LIBSYSTEMD_CFLAGS)
|
||||
LIBS += $(LIBSYSTEMD_LIBS)
|
||||
ifeq ($(USE_SD_NOTIFY),yes)
|
||||
CFLAGS += $(shell pkg-config --cflags libsystemd) -DUSE_SD_NOTIFY
|
||||
LIBS += $(shell pkg-config --libs libsystemd)
|
||||
endif
|
||||
|
||||
lvmlockd: $(OBJECTS) $(top_builddir)/libdaemon/server/libdaemonserver.a $(INTERNAL_LIBS)
|
||||
$(SHOW) " [CC] $@"
|
||||
@echo " [CC] $@"
|
||||
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(LOCK_LIBS) $(LIBS)
|
||||
|
||||
lvmlockctl: lvmlockctl.o $(INTERNAL_LIBS)
|
||||
$(SHOW) " [CC] $@"
|
||||
@echo " [CC] $@"
|
||||
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS)
|
||||
|
||||
install_lvmlockd: lvmlockd
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
@echo " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
|
||||
|
||||
install_lvmlockctl: lvmlockctl
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
@echo " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
|
||||
|
||||
install_lvm2: install_lvmlockd install_lvmlockctl
|
||||
|
@@ -38,7 +38,7 @@ static int stop_lockspaces = 0;
|
||||
static char *arg_vg_name = NULL;
|
||||
|
||||
#define DUMP_SOCKET_NAME "lvmlockd-dump.sock"
|
||||
#define DUMP_BUF_SIZE (4 * 1024 * 1024)
|
||||
#define DUMP_BUF_SIZE (1024 * 1024)
|
||||
static char dump_buf[DUMP_BUF_SIZE+1];
|
||||
static int dump_len;
|
||||
static struct sockaddr_un dump_addr;
|
||||
@@ -264,19 +264,19 @@ static void format_info_r_action(char *line, char *r_name, char *r_type)
|
||||
|
||||
static void format_info_line(char *line, char *r_name, char *r_type)
|
||||
{
|
||||
if (!strncmp(line, "info=structs ", sizeof("info=structs ") - 1)) {
|
||||
if (!strncmp(line, "info=structs ", strlen("info=structs "))) {
|
||||
/* only print this in the raw info dump */
|
||||
|
||||
} else if (!strncmp(line, "info=client ", sizeof("info=client ") - 1)) {
|
||||
} else if (!strncmp(line, "info=client ", strlen("info=client "))) {
|
||||
save_client_info(line);
|
||||
|
||||
} else if (!strncmp(line, "info=ls ", sizeof("info=ls ") - 1)) {
|
||||
} else if (!strncmp(line, "info=ls ", strlen("info=ls "))) {
|
||||
format_info_ls(line);
|
||||
|
||||
} else if (!strncmp(line, "info=ls_action ", sizeof("info=ls_action ") - 1)) {
|
||||
} else if (!strncmp(line, "info=ls_action ", strlen("info=ls_action "))) {
|
||||
format_info_ls_action(line);
|
||||
|
||||
} else if (!strncmp(line, "info=r ", sizeof("info=r ") - 1)) {
|
||||
} else if (!strncmp(line, "info=r ", strlen("info=r "))) {
|
||||
/*
|
||||
* r_name/r_type are reset when a new resource is found.
|
||||
* They are reused for the lock and action lines that
|
||||
@@ -286,11 +286,11 @@ static void format_info_line(char *line, char *r_name, char *r_type)
|
||||
memset(r_type, 0, MAX_NAME+1);
|
||||
format_info_r(line, r_name, r_type);
|
||||
|
||||
} else if (!strncmp(line, "info=lk ", sizeof("info=lk ") - 1)) {
|
||||
} else if (!strncmp(line, "info=lk ", strlen("info=lk "))) {
|
||||
/* will use info from previous r */
|
||||
format_info_lk(line, r_name, r_type);
|
||||
|
||||
} else if (!strncmp(line, "info=r_action ", sizeof("info=r_action ") - 1)) {
|
||||
} else if (!strncmp(line, "info=r_action ", strlen("info=r_action "))) {
|
||||
/* will use info from previous r */
|
||||
format_info_r_action(line, r_name, r_type);
|
||||
} else {
|
||||
@@ -940,7 +940,7 @@ static int read_options(int argc, char *argv[])
|
||||
int option_index = 0;
|
||||
int c;
|
||||
|
||||
static const struct option _long_options[] = {
|
||||
static struct option long_options[] = {
|
||||
{"help", no_argument, 0, 'h' },
|
||||
{"quit", no_argument, 0, 'q' },
|
||||
{"info", no_argument, 0, 'i' },
|
||||
@@ -962,7 +962,7 @@ static int read_options(int argc, char *argv[])
|
||||
}
|
||||
|
||||
while (1) {
|
||||
c = getopt_long(argc, argv, "hqidE:D:w:k:r:Se", _long_options, &option_index);
|
||||
c = getopt_long(argc, argv, "hqidE:D:w:k:r:Se", long_options, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
|
||||
|
@@ -16,12 +16,9 @@
|
||||
#define LVMLOCKD_SOCKET DEFAULT_RUN_DIR "/lvmlockd.socket"
|
||||
#define LVMLOCKD_ADOPT_FILE DEFAULT_RUN_DIR "/lvmlockd.adopt"
|
||||
|
||||
#define LVMLOCKD_USE_SANLOCK_LVB 0
|
||||
|
||||
/* Wrappers to open/close connection */
|
||||
|
||||
static inline __attribute__((always_inline))
|
||||
daemon_handle lvmlockd_open(const char *sock)
|
||||
static inline daemon_handle lvmlockd_open(const char *sock)
|
||||
{
|
||||
daemon_info lvmlockd_info = {
|
||||
.path = "lvmlockd",
|
||||
@@ -54,8 +51,5 @@ static inline void lvmlockd_close(daemon_handle h)
|
||||
#define EREMOVED 219
|
||||
#define EDEVOPEN 220 /* sanlock failed to open lvmlock LV */
|
||||
#define ELMERR 221
|
||||
#define EORPHAN 222
|
||||
#define EADOPT_NONE 223
|
||||
#define EADOPT_RETRY 224
|
||||
|
||||
#endif /* _LVM_LVMLOCKD_CLIENT_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -96,6 +96,7 @@ static int check_args_version(char *vg_args)
|
||||
|
||||
static int read_cluster_name(char *clustername)
|
||||
{
|
||||
static const char close_error_msg[] = "read_cluster_name: close_error %d";
|
||||
char *n;
|
||||
int fd;
|
||||
int rv;
|
||||
@@ -114,19 +115,18 @@ static int read_cluster_name(char *clustername)
|
||||
rv = read(fd, clustername, MAX_ARGS);
|
||||
if (rv < 0) {
|
||||
log_error("read_cluster_name: cluster name read error %d, check dlm_controld", fd);
|
||||
goto out;
|
||||
if (close(fd))
|
||||
log_error(close_error_msg, fd);
|
||||
return rv;
|
||||
}
|
||||
clustername[rv] = 0;
|
||||
|
||||
n = strstr(clustername, "\n");
|
||||
if (n)
|
||||
*n = '\0';
|
||||
rv = 0;
|
||||
out:
|
||||
if (close(fd))
|
||||
log_error("read_cluster_name: close_error %d", fd);
|
||||
|
||||
return rv;
|
||||
log_error(close_error_msg, fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define MAX_VERSION 16
|
||||
@@ -226,14 +226,13 @@ static int get_local_nodeid(void)
|
||||
{
|
||||
struct dirent *de;
|
||||
DIR *ls_dir;
|
||||
char ls_comms_path[PATH_MAX] = { 0 };
|
||||
char path[PATH_MAX] = { 0 };
|
||||
FILE *file;
|
||||
char ls_comms_path[PATH_MAX];
|
||||
FILE *file = NULL;
|
||||
char line[LOCK_LINE_MAX];
|
||||
char *str1, *str2;
|
||||
int rv = -1, val;
|
||||
|
||||
snprintf(ls_comms_path, sizeof(ls_comms_path), "%s", DLM_COMMS_PATH);
|
||||
memset(ls_comms_path, 0, sizeof(ls_comms_path));
|
||||
snprintf(ls_comms_path, PATH_MAX, "%s",DLM_COMMS_PATH);
|
||||
|
||||
if (!(ls_dir = opendir(ls_comms_path)))
|
||||
return -ECONNREFUSED;
|
||||
@@ -241,41 +240,37 @@ static int get_local_nodeid(void)
|
||||
while ((de = readdir(ls_dir))) {
|
||||
if (de->d_name[0] == '.')
|
||||
continue;
|
||||
|
||||
snprintf(path, sizeof(path), "%s/%s/local",
|
||||
DLM_COMMS_PATH, de->d_name);
|
||||
|
||||
if (!(file = fopen(ls_comms_path, "r")))
|
||||
memset(ls_comms_path, 0, sizeof(ls_comms_path));
|
||||
snprintf(ls_comms_path, PATH_MAX, "%s/%s/local",
|
||||
DLM_COMMS_PATH, de->d_name);
|
||||
file = fopen(ls_comms_path, "r");
|
||||
if (!file)
|
||||
continue;
|
||||
str1 = fgets(line, sizeof(line), file);
|
||||
if (fclose(file))
|
||||
log_sys_debug("fclose", path);
|
||||
if (str1) {
|
||||
if (fgets(line, LOCK_LINE_MAX, file)) {
|
||||
fclose(file);
|
||||
rv = sscanf(line, "%d", &val);
|
||||
if ((rv == 1) && (val == 1 )) {
|
||||
snprintf(path, sizeof(path), "%s/%s/nodeid",
|
||||
DLM_COMMS_PATH, de->d_name);
|
||||
|
||||
if (!(file = fopen(path, "r")))
|
||||
memset(ls_comms_path, 0, sizeof(ls_comms_path));
|
||||
snprintf(ls_comms_path, PATH_MAX, "%s/%s/nodeid",
|
||||
DLM_COMMS_PATH, de->d_name);
|
||||
file = fopen(ls_comms_path, "r");
|
||||
if (!file)
|
||||
continue;
|
||||
str2 = fgets(line, sizeof(line), file);
|
||||
if (fclose(file))
|
||||
log_sys_debug("fclose", path);
|
||||
if (str2) {
|
||||
if (fgets(line, LOCK_LINE_MAX, file)) {
|
||||
rv = sscanf(line, "%d", &val);
|
||||
if (rv == 1) {
|
||||
if (closedir(ls_dir))
|
||||
log_sys_debug("closedir", ls_comms_path);
|
||||
fclose(file);
|
||||
closedir(ls_dir);
|
||||
return val;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
if (closedir(ls_dir))
|
||||
log_sys_debug("closedir", ls_comms_path);
|
||||
|
||||
log_error("get_local_nodeid closedir error");
|
||||
return rv;
|
||||
}
|
||||
|
||||
@@ -305,27 +300,20 @@ fail:
|
||||
return rv;
|
||||
}
|
||||
|
||||
int lm_add_lockspace_dlm(struct lockspace *ls, int adopt_only, int adopt_ok)
|
||||
int lm_add_lockspace_dlm(struct lockspace *ls, int adopt)
|
||||
{
|
||||
struct lm_dlm *lmd = (struct lm_dlm *)ls->lm_data;
|
||||
|
||||
if (daemon_test)
|
||||
return 0;
|
||||
|
||||
if (adopt_only || adopt_ok) {
|
||||
if (adopt)
|
||||
lmd->dh = dlm_open_lockspace(ls->name);
|
||||
if (!lmd->dh && adopt_ok)
|
||||
lmd->dh = dlm_new_lockspace(ls->name, 0600, DLM_LSFL_NEWEXCL);
|
||||
if (!lmd->dh)
|
||||
log_error("add_lockspace_dlm adopt_only %d adopt_ok %d %s error",
|
||||
adopt_only, adopt_ok, ls->name);
|
||||
} else {
|
||||
else
|
||||
lmd->dh = dlm_new_lockspace(ls->name, 0600, DLM_LSFL_NEWEXCL);
|
||||
if (!lmd->dh)
|
||||
log_error("add_lockspace_dlm %s error", ls->name);
|
||||
}
|
||||
|
||||
if (!lmd->dh) {
|
||||
log_error("add_lockspace_dlm %s adopt %d error", ls->name, adopt);
|
||||
free(lmd);
|
||||
ls->lm_data = NULL;
|
||||
return -1;
|
||||
@@ -393,7 +381,7 @@ static int lm_add_resource_dlm(struct lockspace *ls, struct resource *r, int wit
|
||||
r->name, strlen(r->name),
|
||||
0, NULL, NULL, NULL);
|
||||
if (rv < 0) {
|
||||
log_error("%s:%s add_resource_dlm lock error %d", ls->name, r->name, rv);
|
||||
log_error("S %s R %s add_resource_dlm lock error %d", ls->name, r->name, rv);
|
||||
return rv;
|
||||
}
|
||||
out:
|
||||
@@ -417,7 +405,7 @@ int lm_rem_resource_dlm(struct lockspace *ls, struct resource *r)
|
||||
|
||||
rv = dlm_ls_unlock_wait(lmd->dh, lksb->sb_lkid, 0, lksb);
|
||||
if (rv < 0) {
|
||||
log_error("%s:%s rem_resource_dlm unlock error %d", ls->name, r->name, rv);
|
||||
log_error("S %s R %s rem_resource_dlm unlock error %d", ls->name, r->name, rv);
|
||||
}
|
||||
out:
|
||||
free(rdd->vb);
|
||||
@@ -472,7 +460,7 @@ static int lm_adopt_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
goto fail;
|
||||
}
|
||||
|
||||
log_debug("%s:%s adopt_dlm", ls->name, r->name);
|
||||
log_debug("S %s R %s adopt_dlm", ls->name, r->name);
|
||||
|
||||
if (daemon_test)
|
||||
return 0;
|
||||
@@ -481,29 +469,29 @@ static int lm_adopt_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
* dlm returns 0 for success, -EAGAIN if an orphan is
|
||||
* found with another mode, and -ENOENT if no orphan.
|
||||
*
|
||||
* cast/bast/param are (void (*)(void*))1 because the kernel
|
||||
* cast/bast/param are (void *)1 because the kernel
|
||||
* returns errors if some are null.
|
||||
*/
|
||||
|
||||
rv = dlm_ls_lockx(lmd->dh, mode, lksb, flags,
|
||||
r->name, strlen(r->name), 0,
|
||||
(void (*)(void*))1, (void (*)(void*))1, (void (*)(void*))1,
|
||||
(void *)1, (void *)1, (void *)1,
|
||||
NULL, NULL);
|
||||
|
||||
if (rv == -1 && (errno == EAGAIN)) {
|
||||
log_debug("%s:%s adopt_dlm adopt mode %d try other mode",
|
||||
log_debug("S %s R %s adopt_dlm adopt mode %d try other mode",
|
||||
ls->name, r->name, ld_mode);
|
||||
rv = -EADOPT_RETRY;
|
||||
rv = -EUCLEAN;
|
||||
goto fail;
|
||||
}
|
||||
if (rv == -1 && (errno == ENOENT)) {
|
||||
log_debug("%s:%s adopt_dlm adopt mode %d no lock",
|
||||
log_debug("S %s R %s adopt_dlm adopt mode %d no lock",
|
||||
ls->name, r->name, ld_mode);
|
||||
rv = -EADOPT_NONE;
|
||||
rv = -ENOENT;
|
||||
goto fail;
|
||||
}
|
||||
if (rv < 0) {
|
||||
log_debug("%s:%s adopt_dlm mode %d flags %x error %d errno %d",
|
||||
log_debug("S %s R %s adopt_dlm mode %d flags %x error %d errno %d",
|
||||
ls->name, r->name, mode, flags, rv, errno);
|
||||
goto fail;
|
||||
}
|
||||
@@ -533,7 +521,7 @@ static int lm_adopt_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
*/
|
||||
|
||||
int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, int adopt_only, int adopt_ok)
|
||||
struct val_blk *vb_out, int adopt)
|
||||
{
|
||||
struct lm_dlm *lmd = (struct lm_dlm *)ls->lm_data;
|
||||
struct rd_dlm *rdd = (struct rd_dlm *)r->lm_data;
|
||||
@@ -543,13 +531,7 @@ int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
int mode;
|
||||
int rv;
|
||||
|
||||
if (adopt_ok) {
|
||||
log_debug("%s:%s lock_dlm adopt_ok not supported", ls->name, r->name);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (adopt_only) {
|
||||
log_debug("%s:%s lock_dlm adopt_only", ls->name, r->name);
|
||||
if (adopt) {
|
||||
/* When adopting, we don't follow the normal method
|
||||
of acquiring a NL lock then converting it to the
|
||||
desired mode. */
|
||||
@@ -578,7 +560,7 @@ int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
log_debug("%s:%s lock_dlm", ls->name, r->name);
|
||||
log_debug("S %s R %s lock_dlm", ls->name, r->name);
|
||||
|
||||
if (daemon_test) {
|
||||
if (rdd->vb) {
|
||||
@@ -598,7 +580,7 @@ int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
r->name, strlen(r->name),
|
||||
0, NULL, NULL, NULL);
|
||||
if (rv == -1) {
|
||||
log_debug("%s:%s lock_dlm acquire mode PR for %d rv %d",
|
||||
log_debug("S %s R %s lock_dlm acquire mode PR for %d rv %d",
|
||||
ls->name, r->name, mode, rv);
|
||||
goto lockrv;
|
||||
}
|
||||
@@ -611,17 +593,17 @@ int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
0, NULL, NULL, NULL);
|
||||
lockrv:
|
||||
if (rv == -1 && errno == EAGAIN) {
|
||||
log_debug("%s:%s lock_dlm acquire mode %d rv EAGAIN", ls->name, r->name, mode);
|
||||
log_debug("S %s R %s lock_dlm acquire mode %d rv EAGAIN", ls->name, r->name, mode);
|
||||
return -EAGAIN;
|
||||
}
|
||||
if (rv < 0) {
|
||||
log_error("%s:%s lock_dlm acquire error %d errno %d", ls->name, r->name, rv, errno);
|
||||
log_error("S %s R %s lock_dlm acquire error %d errno %d", ls->name, r->name, rv, errno);
|
||||
return -ELMERR;
|
||||
}
|
||||
|
||||
if (rdd->vb) {
|
||||
if (lksb->sb_flags & DLM_SBF_VALNOTVALID) {
|
||||
log_debug("%s:%s lock_dlm VALNOTVALID", ls->name, r->name);
|
||||
log_debug("S %s R %s lock_dlm VALNOTVALID", ls->name, r->name);
|
||||
memset(rdd->vb, 0, sizeof(struct val_blk));
|
||||
memset(vb_out, 0, sizeof(struct val_blk));
|
||||
goto out;
|
||||
@@ -650,11 +632,11 @@ int lm_convert_dlm(struct lockspace *ls, struct resource *r,
|
||||
struct lm_dlm *lmd = (struct lm_dlm *)ls->lm_data;
|
||||
struct rd_dlm *rdd = (struct rd_dlm *)r->lm_data;
|
||||
struct dlm_lksb *lksb = &rdd->lksb;
|
||||
int mode;
|
||||
uint32_t mode;
|
||||
uint32_t flags = 0;
|
||||
int rv;
|
||||
|
||||
log_debug("%s:%s convert_dlm", ls->name, r->name);
|
||||
log_debug("S %s R %s convert_dlm", ls->name, r->name);
|
||||
|
||||
flags |= LKF_CONVERT;
|
||||
flags |= LKF_NOQUEUE;
|
||||
@@ -668,16 +650,14 @@ int lm_convert_dlm(struct lockspace *ls, struct resource *r,
|
||||
rdd->vb->r_version = cpu_to_le32(r_version);
|
||||
memcpy(lksb->sb_lvbptr, rdd->vb, sizeof(struct val_blk));
|
||||
|
||||
log_debug("%s:%s convert_dlm set r_version %u",
|
||||
log_debug("S %s R %s convert_dlm set r_version %u",
|
||||
ls->name, r->name, r_version);
|
||||
|
||||
flags |= LKF_VALBLK;
|
||||
}
|
||||
|
||||
if ((mode = to_dlm_mode(ld_mode)) < 0) {
|
||||
log_error("lm_convert_dlm invalid mode %d", ld_mode);
|
||||
return -EINVAL;
|
||||
}
|
||||
mode = to_dlm_mode(ld_mode);
|
||||
|
||||
if (daemon_test)
|
||||
return 0;
|
||||
|
||||
@@ -686,11 +666,11 @@ int lm_convert_dlm(struct lockspace *ls, struct resource *r,
|
||||
0, NULL, NULL, NULL);
|
||||
if (rv == -1 && errno == EAGAIN) {
|
||||
/* FIXME: When does this happen? Should something different be done? */
|
||||
log_error("%s:%s convert_dlm mode %d rv EAGAIN", ls->name, r->name, mode);
|
||||
log_error("S %s R %s convert_dlm mode %d rv EAGAIN", ls->name, r->name, mode);
|
||||
return -EAGAIN;
|
||||
}
|
||||
if (rv < 0) {
|
||||
log_error("%s:%s convert_dlm error %d", ls->name, r->name, rv);
|
||||
log_error("S %s R %s convert_dlm error %d", ls->name, r->name, rv);
|
||||
rv = -ELMERR;
|
||||
}
|
||||
return rv;
|
||||
@@ -740,7 +720,7 @@ int lm_unlock_dlm(struct lockspace *ls, struct resource *r,
|
||||
memcpy(rdd->vb, &vb_next, sizeof(struct val_blk));
|
||||
memcpy(lksb->sb_lvbptr, &vb_next, sizeof(struct val_blk));
|
||||
|
||||
log_debug("%s:%s unlock_dlm vb old %x %x %u new %x %x %u",
|
||||
log_debug("S %s R %s unlock_dlm vb old %x %x %u new %x %x %u",
|
||||
ls->name, r->name,
|
||||
le16_to_cpu(vb_prev.version),
|
||||
le16_to_cpu(vb_prev.flags),
|
||||
@@ -749,12 +729,12 @@ int lm_unlock_dlm(struct lockspace *ls, struct resource *r,
|
||||
le16_to_cpu(vb_next.flags),
|
||||
le32_to_cpu(vb_next.r_version));
|
||||
} else {
|
||||
log_debug("%s:%s unlock_dlm vb unchanged", ls->name, r->name);
|
||||
log_debug("S %s R %s unlock_dlm vb unchanged", ls->name, r->name);
|
||||
}
|
||||
|
||||
flags |= LKF_VALBLK;
|
||||
} else {
|
||||
log_debug("%s:%s unlock_dlm", ls->name, r->name);
|
||||
log_debug("S %s R %s unlock_dlm", ls->name, r->name);
|
||||
}
|
||||
|
||||
if (daemon_test)
|
||||
@@ -764,7 +744,7 @@ int lm_unlock_dlm(struct lockspace *ls, struct resource *r,
|
||||
r->name, strlen(r->name),
|
||||
0, NULL, NULL, NULL);
|
||||
if (rv < 0) {
|
||||
log_error("%s:%s unlock_dlm error %d", ls->name, r->name, rv);
|
||||
log_error("S %s R %s unlock_dlm error %d", ls->name, r->name, rv);
|
||||
rv = -ELMERR;
|
||||
}
|
||||
|
||||
@@ -799,6 +779,7 @@ int lm_unlock_dlm(struct lockspace *ls, struct resource *r,
|
||||
|
||||
int lm_hosts_dlm(struct lockspace *ls, int notify)
|
||||
{
|
||||
static const char closedir_err_msg[] = "lm_hosts_dlm: closedir failed";
|
||||
char ls_nodes_path[PATH_MAX];
|
||||
struct dirent *de;
|
||||
DIR *ls_dir;
|
||||
@@ -821,7 +802,7 @@ int lm_hosts_dlm(struct lockspace *ls, int notify)
|
||||
}
|
||||
|
||||
if (closedir(ls_dir))
|
||||
log_error("lm_hosts_dlm: closedir failed");
|
||||
log_error(closedir_err_msg);
|
||||
|
||||
if (!count) {
|
||||
log_error("lm_hosts_dlm found no nodes in %s", ls_nodes_path);
|
||||
@@ -838,10 +819,10 @@ int lm_hosts_dlm(struct lockspace *ls, int notify)
|
||||
|
||||
int lm_get_lockspaces_dlm(struct list_head *ls_rejoin)
|
||||
{
|
||||
static const char closedir_err_msg[] = "lm_get_lockspace_dlm: closedir failed";
|
||||
struct lockspace *ls;
|
||||
struct dirent *de;
|
||||
DIR *ls_dir;
|
||||
int ret = 0;
|
||||
|
||||
if (!(ls_dir = opendir(DLM_LOCKSPACES_PATH)))
|
||||
return -ECONNREFUSED;
|
||||
@@ -854,20 +835,20 @@ int lm_get_lockspaces_dlm(struct list_head *ls_rejoin)
|
||||
continue;
|
||||
|
||||
if (!(ls = alloc_lockspace())) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
if (closedir(ls_dir))
|
||||
log_error(closedir_err_msg);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ls->lm_type = LD_LM_DLM;
|
||||
dm_strncpy(ls->name, de->d_name, sizeof(ls->name));
|
||||
dm_strncpy(ls->vg_name, ls->name + strlen(LVM_LS_PREFIX), sizeof(ls->vg_name));
|
||||
strncpy(ls->name, de->d_name, MAX_NAME);
|
||||
strncpy(ls->vg_name, ls->name + strlen(LVM_LS_PREFIX), MAX_NAME);
|
||||
list_add_tail(&ls->list, ls_rejoin);
|
||||
}
|
||||
out:
|
||||
if (closedir(ls_dir))
|
||||
log_error("lm_get_lockspace_dlm: closedir failed");
|
||||
|
||||
return ret;
|
||||
if (closedir(ls_dir))
|
||||
log_error(closedir_err_msg);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lm_is_running_dlm(void)
|
||||
@@ -897,7 +878,7 @@ int lm_refresh_lv_start_dlm(struct action *act)
|
||||
int rv;
|
||||
|
||||
/* split /dev/vgname/lvname into vgname and lvname strings */
|
||||
dm_strncpy(path, act->path, sizeof(path));
|
||||
strncpy(path, act->path, PATH_MAX-1);
|
||||
|
||||
/* skip past dev */
|
||||
if (!(p = strchr(path + 1, '/')))
|
||||
|
@@ -136,7 +136,7 @@ static int lm_idm_scsi_directory_select(const struct dirent *s)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int lm_idm_scsi_find_block_directory(const char *block_path)
|
||||
static int lm_idm_scsi_find_block_dirctory(const char *block_path)
|
||||
{
|
||||
struct stat stats;
|
||||
|
||||
@@ -252,7 +252,7 @@ static char *lm_idm_scsi_get_block_device_node(const char *scsi_path)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = lm_idm_scsi_find_block_directory(blk_path);
|
||||
ret = lm_idm_scsi_find_block_dirctory(blk_path);
|
||||
if (ret < 0) {
|
||||
log_error("Fail to find block path %s", blk_path);
|
||||
goto fail;
|
||||
@@ -364,7 +364,7 @@ static void lm_idm_update_vb_timestamp(uint64_t *vb_timestamp)
|
||||
|
||||
/*
|
||||
* It's possible that the multiple nodes have no clock
|
||||
* synchronization with microsecond precision and the time
|
||||
* synchronization with microsecond prcision and the time
|
||||
* is going backward. For this case, simply increment the
|
||||
* existing timestamp and write out to drive.
|
||||
*/
|
||||
@@ -391,7 +391,7 @@ int lm_prepare_lockspace_idm(struct lockspace *ls)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lm_add_lockspace_idm(struct lockspace *ls, int adopt_only, int adopt_ok)
|
||||
int lm_add_lockspace_idm(struct lockspace *ls, int adopt)
|
||||
{
|
||||
char killpath[IDM_FAILURE_PATH_LEN];
|
||||
char killargs[IDM_FAILURE_ARGS_LEN];
|
||||
@@ -530,7 +530,7 @@ static int to_idm_mode(int ld_mode)
|
||||
|
||||
int lm_lock_idm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, char *lv_uuid, struct pvs *pvs,
|
||||
int adopt_only, int adopt_ok)
|
||||
int adopt)
|
||||
{
|
||||
struct lm_idm *lmi = (struct lm_idm *)ls->lm_data;
|
||||
struct rd_idm *rdi = (struct rd_idm *)r->lm_data;
|
||||
|
@@ -107,12 +107,11 @@ struct client {
|
||||
#define LD_AF_SEARCH_LS 0x00000200
|
||||
#define LD_AF_WAIT_STARTING 0x00001000
|
||||
#define LD_AF_DUP_GL_LS 0x00002000
|
||||
#define LD_AF_ADOPT 0x00010000 /* adopt ok but not required */
|
||||
#define LD_AF_ADOPT 0x00010000
|
||||
#define LD_AF_WARN_GL_REMOVED 0x00020000
|
||||
#define LD_AF_LV_LOCK 0x00040000
|
||||
#define LD_AF_LV_UNLOCK 0x00080000
|
||||
#define LD_AF_SH_EXISTS 0x00100000
|
||||
#define LD_AF_ADOPT_ONLY 0x00200000 /* adopt orphan or fail */
|
||||
|
||||
/*
|
||||
* Number of times to repeat a lock request after
|
||||
@@ -132,7 +131,6 @@ struct action {
|
||||
uint32_t flags; /* LD_AF_ */
|
||||
uint32_t version;
|
||||
uint64_t host_id;
|
||||
uint64_t lv_size_bytes;
|
||||
int8_t op; /* operation type LD_OP_ */
|
||||
int8_t rt; /* resource type LD_RT_ */
|
||||
int8_t mode; /* lock mode LD_LK_ */
|
||||
@@ -141,7 +139,6 @@ struct action {
|
||||
int max_retries;
|
||||
int result;
|
||||
int lm_rv; /* return value from lm_ function */
|
||||
int align_mb;
|
||||
char *path;
|
||||
char vg_uuid[64];
|
||||
char vg_name[MAX_NAME+1];
|
||||
@@ -193,6 +190,8 @@ struct lockspace {
|
||||
void *lm_data;
|
||||
uint64_t host_id;
|
||||
uint64_t free_lock_offset; /* for sanlock, start search for free lock here */
|
||||
int free_lock_sector_size; /* for sanlock */
|
||||
int free_lock_align_size; /* for sanlock */
|
||||
struct pvs pvs; /* for idm: PV list */
|
||||
|
||||
uint32_t start_client_id; /* client_id that started the lockspace */
|
||||
@@ -364,8 +363,6 @@ void log_level(int level, const char *fmt, ...) __attribute__((format(printf, 2
|
||||
#define log_debug(fmt, args...) log_level(LOG_DEBUG, fmt, ##args)
|
||||
#define log_error(fmt, args...) log_level(LOG_ERR, fmt, ##args)
|
||||
#define log_warn(fmt, args...) log_level(LOG_WARNING, fmt, ##args)
|
||||
#define log_sys_debug(x, y) \
|
||||
log_debug("%s: %s failed: %s", y, x, strerror(errno))
|
||||
|
||||
struct lockspace *alloc_lockspace(void);
|
||||
int lockspaces_empty(void);
|
||||
@@ -394,11 +391,11 @@ static inline const char *mode_str(int x)
|
||||
|
||||
int lm_init_vg_dlm(char *ls_name, char *vg_name, uint32_t flags, char *vg_args);
|
||||
int lm_prepare_lockspace_dlm(struct lockspace *ls);
|
||||
int lm_add_lockspace_dlm(struct lockspace *ls, int adopt_only, int adopt_ok);
|
||||
int lm_add_lockspace_dlm(struct lockspace *ls, int adopt);
|
||||
int lm_purge_locks_dlm(struct lockspace *ls);
|
||||
int lm_rem_lockspace_dlm(struct lockspace *ls, int free_vg);
|
||||
int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, int adopt_only, int adopt_ok);
|
||||
struct val_blk *vb_out, int adopt);
|
||||
int lm_convert_dlm(struct lockspace *ls, struct resource *r,
|
||||
int ld_mode, uint32_t r_version);
|
||||
int lm_unlock_dlm(struct lockspace *ls, struct resource *r,
|
||||
@@ -428,7 +425,7 @@ static inline int lm_prepare_lockspace_dlm(struct lockspace *ls)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int lm_add_lockspace_dlm(struct lockspace *ls, int adopt_only, int adopt_ok)
|
||||
static inline int lm_add_lockspace_dlm(struct lockspace *ls, int adopt)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -444,7 +441,7 @@ static inline int lm_rem_lockspace_dlm(struct lockspace *ls, int free_vg)
|
||||
}
|
||||
|
||||
static inline int lm_lock_dlm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, int adopt_only, int adopt_ok)
|
||||
struct val_blk *vb_out, int adopt)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -505,16 +502,15 @@ static inline int lm_refresh_lv_check_dlm(struct action *act)
|
||||
|
||||
#ifdef LOCKDSANLOCK_SUPPORT
|
||||
|
||||
int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_args, int opt_align_mb);
|
||||
int lm_init_lv_sanlock(struct lockspace *ls, char *lv_name, char *vg_args, char *lv_args);
|
||||
int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_args);
|
||||
int lm_init_lv_sanlock(char *ls_name, char *vg_name, char *lv_name, char *vg_args, char *lv_args, int sector_size, int align_size, uint64_t free_offset);
|
||||
int lm_free_lv_sanlock(struct lockspace *ls, struct resource *r);
|
||||
int lm_rename_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_args);
|
||||
int lm_prepare_lockspace_sanlock(struct lockspace *ls);
|
||||
int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt_only, int adopt_ok);
|
||||
int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt);
|
||||
int lm_rem_lockspace_sanlock(struct lockspace *ls, int free_vg);
|
||||
int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, int *retry,
|
||||
int adopt_only, int adopt_ok);
|
||||
struct val_blk *vb_out, int *retry, int adopt);
|
||||
int lm_convert_sanlock(struct lockspace *ls, struct resource *r,
|
||||
int ld_mode, uint32_t r_version);
|
||||
int lm_unlock_sanlock(struct lockspace *ls, struct resource *r,
|
||||
@@ -527,7 +523,7 @@ int lm_gl_is_enabled(struct lockspace *ls);
|
||||
int lm_get_lockspaces_sanlock(struct list_head *ls_rejoin);
|
||||
int lm_data_size_sanlock(void);
|
||||
int lm_is_running_sanlock(void);
|
||||
int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t lv_size_bytes);
|
||||
int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t *free_offset, int *sector_size, int *align_size);
|
||||
|
||||
static inline int lm_support_sanlock(void)
|
||||
{
|
||||
@@ -536,12 +532,12 @@ static inline int lm_support_sanlock(void)
|
||||
|
||||
#else
|
||||
|
||||
static inline int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_args, int opt_align_mb)
|
||||
static inline int lm_init_vg_sanlock(char *ls_name, char *vg_name, uint32_t flags, char *vg_args)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int lm_init_lv_sanlock(struct lockspace *ls, char *lv_name, char *vg_args, char *lv_args)
|
||||
static inline int lm_init_lv_sanlock(char *ls_name, char *vg_name, char *lv_name, char *vg_args, char *lv_args, int sector_size, int align_size, uint64_t free_offset)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -561,7 +557,7 @@ static inline int lm_prepare_lockspace_sanlock(struct lockspace *ls)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt_only, int adopt_ok)
|
||||
static inline int lm_add_lockspace_sanlock(struct lockspace *ls, int adopt)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -572,8 +568,7 @@ static inline int lm_rem_lockspace_sanlock(struct lockspace *ls, int free_vg)
|
||||
}
|
||||
|
||||
static inline int lm_lock_sanlock(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, int *retry,
|
||||
int adopt_only, int adopt_ok)
|
||||
struct val_blk *vb_out, int *retry, int adopt)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -630,7 +625,7 @@ static inline int lm_is_running_sanlock(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t lv_size_bytes);
|
||||
static inline int lm_find_free_lock_sanlock(struct lockspace *ls, uint64_t *free_offset, int *sector_size, int *align_size)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -647,11 +642,11 @@ static inline int lm_support_sanlock(void)
|
||||
int lm_data_size_idm(void);
|
||||
int lm_init_vg_idm(char *ls_name, char *vg_name, uint32_t flags, char *vg_args);
|
||||
int lm_prepare_lockspace_idm(struct lockspace *ls);
|
||||
int lm_add_lockspace_idm(struct lockspace *ls, int adopt_only, int adopt_ok);
|
||||
int lm_add_lockspace_idm(struct lockspace *ls, int adopt);
|
||||
int lm_rem_lockspace_idm(struct lockspace *ls, int free_vg);
|
||||
int lm_lock_idm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, char *lv_uuid, struct pvs *pvs,
|
||||
int adopt_only, int adopt_ok);
|
||||
int adopt);
|
||||
int lm_convert_idm(struct lockspace *ls, struct resource *r,
|
||||
int ld_mode, uint32_t r_version);
|
||||
int lm_unlock_idm(struct lockspace *ls, struct resource *r,
|
||||
@@ -684,7 +679,7 @@ static inline int lm_prepare_lockspace_idm(struct lockspace *ls)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static inline int lm_add_lockspace_idm(struct lockspace *ls, int adopt_only, int adopt_ok)
|
||||
static inline int lm_add_lockspace_idm(struct lockspace *ls, int adopt)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -696,7 +691,7 @@ static inline int lm_rem_lockspace_idm(struct lockspace *ls, int free_vg)
|
||||
|
||||
static inline int lm_lock_idm(struct lockspace *ls, struct resource *r, int ld_mode,
|
||||
struct val_blk *vb_out, char *lv_uuid, struct pvs *pvs,
|
||||
int adopt_only, int adopt_ok)
|
||||
int adopt)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -32,11 +32,11 @@ LDFLAGS += $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS)
|
||||
LIBS += $(DAEMON_LIBS) $(PTHREAD_LIBS)
|
||||
|
||||
lvmpolld: $(OBJECTS) $(top_builddir)/libdaemon/server/libdaemonserver.a $(INTERNAL_LIBS)
|
||||
$(SHOW) " [CC] $@"
|
||||
@echo " [CC] $@"
|
||||
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $+ $(LIBS)
|
||||
|
||||
install_lvmpolld: lvmpolld
|
||||
$(SHOW) " [INSTALL] $<"
|
||||
@echo " [INSTALL] $<"
|
||||
$(Q) $(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
|
||||
|
||||
install_lvm2: install_lvmpolld
|
||||
|
@@ -19,7 +19,7 @@
|
||||
|
||||
#define MIN_ARGV_SIZE 8
|
||||
|
||||
static const char *const _polling_ops[] = {
|
||||
static const char *const polling_ops[] = {
|
||||
[PVMOVE] = LVMPD_REQ_PVMOVE,
|
||||
[CONVERT] = LVMPD_REQ_CONVERT,
|
||||
[MERGE] = LVMPD_REQ_MERGE,
|
||||
@@ -28,7 +28,7 @@ static const char *const _polling_ops[] = {
|
||||
|
||||
const char *polling_op(enum poll_type type)
|
||||
{
|
||||
return type < POLL_TYPE_MAX ? _polling_ops[type] : "<undefined>";
|
||||
return type < POLL_TYPE_MAX ? polling_ops[type] : "<undefined>";
|
||||
}
|
||||
|
||||
static int add_to_cmd_arr(const char ***cmdargv, const char *str, unsigned *ind)
|
||||
@@ -81,7 +81,7 @@ const char **cmdargv_ctr(const struct lvmpolld_lv *pdlv, const char *lvm_binary,
|
||||
|
||||
/* one of: "convert", "pvmove", "merge", "merge_thin" */
|
||||
if (!add_to_cmd_arr(&cmd_argv, "--polloperation", &i) ||
|
||||
!add_to_cmd_arr(&cmd_argv, _polling_ops[pdlv->type], &i))
|
||||
!add_to_cmd_arr(&cmd_argv, polling_ops[pdlv->type], &i))
|
||||
goto err;
|
||||
|
||||
/* vg/lv name */
|
||||
|
@@ -75,7 +75,7 @@ static void _usage(const char *prog, FILE *file)
|
||||
" -p|--pidfile Set path to the pidfile\n"
|
||||
" -s|--socket Set path to the communication socket\n"
|
||||
" -B|--binary Path to lvm2 binary\n"
|
||||
" -t|--timeout Time to wait in seconds before shutdown on idle (missing or 0 = infinite)\n\n", prog, prog);
|
||||
" -t|--timeout Time to wait in seconds before shutdown on idle (missing or 0 = inifinite)\n\n", prog, prog);
|
||||
}
|
||||
|
||||
static int _init(struct daemon_state *s)
|
||||
@@ -781,7 +781,7 @@ struct log_line_baton {
|
||||
const char *prefix;
|
||||
};
|
||||
|
||||
static daemon_handle _lvmpolld = { .error = 0 };
|
||||
daemon_handle _lvmpolld = { .error = 0 };
|
||||
|
||||
static daemon_handle _lvmpolld_open(const char *socket)
|
||||
{
|
||||
@@ -867,14 +867,14 @@ enum action_index {
|
||||
ACTION_MAX /* keep at the end */
|
||||
};
|
||||
|
||||
static const action_fn_t actions[ACTION_MAX] = { [ACTION_DUMP] = action_dump };
|
||||
|
||||
static int _make_action(enum action_index idx, void *args)
|
||||
{
|
||||
static const action_fn_t _actions[ACTION_MAX] = { [ACTION_DUMP] = action_dump };
|
||||
|
||||
return idx < ACTION_MAX ? _actions[idx](args) : 0;
|
||||
return idx < ACTION_MAX ? actions[idx](args) : 0;
|
||||
}
|
||||
|
||||
static int _lvmpolld_client(const char *socket, enum action_index action)
|
||||
static int _lvmpolld_client(const char *socket, unsigned action)
|
||||
{
|
||||
int r;
|
||||
|
||||
@@ -892,9 +892,10 @@ static int _lvmpolld_client(const char *socket, enum action_index action)
|
||||
return r ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
||||
static const struct option _long_options[] = {
|
||||
static int action_idx = ACTION_MAX;
|
||||
static struct option long_options[] = {
|
||||
/* Have actions always at the beginning of the array. */
|
||||
{"dump", no_argument, 0, ACTION_DUMP }, /* or an option_index ? */
|
||||
{"dump", no_argument, &action_idx, ACTION_DUMP }, /* or an option_index ? */
|
||||
|
||||
/* other options */
|
||||
{"binary", required_argument, 0, 'B' },
|
||||
@@ -913,7 +914,7 @@ int main(int argc, char *argv[])
|
||||
int opt;
|
||||
int option_index = 0;
|
||||
int client = 0, server = 0;
|
||||
enum action_index action = ACTION_MAX;
|
||||
unsigned action = ACTION_MAX;
|
||||
struct timespec timeout;
|
||||
daemon_idle di = { .ptimeout = &timeout };
|
||||
struct lvmpolld_state ls = { .log_config = "" };
|
||||
@@ -929,16 +930,16 @@ int main(int argc, char *argv[])
|
||||
.socket_path = getenv("LVM_LVMPOLLD_SOCKET") ?: LVMPOLLD_SOCKET,
|
||||
};
|
||||
|
||||
while ((opt = getopt_long(argc, argv, "fhVl:p:s:B:t:", _long_options, &option_index)) != -1) {
|
||||
while ((opt = getopt_long(argc, argv, "fhVl:p:s:B:t:", long_options, &option_index)) != -1) {
|
||||
switch (opt) {
|
||||
case 0 :
|
||||
if (action != ACTION_MAX) {
|
||||
if (action < ACTION_MAX) {
|
||||
fprintf(stderr, "Can't perform more actions. Action already requested: %s\n",
|
||||
_long_options[action].name);
|
||||
long_options[action].name);
|
||||
_usage(argv[0], stderr);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
action = ACTION_DUMP;
|
||||
action = action_idx;
|
||||
client = 1;
|
||||
break;
|
||||
case '?':
|
||||
|
@@ -273,12 +273,12 @@ static void _pdlv_locked_dump(struct buffer *buff, const struct lvmpolld_lv *pdl
|
||||
buffer_append(buff, tmp);
|
||||
if (dm_snprintf(tmp, sizeof(tmp), "\t\tpolling_finished=%d\n", pdlv->polling_finished) > 0)
|
||||
buffer_append(buff, tmp);
|
||||
if (dm_snprintf(tmp, sizeof(tmp), "\t\terror_occurred=%d\n", pdlv->error) > 0)
|
||||
if (dm_snprintf(tmp, sizeof(tmp), "\t\terror_occured=%d\n", pdlv->error) > 0)
|
||||
buffer_append(buff, tmp);
|
||||
if (dm_snprintf(tmp, sizeof(tmp), "\t\tinit_requests_count=%d\n", pdlv->init_rq_count) > 0)
|
||||
buffer_append(buff, tmp);
|
||||
|
||||
/* lvm_command-section { */
|
||||
/* lvm_commmand-section { */
|
||||
buffer_append(buff, "\t\tlvm_command {\n");
|
||||
if (cmd_state->retcode == -1 && !cmd_state->signal)
|
||||
buffer_append(buff, "\t\t\tstate=\"" LVMPD_RESP_IN_PROGRESS "\"\n");
|
||||
@@ -290,7 +290,7 @@ static void _pdlv_locked_dump(struct buffer *buff, const struct lvmpolld_lv *pdl
|
||||
buffer_append(buff, tmp);
|
||||
}
|
||||
buffer_append(buff, "\t\t}\n");
|
||||
/* } lvm_command-section */
|
||||
/* } lvm_commmand-section */
|
||||
|
||||
buffer_append(buff, "\t}\n");
|
||||
/* } pdlv-section */
|
||||
|
@@ -45,18 +45,18 @@ struct lvmpolld_lv {
|
||||
* accessing following vars doesn't
|
||||
* require struct lvmpolld_lv lock
|
||||
*/
|
||||
struct lvmpolld_state *ls;
|
||||
enum poll_type type;
|
||||
const char *lvid;
|
||||
const char *lvmpolld_id;
|
||||
const char *devicesfile;
|
||||
const char *lvname; /* full vg/lv name */
|
||||
unsigned pdtimeout; /* in seconds */
|
||||
const char *sinterval;
|
||||
const char *lvm_system_dir_env;
|
||||
struct lvmpolld_store *pdst;
|
||||
const char **cmdargv;
|
||||
const char **cmdenvp;
|
||||
struct lvmpolld_state *const ls;
|
||||
const enum poll_type type;
|
||||
const char *const lvid;
|
||||
const char *const lvmpolld_id;
|
||||
const char *const devicesfile;
|
||||
const char *const lvname; /* full vg/lv name */
|
||||
const unsigned pdtimeout; /* in seconds */
|
||||
const char *const sinterval;
|
||||
const char *const lvm_system_dir_env;
|
||||
struct lvmpolld_store *const pdst;
|
||||
const char *const *cmdargv;
|
||||
const char *const *cmdenvp;
|
||||
|
||||
/* only used by write */
|
||||
pid_t cmd_pid;
|
||||
@@ -66,9 +66,9 @@ struct lvmpolld_lv {
|
||||
|
||||
/* block of shared variables protected by lock */
|
||||
struct lvmpolld_cmd_stat cmd_state;
|
||||
unsigned init_rq_count; /* for debugging purposes only */
|
||||
unsigned init_rq_count; /* for debuging purposes only */
|
||||
unsigned polling_finished:1; /* no more updates */
|
||||
unsigned error:1; /* unrecoverable error occurred in lvmpolld */
|
||||
unsigned error:1; /* unrecoverable error occured in lvmpolld */
|
||||
};
|
||||
|
||||
typedef void (*lvmpolld_parse_output_fn_t) (struct lvmpolld_lv *pdlv, const char *line);
|
||||
|
@@ -45,7 +45,7 @@
|
||||
#define LVMPD_RESP_OK "OK"
|
||||
|
||||
#define LVMPD_REAS_RETCODE "retcode" /* lvm cmd ret code */
|
||||
#define LVMPD_REAS_SIGNAL "signal" /* lvm cmd terminating signal */
|
||||
#define LVMPD_REAS_SIGNAL "signal" /* lvm cmd terminating singal */
|
||||
|
||||
#define LVMPD_RET_DUP_FAILED 100
|
||||
#define LVMPD_RET_EXC_FAILED 101
|
||||
|
@@ -44,10 +44,10 @@ CLEAN_TARGETS += $(DEVICE_MAPPER_DEPENDS) $(DEVICE_MAPPER_OBJECTS) \
|
||||
#$(DEVICE_MAPPER_OBJECTS): INCLUDES+=$(VDO_INCLUDES)
|
||||
|
||||
$(DEVICE_MAPPER_TARGET): $(DEVICE_MAPPER_OBJECTS)
|
||||
$(SHOW) " [AR] $@"
|
||||
@echo " [AR] $@"
|
||||
$(Q) $(RM) $@
|
||||
$(Q) $(AR) rsv $@ $(DEVICE_MAPPER_OBJECTS) > /dev/null
|
||||
|
||||
ifeq ("$(USE_TRACKING)","yes")
|
||||
ifeq ("$(DEPENDS)","yes")
|
||||
-include $(DEVICE_MAPPER_DEPENDS)
|
||||
endif
|
||||
|
@@ -175,11 +175,12 @@ struct dm_names {
|
||||
|
||||
struct dm_active_device {
|
||||
struct dm_list list;
|
||||
dev_t devno;
|
||||
const char *name; /* device name */
|
||||
int major;
|
||||
int minor;
|
||||
char *name; /* device name */
|
||||
|
||||
uint32_t event_nr; /* valid when DM_DEVICE_LIST_HAS_EVENT_NR is set */
|
||||
const char *uuid; /* valid uuid when DM_DEVICE_LIST_HAS_UUID is set */
|
||||
char *uuid; /* valid uuid when DM_DEVICE_LIST_HAS_UUID is set */
|
||||
};
|
||||
|
||||
struct dm_versions {
|
||||
@@ -229,6 +230,13 @@ struct dm_names *dm_task_get_names(struct dm_task *dmt);
|
||||
#define DM_DEVICE_LIST_HAS_UUID 2
|
||||
int dm_task_get_device_list(struct dm_task *dmt, struct dm_list **devs_list,
|
||||
unsigned *devs_features);
|
||||
/*
|
||||
* -1: no idea about uuid (not provided by DM_DEVICE_LIST ioctl)
|
||||
* 0: uuid not present
|
||||
* 1: listed and dm_active_device will be set for not NULL pointer
|
||||
*/
|
||||
int dm_device_list_find_by_uuid(struct dm_list *devs_list, const char *uuid,
|
||||
const struct dm_active_device **dev);
|
||||
/* Release all associated memory with list of active DM devices */
|
||||
void dm_device_list_destroy(struct dm_list **devs_list);
|
||||
|
||||
@@ -304,15 +312,15 @@ int dm_task_add_target(struct dm_task *dmt,
|
||||
#define DM_FORMAT_DEV_BUFSIZE 13 /* Minimum bufsize to handle worst case. */
|
||||
int dm_format_dev(char *buf, int bufsize, uint32_t dev_major, uint32_t dev_minor);
|
||||
|
||||
/* Use this to retrieve target information returned from a STATUS call */
|
||||
/* Use this to retrive target information returned from a STATUS call */
|
||||
void *dm_get_next_target(struct dm_task *dmt,
|
||||
void *next, uint64_t *start, uint64_t *length,
|
||||
char **target_type, char **params);
|
||||
|
||||
/*
|
||||
* Following dm_get_status_* functions will allocate appropriate status structure
|
||||
* Following dm_get_status_* functions will allocate approriate status structure
|
||||
* from passed mempool together with the necessary character arrays.
|
||||
* Destroying the mempool will release all associated allocation.
|
||||
* Destroying the mempool will release all asociated allocation.
|
||||
*/
|
||||
|
||||
/* Parse params from STATUS call for mirror target */
|
||||
@@ -541,7 +549,7 @@ const char *dm_sysfs_dir(void);
|
||||
|
||||
/*
|
||||
* Configure default UUID prefix string.
|
||||
* Conventionally this is a short capitalized prefix indicating the subsystem
|
||||
* Conventionally this is a short capitalised prefix indicating the subsystem
|
||||
* that is managing the devices, e.g. "LVM-" or "MPATH-".
|
||||
* To support stacks of devices from different subsystems, recursive functions
|
||||
* stop recursing if they reach a device with a different prefix.
|
||||
@@ -584,7 +592,7 @@ int dm_device_has_mounted_fs(uint32_t major, uint32_t minor);
|
||||
|
||||
|
||||
/*
|
||||
* Callback is invoked for individual mountinfo lines,
|
||||
* Callback is invoked for individal mountinfo lines,
|
||||
* minor, major and mount target are parsed and unmangled.
|
||||
*/
|
||||
typedef int (*dm_mountinfo_line_callback_fn) (char *line, unsigned maj, unsigned min,
|
||||
@@ -698,7 +706,7 @@ void *dm_tree_node_get_context(const struct dm_tree_node *node);
|
||||
/*
|
||||
* Returns 0 when node size and its children is unchanged.
|
||||
* Returns 1 when node or any of its children has increased size.
|
||||
* Returns -1 when node or any of its children has reduced size.
|
||||
* Rerurns -1 when node or any of its children has reduced size.
|
||||
*/
|
||||
int dm_tree_node_size_changed(const struct dm_tree_node *dnode);
|
||||
|
||||
@@ -885,7 +893,7 @@ struct dm_tree_node_raid_params {
|
||||
};
|
||||
|
||||
/*
|
||||
* Version 2 of above node raid params struct to keep API compatibility.
|
||||
* Version 2 of above node raid params struct to keeep API compatibility.
|
||||
*
|
||||
* Extended for more than 64 legs (max 253 in the MD kernel runtime!),
|
||||
* delta_disks for disk add/remove reshaping,
|
||||
@@ -908,7 +916,7 @@ struct dm_tree_node_raid_params_v2 {
|
||||
* 'rebuilds' and 'writemostly' are bitfields that signify
|
||||
* which devices in the array are to be rebuilt or marked
|
||||
* writemostly. The kernel supports up to 253 legs.
|
||||
* We limit ourselves by choosing a lower value
|
||||
* We limit ourselvs by choosing a lower value
|
||||
* for DEFAULT_RAID_MAX_IMAGES.
|
||||
*/
|
||||
uint64_t rebuilds[RAID_BITMAP_SIZE];
|
||||
@@ -945,7 +953,7 @@ struct dm_config_node;
|
||||
*
|
||||
* policy_settings {
|
||||
* migration_threshold=2048
|
||||
* sequential_threshold=100
|
||||
* sequention_threashold=100
|
||||
* ...
|
||||
* }
|
||||
*
|
||||
@@ -1023,7 +1031,6 @@ struct integrity_settings {
|
||||
uint32_t commit_time;
|
||||
uint32_t bitmap_flush_interval;
|
||||
uint64_t sectors_per_bit;
|
||||
uint32_t allow_discards;
|
||||
|
||||
unsigned journal_sectors_set:1;
|
||||
unsigned interleave_sectors_set:1;
|
||||
@@ -1032,7 +1039,6 @@ struct integrity_settings {
|
||||
unsigned commit_time_set:1;
|
||||
unsigned bitmap_flush_interval_set:1;
|
||||
unsigned sectors_per_bit_set:1;
|
||||
unsigned allow_discards_set:1;
|
||||
};
|
||||
|
||||
int dm_tree_node_add_integrity_target(struct dm_tree_node *node,
|
||||
@@ -1094,7 +1100,7 @@ int dm_tree_node_add_replicator_dev_target(struct dm_tree_node *node,
|
||||
/* End of Replicator API */
|
||||
|
||||
/*
|
||||
* FIXME: Defines below are based on kernel's dm-thin.c defines
|
||||
* FIXME: Defines bellow are based on kernel's dm-thin.c defines
|
||||
* DATA_DEV_BLOCK_SIZE_MIN_SECTORS (64 * 1024 >> SECTOR_SHIFT)
|
||||
* DATA_DEV_BLOCK_SIZE_MAX_SECTORS (1024 * 1024 * 1024 >> SECTOR_SHIFT)
|
||||
*/
|
||||
@@ -1160,7 +1166,7 @@ int dm_tree_node_set_thin_pool_error_if_no_space(struct dm_tree_node *node,
|
||||
int dm_tree_node_set_thin_pool_read_only(struct dm_tree_node *node,
|
||||
unsigned read_only);
|
||||
/*
|
||||
* FIXME: Defines below are based on kernel's dm-thin.c defines
|
||||
* FIXME: Defines bellow are based on kernel's dm-thin.c defines
|
||||
* MAX_DEV_ID ((1 << 24) - 1)
|
||||
*/
|
||||
#define DM_THIN_MAX_DEVICE_ID (UINT32_C((1 << 24) - 1))
|
||||
@@ -1869,7 +1875,6 @@ const void *dm_report_value_cache_get(struct dm_report *rh, const char *name);
|
||||
#define DM_REPORT_OUTPUT_FIELD_UNQUOTED 0x00000010
|
||||
#define DM_REPORT_OUTPUT_COLUMNS_AS_ROWS 0x00000020
|
||||
#define DM_REPORT_OUTPUT_MULTIPLE_TIMES 0x00000040
|
||||
#define DM_REPORT_OUTPUT_FIELD_IDS_IN_HEADINGS 0x00000080
|
||||
|
||||
struct dm_report *dm_report_init(uint32_t *report_types,
|
||||
const struct dm_report_object_type *types,
|
||||
@@ -2058,7 +2063,7 @@ void dm_config_destroy(struct dm_config_tree *cft);
|
||||
|
||||
/* Simple output line by line. */
|
||||
typedef int (*dm_putline_fn)(const char *line, void *baton);
|
||||
/* More advanced output with config node reference. */
|
||||
/* More advaced output with config node reference. */
|
||||
typedef int (*dm_config_node_out_fn)(const struct dm_config_node *cn, const char *line, void *baton);
|
||||
|
||||
/*
|
||||
@@ -2121,7 +2126,7 @@ struct dm_config_node *dm_config_clone_node(struct dm_config_tree *cft, const st
|
||||
* Common formatting flags applicable to all config node types (lower 16 bits).
|
||||
*/
|
||||
#define DM_CONFIG_VALUE_FMT_COMMON_ARRAY 0x00000001 /* value is array */
|
||||
#define DM_CONFIG_VALUE_FMT_COMMON_EXTRA_SPACES 0x00000002 /* add spaces in "key = value" pairs in contrast to "key=value" for better readability */
|
||||
#define DM_CONFIG_VALUE_FMT_COMMON_EXTRA_SPACES 0x00000002 /* add spaces in "key = value" pairs in constrast to "key=value" for better readability */
|
||||
|
||||
/*
|
||||
* Type-related config node formatting flags (higher 16 bits).
|
||||
@@ -2167,7 +2172,7 @@ struct dm_pool *dm_config_memory(struct dm_config_tree *cft);
|
||||
*/
|
||||
#define DM_UDEV_DISABLE_DM_RULES_FLAG 0x0001
|
||||
/*
|
||||
* DM_UDEV_DISABLE_SUBSYSTEM_RULES_FLAG is set in case we need to disable
|
||||
* DM_UDEV_DISABLE_SUBSYTEM_RULES_FLAG is set in case we need to disable
|
||||
* subsystem udev rules, but still we need the general DM udev rules to
|
||||
* be applied (to create the nodes and symlinks under /dev and /dev/disk).
|
||||
*/
|
||||
@@ -2238,7 +2243,7 @@ struct dm_pool *dm_config_memory(struct dm_config_tree *cft);
|
||||
int dm_cookie_supported(void);
|
||||
|
||||
/*
|
||||
* Udev synchronization functions.
|
||||
* Udev synchronisation functions.
|
||||
*/
|
||||
void dm_udev_set_sync_support(int sync_with_udev);
|
||||
int dm_udev_get_sync_support(void);
|
||||
|
@@ -87,8 +87,10 @@ static int _version_checked = 0;
|
||||
static int _version_ok = 1;
|
||||
static unsigned _ioctl_buffer_double_factor = 0;
|
||||
|
||||
const int _dm_compat = 0;
|
||||
|
||||
/* *INDENT-OFF* */
|
||||
static const struct cmd_data _cmd_data_v4[] = {
|
||||
static struct cmd_data _cmd_data_v4[] = {
|
||||
{"create", DM_DEV_CREATE, {4, 0, 0}},
|
||||
{"reload", DM_TABLE_LOAD, {4, 0, 0}},
|
||||
{"remove", DM_DEV_REMOVE, {4, 0, 0}},
|
||||
@@ -198,7 +200,6 @@ static int _get_proc_number(const char *file, const char *name,
|
||||
char *line = NULL;
|
||||
size_t len;
|
||||
uint32_t num;
|
||||
unsigned blocksection = (strcmp(file, PROC_DEVICES) == 0) ? 0 : 1;
|
||||
|
||||
if (!(fl = fopen(file, "r"))) {
|
||||
log_sys_error("fopen", file);
|
||||
@@ -206,9 +207,7 @@ static int _get_proc_number(const char *file, const char *name,
|
||||
}
|
||||
|
||||
while (getline(&line, &len, fl) != -1) {
|
||||
if (!blocksection && (line[0] == 'B'))
|
||||
blocksection = 1;
|
||||
else if (sscanf(line, "%u %255s\n", &num, &nm[0]) == 2) {
|
||||
if (sscanf(line, "%u %255s\n", &num, &nm[0]) == 2) {
|
||||
if (!strcmp(name, nm)) {
|
||||
if (number) {
|
||||
*number = num;
|
||||
@@ -248,16 +247,6 @@ static int _control_device_number(uint32_t *major, uint32_t *minor)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _control_unlink(const char *control)
|
||||
{
|
||||
if (unlink(control) && (errno != ENOENT)) {
|
||||
log_sys_error("unlink", control);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns 1 if it exists on returning; 0 if it doesn't; -1 if it's wrong.
|
||||
*/
|
||||
@@ -273,7 +262,10 @@ static int _control_exists(const char *control, uint32_t major, uint32_t minor)
|
||||
|
||||
if (!S_ISCHR(buf.st_mode)) {
|
||||
log_verbose("%s: Wrong inode type", control);
|
||||
return _control_unlink(control);
|
||||
if (!unlink(control))
|
||||
return 0;
|
||||
log_sys_error("unlink", control);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (major && buf.st_rdev != MKDEV(major, minor)) {
|
||||
@@ -281,7 +273,10 @@ static int _control_exists(const char *control, uint32_t major, uint32_t minor)
|
||||
"(%u, %u)", control,
|
||||
MAJOR(buf.st_mode), MINOR(buf.st_mode),
|
||||
major, minor);
|
||||
return _control_unlink(control);
|
||||
if (!unlink(control))
|
||||
return 0;
|
||||
log_sys_error("unlink", control);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -317,13 +312,8 @@ static int _create_control(const char *control, uint32_t major, uint32_t minor)
|
||||
old_umask = umask(DM_CONTROL_NODE_UMASK);
|
||||
if (mknod(control, S_IFCHR | S_IRUSR | S_IWUSR,
|
||||
MKDEV(major, minor)) < 0) {
|
||||
if (errno != EEXIST) {
|
||||
log_sys_error("mknod", control);
|
||||
ret = 0;
|
||||
} else if (_control_exists(control, major, minor) != 1) {
|
||||
stack; /* Invalid control node created by parallel command ? */
|
||||
ret = 0;
|
||||
}
|
||||
log_sys_error("mknod", control);
|
||||
ret = 0;
|
||||
}
|
||||
umask(old_umask);
|
||||
(void) dm_prepare_selinux_context(NULL, 0);
|
||||
@@ -409,7 +399,7 @@ static void _close_control_fd(void)
|
||||
{
|
||||
if (_control_fd != -1) {
|
||||
if (close(_control_fd) < 0)
|
||||
log_sys_debug("close", "_control_fd");
|
||||
log_sys_error("close", "_control_fd");
|
||||
_control_fd = -1;
|
||||
}
|
||||
}
|
||||
@@ -598,9 +588,23 @@ int dm_check_version(void)
|
||||
|
||||
_version_checked = 1;
|
||||
|
||||
if (_check_version(dmversion, sizeof(dmversion), 0))
|
||||
if (_check_version(dmversion, sizeof(dmversion), _dm_compat))
|
||||
return 1;
|
||||
|
||||
if (!_dm_compat)
|
||||
goto_bad;
|
||||
|
||||
log_verbose("device-mapper ioctl protocol version %u failed. "
|
||||
"Trying protocol version 1.", _dm_version);
|
||||
_dm_version = 1;
|
||||
if (_check_version(dmversion, sizeof(dmversion), 0)) {
|
||||
log_verbose("Using device-mapper ioctl protocol version 1");
|
||||
return 1;
|
||||
}
|
||||
|
||||
compat = "(compat)";
|
||||
|
||||
bad:
|
||||
dm_get_library_version(libversion, sizeof(libversion));
|
||||
|
||||
log_error("Incompatible libdevmapper %s%s and kernel driver %s.",
|
||||
@@ -659,7 +663,7 @@ void *dm_get_next_target(struct dm_task *dmt, void *next,
|
||||
return t->next;
|
||||
}
|
||||
|
||||
/* Unmarshal the target info returned from a status call */
|
||||
/* Unmarshall the target info returned from a status call */
|
||||
static int _unmarshal_status(struct dm_task *dmt, struct dm_ioctl *dmi)
|
||||
{
|
||||
char *outbuf = (char *) dmi + dmi->data_start;
|
||||
@@ -748,11 +752,6 @@ uint32_t dm_task_get_read_ahead(const struct dm_task *dmt, uint32_t *read_ahead)
|
||||
|
||||
struct dm_deps *dm_task_get_deps(struct dm_task *dmt)
|
||||
{
|
||||
if (!dmt) {
|
||||
log_error(INTERNAL_ERROR "Missing dm_task.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (struct dm_deps *) (((char *) dmt->dmi.v4) +
|
||||
dmt->dmi.v4->data_start);
|
||||
}
|
||||
@@ -782,12 +781,19 @@ static int _check_has_event_nr(void) {
|
||||
return _has_event_nr;
|
||||
}
|
||||
|
||||
struct dm_device_list {
|
||||
struct dm_list list;
|
||||
unsigned count;
|
||||
unsigned features;
|
||||
struct dm_hash_table *uuids;
|
||||
};
|
||||
|
||||
int dm_task_get_device_list(struct dm_task *dmt, struct dm_list **devs_list,
|
||||
unsigned *devs_features)
|
||||
{
|
||||
struct dm_names *names, *names1;
|
||||
struct dm_active_device *dm_dev, *dm_new_dev;
|
||||
struct dm_list *devs;
|
||||
struct dm_device_list *devs;
|
||||
unsigned next = 0;
|
||||
uint32_t *event_nr;
|
||||
char *uuid_ptr;
|
||||
@@ -808,12 +814,12 @@ int dm_task_get_device_list(struct dm_task *dmt, struct dm_list **devs_list,
|
||||
} while (next);
|
||||
}
|
||||
|
||||
/* buffer for devs + sorted ptrs + dm_devs + aligned strings */
|
||||
if (!(devs = malloc(sizeof(*devs) + cnt * (2 * sizeof(void*) + sizeof(*dm_dev)) +
|
||||
(cnt ? (char*)names1 - (char*)names + 256 : 0))))
|
||||
if (!(devs = malloc(sizeof(*devs) + (cnt ? cnt * sizeof(*dm_dev) + (char*)names1 - (char*)names + 256 : 0))))
|
||||
return_0;
|
||||
|
||||
dm_list_init(devs);
|
||||
dm_list_init(&devs->list);
|
||||
devs->count = cnt;
|
||||
devs->uuids = NULL;
|
||||
|
||||
if (!cnt) {
|
||||
/* nothing in the list -> mark all features present */
|
||||
@@ -821,22 +827,27 @@ int dm_task_get_device_list(struct dm_task *dmt, struct dm_list **devs_list,
|
||||
goto out; /* nothing else to do */
|
||||
}
|
||||
|
||||
/* Shift position where to store individual dm_devs */
|
||||
dm_dev = (struct dm_active_device *) ((long*) (devs + 1) + cnt);
|
||||
dm_dev = (struct dm_active_device *) (devs + 1);
|
||||
|
||||
do {
|
||||
names = (struct dm_names *)((char *) names + next);
|
||||
|
||||
dm_dev->devno = (dev_t) names->dev;
|
||||
dm_dev->name = (const char *)(dm_dev + 1);
|
||||
dm_dev->major = MAJOR(names->dev);
|
||||
dm_dev->minor = MINOR(names->dev);
|
||||
dm_dev->name = (char*)(dm_dev + 1);
|
||||
dm_dev->event_nr = 0;
|
||||
dm_dev->uuid = "";
|
||||
dm_dev->uuid = NULL;
|
||||
|
||||
strcpy(dm_dev->name, names->name);
|
||||
len = strlen(names->name) + 1;
|
||||
memcpy((char*)dm_dev->name, names->name, len);
|
||||
|
||||
dm_new_dev = _align_ptr((char*)(dm_dev + 1) + len);
|
||||
if (_check_has_event_nr()) {
|
||||
/* Hash for UUIDs with some more bits to reduce colision count */
|
||||
if (!devs->uuids && !(devs->uuids = dm_hash_create(cnt * 8))) {
|
||||
free(devs);
|
||||
return_0;
|
||||
}
|
||||
|
||||
*devs_features |= DM_DEVICE_LIST_HAS_EVENT_NR;
|
||||
event_nr = _align_ptr(names->name + len);
|
||||
@@ -845,29 +856,54 @@ int dm_task_get_device_list(struct dm_task *dmt, struct dm_list **devs_list,
|
||||
if ((event_nr[1] & DM_NAME_LIST_FLAG_HAS_UUID)) {
|
||||
*devs_features |= DM_DEVICE_LIST_HAS_UUID;
|
||||
uuid_ptr = _align_ptr(event_nr + 2);
|
||||
len = strlen(uuid_ptr) + 1;
|
||||
memcpy(dm_new_dev, uuid_ptr, len);
|
||||
dm_dev->uuid = (const char *) dm_new_dev;
|
||||
dm_new_dev = _align_ptr((char*)dm_new_dev + len);
|
||||
dm_dev->uuid = (char*) dm_new_dev;
|
||||
dm_new_dev = _align_ptr((char*)dm_new_dev + strlen(uuid_ptr) + 1);
|
||||
strcpy(dm_dev->uuid, uuid_ptr);
|
||||
if (!dm_hash_insert(devs->uuids, dm_dev->uuid, dm_dev))
|
||||
return_0; // FIXME
|
||||
#if 0
|
||||
log_debug("Active %s (%s) %d:%d event:%u",
|
||||
dm_dev->name, dm_dev->uuid,
|
||||
dm_dev->major, dm_dev->minor, dm_dev->event_nr);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
dm_list_add(devs, &dm_dev->list);
|
||||
dm_list_add(&devs->list, &dm_dev->list);
|
||||
dm_dev = dm_new_dev;
|
||||
next = names->next;
|
||||
} while (next);
|
||||
|
||||
out:
|
||||
*devs_list = devs;
|
||||
*devs_list = (struct dm_list *)devs;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int dm_device_list_find_by_uuid(struct dm_list *devs_list, const char *uuid,
|
||||
const struct dm_active_device **dev)
|
||||
{
|
||||
struct dm_device_list *devs = (struct dm_device_list *) devs_list;
|
||||
struct dm_active_device *dm_dev;
|
||||
|
||||
if (devs->uuids &&
|
||||
(dm_dev = dm_hash_lookup(devs->uuids, uuid))) {
|
||||
if (dev)
|
||||
*dev = dm_dev;
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dm_device_list_destroy(struct dm_list **devs_list)
|
||||
{
|
||||
struct dm_device_list *devs = (struct dm_device_list *) *devs_list;
|
||||
|
||||
if (devs) {
|
||||
if (devs->uuids)
|
||||
dm_hash_destroy(devs->uuids);
|
||||
|
||||
free(devs);
|
||||
*devs_list = NULL;
|
||||
}
|
||||
@@ -1160,10 +1196,9 @@ static char *_add_target(struct target *t, char *out, char *end)
|
||||
while (*pt)
|
||||
if (*pt++ == '\\')
|
||||
backslash_count++;
|
||||
len = strlen(t->params) + backslash_count;
|
||||
|
||||
len = strlen(t->params) + 1;
|
||||
|
||||
if ((out >= end) || (out + len + backslash_count) >= end) {
|
||||
if ((out >= end) || (out + len + 1) >= end) {
|
||||
log_error("Ran out of memory building ioctl parameter");
|
||||
return NULL;
|
||||
}
|
||||
@@ -1179,8 +1214,8 @@ static char *_add_target(struct target *t, char *out, char *end)
|
||||
*out++ = '\0';
|
||||
}
|
||||
else {
|
||||
memcpy(out, t->params, len);
|
||||
out += len + backslash_count;
|
||||
strcpy(out, t->params);
|
||||
out += len + 1;
|
||||
}
|
||||
|
||||
/* align next block */
|
||||
@@ -1214,7 +1249,7 @@ static int _lookup_dev_name(uint64_t dev, char *buf, size_t len)
|
||||
do {
|
||||
names = (struct dm_names *)((char *) names + next);
|
||||
if (names->dev == dev) {
|
||||
memccpy(buf, names->name, 0, len);
|
||||
strncpy(buf, names->name, len);
|
||||
r = 1;
|
||||
break;
|
||||
}
|
||||
@@ -1251,7 +1286,6 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
||||
struct target *t;
|
||||
struct dm_target_msg *tmsg;
|
||||
size_t len = sizeof(struct dm_ioctl);
|
||||
size_t message_len = 0, newname_len = 0, geometry_len = 0;
|
||||
char *b, *e;
|
||||
int count = 0;
|
||||
|
||||
@@ -1312,20 +1346,14 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (dmt->newname) {
|
||||
newname_len = strlen(dmt->newname) + 1;
|
||||
len += newname_len;
|
||||
}
|
||||
if (dmt->newname)
|
||||
len += strlen(dmt->newname) + 1;
|
||||
|
||||
if (dmt->message) {
|
||||
message_len = strlen(dmt->message) + 1;
|
||||
len += sizeof(struct dm_target_msg) + message_len;
|
||||
}
|
||||
if (dmt->message)
|
||||
len += sizeof(struct dm_target_msg) + strlen(dmt->message) + 1;
|
||||
|
||||
if (dmt->geometry) {
|
||||
geometry_len = strlen(dmt->geometry) + 1;
|
||||
len += geometry_len;
|
||||
}
|
||||
if (dmt->geometry)
|
||||
len += strlen(dmt->geometry) + 1;
|
||||
|
||||
/*
|
||||
* Give len a minimum size so that we have space to store
|
||||
@@ -1383,10 +1411,12 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
||||
/* FIXME Until resume ioctl supplies name, use dev_name for readahead */
|
||||
if (DEV_NAME(dmt) && (dmt->type != DM_DEVICE_RESUME || dmt->minor < 0 ||
|
||||
dmt->major < 0))
|
||||
memccpy(dmi->name, DEV_NAME(dmt), 0, sizeof(dmi->name));
|
||||
/* coverity[buffer_size_warning] */
|
||||
strncpy(dmi->name, DEV_NAME(dmt), sizeof(dmi->name));
|
||||
|
||||
if (DEV_UUID(dmt))
|
||||
memccpy(dmi->uuid, DEV_UUID(dmt), 0, sizeof(dmi->uuid));
|
||||
/* coverity[buffer_size_warning] */
|
||||
strncpy(dmi->uuid, DEV_UUID(dmt), sizeof(dmi->uuid));
|
||||
|
||||
if (dmt->type == DM_DEVICE_SUSPEND)
|
||||
dmi->flags |= DM_SUSPEND_FLAG;
|
||||
@@ -1445,16 +1475,16 @@ static struct dm_ioctl *_flatten(struct dm_task *dmt, unsigned repeat_count)
|
||||
goto_bad;
|
||||
|
||||
if (dmt->newname)
|
||||
memcpy(b, dmt->newname, newname_len);
|
||||
strcpy(b, dmt->newname);
|
||||
|
||||
if (dmt->message) {
|
||||
tmsg = (struct dm_target_msg *) b;
|
||||
tmsg->sector = dmt->sector;
|
||||
memcpy(tmsg->message, dmt->message, message_len);
|
||||
strcpy(tmsg->message, dmt->message);
|
||||
}
|
||||
|
||||
if (dmt->geometry)
|
||||
memcpy(b, dmt->geometry, geometry_len);
|
||||
strcpy(b, dmt->geometry);
|
||||
|
||||
return dmi;
|
||||
|
||||
@@ -1576,7 +1606,7 @@ static int _check_uevent_generated(struct dm_ioctl *dmi)
|
||||
static int _create_and_load_v4(struct dm_task *dmt)
|
||||
{
|
||||
struct dm_task *task;
|
||||
int r, ioctl_errno = 0;
|
||||
int r;
|
||||
uint32_t cookie;
|
||||
|
||||
/* Use new task struct to create the device */
|
||||
@@ -1602,10 +1632,8 @@ static int _create_and_load_v4(struct dm_task *dmt)
|
||||
task->cookie_set = dmt->cookie_set;
|
||||
task->add_node = dmt->add_node;
|
||||
|
||||
if (!dm_task_run(task)) {
|
||||
ioctl_errno = task->ioctl_errno;
|
||||
if (!dm_task_run(task))
|
||||
goto_bad;
|
||||
}
|
||||
|
||||
dm_task_destroy(task);
|
||||
|
||||
@@ -1631,8 +1659,6 @@ static int _create_and_load_v4(struct dm_task *dmt)
|
||||
task->ima_measurement = dmt->ima_measurement;
|
||||
|
||||
r = dm_task_run(task);
|
||||
if (!r)
|
||||
ioctl_errno = task->ioctl_errno;
|
||||
|
||||
task->head = NULL;
|
||||
task->tail = NULL;
|
||||
@@ -1650,7 +1676,6 @@ static int _create_and_load_v4(struct dm_task *dmt)
|
||||
dmt->uuid = NULL;
|
||||
free(dmt->mangled_uuid);
|
||||
dmt->mangled_uuid = NULL;
|
||||
/* coverity[double_free] recursive function call */
|
||||
_dm_task_free_targets(dmt);
|
||||
|
||||
if (dm_task_run(dmt))
|
||||
@@ -1662,7 +1687,6 @@ static int _create_and_load_v4(struct dm_task *dmt)
|
||||
dmt->uuid = NULL;
|
||||
free(dmt->mangled_uuid);
|
||||
dmt->mangled_uuid = NULL;
|
||||
/* coverity[double_free] recursive function call */
|
||||
_dm_task_free_targets(dmt);
|
||||
|
||||
/*
|
||||
@@ -1681,18 +1705,12 @@ static int _create_and_load_v4(struct dm_task *dmt)
|
||||
if (!dm_task_run(dmt))
|
||||
log_error("Failed to revert device creation.");
|
||||
|
||||
if (ioctl_errno != 0)
|
||||
dmt->ioctl_errno = ioctl_errno;
|
||||
|
||||
return 0;
|
||||
|
||||
bad:
|
||||
dm_task_destroy(task);
|
||||
_udev_complete(dmt);
|
||||
|
||||
if (ioctl_errno != 0)
|
||||
dmt->ioctl_errno = ioctl_errno;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2034,7 +2052,7 @@ static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
|
||||
/*
|
||||
* Prevent udev vs. libdevmapper race when processing nodes
|
||||
* and symlinks. This can happen when the udev rules are
|
||||
* installed and udev synchronization code is enabled in
|
||||
* installed and udev synchronisation code is enabled in
|
||||
* libdevmapper but the software using libdevmapper does not
|
||||
* make use of it (by not calling dm_task_set_cookie before).
|
||||
* We need to instruct the udev rules not to be applied at
|
||||
@@ -2044,7 +2062,7 @@ static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command,
|
||||
if (!dmt->cookie_set && dm_udev_get_sync_support()) {
|
||||
log_debug_activation("Cookie value is not set while trying to call %s "
|
||||
"ioctl. Please, consider using libdevmapper's udev "
|
||||
"synchronization interface or disable it explicitly "
|
||||
"synchronisation interface or disable it explicitly "
|
||||
"by calling dm_udev_set_sync_support(0).",
|
||||
dmt->type == DM_DEVICE_RESUME ? "DM_DEVICE_RESUME" :
|
||||
dmt->type == DM_DEVICE_REMOVE ? "DM_DEVICE_REMOVE" :
|
||||
|
@@ -79,7 +79,7 @@ struct dm_task {
|
||||
};
|
||||
|
||||
struct cmd_data {
|
||||
const char name[16];
|
||||
const char *name;
|
||||
const unsigned cmd;
|
||||
const int version[3];
|
||||
};
|
||||
|
@@ -537,8 +537,7 @@ int unmangle_string(const char *str, const char *str_name, size_t len,
|
||||
}
|
||||
|
||||
if (str[i] == '\\' && str[i+1] == 'x') {
|
||||
if (!sscanf(&str[i+2], "%2x%" DM_TO_STRING(DM_NAME_LEN) "s",
|
||||
&code, str_rest)) {
|
||||
if (!sscanf(&str[i+2], "%2x%s", &code, str_rest)) {
|
||||
log_debug_activation("Hex encoding mismatch detected in %s \"%s\" "
|
||||
"while trying to unmangle it.", str_name, str);
|
||||
goto out;
|
||||
@@ -1061,8 +1060,9 @@ static int _add_dev_node(const char *dev_name, uint32_t major, uint32_t minor,
|
||||
if (info.st_rdev == dev)
|
||||
return 1;
|
||||
|
||||
if (unlink(path) && (errno != ENOENT)) {
|
||||
log_sys_error("unlink", path);
|
||||
if (unlink(path) < 0) {
|
||||
log_error("Unable to unlink device node for '%s'",
|
||||
dev_name);
|
||||
return 0;
|
||||
}
|
||||
} else if (_warn_if_op_needed(warn_if_udev_failed))
|
||||
@@ -1106,8 +1106,8 @@ static int _rm_dev_node(const char *dev_name, int warn_if_udev_failed)
|
||||
"Falling back to direct node removal.", path);
|
||||
|
||||
/* udev may already have deleted the node. Ignore ENOENT. */
|
||||
if (unlink(path) && (errno != ENOENT)) {
|
||||
log_sys_error("unlink", path);
|
||||
if (unlink(path) < 0 && errno != ENOENT) {
|
||||
log_error("Unable to unlink device node for '%s'", dev_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1451,10 +1451,9 @@ struct node_op_parms {
|
||||
|
||||
static void _store_str(char **pos, char **ptr, const char *str)
|
||||
{
|
||||
size_t len = strlen(str) + 1;
|
||||
memcpy(*pos, str, len);
|
||||
strcpy(*pos, str);
|
||||
*ptr = *pos;
|
||||
*pos += len;
|
||||
*pos += strlen(*ptr) + 1;
|
||||
}
|
||||
|
||||
static void _del_node_op(struct node_op_parms *nop)
|
||||
@@ -1704,17 +1703,15 @@ const char *dm_sysfs_dir(void)
|
||||
*/
|
||||
int dm_set_uuid_prefix(const char *uuid_prefix)
|
||||
{
|
||||
size_t len;
|
||||
|
||||
if (!uuid_prefix)
|
||||
return_0;
|
||||
|
||||
if ((len = strlen(uuid_prefix)) > DM_MAX_UUID_PREFIX_LEN) {
|
||||
if (strlen(uuid_prefix) > DM_MAX_UUID_PREFIX_LEN) {
|
||||
log_error("New uuid prefix %s too long.", uuid_prefix);
|
||||
return 0;
|
||||
}
|
||||
|
||||
memcpy(_default_uuid_prefix, uuid_prefix, len + 1);
|
||||
strcpy(_default_uuid_prefix, uuid_prefix);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1743,9 +1740,6 @@ static void _unmangle_mountinfo_string(const char *src, char *buf)
|
||||
*buf = '\0';
|
||||
}
|
||||
|
||||
/* coverity[+tainted_string_sanitize_content:arg-0] */
|
||||
static int _sanitize_line(const char *line) { return 1; }
|
||||
|
||||
/* Parse one line of mountinfo and unmangled target line */
|
||||
static int _mountinfo_parse_line(const char *line, unsigned *maj, unsigned *min, char *buf)
|
||||
{
|
||||
@@ -1796,7 +1790,7 @@ static int _mountinfo_parse_line(const char *line, unsigned *maj, unsigned *min,
|
||||
}
|
||||
|
||||
/*
|
||||
* Function to operate on individual mountinfo line,
|
||||
* Function to operate on individal mountinfo line,
|
||||
* minor, major and mount target are parsed and unmangled
|
||||
*/
|
||||
int dm_mountinfo_read(dm_mountinfo_line_callback_fn read_fn, void *cb_data)
|
||||
@@ -1816,8 +1810,7 @@ int dm_mountinfo_read(dm_mountinfo_line_callback_fn read_fn, void *cb_data)
|
||||
}
|
||||
|
||||
while (!feof(minfo) && fgets(buffer, sizeof(buffer), minfo))
|
||||
if (!_sanitize_line(buffer) ||
|
||||
!_mountinfo_parse_line(buffer, &maj, &min, target) ||
|
||||
if (!_mountinfo_parse_line(buffer, &maj, &min, target) ||
|
||||
!read_fn(buffer, maj, min, target, cb_data)) {
|
||||
stack;
|
||||
r = 0;
|
||||
@@ -1961,7 +1954,7 @@ static int _sysfs_find_kernel_name(uint32_t major, uint32_t minor, char *buf, si
|
||||
!strcmp(name_dev, "holders") ||
|
||||
!strcmp(name_dev, "integrity") ||
|
||||
!strcmp(name_dev, "loop") ||
|
||||
!strcmp(name_dev, "queue") ||
|
||||
!strcmp(name_dev, "queueu") ||
|
||||
!strcmp(name_dev, "md") ||
|
||||
!strcmp(name_dev, "mq") ||
|
||||
!strcmp(name_dev, "power") ||
|
||||
@@ -2318,7 +2311,7 @@ static int _check_semaphore_is_supported(void)
|
||||
|
||||
if (maxid < 0) {
|
||||
log_warn("Kernel not configured for semaphores (System V IPC). "
|
||||
"Not using udev synchronization code.");
|
||||
"Not using udev synchronisation code.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -2341,7 +2334,7 @@ static int _check_udev_is_running(void)
|
||||
|
||||
if (!(r = udev_queue_get_udev_is_active(udev_queue)))
|
||||
log_debug_activation("Udev is not running. "
|
||||
"Not using udev synchronization code.");
|
||||
"Not using udev synchronisation code.");
|
||||
|
||||
udev_queue_unref(udev_queue);
|
||||
udev_unref(udev);
|
||||
@@ -2416,7 +2409,7 @@ static int _get_cookie_sem(uint32_t cookie, int *semid)
|
||||
break;
|
||||
case EACCES:
|
||||
log_error("No permission to access "
|
||||
"notification semaphore identified "
|
||||
"notificaton semaphore identified "
|
||||
"by cookie value %" PRIu32 " (0x%x)",
|
||||
cookie, cookie);
|
||||
break;
|
||||
@@ -2437,20 +2430,20 @@ static int _udev_notify_sem_inc(uint32_t cookie, int semid)
|
||||
int val;
|
||||
|
||||
if (semop(semid, &sb, 1) < 0) {
|
||||
log_error("cookie inc: semid %d: semop failed for cookie 0x%" PRIx32 ": %s",
|
||||
log_error("semid %d: semop failed for cookie 0x%" PRIx32 ": %s",
|
||||
semid, cookie, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((val = semctl(semid, 0, GETVAL)) < 0) {
|
||||
log_warn("cookie inc: semid %d: sem_ctl GETVAL failed for "
|
||||
log_error("semid %d: sem_ctl GETVAL failed for "
|
||||
"cookie 0x%" PRIx32 ": %s",
|
||||
semid, cookie, strerror(errno));
|
||||
log_debug_activation("Udev cookie 0x%" PRIx32 " (semid %d) incremented.",
|
||||
cookie, semid);
|
||||
} else
|
||||
log_debug_activation("Udev cookie 0x%" PRIx32 " (semid %d) incremented to %d",
|
||||
cookie, semid, val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
log_debug_activation("Udev cookie 0x%" PRIx32 " (semid %d) incremented to %d",
|
||||
cookie, semid, val);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -2460,21 +2453,23 @@ static int _udev_notify_sem_dec(uint32_t cookie, int semid)
|
||||
struct sembuf sb = {0, -1, IPC_NOWAIT};
|
||||
int val;
|
||||
|
||||
if ((val = semctl(semid, 0, GETVAL)) < 0)
|
||||
log_warn("cookie dec: semid %d: sem_ctl GETVAL failed for "
|
||||
"cookie 0x%" PRIx32 ": %s",
|
||||
semid, cookie, strerror(errno));
|
||||
if ((val = semctl(semid, 0, GETVAL)) < 0) {
|
||||
log_error("semid %d: sem_ctl GETVAL failed for "
|
||||
"cookie 0x%" PRIx32 ": %s",
|
||||
semid, cookie, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (semop(semid, &sb, 1) < 0) {
|
||||
switch (errno) {
|
||||
case EAGAIN:
|
||||
log_error("cookie dec: semid %d: semop failed for cookie "
|
||||
log_error("semid %d: semop failed for cookie "
|
||||
"0x%" PRIx32 ": "
|
||||
"incorrect semaphore state",
|
||||
semid, cookie);
|
||||
break;
|
||||
default:
|
||||
log_error("cookie dec: semid %d: semop failed for cookie "
|
||||
log_error("semid %d: semop failed for cookie "
|
||||
"0x%" PRIx32 ": %s",
|
||||
semid, cookie, strerror(errno));
|
||||
break;
|
||||
@@ -2482,12 +2477,9 @@ static int _udev_notify_sem_dec(uint32_t cookie, int semid)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (val < 0)
|
||||
log_debug_activation("Udev cookie 0x%" PRIx32 " (semid %d) decremented.",
|
||||
cookie, semid);
|
||||
else
|
||||
log_debug_activation("Udev cookie 0x%" PRIx32 " (semid %d) decremented to %d",
|
||||
cookie, semid, val - 1);
|
||||
log_debug_activation("Udev cookie 0x%" PRIx32 " (semid %d) decremented to %d",
|
||||
cookie, semid, val - 1);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -2564,7 +2556,7 @@ static int _udev_notify_sem_create(uint32_t *cookie, int *semid)
|
||||
sem_arg.val = 1;
|
||||
|
||||
if (semctl(gen_semid, 0, SETVAL, sem_arg) < 0) {
|
||||
log_error("cookie create: semid %d: semctl failed: %s", gen_semid, strerror(errno));
|
||||
log_error("semid %d: semctl failed: %s", gen_semid, strerror(errno));
|
||||
/* We have to destroy just created semaphore
|
||||
* so it won't stay in the system. */
|
||||
(void) _udev_notify_sem_destroy(gen_cookie, gen_semid);
|
||||
@@ -2572,10 +2564,9 @@ static int _udev_notify_sem_create(uint32_t *cookie, int *semid)
|
||||
}
|
||||
|
||||
if ((val = semctl(gen_semid, 0, GETVAL)) < 0) {
|
||||
log_error("cookie create: semid %d: sem_ctl GETVAL failed for "
|
||||
log_error("semid %d: sem_ctl GETVAL failed for "
|
||||
"cookie 0x%" PRIx32 ": %s",
|
||||
gen_semid, gen_cookie, strerror(errno));
|
||||
(void) _udev_notify_sem_destroy(gen_cookie, gen_semid);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
|
@@ -70,11 +70,12 @@ static struct dm_config_value *_value(struct parser *p);
|
||||
static struct dm_config_value *_type(struct parser *p);
|
||||
static int _match_aux(struct parser *p, int t);
|
||||
static struct dm_config_value *_create_value(struct dm_pool *mem);
|
||||
static struct dm_config_value *_create_str_value(struct dm_pool *mem, const char *str, size_t str_len);
|
||||
static struct dm_config_node *_create_node(struct dm_pool *mem, const char *key, size_t key_len);
|
||||
static struct dm_config_node *_create_node(struct dm_pool *mem);
|
||||
static char *_dup_tok(struct parser *p);
|
||||
static char *_dup_token(struct dm_pool *mem, const char *b, const char *e);
|
||||
|
||||
static const int _sep = '/';
|
||||
|
||||
#define MAX_INDENT 32
|
||||
|
||||
#define match(t) do {\
|
||||
@@ -85,19 +86,14 @@ static char *_dup_token(struct dm_pool *mem, const char *b, const char *e);
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/* match token */
|
||||
static int _tok_match(const char *str, const char *b, const char *e)
|
||||
{
|
||||
while (b < e) {
|
||||
if (*str != *b)
|
||||
while (*str && (b != e)) {
|
||||
if (*str++ != *b++)
|
||||
return 0;
|
||||
if (!*str)
|
||||
return 0;
|
||||
++str;
|
||||
++b;
|
||||
}
|
||||
|
||||
return !*str; /* token is matching for \0 end */
|
||||
return !(*str || (b != e));
|
||||
}
|
||||
|
||||
struct dm_config_tree *dm_config_create(void)
|
||||
@@ -181,18 +177,19 @@ static int _do_dm_config_parse(struct dm_config_tree *cft, const char *start, co
|
||||
{
|
||||
/* TODO? if (start == end) return 1; */
|
||||
|
||||
struct parser p = {
|
||||
.mem = cft->mem,
|
||||
.tb = start,
|
||||
.te = start,
|
||||
.fb = start,
|
||||
.fe = end,
|
||||
.line = 1,
|
||||
.no_dup_node_check = no_dup_node_check
|
||||
};
|
||||
struct parser *p;
|
||||
if (!(p = dm_pool_zalloc(cft->mem, sizeof(*p))))
|
||||
return_0;
|
||||
|
||||
_get_token(&p, TOK_SECTION_E);
|
||||
if (!(cft->root = _file(&p)))
|
||||
p->mem = cft->mem;
|
||||
p->fb = start;
|
||||
p->fe = end;
|
||||
p->tb = p->te = p->fb;
|
||||
p->line = 1;
|
||||
p->no_dup_node_check = no_dup_node_check;
|
||||
|
||||
_get_token(p, TOK_SECTION_E);
|
||||
if (!(cft->root = _file(p)))
|
||||
return_0;
|
||||
|
||||
cft->root = _config_reverse(cft->root);
|
||||
@@ -473,33 +470,23 @@ int dm_config_write_node_out(const struct dm_config_node *cn,
|
||||
/*
|
||||
* parser
|
||||
*/
|
||||
static const char *_string_tok(struct parser *p, size_t *len)
|
||||
static char *_dup_string_tok(struct parser *p)
|
||||
{
|
||||
ptrdiff_t d = p->te - p->tb;
|
||||
char *str;
|
||||
|
||||
if (d < 2) {
|
||||
p->tb++, p->te--; /* strip "'s */
|
||||
|
||||
if (p->te < p->tb) {
|
||||
log_error("Parse error at byte %" PRIptrdiff_t " (line %d): "
|
||||
"expected a string token.",
|
||||
p->tb - p->fb + 1, p->line);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*len = (size_t)(d - 2); /* strip "'s */
|
||||
|
||||
return p->tb + 1;
|
||||
}
|
||||
|
||||
static char *_dup_string_tok(struct parser *p)
|
||||
{
|
||||
const char *tok;
|
||||
size_t len;
|
||||
char *str;
|
||||
|
||||
if (!(tok = _string_tok(p, &len)))
|
||||
if (!(str = _dup_tok(p)))
|
||||
return_NULL;
|
||||
|
||||
if (!(str = _dup_token(p->mem, tok, tok + len)))
|
||||
return_NULL;
|
||||
p->te++;
|
||||
|
||||
return str;
|
||||
}
|
||||
@@ -521,9 +508,10 @@ static struct dm_config_node *_make_node(struct dm_pool *mem,
|
||||
{
|
||||
struct dm_config_node *n;
|
||||
|
||||
if (!(n = _create_node(mem, key_b, key_e - key_b)))
|
||||
if (!(n = _create_node(mem)))
|
||||
return_NULL;
|
||||
|
||||
n->key = _dup_token(mem, key_b, key_e);
|
||||
if (parent) {
|
||||
n->parent = parent;
|
||||
n->sib = parent->child;
|
||||
@@ -538,18 +526,17 @@ static struct dm_config_node *_find_or_make_node(struct dm_pool *mem,
|
||||
const char *path,
|
||||
int no_dup_node_check)
|
||||
{
|
||||
const int sep = '/';
|
||||
const char *e;
|
||||
struct dm_config_node *cn = parent ? parent->child : NULL;
|
||||
struct dm_config_node *cn_found = NULL;
|
||||
|
||||
while (cn || mem) {
|
||||
/* trim any leading slashes */
|
||||
while (*path && (*path == sep))
|
||||
while (*path && (*path == _sep))
|
||||
path++;
|
||||
|
||||
/* find the end of this segment */
|
||||
for (e = path; *e && (*e != sep); e++) ;
|
||||
for (e = path; *e && (*e != _sep); e++) ;
|
||||
|
||||
/* hunt for the node */
|
||||
cn_found = NULL;
|
||||
@@ -684,14 +671,16 @@ static struct dm_config_value *_value(struct parser *p)
|
||||
static struct dm_config_value *_type(struct parser *p)
|
||||
{
|
||||
/* [+-]{0,1}[0-9]+ | [0-9]*\.[0-9]* | ".*" */
|
||||
struct dm_config_value *v;
|
||||
const char *str;
|
||||
size_t len;
|
||||
struct dm_config_value *v = _create_value(p->mem);
|
||||
char *str;
|
||||
|
||||
if (!v) {
|
||||
log_error("Failed to allocate type value");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
switch (p->t) {
|
||||
case TOK_INT:
|
||||
if (!(v = _create_value(p->mem)))
|
||||
break;
|
||||
v->type = DM_CFG_INT;
|
||||
errno = 0;
|
||||
v->v.i = strtoll(p->tb, NULL, 0); /* FIXME: check error */
|
||||
@@ -712,8 +701,6 @@ static struct dm_config_value *_type(struct parser *p)
|
||||
break;
|
||||
|
||||
case TOK_FLOAT:
|
||||
if (!(v = _create_value(p->mem)))
|
||||
break;
|
||||
v->type = DM_CFG_FLOAT;
|
||||
errno = 0;
|
||||
v->v.f = strtod(p->tb, NULL); /* FIXME: check error */
|
||||
@@ -725,31 +712,31 @@ static struct dm_config_value *_type(struct parser *p)
|
||||
break;
|
||||
|
||||
case TOK_STRING:
|
||||
if (!(str = _string_tok(p, &len)))
|
||||
v->type = DM_CFG_STRING;
|
||||
|
||||
if (!(v->v.str = _dup_string_tok(p)))
|
||||
return_NULL;
|
||||
|
||||
if ((v = _create_str_value(p->mem, str, len))) {
|
||||
v->type = DM_CFG_STRING;
|
||||
match(TOK_STRING);
|
||||
}
|
||||
match(TOK_STRING);
|
||||
break;
|
||||
|
||||
case TOK_STRING_BARE:
|
||||
if ((v = _create_str_value(p->mem, p->tb, p->te - p->tb))) {
|
||||
v->type = DM_CFG_STRING;
|
||||
match(TOK_STRING_BARE);
|
||||
}
|
||||
v->type = DM_CFG_STRING;
|
||||
|
||||
if (!(v->v.str = _dup_tok(p)))
|
||||
return_NULL;
|
||||
|
||||
match(TOK_STRING_BARE);
|
||||
break;
|
||||
|
||||
case TOK_STRING_ESCAPED:
|
||||
if (!(str = _string_tok(p, &len)))
|
||||
return_NULL;
|
||||
v->type = DM_CFG_STRING;
|
||||
|
||||
if ((v = _create_str_value(p->mem, str, len))) {
|
||||
v->type = DM_CFG_STRING;
|
||||
dm_unescape_double_quotes((char*)v->v.str);
|
||||
match(TOK_STRING_ESCAPED);
|
||||
}
|
||||
if (!(str = _dup_string_tok(p)))
|
||||
return_NULL;
|
||||
dm_unescape_double_quotes(str);
|
||||
v->v.str = str;
|
||||
match(TOK_STRING_ESCAPED);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -757,12 +744,6 @@ static struct dm_config_value *_type(struct parser *p)
|
||||
p->tb - p->fb + 1, p->line);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!v) {
|
||||
log_error("Failed to allocate type value.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -904,19 +885,16 @@ static void _get_token(struct parser *p, int tok_prev)
|
||||
static void _eat_space(struct parser *p)
|
||||
{
|
||||
while (p->tb != p->fe) {
|
||||
if (!isspace(*p->te)) {
|
||||
if (*p->te != '#')
|
||||
break;
|
||||
|
||||
if (*p->te == '#')
|
||||
while ((p->te != p->fe) && (*p->te != '\n') && (*p->te))
|
||||
++p->te;
|
||||
}
|
||||
|
||||
while (p->te != p->fe) {
|
||||
else if (!isspace(*p->te))
|
||||
break;
|
||||
|
||||
while ((p->te != p->fe) && isspace(*p->te)) {
|
||||
if (*p->te == '\n')
|
||||
++p->line;
|
||||
else if (!isspace(*p->te))
|
||||
break;
|
||||
++p->te;
|
||||
}
|
||||
|
||||
@@ -932,46 +910,9 @@ static struct dm_config_value *_create_value(struct dm_pool *mem)
|
||||
return dm_pool_zalloc(mem, sizeof(struct dm_config_value));
|
||||
}
|
||||
|
||||
static struct dm_config_value *_create_str_value(struct dm_pool *mem, const char *str, size_t str_len)
|
||||
static struct dm_config_node *_create_node(struct dm_pool *mem)
|
||||
{
|
||||
struct dm_config_value *cv;
|
||||
char *str_buf;
|
||||
|
||||
if (!(cv = dm_pool_alloc(mem, sizeof(struct dm_config_value) + str_len + 1)))
|
||||
return_NULL;
|
||||
|
||||
memset(cv, 0, sizeof(*cv));
|
||||
|
||||
if (str) {
|
||||
str_buf = (char *)(cv + 1);
|
||||
if (str_len)
|
||||
memcpy(str_buf, str, str_len);
|
||||
str_buf[str_len] = '\0';
|
||||
cv->v.str = str_buf;
|
||||
}
|
||||
|
||||
return cv;
|
||||
}
|
||||
|
||||
static struct dm_config_node *_create_node(struct dm_pool *mem, const char *key, size_t key_len)
|
||||
{
|
||||
struct dm_config_node *cn;
|
||||
char *key_buf;
|
||||
|
||||
if (!(cn = dm_pool_alloc(mem, sizeof(struct dm_config_node) + key_len + 1)))
|
||||
return_NULL;
|
||||
|
||||
memset(cn, 0, sizeof(*cn));
|
||||
|
||||
if (key) {
|
||||
key_buf = (char *)(cn + 1);
|
||||
if (key_len)
|
||||
memcpy(key_buf, key, key_len);
|
||||
key_buf[key_len] = '\0';
|
||||
cn->key = key_buf;
|
||||
}
|
||||
|
||||
return cn;
|
||||
return dm_pool_zalloc(mem, sizeof(struct dm_config_node));
|
||||
}
|
||||
|
||||
static char *_dup_token(struct dm_pool *mem, const char *b, const char *e)
|
||||
@@ -1388,19 +1329,19 @@ static struct dm_config_value *_clone_config_value(struct dm_pool *mem,
|
||||
{
|
||||
struct dm_config_value *new_cv;
|
||||
|
||||
if (v->type == DM_CFG_STRING) {
|
||||
if (!(new_cv = _create_str_value(mem, v->v.str, strlen(v->v.str)))) {
|
||||
|
||||
}
|
||||
} else {
|
||||
if (!(new_cv = _create_value(mem))) {
|
||||
log_error("Failed to clone config value.");
|
||||
return NULL;
|
||||
}
|
||||
new_cv->v = v->v;
|
||||
if (!(new_cv = _create_value(mem))) {
|
||||
log_error("Failed to clone config value.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_cv->type = v->type;
|
||||
if (v->type == DM_CFG_STRING) {
|
||||
if (!(new_cv->v.str = dm_pool_strdup(mem, v->v.str))) {
|
||||
log_error("Failed to clone config string value.");
|
||||
return NULL;
|
||||
}
|
||||
} else
|
||||
new_cv->v = v->v;
|
||||
|
||||
if (v->next && !(new_cv->next = _clone_config_value(mem, v->next)))
|
||||
return_NULL;
|
||||
@@ -1417,11 +1358,16 @@ struct dm_config_node *dm_config_clone_node_with_mem(struct dm_pool *mem, const
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(new_cn = _create_node(mem, cn->key, cn->key ? strlen(cn->key) : 0))) {
|
||||
if (!(new_cn = _create_node(mem))) {
|
||||
log_error("Failed to clone config node.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((cn->key && !(new_cn->key = dm_pool_strdup(mem, cn->key)))) {
|
||||
log_error("Failed to clone config node key.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new_cn->id = cn->id;
|
||||
|
||||
if ((cn->v && !(new_cn->v = _clone_config_value(mem, cn->v))) ||
|
||||
@@ -1441,11 +1387,14 @@ struct dm_config_node *dm_config_create_node(struct dm_config_tree *cft, const c
|
||||
{
|
||||
struct dm_config_node *cn;
|
||||
|
||||
if (!(cn = _create_node(cft->mem, key, strlen(key)))) {
|
||||
if (!(cn = _create_node(cft->mem))) {
|
||||
log_error("Failed to create config node.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(cn->key = dm_pool_strdup(cft->mem, key))) {
|
||||
log_error("Failed to create config node's key.");
|
||||
return NULL;
|
||||
}
|
||||
cn->parent = NULL;
|
||||
cn->v = NULL;
|
||||
|
||||
|
@@ -171,7 +171,7 @@ struct load_segment {
|
||||
uint32_t region_size; /* Mirror + raid */
|
||||
unsigned clustered; /* Mirror */
|
||||
unsigned mirror_area_count; /* Mirror */
|
||||
uint64_t flags; /* Mirror + Raid + Cache */
|
||||
uint32_t flags; /* Mirror + raid + Cache */
|
||||
char *uuid; /* Clustered mirror log */
|
||||
|
||||
const char *policy_name; /* Cache */
|
||||
@@ -265,7 +265,7 @@ struct load_properties {
|
||||
/*
|
||||
* Preload tree normally only loads and not resume, but there is
|
||||
* automatic resume when target is extended, as it's believed
|
||||
* there can be no i/o flying to this 'new' extended space
|
||||
* there can be no i/o flying to this 'new' extedend space
|
||||
* from any device above. Reason is that preloaded target above
|
||||
* may actually need to see its bigger subdevice before it
|
||||
* gets suspended. As long as devices are simple linears
|
||||
@@ -277,7 +277,7 @@ struct load_properties {
|
||||
|
||||
/*
|
||||
* When comparing table lines to decide if a reload is
|
||||
* needed, ignore any differences between the lvm device
|
||||
* needed, ignore any differences betwen the lvm device
|
||||
* params and the kernel-reported device params.
|
||||
* dm-integrity reports many internal parameters on the
|
||||
* table line when lvm does not explicitly set them,
|
||||
@@ -288,16 +288,12 @@ struct load_properties {
|
||||
/*
|
||||
* Call node_send_messages(), set to 2 if there are messages
|
||||
* When != 0, it validates matching transaction id, thus thin-pools
|
||||
* where transaction_id is passed as 0 are never validated, this
|
||||
* allows external management of thin-pool TID.
|
||||
* where transation_id is passed as 0 are never validated, this
|
||||
* allows external managment of thin-pool TID.
|
||||
*/
|
||||
unsigned send_messages;
|
||||
/* Skip suspending node's children, used when sending messages to thin-pool */
|
||||
int skip_suspend;
|
||||
|
||||
/* Suspend and Resume siblings after node activation with udev flags*/
|
||||
unsigned reactivate_siblings;
|
||||
uint16_t reactivate_udev_flags;
|
||||
};
|
||||
|
||||
/* Two of these used to join two nodes with uses and used_by. */
|
||||
@@ -348,7 +344,7 @@ struct dm_tree {
|
||||
int retry_remove; /* 1 retries remove if not successful */
|
||||
uint32_t cookie;
|
||||
char buf[DM_NAME_LEN + 32]; /* print buffer for device_name (major:minor) */
|
||||
const char * const *optional_uuid_suffixes; /* uuid suffixes ignored when matching */
|
||||
const char **optional_uuid_suffixes; /* uuid suffixes ignored when matching */
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -590,7 +586,6 @@ void dm_tree_set_optional_uuid_suffixes(struct dm_tree *dtree, const char **opti
|
||||
dtree->optional_uuid_suffixes = optional_uuid_suffixes;
|
||||
}
|
||||
|
||||
static const char *_node_name(struct dm_tree_node *dnode);
|
||||
static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
|
||||
const char *uuid)
|
||||
{
|
||||
@@ -598,26 +593,28 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
|
||||
const char *default_uuid_prefix;
|
||||
size_t default_uuid_prefix_len;
|
||||
const char *suffix, *suffix_position;
|
||||
char uuid_without_suffix[DM_UUID_LEN + 1];
|
||||
char uuid_without_suffix[DM_UUID_LEN];
|
||||
unsigned i = 0;
|
||||
const char * const *suffix_list = dtree->optional_uuid_suffixes;
|
||||
const char **suffix_list = dtree->optional_uuid_suffixes;
|
||||
|
||||
if ((node = dm_hash_lookup(dtree->uuids, uuid))) {
|
||||
log_debug_activation("Matched uuid %s %s in deptree.", uuid, _node_name(node));
|
||||
log_debug("Matched uuid %s in deptree.", uuid);
|
||||
return node;
|
||||
}
|
||||
|
||||
default_uuid_prefix = dm_uuid_prefix();
|
||||
default_uuid_prefix_len = strlen(default_uuid_prefix);
|
||||
|
||||
if (suffix_list && (suffix_position = strrchr(uuid, '-'))) {
|
||||
while ((suffix = suffix_list[i++])) {
|
||||
if (strcmp(suffix_position + 1, suffix))
|
||||
continue;
|
||||
|
||||
dm_strncpy(uuid_without_suffix, uuid, sizeof(uuid_without_suffix));
|
||||
(void) strncpy(uuid_without_suffix, uuid, sizeof(uuid_without_suffix));
|
||||
uuid_without_suffix[suffix_position - uuid] = '\0';
|
||||
|
||||
if ((node = dm_hash_lookup(dtree->uuids, uuid_without_suffix))) {
|
||||
log_debug_activation("Matched uuid %s %s (missing suffix -%s) in deptree.",
|
||||
uuid_without_suffix, _node_name(node), suffix);
|
||||
log_debug("Matched uuid %s (missing suffix -%s) in deptree.", uuid_without_suffix, suffix);
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -625,17 +622,15 @@ static struct dm_tree_node *_find_dm_tree_node_by_uuid(struct dm_tree *dtree,
|
||||
};
|
||||
}
|
||||
|
||||
default_uuid_prefix = dm_uuid_prefix();
|
||||
default_uuid_prefix_len = strlen(default_uuid_prefix);
|
||||
if (strncmp(uuid, default_uuid_prefix, default_uuid_prefix_len))
|
||||
return NULL;
|
||||
|
||||
if ((strncmp(uuid, default_uuid_prefix, default_uuid_prefix_len) == 0) &&
|
||||
(node = dm_hash_lookup(dtree->uuids, uuid + default_uuid_prefix_len))) {
|
||||
log_debug_activation("Matched uuid %s %s (missing prefix) in deptree.",
|
||||
uuid + default_uuid_prefix_len, _node_name(node));
|
||||
if ((node = dm_hash_lookup(dtree->uuids, uuid + default_uuid_prefix_len))) {
|
||||
log_debug("Matched uuid %s (missing prefix) in deptree.", uuid + default_uuid_prefix_len);
|
||||
return node;
|
||||
}
|
||||
|
||||
log_debug_activation("Not matched uuid %s in deptree.", uuid);
|
||||
log_debug("Not matched uuid %s in deptree.", uuid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -968,7 +963,7 @@ static int _check_device_not_in_use(const char *name, struct dm_info *info)
|
||||
} else if (dm_device_has_holders(info->major, info->minor))
|
||||
reason = "is used by another device";
|
||||
else if (dm_device_has_mounted_fs(info->major, info->minor))
|
||||
reason = "contains a filesystem in use";
|
||||
reason = "constains a filesystem in use";
|
||||
else
|
||||
return 1;
|
||||
|
||||
@@ -1816,7 +1811,7 @@ static int _dm_tree_deactivate_children(struct dm_tree_node *dnode,
|
||||
|
||||
if (info.open_count) {
|
||||
/* Skip internal non-toplevel opened nodes */
|
||||
/* On some old udev systems without correct udev rules
|
||||
/* On some old udev systems without corrrect udev rules
|
||||
* this hack avoids 'leaking' active _mimageX legs after
|
||||
* deactivation of mirror LV. Other suffixes are not added
|
||||
* since it's expected newer systems with wider range of
|
||||
@@ -2035,68 +2030,6 @@ static int _rename_conflict_exists(struct dm_tree_node *parent,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Reactivation of sibling nodes
|
||||
*
|
||||
* Function is used when activating origin and its thick snapshots
|
||||
* to ensure udev is processing first the origin LV and all the
|
||||
* snapshot LVs are processed afterwards.
|
||||
*/
|
||||
static int _reactivate_siblings(struct dm_tree_node *dnode,
|
||||
const char *uuid_prefix,
|
||||
size_t uuid_prefix_len)
|
||||
{
|
||||
struct dm_tree_node *child;
|
||||
const char *uuid;
|
||||
void *handle = NULL;
|
||||
int r = 1;
|
||||
|
||||
/* Wait for udev before reactivating siblings */
|
||||
if (!dm_udev_wait(dm_tree_get_cookie(dnode)))
|
||||
stack;
|
||||
|
||||
dm_tree_set_cookie(dnode, 0);
|
||||
|
||||
while ((child = dm_tree_next_child(&handle, dnode, 0))) {
|
||||
if (child->props.reactivate_siblings) {
|
||||
/* Skip 'leading' device in this group, marked with flag */
|
||||
child->props.reactivate_siblings = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(uuid = dm_tree_node_get_uuid(child))) {
|
||||
stack;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!_uuid_prefix_matches(uuid, uuid_prefix, uuid_prefix_len))
|
||||
continue;
|
||||
|
||||
if (!_suspend_node(child->name, child->info.major, child->info.minor,
|
||||
child->dtree->skip_lockfs,
|
||||
child->dtree->no_flush, &child->info)) {
|
||||
log_error("Unable to suspend %s (" FMTu32
|
||||
":" FMTu32 ")", child->name,
|
||||
child->info.major, child->info.minor);
|
||||
r = 0;
|
||||
continue;
|
||||
}
|
||||
if (!_resume_node(child->name, child->info.major, child->info.minor,
|
||||
child->props.read_ahead, child->props.read_ahead_flags,
|
||||
&child->info, &child->dtree->cookie,
|
||||
child->props.reactivate_udev_flags, // use these flags
|
||||
child->info.suspended)) {
|
||||
log_error("Failed to suspend %s (" FMTu32
|
||||
":" FMTu32 ")", child->name,
|
||||
child->info.major, child->info.minor);
|
||||
r = 0;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
int dm_tree_activate_children(struct dm_tree_node *dnode,
|
||||
const char *uuid_prefix,
|
||||
size_t uuid_prefix_len)
|
||||
@@ -2107,7 +2040,7 @@ int dm_tree_activate_children(struct dm_tree_node *dnode,
|
||||
struct dm_tree_node *child = dnode;
|
||||
const char *name;
|
||||
const char *uuid;
|
||||
int priority, next_priority;
|
||||
int priority;
|
||||
|
||||
/* Activate children first */
|
||||
while ((child = dm_tree_next_child(&handle, dnode, 0))) {
|
||||
@@ -2125,16 +2058,12 @@ int dm_tree_activate_children(struct dm_tree_node *dnode,
|
||||
}
|
||||
|
||||
handle = NULL;
|
||||
|
||||
for (priority = 0; priority < 3; priority++) {
|
||||
awaiting_peer_rename = 0;
|
||||
next_priority = 0;
|
||||
while ((child = dm_tree_next_child(&handle, dnode, 0))) {
|
||||
if (priority != child->activation_priority) {
|
||||
if ((next_priority < child->activation_priority) &&
|
||||
(child->activation_priority > priority))
|
||||
next_priority = child->activation_priority;
|
||||
if (priority != child->activation_priority)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(uuid = dm_tree_node_get_uuid(child))) {
|
||||
stack;
|
||||
@@ -2182,23 +2111,16 @@ int dm_tree_activate_children(struct dm_tree_node *dnode,
|
||||
/*
|
||||
* FIXME: Implement delayed error reporting
|
||||
* activation should be stopped only in the case,
|
||||
* the submission of transaction_id message fails,
|
||||
* the submission of transation_id message fails,
|
||||
* resume should continue further, just whole command
|
||||
* has to report failure.
|
||||
*/
|
||||
if (r && (child->props.send_messages > 1) &&
|
||||
!(r = _node_send_messages(child, uuid_prefix, uuid_prefix_len, 1)))
|
||||
stack;
|
||||
|
||||
/* Reactivate only for fresh activated origin */
|
||||
if (r && child->props.reactivate_siblings &&
|
||||
(!(r = _reactivate_siblings(dnode, uuid_prefix, uuid_prefix_len))))
|
||||
stack;
|
||||
}
|
||||
if (awaiting_peer_rename)
|
||||
priority--; /* redo priority level */
|
||||
else if (!next_priority)
|
||||
break; /* no more work, higher priority was not found in the chain */
|
||||
}
|
||||
|
||||
return r;
|
||||
@@ -2274,7 +2196,7 @@ static int _build_dev_string(char *devbuf, size_t bufsize, struct dm_tree_node *
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* simplify string emitting code */
|
||||
/* simplify string emiting code */
|
||||
#define EMIT_PARAMS(p, str...)\
|
||||
do {\
|
||||
int w;\
|
||||
@@ -2868,8 +2790,6 @@ static int _integrity_emit_segment_line(struct dm_task *dmt,
|
||||
count++;
|
||||
if (set->sectors_per_bit_set)
|
||||
count++;
|
||||
if (set->allow_discards_set && set->allow_discards)
|
||||
count++;
|
||||
|
||||
EMIT_PARAMS(pos, "%s 0 %u %s %d fix_padding block_size:%u internal_hash:%s",
|
||||
origin_dev,
|
||||
@@ -2889,7 +2809,7 @@ static int _integrity_emit_segment_line(struct dm_task *dmt,
|
||||
EMIT_PARAMS(pos, " journal_sectors:%u", set->journal_sectors);
|
||||
|
||||
if (set->interleave_sectors_set)
|
||||
EMIT_PARAMS(pos, " interleave_sectors:%u", set->interleave_sectors);
|
||||
EMIT_PARAMS(pos, " ineterleave_sectors:%u", set->interleave_sectors);
|
||||
|
||||
if (set->buffer_sectors_set)
|
||||
EMIT_PARAMS(pos, " buffer_sectors:%u", set->buffer_sectors);
|
||||
@@ -2906,9 +2826,6 @@ static int _integrity_emit_segment_line(struct dm_task *dmt,
|
||||
if (set->sectors_per_bit_set)
|
||||
EMIT_PARAMS(pos, " sectors_per_bit:%llu", (unsigned long long)set->sectors_per_bit);
|
||||
|
||||
if (set->allow_discards_set && set->allow_discards)
|
||||
EMIT_PARAMS(pos, " allow_discards");
|
||||
|
||||
if (!dm_task_secure_data(dmt))
|
||||
stack;
|
||||
|
||||
@@ -2970,7 +2887,7 @@ static int _vdo_emit_segment_line(struct dm_task *dmt, uint32_t major, uint32_t
|
||||
* If there is already running VDO target, read 'existing' virtual size out of table line
|
||||
* and avoid reading it them from VDO metadata device
|
||||
*
|
||||
* NOTE: ATM VDO virtual size can be ONLY extended thus it's simple to recognize 'right' size.
|
||||
* NOTE: ATM VDO virtual size can be ONLY extended thus it's simple to recongnize 'right' size.
|
||||
* However if there would be supported also reduction, this check would need to check range.
|
||||
*/
|
||||
if ((vdo_dmt = dm_task_create(DM_DEVICE_TABLE))) {
|
||||
@@ -3382,7 +3299,7 @@ int dm_tree_preload_children(struct dm_tree_node *dnode,
|
||||
if (!child->info.exists && !(node_created = _create_node(child, dnode)))
|
||||
return_0;
|
||||
|
||||
/* Propagate delayed resume from extended child node */
|
||||
/* Propagate delayed resume from exteded child node */
|
||||
if (child->props.delay_resume_if_extended)
|
||||
dnode->props.delay_resume_if_extended = 1;
|
||||
|
||||
@@ -3532,10 +3449,6 @@ int dm_tree_node_add_snapshot_origin_target(struct dm_tree_node *dnode,
|
||||
/* Resume snapshot origins after new snapshots */
|
||||
dnode->activation_priority = 1;
|
||||
|
||||
if (!dnode->info.exists)
|
||||
/* Reactivate siblings for this origin after being resumed */
|
||||
dnode->props.reactivate_siblings = 1;
|
||||
|
||||
/*
|
||||
* Don't resume the origin immediately in case it is a non-trivial
|
||||
* target that must not be active more than once concurrently!
|
||||
@@ -3598,20 +3511,6 @@ static int _add_snapshot_target(struct dm_tree_node *node,
|
||||
/* Resume merging snapshot after snapshot-merge */
|
||||
seg->merge->activation_priority = 2;
|
||||
}
|
||||
} else if (!origin_node->info.exists) {
|
||||
/* Keep original udev_flags for reactivation. */
|
||||
node->props.reactivate_udev_flags = node->udev_flags;
|
||||
|
||||
/* Reactivation is needed if the origin's -real device is not in DM table.
|
||||
* For this case after the resume of its origin LV we resume its snapshots
|
||||
* with updated udev_flags to completely avoid udev scanning for the first resume.
|
||||
* Reactivation then resumes snapshots with original udev_flags.
|
||||
*/
|
||||
node->udev_flags |= DM_SUBSYSTEM_UDEV_FLAG0 |
|
||||
DM_UDEV_DISABLE_DISK_RULES_FLAG |
|
||||
DM_UDEV_DISABLE_OTHER_RULES_FLAG;
|
||||
log_debug_activation("Using udev_flags 0x%x for activation of %s.",
|
||||
node->udev_flags, node->name);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -3818,7 +3717,7 @@ int dm_tree_node_add_raid_target(struct dm_tree_node *node,
|
||||
* - maximum 253 legs in a raid set (MD kernel limitation)
|
||||
* - delta_disks for disk add/remove reshaping
|
||||
* - data_offset for out-of-place reshaping
|
||||
* - data_copies to cope with odd numbers of raid10 disks
|
||||
* - data_copies to cope witth odd numbers of raid10 disks
|
||||
*/
|
||||
int dm_tree_node_add_raid_target_with_params_v2(struct dm_tree_node *node,
|
||||
uint64_t size,
|
||||
@@ -3869,7 +3768,7 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
|
||||
{
|
||||
struct dm_config_node *cn;
|
||||
struct load_segment *seg;
|
||||
const uint64_t modemask =
|
||||
static const uint64_t _modemask =
|
||||
DM_CACHE_FEATURE_PASSTHROUGH |
|
||||
DM_CACHE_FEATURE_WRITETHROUGH |
|
||||
DM_CACHE_FEATURE_WRITEBACK;
|
||||
@@ -3881,12 +3780,12 @@ int dm_tree_node_add_cache_target(struct dm_tree_node *node,
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (feature_flags & modemask) {
|
||||
switch (feature_flags & _modemask) {
|
||||
case DM_CACHE_FEATURE_PASSTHROUGH:
|
||||
case DM_CACHE_FEATURE_WRITEBACK:
|
||||
if (strcmp(policy_name, "cleaner") == 0) {
|
||||
/* Enforce writethrough mode for cleaner policy */
|
||||
feature_flags = ~modemask;
|
||||
feature_flags = ~_modemask;
|
||||
feature_flags |= DM_CACHE_FEATURE_WRITETHROUGH;
|
||||
}
|
||||
/* Fall through */
|
||||
@@ -4082,7 +3981,7 @@ int dm_tree_node_add_replicator_dev_target(struct dm_tree_node *node,
|
||||
uint32_t slog_flags,
|
||||
uint32_t slog_region_size)
|
||||
{
|
||||
log_error("Replicator target is unsupported.");
|
||||
log_error("Replicator targer is unsupported.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -4369,12 +4268,6 @@ int dm_tree_node_set_thin_external_origin(struct dm_tree_node *node,
|
||||
|
||||
seg->external = external;
|
||||
|
||||
if (!external->info.minor) {
|
||||
log_debug_activation("Delaying resume for new external origin %s.",
|
||||
external->name);
|
||||
external->props.delay_resume_if_new = 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@@ -223,6 +223,7 @@ retry_fcntl:
|
||||
}
|
||||
|
||||
/* coverity[leaked_handle] intentional leak of fd handle here */
|
||||
|
||||
return 1;
|
||||
|
||||
fail_close_unlink:
|
||||
|
@@ -153,7 +153,7 @@ struct op_def {
|
||||
* shorter one if one is a prefix of another!
|
||||
* (e.g. =~ comes before =)
|
||||
*/
|
||||
static const struct op_def _op_cmp[] = {
|
||||
static struct op_def _op_cmp[] = {
|
||||
{ "=~", FLD_CMP_REGEX, "Matching regular expression. [regex]" },
|
||||
{ "!~", FLD_CMP_REGEX|FLD_CMP_NOT, "Not matching regular expression. [regex]" },
|
||||
{ "=", FLD_CMP_EQUAL, "Equal to. [number, size, percent, string, string list, time]" },
|
||||
@@ -187,7 +187,7 @@ static const struct op_def _op_cmp[] = {
|
||||
#define SEL_LIST_SUBSET_LS 0x00040000
|
||||
#define SEL_LIST_SUBSET_LE 0x00080000
|
||||
|
||||
static const struct op_def _op_log[] = {
|
||||
static struct op_def _op_log[] = {
|
||||
{ "&&", SEL_AND, "All fields must match" },
|
||||
{ ",", SEL_AND, "All fields must match" },
|
||||
{ "||", SEL_OR, "At least one field must match" },
|
||||
@@ -459,7 +459,7 @@ static int _report_field_string_list(struct dm_report *rh,
|
||||
*
|
||||
* The very first item in the array of 'struct pos_len' is always
|
||||
* a pair denoting '[list_size,strlen(field->report_string)]'. The
|
||||
* rest of items denote start and length of each item in the list.
|
||||
* rest of items denote start and lenght of each item in the list.
|
||||
*
|
||||
*
|
||||
* For example, if we have a list with "abc", "xy", "defgh"
|
||||
@@ -796,11 +796,11 @@ static const char *_get_field_type_name(unsigned field_type)
|
||||
static size_t _get_longest_field_id_len(const struct dm_report_field_type *fields)
|
||||
{
|
||||
uint32_t f;
|
||||
size_t l, id_len = 0;
|
||||
size_t id_len = 0;
|
||||
|
||||
for (f = 0; fields[f].report_fn; f++)
|
||||
if ((l = strlen(fields[f].id)) > id_len)
|
||||
id_len = l;
|
||||
if (strlen(fields[f].id) > id_len)
|
||||
id_len = strlen(fields[f].id);
|
||||
|
||||
return id_len;
|
||||
}
|
||||
@@ -811,17 +811,16 @@ static void _display_fields_more(struct dm_report *rh,
|
||||
int display_field_types)
|
||||
{
|
||||
uint32_t f;
|
||||
size_t l;
|
||||
const struct dm_report_object_type *type;
|
||||
const char *desc, *last_desc = "";
|
||||
|
||||
for (f = 0; fields[f].report_fn; f++)
|
||||
if ((l = strlen(fields[f].id)) > id_len)
|
||||
id_len = l;
|
||||
if (strlen(fields[f].id) > id_len)
|
||||
id_len = strlen(fields[f].id);
|
||||
|
||||
for (type = rh->types; type->data_fn; type++)
|
||||
if ((l = strlen(type->prefix) + 3) > id_len)
|
||||
id_len = l;
|
||||
if (strlen(type->prefix) + 3 > id_len)
|
||||
id_len = strlen(type->prefix) + 3;
|
||||
|
||||
for (f = 0; fields[f].report_fn; f++) {
|
||||
if (!(type = _find_type(rh, fields[f].type))) {
|
||||
@@ -965,13 +964,16 @@ static int _get_canonical_field_name(const char *field,
|
||||
* Both names are always null-terminated.
|
||||
*/
|
||||
static int _is_same_field(const char *canonical_name1, const char *canonical_name2,
|
||||
const char *prefix, size_t prefix_len)
|
||||
const char *prefix)
|
||||
{
|
||||
size_t prefix_len;
|
||||
|
||||
/* Exact match? */
|
||||
if (!strcasecmp(canonical_name1, canonical_name2))
|
||||
return 1;
|
||||
|
||||
/* Match including prefix? */
|
||||
prefix_len = strlen(prefix) - 1;
|
||||
if (!strncasecmp(prefix, canonical_name1, prefix_len) &&
|
||||
!strcasecmp(canonical_name1 + prefix_len, canonical_name2))
|
||||
return 1;
|
||||
@@ -1047,7 +1049,6 @@ static int _get_field(struct dm_report *rh, const char *field, size_t flen,
|
||||
{
|
||||
char field_canon[DM_REPORT_FIELD_TYPE_ID_LEN];
|
||||
uint32_t f;
|
||||
size_t prefix_len;
|
||||
|
||||
if (!flen)
|
||||
return 0;
|
||||
@@ -1055,9 +1056,8 @@ static int _get_field(struct dm_report *rh, const char *field, size_t flen,
|
||||
if (!_get_canonical_field_name(field, flen, field_canon, sizeof(field_canon), NULL))
|
||||
return_0;
|
||||
|
||||
prefix_len = strlen(rh->field_prefix) - 1;
|
||||
for (f = 0; _implicit_report_fields[f].report_fn; f++) {
|
||||
if (_is_same_field(_implicit_report_fields[f].id, field_canon, rh->field_prefix, prefix_len)) {
|
||||
if (_is_same_field(_implicit_report_fields[f].id, field_canon, rh->field_prefix)) {
|
||||
*f_ret = f;
|
||||
*implicit = 1;
|
||||
return 1;
|
||||
@@ -1065,7 +1065,7 @@ static int _get_field(struct dm_report *rh, const char *field, size_t flen,
|
||||
}
|
||||
|
||||
for (f = 0; rh->fields[f].report_fn; f++) {
|
||||
if (_is_same_field(rh->canonical_field_ids[f], field_canon, rh->field_prefix, prefix_len)) {
|
||||
if (_is_same_field(rh->canonical_field_ids[f], field_canon, rh->field_prefix)) {
|
||||
*f_ret = f;
|
||||
*implicit = 0;
|
||||
return 1;
|
||||
@@ -1146,7 +1146,7 @@ static int _add_sort_key(struct dm_report *rh, uint32_t field_num, int implicit,
|
||||
static int _key_match(struct dm_report *rh, const char *key, size_t len,
|
||||
unsigned report_type_only)
|
||||
{
|
||||
int implicit;
|
||||
char key_canon[DM_REPORT_FIELD_TYPE_ID_LEN];
|
||||
uint32_t f;
|
||||
uint32_t flags;
|
||||
|
||||
@@ -1169,8 +1169,16 @@ static int _key_match(struct dm_report *rh, const char *key, size_t len,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (_get_field(rh, key, len, &f, &implicit))
|
||||
return _add_sort_key(rh, f, implicit, flags, report_type_only);
|
||||
if (!_get_canonical_field_name(key, len, key_canon, sizeof(key_canon), NULL))
|
||||
return_0;
|
||||
|
||||
for (f = 0; _implicit_report_fields[f].report_fn; f++)
|
||||
if (_is_same_field(_implicit_report_fields[f].id, key_canon, rh->field_prefix))
|
||||
return _add_sort_key(rh, f, 1, flags, report_type_only);
|
||||
|
||||
for (f = 0; rh->fields[f].report_fn; f++)
|
||||
if (_is_same_field(rh->canonical_field_ids[f], key_canon, rh->field_prefix))
|
||||
return _add_sort_key(rh, f, 0, flags, report_type_only);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1396,7 +1404,7 @@ struct dm_report *dm_report_init(uint32_t *report_types,
|
||||
}
|
||||
|
||||
/*
|
||||
* Return updated types value for further compatibility check by caller.
|
||||
* Return updated types value for further compatility check by caller.
|
||||
*/
|
||||
_dm_report_init_update_types(rh, report_types);
|
||||
|
||||
@@ -1453,14 +1461,9 @@ static void *_report_get_field_data(struct dm_report *rh,
|
||||
const struct dm_report_field_type *fields = fp->implicit ? _implicit_report_fields
|
||||
: rh->fields;
|
||||
|
||||
char *ret;
|
||||
char *ret = fp->type->data_fn(object);
|
||||
|
||||
if (!object) {
|
||||
log_error(INTERNAL_ERROR "_report_get_field_data: missing object.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(ret = fp->type->data_fn(object)))
|
||||
if (!ret)
|
||||
return NULL;
|
||||
|
||||
return (void *)(ret + fields[fp->field_num].offset);
|
||||
@@ -2261,7 +2264,7 @@ static const char * _skip_space(const char *s)
|
||||
return s;
|
||||
}
|
||||
|
||||
static int _tok_op(const struct op_def *t, const char *s, const char **end,
|
||||
static int _tok_op(struct op_def *t, const char *s, const char **end,
|
||||
uint32_t expect)
|
||||
{
|
||||
size_t len;
|
||||
@@ -2430,7 +2433,7 @@ static const char *_reserved_name(struct dm_report *rh,
|
||||
(reserved->type & DM_REPORT_FIELD_TYPE_MASK) ? "type-specific" : "field-specific",
|
||||
rh->fields[field_num].id);
|
||||
else
|
||||
log_error("Error occurred while processing %s reserved value handler for field %s",
|
||||
log_error("Error occured while processing %s reserved value handler for field %s",
|
||||
(reserved->type & DM_REPORT_FIELD_TYPE_MASK) ? "type-specific" : "field-specific",
|
||||
rh->fields[field_num].id);
|
||||
}
|
||||
@@ -2502,7 +2505,7 @@ float dm_percent_to_float(dm_percent_t percent)
|
||||
|
||||
float dm_percent_to_round_float(dm_percent_t percent, unsigned digits)
|
||||
{
|
||||
const float power10[] = {
|
||||
static const float power10[] = {
|
||||
1.f, .1f, .01f, .001f, .0001f, .00001f, .000001f,
|
||||
.0000001f, .00000001f, .000000001f,
|
||||
.0000000001f
|
||||
@@ -2568,12 +2571,12 @@ static int _check_reserved_values_supported(const struct dm_report_field_type fi
|
||||
const struct dm_report_reserved_value *iter;
|
||||
const struct dm_report_field_reserved_value *field_res;
|
||||
const struct dm_report_field_type *field;
|
||||
const uint32_t supported_reserved_types = DM_REPORT_FIELD_TYPE_NUMBER |
|
||||
static uint32_t supported_reserved_types = DM_REPORT_FIELD_TYPE_NUMBER |
|
||||
DM_REPORT_FIELD_TYPE_SIZE |
|
||||
DM_REPORT_FIELD_TYPE_PERCENT |
|
||||
DM_REPORT_FIELD_TYPE_STRING |
|
||||
DM_REPORT_FIELD_TYPE_TIME;
|
||||
const uint32_t supported_reserved_types_with_range = DM_REPORT_FIELD_RESERVED_VALUE_RANGE |
|
||||
static uint32_t supported_reserved_types_with_range = DM_REPORT_FIELD_RESERVED_VALUE_RANGE |
|
||||
DM_REPORT_FIELD_TYPE_NUMBER |
|
||||
DM_REPORT_FIELD_TYPE_SIZE |
|
||||
DM_REPORT_FIELD_TYPE_PERCENT |
|
||||
@@ -2589,8 +2592,7 @@ static int _check_reserved_values_supported(const struct dm_report_field_type fi
|
||||
if (iter->type & DM_REPORT_FIELD_TYPE_MASK) {
|
||||
if (!(iter->type & supported_reserved_types) ||
|
||||
((iter->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE) &&
|
||||
!(iter->type & (supported_reserved_types_with_range &
|
||||
~DM_REPORT_FIELD_RESERVED_VALUE_RANGE)))) {
|
||||
!(iter->type & supported_reserved_types_with_range))) {
|
||||
log_error(INTERNAL_ERROR "_check_reserved_values_supported: "
|
||||
"global reserved value for type 0x%x not supported",
|
||||
iter->type);
|
||||
@@ -2600,9 +2602,8 @@ static int _check_reserved_values_supported(const struct dm_report_field_type fi
|
||||
field_res = (const struct dm_report_field_reserved_value *) iter->value;
|
||||
field = &fields[field_res->field_num];
|
||||
if (!(field->flags & supported_reserved_types) ||
|
||||
((field->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE) &&
|
||||
!(field->type & (supported_reserved_types_with_range &
|
||||
~DM_REPORT_FIELD_RESERVED_VALUE_RANGE)))) {
|
||||
((iter->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE) &&
|
||||
!(iter->type & supported_reserved_types_with_range))) {
|
||||
log_error(INTERNAL_ERROR "_check_reserved_values_supported: "
|
||||
"field-specific reserved value of type 0x%x for "
|
||||
"field %s not supported",
|
||||
@@ -2842,7 +2843,7 @@ struct time_value {
|
||||
time_t t2;
|
||||
};
|
||||
|
||||
static const char _out_of_range_msg[] = "Field selection value %s out of supported range for field %s.";
|
||||
static const char *_out_of_range_msg = "Field selection value %s out of supported range for field %s.";
|
||||
|
||||
/*
|
||||
* Standard formatted date and time - ISO8601.
|
||||
@@ -2867,7 +2868,7 @@ static const char _out_of_range_msg[] = "Field selection value %s out of support
|
||||
#define DELIM_DATE '-'
|
||||
#define DELIM_TIME ':'
|
||||
|
||||
static const int _days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
static int _days_in_month[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
|
||||
|
||||
static int _is_leap_year(long year)
|
||||
{
|
||||
@@ -2892,6 +2893,7 @@ typedef enum {
|
||||
|
||||
static char *_get_date(char *str, struct tm *tm, time_range_t *range)
|
||||
{
|
||||
static const char incorrect_date_format_msg[] = "Incorrect date format.";
|
||||
time_range_t tmp_range = RANGE_NONE;
|
||||
long n1, n2 = -1, n3 = -1;
|
||||
char *s = str, *end;
|
||||
@@ -2937,15 +2939,19 @@ static char *_get_date(char *str, struct tm *tm, time_range_t *range)
|
||||
n3 = n1 % 100;
|
||||
n2 = (n1 / 100) % 100;
|
||||
n1 = n1 / 10000;
|
||||
} else
|
||||
goto_bad;
|
||||
} else {
|
||||
log_error(incorrect_date_format_msg);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
if (len == 7) {
|
||||
tmp_range = RANGE_MONTH;
|
||||
/* YYYY-MM */
|
||||
n3 = 1;
|
||||
} else
|
||||
goto_bad;
|
||||
} else {
|
||||
log_error(incorrect_date_format_msg);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2968,15 +2974,11 @@ static char *_get_date(char *str, struct tm *tm, time_range_t *range)
|
||||
*range = tmp_range;
|
||||
|
||||
return (char *) _skip_space(end);
|
||||
|
||||
bad:
|
||||
log_error("Incorrect date format.");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char *_get_time(char *str, struct tm *tm, time_range_t *range)
|
||||
{
|
||||
static const char incorrect_time_format_msg[] = "Incorrect time format.";
|
||||
time_range_t tmp_range = RANGE_NONE;
|
||||
long n1, n2 = -1, n3 = -1;
|
||||
char *s = str, *end;
|
||||
@@ -3024,15 +3026,19 @@ static char *_get_time(char *str, struct tm *tm, time_range_t *range)
|
||||
n3 = n1 % 100;
|
||||
n2 = (n1 / 100) % 100;
|
||||
n1 = n1 / 10000;
|
||||
} else
|
||||
goto_bad;
|
||||
} else {
|
||||
log_error(incorrect_time_format_msg);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
if (len == 5) {
|
||||
/* HH:MM */
|
||||
tmp_range = RANGE_MINUTE;
|
||||
n3 = 0;
|
||||
} else
|
||||
goto_bad;
|
||||
} else {
|
||||
log_error(incorrect_time_format_msg);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3063,11 +3069,6 @@ static char *_get_time(char *str, struct tm *tm, time_range_t *range)
|
||||
*range = tmp_range;
|
||||
|
||||
return (char *) _skip_space(end);
|
||||
|
||||
bad:
|
||||
log_error("Incorrect time format.");
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* The offset is always an absolute offset against GMT! */
|
||||
@@ -3496,7 +3497,7 @@ static int _get_reserved_value(struct dm_report *rh, uint32_t field_num,
|
||||
(rvw->reserved->type) & DM_REPORT_FIELD_TYPE_MASK ? "type-specific" : "field-specific",
|
||||
rh->fields[field_num].id);
|
||||
else
|
||||
log_error("Error occurred while processing %s reserved value handler for field %s",
|
||||
log_error("Error occured while processing %s reserved value handler for field %s",
|
||||
(rvw->reserved->type) & DM_REPORT_FIELD_TYPE_MASK ? "type-specific" : "field-specific",
|
||||
rh->fields[field_num].id);
|
||||
return 0;
|
||||
@@ -3516,6 +3517,7 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
|
||||
struct reserved_value_wrapper *rvw,
|
||||
void *custom)
|
||||
{
|
||||
static const char *_field_selection_value_alloc_failed_msg = "dm_report: struct field_selection_value allocation failed for selection field %s";
|
||||
const struct dm_report_field_type *fields = implicit ? _implicit_report_fields
|
||||
: rh->fields;
|
||||
struct field_properties *fp, *found = NULL;
|
||||
@@ -3563,8 +3565,8 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
|
||||
}
|
||||
|
||||
if (!(fs->value = dm_pool_zalloc(rh->selection->mem, sizeof(struct field_selection_value)))) {
|
||||
stack;
|
||||
goto error_field_id;
|
||||
log_error(_field_selection_value_alloc_failed_msg, field_id);
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (((rvw->reserved && (rvw->reserved->type & DM_REPORT_FIELD_RESERVED_VALUE_RANGE)) ||
|
||||
@@ -3572,8 +3574,8 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
|
||||
custom && ((struct time_value *) custom)->range))
|
||||
&&
|
||||
!(fs->value->next = dm_pool_zalloc(rh->selection->mem, sizeof(struct field_selection_value)))) {
|
||||
stack;
|
||||
goto error_field_id;
|
||||
log_error(_field_selection_value_alloc_failed_msg, field_id);
|
||||
goto error;
|
||||
}
|
||||
|
||||
fs->fp = found;
|
||||
@@ -3722,12 +3724,8 @@ static struct field_selection *_create_field_selection(struct dm_report *rh,
|
||||
}
|
||||
|
||||
return fs;
|
||||
error_field_id:
|
||||
log_error("dm_report: struct field_selection_value allocation failed for selection field %s",
|
||||
field_id);
|
||||
goto error;
|
||||
bad:
|
||||
log_error(INTERNAL_ERROR "Forbidden NULL custom detected.");
|
||||
log_error(INTERNAL_ERROR "Forbiden NULL custom detected.");
|
||||
error:
|
||||
dm_pool_free(rh->selection->mem, fs);
|
||||
|
||||
@@ -3754,7 +3752,7 @@ static struct selection_node *_alloc_selection_node(struct dm_pool *mem, uint32_
|
||||
static void _display_selection_help(struct dm_report *rh)
|
||||
{
|
||||
static const char _grow_object_failed_msg[] = "_display_selection_help: dm_pool_grow_object failed";
|
||||
const struct op_def *t;
|
||||
struct op_def *t;
|
||||
const struct dm_report_reserved_value *rv;
|
||||
size_t len_all, len_final = 0;
|
||||
const char **rvs;
|
||||
@@ -4025,7 +4023,7 @@ error:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* AND_EXPRESSION := EX (AND_OP AND_EXPRESSION) */
|
||||
/* AND_EXPRESSION := EX (AND_OP AND_EXPRSSION) */
|
||||
static struct selection_node *_parse_and_ex(struct dm_report *rh,
|
||||
const char *s,
|
||||
const char **next,
|
||||
@@ -4107,7 +4105,7 @@ static int _alloc_rh_selection(struct dm_report *rh)
|
||||
static int _report_set_selection(struct dm_report *rh, const char *selection, int add_new_fields)
|
||||
{
|
||||
struct selection_node *root = NULL;
|
||||
const char *fin = NULL, *next;
|
||||
const char *fin, *next;
|
||||
|
||||
if (rh->selection) {
|
||||
if (rh->selection->selection_root)
|
||||
@@ -4127,7 +4125,7 @@ static int _report_set_selection(struct dm_report *rh, const char *selection, in
|
||||
if (!(root = _alloc_selection_node(rh->selection->mem, SEL_OR)))
|
||||
return 0;
|
||||
|
||||
if (!_parse_or_ex(rh, selection, &fin, root) || !fin)
|
||||
if (!_parse_or_ex(rh, selection, &fin, root))
|
||||
goto_bad;
|
||||
|
||||
next = _skip_space(fin);
|
||||
@@ -4265,9 +4263,7 @@ static int _report_headings(struct dm_report *rh)
|
||||
|
||||
fields = fp->implicit ? _implicit_report_fields : rh->fields;
|
||||
|
||||
heading = rh->flags & DM_REPORT_OUTPUT_FIELD_IDS_IN_HEADINGS ?
|
||||
fields[fp->field_num].id : fields[fp->field_num].heading;
|
||||
|
||||
heading = fields[fp->field_num].heading;
|
||||
if (rh->flags & DM_REPORT_OUTPUT_ALIGNED) {
|
||||
if (dm_snprintf(buf, buf_size, "%-*.*s",
|
||||
fp->width, fp->width, heading) < 0) {
|
||||
@@ -4319,7 +4315,6 @@ static void _recalculate_fields(struct dm_report *rh)
|
||||
struct row *row;
|
||||
struct dm_report_field *field;
|
||||
int len;
|
||||
int id_len;
|
||||
|
||||
dm_list_iterate_items(row, &rh->rows) {
|
||||
dm_list_iterate_items(field, &row->fields) {
|
||||
@@ -4334,12 +4329,6 @@ static void _recalculate_fields(struct dm_report *rh)
|
||||
field->props->width = len;
|
||||
|
||||
}
|
||||
|
||||
if (rh->flags & DM_REPORT_OUTPUT_FIELD_IDS_IN_HEADINGS) {
|
||||
id_len = (int) strlen(rh->fields[field->props->field_num].id);
|
||||
if (field->props->width < id_len)
|
||||
field->props->width = id_len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4426,9 +4415,8 @@ static int _sort_rows(struct dm_report *rh)
|
||||
qsort(rows, count, sizeof(**rows), _row_compare);
|
||||
|
||||
dm_list_init(&rh->rows);
|
||||
|
||||
while (count > 0)
|
||||
dm_list_add_h(&rh->rows, &(*rows)[--count]->list);
|
||||
while (count--)
|
||||
dm_list_add_h(&rh->rows, &(*rows)[count]->list);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -4752,13 +4740,10 @@ static int _output_as_rows(struct dm_report *rh)
|
||||
struct field_properties *fp;
|
||||
struct dm_report_field *field;
|
||||
struct row *row;
|
||||
const char *heading;
|
||||
|
||||
dm_list_iterate_items(fp, &rh->field_props) {
|
||||
if (fp->flags & FLD_HIDDEN) {
|
||||
dm_list_iterate_items(row, &rh->rows) {
|
||||
if (dm_list_empty(&row->fields))
|
||||
continue;
|
||||
field = dm_list_item(dm_list_first(&row->fields), struct dm_report_field);
|
||||
dm_list_del(&field->list);
|
||||
}
|
||||
@@ -4773,10 +4758,7 @@ static int _output_as_rows(struct dm_report *rh)
|
||||
}
|
||||
|
||||
if ((rh->flags & DM_REPORT_OUTPUT_HEADINGS)) {
|
||||
heading = rh->flags & DM_REPORT_OUTPUT_FIELD_IDS_IN_HEADINGS ?
|
||||
fields[fp->field_num].id : fields[fp->field_num].heading;
|
||||
|
||||
if (!dm_pool_grow_object(rh->mem, heading, 0)) {
|
||||
if (!dm_pool_grow_object(rh->mem, fields[fp->field_num].heading, 0)) {
|
||||
log_error("dm_report: Failed to extend row for field name");
|
||||
goto bad;
|
||||
}
|
||||
@@ -4816,36 +4798,12 @@ static int _output_as_rows(struct dm_report *rh)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct dm_list *_get_last_displayed_rowh(struct dm_report *rh)
|
||||
{
|
||||
struct dm_list *rowh;
|
||||
struct row *row;
|
||||
|
||||
/*
|
||||
* We need to find 'last displayed row', not just 'last row'.
|
||||
*
|
||||
* This is because the report may be marked with
|
||||
* DM_REPORT_OUTPUT_MULTIPLE_TIMES flag. In that case, the report
|
||||
* may be used more than once and with different selection
|
||||
* criteria each time. Therefore, such report may also contain
|
||||
* rows which we do not display on output with current selection
|
||||
* criteria.
|
||||
*/
|
||||
for (rowh = dm_list_last(&rh->rows); rowh; rowh = dm_list_prev(&rh->rows, rowh)) {
|
||||
row = dm_list_item(rowh, struct row);
|
||||
if (_should_display_row(row))
|
||||
return rowh;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int _output_as_columns(struct dm_report *rh)
|
||||
{
|
||||
struct dm_list *fh, *rowh, *ftmp, *rtmp;
|
||||
struct row *row = NULL;
|
||||
struct dm_report_field *field;
|
||||
struct dm_list *last_rowh;
|
||||
struct dm_list *last_row;
|
||||
int do_field_delim;
|
||||
char *line;
|
||||
|
||||
@@ -4854,7 +4812,7 @@ static int _output_as_columns(struct dm_report *rh)
|
||||
_report_headings(rh);
|
||||
|
||||
/* Print and clear buffer */
|
||||
last_rowh = _get_last_displayed_rowh(rh);
|
||||
last_row = dm_list_last(&rh->rows);
|
||||
dm_list_iterate_safe(rowh, rtmp, &rh->rows) {
|
||||
row = dm_list_item(rowh, struct row);
|
||||
|
||||
@@ -4908,7 +4866,7 @@ static int _output_as_columns(struct dm_report *rh)
|
||||
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||
goto bad;
|
||||
}
|
||||
if (rowh != last_rowh &&
|
||||
if (rowh != last_row &&
|
||||
!dm_pool_grow_object(rh->mem, JSON_SEPARATOR, 0)) {
|
||||
log_error(UNABLE_TO_EXTEND_OUTPUT_LINE_MSG);
|
||||
goto bad;
|
||||
@@ -5105,7 +5063,7 @@ struct dm_report_group *dm_report_group_create(dm_report_group_type_t type, void
|
||||
dm_list_init(&group->items);
|
||||
|
||||
if (!(item = dm_pool_zalloc(mem, sizeof(*item)))) {
|
||||
log_error("dm_report: failed to allocate root report group item");
|
||||
log_error("dm_report: faile to allocate root report group item");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
|
@@ -192,7 +192,7 @@ int dm_asprintf(char **result, const char *format, ...)
|
||||
}
|
||||
|
||||
/*
|
||||
* Count occurrences of 'c' in 'str' until we reach a null char.
|
||||
* Count occurences of 'c' in 'str' until we reach a null char.
|
||||
*
|
||||
* Returns:
|
||||
* len - incremented for each char we encounter.
|
||||
@@ -385,7 +385,7 @@ char *dm_build_dm_uuid(struct dm_pool *mem, const char *uuid_prefix, const char
|
||||
return NULL;
|
||||
}
|
||||
|
||||
snprintf(dmuuid, len, "%s%s%s%s", uuid_prefix, lvid, (*layer) ? "-" : "", layer);
|
||||
sprintf(dmuuid, "%s%s%s%s", uuid_prefix, lvid, (*layer) ? "-" : "", layer);
|
||||
|
||||
return dmuuid;
|
||||
}
|
||||
@@ -552,7 +552,7 @@ const char *dm_size_to_string(struct dm_pool *mem, uint64_t size,
|
||||
if (size == UINT64_C(0)) {
|
||||
if (base == BASE_UNKNOWN)
|
||||
s = 0;
|
||||
snprintf(size_buf, SIZE_BUF, "0%s", include_suffix ? size_str[base + s][suffix_type] : "");
|
||||
sprintf(size_buf, "0%s", include_suffix ? size_str[base + s][suffix_type] : "");
|
||||
return size_buf;
|
||||
}
|
||||
|
||||
|
@@ -106,31 +106,26 @@ int dm_get_status_raid(struct dm_pool *mem, const char *params,
|
||||
|
||||
/* Second field holds the device count */
|
||||
msg_fields = "<#devs> ";
|
||||
if (!(pp = _skip_fields(params, 1)) || (sscanf(pp, "%d", &i) != 1) || !(p = _skip_fields(pp, 1)))
|
||||
if (!(p = _skip_fields(params, 1)) || (sscanf(p, "%d", &i) != 1))
|
||||
goto_bad;
|
||||
|
||||
msg_fields = "";
|
||||
if (!(s = dm_pool_zalloc(mem, sizeof(struct dm_status_raid))))
|
||||
goto_bad;
|
||||
|
||||
msg_fields = "<raid_type> <#devices> <health_chars> and <sync_ratio> ";
|
||||
if (!(s->raid_type = dm_pool_strndup(mem, params, pp - params - 1)))
|
||||
if (!(s->raid_type = dm_pool_zalloc(mem, p - params)))
|
||||
goto_bad; /* memory is freed when pool is destroyed */
|
||||
|
||||
if (!(pp = _skip_fields(p, 1)))
|
||||
if (!(s->dev_health = dm_pool_zalloc(mem, i + 1))) /* Space for health chars */
|
||||
goto_bad;
|
||||
|
||||
/* Raid target can actually report more then real number of legs in a case
|
||||
* raid legs have been removed during initial raid array resynchronization */
|
||||
if (i > (pp - p - 1))
|
||||
i = pp - p - 1;
|
||||
|
||||
if (!(s->dev_health = dm_pool_strndup(mem, p, i))) /* health chars */
|
||||
goto_bad;
|
||||
p = pp;
|
||||
|
||||
s->dev_count = i;
|
||||
if (sscanf(p, FMTu64 "/" FMTu64, &s->insync_regions, &s->total_regions) != 2)
|
||||
msg_fields = "<raid_type> <#devices> <health_chars> and <sync_ratio> ";
|
||||
if (sscanf(params, "%s %u %s " FMTu64 "/" FMTu64,
|
||||
s->raid_type,
|
||||
&s->dev_count,
|
||||
s->dev_health,
|
||||
&s->insync_regions,
|
||||
&s->total_regions) != 5)
|
||||
goto_bad;
|
||||
|
||||
/*
|
||||
@@ -146,13 +141,13 @@ int dm_get_status_raid(struct dm_pool *mem, const char *params,
|
||||
msg_fields = "<sync_action> and <mismatch_cnt> ";
|
||||
|
||||
/* Skip pre-1.5.0 params */
|
||||
if (!(pp = _skip_fields(params, 4)) || !(p = _skip_fields(pp, 1)))
|
||||
if (!(p = _skip_fields(params, 4)) || !(pp = _skip_fields(p, 1)))
|
||||
goto_bad;
|
||||
|
||||
if (!(s->sync_action = dm_pool_strndup(mem, pp, p - pp - 1)))
|
||||
if (!(s->sync_action = dm_pool_zalloc(mem, pp - p)))
|
||||
goto_bad;
|
||||
|
||||
if (sscanf(p, FMTu64, &s->mismatch_count) != 1)
|
||||
if (sscanf(p, "%s " FMTu64, s->sync_action, &s->mismatch_count) != 2)
|
||||
goto_bad;
|
||||
|
||||
if (num_fields < 7)
|
||||
@@ -171,35 +166,23 @@ int dm_get_status_raid(struct dm_pool *mem, const char *params,
|
||||
if (sscanf(p, FMTu64, &s->data_offset) != 1)
|
||||
goto bad;
|
||||
|
||||
/* <journal_char> - 'A' - active write-through journal device.
|
||||
* - 'a' - active write-back journal device.
|
||||
* - 'D' - dead journal device.
|
||||
* - '-' - no journal device.
|
||||
*/
|
||||
|
||||
out:
|
||||
*status = s;
|
||||
|
||||
while (i-- > 0)
|
||||
if (s->dev_health[i] == 'a')
|
||||
a++; /* Count number of 'a' */
|
||||
if (s->insync_regions == s->total_regions) {
|
||||
/* FIXME: kernel gives misleading info here
|
||||
* Trying to recognize a true state */
|
||||
while (i-- > 0)
|
||||
if (s->dev_health[i] == 'a')
|
||||
a++; /* Count number of 'a' */
|
||||
|
||||
if (a) {
|
||||
if ((a < s->dev_count) && /* SOME legs are in 'a' */
|
||||
/* FIXME: kernel gives misleading info here
|
||||
* Trying to recognize a true state */
|
||||
(s->insync_regions == s->total_regions) &&
|
||||
(!strcasecmp(s->sync_action, "recover") ||
|
||||
!strcasecmp(s->sync_action, "idle"))) {
|
||||
/* Kernel may possibly start some action
|
||||
* in near-by future, do not report 100% */
|
||||
s->insync_regions--;
|
||||
}
|
||||
if ((a == s->dev_count) && /* all legs are in 'a' */
|
||||
(!strcasecmp(s->sync_action, "resync") ||
|
||||
!strcasecmp(s->sync_action, "idle"))) {
|
||||
/* Mark 1st. leg in sync */
|
||||
s->dev_health[0] = 'A';
|
||||
if (a && a < s->dev_count) {
|
||||
/* SOME legs are in 'a' */
|
||||
if (!strcasecmp(s->sync_action, "recover")
|
||||
|| !strcasecmp(s->sync_action, "idle"))
|
||||
/* Kernel may possibly start some action
|
||||
* in near-by future, do not report 100% */
|
||||
s->insync_regions--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -528,21 +511,6 @@ int dm_get_status_thin(struct dm_pool *mem, const char *params,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static dm_status_mirror_health_t _get_health(char c)
|
||||
{
|
||||
switch (c) {
|
||||
case 'A': return DM_STATUS_MIRROR_ALIVE;
|
||||
case 'F': return DM_STATUS_MIRROR_FLUSH_FAILED;
|
||||
case 'D': return DM_STATUS_MIRROR_WRITE_FAILED;
|
||||
case 'S': return DM_STATUS_MIRROR_SYNC_FAILED;
|
||||
case 'R': return DM_STATUS_MIRROR_READ_FAILED;
|
||||
default:
|
||||
log_warn("WARNING: Unknown mirror health status char: %c", c);
|
||||
/* fall through */
|
||||
case 'U': return DM_STATUS_MIRROR_UNCLASSIFIED;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* dm core parms: 0 409600 mirror
|
||||
* Mirror core parms: 2 253:4 253:5 400/400
|
||||
@@ -596,7 +564,7 @@ int dm_get_status_mirror(struct dm_pool *mem, const char *params,
|
||||
pos += used;
|
||||
|
||||
for (i = 0; i < num_devs ; ++i)
|
||||
s->devs[i].health = _get_health(pos[i]);
|
||||
s->devs[i].health = pos[i];
|
||||
|
||||
if (!(pos = _skip_fields(pos, argc)))
|
||||
goto_out;
|
||||
@@ -641,7 +609,7 @@ int dm_get_status_mirror(struct dm_pool *mem, const char *params,
|
||||
goto_out;
|
||||
|
||||
for (i = 0; i < s->log_count; ++i)
|
||||
s->logs[i].health = _get_health(pos[i]);
|
||||
s->logs[i].health = pos[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -209,7 +209,7 @@ struct dm_name_list {
|
||||
};
|
||||
|
||||
#define DM_NAME_LIST_FLAG_HAS_UUID 1
|
||||
#define DM_NAME_LIST_FLAG_DOES_NOT_HAVE_UUID 2
|
||||
#define DM_NAME_LIST_FLAG_DOESNT_HAVE_UUID 2
|
||||
|
||||
/*
|
||||
* Used to retrieve the target versions
|
||||
|
@@ -62,7 +62,7 @@
|
||||
*
|
||||
* The UUID contained in the dm_ulog_request structure is the reference that
|
||||
* will be used by all request types to a specific log. The constructor must
|
||||
* record this association with the instance created.
|
||||
* record this assotiation with the instance created.
|
||||
*
|
||||
* When the request has been processed, user-space must return the
|
||||
* dm_ulog_request to the kernel - setting the 'error' field, filling the
|
||||
|
@@ -129,7 +129,7 @@ int dm_pool_locked(struct dm_pool *p)
|
||||
* Bool specifies whether to store the pool crc/hash checksum.
|
||||
*
|
||||
* \return
|
||||
* 1 (success) when the pool was properly locked, 0 otherwise.
|
||||
* 1 (success) when the pool was preperly locked, 0 otherwise.
|
||||
*/
|
||||
int dm_pool_lock(struct dm_pool *p, int crc)
|
||||
{
|
||||
|
@@ -81,6 +81,7 @@ struct dm_vdo_target_params {
|
||||
uint32_t block_map_era_length; // format period
|
||||
uint32_t block_map_period; // supported alias
|
||||
};
|
||||
uint32_t check_point_frequency;
|
||||
uint32_t index_memory_size_mb; // format
|
||||
|
||||
uint32_t slab_size_mb; // format
|
||||
|
@@ -128,15 +128,7 @@ struct vdo_volume_geometry {
|
||||
struct vdo_index_config index_config;
|
||||
} __packed;
|
||||
|
||||
struct vdo_volume_geometry_4 {
|
||||
uint32_t release_version;
|
||||
uint64_t nonce;
|
||||
uuid_t uuid;
|
||||
struct vdo_volume_region regions[VDO_VOLUME_REGION_COUNT];
|
||||
struct vdo_index_config index_config;
|
||||
} __packed;
|
||||
|
||||
/* Decoding mostly only some used structure members */
|
||||
/* Decoding mostly only some used stucture members */
|
||||
|
||||
static void _vdo_decode_version(struct vdo_version_number *v)
|
||||
{
|
||||
@@ -154,24 +146,13 @@ static void _vdo_decode_header(struct vdo_header *h)
|
||||
static void _vdo_decode_geometry_region(struct vdo_volume_region *vr)
|
||||
{
|
||||
vr->id = le32_to_cpu(vr->id);
|
||||
vr->start_block = le64_to_cpu(vr->start_block);
|
||||
vr->start_block = le32_to_cpu(vr->start_block);
|
||||
}
|
||||
|
||||
static void _vdo_decode_volume_geometry(struct vdo_volume_geometry *vg)
|
||||
{
|
||||
vg->release_version = le32_to_cpu(vg->release_version);
|
||||
vg->release_version = le64_to_cpu(vg->release_version);
|
||||
vg->nonce = le64_to_cpu(vg->nonce);
|
||||
vg->bio_offset = le64_to_cpu(vg->bio_offset);
|
||||
_vdo_decode_geometry_region(&vg->regions[VDO_DATA_REGION]);
|
||||
}
|
||||
|
||||
static void _vdo_decode_volume_geometry_4(struct vdo_volume_geometry *vg,
|
||||
struct vdo_volume_geometry_4 *vg_4)
|
||||
{
|
||||
vg->release_version = le32_to_cpu(vg_4->release_version);
|
||||
vg->nonce = le64_to_cpu(vg_4->nonce);
|
||||
vg->bio_offset = 0;
|
||||
vg->regions[VDO_DATA_REGION] = vg_4->regions[VDO_DATA_REGION];
|
||||
_vdo_decode_geometry_region(&vg->regions[VDO_DATA_REGION]);
|
||||
}
|
||||
|
||||
@@ -193,8 +174,9 @@ static void _vdo_decode_pvc(struct vdo_component_41_0 *pvc)
|
||||
bool dm_vdo_parse_logical_size(const char *vdo_path, uint64_t *logical_blocks)
|
||||
{
|
||||
char buffer[4096];
|
||||
int fh;
|
||||
int fh, n;
|
||||
bool r = false;
|
||||
off_t l;
|
||||
struct stat st;
|
||||
uint64_t size;
|
||||
uint64_t regpos;
|
||||
@@ -202,7 +184,6 @@ bool dm_vdo_parse_logical_size(const char *vdo_path, uint64_t *logical_blocks)
|
||||
struct vdo_header h;
|
||||
struct vdo_version_number vn;
|
||||
struct vdo_volume_geometry vg;
|
||||
struct vdo_volume_geometry_4 vg_4;
|
||||
struct vdo_component_41_0 pvc;
|
||||
|
||||
*logical_blocks = 0;
|
||||
@@ -226,7 +207,7 @@ bool dm_vdo_parse_logical_size(const char *vdo_path, uint64_t *logical_blocks)
|
||||
size = st.st_size;
|
||||
}
|
||||
|
||||
if (read(fh, buffer, sizeof(buffer)) < 0) {
|
||||
if ((n = read(fh, buffer, sizeof(buffer))) < 0) {
|
||||
log_sys_debug("read", vdo_path);
|
||||
goto err;
|
||||
}
|
||||
@@ -239,42 +220,32 @@ bool dm_vdo_parse_logical_size(const char *vdo_path, uint64_t *logical_blocks)
|
||||
memcpy(&h, buffer + MAGIC_NUMBER_SIZE, sizeof(h));
|
||||
_vdo_decode_header(&h);
|
||||
|
||||
if (h.id != 5) {
|
||||
log_debug_activation("Expected geometry VDO block instead of block %u.", h.id);
|
||||
goto err;
|
||||
}
|
||||
|
||||
switch (h.version.major_version) {
|
||||
case 4:
|
||||
memcpy(&vg_4, buffer + MAGIC_NUMBER_SIZE + sizeof(h), sizeof(vg_4));
|
||||
_vdo_decode_volume_geometry_4(&vg, &vg_4);
|
||||
break;
|
||||
case 5:
|
||||
memcpy(&vg, buffer + MAGIC_NUMBER_SIZE + sizeof(h), sizeof(vg));
|
||||
_vdo_decode_volume_geometry(&vg);
|
||||
break;
|
||||
default:
|
||||
if (h.version.major_version != 5) {
|
||||
log_debug_activation("Unsupported VDO version %u.%u.", h.version.major_version, h.version.minor_version);
|
||||
goto err;
|
||||
}
|
||||
|
||||
regpos = (vg.regions[VDO_DATA_REGION].start_block - vg.bio_offset) * 4096;
|
||||
memcpy(&vg, buffer + MAGIC_NUMBER_SIZE + sizeof(h), sizeof(vg));
|
||||
_vdo_decode_volume_geometry(&vg);
|
||||
|
||||
regpos = vg.regions[VDO_DATA_REGION].start_block * 4096;
|
||||
|
||||
if ((regpos + sizeof(buffer)) > size) {
|
||||
log_debug_activation("File/Device is shorter and can't provide requested VDO volume region at " FMTu64 " > " FMTu64 ".", regpos, size);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (lseek(fh, regpos, SEEK_SET) < 0) {
|
||||
if ((l = lseek(fh, regpos, SEEK_SET)) < 0) {
|
||||
log_sys_debug("lseek", vdo_path);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (read(fh, buffer, sizeof(buffer)) < 0) {
|
||||
if ((n = read(fh, buffer, sizeof(buffer))) < 0) {
|
||||
log_sys_debug("read", vdo_path);
|
||||
goto err;
|
||||
}
|
||||
|
||||
|
||||
memcpy(&vn, buffer + sizeof(struct vdo_geometry_block), sizeof(vn));
|
||||
_vdo_decode_version(&vn);
|
||||
|
||||
|
@@ -1,24 +0,0 @@
|
||||
# Common problems
|
||||
|
||||
## Duplicate PVs in the system
|
||||
|
||||
LVM tries to detect the common sources of duplicates, mdadm RAID and multipath,
|
||||
there are cases where duplicate PV appears on the system.
|
||||
|
||||
There are two solutions to this problem:
|
||||
|
||||
* Setting a *global_filter* configuration option.
|
||||
* Using of *devices_file* (See [lvmdevices(8)](https://man7.org/linux/man-pages/man8/lvmdevices.8.html))
|
||||
|
||||
## Device Filtering
|
||||
|
||||
*filter* and *global_filter* are meant to be used in two ways:
|
||||
|
||||
* as an allow list, listing patterns for devices which will be accepted
|
||||
* `a|/dev/sdX|`, and rejecting the rest `r|.*|`,
|
||||
* as a reject list, listing only patterns for devices which will be rejected
|
||||
* `r|/dev/sdX|`,
|
||||
|
||||
Even though there are situations where it works, mixing reject and accept
|
||||
patterns is not recommended.
|
||||
|
@@ -1,34 +0,0 @@
|
||||
LVM2 Wiki Documentation
|
||||
=======================
|
||||
|
||||
If you are looking for information about LVM2 visit the [[Index]] page,
|
||||
|
||||
There are only some notes about writing stuff under *./doc* here:
|
||||
|
||||
* If possible use [[MarkDown]] for formatting, use *.md* (or *.mdwn*) suffix.
|
||||
* For linking between files, use [[IkiWiki]] syntax `[[FileName]]` or
|
||||
`[[FileName#Anchor]]`, or `[[link text|FileName]]`
|
||||
|
||||
Markdown
|
||||
--------
|
||||
|
||||
* Use `<!-- comment -->` to keep notes, which will not be rendered.
|
||||
* Use `[[TODO]]` for anything what needs attention. This will be accessible
|
||||
through the linked [[TODO]] page.
|
||||
|
||||
IkiWiki
|
||||
-------
|
||||
|
||||
* Install ikiwiki:
|
||||
|
||||
yum install ikiwiki
|
||||
|
||||
* To generate the content, run following in the LVM2 top directory:
|
||||
|
||||
ikiwiki --setup ikiwiki.setup
|
||||
|
||||
Internal Stuff:
|
||||
---------------
|
||||
|
||||
* [[TODO]] Can we have a section which is hidden by default? Like this one?
|
||||
* [[TODO]] Add basic IkiWiki and MarkDown How To.
|
152
doc/index.mdwn
152
doc/index.mdwn
@@ -1,152 +0,0 @@
|
||||
# LVM - Logical Volume Manager for Linux
|
||||
|
||||
<!--
|
||||
* TODO: Add banner for Important News: Critical Bugs, Important Announcements,...
|
||||
-->
|
||||
|
||||
<!--
|
||||
* TODO: Add a feed for latest articles/release-notes on the right
|
||||
-->
|
||||
|
||||
<!--
|
||||
## About LVM2
|
||||
-->
|
||||
LVM aka LVM2 refers to the userspace toolset that provide logical volume
|
||||
management facilities on linux.
|
||||
<!--
|
||||
It is reasonably backwards-compatible with the
|
||||
original LVM1 toolset.
|
||||
* TODO: Add information about LVM1 metadata format conversion!
|
||||
-->
|
||||
|
||||
LVM offers more flexibility than using partitions, allowing one to
|
||||
|
||||
* grow and, where supported by filesystem, shrink volumes,
|
||||
* create snapshots of existing volumes,
|
||||
* mirror data on multiple disks including RAID levels 5 or 6,
|
||||
* striping data on multiple disks,
|
||||
* create a read or write cache.
|
||||
|
||||
To use LVM2 you need 3 things:
|
||||
|
||||
* [device-mapper](https://sourceware.org/dm/) in your kernel (upstream since long ago)
|
||||
* the userspace device-mapper support library (*libdevmapper*) (part of lvm2)
|
||||
* and the userspace LVM2 tools.
|
||||
|
||||
## Getting LVM
|
||||
|
||||
Most of linux distribution offer packaged LVM tools.
|
||||
Depending on your distribution use
|
||||
|
||||
# RPM based distributions (Fedora):
|
||||
yum install lvm2
|
||||
# DEB based distributions (Debian, Ubuntu):
|
||||
apt-get install lvm2
|
||||
|
||||
Tarballs of the userspace LVM2 source code releases are available from [sourceware.org](https://sourceware.org/pub/lvm2/) [ftp](ftp://sourceware.org/pub/lvm2/).
|
||||
|
||||
List of official [mirror sites](https://sourceware.org/mirrors.html) (including http and rsync protocols).
|
||||
|
||||
### LVM Releases
|
||||
|
||||
[[!inline pages="release-notes/2.03.* and !*/template and !*/Discussion and !tagged(draft) and !tagged(pending)" limit=2 rootpage="release-notes"]]
|
||||
|
||||
[[More releases|release-notes/index]]
|
||||
|
||||
## Getting Started
|
||||
|
||||
<!--
|
||||
TODO: We are missing a lvm(7) man page explaining this, I think it would be a nic addition!
|
||||
And perhaps so would be a lvmtroubleshooting(7) guide.
|
||||
-->
|
||||
Word of warning first! Even though LVM errs on the side of data safety it is a
|
||||
tool with low level access and one may seriously harm their data when used
|
||||
incorrectly!
|
||||
|
||||
|
||||
* Physical Volume (PV) is underlying disk, local or remote, encrypted or even
|
||||
a mdadm RAID volume. PV is divided into so called Physical Extents (PE) which
|
||||
are a basic allocation unit.
|
||||
List PVs using [pvs(8)](https://man7.org/linux/man-pages/man8/pvs.8.html) or
|
||||
[pvdisplay(8)](https://man7.org/linux/man-pages/man8/pvdisplay.8.html).
|
||||
|
||||
Make one by running `pvcreate /dev/sdX`.
|
||||
See [pvcreate(8)](https://man7.org/linux/man-pages/man8/pvcreate.8.html). This step is optional.
|
||||
* Volume Group (VG) consisting of one or more PVs is used as a pool from which LVs are allocated.
|
||||
List VGs using [vgs(8)](https://man7.org/linux/man-pages/man8/vgs.8.html) or
|
||||
[vgdisplay(8)](https://man7.org/linux/man-pages/man8/vgdisplay.8.html).
|
||||
|
||||
Make one by running `vgcreate VGNAME /dev/sdX...`, add PVs to existing one by `vgextend VGNAME /dev/sdX`.
|
||||
To use LVM at least one Volume Group must be present on the system.
|
||||
See [vgcreate(8)](https://man7.org/linux/man-pages/man8/vgcreate.8.html), and
|
||||
[vgextend(8)](https://man7.org/linux/man-pages/man8/vgextend.8.html).
|
||||
* Logical Volume (LV) is the block device usually visible to user to be used for file system.
|
||||
List PVs using [lvs(8)](https://man7.org/linux/man-pages/man8/lvs.8.html) or
|
||||
[lvdisplay(8)](https://man7.org/linux/man-pages/man8/lvdisplay.8.html).
|
||||
|
||||
Make one by running `lvcreate [-n LVNAME] -L SIZE VGNAME`, and you are done!
|
||||
See [vgcreate(8)](https://man7.org/linux/man-pages/man8/vgcreate.8.html).
|
||||
|
||||
## Avoiding Problems
|
||||
|
||||
Good start is to avoid using `{--force|-f}` and `{--yes|-y}` options which are
|
||||
often seen on internet discussions.
|
||||
there is a possibility of data loss, LVM tools usually ask, so read the prompts
|
||||
carefully! Using `--yes` removes these safety.
|
||||
Also in some cases where it is too dangerous to proceed, e.g. device is used,
|
||||
LVM refuses to do so, which can be overridden by `--force`.
|
||||
|
||||
Second, when resizing and especially when shrinking LVs it is always a good
|
||||
idea to use `--resizefs` option which ensures the devices are resized in
|
||||
correct order.
|
||||
|
||||
Third, if you still make a mess, never ever run fsck on damaged LV/FS, this is
|
||||
usually the final blow to your data. It is always better to ask first!
|
||||
|
||||
|
||||
## Documentation
|
||||
|
||||
## Resolving Problems
|
||||
|
||||
* Backup if possible!
|
||||
* Search the problem first, check the list of [[common problems|Problems]]
|
||||
* Never run `fsck` on damaged LV, LV must be recovered first!
|
||||
* When asking for help describe exactly how the system got corrupted. It really
|
||||
does not help trying to cover one's mistakes in such situation, it takes
|
||||
longer to get help and also you are likely to get wrong answer making repair
|
||||
impossible.
|
||||
|
||||
## Reporting Bugs
|
||||
|
||||
* When you find a problem there is often something specific about your system.
|
||||
If the problem is reproducible run the failing command(s) with verbose flag
|
||||
`-vvvv` which gives developers clue where the problem might be.
|
||||
There is a [lvmdump(8)](https://man7.org/linux/man-pages/man8/lvmdump.8.html)
|
||||
tool to help collect data about your system, block devices and LVM setup.
|
||||
* Please report upstream bugs or request features in [Red Hat Bugzilla](https://bugzilla.redhat.com/enter_bug.cgi?product=LVM%20and%20device-mapper)
|
||||
|
||||
<!--
|
||||
TODO:
|
||||
* Add links to other documentation
|
||||
* Add links to git
|
||||
* Add links to mailing lists
|
||||
|
||||
* Resolving problems
|
||||
* Backup if possible!
|
||||
* Newer run fsck! Do the research first!
|
||||
* List of Common issues
|
||||
* Resizing in wrong order
|
||||
* Thin pool running out of space
|
||||
* Configuration - duplicates
|
||||
* Mailing list
|
||||
* IRC?
|
||||
|
||||
* Reporting Bugs
|
||||
* sosreport/lvmdump
|
||||
* BZ
|
||||
|
||||
* Contributing
|
||||
* gitlab MR
|
||||
|
||||
* Add latest articles
|
||||
-->
|
@@ -13,7 +13,7 @@ different targets were rolling their own data structures, for example:
|
||||
Maintaining these data structures takes a lot of work, so if possible
|
||||
we'd like to reduce the number.
|
||||
|
||||
The persistent-data library is an attempt to provide a reusable
|
||||
The persistent-data library is an attempt to provide a re-usable
|
||||
framework for people who want to store metadata in device-mapper
|
||||
targets. It's currently used by the thin-provisioning target and an
|
||||
upcoming hierarchical storage target.
|
||||
|
@@ -41,7 +41,7 @@ metadata.
|
||||
The zones of the device are separated into 2 types:
|
||||
|
||||
1) Metadata zones: these are conventional zones used to store metadata.
|
||||
Metadata zones are not reported as usable capacity to the user.
|
||||
Metadata zones are not reported as useable capacity to the user.
|
||||
|
||||
2) Data zones: all remaining zones, the vast majority of which will be
|
||||
sequential zones used exclusively to store user data. The conventional
|
||||
|
@@ -1,4 +0,0 @@
|
||||
.page {
|
||||
max-width: 1280px;
|
||||
margin: auto;
|
||||
}
|
@@ -86,7 +86,7 @@ are as follows:
|
||||
the policies outlined in the LVM configuration file - usually,
|
||||
/etc/lvm/lvm.conf. Once this operation is complete, the logical volumes
|
||||
will be consistent. However, the volume group will still be inconsistent -
|
||||
due to the referenced-but-missing device/PV - and operations will still be
|
||||
due to the refernced-but-missing device/PV - and operations will still be
|
||||
restricted to the aforementioned actions until either the device is
|
||||
restored or 'vgreduce --removemissing' is run.
|
||||
|
||||
|
@@ -108,7 +108,7 @@ really an orphan and enable its usage for creating or extending VGs. In
|
||||
practice, the decision might be governed by a timeout or assumed immediately --
|
||||
the former case is a little safer, the latter is probably more transparent. I
|
||||
am not very keen on using timeouts and we can probably assume that the admin
|
||||
won't blindly try to reuse devices in a way that would trip up LVM in this
|
||||
won't blindly try to re-use devices in a way that would trip up LVM in this
|
||||
respect. I would be in favour of just assuming that metadata-less VGs with no
|
||||
known referencing VGs are orphans -- after all, this is the same approach as we
|
||||
use today. The metadata balancing support may stress this a bit more than the
|
||||
@@ -153,7 +153,7 @@ Protocol & co.
|
||||
|
||||
I expect a simple text-based protocol executed on top of an Unix Domain Socket
|
||||
to be the communication interface for lvmetad. Ideally, the requests and
|
||||
replies will be well-formed "config file" style strings, so we can reuse
|
||||
replies will be well-formed "config file" style strings, so we can re-use
|
||||
existing parsing infrastructure.
|
||||
|
||||
Since we already have two daemons, I would probably look into factoring some
|
||||
|
@@ -56,7 +56,7 @@ Device mapper
|
||||
-------------
|
||||
|
||||
As well as the low level dm-ioctl driving code we need to have all our dm 'best
|
||||
practice' stuff in here. For instance this is the code that decides to use the
|
||||
practise' stuff in here. For instance this is the code that decides to use the
|
||||
mirror target to move some data around; that knows to suspend a thin volume
|
||||
before taking a snapshot of it. This module is going to have a lot more code
|
||||
in it than the current libdevmapper.
|
||||
@@ -150,7 +150,7 @@ interface to get round.
|
||||
'lib' is where the bulk of our code currently is. Dependency-wise the code is
|
||||
a bit like a ball of string. So splitting it up is going to take time. We can
|
||||
probably pull code pretty quickly into the 'metadata model' dir. But factoring
|
||||
out the dm best practices stuff is going to require splitting at least
|
||||
out the dm best practises stuff is going to require splitting at least
|
||||
files, and probably functions. Certainly not something that can be done in one
|
||||
go. System should just be a question of cherry picking functions.
|
||||
|
||||
|
@@ -51,5 +51,3 @@ In future optional target flags will be given in two situations:
|
||||
|
||||
This decision could well be contentious, so could distro maintainers feel
|
||||
free to comment.
|
||||
|
||||
[[!tag legacy]]
|
||||
|
@@ -1,76 +0,0 @@
|
||||
<!-- Page title -->
|
||||
[[!meta title="Version 2.03.24 - Feature and Bug Fix Release"]]
|
||||
|
||||
Version 2.03.24
|
||||
===============
|
||||
|
||||
* **Changes in udev rules, new version of systemd is recommended (256).**
|
||||
* **When using LVs as PVs these are no longer auto activated!**
|
||||
* Allow creating VDO device for thin data when creating thin pool.
|
||||
* More devices can be used as external origin for thin snapshot.
|
||||
* And [[!toggle text="more"]]
|
||||
|
||||
[[!toggleable text="""
|
||||
Features
|
||||
-----------------------
|
||||
|
||||
* Swap properties like hostname, date and time when swapping LVs.
|
||||
* Allow thin snapshot taken of thin volume from another pool as external origin.
|
||||
* Allow chaining of external origins.
|
||||
|
||||
### Changes to device handling
|
||||
|
||||
* **IMPORTANT:** When `devices/scan_lvs` is enabled found LVs are no longer auto
|
||||
activated, must enable `LVM_PVSCAN_ON_LVS` in udev rules (*69-dm-lvm.rules*.)
|
||||
* NOTE: It is not recommended to use LVs for PVs. If you have an use case for
|
||||
this talk to us, please.
|
||||
* Changes to devices file are now backed up in */etc/lvm/devices/backup/*.
|
||||
Controlled by `devices/devicesfile_backup_limit` configuration option.
|
||||
* When `devices/use_devicesfile` is set to `0` existing file is renamed to
|
||||
*system.devices-unused.YYYYMMDD.HHMMSS* to prevent outdated file to be used
|
||||
on reenabling.
|
||||
|
||||
### Use VDO device for thin pool's data
|
||||
|
||||
New option `--pooldatavdo` during lvcreate or lvconvert allows using VDO as backing device.
|
||||
|
||||
More options (`--compression {y|n}`, `--deduplication {y|n}`,
|
||||
`--vdosettings STRING`) to control the options are supported by these commands.
|
||||
|
||||
Example of converting a *lvol1* to a thin pool with enabled compression and deduplication:
|
||||
|
||||
lvconvert --type thin-pool --pooldatavdo y vg/lvol1
|
||||
|
||||
Changes in command line
|
||||
-----------------------
|
||||
|
||||
* Add *--wipesignature* option controlling signature wiping when converting volume to thin-pool.
|
||||
* Allow *lvcreate --snapshot* without *{-T|--thin}* option when creating snapshot of a thin volume.
|
||||
* Allow *--raidintegrity{,mode,blocksize}* options with implicit RAID1 (i.e. when *-m1* is used on command line)
|
||||
|
||||
./configure options
|
||||
-------------------
|
||||
|
||||
These changes are for packagers:
|
||||
|
||||
* Add `--with-default-event-activation` option controlling default for
|
||||
`global/event_activation`. Default value is unchanged. Useful when creating
|
||||
builds for testing.
|
||||
* Add `--with-modulesdir` option.
|
||||
|
||||
Changes in udev rules
|
||||
---------------------
|
||||
|
||||
**IMPORTANT:** Rework of udev rules in cooperation with systemd is included in this release.
|
||||
|
||||
* `DM_SUSPENDED` and `DM_NOSCAN` are now entirely internal for DM and cannot be used outside of DM rules.
|
||||
* Upper level rules should consume `DM_UDEV_DISABLE_OTHER_RULES_FLAG` rather than `DM_NOSCAN` and `DM_SUSPENDED`.
|
||||
|
||||
Also few more minor improvements:
|
||||
|
||||
* Better handling of `DISK_RO` events and suspended devices
|
||||
|
||||
"""]]
|
||||
|
||||
[[!tag]]
|
||||
[[!meta date="Thu May 16 12:12:06 2024 +0200"]]
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user