master - libdm: split code for sending message
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=4c1caa7e26b6f8011ca...
Commit: 4c1caa7e26b6f8011ca083395650d11943a42a8a
Parent: 58976ccc34f9c60471e630666417a1fcef4d9799
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sat Jun 23 21:00:40 2018 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 19 16:53:18 2020 +0200
libdm: split code for sending message
Move message sending from _thin_pool_node_message to
new _node_message for possible better code sharing.
---
libdm/libdm-deptree.c | 62 ++++++++++++++++++++++++++++++---------------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c
index ee12da2b2..887e8f275 100644
--- a/libdm/libdm-deptree.c
+++ b/libdm/libdm-deptree.c
@@ -1428,9 +1428,41 @@ out:
return r;
}
-static int _thin_pool_node_message(struct dm_tree_node *dnode, struct thin_message *tm)
+static int _node_message(uint32_t major, uint32_t minor,
+ int expected_errno, const char *message)
{
struct dm_task *dmt;
+ int r = 0;
+
+ if (!(dmt = dm_task_create(DM_DEVICE_TARGET_MSG)))
+ return_0;
+
+ if (!dm_task_set_major(dmt, major) ||
+ !dm_task_set_minor(dmt, minor)) {
+ log_error("Failed to set message major minor.");
+ goto out;
+ }
+
+ if (!dm_task_set_message(dmt, message))
+ goto_out;
+
+ /* Internal functionality of dm_task */
+ dmt->expected_errno = expected_errno;
+
+ if (!dm_task_run(dmt)) {
+ log_error("Failed to process message \"%s\".", message);
+ goto out;
+ }
+
+ r = 1;
+out:
+ dm_task_destroy(dmt);
+
+ return r;
+}
+
+static int _thin_pool_node_message(struct dm_tree_node *dnode, struct thin_message *tm)
+{
struct dm_thin_message *m = &tm->message;
char buf[64];
int r;
@@ -1470,33 +1502,11 @@ static int _thin_pool_node_message(struct dm_tree_node *dnode, struct thin_messa
return 0;
}
- r = 0;
-
- if (!(dmt = dm_task_create(DM_DEVICE_TARGET_MSG)))
+ if (!_node_message(dnode->info.major, dnode->info.minor,
+ tm->expected_errno, buf))
return_0;
- if (!dm_task_set_major(dmt, dnode->info.major) ||
- !dm_task_set_minor(dmt, dnode->info.minor)) {
- log_error("Failed to set message major minor.");
- goto out;
- }
-
- if (!dm_task_set_message(dmt, buf))
- goto_out;
-
- /* Internal functionality of dm_task */
- dmt->expected_errno = tm->expected_errno;
-
- if (!dm_task_run(dmt)) {
- log_error("Failed to process thin pool message \"%s\".", buf);
- goto out;
- }
-
- r = 1;
-out:
- dm_task_destroy(dmt);
-
- return r;
+ return 1;
}
static struct load_segment *_get_last_load_segment(struct dm_tree_node *node)
3 years, 6 months
master - properties: fix data_usage typo
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=58976ccc34f9c60471e...
Commit: 58976ccc34f9c60471e630666417a1fcef4d9799
Parent: d2bdad28d1d1ad337a6c876c235797dbf6907886
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 16 17:51:23 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 19 16:53:18 2020 +0200
properties: fix data_usage typo
Patch 4de6f58085c533c79ce2e0db6cdeb6ed06fe05f8 introduce typo,
we need to use data_usage.
Note: this code was used by lvmapp library and currently is unused.
---
lib/report/properties.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/report/properties.c b/lib/report/properties.c
index ef2888f50..c013152f2 100644
--- a/lib/report/properties.c
+++ b/lib/report/properties.c
@@ -168,7 +168,7 @@ static dm_percent_t _data_percent(const struct logical_volume *lv)
if (!lv_thin_pool_status(lv, 0, &thin_pool_status))
stack;
else {
- percent = thin_pool_status->metadata_usage;
+ percent = thin_pool_status->data_usage;
dm_pool_destroy(thin_pool_status->mem);
}
}
3 years, 6 months
master - tests: extend area covered by error target
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d2bdad28d1d1ad337a6...
Commit: d2bdad28d1d1ad337a6c876c235797dbf6907886
Parent: b50134dc14296bf9bee96f3b4021ba5b123d54c9
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 6 15:45:19 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 19 16:53:18 2020 +0200
tests: extend area covered by error target
Since 'BLKZEROOUT' streams out more block at once, at can easily
zero-out larger set of blocks after 1st. failing one.
So the test is adapted to fully 'hide' swap header under error target.
---
test/shell/lvcreate-signature-wiping.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/shell/lvcreate-signature-wiping.sh b/test/shell/lvcreate-signature-wiping.sh
index 18d7a2f7e..4893d9a66 100644
--- a/test/shell/lvcreate-signature-wiping.sh
+++ b/test/shell/lvcreate-signature-wiping.sh
@@ -43,7 +43,7 @@ test_blkid_ || skip
lvremove -f $vg/$lv1
# Zeroing stops the command when there is a failure (write error in this case)
-aux error_dev "$dev1" "$(get first_extent_sector "$dev1"):2"
+aux error_dev "$dev1" "$(get first_extent_sector "$dev1"):8"
not lvcreate -l1 -n $lv1 $vg 2>&1 | tee out
grep "Failed to initialize" out
aux enable_dev "$dev1"
3 years, 6 months
stable-2.02 - blkdeactivate: add support for VDO in blkdeactivate script
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2c048bd77d669f77825...
Commit: 2c048bd77d669f77825455b8e5110c80beff7da5
Parent: e5af7bef223881134209b71f90240cdbf59d9ec1
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Thu Apr 9 15:23:58 2020 +0200
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Mon Oct 19 16:02:20 2020 +0200
blkdeactivate: add support for VDO in blkdeactivate script
Make it possible to tear down VDO volumes with blkdeactivate if VDO is
part of a device stack (and if VDO binary is installed). Also, support
optional -o|--vdooptions configfile=file.
(cherry picked from commit 0dd905c959a8f36ea627027336b6d5dafb015001)
Conflicts:
WHATS_NEW_DM
---
WHATS_NEW_DM | 1 +
man/blkdeactivate.8_main | 11 +++++++++++
scripts/blkdeactivate.sh.in | 48 ++++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 56d9e0684..06e65b7d3 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,6 @@
Version 1.02.172 -
==================================
+ Add support for VDO in blkdeactivate script.
Try to remove all created devices on dm preload tree error path.
Fix dm_list interators with gcc 10 optimization (-ftree-pta).
Dmeventd handles timer without looping on short intervals.
diff --git a/man/blkdeactivate.8_main b/man/blkdeactivate.8_main
index f3c19a8c3..06af52e52 100644
--- a/man/blkdeactivate.8_main
+++ b/man/blkdeactivate.8_main
@@ -9,6 +9,7 @@ blkdeactivate \(em utility to deactivate block devices
.RB [ -l \ \fIlvm_options\fP ]
.RB [ -m \ \fImpath_options\fP ]
.RB [ -r \ \fImdraid_options\fP ]
+.RB [ -o \ \fIvdo_options\fP ]
.RB [ -u ]
.RB [ -v ]
.RI [ device ]
@@ -70,6 +71,15 @@ Comma-separated list of MD RAID specific options:
Wait MD device's resync, recovery or reshape action to complete
before deactivation.
.RE
+
+.TP
+.BR -o ", " --vdooptions \ \fIvdo_options\fP
+Comma-separated list of VDO specific options:
+.RS
+.IP \fIconfigfile=file\fP
+Use specified VDO configuration file.
+.RE
+
.TP
.BR -u ", " --umount
Unmount a mounted device before trying to deactivate it.
@@ -120,4 +130,5 @@ of a device-mapper device fails, retry it and force removal.
.BR lvm (8),
.BR mdadm (8),
.BR multipathd (8),
+.BR vdo (8),
.BR umount (8)
diff --git a/scripts/blkdeactivate.sh.in b/scripts/blkdeactivate.sh.in
index a4b8a8fb5..57b3e58bf 100644
--- a/scripts/blkdeactivate.sh.in
+++ b/scripts/blkdeactivate.sh.in
@@ -1,6 +1,6 @@
#!/bin/bash
#
-# Copyright (C) 2012-2017 Red Hat, Inc. All rights reserved.
+# Copyright (C) 2012-2020 Red Hat, Inc. All rights reserved.
#
# This file is part of LVM2.
#
@@ -38,6 +38,7 @@ MDADM="/sbin/mdadm"
MOUNTPOINT="/bin/mountpoint"
MPATHD="/sbin/multipathd"
UMOUNT="/bin/umount"
+VDO="/bin/vdo"
sbindir="@SBINDIR@"
DMSETUP="$sbindir/dmsetup"
@@ -54,6 +55,7 @@ DMSETUP_OPTS=""
LVM_OPTS=""
MDADM_OPTS=""
MPATHD_OPTS=""
+VDO_OPTS=""
LSBLK="/bin/lsblk -r --noheadings -o TYPE,KNAME,NAME,MOUNTPOINT"
LSBLK_VARS="local devtype local kname local name local mnt"
@@ -124,6 +126,7 @@ usage() {
echo " -l | --lvmoptions LVM_OPTIONS Comma separated LVM specific options"
echo " -m | --mpathoptions MPATH_OPTIONS Comma separated DM-multipath specific options"
echo " -r | --mdraidoptions MDRAID_OPTIONS Comma separated MD RAID specific options"
+ echo " -o | --vdooptions VDO_OPTIONS Comma separated VDO specific options"
echo " -u | --umount Unmount the device if mounted"
echo " -v | --verbose Verbose mode (also implies -e)"
echo
@@ -138,6 +141,8 @@ usage() {
echo " wait wait for resync, recovery or reshape to complete first"
echo " MPATH_OPTIONS:"
echo " disablequeueing disable queueing on all DM-multipath devices first"
+ echo " VDO_OPTIONS:"
+ echo " configfile=file use specified VDO configuration file"
exit
}
@@ -319,6 +324,23 @@ deactivate_md () {
fi
}
+deactivate_vdo() {
+ local xname
+ xname=$(printf "%s" "$name")
+ test -b "$DEV_DIR/mapper/$xname" || return 0
+ test -z "${SKIP_DEVICE_LIST["$kname"]}" || return 1
+
+ deactivate_holders "$DEV_DIR/mapper/$xname" || return 1
+
+ echo -n " [VDO]: deactivating VDO volume $xname... "
+ if eval "$VDO" stop $VDO_OPTS --name="$xname" "$OUT" "$ERR"; then
+ echo "done"
+ else
+ echo "skipping"
+ add_device_to_skip_list
+ fi
+}
+
deactivate () {
######################################################################
# DEACTIVATION HOOKS FOR NEW DEVICE TYPES GO HERE! #
@@ -335,6 +357,8 @@ deactivate () {
######################################################################
if test "$devtype" = "lvm"; then
deactivate_lvm
+ elif test "$devtype" = "vdo"; then
+ deactivate_vdo
elif test "${kname:0:3}" = "dm-"; then
deactivate_dm
elif test "${kname:0:2}" = "md"; then
@@ -479,6 +503,20 @@ get_mpathopts() {
IFS=$ORIG_IFS
}
+get_vdoopts() {
+ ORIG_IFS=$IFS; IFS=','
+
+ for opt in $1; do
+ case "$opt" in
+ "") ;;
+ configfile=*) tmp=${opt#*=}; VDO_OPTS+="--confFile=${tmp%%,*} " ;;
+ *) echo "$opt: unknown VDO option"
+ esac
+ done
+
+ IFS=$ORIG_IFS
+}
+
set_env() {
if test "$ERRORS" -eq "1"; then
unset ERR
@@ -493,6 +531,7 @@ set_env() {
LVM_OPTS+="-vvvv"
MDADM_OPTS+="-vv"
MPATHD_OPTS+="-v 3"
+ VDO_OPTS+="--verbose "
else
OUT="1>$DEV_DIR/null"
fi
@@ -509,6 +548,12 @@ set_env() {
MDADM_AVAILABLE=0
fi
+ if test -f $VDO; then
+ VDO_AVAILABLE=1
+ else
+ VDO_AVAILABLE=0
+ fi
+
MPATHD_RUNNING=0
test "$MPATHD_DO_DISABLEQUEUEING" -eq 1 && {
if test -f "$MPATHD"; then
@@ -528,6 +573,7 @@ while test $# -ne 0; do
"-l"|"--lvmoptions") get_lvmopts "$2" ; shift ;;
"-m"|"--mpathoptions") get_mpathopts "$2" ; shift ;;
"-r"|"--mdraidoptions") get_mdraidopts "$2"; shift ;;
+ "-o"|"--vdooptions") get_vdoopts "$2"; shift ;;
"-u"|"--umount") DO_UMOUNT=1 ;;
"-v"|"--verbose") VERBOSE=1 ; ERRORS=1 ;;
"-vv") VERBOSE=1 ; ERRORS=1 ; set -x ;;
3 years, 6 months
stable-2.02 - blkdeactivate: add missing VDO_AVAILABLE check in deactivate_vdo
by Marian Csontos
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=aa4f1f117a355c7046a...
Commit: aa4f1f117a355c7046a348fd217fdfab20242ae6
Parent: 2c048bd77d669f77825455b8e5110c80beff7da5
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Mon Jun 8 15:41:35 2020 +0200
Committer: Marian Csontos <mcsontos(a)redhat.com>
CommitterDate: Mon Oct 19 16:02:20 2020 +0200
blkdeactivate: add missing VDO_AVAILABLE check in deactivate_vdo
(cherry picked from commit 8806f2d5ed4792042b246b930fb44f24b9ee45c2)
---
scripts/blkdeactivate.sh.in | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/scripts/blkdeactivate.sh.in b/scripts/blkdeactivate.sh.in
index 57b3e58bf..7c517b87b 100644
--- a/scripts/blkdeactivate.sh.in
+++ b/scripts/blkdeactivate.sh.in
@@ -330,6 +330,12 @@ deactivate_vdo() {
test -b "$DEV_DIR/mapper/$xname" || return 0
test -z "${SKIP_DEVICE_LIST["$kname"]}" || return 1
+ # Skip VDO device deactivation if VDO tools missing.
+ test "$VDO_AVAILABLE" -eq 0 && {
+ add_device_to_skip_list
+ return 1
+ }
+
deactivate_holders "$DEV_DIR/mapper/$xname" || return 1
echo -n " [VDO]: deactivating VDO volume $xname... "
3 years, 6 months
stable-2.02 - tests: extend area covered by error target
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e5af7bef22388113420...
Commit: e5af7bef223881134209b71f90240cdbf59d9ec1
Parent: 5ad30c57b3415150f6b71b0828eedc3d92ea49a8
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Oct 6 15:45:19 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 18 21:28:13 2020 +0200
tests: extend area covered by error target
Since 'BLKZEROOUT' streams out more block at once, at can easily
zero-out larger set of blocks after 1st. failing one.
So the test is adapted to fully 'hide' swap header under error target.
---
test/shell/lvcreate-signature-wiping.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/shell/lvcreate-signature-wiping.sh b/test/shell/lvcreate-signature-wiping.sh
index 18d7a2f7e..4893d9a66 100644
--- a/test/shell/lvcreate-signature-wiping.sh
+++ b/test/shell/lvcreate-signature-wiping.sh
@@ -43,7 +43,7 @@ test_blkid_ || skip
lvremove -f $vg/$lv1
# Zeroing stops the command when there is a failure (write error in this case)
-aux error_dev "$dev1" "$(get first_extent_sector "$dev1"):2"
+aux error_dev "$dev1" "$(get first_extent_sector "$dev1"):8"
not lvcreate -l1 -n $lv1 $vg 2>&1 | tee out
grep "Failed to initialize" out
aux enable_dev "$dev1"
3 years, 6 months
stable-2.02 - debug: update messages
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5ad30c57b3415150f6b...
Commit: 5ad30c57b3415150f6b71b0828eedc3d92ea49a8
Parent: b8454b59e1901404d184f6198c87307711f35471
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Sep 29 23:48:45 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 18 21:28:13 2020 +0200
debug: update messages
---
lib/device/dev-io.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/device/dev-io.c b/lib/device/dev-io.c
index 0289a1768..0c9829a03 100644
--- a/lib/device/dev-io.c
+++ b/lib/device/dev-io.c
@@ -412,7 +412,7 @@ static int _dev_get_size_dev(struct device *dev, uint64_t *size)
if (ioctl(fd, BLKGETSIZE64, size) < 0) {
log_sys_error("ioctl BLKGETSIZE64", name);
if (do_close && !dev_close_immediate(dev))
- log_sys_error("close", name);
+ stack;
return 0;
}
@@ -423,7 +423,7 @@ static int _dev_get_size_dev(struct device *dev, uint64_t *size)
log_very_verbose("%s: size is %" PRIu64 " sectors", name, *size);
if (do_close && !dev_close_immediate(dev))
- log_sys_error("close", name);
+ stack;
return 1;
}
@@ -713,7 +713,7 @@ int dev_test_excl(struct device *dev)
static void _close(struct device *dev)
{
if (close(dev->fd))
- log_sys_error("close", dev_name(dev));
+ log_sys_debug("close", dev_name(dev));
dev->fd = -1;
dev->phys_block_size = -1;
dev->block_size = -1;
3 years, 6 months
stable-2.02 - wipe_lv: use BLKZEROOUT when possible
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b8454b59e1901404d18...
Commit: b8454b59e1901404d184f6198c87307711f35471
Parent: ac5cf1544efef5a585f7e66edf2d3cfbf7bbbe8d
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 19:32:28 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 18 21:28:13 2020 +0200
wipe_lv: use BLKZEROOUT when possible
Since BLKZEROOUT ioctl should be supposedly fastest
way how to clear block device start using this ioctl
for zeroing a device. Commonly we do zero typically
small portion of a device (8KiB) - however since we now
also started to zero metadata devices, in the case
of i.e. thin-pool metadata this can go upto ~16GiB
and here the performance starts to be noticable.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index e4a61dcbc..31f21ce4f 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.188 -
==================================
+ Support using BLKZEROOUT for clearing devices.
Support interruption when wipping LVs.
Add configure --enable-editline support as an alternative to readline.
Zero pool metadata on allocation (disable with allocation/zero_metadata=0).
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index d24c1984f..4b1b4de61 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -33,6 +33,11 @@
#include "label.h"
#include "lvm-signal.h"
+#ifdef HAVE_BLKZEROOUT
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+#endif
+
typedef enum {
PREFERRED,
USE_AREA,
@@ -7270,6 +7275,33 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
display_size(lv->vg->cmd, zero_sectors),
display_lvname(lv), wp.zero_value);
+#ifdef HAVE_BLKZEROOUT
+ if (!test_mode() && !wp.zero_value) {
+ /* TODO: maybe integrate with bcache_zero_set() */
+ const uint64_t end = zero_sectors << SECTOR_SHIFT;
+ uint64_t range[2] = { 0, 1024 * 1024 }; /* zeroing with 1M steps (for better ^C support) */
+ for (/* empty */ ; range[0] < end; range[0] += range[1]) {
+ if ((range[0] + range[1]) > end)
+ range[1] = end - range[0];
+
+ if (ioctl(dev->bcache_fd, BLKZEROOUT, &range)) {
+ if (errno == EINVAL)
+ goto retry_with_dev_set; /* Kernel without support for BLKZEROOUT */
+ log_sys_debug("ioctl", "BLKZEROOUT");
+ sigint_restore();
+ label_scan_invalidate(dev);
+ if (sigint_caught())
+ log_error("Interrupted initialization logical volume %s.",
+ display_lvname(lv));
+ else
+ log_error("Failed to initialize logical volume %s at position " FMTu64 " and size " FMTu64 ".",
+ display_lvname(lv), range[0], range[1]);
+ return 0;
+ }
+ }
+ } else
+retry_with_dev_set:
+#endif
if (!dev_set_bytes(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT, wp.zero_value)) {
sigint_restore();
if (sigint_caught()) {
3 years, 6 months
stable-2.02 - configure: check for BLKZEROOUT support
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ac5cf1544efef5a585f...
Commit: ac5cf1544efef5a585f7e66edf2d3cfbf7bbbe8d
Parent: e9241860a85df1fc42cd958ca4109be850c1f8fd
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 18:39:19 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 18 21:28:13 2020 +0200
configure: check for BLKZEROOUT support
---
configure | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
configure.ac | 27 ++++++++++++++++++++++++
include/configure.h.in | 3 +++
3 files changed, 87 insertions(+)
diff --git a/configure b/configure
index 6859d51b1..bb8d50220 100755
--- a/configure
+++ b/configure
@@ -978,6 +978,7 @@ enable_fsadm
enable_blkdeactivate
enable_dmeventd
enable_selinux
+enable_blkzeroout
enable_nls
with_localedir
with_confdir
@@ -1731,6 +1732,7 @@ Optional Features:
--disable-blkdeactivate disable blkdeactivate
--enable-dmeventd enable the device-mapper event daemon
--disable-selinux disable selinux support
+ --disable-blkzeroout do not use BLKZEROOUT for device zeroing
--enable-nls enable Native Language Support
Optional Packages:
@@ -14113,6 +14115,61 @@ fi
fi
+################################################################################
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BLKZEROOUT in sys/ioctl.h." >&5
+$as_echo_n "checking for BLKZEROOUT in sys/ioctl.h.... " >&6; }
+if ${ac_cv_have_blkzeroout+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/ioctl.h>
+#include <linux/fs.h>
+int bar(void) { return ioctl(0, BLKZEROOUT, 0); }
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_have_blkzeroout=yes
+else
+ ac_cv_have_blkzeroout=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_blkzeroout" >&5
+$as_echo "$ac_cv_have_blkzeroout" >&6; }
+
+
+# Check whether --enable-blkzeroout was given.
+if test "${enable_blkzeroout+set}" = set; then :
+ enableval=$enable_blkzeroout; BLKZEROOUT=$enableval
+else
+ BLKZEROOUT=yes
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to use BLKZEROOUT for device zeroing" >&5
+$as_echo_n "checking whether to use BLKZEROOUT for device zeroing... " >&6; }
+if test "$BLKZEROOUT" = yes; then
+ if test $ac_cv_have_blkzeroout = yes; then :
+
+$as_echo "#define HAVE_BLKZEROOUT 1" >>confdefs.h
+
+else
+ BLKZEROOUT=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $BLKZEROOUT" >&5
+$as_echo "$BLKZEROOUT" >&6; }
+
+
################################################################################
RT_LIBS=
HAVE_REALTIME=no
diff --git a/configure.ac b/configure.ac
index 9d90ff062..f040a5a71 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1588,6 +1588,33 @@ if test "$SELINUX" = yes; then
HAVE_SELINUX=no ])
fi
+################################################################################
+dnl -- Check BLKZEROOUT support
+
+AC_CACHE_CHECK([for BLKZEROOUT in sys/ioctl.h.],
+ [ac_cv_have_blkzeroout],
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[#include <sys/ioctl.h>
+#include <linux/fs.h>
+int bar(void) { return ioctl(0, BLKZEROOUT, 0); }]
+ )], [ac_cv_have_blkzeroout=yes], [ac_cv_have_blkzeroout=no])])
+
+
+AC_ARG_ENABLE(blkzeroout,
+ AC_HELP_STRING([--disable-blkzeroout],
+ [do not use BLKZEROOUT for device zeroing]),
+ BLKZEROOUT=$enableval, BLKZEROOUT=yes)
+
+AC_MSG_CHECKING(whether to use BLKZEROOUT for device zeroing)
+if test "$BLKZEROOUT" = yes; then
+ AC_IF_YES(ac_cv_have_blkzeroout,
+ AC_DEFINE(HAVE_BLKZEROOUT, 1,
+ [Define if ioctl BLKZEROOUT can be used for device zeroing.]),
+ BLKZEROOUT=no)
+fi
+AC_MSG_RESULT($BLKZEROOUT)
+
+
################################################################################
dnl -- Check for realtime clock support
RT_LIBS=
diff --git a/include/configure.h.in b/include/configure.h.in
index 94f755c82..49663e484 100644
--- a/include/configure.h.in
+++ b/include/configure.h.in
@@ -172,6 +172,9 @@
/* Define to 1 if you have the `atexit' function. */
#undef HAVE_ATEXIT
+/* Define if ioctl BLKZEROOUT can be used for device zeroing. */
+#undef HAVE_BLKZEROOUT
+
/* Define to 1 if canonicalize_file_name is available. */
#undef HAVE_CANONICALIZE_FILE_NAME
3 years, 6 months
stable-2.02 - wipe_lv: interruptible wiping
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e9241860a85df1fc42c...
Commit: e9241860a85df1fc42cd958ca4109be850c1f8fd
Parent: e94e0cd0206044780bdde19b833d818da8f3f651
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri Oct 2 19:31:05 2020 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Sun Oct 18 21:28:13 2020 +0200
wipe_lv: interruptible wiping
Since we now block signals and wiping may take unexpectedly long
time - support breaking command while wipe is in progress.
---
WHATS_NEW | 1 +
lib/metadata/lv_manip.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/WHATS_NEW b/WHATS_NEW
index 764af0da4..e4a61dcbc 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.188 -
==================================
+ Support interruption when wipping LVs.
Add configure --enable-editline support as an alternative to readline.
Zero pool metadata on allocation (disable with allocation/zero_metadata=0).
Failure in zeroing or wiping will fail command (bypass with -Zn, -Wn).
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 7576eaeba..d24c1984f 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -31,6 +31,7 @@
#include "memlock.h"
#include "lvmlockd.h"
#include "label.h"
+#include "lvm-signal.h"
typedef enum {
PREFERRED,
@@ -7225,12 +7226,20 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
return 0;
}
+ sigint_allow();
if (wp.do_wipe_signatures) {
log_verbose("Wiping known signatures on logical volume %s.",
display_lvname(lv));
if (!wipe_known_signatures(lv->vg->cmd, dev, name, 0,
TYPE_DM_SNAPSHOT_COW,
wp.yes, wp.force, NULL)) {
+ sigint_restore();
+ label_scan_invalidate(dev);
+ if (sigint_caught()) {
+ log_error("Interrupted initialization logical volume %s.",
+ display_lvname(lv));
+ return 0;
+ }
log_error("Filed to wipe signatures of logical volume %s.",
display_lvname(lv));
return 0;
@@ -7262,12 +7271,19 @@ int wipe_lv(struct logical_volume *lv, struct wipe_params wp)
display_lvname(lv), wp.zero_value);
if (!dev_set_bytes(dev, UINT64_C(0), (size_t) zero_sectors << SECTOR_SHIFT, wp.zero_value)) {
+ sigint_restore();
+ if (sigint_caught()) {
+ log_error("Interrupted initialization logical volume %s.",
+ display_lvname(lv));
+ return 0;
+ }
log_error("Failed to initialize %s of logical volume %s with value %d.",
display_size(lv->vg->cmd, zero_sectors),
display_lvname(lv), wp.zero_value);
return 0;
}
}
+ sigint_restore();
label_scan_invalidate(dev);
3 years, 6 months