master - integrity: wait for raid sync to complete
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=950d2d59c140c82fea3...
Commit: 950d2d59c140c82fea35e56d34c92289562d4d6f
Parent: 48872b0369af5ee048c947586d7da82d9769f5c3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jun 16 12:29:41 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jun 16 12:29:41 2020 -0500
integrity: wait for raid sync to complete
---
test/shell/integrity-misc.sh | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/test/shell/integrity-misc.sh b/test/shell/integrity-misc.sh
index 0d056890c..2dae25f59 100644
--- a/test/shell/integrity-misc.sh
+++ b/test/shell/integrity-misc.sh
@@ -95,7 +95,7 @@ _sync_percent() {
get lv_field "$checklv" sync_percent | cut -d. -f1
}
-_wait_recalc() {
+_wait_sync() {
local checklv=$1
for i in $(seq 1 10) ; do
@@ -124,8 +124,9 @@ _wait_recalc() {
# lvrename
_prepare_vg
lvcreate --type raid1 -m1 --raidintegrity y -n $lv1 -l 8 $vg
-_wait_recalc $vg/${lv1}_rimage_0
-_wait_recalc $vg/${lv1}_rimage_1
+_wait_sync $vg/${lv1}_rimage_0
+_wait_sync $vg/${lv1}_rimage_1
+_wait_sync $vg/$lv1
_add_new_data_to_mnt
umount $mnt
lvrename $vg/$lv1 $vg/$lv2
@@ -141,8 +142,9 @@ vgremove -ff $vg
# lv must be active
_prepare_vg
lvcreate --type raid1 -m1 --raidintegrity y -n $lv1 -l 8 $vg "$dev1" "$dev2"
-_wait_recalc $vg/${lv1}_rimage_0
-_wait_recalc $vg/${lv1}_rimage_1
+_wait_sync $vg/${lv1}_rimage_0
+_wait_sync $vg/${lv1}_rimage_1
+_wait_sync $vg/$lv1
_add_new_data_to_mnt
lvconvert --replace "$dev1" $vg/$lv1 "$dev3"
lvs -a -o+devices $vg > out
@@ -162,8 +164,9 @@ vgremove -ff $vg
# same as prev but with bitmap mode
_prepare_vg
lvcreate --type raid1 -m1 --raidintegrity y --raidintegritymode bitmap -n $lv1 -l 8 $vg "$dev1" "$dev2"
-_wait_recalc $vg/${lv1}_rimage_0
-_wait_recalc $vg/${lv1}_rimage_1
+_wait_sync $vg/${lv1}_rimage_0
+_wait_sync $vg/${lv1}_rimage_1
+_wait_sync $vg/$lv1
_add_new_data_to_mnt
lvconvert --replace "$dev1" $vg/$lv1 "$dev3"
lvs -a -o+devices $vg > out
@@ -185,8 +188,9 @@ vgremove -ff $vg
# (like lvconvert --replace does for a dev that's not missing).
_prepare_vg
lvcreate --type raid1 -m1 --raidintegrity y -n $lv1 -l 8 $vg "$dev1" "$dev2"
-_wait_recalc $vg/${lv1}_rimage_0
-_wait_recalc $vg/${lv1}_rimage_1
+_wait_sync $vg/${lv1}_rimage_0
+_wait_sync $vg/${lv1}_rimage_1
+_wait_sync $vg/$lv1
_add_new_data_to_mnt
aux disable_dev "$dev2"
lvs -a -o+devices $vg > out
@@ -213,8 +217,9 @@ vgremove -ff $vg
_prepare_vg
lvcreate --type raid1 -m1 --raidintegrity y -n $lv1 -l 8 $vg "$dev1" "$dev2"
-_wait_recalc $vg/${lv1}_rimage_0
-_wait_recalc $vg/${lv1}_rimage_1
+_wait_sync $vg/${lv1}_rimage_0
+_wait_sync $vg/${lv1}_rimage_1
+_wait_sync $vg/$lv1
_add_new_data_to_mnt
umount $mnt
lvchange -an $vg/$lv1
3 years, 10 months
master - integrity: avoid increasing logical block size of active LV
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=48872b0369af5ee048c...
Commit: 48872b0369af5ee048c947586d7da82d9769f5c3
Parent: a014c4f3411f6b2f6c4c721a84253eed46cc3de6
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Jun 16 11:59:59 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Jun 16 12:27:22 2020 -0500
integrity: avoid increasing logical block size of active LV
When adding integrity to an active LV, avoid choosing an
integrity block size that would result in increasing the
logical block size of the LV.
---
lib/metadata/integrity_manip.c | 12 +++++++++---
test/shell/integrity-blocksize-2.sh | 39 +++++++++++++++++++------------------
test/shell/integrity-blocksize-3.sh | 39 +++++++++++++++++++------------------
test/shell/integrity-blocksize.sh | 20 +++++++++++++++----
test/shell/integrity-large.sh | 2 +-
5 files changed, 66 insertions(+), 46 deletions(-)
diff --git a/lib/metadata/integrity_manip.c b/lib/metadata/integrity_manip.c
index 790642dbb..334452711 100644
--- a/lib/metadata/integrity_manip.c
+++ b/lib/metadata/integrity_manip.c
@@ -278,7 +278,7 @@ int lv_remove_integrity_from_raid(struct logical_volume *lv)
return 1;
}
-static int _set_integrity_block_size(struct cmd_context *cmd, struct logical_volume *lv,
+static int _set_integrity_block_size(struct cmd_context *cmd, struct logical_volume *lv, int is_active,
struct integrity_settings *settings,
int lbs_4k, int lbs_512, int pbs_4k, int pbs_512)
{
@@ -375,7 +375,13 @@ static int _set_integrity_block_size(struct cmd_context *cmd, struct logical_vol
}
if (!settings->block_size) {
- if (fs_block_size <= 4096)
+ if (is_active && lbs_512) {
+ /* increasing the lbs from 512 to 4k under an active LV could cause problems
+ for an application that expects a given io size/alignment is possible. */
+ settings->block_size = 512;
+ if (fs_block_size > 512)
+ log_print("Limiting integrity block size to 512 because the LV is active.");
+ } else if (fs_block_size <= 4096)
settings->block_size = fs_block_size;
else
settings->block_size = 4096; /* dm-integrity max is 4096 */
@@ -602,7 +608,7 @@ int lv_add_integrity_to_raid(struct logical_volume *lv, struct integrity_setting
* integrity block size chosen based on device logical block size and
* file system block size.
*/
- if (!_set_integrity_block_size(cmd, lv, settings, lbs_4k, lbs_512, pbs_4k, pbs_512)) {
+ if (!_set_integrity_block_size(cmd, lv, is_active, settings, lbs_4k, lbs_512, pbs_4k, pbs_512)) {
if (!is_active && !deactivate_lv(cmd, lv))
stack;
goto_bad;
diff --git a/test/shell/integrity-blocksize-2.sh b/test/shell/integrity-blocksize-2.sh
index a7bb71f9a..5e0fd9ad1 100644
--- a/test/shell/integrity-blocksize-2.sh
+++ b/test/shell/integrity-blocksize-2.sh
@@ -81,28 +81,29 @@ umount $mnt
lvchange -an $vg/$lv1
lvremove $vg/$lv1
-# FIXME: the second xfs mount fails related to block size and converting active LV, bug 1847180
# add integrity while LV is active, fs unmounted
-#lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
-#lvchange -an $vg/$lv1
-#lvchange -ay $vg/$lv1
-#mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
-#mount "$DM_DEV_DIR/$vg/$lv1" $mnt
-#echo "hello world" > $mnt/hello
-#umount $mnt
-#lvchange -an $vg
-#lvchange -ay $vg
-#lvconvert --raidintegrity y $vg/$lv1
-#_wait_recalc $vg/${lv1}_rimage_0
-#_wait_recalc $vg/${lv1}_rimage_1
-#lvs -a -o+devices $vg
-#mount "$DM_DEV_DIR/$vg/$lv1" $mnt
-#cat $mnt/hello | grep "hello world"
-#umount $mnt
-#lvchange -an $vg/$lv1
-#lvremove $vg/$lv1
+# lvconvert will use ribs 512 to avoid increasing LBS from 512 to 4k on active LV
+lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
+lvchange -an $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+echo "hello world" > $mnt/hello
+umount $mnt
+lvchange -an $vg
+lvchange -ay $vg
+lvconvert --raidintegrity y $vg/$lv1
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+lvs -a -o+devices $vg
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+cat $mnt/hello | grep "hello world"
+umount $mnt
+lvchange -an $vg/$lv1
+lvremove $vg/$lv1
# add integrity while LV is active, fs mounted
+# lvconvert will use ribs 512 to avoid increasing LBS from 512 to 4k on active LV
lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
lvchange -an $vg/$lv1
lvchange -ay $vg/$lv1
diff --git a/test/shell/integrity-blocksize-3.sh b/test/shell/integrity-blocksize-3.sh
index 7170aa907..4aea97253 100644
--- a/test/shell/integrity-blocksize-3.sh
+++ b/test/shell/integrity-blocksize-3.sh
@@ -236,28 +236,29 @@ umount $mnt
lvchange -an $vg/$lv1
lvremove $vg/$lv1
-# FIXME: second xfs mount fails related to block size and converting active LV, bug 1847180
# add integrity while LV is active, fs unmounted
-#lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
-#lvchange -an $vg/$lv1
-#lvchange -ay $vg/$lv1
-#mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
-#mount "$DM_DEV_DIR/$vg/$lv1" $mnt
-#echo "hello world" > $mnt/hello
-#umount $mnt
-#lvchange -an $vg
-#lvchange -ay $vg
-#lvconvert --raidintegrity y $vg/$lv1
-#_wait_recalc $vg/${lv1}_rimage_0
-#_wait_recalc $vg/${lv1}_rimage_1
-#lvs -a -o+devices $vg
-#mount "$DM_DEV_DIR/$vg/$lv1" $mnt
-#cat $mnt/hello | grep "hello world"
-#umount $mnt
-#lvchange -an $vg/$lv1
-#lvremove $vg/$lv1
+# lvconvert will use ribs 512 to avoid increasing LBS from 512 to 4k on active LV
+lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
+lvchange -an $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+echo "hello world" > $mnt/hello
+umount $mnt
+lvchange -an $vg
+lvchange -ay $vg
+lvconvert --raidintegrity y $vg/$lv1
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+lvs -a -o+devices $vg
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+cat $mnt/hello | grep "hello world"
+umount $mnt
+lvchange -an $vg/$lv1
+lvremove $vg/$lv1
# add integrity while LV is active, fs mounted
+# lvconvert will use ribs 512 to avoid increasing LBS from 512 to 4k on active LV
lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
lvchange -an $vg/$lv1
lvchange -ay $vg/$lv1
diff --git a/test/shell/integrity-blocksize.sh b/test/shell/integrity-blocksize.sh
index a829502d1..eb6a364f2 100644
--- a/test/shell/integrity-blocksize.sh
+++ b/test/shell/integrity-blocksize.sh
@@ -140,7 +140,7 @@ umount $mnt
pvck --dump metadata $LOOP3 | grep 'block_size = 4096'
lvremove -y $vg2/$lv1
-# lvconvert on dev512, ext4 1024, result 1024
+# lvconvert on dev512, ext4 1024, result 1024 (LV active when adding)
lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg1
aux wipefs_a /dev/$vg1/$lv1
mkfs.ext4 -b 1024 "$DM_DEV_DIR/$vg1/$lv1"
@@ -149,6 +149,20 @@ lvconvert --raidintegrity y $vg1/$lv1
blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"1024\"
mount "$DM_DEV_DIR/$vg1/$lv1" $mnt
umount $mnt
+pvck --dump metadata $LOOP1 | grep 'block_size = 512'
+lvremove -y $vg1/$lv1
+
+# lvconvert on dev512, ext4 1024, result 1024 (LV inactive when adding)
+lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg1
+aux wipefs_a /dev/$vg1/$lv1
+mkfs.ext4 -b 1024 "$DM_DEV_DIR/$vg1/$lv1"
+blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"1024\"
+lvchange -an $vg1/$lv1
+lvconvert --raidintegrity y $vg1/$lv1
+lvchange -ay $vg1/$lv1
+blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"1024\"
+mount "$DM_DEV_DIR/$vg1/$lv1" $mnt
+umount $mnt
pvck --dump metadata $LOOP1 | grep 'block_size = 1024'
lvremove -y $vg1/$lv1
@@ -176,15 +190,13 @@ umount $mnt
pvck --dump metadata $LOOP1 | grep 'block_size = 512'
lvremove -y $vg1/$lv1
-# FIXME: if lv is active while integrity is added, then xfs mount fails related to block size, bug 1847180
# lvconvert --bs 1024 on dev512, xfs 4096, result 1024
lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg1
aux wipefs_a /dev/$vg1/$lv1
mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg1/$lv1"
blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"4096\"
-# TODO: also test adding integrity when the lv is active,
-# and also when the lv is active and fs is mounted?
lvchange -an $vg1/$lv1
+# lv needs to be inactive to increase LBS from 512
lvconvert --raidintegrity y --raidintegrityblocksize 1024 $vg1/$lv1
lvchange -ay $vg1/$lv1
blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"4096\"
diff --git a/test/shell/integrity-large.sh b/test/shell/integrity-large.sh
index 016d100d9..1df9e6b53 100644
--- a/test/shell/integrity-large.sh
+++ b/test/shell/integrity-large.sh
@@ -115,8 +115,8 @@ lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
lvchange -an $vg/$lv1
lvchange -ay $vg/$lv1
_add_data_to_lv
+# lv needs to be inactive when adding integrity to increase LBS from 512 and get a ribs of 4k
lvchange -an $vg/$lv1
-# FIXME: if lv remains active during convert, then xfs mount fails related to block size, bug 1847180
lvconvert --raidintegrity y $vg/$lv1
lvchange -ay $vg/$lv1
_wait_recalc $vg/${lv1}_rimage_0
3 years, 10 months
master - tests: integrity and block size
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a014c4f3411f6b2f6c4...
Commit: a014c4f3411f6b2f6c4c721a84253eed46cc3de6
Parent: 8e2938c963bb8226b72297647bef89895e5ae548
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Jun 15 14:08:28 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Jun 15 16:04:40 2020 -0500
tests: integrity and block size
---
test/shell/integrity-blocksize-2.sh | 127 ++++++++++++++++
test/shell/integrity-blocksize-3.sh | 284 ++++++++++++++++++++++++++++++++++++
test/shell/integrity-blocksize.sh | 46 ++++--
test/shell/integrity-large.sh | 3 +
4 files changed, 445 insertions(+), 15 deletions(-)
diff --git a/test/shell/integrity-blocksize-2.sh b/test/shell/integrity-blocksize-2.sh
new file mode 100644
index 000000000..a7bb71f9a
--- /dev/null
+++ b/test/shell/integrity-blocksize-2.sh
@@ -0,0 +1,127 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2018 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 have_integrity 1 5 0 || skip
+
+mnt="mnt"
+mkdir -p $mnt
+
+_sync_percent() {
+ local checklv=$1
+ get lv_field "$checklv" sync_percent | cut -d. -f1
+}
+
+_wait_recalc() {
+ local checklv=$1
+
+ for i in $(seq 1 10) ; do
+ sync=$(_sync_percent "$checklv")
+ echo "sync_percent is $sync"
+
+ if test "$sync" = "100"; then
+ return
+ fi
+
+ sleep 1
+ done
+
+ # TODO: There is some strange bug, first leg of RAID with integrity
+ # enabled never gets in sync. I saw this in BB, but not when executing
+ # the commands manually
+ if test -z "$sync"; then
+ echo "TEST WARNING: Resync of dm-integrity device '$checklv' failed"
+ dmsetup status "$DM_DEV_DIR/mapper/${checklv/\//-}"
+ exit
+ fi
+ echo "timeout waiting for recalc"
+ return 1
+}
+
+# prepare_devs uses ramdisk backing which has 512 LBS and 4K PBS
+# This should cause mkfs.xfs to use 4K sector size,
+# and integrity to use 4K block size
+aux prepare_devs 2 64
+
+vgcreate $vg "$dev1" "$dev2"
+blockdev --getss "$dev1"
+blockdev --getpbsz "$dev1"
+blockdev --getss "$dev2"
+blockdev --getpbsz "$dev2"
+
+# add integrity while LV is inactive
+lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
+lvchange -an $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+echo "hello world" > $mnt/hello
+umount $mnt
+lvchange -an $vg
+lvconvert --raidintegrity y $vg/$lv1
+lvchange -ay $vg
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+lvs -a -o+devices $vg
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+cat $mnt/hello
+umount $mnt
+lvchange -an $vg/$lv1
+lvremove $vg/$lv1
+
+# FIXME: the second xfs mount fails related to block size and converting active LV, bug 1847180
+# add integrity while LV is active, fs unmounted
+#lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
+#lvchange -an $vg/$lv1
+#lvchange -ay $vg/$lv1
+#mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+#mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+#echo "hello world" > $mnt/hello
+#umount $mnt
+#lvchange -an $vg
+#lvchange -ay $vg
+#lvconvert --raidintegrity y $vg/$lv1
+#_wait_recalc $vg/${lv1}_rimage_0
+#_wait_recalc $vg/${lv1}_rimage_1
+#lvs -a -o+devices $vg
+#mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+#cat $mnt/hello | grep "hello world"
+#umount $mnt
+#lvchange -an $vg/$lv1
+#lvremove $vg/$lv1
+
+# add integrity while LV is active, fs mounted
+lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
+lvchange -an $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+echo "hello world" > $mnt/hello
+lvconvert --raidintegrity y $vg/$lv1
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+lvs -a -o+devices $vg
+cat $mnt/hello | grep "hello world"
+umount $mnt
+lvchange -an $vg/$lv1
+lvchange -ay $vg/$lv1
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+cat $mnt/hello | grep "hello world"
+umount $mnt
+lvchange -an $vg/$lv1
+lvremove $vg/$lv1
+
+vgremove -ff $vg
+
diff --git a/test/shell/integrity-blocksize-3.sh b/test/shell/integrity-blocksize-3.sh
new file mode 100644
index 000000000..7170aa907
--- /dev/null
+++ b/test/shell/integrity-blocksize-3.sh
@@ -0,0 +1,284 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2018 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 have_integrity 1 5 0 || skip
+
+mnt="mnt"
+mkdir -p $mnt
+
+_sync_percent() {
+ local checklv=$1
+ get lv_field "$checklv" sync_percent | cut -d. -f1
+}
+
+_wait_recalc() {
+ local checklv=$1
+
+ for i in $(seq 1 10) ; do
+ sync=$(_sync_percent "$checklv")
+ echo "sync_percent is $sync"
+
+ if test "$sync" = "100"; then
+ return
+ fi
+
+ sleep 1
+ done
+
+ # TODO: There is some strange bug, first leg of RAID with integrity
+ # enabled never gets in sync. I saw this in BB, but not when executing
+ # the commands manually
+ if test -z "$sync"; then
+ echo "TEST WARNING: Resync of dm-integrity device '$checklv' failed"
+ dmsetup status "$DM_DEV_DIR/mapper/${checklv/\//-}"
+ exit
+ fi
+ echo "timeout waiting for recalc"
+ return 1
+}
+
+# scsi_debug devices with 512 LBS 512 PBS
+aux prepare_scsi_debug_dev 256
+check sysfs "$(< SCSI_DEBUG_DEV)" queue/logical_block_size "512"
+check sysfs "$(< SCSI_DEBUG_DEV)" queue/physical_block_size "512"
+aux prepare_devs 2 64
+
+vgcreate $vg "$dev1" "$dev2"
+blockdev --getss "$dev1"
+blockdev --getpbsz "$dev1"
+blockdev --getss "$dev2"
+blockdev --getpbsz "$dev2"
+
+# add integrity while LV is inactive
+lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
+lvchange -an $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+echo "hello world" > $mnt/hello
+umount $mnt
+lvchange -an $vg
+lvconvert --raidintegrity y $vg/$lv1
+lvchange -ay $vg
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+lvs -a -o+devices $vg
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+cat $mnt/hello
+umount $mnt
+lvchange -an $vg/$lv1
+lvremove $vg/$lv1
+
+# add integrity while LV is active, fs unmounted
+lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
+lvchange -an $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+echo "hello world" > $mnt/hello
+umount $mnt
+lvchange -an $vg
+lvchange -ay $vg
+lvconvert --raidintegrity y $vg/$lv1
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+lvs -a -o+devices $vg
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+cat $mnt/hello | grep "hello world"
+umount $mnt
+lvchange -an $vg/$lv1
+lvremove $vg/$lv1
+
+# add integrity while LV is active, fs mounted
+lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
+lvchange -an $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+echo "hello world" > $mnt/hello
+lvconvert --raidintegrity y $vg/$lv1
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+lvs -a -o+devices $vg
+cat $mnt/hello | grep "hello world"
+umount $mnt
+lvchange -an $vg/$lv1
+lvchange -ay $vg/$lv1
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+cat $mnt/hello | grep "hello world"
+umount $mnt
+lvchange -an $vg/$lv1
+lvremove $vg/$lv1
+
+vgremove -ff $vg
+aux cleanup_scsi_debug_dev
+sleep 1
+
+# scsi_debug devices with 4K LBS and 4K PBS
+aux prepare_scsi_debug_dev 256 sector_size=4096
+check sysfs "$(< SCSI_DEBUG_DEV)" queue/logical_block_size "4096"
+check sysfs "$(< SCSI_DEBUG_DEV)" queue/physical_block_size "4096"
+aux prepare_devs 2 64
+
+vgcreate $vg "$dev1" "$dev2"
+blockdev --getss "$dev1"
+blockdev --getpbsz "$dev1"
+blockdev --getss "$dev2"
+blockdev --getpbsz "$dev2"
+
+# add integrity while LV is inactive
+lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
+lvchange -an $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+echo "hello world" > $mnt/hello
+umount $mnt
+lvchange -an $vg
+lvconvert --raidintegrity y $vg/$lv1
+lvchange -ay $vg
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+lvs -a -o+devices $vg
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+cat $mnt/hello
+umount $mnt
+lvchange -an $vg/$lv1
+lvremove $vg/$lv1
+
+# add integrity while LV is active, fs unmounted
+lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
+lvchange -an $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+echo "hello world" > $mnt/hello
+umount $mnt
+lvchange -an $vg
+lvchange -ay $vg
+lvconvert --raidintegrity y $vg/$lv1
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+lvs -a -o+devices $vg
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+cat $mnt/hello | grep "hello world"
+umount $mnt
+lvchange -an $vg/$lv1
+lvremove $vg/$lv1
+
+# add integrity while LV is active, fs mounted
+lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
+lvchange -an $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+echo "hello world" > $mnt/hello
+lvconvert --raidintegrity y $vg/$lv1
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+lvs -a -o+devices $vg
+cat $mnt/hello | grep "hello world"
+umount $mnt
+lvchange -an $vg/$lv1
+lvchange -ay $vg/$lv1
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+cat $mnt/hello | grep "hello world"
+umount $mnt
+lvchange -an $vg/$lv1
+lvremove $vg/$lv1
+
+vgremove -ff $vg
+aux cleanup_scsi_debug_dev
+sleep 1
+
+# scsi_debug devices with 512 LBS and 4K PBS
+aux prepare_scsi_debug_dev 256 sector_size=512 physblk_exp=3
+check sysfs "$(< SCSI_DEBUG_DEV)" queue/logical_block_size "512"
+check sysfs "$(< SCSI_DEBUG_DEV)" queue/physical_block_size "4096"
+aux prepare_devs 2 64
+
+vgcreate $vg "$dev1" "$dev2"
+blockdev --getss "$dev1"
+blockdev --getpbsz "$dev1"
+blockdev --getss "$dev2"
+blockdev --getpbsz "$dev2"
+
+# add integrity while LV is inactive
+lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
+lvchange -an $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+echo "hello world" > $mnt/hello
+umount $mnt
+lvchange -an $vg
+lvconvert --raidintegrity y $vg/$lv1
+lvchange -ay $vg
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+lvs -a -o+devices $vg
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+cat $mnt/hello
+umount $mnt
+lvchange -an $vg/$lv1
+lvremove $vg/$lv1
+
+# FIXME: second xfs mount fails related to block size and converting active LV, bug 1847180
+# add integrity while LV is active, fs unmounted
+#lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
+#lvchange -an $vg/$lv1
+#lvchange -ay $vg/$lv1
+#mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+#mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+#echo "hello world" > $mnt/hello
+#umount $mnt
+#lvchange -an $vg
+#lvchange -ay $vg
+#lvconvert --raidintegrity y $vg/$lv1
+#_wait_recalc $vg/${lv1}_rimage_0
+#_wait_recalc $vg/${lv1}_rimage_1
+#lvs -a -o+devices $vg
+#mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+#cat $mnt/hello | grep "hello world"
+#umount $mnt
+#lvchange -an $vg/$lv1
+#lvremove $vg/$lv1
+
+# add integrity while LV is active, fs mounted
+lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
+lvchange -an $vg/$lv1
+lvchange -ay $vg/$lv1
+mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+echo "hello world" > $mnt/hello
+lvconvert --raidintegrity y $vg/$lv1
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+lvs -a -o+devices $vg
+cat $mnt/hello | grep "hello world"
+umount $mnt
+lvchange -an $vg/$lv1
+lvchange -ay $vg/$lv1
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+cat $mnt/hello | grep "hello world"
+umount $mnt
+lvchange -an $vg/$lv1
+lvremove $vg/$lv1
+
+vgremove -ff $vg
+aux cleanup_scsi_debug_dev
+sleep 1
+
diff --git a/test/shell/integrity-blocksize.sh b/test/shell/integrity-blocksize.sh
index 8c4b94d49..a829502d1 100644
--- a/test/shell/integrity-blocksize.sh
+++ b/test/shell/integrity-blocksize.sh
@@ -54,6 +54,18 @@ mkdir -p $mnt
vgcreate $vg1 $LOOP1 $LOOP2
vgcreate $vg2 $LOOP3 $LOOP4
+# LOOP1/LOOP2 have LBS 512 and PBS 512
+# LOOP3/LOOP4 have LBS 4K and PBS 4K
+
+blockdev --getss $LOOP1
+blockdev --getpbsz $LOOP1
+blockdev --getss $LOOP2
+blockdev --getpbsz $LOOP2
+blockdev --getss $LOOP3
+blockdev --getpbsz $LOOP3
+blockdev --getss $LOOP4
+blockdev --getpbsz $LOOP4
+
# lvcreate on dev512, result 512
lvcreate --type raid1 -m1 --raidintegrity y -l 8 -n $lv1 $vg1
pvck --dump metadata $LOOP1 | grep 'block_size = 512'
@@ -164,18 +176,22 @@ umount $mnt
pvck --dump metadata $LOOP1 | grep 'block_size = 512'
lvremove -y $vg1/$lv1
-# FIXME: kernel error reported, disallow this combination?
+# FIXME: if lv is active while integrity is added, then xfs mount fails related to block size, bug 1847180
# lvconvert --bs 1024 on dev512, xfs 4096, result 1024
-#lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg1
-#aux wipefs_a /dev/$vg1/$lv1
-#mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg1/$lv1"
-#blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"4096\"
-#lvconvert --raidintegrity y --raidintegrityblocksize 1024 $vg1/$lv1
-#blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"4096\"
-#mount "$DM_DEV_DIR/$vg1/$lv1" $mnt
-#umount $mnt
-#pvck --dump metadata $LOOP1 | grep 'block_size = 1024'
-#lvremove -y $vg1/$lv1
+lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg1
+aux wipefs_a /dev/$vg1/$lv1
+mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg1/$lv1"
+blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"4096\"
+# TODO: also test adding integrity when the lv is active,
+# and also when the lv is active and fs is mounted?
+lvchange -an $vg1/$lv1
+lvconvert --raidintegrity y --raidintegrityblocksize 1024 $vg1/$lv1
+lvchange -ay $vg1/$lv1
+blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"4096\"
+mount "$DM_DEV_DIR/$vg1/$lv1" $mnt
+umount $mnt
+pvck --dump metadata $LOOP1 | grep 'block_size = 1024'
+lvremove -y $vg1/$lv1
# lvconvert --bs 512 on dev512, ext4 1024, result 512
lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg1
@@ -196,10 +212,10 @@ mkfs.ext4 "$DM_DEV_DIR/$vg2/$lv1"
not lvconvert --raidintegrity y --raidintegrityblocksize 512 $vg2/$lv1
lvremove -y $vg2/$lv1
-# FIXME: need to use scsi_debug to create devs with LBS 512 PBS 4k
-# FIXME: lvconvert, fsunknown, LBS 512, PBS 4k: result 512
-# FIXME: lvconvert --bs 512, fsunknown, LBS 512, PBS 4k: result 512
-# FIXME: lvconvert --bs 4k, fsunknown, LBS 512, PBS 4k: result 4k
+# TODO: need to use scsi_debug to create devs with LBS 512 PBS 4k
+# TODO: lvconvert, fsunknown, LBS 512, PBS 4k: result 512
+# TODO: lvconvert --bs 512, fsunknown, LBS 512, PBS 4k: result 512
+# TODO: lvconvert --bs 4k, fsunknown, LBS 512, PBS 4k: result 4k
# lvconvert on dev512, xfs 512, result 512, (detect fs with LV inactive)
lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg1
diff --git a/test/shell/integrity-large.sh b/test/shell/integrity-large.sh
index 5aba80e6a..016d100d9 100644
--- a/test/shell/integrity-large.sh
+++ b/test/shell/integrity-large.sh
@@ -115,7 +115,10 @@ lvcreate --type raid1 -m1 -n $lv1 -l 8 $vg
lvchange -an $vg/$lv1
lvchange -ay $vg/$lv1
_add_data_to_lv
+lvchange -an $vg/$lv1
+# FIXME: if lv remains active during convert, then xfs mount fails related to block size, bug 1847180
lvconvert --raidintegrity y $vg/$lv1
+lvchange -ay $vg/$lv1
_wait_recalc $vg/${lv1}_rimage_0
_wait_recalc $vg/${lv1}_rimage_1
lvs -a -o+devices $vg
3 years, 10 months
master - improve get_fs_block_size string to number
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8e2938c963bb8226b72...
Commit: 8e2938c963bb8226b72297647bef89895e5ae548
Parent: 9f38e95a2f84f148dae1a8ec440adc29eb12d513
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jun 11 15:05:47 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 11 15:05:47 2020 -0500
improve get_fs_block_size string to number
---
lib/device/dev-type.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index e3fa9babb..896821de8 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -650,11 +650,9 @@ out:
int get_fs_block_size(struct device *dev, uint32_t *fs_block_size)
{
char *block_size_str = NULL;
- uint64_t block_size_val;
if ((block_size_str = blkid_get_tag_value(NULL, "BLOCK_SIZE", dev_name(dev)))) {
- block_size_val = strtoull(block_size_str, NULL, 10);
- *fs_block_size = (uint32_t)block_size_val;
+ *fs_block_size = (uint32_t)atoi(block_size_str);
free(block_size_str);
log_debug("Found blkid BLOCK_SIZE %u for fs on %s", *fs_block_size, dev_name(dev));
return 1;
3 years, 10 months
master - tests: fix typo in writecache-blocksize
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9f38e95a2f84f148dae...
Commit: 9f38e95a2f84f148dae1a8ec440adc29eb12d513
Parent: f32e85ae519d9c278d7e76329438f976e91ac317
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jun 11 13:15:38 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 11 13:15:38 2020 -0500
tests: fix typo in writecache-blocksize
---
test/shell/writecache-blocksize.sh | 1 -
1 file changed, 1 deletion(-)
diff --git a/test/shell/writecache-blocksize.sh b/test/shell/writecache-blocksize.sh
index 42c963c29..13001760a 100644
--- a/test/shell/writecache-blocksize.sh
+++ b/test/shell/writecache-blocksize.sh
@@ -264,7 +264,6 @@ blockdev --getpbsz "$dev2"
# lbs 512, pbs 4k, xfs 4k, wc 4k
vgcreate $SHARED $vg "$dev1"
-vgcreate $SHARED $vg "$dev1"
vgextend $vg "$dev2"
lvcreate -n $lv1 -l 8 -an $vg "$dev1"
lvcreate -n $lv2 -l 4 -an $vg "$dev2"
3 years, 10 months
master - tests: expand integrity-blocksize
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=f32e85ae519d9c278d7...
Commit: f32e85ae519d9c278d7e76329438f976e91ac317
Parent: b528a9ce9060ed8d66466f7df86c0eafa7c94ec8
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jun 11 12:46:47 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 11 12:46:47 2020 -0500
tests: expand integrity-blocksize
---
test/shell/integrity-blocksize.sh | 82 ++++++++++++++++++++++++++++++++++++---
1 file changed, 76 insertions(+), 6 deletions(-)
diff --git a/test/shell/integrity-blocksize.sh b/test/shell/integrity-blocksize.sh
index 444e3db4c..8c4b94d49 100644
--- a/test/shell/integrity-blocksize.sh
+++ b/test/shell/integrity-blocksize.sh
@@ -48,6 +48,9 @@ aux extend_filter "a|$LOOP4|"
aux lvmconf 'devices/scan = "/dev"'
+mnt="mnt"
+mkdir -p $mnt
+
vgcreate $vg1 $LOOP1 $LOOP2
vgcreate $vg2 $LOOP3 $LOOP4
@@ -105,7 +108,11 @@ lvremove -y $vg2/$lv1
lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg1
aux wipefs_a /dev/$vg1/$lv1
mkfs.xfs -f "$DM_DEV_DIR/$vg1/$lv1"
+blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"512\"
lvconvert --raidintegrity y $vg1/$lv1
+blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"512\"
+mount "$DM_DEV_DIR/$vg1/$lv1" $mnt
+umount $mnt
pvck --dump metadata $LOOP1 | grep 'block_size = 512'
lvremove -y $vg1/$lv1
@@ -113,7 +120,11 @@ lvremove -y $vg1/$lv1
lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg2
aux wipefs_a /dev/$vg2/$lv1
mkfs.xfs -f "$DM_DEV_DIR/$vg2/$lv1"
+blkid "$DM_DEV_DIR/$vg2/$lv1" | grep BLOCK_SIZE=\"4096\"
lvconvert --raidintegrity y $vg2/$lv1
+blkid "$DM_DEV_DIR/$vg2/$lv1" | grep BLOCK_SIZE=\"4096\"
+mount "$DM_DEV_DIR/$vg2/$lv1" $mnt
+umount $mnt
pvck --dump metadata $LOOP3 | grep 'block_size = 4096'
lvremove -y $vg2/$lv1
@@ -121,7 +132,11 @@ lvremove -y $vg2/$lv1
lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg1
aux wipefs_a /dev/$vg1/$lv1
mkfs.ext4 -b 1024 "$DM_DEV_DIR/$vg1/$lv1"
+blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"1024\"
lvconvert --raidintegrity y $vg1/$lv1
+blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"1024\"
+mount "$DM_DEV_DIR/$vg1/$lv1" $mnt
+umount $mnt
pvck --dump metadata $LOOP1 | grep 'block_size = 1024'
lvremove -y $vg1/$lv1
@@ -129,7 +144,11 @@ lvremove -y $vg1/$lv1
lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg2
aux wipefs_a /dev/$vg2/$lv1
mkfs.ext4 "$DM_DEV_DIR/$vg2/$lv1"
+blkid "$DM_DEV_DIR/$vg2/$lv1" | grep BLOCK_SIZE=\"4096\"
lvconvert --raidintegrity y $vg2/$lv1
+blkid "$DM_DEV_DIR/$vg2/$lv1" | grep BLOCK_SIZE=\"4096\"
+mount "$DM_DEV_DIR/$vg2/$lv1" $mnt
+umount $mnt
pvck --dump metadata $LOOP3 | grep 'block_size = 4096'
lvremove -y $vg2/$lv1
@@ -137,23 +156,36 @@ lvremove -y $vg2/$lv1
lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg1
aux wipefs_a /dev/$vg1/$lv1
mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg1/$lv1"
+blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"4096\"
lvconvert --raidintegrity y --raidintegrityblocksize 512 $vg1/$lv1
+blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"4096\"
+mount "$DM_DEV_DIR/$vg1/$lv1" $mnt
+umount $mnt
pvck --dump metadata $LOOP1 | grep 'block_size = 512'
lvremove -y $vg1/$lv1
+# FIXME: kernel error reported, disallow this combination?
# lvconvert --bs 1024 on dev512, xfs 4096, result 1024
-lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg1
-aux wipefs_a /dev/$vg1/$lv1
-mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg1/$lv1"
-lvconvert --raidintegrity y --raidintegrityblocksize 1024 $vg1/$lv1
-pvck --dump metadata $LOOP1 | grep 'block_size = 1024'
-lvremove -y $vg1/$lv1
+#lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg1
+#aux wipefs_a /dev/$vg1/$lv1
+#mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg1/$lv1"
+#blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"4096\"
+#lvconvert --raidintegrity y --raidintegrityblocksize 1024 $vg1/$lv1
+#blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"4096\"
+#mount "$DM_DEV_DIR/$vg1/$lv1" $mnt
+#umount $mnt
+#pvck --dump metadata $LOOP1 | grep 'block_size = 1024'
+#lvremove -y $vg1/$lv1
# lvconvert --bs 512 on dev512, ext4 1024, result 512
lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg1
aux wipefs_a /dev/$vg1/$lv1
mkfs.ext4 -b 1024 "$DM_DEV_DIR/$vg1/$lv1"
+blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"1024\"
lvconvert --raidintegrity y --raidintegrityblocksize 512 $vg1/$lv1
+blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"1024\"
+mount "$DM_DEV_DIR/$vg1/$lv1" $mnt
+umount $mnt
pvck --dump metadata $LOOP1 | grep 'block_size = 512'
lvremove -y $vg1/$lv1
@@ -169,6 +201,44 @@ lvremove -y $vg2/$lv1
# FIXME: lvconvert --bs 512, fsunknown, LBS 512, PBS 4k: result 512
# FIXME: lvconvert --bs 4k, fsunknown, LBS 512, PBS 4k: result 4k
+# lvconvert on dev512, xfs 512, result 512, (detect fs with LV inactive)
+lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg1
+aux wipefs_a /dev/$vg1/$lv1
+mkfs.xfs -f "$DM_DEV_DIR/$vg1/$lv1"
+mount "$DM_DEV_DIR/$vg1/$lv1" $mnt
+echo "test" > $mnt/test
+umount $mnt
+blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"512\"
+lvchange -an $vg1/$lv1
+lvconvert --raidintegrity y $vg1/$lv1
+lvchange -ay $vg1/$lv1
+mount "$DM_DEV_DIR/$vg1/$lv1" $mnt
+cat $mnt/test
+umount $mnt
+blkid "$DM_DEV_DIR/$vg1/$lv1" | grep BLOCK_SIZE=\"512\"
+pvck --dump metadata $LOOP1 | grep 'block_size = 512'
+lvchange -an $vg1/$lv1
+lvremove -y $vg1/$lv1
+
+# lvconvert on dev4k, xfs 4096, result 4096 (detect fs with LV inactive)
+lvcreate --type raid1 -m1 -l 8 -n $lv1 $vg2
+aux wipefs_a /dev/$vg2/$lv1
+mkfs.xfs -f "$DM_DEV_DIR/$vg2/$lv1"
+mount "$DM_DEV_DIR/$vg2/$lv1" $mnt
+echo "test" > $mnt/test
+umount $mnt
+blkid "$DM_DEV_DIR/$vg2/$lv1" | grep BLOCK_SIZE=\"4096\"
+lvchange -an $vg2/$lv1
+lvconvert --raidintegrity y $vg2/$lv1
+lvchange -ay $vg2/$lv1
+mount "$DM_DEV_DIR/$vg2/$lv1" $mnt
+cat $mnt/test
+umount $mnt
+blkid "$DM_DEV_DIR/$vg2/$lv1" | grep BLOCK_SIZE=\"4096\"
+pvck --dump metadata $LOOP3 | grep 'block_size = 4096'
+lvchange -an $vg2/$lv1
+lvremove -y $vg2/$lv1
+
vgremove -ff $vg1
vgremove -ff $vg2
3 years, 10 months
master - integrity: fix block size check when inactive
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b528a9ce9060ed8d664...
Commit: b528a9ce9060ed8d66466f7df86c0eafa7c94ec8
Parent: 9fbad5bb0fdc7d9a9dca8539e4cd217c5ef1fede
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jun 11 12:43:52 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 11 12:43:52 2020 -0500
integrity: fix block size check when inactive
Checking fs block size requires the LV to be active.
---
lib/metadata/integrity_manip.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/lib/metadata/integrity_manip.c b/lib/metadata/integrity_manip.c
index 7942be0d6..790642dbb 100644
--- a/lib/metadata/integrity_manip.c
+++ b/lib/metadata/integrity_manip.c
@@ -587,13 +587,33 @@ int lv_add_integrity_to_raid(struct logical_volume *lv, struct integrity_setting
}
}
+ if (!is_active) {
+ /* checking block size of fs on the lv requires the lv to be active */
+ if (!activate_lv(cmd, lv)) {
+ log_error("Failed to activate LV to check block size %s", display_lvname(lv));
+ goto bad;
+ }
+ if (!sync_local_dev_names(cmd))
+ stack;
+ }
+
/*
* Set settings->block_size which will be copied to segment settings below.
* integrity block size chosen based on device logical block size and
* file system block size.
*/
- if (!_set_integrity_block_size(cmd, lv, settings, lbs_4k, lbs_512, pbs_4k, pbs_512))
+ if (!_set_integrity_block_size(cmd, lv, settings, lbs_4k, lbs_512, pbs_4k, pbs_512)) {
+ if (!is_active && !deactivate_lv(cmd, lv))
+ stack;
goto_bad;
+ }
+
+ if (!is_active) {
+ if (!deactivate_lv(cmd, lv)) {
+ log_error("Failed to deactivate LV after checking block size %s", display_lvname(lv));
+ goto bad;
+ }
+ }
/*
* For each rimage, move its segments to a new rimage_iorig and give
3 years, 10 months
master - fix libblkid BLOCK_SIZE check
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=9fbad5bb0fdc7d9a9dc...
Commit: 9fbad5bb0fdc7d9a9dca8539e4cd217c5ef1fede
Parent: 6ea3654868e3727b9197113f973e1c7edeed38b2
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Jun 11 12:43:07 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Jun 11 12:43:07 2020 -0500
fix libblkid BLOCK_SIZE check
---
lib/device/dev-type.c | 36 ++++++++++++------------------------
1 file changed, 12 insertions(+), 24 deletions(-)
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index deb5d6a0f..e3fa9babb 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -649,37 +649,25 @@ out:
#ifdef BLKID_WIPING_SUPPORT
int get_fs_block_size(struct device *dev, uint32_t *fs_block_size)
{
- blkid_probe probe = NULL;
- const char *block_size_str = NULL;
+ char *block_size_str = NULL;
uint64_t block_size_val;
- int r = 0;
- *fs_block_size = 0;
-
- if (!(probe = blkid_new_probe_from_filename(dev_name(dev)))) {
- log_error("Failed to create a new blkid probe for device %s.", dev_name(dev));
- goto out;
+ if ((block_size_str = blkid_get_tag_value(NULL, "BLOCK_SIZE", dev_name(dev)))) {
+ block_size_val = strtoull(block_size_str, NULL, 10);
+ *fs_block_size = (uint32_t)block_size_val;
+ free(block_size_str);
+ log_debug("Found blkid BLOCK_SIZE %u for fs on %s", *fs_block_size, dev_name(dev));
+ return 1;
+ } else {
+ log_debug("No blkid BLOCK_SIZE for fs on %s", dev_name(dev));
+ *fs_block_size = 0;
+ return 0;
}
-
- blkid_probe_enable_partitions(probe, 1);
-
- (void) blkid_probe_lookup_value(probe, "BLOCK_SIZE", &block_size_str, NULL);
-
- if (!block_size_str)
- goto out;
-
- block_size_val = strtoull(block_size_str, NULL, 10);
-
- *fs_block_size = (uint32_t)block_size_val;
- r = 1;
-out:
- if (probe)
- blkid_free_probe(probe);
- return r;
}
#else
int get_fs_block_size(struct device *dev, uint32_t *fs_block_size)
{
+ log_debug("Disabled blkid BLOCK_SIZE for fs.");
*fs_block_size = 0;
return 0;
}
3 years, 10 months
master - tests: writecache tests
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6ea3654868e3727b919...
Commit: 6ea3654868e3727b9197113f973e1c7edeed38b2
Parent: ba27b9ee2a67d189a56827774001436556cae8a5
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Jun 10 16:08:28 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Jun 10 16:09:36 2020 -0500
tests: writecache tests
backport updates from later commits
---
test/shell/writecache-large.sh | 153 ++++++++++++++++++++
test/shell/writecache-split.sh | 1 -
test/shell/writecache.sh | 315 +++++++++++++++++++++++++++--------------
3 files changed, 360 insertions(+), 109 deletions(-)
diff --git a/test/shell/writecache-large.sh b/test/shell/writecache-large.sh
new file mode 100644
index 000000000..b52eaf6ab
--- /dev/null
+++ b/test/shell/writecache-large.sh
@@ -0,0 +1,153 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2018 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
+
+# Test writecache usage
+
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux have_writecache 1 0 0 || skip
+which mkfs.xfs || skip
+
+# scsi_debug devices with 512 LBS 512 PBS
+aux prepare_scsi_debug_dev 1200
+check sysfs "$(< SCSI_DEBUG_DEV)" queue/logical_block_size "512"
+check sysfs "$(< SCSI_DEBUG_DEV)" queue/physical_block_size "512"
+
+aux prepare_devs 2 600
+blockdev --getss "$dev1"
+blockdev --getpbsz "$dev1"
+blockdev --getss "$dev2"
+blockdev --getpbsz "$dev2"
+
+mnt="mnt"
+mkdir -p $mnt
+
+for i in `seq 1 16384`; do echo -n "A" >> fileA; done
+for i in `seq 1 16384`; do echo -n "B" >> fileB; done
+for i in `seq 1 16384`; do echo -n "C" >> fileC; done
+
+# generate random data
+dd if=/dev/urandom of=randA bs=512K count=2
+dd if=/dev/urandom of=randB bs=512K count=3
+dd if=/dev/urandom of=randC bs=512K count=4
+
+_add_new_data_to_mnt() {
+ mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+
+ mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+
+ # add original data
+ cp randA $mnt
+ cp randB $mnt
+ cp randC $mnt
+ mkdir $mnt/1
+ cp fileA $mnt/1
+ cp fileB $mnt/1
+ cp fileC $mnt/1
+ mkdir $mnt/2
+ cp fileA $mnt/2
+ cp fileB $mnt/2
+ cp fileC $mnt/2
+ sync
+}
+
+_add_more_data_to_mnt() {
+ mkdir $mnt/more
+ cp fileA $mnt/more
+ cp fileB $mnt/more
+ cp fileC $mnt/more
+ cp randA $mnt/more
+ cp randB $mnt/more
+ cp randC $mnt/more
+ sync
+}
+
+_verify_data_on_mnt() {
+ diff randA $mnt/randA
+ diff randB $mnt/randB
+ diff randC $mnt/randC
+ diff fileA $mnt/1/fileA
+ diff fileB $mnt/1/fileB
+ diff fileC $mnt/1/fileC
+ diff fileA $mnt/2/fileA
+ diff fileB $mnt/2/fileB
+ diff fileC $mnt/2/fileC
+}
+
+_verify_more_data_on_mnt() {
+ diff randA $mnt/more/randA
+ diff randB $mnt/more/randB
+ diff randC $mnt/more/randC
+ diff fileA $mnt/more/fileA
+ diff fileB $mnt/more/fileB
+ diff fileC $mnt/more/fileC
+}
+
+_verify_data_on_lv() {
+ lvchange -ay $vg/$lv1
+ mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+ _verify_data_on_mnt
+ rm $mnt/randA
+ rm $mnt/randB
+ rm $mnt/randC
+ rm -rf $mnt/1
+ rm -rf $mnt/2
+ umount $mnt
+ lvchange -an $vg/$lv1
+}
+
+vgcreate $SHARED $vg "$dev1"
+vgextend $vg "$dev2"
+
+# Use a large enough size so that the cleaner will not
+# finish immediately when detaching, and will require
+# a secondary check from command top level.
+
+lvcreate -n $lv1 -L 560M -an $vg "$dev1"
+lvcreate -n $lv2 -L 500M -an $vg "$dev2"
+
+lvchange -ay $vg/$lv1
+blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
+blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
+
+lvconvert --yes --type writecache --cachevol $lv2 $vg/$lv1
+dmsetup table $vg-$lv1
+blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
+blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
+
+_add_new_data_to_mnt
+_add_more_data_to_mnt
+_verify_data_on_mnt
+
+dd if=/dev/zero of=$mnt/big1 bs=1M count=100 oflag=sync
+dd if=/dev/zero of=$mnt/big2 bs=1M count=100 oflag=sync
+dd if=/dev/zero of=$mnt/big3 bs=1M count=100 oflag=sync
+dd if=/dev/zero of=$mnt/big4 bs=1M count=100 oflag=sync
+
+lvconvert --splitcache $vg/$lv1
+check lv_field $vg/$lv1 segtype linear
+check lv_field $vg/$lv2 segtype linear
+dmsetup table $vg-$lv1
+_verify_data_on_mnt
+_verify_more_data_on_mnt
+dd if=$mnt/big4 of=/dev/null bs=1M count=100
+umount $mnt
+lvchange -an $vg/$lv1
+_verify_data_on_lv
+lvchange -an $vg/$lv2
+lvremove $vg/$lv1
+lvremove $vg/$lv2
+
+vgremove -ff $vg
+
diff --git a/test/shell/writecache-split.sh b/test/shell/writecache-split.sh
index 9553ade0c..e615e2a13 100644
--- a/test/shell/writecache-split.sh
+++ b/test/shell/writecache-split.sh
@@ -84,7 +84,6 @@ lvconvert --splitcache $vg/$lv1
lvs -o segtype $vg/$lv1 | grep linear
lvs -o segtype $vg/$lv2 | grep linear
-lvchange -ay $vg/$lv1
mount_umount $lv1
lvchange -an $vg/$lv1
diff --git a/test/shell/writecache.sh b/test/shell/writecache.sh
index 8852e93f4..39ef31930 100644
--- a/test/shell/writecache.sh
+++ b/test/shell/writecache.sh
@@ -19,152 +19,251 @@ SKIP_WITH_LVMPOLLD=1
aux have_writecache 1 0 0 || skip
which mkfs.xfs || skip
-mount_dir="mnt"
-mkdir -p $mount_dir
+# scsi_debug devices with 512 LBS 512 PBS
+aux prepare_scsi_debug_dev 256
+check sysfs "$(< SCSI_DEBUG_DEV)" queue/logical_block_size "512"
+check sysfs "$(< SCSI_DEBUG_DEV)" queue/physical_block_size "512"
+aux prepare_devs 2 64
+
+# scsi_debug devices with 512 LBS and 4K PBS
+#aux prepare_scsi_debug_dev 256 sector_size=512 physblk_exp=3
+#check sysfs "$(< SCSI_DEBUG_DEV)" queue/logical_block_size "512"
+#check sysfs "$(< SCSI_DEBUG_DEV)" queue/physical_block_size "4096"
+#aux prepare_devs 2 64
+
+# loop devs with 512 LBS and 512 PBS
+#dd if=/dev/zero of=loopa bs=$((1024*1024)) count=64 2> /dev/null
+#dd if=/dev/zero of=loopb bs=$((1024*1024)) count=64 2> /dev/null
+#LOOP1=$(losetup -f loopa --show)
+#LOOP2=$(losetup -f loopb --show)
+#aux extend_filter "a|$LOOP1|"
+#aux extend_filter "a|$LOOP2|"
+#aux lvmconf 'devices/scan = "/dev"'
+#dev1=$LOOP1
+#dev2=$LOOP2
+
+# loop devs with 4096 LBS and 4096 PBS
+#dd if=/dev/zero of=loopa bs=$((1024*1024)) count=64 2> /dev/null
+#dd if=/dev/zero of=loopb bs=$((1024*1024)) count=64 2> /dev/null
+#LOOP1=$(losetup -f loopa --sector-size 4096 --show)
+#LOOP2=$(losetup -f loopb --sector-size 4096 --show)
+#aux extend_filter "a|$LOOP1|"
+#aux extend_filter "a|$LOOP2|"
+#aux lvmconf 'devices/scan = "/dev"'
+#dev1=$LOOP1
+#dev2=$LOOP2
+
+# the default is brd ram devs with 512 LBS 4K PBS
+# aux prepare_devs 2 64
+
+blockdev --getss "$dev1"
+blockdev --getpbsz "$dev1"
+blockdev --getss "$dev2"
+blockdev --getpbsz "$dev2"
+
+
+mnt="mnt"
+mkdir -p $mnt
+
+for i in `seq 1 16384`; do echo -n "A" >> fileA; done
+for i in `seq 1 16384`; do echo -n "B" >> fileB; done
+for i in `seq 1 16384`; do echo -n "C" >> fileC; done
# generate random data
-dd if=/dev/urandom of=pattern1 bs=512K count=1
+dd if=/dev/urandom of=randA bs=512K count=2
+dd if=/dev/urandom of=randB bs=512K count=3
+dd if=/dev/urandom of=randC bs=512K count=4
+
+_add_new_data_to_mnt() {
+ mkfs.xfs -f "$DM_DEV_DIR/$vg/$lv1"
+
+ mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+
+ # add original data
+ cp randA $mnt
+ cp randB $mnt
+ cp randC $mnt
+ mkdir $mnt/1
+ cp fileA $mnt/1
+ cp fileB $mnt/1
+ cp fileC $mnt/1
+ mkdir $mnt/2
+ cp fileA $mnt/2
+ cp fileB $mnt/2
+ cp fileC $mnt/2
+ sync
+}
+
+_add_more_data_to_mnt() {
+ mkdir $mnt/more
+ cp fileA $mnt/more
+ cp fileB $mnt/more
+ cp fileC $mnt/more
+ cp randA $mnt/more
+ cp randB $mnt/more
+ cp randC $mnt/more
+ sync
+}
+
+_verify_data_on_mnt() {
+ diff randA $mnt/randA
+ diff randB $mnt/randB
+ diff randC $mnt/randC
+ diff fileA $mnt/1/fileA
+ diff fileB $mnt/1/fileB
+ diff fileC $mnt/1/fileC
+ diff fileA $mnt/2/fileA
+ diff fileB $mnt/2/fileB
+ diff fileC $mnt/2/fileC
+}
+
+_verify_more_data_on_mnt() {
+ diff randA $mnt/more/randA
+ diff randB $mnt/more/randB
+ diff randC $mnt/more/randC
+ diff fileA $mnt/more/fileA
+ diff fileB $mnt/more/fileB
+ diff fileC $mnt/more/fileC
+}
+
+_verify_data_on_lv() {
+ lvchange -ay $vg/$lv1
+ mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+ _verify_data_on_mnt
+ rm $mnt/randA
+ rm $mnt/randB
+ rm $mnt/randC
+ rm -rf $mnt/1
+ rm -rf $mnt/2
+ umount $mnt
+ lvchange -an $vg/$lv1
+}
-aux prepare_devs 2 64
vgcreate $SHARED $vg "$dev1"
-
vgextend $vg "$dev2"
-lvcreate -n $lv1 -l 8 -an $vg "$dev1"
-
-lvcreate -n $lv2 -l 4 -an $vg "$dev2"
+blockdev --getss "$dev1"
+blockdev --getpbsz "$dev1"
+blockdev --getss "$dev2"
+blockdev --getpbsz "$dev2"
-# test1: create fs on LV before writecache is attached
+# Test attach while inactive, detach while inactive
+# create fs on LV before writecache is attached
+lvcreate -n $lv1 -l 8 -an $vg "$dev1"
+lvcreate -n $lv2 -l 4 -an $vg "$dev2"
lvchange -ay $vg/$lv1
-
-mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg/$lv1"
-
-mount "$DM_DEV_DIR/$vg/$lv1" $mount_dir
-
-cp pattern1 $mount_dir/pattern1
-
-umount $mount_dir
+_add_new_data_to_mnt
+umount $mnt
lvchange -an $vg/$lv1
-
lvconvert --yes --type writecache --cachevol $lv2 $vg/$lv1
-
check lv_field $vg/$lv1 segtype writecache
-
lvs -a $vg/${lv2}_cvol --noheadings -o segtype >out
grep linear out
-
lvchange -ay $vg/$lv1
-
-mount "$DM_DEV_DIR/$vg/$lv1" $mount_dir
-
-diff pattern1 $mount_dir/pattern1
-
-cp pattern1 $mount_dir/pattern1b
-
-ls -l $mount_dir
-
-umount $mount_dir
-
+blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
+blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+_add_more_data_to_mnt
+_verify_data_on_mnt
+_verify_more_data_on_mnt
+umount $mnt
lvchange -an $vg/$lv1
-
lvconvert --splitcache $vg/$lv1
-
check lv_field $vg/$lv1 segtype linear
check lv_field $vg/$lv2 segtype linear
-
lvchange -ay $vg/$lv1
-lvchange -ay $vg/$lv2
-
-mount "$DM_DEV_DIR/$vg/$lv1" $mount_dir
-
-ls -l $mount_dir
-
-diff pattern1 $mount_dir/pattern1
-diff pattern1 $mount_dir/pattern1b
-
-umount $mount_dir
+blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
+blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
lvchange -an $vg/$lv1
+_verify_data_on_lv
lvchange -an $vg/$lv2
+lvremove $vg/$lv1
+lvremove $vg/$lv2
-# test2: create fs on LV after writecache is attached
+# Test attach while inactive, detach while inactive
+# create fs on LV after writecache is attached
+lvcreate -n $lv1 -l 8 -an $vg "$dev1"
+lvcreate -n $lv2 -l 4 -an $vg "$dev2"
lvconvert --yes --type writecache --cachevol $lv2 $vg/$lv1
-
check lv_field $vg/$lv1 segtype writecache
-
lvs -a $vg/${lv2}_cvol --noheadings -o segtype >out
grep linear out
-
lvchange -ay $vg/$lv1
-
-mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg/$lv1"
-
-mount "$DM_DEV_DIR/$vg/$lv1" $mount_dir
-
-cp pattern1 $mount_dir/pattern1
-ls -l $mount_dir
-
-umount $mount_dir
+blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
+blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
+_add_new_data_to_mnt
+umount $mnt
lvchange -an $vg/$lv1
-
lvconvert --splitcache $vg/$lv1
-
-check lv_field $vg/$lv1 segtype linear
-check lv_field $vg/$lv2 segtype linear
-
lvchange -ay $vg/$lv1
-lvchange -ay $vg/$lv2
-
-mount "$DM_DEV_DIR/$vg/$lv1" $mount_dir
-
-ls -l $mount_dir
-
-diff pattern1 $mount_dir/pattern1
-
-umount $mount_dir
+blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
+blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
+mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+_add_more_data_to_mnt
+_verify_data_on_mnt
+_verify_more_data_on_mnt
+umount $mnt
lvchange -an $vg/$lv1
-lvchange -an $vg/$lv2
-
-
-# test3: attach writecache to an active LV
-
-lvchange -ay $vg/$lv1
-
-mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg/$lv1"
-
-mount "$DM_DEV_DIR/$vg/$lv1" $mount_dir
-
-cp pattern1 $mount_dir/pattern1
-ls -l $mount_dir
-
-# TODO BZ 1808012 - can not convert active volume to writecache:
-not lvconvert --yes --type writecache --cachevol $lv2 $vg/$lv1
-
-if false; then
-check lv_field $vg/$lv1 segtype writecache
-
-lvs -a $vg/${lv2}_cvol --noheadings -o segtype >out
-grep linear out
-
-cp pattern1 $mount_dir/pattern1.after
+_verify_data_on_lv
+lvremove $vg/$lv1
+lvremove $vg/$lv2
-diff pattern1 $mount_dir/pattern1
-diff pattern1 $mount_dir/pattern1.after
+# Test attach while active, detach while active
-umount $mount_dir
-lvchange -an $vg/$lv1
+lvcreate -n $lv1 -l 8 -an $vg "$dev1"
+lvcreate -n $lv2 -l 4 -an $vg "$dev2"
lvchange -ay $vg/$lv1
-mount "$DM_DEV_DIR/$vg/$lv1" $mount_dir
-
-diff pattern1 $mount_dir/pattern1
-diff pattern1 $mount_dir/pattern1.after
-fi
-
-umount $mount_dir
+_add_new_data_to_mnt
+lvconvert --yes --type writecache --cachevol $lv2 $vg/$lv1
+blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
+blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
+_add_more_data_to_mnt
+_verify_data_on_mnt
+lvconvert --splitcache $vg/$lv1
+check lv_field $vg/$lv1 segtype linear
+check lv_field $vg/$lv2 segtype linear
+blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
+blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
+_verify_data_on_mnt
+_verify_more_data_on_mnt
+umount $mnt
lvchange -an $vg/$lv1
+lvchange -an $vg/$lv2
+_verify_data_on_lv
lvremove $vg/$lv1
+lvremove $vg/$lv2
+# FIXME: test depends on unpushed commit
+# that enables two stage flush using cleaner
+#
+# Test attach while active, detach while active,
+# skip cleaner so flush message is used instead
+#
+# lvcreate -n $lv1 -l 8 -an $vg "$dev1"
+# lvcreate -n $lv2 -l 4 -an $vg "$dev2"
+# lvchange -ay $vg/$lv1
+# _add_new_data_to_mnt
+# lvconvert --yes --type writecache --cachevol $lv2 $vg/$lv1
+# blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
+# blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
+# _add_more_data_to_mnt
+# _verify_data_on_mnt
+# lvconvert --splitcache --cachesettings cleaner=0 $vg/$lv1
+# check lv_field $vg/$lv1 segtype linear
+# check lv_field $vg/$lv2 segtype linear
+# blockdev --getss "$DM_DEV_DIR/$vg/$lv1"
+# blockdev --getpbsz "$DM_DEV_DIR/$vg/$lv1"
+# _verify_data_on_mnt
+# _verify_more_data_on_mnt
+# umount $mnt
+# lvchange -an $vg/$lv1
+# lvchange -an $vg/$lv2
+# _verify_data_on_lv
+# lvremove $vg/$lv1
+# lvremove $vg/$lv2
+
vgremove -ff $vg
-
+
3 years, 10 months
master - writecache: activate to check block size
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ba27b9ee2a67d189a56...
Commit: ba27b9ee2a67d189a56827774001436556cae8a5
Parent: 38eaa1035b13ba1633d0002fa53071d5b7098ef9
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Jun 10 15:58:25 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Jun 10 15:58:25 2020 -0500
writecache: activate to check block size
backport fixes from later commit
---
tools/lvconvert.c | 34 +++++++++++++++++++++++++++++-----
1 file changed, 29 insertions(+), 5 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index b25fa1704..94ea70fa5 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -5352,7 +5352,7 @@ static int _lvconvert_detach_writecache(struct cmd_context *cmd,
backup(lv->vg);
- log_print_unless_silent("Logical volume %s write cache has been detached.",
+ log_print_unless_silent("Logical volume %s writecache has been detached.",
display_lvname(lv));
return 1;
}
@@ -5499,14 +5499,17 @@ static int _set_writecache_block_size(struct cmd_context *cmd,
goto_bad;
}
- if (dm_snprintf(pathname, sizeof(pathname), "%s%s/%s", cmd->dev_dir,
+ if (dm_snprintf(pathname, sizeof(pathname), "%s/%s/%s", cmd->dev_dir,
lv->vg->name, lv->name) < 0) {
log_error("Path name too long to get LV block size %s", display_lvname(lv));
goto_bad;
}
+ if (!sync_local_dev_names(cmd))
+ stack;
+
if (!(fs_dev = dev_cache_get(cmd, pathname, NULL))) {
- log_error("Device for LV not found to check block size %s", display_lvname(lv));
+ log_error("Device for LV not found to check block size %s", pathname);
goto_bad;
}
@@ -5608,6 +5611,7 @@ static int _lvconvert_writecache_attach_single(struct cmd_context *cmd,
char *lockd_fast_name = NULL;
struct id lockd_fast_id;
char cvol_name[NAME_LEN];
+ int is_active;
fast_name = arg_str_value(cmd, cachevol_ARG, "");
@@ -5637,6 +5641,8 @@ static int _lvconvert_writecache_attach_single(struct cmd_context *cmd,
goto bad;
}
+ is_active = lv_is_active(lv);
+
memset(&settings, 0, sizeof(settings));
if (!get_writecache_settings(cmd, &settings, &block_size_sectors)) {
@@ -5644,8 +5650,26 @@ static int _lvconvert_writecache_attach_single(struct cmd_context *cmd,
goto bad;
}
- if (!_set_writecache_block_size(cmd, lv, &block_size_sectors))
+ if (!is_active) {
+ /* checking block size of fs on the lv requires the lv to be active */
+ if (!activate_lv(cmd, lv)) {
+ log_error("Failed to activate LV to check block size %s", display_lvname(lv));
+ goto bad;
+ }
+ }
+
+ if (!_set_writecache_block_size(cmd, lv, &block_size_sectors)) {
+ if (!is_active && !deactivate_lv(cmd, lv))
+ stack;
goto_bad;
+ }
+
+ if (!is_active) {
+ if (!deactivate_lv(cmd, lv)) {
+ log_error("Failed to deactivate LV after checking block size %s", display_lvname(lv));
+ goto bad;
+ }
+ }
if (!arg_is_set(cmd, yes_ARG) &&
yes_no_prompt("Erase all existing data on %s? [y/n]: ", display_lvname(lv_fast)) == 'n') {
@@ -5723,7 +5747,7 @@ static int _lvconvert_writecache_attach_single(struct cmd_context *cmd,
log_error("Failed to unlock fast LV %s/%s", vg->name, lockd_fast_name);
}
- log_print_unless_silent("Logical volume %s now has write cache.",
+ log_print_unless_silent("Logical volume %s now has writecache.",
display_lvname(lv));
return ECMD_PROCESSED;
bad:
3 years, 10 months