Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=06439a256217b5d37ef33…
Commit: 06439a256217b5d37ef33833051fc322a58b4859
Parent: db741e75a21bd9327ed1478e42495f2b0a419be9
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jul 10 09:58:22 2018 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jul 10 10:49:34 2018 -0500
tests: autoactivation tests for use without lvmetad
Adjust a few lvmetad pvscan/autoactivation tests to be
used without lvmetad, and add a test to cover some cases
that have not been tested before.
---
.../shell/lvmetad-pvscan-autoactivation-polling.sh | 75 ----------
test/shell/lvmetad-pvscan-cache.sh | 63 ---------
test/shell/lvmetad-pvscan-nomda-bg.sh | 59 --------
test/shell/pvscan-autoactivate.sh | 143 ++++++++++++++++++++
test/shell/pvscan-autoactivation-polling.sh | 74 ++++++++++
test/shell/pvscan-cache.sh | 62 +++++++++
test/shell/pvscan-nomda-bg.sh | 41 ++++++
7 files changed, 320 insertions(+), 197 deletions(-)
diff --git a/test/shell/lvmetad-pvscan-autoactivation-polling.sh b/test/shell/lvmetad-pvscan-autoactivation-polling.sh
deleted file mode 100644
index 46c454b..0000000
--- a/test/shell/lvmetad-pvscan-autoactivation-polling.sh
+++ /dev/null
@@ -1,75 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright (C) 2016 Red Hat, Inc. All rights reserved.
-#
-# This copyrighted material is made available to anyone wishing to use,
-# modify, copy, or redistribute it subject to the terms and conditions
-# of the GNU General Public License v.2.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-SKIP_WITH_LVMLOCKD=1
-SKIP_WITHOUT_LVMETAD=1
-
-. lib/inittest
-
-# test if snapshot-merge target is available
-aux target_at_least dm-snapshot-merge 1 0 0 || skip
-
-which mkfs.ext3 || skip
-
-lvdev_() {
- echo "$DM_DEV_DIR/$1/$2"
-}
-
-snap_lv_name_() {
- echo ${1}_snap
-}
-
-setup_merge_() {
- local VG_NAME=$1
- local LV_NAME=$2
- local NUM_EXTRA_SNAPS=${3:-0}
- local BASE_SNAP_LV_NAME
-
- BASE_SNAP_LV_NAME=$(snap_lv_name_ $LV_NAME)
-
- lvcreate -aey -n $LV_NAME -l 50%FREE $VG_NAME
- lvs
- lvcreate -s -n $BASE_SNAP_LV_NAME -l 20%FREE ${VG_NAME}/${LV_NAME}
- mkfs.ext3 "$(lvdev_ $VG_NAME $LV_NAME)"
-
- if [ $NUM_EXTRA_SNAPS -gt 0 ]; then
- for i in $(seq 1 $NUM_EXTRA_SNAPS); do
- lvcreate -s -n ${BASE_SNAP_LV_NAME}_${i} -l 20%ORIGIN ${VG_NAME}/${LV_NAME}
- done
- fi
-}
-
-aux prepare_pvs 1 50
-
-vgcreate $vg1 "$dev1"
-mkdir test_mnt
-
-setup_merge_ $vg1 $lv1
-mount "$(lvdev_ $vg1 $lv1)" test_mnt
-lvconvert --merge "$vg1/$(snap_lv_name_ "$lv1")"
-umount test_mnt
-vgchange -an $vg1
-
-# check snapshot get removed on autoactivation
-pvscan --cache -aay "$dev1"
-
-check active $vg1 $lv1
-i=100
-while ! check lv_not_exists "$vg1/$(snap_lv_name_ "$lv1")"; do
- test $i -lt 0 && fail "Background polling failed to remove merged snapshot LV"
- sleep .1
- i=$((i-1))
-done
-
-# TODO: add similar simple tests for other interrupted/unfinished polling operation
-
-vgremove -ff $vg1
diff --git a/test/shell/lvmetad-pvscan-cache.sh b/test/shell/lvmetad-pvscan-cache.sh
deleted file mode 100644
index 367220e..0000000
--- a/test/shell/lvmetad-pvscan-cache.sh
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
-#
-# This copyrighted material is made available to anyone wishing to use,
-# modify, copy, or redistribute it subject to the terms and conditions
-# of the GNU General Public License v.2.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-SKIP_WITH_LVMLOCKD=1
-SKIP_WITHOUT_LVMETAD=1
-SKIP_WITH_LVMPOLLD=1
-
-. lib/inittest
-
-aux prepare_pvs 2
-
-vgcreate $vg1 "$dev1" "$dev2"
-vgs | grep $vg1
-
-pvscan --cache
-
-vgs | grep $vg1
-
-# Check that an LV cannot be activated by lvchange while VG is exported
-lvcreate -n $lv1 -l 4 -a n $vg1
-check lv_exists $vg1
-vgexport $vg1
-fail lvs $vg1
-fail lvchange -ay $vg1/$lv1
-vgimport $vg1
-check lv_exists $vg1
-check lv_field $vg1/$lv1 lv_active ""
-
-# Check that an LV cannot be activated by pvscan while VG is exported
-vgexport $vg1
-not pvscan --cache -aay "$dev1"
-not pvscan --cache -aay "$dev2"
-vgimport $vg1
-check lv_exists $vg1
-check lv_field $vg1/$lv1 lv_active ""
-pvscan --cache -aay "$dev1"
-pvscan --cache -aay "$dev2"
-check lv_field $vg1/$lv1 lv_active "active"
-lvchange -an $vg1/$lv1
-
-# When MDA is ignored on PV, do not read any VG
-# metadata from such PV as it may contain old
-# metadata which hasn't been updated for some
-# time and also since the MDA is marked as ignored,
-# it should really be *ignored*!
-pvchange --metadataignore y "$dev1"
-aux disable_dev "$dev2"
-pvscan --cache
-check pv_field "$dev1" vg_name "[unknown]"
-aux enable_dev "$dev2"
-pvscan --cache
-check pv_field "$dev1" vg_name "$vg1"
-
-vgremove -ff $vg1
diff --git a/test/shell/lvmetad-pvscan-nomda-bg.sh b/test/shell/lvmetad-pvscan-nomda-bg.sh
deleted file mode 100644
index 351e446..0000000
--- a/test/shell/lvmetad-pvscan-nomda-bg.sh
+++ /dev/null
@@ -1,59 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright (C) 2015 Red Hat, Inc. All rights reserved.
-#
-# This copyrighted material is made available to anyone wishing to use,
-# modify, copy, or redistribute it subject to the terms and conditions
-# of the GNU General Public License v.2.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-
-SKIP_WITH_LVMLOCKD=1
-SKIP_WITHOUT_LVMETAD=1
-SKIP_WITH_LVMPOLLD=1
-
-. lib/inittest
-
-kill "$(< LOCAL_LVMETAD)"
-rm LOCAL_LVMETAD
-
-aux prepare_devs 2
-
-pvcreate --metadatacopies 0 "$dev1"
-pvcreate --metadatacopies 1 "$dev2"
-vgcreate $vg1 "$dev1" "$dev2"
-lvcreate -n foo -l 1 -an --zero n $vg1
-
-# start lvmetad but make sure it doesn't know about $dev1 or $dev2
-aux disable_dev "$dev1" "$dev2"
-aux prepare_lvmetad
-lvs
-mv LOCAL_LVMETAD XXX
-aux enable_dev "$dev2" "$dev1"
-mv XXX LOCAL_LVMETAD
-
-aux lvmconf 'global/use_lvmetad = 0'
-check inactive $vg1 foo
-aux lvmconf 'global/use_lvmetad = 1'
-
-pvscan --cache --background "$dev2" -aay
-
-aux lvmconf 'global/use_lvmetad = 0'
-# FIXME: inconclusive. may be a timing issue
-check inactive $vg1 foo
-aux lvmconf 'global/use_lvmetad = 1'
-
-pvscan --cache --background "$dev1" -aay
-
-aux lvmconf 'global/use_lvmetad = 0'
-i=100
-while ! check active $vg1 foo; do
- test $i -lt 0 && fail "Failed to autoactivate"
- sleep .1
- i=$((i-1))
-done
-aux lvmconf 'global/use_lvmetad = 1'
-
-vgremove -ff $vg1
diff --git a/test/shell/pvscan-autoactivate.sh b/test/shell/pvscan-autoactivate.sh
new file mode 100644
index 0000000..af6f2b2
--- /dev/null
+++ b/test/shell/pvscan-autoactivate.sh
@@ -0,0 +1,143 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux prepare_pvs 2
+
+vgcreate $vg1 "$dev1" "$dev2"
+lvcreate -n $lv1 -l 4 -a n $vg1
+
+# the first pvscan scans all devs
+
+rm /run/lvm/pvs_online/*
+
+pvscan --cache -aay
+check lv_field $vg1/$lv1 lv_active "active"
+lvchange -an $vg1
+
+# the first pvscan scans all devs even when
+# only one device is specified
+
+rm /run/lvm/pvs_online/*
+
+pvscan --cache -aay "$dev1"
+check lv_field $vg1/$lv1 lv_active "active"
+lvchange -an $vg1
+
+# touch foo to disable first-pvscan case,
+# then check pvscan with no args scans all
+
+rm /run/lvm/pvs_online/*
+touch /run/lvm/pvs_online/foo
+
+pvscan --cache -aay
+check lv_field $vg1/$lv1 lv_active "active"
+lvchange -an $vg1
+
+# touch foo to disable first-pvscan case,
+# then check that vg is activated only after
+# both devs appear separately
+
+rm /run/lvm/pvs_online/*
+touch /run/lvm/pvs_online/foo
+
+pvscan --cache -aay "$dev1"
+check lv_field $vg1/$lv1 lv_active ""
+pvscan --cache -aay "$dev2"
+check lv_field $vg1/$lv1 lv_active "active"
+lvchange -an $vg1
+
+# touch foo to disable first-pvscan case,
+# then check that vg is activated when both
+# devs appear together
+
+rm /run/lvm/pvs_online/*
+touch /run/lvm/pvs_online/foo
+
+pvscan --cache -aay "$dev1" "$dev2"
+check lv_field $vg1/$lv1 lv_active "active"
+lvchange -an $vg1
+
+# Set up tests where one dev has no metadata
+
+vgchange -an $vg1
+vgremove -ff $vg1
+pvremove "$dev1"
+pvremove "$dev2"
+pvcreate --metadatacopies 0 "$dev1"
+pvcreate --metadatacopies 1 "$dev2"
+vgcreate $vg1 "$dev1" "$dev2"
+lvcreate -n $lv1 -l 4 -a n $vg1
+
+# touch foo to disable first-pvscan case,
+# test case where dev with metadata appears first
+
+rm /run/lvm/pvs_online/*
+touch /run/lvm/pvs_online/foo
+
+pvscan --cache -aay "$dev2"
+check lv_field $vg1/$lv1 lv_active ""
+pvscan --cache -aay "$dev1"
+check lv_field $vg1/$lv1 lv_active "active"
+lvchange -an $vg1
+
+# touch foo to disable first-pvscan case,
+# test case where dev without metadata
+# appears first which triggers scanning all
+
+rm /run/lvm/pvs_online/*
+touch /run/lvm/pvs_online/foo
+
+pvscan --cache -aay "$dev1"
+check lv_field $vg1/$lv1 lv_active "active"
+pvscan --cache -aay "$dev2"
+check lv_field $vg1/$lv1 lv_active "active"
+lvchange -an $vg1
+
+# dev without metadata is scanned, but
+# first-pvscan case scans all devs
+
+rm /run/lvm/pvs_online/*
+
+pvscan --cache -aay "$dev1"
+check lv_field $vg1/$lv1 lv_active "active"
+lvchange -an $vg1
+
+# use the --cache option to record a dev
+# is online without the -aay option to
+# activate until after they are online
+
+rm /run/lvm/pvs_online/*
+touch /run/lvm/pvs_online/foo
+
+pvscan --cache "$dev1"
+check lv_field $vg1/$lv1 lv_active ""
+pvscan --cache "$dev2"
+check lv_field $vg1/$lv1 lv_active ""
+pvscan --cache -aay
+check lv_field $vg1/$lv1 lv_active "active"
+lvchange -an $vg1
+
+# like previous
+
+rm /run/lvm/pvs_online/*
+touch /run/lvm/pvs_online/foo
+
+pvscan --cache "$dev1"
+check lv_field $vg1/$lv1 lv_active ""
+pvscan --cache -aay "$dev2"
+check lv_field $vg1/$lv1 lv_active "active"
+lvchange -an $vg1
+
diff --git a/test/shell/pvscan-autoactivation-polling.sh b/test/shell/pvscan-autoactivation-polling.sh
new file mode 100644
index 0000000..53adf51
--- /dev/null
+++ b/test/shell/pvscan-autoactivation-polling.sh
@@ -0,0 +1,74 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2016 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+SKIP_WITH_LVMLOCKD=1
+
+. lib/inittest
+
+# test if snapshot-merge target is available
+aux target_at_least dm-snapshot-merge 1 0 0 || skip
+
+which mkfs.ext3 || skip
+
+lvdev_() {
+ echo "$DM_DEV_DIR/$1/$2"
+}
+
+snap_lv_name_() {
+ echo ${1}_snap
+}
+
+setup_merge_() {
+ local VG_NAME=$1
+ local LV_NAME=$2
+ local NUM_EXTRA_SNAPS=${3:-0}
+ local BASE_SNAP_LV_NAME
+
+ BASE_SNAP_LV_NAME=$(snap_lv_name_ $LV_NAME)
+
+ lvcreate -aey -n $LV_NAME -l 50%FREE $VG_NAME
+ lvs
+ lvcreate -s -n $BASE_SNAP_LV_NAME -l 20%FREE ${VG_NAME}/${LV_NAME}
+ mkfs.ext3 "$(lvdev_ $VG_NAME $LV_NAME)"
+
+ if [ $NUM_EXTRA_SNAPS -gt 0 ]; then
+ for i in $(seq 1 $NUM_EXTRA_SNAPS); do
+ lvcreate -s -n ${BASE_SNAP_LV_NAME}_${i} -l 20%ORIGIN ${VG_NAME}/${LV_NAME}
+ done
+ fi
+}
+
+aux prepare_pvs 1 50
+
+vgcreate $vg1 "$dev1"
+mkdir test_mnt
+
+setup_merge_ $vg1 $lv1
+mount "$(lvdev_ $vg1 $lv1)" test_mnt
+lvconvert --merge "$vg1/$(snap_lv_name_ "$lv1")"
+umount test_mnt
+vgchange -an $vg1
+
+# check snapshot get removed on autoactivation
+pvscan --cache -aay "$dev1"
+
+check active $vg1 $lv1
+i=100
+while ! check lv_not_exists "$vg1/$(snap_lv_name_ "$lv1")"; do
+ test $i -lt 0 && fail "Background polling failed to remove merged snapshot LV"
+ sleep .1
+ i=$((i-1))
+done
+
+# TODO: add similar simple tests for other interrupted/unfinished polling operation
+
+vgremove -ff $vg1
diff --git a/test/shell/pvscan-cache.sh b/test/shell/pvscan-cache.sh
new file mode 100644
index 0000000..c272c6c
--- /dev/null
+++ b/test/shell/pvscan-cache.sh
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2012 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux prepare_pvs 2
+
+vgcreate $vg1 "$dev1" "$dev2"
+vgs | grep $vg1
+
+pvscan --cache
+
+vgs | grep $vg1
+
+# Check that an LV cannot be activated by lvchange while VG is exported
+lvcreate -n $lv1 -l 4 -a n $vg1
+check lv_exists $vg1
+vgexport $vg1
+fail lvs $vg1
+fail lvchange -ay $vg1/$lv1
+vgimport $vg1
+check lv_exists $vg1
+check lv_field $vg1/$lv1 lv_active ""
+
+# Check that an LV cannot be activated by pvscan while VG is exported
+vgexport $vg1
+not pvscan --cache -aay "$dev1"
+not pvscan --cache -aay "$dev2"
+vgimport $vg1
+check lv_exists $vg1
+check lv_field $vg1/$lv1 lv_active ""
+pvscan --cache -aay "$dev1"
+pvscan --cache -aay "$dev2"
+check lv_field $vg1/$lv1 lv_active "active"
+lvchange -an $vg1/$lv1
+
+# When MDA is ignored on PV, do not read any VG
+# metadata from such PV as it may contain old
+# metadata which hasn't been updated for some
+# time and also since the MDA is marked as ignored,
+# it should really be *ignored*!
+pvchange --metadataignore y "$dev1"
+aux disable_dev "$dev2"
+pvscan --cache
+check pv_field "$dev1" vg_name "[unknown]"
+aux enable_dev "$dev2"
+pvscan --cache
+check pv_field "$dev1" vg_name "$vg1"
+
+vgremove -ff $vg1
diff --git a/test/shell/pvscan-nomda-bg.sh b/test/shell/pvscan-nomda-bg.sh
new file mode 100644
index 0000000..f8ecc08
--- /dev/null
+++ b/test/shell/pvscan-nomda-bg.sh
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2015 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux prepare_devs 2
+
+pvcreate --metadatacopies 0 "$dev1"
+pvcreate --metadatacopies 1 "$dev2"
+vgcreate $vg1 "$dev1" "$dev2"
+lvcreate -n foo -l 1 -an --zero n $vg1
+
+check inactive $vg1 foo
+
+# create a file in pvs_online to disable the pvscan init
+# case which scans everything when the first dev appears.
+mkdir /run/lvm/pvs_online/
+touch /run/lvm/pvs_online/foo
+
+pvscan --cache --background "$dev2" -aay
+
+check inactive $vg1 foo
+
+pvscan --cache --background "$dev1" -aay
+
+check active $vg1 foo
+
+rm /run/lvm/pvs_online/foo
+vgremove -ff $vg1
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=faa126882a9cf2fb64dd1…
Commit: faa126882a9cf2fb64dd143bb96414399e30edf2
Parent: 12213445b5f86155665ed6f027082e93c4f6cf85
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Mon Jul 9 11:43:12 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Jul 9 15:29:16 2018 +0200
dmeventd: lvm vdo support
---
conf/example.conf.in | 44 +++++++++++++++++++++++++++++++++++++++++
lib/config/config_settings.h | 38 +++++++++++++++++++++++++++++++++++
lib/config/defaults.h | 4 +++
lib/vdo/vdo.c | 45 ++++++++++++++++++++++++++++++++++++++++++
tools/lvmcmdlib.c | 3 ++
5 files changed, 134 insertions(+), 0 deletions(-)
diff --git a/conf/example.conf.in b/conf/example.conf.in
index f2bb77b..36204d3 100644
--- a/conf/example.conf.in
+++ b/conf/example.conf.in
@@ -1533,6 +1533,33 @@ activation {
#
thin_pool_autoextend_percent = 20
+ # Configuration option activation/vdo_pool_autoextend_threshold.
+ # Auto-extend a VDO pool when its usage exceeds this percent.
+ # Setting this to 100 disables automatic extension.
+ # The minimum value is 50 (a smaller value is treated as 50.)
+ # Also see vdo_pool_autoextend_percent.
+ # Automatic extension requires dmeventd to be monitoring the LV.
+ #
+ # Example
+ # Using 70% autoextend threshold and 20% autoextend size, when a 10G
+ # VDO pool exceeds 7G, it is extended to 12G, and when it exceeds
+ # 8.4G, it is extended to 14.4G:
+ # vdo_pool_autoextend_threshold = 70
+ #
+ vdo_pool_autoextend_threshold = 100
+
+ # Configuration option activation/vdo_pool_autoextend_percent.
+ # Auto-extending a VDO pool adds this percent extra space.
+ # The amount of additional space added to a VDO pool is this
+ # percent of its current size.
+ #
+ # Example
+ # Using 70% autoextend threshold and 20% autoextend size, when a 10G
+ # VDO pool exceeds 7G, it is extended to 12G, and when it exceeds
+ # 8.4G, it is extended to 14.4G:
+ # This configuration option has an automatic default value.
+ # vdo_pool_autoextend_percent = 20
+
# Configuration option activation/mlock_filter.
# Do not mlock these memory areas.
# While activating devices, I/O to devices being (re)configured is
@@ -2154,6 +2181,23 @@ dmeventd {
# This configuration option has an automatic default value.
# thin_command = "lvm lvextend --use-policies"
+ # Configuration option dmeventd/vdo_library.
+ # The library dmeventd uses when monitoring a VDO pool device.
+ # libdevmapper-event-lvm2vdo.so monitors the filling of a pool
+ # and emits a warning through syslog when the usage exceeds 80%. The
+ # warning is repeated when 85%, 90% and 95% of the pool is filled.
+ # This configuration option has an automatic default value.
+ # vdo_library = "libdevmapper-event-lvm2vdo.so"
+
+ # Configuration option dmeventd/vdo_command.
+ # The plugin runs command with each 5% increment when VDO pool volume
+ # gets above 50%.
+ # Command which starts with 'lvm ' prefix is internal lvm command.
+ # You can write your own handler to customise behaviour in more details.
+ # User handler is specified with the full path starting with '/'.
+ # This configuration option has an automatic default value.
+ # vdo_command = "lvm lvextend --use-policies"
+
# Configuration option dmeventd/executable.
# The full path to the dmeventd binary.
# This configuration option has an automatic default value.
diff --git a/lib/config/config_settings.h b/lib/config/config_settings.h
index 9026c2d..3417127 100644
--- a/lib/config/config_settings.h
+++ b/lib/config/config_settings.h
@@ -1478,6 +1478,30 @@ cfg(activation_thin_pool_autoextend_percent_CFG, "thin_pool_autoextend_percent",
"thin_pool_autoextend_percent = 20\n"
"#\n")
+cfg(activation_vdo_pool_autoextend_threshold_CFG, "vdo_pool_autoextend_threshold", activation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA, CFG_TYPE_INT, DEFAULT_VDO_POOL_AUTOEXTEND_THRESHOLD, VDO_1ST_VSN, NULL, 0, NULL,
+ "Auto-extend a VDO pool when its usage exceeds this percent.\n"
+ "Setting this to 100 disables automatic extension.\n"
+ "The minimum value is 50 (a smaller value is treated as 50.)\n"
+ "Also see vdo_pool_autoextend_percent.\n"
+ "Automatic extension requires dmeventd to be monitoring the LV.\n"
+ "#\n"
+ "Example\n"
+ "Using 70% autoextend threshold and 20% autoextend size, when a 10G\n"
+ "VDO pool exceeds 7G, it is extended to 12G, and when it exceeds\n"
+ "8.4G, it is extended to 14.4G:\n"
+ "vdo_pool_autoextend_threshold = 70\n"
+ "#\n")
+
+cfg(activation_vdo_pool_autoextend_percent_CFG, "vdo_pool_autoextend_percent", activation_CFG_SECTION, CFG_PROFILABLE | CFG_PROFILABLE_METADATA | CFG_DEFAULT_COMMENTED, CFG_TYPE_INT, DEFAULT_VDO_POOL_AUTOEXTEND_PERCENT, VDO_1ST_VSN, NULL, 0, NULL,
+ "Auto-extending a VDO pool adds this percent extra space.\n"
+ "The amount of additional space added to a VDO pool is this\n"
+ "percent of its current size.\n"
+ "#\n"
+ "Example\n"
+ "Using 70% autoextend threshold and 20% autoextend size, when a 10G\n"
+ "VDO pool exceeds 7G, it is extended to 12G, and when it exceeds\n"
+ "8.4G, it is extended to 14.4G:\n")
+
cfg_array(activation_mlock_filter_CFG, "mlock_filter", activation_CFG_SECTION, CFG_DEFAULT_UNDEFINED | CFG_ADVANCED, CFG_TYPE_STRING, NULL, vsn(2, 2, 62), NULL, 0, NULL,
"Do not mlock these memory areas.\n"
"While activating devices, I/O to devices being (re)configured is\n"
@@ -1965,6 +1989,20 @@ cfg(dmeventd_thin_command_CFG, "thin_command", dmeventd_CFG_SECTION, CFG_DEFAULT
"User handler is specified with the full path starting with '/'.\n")
/* TODO: systemd service handler */
+cfg(dmeventd_vdo_library_CFG, "vdo_library", dmeventd_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_DMEVENTD_VDO_LIB, VDO_1ST_VSN, NULL, 0, NULL,
+ "The library dmeventd uses when monitoring a VDO pool device.\n"
+ "libdevmapper-event-lvm2vdo.so monitors the filling of a pool\n"
+ "and emits a warning through syslog when the usage exceeds 80%. The\n"
+ "warning is repeated when 85%, 90% and 95% of the pool is filled.\n")
+
+cfg(dmeventd_vdo_command_CFG, "vdo_command", dmeventd_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_DMEVENTD_VDO_COMMAND, VDO_1ST_VSN, NULL, 0, NULL,
+ "The plugin runs command with each 5% increment when VDO pool volume\n"
+ "gets above 50%.\n"
+ "Command which starts with 'lvm ' prefix is internal lvm command.\n"
+ "You can write your own handler to customise behaviour in more details.\n"
+ "User handler is specified with the full path starting with '/'.\n")
+ /* TODO: systemd service handler */
+
cfg(dmeventd_executable_CFG, "executable", dmeventd_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, DEFAULT_DMEVENTD_PATH, vsn(2, 2, 73), "@DMEVENTD_PATH@", 0, NULL,
"The full path to the dmeventd binary.\n")
diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 2d70f53..9928fb1 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -83,6 +83,8 @@
#define DEFAULT_DMEVENTD_SNAPSHOT_LIB "libdevmapper-event-lvm2snapshot.so"
#define DEFAULT_DMEVENTD_THIN_LIB "libdevmapper-event-lvm2thin.so"
#define DEFAULT_DMEVENTD_THIN_COMMAND "lvm lvextend --use-policies"
+#define DEFAULT_DMEVENTD_VDO_LIB "libdevmapper-event-lvm2vdo.so"
+#define DEFAULT_DMEVENTD_VDO_COMMAND "lvm lvextend --use-policies"
#define DEFAULT_DMEVENTD_MONITOR 1
#define DEFAULT_BACKGROUND_POLLING 1
@@ -295,5 +297,7 @@
#define DEFAULT_SNAPSHOT_AUTOEXTEND_PERCENT 20
#define DEFAULT_THIN_POOL_AUTOEXTEND_THRESHOLD 100
#define DEFAULT_THIN_POOL_AUTOEXTEND_PERCENT 20
+#define DEFAULT_VDO_POOL_AUTOEXTEND_THRESHOLD 100
+#define DEFAULT_VDO_POOL_AUTOEXTEND_PERCENT 20
#endif /* _LVM_DEFAULTS_H */
diff --git a/lib/vdo/vdo.c b/lib/vdo/vdo.c
index 80ddcfd..455ce5b 100644
--- a/lib/vdo/vdo.c
+++ b/lib/vdo/vdo.c
@@ -450,6 +450,38 @@ static int _vdo_modules_needed(struct dm_pool *mem,
return 1;
}
+
+# ifdef DMEVENTD
+/* FIXME Cache this */
+static int _vdo_pool_target_registered(struct lv_segment *seg, int *pending, int *monitored)
+{
+ return target_registered_with_dmeventd(seg->lv->vg->cmd,
+ seg->segtype->dso,
+ seg->lv, pending, monitored);
+}
+
+/* FIXME This gets run while suspended and performs banned operations. */
+static int _vdo_pool_target_set_events(struct lv_segment *seg, int evmask, int set)
+{
+ /* FIXME Make timeout (10) configurable */
+ return target_register_events(seg->lv->vg->cmd,
+ seg->segtype->dso,
+ seg->lv, evmask, set, 10);
+}
+
+static int _vdo_pool_target_register_events(struct lv_segment *seg,
+ int events)
+{
+ return _vdo_pool_target_set_events(seg, events, 1);
+}
+
+static int _vdo_pool_target_unregister_events(struct lv_segment *seg,
+ int events)
+{
+ return _vdo_pool_target_set_events(seg, events, 0);
+}
+
+# endif /* DMEVENTD */
#endif
/* reused as _vdo_destroy */
@@ -487,6 +519,12 @@ static struct segtype_handler _vdo_pool_ops = {
.add_target_line = _vdo_pool_add_target_line,
.target_present = _vdo_target_present,
.modules_needed = _vdo_modules_needed,
+
+# ifdef DMEVENTD
+ .target_monitored = _vdo_pool_target_registered,
+ .target_monitor_events = _vdo_pool_target_register_events,
+ .target_unmonitor_events = _vdo_pool_target_unregister_events,
+# endif /* DMEVENTD */
#endif
.destroy = _vdo_pool_destroy,
};
@@ -515,6 +553,13 @@ int init_vdo_segtypes(struct cmd_context *cmd,
pool_segtype->name = SEG_TYPE_NAME_VDO_POOL;
pool_segtype->flags = SEG_VDO_POOL | SEG_ONLY_EXCLUSIVE;
pool_segtype->ops = &_vdo_pool_ops;
+#ifdef DEVMAPPER_SUPPORT
+# ifdef DMEVENTD
+ pool_segtype->dso = get_monitor_dso_path(cmd, dmeventd_vdo_library_CFG);
+ if (pool_segtype->dso)
+ pool_segtype->flags |= SEG_MONITORED;
+# endif /* DMEVENTD */
+#endif
if (!lvm_register_segtype(seglib, pool_segtype))
return_0;
diff --git a/tools/lvmcmdlib.c b/tools/lvmcmdlib.c
index b787d09..695d4dd 100644
--- a/tools/lvmcmdlib.c
+++ b/tools/lvmcmdlib.c
@@ -87,6 +87,9 @@ int lvm2_run(void *handle, const char *cmdline)
else if (!strcmp(cmdline, "_dmeventd_thin_command")) {
if (setenv(cmdline, find_config_tree_str(cmd, dmeventd_thin_command_CFG, NULL), 1))
ret = ECMD_FAILED;
+ } else if (!strcmp(cmdline, "_dmeventd_vdo_command")) {
+ if (setenv(cmdline, find_config_tree_str(cmd, dmeventd_vdo_command_CFG, NULL), 1))
+ ret = ECMD_FAILED;
} else
ret = lvm_run_command(cmd, argc, argv);