master - WHATS_NEW
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=11384637fb57c0fdefe...
Commit: 11384637fb57c0fdefe5940cf27285ebdcc1dbc6
Parent: 3810fd8d0d9cfcc519355f995d9cc70dca2811fd
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Tue Jun 5 16:24:19 2018 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Tue Jun 5 16:24:19 2018 +0200
WHATS_NEW
---
WHATS_NEW | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index 25707ab..7737313 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.178 -
====================================
+ lvconvert: provide possible layouts between linear and striped/raid
Use versionsort to fix archive file expiry beyond 100000 files.
Version 2.02.178-rc1 - 24th May 2018
5 years, 11 months
master - test: add convcenience conversion tests linear <-> striped
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3810fd8d0d9cfcc5193...
Commit: 3810fd8d0d9cfcc519355f995d9cc70dca2811fd
Parent: bd7cdd0b09ba123b064937fddde08daacbed7dab
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Wed May 30 12:50:34 2018 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Tue Jun 5 16:23:18 2018 +0200
test: add convcenience conversion tests linear <-> striped
Add tests for linear <-> striped|raid* conversions.
Add region_size config to reshape tests to avoid test
failures in case of it being defined unexpectedly in lvm.conf.
Related: rhbz1439925
Related: rhbz1447809
---
test/shell/lvchange-rebuild-raid.sh | 2 +-
...ert-raid-reshape-linear_to_raid6-single-type.sh | 102 ++++++++++++++++++++
...t-raid-reshape-linear_to_striped-single-type.sh | 80 +++++++++++++++
.../lvconvert-raid-reshape-linear_to_striped.sh | 2 +
...t-raid-reshape-striped_to_linear-single-type.sh | 89 +++++++++++++++++
.../lvconvert-raid-reshape-striped_to_linear.sh | 9 ++-
.../lvconvert-raid-reshape-stripes-load-fail.sh | 9 +-
test/shell/lvconvert-raid-restripe-linear.sh | 76 +++++++++++++++
8 files changed, 363 insertions(+), 6 deletions(-)
diff --git a/test/shell/lvchange-rebuild-raid.sh b/test/shell/lvchange-rebuild-raid.sh
index 913a88d..22acb92 100644
--- a/test/shell/lvchange-rebuild-raid.sh
+++ b/test/shell/lvchange-rebuild-raid.sh
@@ -17,7 +17,7 @@ SKIP_WITH_LVMPOLLD=1
aux have_raid 1 3 2 || skip
v1_9_0=0
-aux have_raid 1 9 && v1_9_0=1
+aux have_raid 1 9 0 && v1_9_0=1
aux prepare_vg 8
get_devs
diff --git a/test/shell/lvconvert-raid-reshape-linear_to_raid6-single-type.sh b/test/shell/lvconvert-raid-reshape-linear_to_raid6-single-type.sh
new file mode 100644
index 0000000..f01e7ef
--- /dev/null
+++ b/test/shell/lvconvert-raid-reshape-linear_to_raid6-single-type.sh
@@ -0,0 +1,102 @@
+#!/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, MA2110-1301 USA
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+# Ensure expected default region size
+aux lvmconf 'activation/raid_region_size = 512'
+
+which mkfs.ext4 || skip
+aux have_raid 1 13 1 || skip
+
+# Temporarily skip reshape tests on single-core CPUs until there's a fix for
+# https://bugzilla.redhat.com/1443999 - AGK 2017/04/20
+aux have_multi_core || skip
+aux prepare_vg 5
+
+#
+# Test multi step linear -> striped conversion
+#
+
+# Create linear LV
+lvcreate -aey -L 16M -n $lv $vg
+check lv_field $vg/$lv segtype "linear"
+check lv_field $vg/$lv stripes 1
+check lv_field $vg/$lv data_stripes 1
+echo y|mkfs -t ext4 $DM_DEV_DIR/$vg/$lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+
+# Convert linear -> raid1 (takeover)
+lvconvert -y --type raid6 --stripes 3 --stripesize 64K --regionsize 128K $vg/$lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+check lv_field $vg/$lv segtype "raid1"
+check lv_field $vg/$lv stripes 2
+check lv_field $vg/$lv data_stripes 2
+check lv_field $vg/$lv regionsize "128.00k"
+aux wait_for_sync $vg $lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+
+# Convert raid1 -> raid5_ls (takeover)
+lvconvert -y --type raid6 --stripes 3 --stripesize 64K --regionsize 128K $vg/$lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+check lv_field $vg/$lv segtype "raid5_ls"
+check lv_field $vg/$lv stripes 2
+check lv_field $vg/$lv data_stripes 1
+check lv_field $vg/$lv stripesize "64.00k"
+check lv_field $vg/$lv regionsize "128.00k"
+
+# Convert raid5_ls adding stripes (reshape)
+lvconvert -y --type raid6 --stripes 3 --stripesize 64K --regionsize 128K $vg/$lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+check lv_first_seg_field $vg/$lv segtype "raid5_ls"
+check lv_first_seg_field $vg/$lv stripes 4
+check lv_first_seg_field $vg/$lv data_stripes 3
+check lv_first_seg_field $vg/$lv stripesize "64.00k"
+check lv_first_seg_field $vg/$lv regionsize "128.00k"
+check lv_first_seg_field $vg/$lv reshape_len_le 8
+aux wait_for_sync $vg $lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+
+# Convert raid5_ls -> raid6_ls_6 (takeover)
+lvconvert -y --type raid6 --stripes 3 --stripesize 64K --regionsize 128K $vg/$lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+check lv_first_seg_field $vg/$lv segtype "raid6_ls_6"
+check lv_first_seg_field $vg/$lv stripes 5
+check lv_first_seg_field $vg/$lv data_stripes 3
+check lv_first_seg_field $vg/$lv stripesize "64.00k"
+check lv_first_seg_field $vg/$lv regionsize "128.00k"
+check lv_first_seg_field $vg/$lv reshape_len_le 0
+
+# Convert raid6_ls_6 -> raid6(_zr) (reshape)
+lvconvert -y --type raid6 --stripes 3 --stripesize 64K --regionsize 128K $vg/$lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+check lv_first_seg_field $vg/$lv segtype "raid6"
+check lv_first_seg_field $vg/$lv stripes 5
+check lv_first_seg_field $vg/$lv data_stripes 3
+check lv_first_seg_field $vg/$lv stripesize "64.00k"
+check lv_first_seg_field $vg/$lv regionsize "128.00k"
+check lv_first_seg_field $vg/$lv reshape_len_le 10
+
+# Remove reshape space
+lvconvert -y --type raid6 --stripes 3 --stripesize 64K --regionsize 128K $vg/$lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+check lv_first_seg_field $vg/$lv segtype "raid6"
+check lv_first_seg_field $vg/$lv stripes 5
+check lv_first_seg_field $vg/$lv data_stripes 3
+check lv_first_seg_field $vg/$lv stripesize "64.00k"
+check lv_first_seg_field $vg/$lv regionsize "128.00k"
+check lv_first_seg_field $vg/$lv reshape_len_le 0
+
+vgremove -ff $vg
diff --git a/test/shell/lvconvert-raid-reshape-linear_to_striped-single-type.sh b/test/shell/lvconvert-raid-reshape-linear_to_striped-single-type.sh
new file mode 100644
index 0000000..7e31cb9
--- /dev/null
+++ b/test/shell/lvconvert-raid-reshape-linear_to_striped-single-type.sh
@@ -0,0 +1,80 @@
+#!/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, MA2110-1301 USA
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux lvmconf 'activation/raid_region_size = 512'
+
+which mkfs.ext4 || skip
+aux have_raid 1 13 1 || skip
+
+# Temporarily skip reshape tests on single-core CPUs until there's a fix for
+# https://bugzilla.redhat.com/1443999 - AGK 2017/04/20
+aux have_multi_core || skip
+aux prepare_vg 5
+
+#
+# Test multi step linear -> striped conversion
+#
+
+# Create linear LV
+lvcreate -aey -L 16M -n $lv $vg
+check lv_field $vg/$lv segtype "linear"
+check lv_field $vg/$lv stripes 1
+check lv_field $vg/$lv data_stripes 1
+echo y|mkfs -t ext4 $DM_DEV_DIR/$vg/$lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+
+# Convert linear -> raid1
+lvconvert -y --type striped --stripes 4 --stripesize 64K --regionsize 128K $vg/$lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+check lv_field $vg/$lv segtype "raid1"
+check lv_field $vg/$lv stripes 2
+check lv_field $vg/$lv data_stripes 2
+check lv_field $vg/$lv regionsize "128.00k"
+aux wait_for_sync $vg $lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+
+# Convert raid1 -> raid5_n
+lvconvert -y --type striped --stripes 4 --stripesize 64K --regionsize 128K $vg/$lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+check lv_field $vg/$lv segtype "raid5_n"
+check lv_field $vg/$lv stripes 2
+check lv_field $vg/$lv data_stripes 1
+check lv_field $vg/$lv stripesize "64.00k"
+check lv_field $vg/$lv regionsize "128.00k"
+
+# Convert raid5_n adding stripes
+lvconvert -y --type striped --stripes 4 --stripesize 64K --regionsize 128K $vg/$lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+check lv_first_seg_field $vg/$lv segtype "raid5_n"
+check lv_first_seg_field $vg/$lv data_stripes 4
+check lv_first_seg_field $vg/$lv stripes 5
+check lv_first_seg_field $vg/$lv data_stripes 4
+check lv_first_seg_field $vg/$lv stripesize "64.00k"
+check lv_first_seg_field $vg/$lv regionsize "128.00k"
+check lv_first_seg_field $vg/$lv reshape_len_le 10
+aux wait_for_sync $vg $lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+
+# Convert raid5_n -> striped
+lvconvert -y --type striped --stripes 4 --stripesize 64K --regionsize 128K $vg/$lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+check lv_first_seg_field $vg/$lv segtype "striped"
+check lv_first_seg_field $vg/$lv stripes 4
+check lv_first_seg_field $vg/$lv data_stripes 4
+check lv_first_seg_field $vg/$lv stripesize "64.00k"
+
+vgremove -ff $vg
diff --git a/test/shell/lvconvert-raid-reshape-linear_to_striped.sh b/test/shell/lvconvert-raid-reshape-linear_to_striped.sh
index 55d4c18..04e2d62 100644
--- a/test/shell/lvconvert-raid-reshape-linear_to_striped.sh
+++ b/test/shell/lvconvert-raid-reshape-linear_to_striped.sh
@@ -14,6 +14,8 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
+aux lvmconf 'activation/raid_region_size = 512'
+
which mkfs.ext4 || skip
aux have_raid 1 12 0 || skip
diff --git a/test/shell/lvconvert-raid-reshape-striped_to_linear-single-type.sh b/test/shell/lvconvert-raid-reshape-striped_to_linear-single-type.sh
new file mode 100644
index 0000000..476fb10
--- /dev/null
+++ b/test/shell/lvconvert-raid-reshape-striped_to_linear-single-type.sh
@@ -0,0 +1,89 @@
+#!/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, MA2110-1301 USA
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+aux lvmconf 'activation/raid_region_size = 512'
+
+which mkfs.ext4 || skip
+aux have_raid 1 13 1 || skip
+
+# Temporarily skip reshape tests on single-core CPUs until there's a fix for
+# https://bugzilla.redhat.com/1443999 - AGK 2017/04/20
+aux have_multi_core || skip
+
+aux prepare_vg 5
+
+#
+# Test multi step striped -> linear conversion
+#
+
+# Create 4-way striped LV
+lvcreate -aey --type striped -L 16M --stripes 4 --stripesize 64K -n $lv $vg
+check lv_first_seg_field $vg/$lv segtype "striped"
+check lv_first_seg_field $vg/$lv stripes 4
+check lv_first_seg_field $vg/$lv data_stripes 4
+check lv_first_seg_field $vg/$lv stripesize "64.00k"
+echo y|mkfs -t ext4 $DM_DEV_DIR/$vg/$lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+lvextend -y -L64M $DM_DEV_DIR/$vg/$lv
+
+# Convert striped -> raid5_n
+lvconvert -y --type linear $vg/$lv
+check lv_field $vg/$lv segtype "raid5_n"
+check lv_field $vg/$lv data_stripes 4
+check lv_field $vg/$lv stripes 5
+check lv_field $vg/$lv data_stripes 4
+check lv_field $vg/$lv stripesize "64.00k"
+check lv_field $vg/$lv regionsize "512.00k"
+check lv_field $vg/$lv reshape_len_le 0
+aux wait_for_sync $vg $lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+
+# Restripe raid5_n LV to single data stripe
+#
+# Need --force in order to remove stripes thus shrinking LV size!
+lvconvert -y --force --type linear $vg/$lv
+aux wait_for_sync $vg $lv 1
+fsck -fn $DM_DEV_DIR/$vg/$lv
+# Remove the now freed stripes
+lvconvert -y --type linear $vg/$lv
+check lv_field $vg/$lv segtype "raid5_n"
+check lv_field $vg/$lv stripes 2
+check lv_field $vg/$lv data_stripes 1
+check lv_field $vg/$lv stripesize "64.00k"
+check lv_field $vg/$lv regionsize "512.00k"
+check lv_field $vg/$lv reshape_len_le 4
+
+# Convert raid5_n -> raid1
+lvconvert -y --type linear $vg/$lv
+check lv_field $vg/$lv segtype "raid1"
+check lv_field $vg/$lv stripes 2
+check lv_field $vg/$lv data_stripes 2
+check lv_field $vg/$lv stripesize 0
+check lv_field $vg/$lv regionsize "512.00k"
+check lv_field $vg/$lv reshape_len_le ""
+fsck -fn $DM_DEV_DIR/$vg/$lv
+
+# Convert raid1 -> linear
+lvconvert -y --type linear $vg/$lv
+check lv_first_seg_field $vg/$lv segtype "linear"
+check lv_first_seg_field $vg/$lv stripes 1
+check lv_first_seg_field $vg/$lv data_stripes 1
+check lv_first_seg_field $vg/$lv stripesize 0
+check lv_first_seg_field $vg/$lv regionsize 0
+fsck -fn $DM_DEV_DIR/$vg/$lv
+
+vgremove -ff $vg
diff --git a/test/shell/lvconvert-raid-reshape-striped_to_linear.sh b/test/shell/lvconvert-raid-reshape-striped_to_linear.sh
index ed3769d..ccbe6ad 100644
--- a/test/shell/lvconvert-raid-reshape-striped_to_linear.sh
+++ b/test/shell/lvconvert-raid-reshape-striped_to_linear.sh
@@ -15,6 +15,8 @@ SKIP_WITH_LVMPOLLD=1
. lib/inittest
+aux lvmconf 'activation/raid_region_size = 512'
+
which mkfs.ext4 || skip
aux have_raid 1 12 0 || skip
@@ -51,7 +53,9 @@ aux wait_for_sync $vg $lv1
fsck -fn $DM_DEV_DIR/$vg/$lv1
# Extend raid5_n LV by factor 4 to keep size once linear
-lvresize -y -L 64 $vg/$lv1
+lvresize -y -L 64M $vg/$lv1
+aux wait_for_sync $vg $lv1
+
check lv_field $vg/$lv1 segtype "raid5_n"
check lv_field $vg/$lv1 data_stripes 4
check lv_field $vg/$lv1 stripes 5
@@ -87,6 +91,7 @@ check lv_first_seg_field $vg/$lv1 stripes 2
check lv_first_seg_field $vg/$lv1 stripesize "32.00k"
check lv_first_seg_field $vg/$lv1 regionsize "1.00m"
check lv_first_seg_field $vg/$lv1 reshape_len_le 4
+fsck -fn $DM_DEV_DIR/$vg/$lv1
# Convert raid5_n to raid1
lvconvert -y --type raid1 $vg/$lv1
@@ -97,6 +102,7 @@ check lv_first_seg_field $vg/$lv1 stripes 2
check lv_first_seg_field $vg/$lv1 stripesize "0"
check lv_first_seg_field $vg/$lv1 regionsize "1.00m"
check lv_first_seg_field $vg/$lv1 reshape_len_le ""
+fsck -fn $DM_DEV_DIR/$vg/$lv1
# Convert raid1 -> linear
lvconvert -y --type linear $vg/$lv1
@@ -107,5 +113,6 @@ check lv_first_seg_field $vg/$lv1 stripes 1
check lv_first_seg_field $vg/$lv1 stripesize "0"
check lv_first_seg_field $vg/$lv1 regionsize "0"
check lv_first_seg_field $vg/$lv1 reshape_len_le ""
+fsck -fn $DM_DEV_DIR/$vg/$lv1
vgremove -ff $vg
diff --git a/test/shell/lvconvert-raid-reshape-stripes-load-fail.sh b/test/shell/lvconvert-raid-reshape-stripes-load-fail.sh
index feaf1e2..c7ccad8 100644
--- a/test/shell/lvconvert-raid-reshape-stripes-load-fail.sh
+++ b/test/shell/lvconvert-raid-reshape-stripes-load-fail.sh
@@ -46,6 +46,7 @@ check lv_first_seg_field $vg/$lv1 stripesize "64.00k"
check lv_first_seg_field $vg/$lv1 data_stripes 10
check lv_first_seg_field $vg/$lv1 stripes 11
echo y|mkfs -t ext4 /dev/$vg/$lv1
+fsck -fn /dev/$vg/$lv1
mkdir -p $mount_dir
mount "$DM_DEV_DIR/$vg/$lv1" $mount_dir
@@ -53,8 +54,8 @@ mkdir -p $mount_dir/1 $mount_dir/2
echo 3 >/proc/sys/vm/drop_caches
-cp -r /usr/bin $mount_dir/1 >/dev/null 2>/dev/null &
-cp -r /usr/bin $mount_dir/2 >/dev/null 2>/dev/null &
+cp -r /usr/bin $mount_dir/1 &>/dev/null &
+cp -r /usr/bin $mount_dir/2 &>/dev/null &
sync &
aux wait_for_sync $vg $lv1
@@ -69,11 +70,11 @@ check lv_first_seg_field $vg/$lv1 stripesize "64.00k"
check lv_first_seg_field $vg/$lv1 data_stripes 15
check lv_first_seg_field $vg/$lv1 stripes 16
-rm -fr $mount_dir/2
-sync
kill -9 %%
wait
+rm -fr $mount_dir/[12]
+sync
umount $mount_dir
fsck -fn "$DM_DEV_DIR/$vg/$lv1"
diff --git a/test/shell/lvconvert-raid-restripe-linear.sh b/test/shell/lvconvert-raid-restripe-linear.sh
new file mode 100644
index 0000000..0ac8a04
--- /dev/null
+++ b/test/shell/lvconvert-raid-restripe-linear.sh
@@ -0,0 +1,76 @@
+#!/usr/bin/env bash
+
+# Copyright (C) 2017 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, MA2110-1301 USA
+
+SKIP_WITH_LVMLOCKD=1
+SKIP_WITH_LVMPOLLD=1
+
+. lib/inittest
+
+which mkfs.ext4 || skip
+aux have_raid 1 12 0 || skip
+
+# Temporarily skip reshape tests on single-core CPUs until there's a fix for
+# https://bugzilla.redhat.com/1443999 - AGK 2017/04/20
+aux have_multi_core || skip
+aux prepare_vg 5
+
+#
+# Test single step linear -> striped conversion
+#
+
+# Create linear LV
+lvcreate -aey -L 16M -n $lv $vg
+check lv_field $vg/$lv segtype "linear"
+check lv_field $vg/$lv stripes 1
+check lv_field $vg/$lv data_stripes 1
+echo y|mkfs -t ext4 $DM_DEV_DIR/$vg/$lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+
+# Convert linear -> raid1
+not lvconvert -y --stripes 4 $vg/$lv
+not lvconvert -y --stripes 4 --stripesize 64K $vg/$lv
+not lvconvert -y --stripes 4 --stripesize 64K --regionsize 512K $vg/$lv
+lvconvert -y --type striped --stripes 4 --stripesize 64K --regionsize 512K $vg/$lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+check lv_field $vg/$lv segtype "raid1"
+check lv_field $vg/$lv stripes 2
+check lv_field $vg/$lv data_stripes 2
+check lv_field $vg/$lv regionsize "512.00k"
+aux wait_for_sync $vg $lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+
+# Convert raid1 -> raid5_n
+lvconvert -y --type striped --stripes 4 --stripesize 64K --regionsize 512K $vg/$lv
+check lv_field $vg/$lv segtype "raid5_n"
+check lv_field $vg/$lv stripes 2
+check lv_field $vg/$lv data_stripes 1
+check lv_field $vg/$lv stripesize "64.00k"
+check lv_field $vg/$lv regionsize "512.00k"
+fsck -fn $DM_DEV_DIR/$vg/$lv
+
+# Convert raid5_n adding stripes
+lvconvert -y --type striped --stripes 4 --stripesize 64K --regionsize 512K $vg/$lv
+check lv_first_seg_field $vg/$lv segtype "raid5_n"
+check lv_first_seg_field $vg/$lv data_stripes 4
+check lv_first_seg_field $vg/$lv stripes 5
+check lv_first_seg_field $vg/$lv stripesize "64.00k"
+check lv_first_seg_field $vg/$lv regionsize "512.00k"
+check lv_first_seg_field $vg/$lv reshape_len_le 10
+aux wait_for_sync $vg $lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+resize2fs $DM_DEV_DIR/$vg/$lv
+
+# Convert raid5_n -> striped
+lvconvert -y --type striped $vg/$lv
+fsck -fn $DM_DEV_DIR/$vg/$lv
+
+vgremove -ff $vg
5 years, 11 months
master - lvconvert: support linear <-> striped convenience conversions
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=bd7cdd0b09ba123b064...
Commit: bd7cdd0b09ba123b064937fddde08daacbed7dab
Parent: de66704253653305e4513637735a078af00912b7
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Wed May 30 12:49:15 2018 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Tue Jun 5 16:23:18 2018 +0200
lvconvert: support linear <-> striped convenience conversions
"lvconvert --type {linear|striped|raid*} ..." on a striped/linear
LV provides convenience interim type to convert to the requested
final layout similar to the given raid* <-> raid* conveninece types.
Whilst on it, add missing raid5_n convenince type from raid5* to raid10.
Resolves: rhbz1439925
Resolves: rhbz1447809
Resolves: rhbz1573255
---
lib/metadata/raid_manip.c | 172 ++++++++++++++++++++++++++++++---------------
tools/lvconvert.c | 110 ++++++++++-------------------
2 files changed, 154 insertions(+), 128 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 9b4cb83..4d58d74 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -4526,17 +4526,18 @@ static struct possible_takeover_reshape_type _possible_takeover_reshape_types[]
.current_areas = 1,
.options = ALLOW_REGION_SIZE },
- { .current_types = SEG_STRIPED_TARGET, /* linear, i.e. seg->area_count = 1 */
- .possible_types = SEG_RAID0|SEG_RAID0_META,
- .current_areas = 1,
- .options = ALLOW_STRIPE_SIZE },
-
/* raid0* -> raid1 */
{ .current_types = SEG_RAID0|SEG_RAID0_META, /* seg->area_count = 1 */
.possible_types = SEG_RAID1,
.current_areas = 1,
.options = ALLOW_REGION_SIZE },
+ /* raid5_n -> linear through interim raid1 */
+ { .current_types = SEG_RAID5_N,
+ .possible_types = SEG_STRIPED_TARGET,
+ .current_areas = 2,
+ .options = ALLOW_NONE },
+
/* striped,raid0* <-> striped,raid0* */
{ .current_types = SEG_STRIPED_TARGET|SEG_RAID0|SEG_RAID0_META,
.possible_types = SEG_STRIPED_TARGET|SEG_RAID0|SEG_RAID0_META,
@@ -4547,13 +4548,13 @@ static struct possible_takeover_reshape_type _possible_takeover_reshape_types[]
{ .current_types = SEG_STRIPED_TARGET|SEG_RAID0|SEG_RAID0_META,
.possible_types = SEG_RAID4|SEG_RAID5_N|SEG_RAID6_N_6|SEG_RAID10_NEAR,
.current_areas = ~0U,
- .options = ALLOW_REGION_SIZE },
+ .options = ALLOW_REGION_SIZE|ALLOW_STRIPES },
/* raid4,raid5_n,raid6_n_6,raid10_near -> striped/raid0* */
{ .current_types = SEG_RAID4|SEG_RAID5_N|SEG_RAID6_N_6|SEG_RAID10_NEAR,
.possible_types = SEG_STRIPED_TARGET|SEG_RAID0|SEG_RAID0_META,
.current_areas = ~0U,
- .options = ALLOW_NONE },
+ .options = ALLOW_STRIPES },
/* raid4,raid5_n,raid6_n_6 <-> raid4,raid5_n,raid6_n_6 */
{ .current_types = SEG_RAID4|SEG_RAID5_N|SEG_RAID6_N_6,
@@ -4640,7 +4641,8 @@ static struct possible_takeover_reshape_type *_get_possible_takeover_reshape_typ
for ( ; pt->current_types; pt++)
if ((seg_from->segtype->flags & pt->current_types) &&
(segtype_to ? (segtype_to->flags & pt->possible_types) : 1))
- if (seg_from->area_count <= pt->current_areas)
+ if ((seg_from->area_count == pt->current_areas) ||
+ (seg_from->area_count > 1 && seg_from->area_count <= pt->current_areas))
return pt;
return NULL;
@@ -4816,7 +4818,7 @@ typedef int (*takeover_fn_t)(TAKEOVER_FN_ARGS);
/*
* Unsupported takeover functions.
*/
-static int _takeover_noop(TAKEOVER_FN_ARGS)
+static int _takeover_same_layout(const struct logical_volume *lv)
{
log_error("Logical volume %s is already of requested type %s.",
display_lvname(lv), lvseg_name(first_seg(lv)));
@@ -4824,6 +4826,11 @@ static int _takeover_noop(TAKEOVER_FN_ARGS)
return 0;
}
+static int _takeover_noop(TAKEOVER_FN_ARGS)
+{
+ return _takeover_same_layout(lv);
+}
+
static int _takeover_unsupported(TAKEOVER_FN_ARGS)
{
struct lv_segment *seg = first_seg(lv);
@@ -5618,7 +5625,9 @@ static int _takeover_from_linear_to_raid0(TAKEOVER_FN_ARGS)
static int _takeover_from_linear_to_raid1(TAKEOVER_FN_ARGS)
{
- return _takeover_unsupported_yet(lv, new_stripes, new_segtype);
+ first_seg(lv)->region_size = new_region_size;
+
+ return _lv_raid_change_image_count(lv, 1, 2, allocate_pvs, NULL, 1, 0);
}
static int _takeover_from_linear_to_raid10(TAKEOVER_FN_ARGS)
@@ -6102,23 +6111,34 @@ static uint64_t _raid_segtype_flag_5_to_6(const struct segment_type *segtype)
/* FIXME: do this like _conversion_options_allowed()? */
static int _set_convenient_raid145610_segtype_to(const struct lv_segment *seg_from,
const struct segment_type **segtype,
+ uint32_t *new_image_count,
+ uint32_t *stripes,
int yes)
{
uint64_t seg_flag = 0;
struct cmd_context *cmd = seg_from->lv->vg->cmd;
const struct segment_type *segtype_sav = *segtype;
+ /* Linear -> striped request */
+ if (seg_is_striped(seg_from) &&
+ seg_from->area_count == 1 &&
+ segtype_is_striped(*segtype))
+ ;
/* Bail out if same RAID level is requested. */
- if (_is_same_level(seg_from->segtype, *segtype))
+ else if (_is_same_level(seg_from->segtype, *segtype))
return 1;
log_debug("Checking LV %s requested %s segment type for convenience",
display_lvname(seg_from->lv), (*segtype)->name);
-
/* striped/raid0 -> raid5/6 */
if (seg_is_striped(seg_from) || seg_is_any_raid0(seg_from)) {
+ /* linear -> raid*, interim/first conversion is to raid1 */
+ if (seg_from->area_count == 1)
+ seg_flag = SEG_RAID1;
+
/* If this is any raid5 conversion request -> enforce raid5_n, because we convert from striped */
- if (segtype_is_any_raid5(*segtype) && !segtype_is_raid5_n(*segtype))
+ else if (((segtype_is_striped(*segtype) && !segtype_is_any_raid0(*segtype)) || segtype_is_any_raid5(*segtype)) &&
+ !segtype_is_raid5_n(*segtype))
seg_flag = SEG_RAID5_N;
/* If this is any raid6 conversion request -> enforce raid6_n_6, because we convert from striped */
@@ -6143,40 +6163,71 @@ static int _set_convenient_raid145610_segtype_to(const struct lv_segment *seg_fr
/* raid4/raid5 -> striped/raid0/raid1/raid6/raid10 */
} else if (seg_is_raid4(seg_from) || seg_is_any_raid5(seg_from)) {
- if (segtype_is_raid1(*segtype) &&
- seg_from->area_count != 2) {
+ if ((segtype_is_raid1(*segtype) || segtype_is_linear(*segtype)) && seg_is_raid5_n(seg_from)) {
+ if (seg_from->area_count != 2) {
+ log_error("Converting %s LV %s to 2 stripes first.",
+ lvseg_name(seg_from), display_lvname(seg_from->lv));
+ *new_image_count = 2;
+ seg_flag = SEG_RAID5_N;
+ } else
+ seg_flag = SEG_RAID1;
+
+ } else if (segtype_is_raid1(*segtype) && seg_from->area_count != 2) {
log_error("Convert %s LV %s to 2 stripes first (i.e. --stripes 1).",
lvseg_name(seg_from), display_lvname(seg_from->lv));
return 0;
- }
-
- if (seg_is_raid4(seg_from) &&
- segtype_is_any_raid5(*segtype) &&
- !segtype_is_raid5_n(*segtype))
- seg_flag = SEG_RAID5_N;
- else if (seg_is_any_raid5(seg_from) &&
- segtype_is_raid4(*segtype) &&
+ } else if (seg_is_raid4(seg_from) &&
+ (segtype_is_linear(*segtype) || segtype_is_any_raid5(*segtype)) &&
!segtype_is_raid5_n(*segtype))
seg_flag = SEG_RAID5_N;
- else if (segtype_is_raid10(*segtype)) {
- if (seg_from->area_count < 3) {
+ else if (seg_is_raid5_n(seg_from) && seg_from->area_count == 2) {
+ if (*stripes >= 2) {
+ log_error("Converting %s LV %s to %u stripes first.",
+ lvseg_name(seg_from), display_lvname(seg_from->lv), *stripes);
+ *new_image_count = *stripes + seg_from->segtype->parity_devs;
+ seg_flag = SEG_RAID5_N;
+ } else {
log_error("Convert %s LV %s to minimum 3 stripes first (i.e. --stripes 2).",
lvseg_name(seg_from), display_lvname(seg_from->lv));
return 0;
}
+ } else if (seg_is_any_raid5(seg_from) &&
+ (segtype_is_linear(*segtype) || segtype_is_raid4(*segtype)) &&
+ !segtype_is_raid5_n(*segtype))
+ seg_flag = SEG_RAID5_N;
- seg_flag = seg_is_raid5_n(seg_from) ? SEG_RAID0_META : SEG_RAID5_N;
+ else if (segtype_is_raid10(*segtype)) {
+ if (seg_from->area_count < 3) {
+ if (*stripes >= 2) {
+ log_error("Converting %s LV %s to %u stripes first.",
+ lvseg_name(seg_from), display_lvname(seg_from->lv), *stripes);
+ *new_image_count = *stripes + seg_from->segtype->parity_devs;
+ seg_flag = SEG_RAID5_N;
+ } else {
+ log_error("Convert %s LV %s to minimum 3 stripes first (i.e. --stripes 2).",
+ lvseg_name(seg_from), display_lvname(seg_from->lv));
+ return 0;
+ }
+ } else
+ seg_flag = seg_is_raid5_n(seg_from) ? SEG_RAID0_META : SEG_RAID5_N;
} else if (segtype_is_any_raid6(*segtype)) {
- if (seg_from->area_count < 4) {
- log_error("Convert %s LV %s to minimum 4 stripes first (i.e. --stripes 3).",
- lvseg_name(seg_from), display_lvname(seg_from->lv));
- return 0;
- }
+ if (seg_from->area_count < 4 &&
+ seg_is_any_raid5(seg_from)) {
+ if (*stripes >= 3) {
+ log_error("Converting %s LV %s to %u stripes first.",
+ lvseg_name(seg_from), display_lvname(seg_from->lv), *stripes);
+ *new_image_count = *stripes + seg_from->segtype->parity_devs;
+ seg_flag = SEG_RAID5_LS;
+ } else {
+ log_error("Convert %s LV %s to minimum 4 stripes first (i.e. --stripes 3).",
+ lvseg_name(seg_from), display_lvname(seg_from->lv));
+ return 0;
+ }
- if (seg_is_raid4(seg_from) && !segtype_is_raid6_n_6(*segtype))
+ } else if (seg_is_raid4(seg_from) && !segtype_is_raid6_n_6(*segtype))
seg_flag = SEG_RAID6_N_6;
else
seg_flag = _raid_seg_flag_5_to_6(seg_from);
@@ -6193,9 +6244,9 @@ static int _set_convenient_raid145610_segtype_to(const struct lv_segment *seg_fr
} else if (segtype_is_any_raid10(*segtype)) {
seg_flag = seg_is_raid6_n_6(seg_from) ? SEG_RAID0_META : SEG_RAID6_N_6;
- } else if ((segtype_is_striped(*segtype) || segtype_is_any_raid0(*segtype)) &&
- !seg_is_raid6_n_6(seg_from)) {
- seg_flag = SEG_RAID6_N_6;
+ } else if (segtype_is_striped(*segtype) || segtype_is_any_raid0(*segtype)) {
+ if (!seg_is_raid6_n_6(seg_from))
+ seg_flag = SEG_RAID6_N_6;
} else if (segtype_is_raid4(*segtype) && !seg_is_raid6_n_6(seg_from)) {
seg_flag = SEG_RAID6_N_6;
@@ -6331,41 +6382,48 @@ static int _conversion_options_allowed(const struct lv_segment *seg_from,
int yes,
uint32_t new_image_count,
int new_data_copies, int new_region_size,
- int stripes, unsigned new_stripe_size_supplied)
+ uint32_t *stripes, unsigned new_stripe_size_supplied)
{
int r = 1;
- uint32_t opts;
+ uint32_t count = new_image_count, opts;
+
+ /* Linear -> linear rejection */
+ if ((seg_is_linear(seg_from) || seg_is_striped(seg_from)) &&
+ seg_from->area_count == 1 &&
+ segtype_is_striped(*segtype_to) &&
+ *stripes < 2)
+ return _takeover_same_layout(seg_from->lv);
- if (!new_image_count && !_set_convenient_raid145610_segtype_to(seg_from, segtype_to, yes))
+ if (!new_image_count && !_set_convenient_raid145610_segtype_to(seg_from, segtype_to, &count, stripes, yes))
return_0;
+ if (new_image_count != count)
+ *stripes = count - seg_from->segtype->parity_devs;
+
if (!_get_allowed_conversion_options(seg_from, *segtype_to, new_image_count, &opts)) {
- log_error("Unable to convert LV %s from %s to %s.",
- display_lvname(seg_from->lv), lvseg_name(seg_from), (*segtype_to)->name);
+ if (strcmp(lvseg_name(seg_from), (*segtype_to)->name))
+ log_error("Unable to convert LV %s from %s to %s.",
+ display_lvname(seg_from->lv), lvseg_name(seg_from), (*segtype_to)->name);
+ else
+ _takeover_same_layout(seg_from->lv);
+
return 0;
}
- if (stripes > 1 && !(opts & ALLOW_STRIPES)) {
- if (!_log_prohibited_option(seg_from, *segtype_to, "--stripes"))
- stack;
- r = 0;
+ if (*stripes > 1 && !(opts & ALLOW_STRIPES)) {
+ _log_prohibited_option(seg_from, *segtype_to, "--stripes");
+ *stripes = seg_from->area_count;
}
- if (new_stripe_size_supplied && !(opts & ALLOW_STRIPE_SIZE)) {
- if (!_log_prohibited_option(seg_from, *segtype_to, "-I/--stripesize"))
- stack;
- r = 0;
- }
+ if (new_stripe_size_supplied && !(opts & ALLOW_STRIPE_SIZE))
+ _log_prohibited_option(seg_from, *segtype_to, "-I/--stripesize");
- if (new_region_size && !(opts & ALLOW_REGION_SIZE)) {
- if (!_log_prohibited_option(seg_from, *segtype_to, "-R/--regionsize"))
- stack;
- r = 0;
- }
+ if (new_region_size && new_region_size != seg_from->region_size && !(opts & ALLOW_REGION_SIZE))
+ _log_prohibited_option(seg_from, *segtype_to, "-R/--regionsize");
/* Can't reshape stripes or stripe size when performing a takeover! */
if (!_is_same_level(seg_from->segtype, *segtype_to)) {
- if (stripes && stripes != _data_rimages_count(seg_from, seg_from->area_count))
+ if (*stripes && *stripes != _data_rimages_count(seg_from, seg_from->area_count))
log_warn("WARNING: ignoring --stripes option on takeover of %s (reshape afterwards).",
display_lvname(seg_from->lv));
@@ -6501,7 +6559,7 @@ int lv_raid_convert(struct logical_volume *lv,
*/
if (!_conversion_options_allowed(seg, &new_segtype, yes,
0 /* Takeover */, 0 /*new_data_copies*/, new_region_size,
- new_stripes, new_stripe_size_supplied))
+ &stripes, new_stripe_size_supplied))
return _log_possible_conversion_types(lv, new_segtype);
/* https://bugzilla.redhat.com/1439399 */
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index be4b1d0..536b925 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -238,6 +238,14 @@ static int _read_params(struct cmd_context *cmd, struct lvconvert_params *lp)
break;
case CONV_OTHER:
+ if (arg_is_set(cmd, regionsize_ARG)) {
+ lp->region_size = arg_uint_value(cmd, regionsize_ARG, 0);
+ lp->region_size_supplied = 1;
+ } else {
+ lp->region_size = get_default_region_size(cmd);
+ lp->region_size_supplied = 0;
+ }
+
if (_mirror_or_raid_type_requested(cmd, lp->type_str) ||
lp->mirrorlog || lp->corelog) { /* Mirrors (and some RAID functions) */
if (arg_is_set(cmd, chunksize_ARG)) {
@@ -250,14 +258,6 @@ static int _read_params(struct cmd_context *cmd, struct lvconvert_params *lp)
return 0;
}
- if (arg_is_set(cmd, regionsize_ARG)) {
- lp->region_size = arg_uint_value(cmd, regionsize_ARG, 0);
- lp->region_size_supplied = 1;
- } else {
- lp->region_size = get_default_region_size(cmd);
- lp->region_size_supplied = 0;
- }
-
/* FIXME man page says in one place that --type and --mirrors can't be mixed */
if (lp->mirrors_supplied && !lp->mirrors)
/* down-converting to linear/stripe? */
@@ -265,7 +265,7 @@ static int _read_params(struct cmd_context *cmd, struct lvconvert_params *lp)
} else if (_raid0_type_requested(lp->type_str) || _striped_type_requested(lp->type_str)) { /* striped or linear or raid0 */
if (arg_from_list_is_set(cmd, "cannot be used with --type raid0 or --type striped or --type linear",
- chunksize_ARG, corelog_ARG, mirrors_ARG, mirrorlog_ARG, regionsize_ARG, zero_ARG,
+ chunksize_ARG, corelog_ARG, mirrors_ARG, mirrorlog_ARG, zero_ARG,
-1))
return_0;
} /* else segtype will default to current type */
@@ -1258,11 +1258,11 @@ static int _is_valid_raid_conversion(const struct segment_type *from_segtype,
if (!from_segtype)
return 1;
- if (from_segtype == to_segtype)
- return 1;
-
- /* Support raid0 <-> striped conversions */
+ /* linear/striped/raid0 <-> striped/raid0/linear (restriping via raid) */
if (segtype_is_striped(from_segtype) && segtype_is_striped(to_segtype))
+ return 0;
+
+ if (from_segtype == to_segtype)
return 1;
if (!segtype_is_raid(from_segtype) && !segtype_is_raid(to_segtype))
@@ -1305,45 +1305,18 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
lp->mirrors = 0;
}
- /* Can only change image count for raid1 and linear */
- if (lp->mirrors_supplied) {
- if (_raid0_type_requested(lp->type_str)) {
- log_error("--mirrors/-m is not compatible with conversion to %s.",
- lp->type_str);
- return 0;
- }
- if (!seg_is_mirrored(seg) && !seg_is_linear(seg)) {
- log_error("--mirrors/-m is not compatible with %s.",
- lvseg_name(seg));
- return 0;
- }
- if (seg_is_raid10(seg)) {
- log_error("--mirrors/-m cannot be changed with %s.",
- lvseg_name(seg));
- return 0;
- }
- }
-
if (!_lvconvert_validate_thin(lv, lp))
return_0;
- if (!_is_valid_raid_conversion(seg->segtype, lp->segtype))
+ if (!_is_valid_raid_conversion(seg->segtype, lp->segtype) &&
+ !lp->mirrors_supplied)
goto try_new_takeover_or_reshape;
- if (seg_is_linear(seg) && !lp->mirrors_supplied) {
- if (_raid0_type_requested(lp->type_str)) {
- log_error("Linear LV %s cannot be converted to %s.",
- display_lvname(lv), lp->type_str);
- return 0;
- }
+ if (seg_is_striped(seg) && !lp->mirrors_supplied)
+ goto try_new_takeover_or_reshape;
- if (!strcmp(lp->type_str, SEG_TYPE_NAME_RAID1)) {
- log_error("Raid conversions of LV %s require -m/--mirrors.",
- display_lvname(lv));
- return 0;
- }
+ if (seg_is_linear(seg) && !lp->mirrors_supplied)
goto try_new_takeover_or_reshape;
- }
/* Change number of RAID1 images */
if (lp->mirrors_supplied || lp->keep_mimages) {
@@ -1381,6 +1354,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
return lv_raid_split(lv, lp->yes, lp->lv_split_name, image_count, lp->pvh);
if (lp->mirrors_supplied) {
+ if ((seg_is_striped(seg) && seg->area_count == 1) || seg_is_raid1(seg)) { /* ??? */
if (!*lp->type_str || !strcmp(lp->type_str, SEG_TYPE_NAME_RAID1) || !strcmp(lp->type_str, SEG_TYPE_NAME_LINEAR) ||
(!strcmp(lp->type_str, SEG_TYPE_NAME_STRIPED) && image_count == 1)) {
if (image_count > DEFAULT_RAID1_MAX_IMAGES) {
@@ -1398,6 +1372,7 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
return 1;
}
+ }
goto try_new_takeover_or_reshape;
}
@@ -1440,7 +1415,6 @@ static int _lvconvert_raid(struct logical_volume *lv, struct lvconvert_params *l
}
try_new_takeover_or_reshape:
-
if (!_raid4_conversion_supported(lv, lp))
return 0;
@@ -1450,24 +1424,15 @@ try_new_takeover_or_reshape:
if (!arg_is_set(cmd, type_ARG))
lp->segtype = NULL;
- /* Only let raid4 through for now. */
- if (!lp->segtype ||
- (lp->type_str && lp->type_str[0] && lp->segtype != seg->segtype &&
- ((seg_is_raid4(seg) && seg_is_striped(lp) && lp->stripes > 1) ||
- (seg_is_striped(seg) && seg->area_count > 1 && seg_is_raid4(lp))))) {
- if (!lv_raid_convert(lv, lp->segtype,
- lp->yes, lp->force, lp->stripes, lp->stripe_size_supplied, lp->stripe_size,
- (lp->region_size_supplied || !seg->region_size) ?
- lp->region_size : seg->region_size , lp->pvh))
- return_0;
-
- log_print_unless_silent("Logical volume %s successfully converted.",
- display_lvname(lv));
- return 1;
- }
+ if (!lv_raid_convert(lv, lp->segtype,
+ lp->yes, lp->force, lp->stripes, lp->stripe_size_supplied, lp->stripe_size,
+ (lp->region_size_supplied || !seg->region_size) ?
+ lp->region_size : seg->region_size , lp->pvh))
+ return_0;
- log_error("Conversion operation not yet supported.");
- return 0;
+ log_print_unless_silent("Logical volume %s successfully converted.",
+ display_lvname(lv));
+ return 1;
}
/*
@@ -1692,21 +1657,24 @@ static int _convert_striped(struct cmd_context *cmd, struct logical_volume *lv,
struct lvconvert_params *lp)
{
const char *mirrors_type = find_config_tree_str(cmd, global_mirror_segtype_default_CFG, NULL);
+ int raid_type = *lp->type_str && !strncmp(lp->type_str, "raid", 4);
- if (!strcmp(lp->type_str, SEG_TYPE_NAME_MIRROR))
- return _convert_striped_mirror(cmd, lv, lp);
+ if (!raid_type) {
+ if (!strcmp(lp->type_str, SEG_TYPE_NAME_MIRROR))
+ return _convert_striped_mirror(cmd, lv, lp);
- if (segtype_is_raid(lp->segtype))
- return _convert_striped_raid(cmd, lv, lp);
-
- /* --mirrors can mean --type mirror or --type raid1 depending on config setting. */
+ /* --mirrors can mean --type mirror or --type raid1 depending on config setting. */
- if (arg_is_set(cmd, mirrors_ARG) && mirrors_type && !strcmp(mirrors_type, SEG_TYPE_NAME_MIRROR))
- return _convert_striped_mirror(cmd, lv, lp);
+ if (arg_is_set(cmd, mirrors_ARG) && mirrors_type && !strcmp(mirrors_type, SEG_TYPE_NAME_MIRROR))
+ return _convert_striped_mirror(cmd, lv, lp);
+ }
if (arg_is_set(cmd, mirrors_ARG) && mirrors_type && !strcmp(mirrors_type, SEG_TYPE_NAME_RAID1))
return _convert_striped_raid(cmd, lv, lp);
+ if (segtype_is_striped(lp->segtype) || segtype_is_raid(lp->segtype))
+ return _convert_striped_raid(cmd, lv, lp);
+
log_error("Unknown operation on striped or linear LV %s.", display_lvname(lv));
return 0;
}
5 years, 11 months
master - segtype: add linear
by Heinz Mauelshagen
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=de66704253653305e45...
Commit: de66704253653305e4513637735a078af00912b7
Parent: 2eda683a205d1ad2463cf60d783bc63d9833717e
Author: Heinz Mauelshagen <heinzm(a)redhat.com>
AuthorDate: Wed May 30 12:44:24 2018 +0200
Committer: Heinz Mauelshagen <heinzm(a)redhat.com>
CommitterDate: Tue Jun 5 16:23:18 2018 +0200
segtype: add linear
Add linear segtype addressing FIXME in preparation
for linear <-> striped convenience conversion support
---
lib/commands/toolcontext.c | 1 +
lib/metadata/segtype.c | 4 ----
lib/metadata/segtype.h | 4 +++-
lib/striped/striped.c | 19 ++++++++++++++-----
4 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index 7d0640a..8eaece6 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -1462,6 +1462,7 @@ static int _init_segtypes(struct cmd_context *cmd)
struct segment_type *segtype;
struct segtype_library seglib = { .cmd = cmd, .lib = NULL };
struct segment_type *(*init_segtype_array[])(struct cmd_context *cmd) = {
+ init_linear_segtype,
init_striped_segtype,
init_zero_segtype,
init_error_segtype,
diff --git a/lib/metadata/segtype.c b/lib/metadata/segtype.c
index 2fdbaa3..a6f6203 100644
--- a/lib/metadata/segtype.c
+++ b/lib/metadata/segtype.c
@@ -22,10 +22,6 @@ struct segment_type *get_segtype_from_string(struct cmd_context *cmd,
{
struct segment_type *segtype;
- /* FIXME Register this properly within striped.c */
- if (!strcmp(str, SEG_TYPE_NAME_LINEAR))
- str = SEG_TYPE_NAME_STRIPED;
-
dm_list_iterate_items(segtype, &cmd->segtypes)
if (!strcmp(segtype->name, str))
return segtype;
diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h
index fe19b34..5484c23 100644
--- a/lib/metadata/segtype.h
+++ b/lib/metadata/segtype.h
@@ -68,6 +68,7 @@ struct dev_manager;
#define SEG_RAID6 SEG_RAID6_ZR
#define SEG_STRIPED_TARGET (1ULL << 39)
+#define SEG_LINEAR_TARGET (1ULL << 40)
#define SEG_UNKNOWN (1ULL << 63)
@@ -105,7 +106,7 @@ struct dev_manager;
#define SEG_TYPE_NAME_RAID6_RS_6 "raid6_rs_6"
#define SEG_TYPE_NAME_RAID6_N_6 "raid6_n_6"
-#define segtype_is_linear(segtype) (!strcmp(segtype->name, SEG_TYPE_NAME_LINEAR))
+#define segtype_is_linear(segtype) (!strcmp((segtype)->name, SEG_TYPE_NAME_LINEAR))
#define segtype_is_striped_target(segtype) ((segtype)->flags & SEG_STRIPED_TARGET ? 1 : 0)
#define segtype_is_cache(segtype) ((segtype)->flags & SEG_CACHE ? 1 : 0)
#define segtype_is_cache_pool(segtype) ((segtype)->flags & SEG_CACHE_POOL ? 1 : 0)
@@ -274,6 +275,7 @@ struct segtype_library;
int lvm_register_segtype(struct segtype_library *seglib,
struct segment_type *segtype);
+struct segment_type *init_linear_segtype(struct cmd_context *cmd);
struct segment_type *init_striped_segtype(struct cmd_context *cmd);
struct segment_type *init_zero_segtype(struct cmd_context *cmd);
struct segment_type *init_error_segtype(struct cmd_context *cmd);
diff --git a/lib/striped/striped.c b/lib/striped/striped.c
index 9c8408c..a9854a2 100644
--- a/lib/striped/striped.c
+++ b/lib/striped/striped.c
@@ -230,7 +230,7 @@ static struct segtype_handler _striped_ops = {
.destroy = _striped_destroy,
};
-struct segment_type *init_striped_segtype(struct cmd_context *cmd)
+static struct segment_type *_init_segtype(struct cmd_context *cmd, const char *name, uint64_t target)
{
struct segment_type *segtype = dm_zalloc(sizeof(*segtype));
@@ -238,11 +238,20 @@ struct segment_type *init_striped_segtype(struct cmd_context *cmd)
return_NULL;
segtype->ops = &_striped_ops;
- segtype->name = SEG_TYPE_NAME_STRIPED;
- segtype->flags = SEG_STRIPED_TARGET |
- SEG_CAN_SPLIT | SEG_AREAS_STRIPED;
+ segtype->name = name;
+ segtype->flags = target | SEG_CAN_SPLIT | SEG_AREAS_STRIPED;
log_very_verbose("Initialised segtype: %s", segtype->name);
-
return segtype;
}
+
+struct segment_type *init_striped_segtype(struct cmd_context *cmd)
+{
+ return _init_segtype(cmd, SEG_TYPE_NAME_STRIPED, SEG_STRIPED_TARGET);
+}
+
+
+struct segment_type *init_linear_segtype(struct cmd_context *cmd)
+{
+ return _init_segtype(cmd, SEG_TYPE_NAME_LINEAR, SEG_LINEAR_TARGET);
+}
5 years, 11 months
master - build: base/Makefile
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2eda683a205d1ad2463...
Commit: 2eda683a205d1ad2463cf60d783bc63d9833717e
Parent: 232918fb86e1ee254ae5e4c9aece4615d828c9bb
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Mon Jun 4 15:37:35 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Mon Jun 4 15:37:35 2018 +0100
build: base/Makefile
.gitignore hid it.
---
base/Makefile | 29 +++++++++++++++++++++++++++++
1 files changed, 29 insertions(+), 0 deletions(-)
diff --git a/base/Makefile b/base/Makefile
new file mode 100644
index 0000000..27f539f
--- /dev/null
+++ b/base/Makefile
@@ -0,0 +1,29 @@
+# Copyright (C) 2018 Red Hat, Inc. All rights reserved.
+#
+# This file is part of the device-mapper userspace tools.
+#
+# 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 Lesser General Public License v.2.1.
+#
+# You should have received a copy of the GNU Lesser 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
+
+BASE_SOURCE=\
+ base/data-struct/radix-tree.c \
+
+BASE_DEPENDS=$(addprefix $(top_builddir)/,$(subst .c,.d,$(BASE_SOURCE)))
+BASE_OBJECTS=$(addprefix $(top_builddir)/,$(subst .c,.o,$(BASE_SOURCE)))
+CLEAN_TARGETS+=$(BASE_DEPENDS) $(BASE_OBJECTS)
+
+-include $(BASE_DEPENDS)
+
+$(BASE_OBJECTS): INCLUDES+=-I$(top_srcdir)/base/
+
+$(top_builddir)/base/libbase.a: $(BASE_OBJECTS)
+ @echo " [AR] $@"
+ $(Q) $(RM) $@
+ $(Q) $(AR) rsv $@ $(BASE_OBJECTS) > /dev/null
+
+CLEAN_TARGETS+=$(top_builddir)/base/libbase.a
5 years, 11 months
master - build: libbase.a
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=232918fb86e1ee254ae...
Commit: 232918fb86e1ee254ae5e4c9aece4615d828c9bb
Parent: 29abba378520a270c3a9385724c8ef5df66497b1
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Mon Jun 4 13:53:07 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Mon Jun 4 13:53:07 2018 +0100
build: libbase.a
---
Makefile.in | 1 +
daemons/clvmd/Makefile.in | 2 +-
daemons/dmeventd/Makefile.in | 2 +-
daemons/lvmetad/Makefile.in | 8 ++++----
daemons/lvmlockd/Makefile.in | 6 ++----
daemons/lvmpolld/Makefile.in | 3 +--
lib/Makefile.in | 1 -
libdm/make.tmpl.in | 4 ++--
make.tmpl.in | 8 ++++++--
scripts/Makefile.in | 4 ++--
test/api/Makefile.in | 3 +--
test/unit/Makefile.in | 2 +-
tools/Makefile.in | 8 ++++----
13 files changed, 26 insertions(+), 26 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 851447e..7eb6460 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -214,6 +214,7 @@ endif
include test/unit/Makefile
include $(top_srcdir)/device_mapper/Makefile
+include $(top_srcdir)/base/Makefile
ifneq ($(shell which ctags),)
.PHONY: tags
diff --git a/daemons/clvmd/Makefile.in b/daemons/clvmd/Makefile.in
index 9e096b5..622a603 100644
--- a/daemons/clvmd/Makefile.in
+++ b/daemons/clvmd/Makefile.in
@@ -80,7 +80,7 @@ CFLAGS += -fno-strict-aliasing $(EXTRA_EXEC_CFLAGS)
INSTALL_TARGETS = \
install_clvmd
-clvmd: $(OBJECTS) $(top_builddir)/lib/liblvm-internal.a $(top_builddir)/device_mapper/libdevice-mapper.a
+clvmd: $(OBJECTS) $(top_builddir)/lib/liblvm-internal.a $(INTERNAL_LIBS)
$(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) \
-o clvmd $+ $(LMLIBS) $(LIBS)
diff --git a/daemons/dmeventd/Makefile.in b/daemons/dmeventd/Makefile.in
index e43bb2b..56a9e35 100644
--- a/daemons/dmeventd/Makefile.in
+++ b/daemons/dmeventd/Makefile.in
@@ -61,7 +61,7 @@ LIBS += $(PTHREAD_LIBS)
dmeventd: $(LIB_SHARED) dmeventd.o
$(CC) $(CFLAGS) -L. $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) dmeventd.o \
- -o $@ $(DL_LIBS) $(DMEVENT_LIBS) $(top_builddir)/device_mapper/libdevice-mapper.a $(LIBS) -lm
+ -o $@ $(DL_LIBS) $(DMEVENT_LIBS) $(INTERNAL_LIBS) $(LIBS) -lm
dmeventd.static: $(LIB_STATIC) dmeventd.o
$(CC) $(CFLAGS) $(LDFLAGS) -static -L. -L$(interfacebuilddir) dmeventd.o \
diff --git a/daemons/lvmetad/Makefile.in b/daemons/lvmetad/Makefile.in
index f652db8..5738bbe 100644
--- a/daemons/lvmetad/Makefile.in
+++ b/daemons/lvmetad/Makefile.in
@@ -36,13 +36,13 @@ LIBS += $(RT_LIBS) $(DAEMON_LIBS) $(PTHREAD_LIBS) -lm
lvmetad: $(OBJECTS) $(top_builddir)/libdaemon/client/libdaemonclient.a \
$(top_builddir)/libdaemon/server/libdaemonserver.a \
- $(top_builddir)/device_mapper/libdevice-mapper.a
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) $(top_builddir)/device_mapper/libdevice-mapper.a -ldaemonserver $(LIBS)
+ $(INTERNAL_LIBS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) -ldaemonserver $(INTERNAL_LIBS) $(LIBS)
lvmetactl: lvmetactl.o $(top_builddir)/libdaemon/client/libdaemonclient.a \
$(top_builddir)/libdaemon/server/libdaemonserver.a \
- $(top_builddir)/device_mapper/libdevice-mapper.a
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ lvmetactl.o $(top_builddir)/device_mapper/libdevice-mapper.a $(LIBS)
+ $(INTERNAL_LIBS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ lvmetactl.o $(INTERNAL_LIBS) $(LIBS)
CLEAN_TARGETS += lvmetactl.o
diff --git a/daemons/lvmlockd/Makefile.in b/daemons/lvmlockd/Makefile.in
index 7c58fe2..6dcc207 100644
--- a/daemons/lvmlockd/Makefile.in
+++ b/daemons/lvmlockd/Makefile.in
@@ -42,12 +42,10 @@ LIBS += $(RT_LIBS) $(DAEMON_LIBS) $(PTHREAD_LIBS)
lvmlockd: $(OBJECTS) $(top_builddir)/libdaemon/client/libdaemonclient.a \
$(top_builddir)/libdaemon/server/libdaemonserver.a
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) $(LOCK_LIBS) -ldaemonserver \
- $(top_builddir)/device_mapper/libdevice-mapper.a $(LIBS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) $(LOCK_LIBS) -ldaemonserver $(INTERNAL_LIBS) $(LIBS)
lvmlockctl: lvmlockctl.o $(top_builddir)/libdaemon/client/libdaemonclient.a
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ lvmlockctl.o \
- $(top_builddir)/device_mapper/libdevice-mapper.a $(LIBS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ lvmlockctl.o $(INTERNAL_LIBS) $(LIBS)
install_lvmlockd: lvmlockd
$(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
diff --git a/daemons/lvmpolld/Makefile.in b/daemons/lvmpolld/Makefile.in
index 229a87e..8bf2556 100644
--- a/daemons/lvmpolld/Makefile.in
+++ b/daemons/lvmpolld/Makefile.in
@@ -34,8 +34,7 @@ LIBS += $(DAEMON_LIBS) -ldaemonserver $(PTHREAD_LIBS)
lvmpolld: $(OBJECTS) $(top_builddir)/libdaemon/client/libdaemonclient.a \
$(top_builddir)/libdaemon/server/libdaemonserver.a
- $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) \
- $(top_builddir)/device_mapper/libdevice-mapper.a $(LIBS)
+ $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJECTS) $(INTERNAL_LIBS) $(LIBS)
install_lvmpolld: lvmpolld
$(INSTALL_PROGRAM) -D $< $(sbindir)/$(<F)
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 4fb4fcf..1d42235 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -21,7 +21,6 @@ ifeq ("@CLUSTER@", "shared")
endif
SOURCES =\
- ../base/data-struct/radix-tree.c \
activate/activate.c \
cache/lvmcache.c \
cache_segtype/cache.c \
diff --git a/libdm/make.tmpl.in b/libdm/make.tmpl.in
index b9672dc..fc29034 100644
--- a/libdm/make.tmpl.in
+++ b/libdm/make.tmpl.in
@@ -342,7 +342,7 @@ SUBDIRS.distclean := $(SUBDIRS:=.distclean)
TARGETS += $(LIB_SHARED) $(LIB_STATIC)
-all: $(top_builddir)/device_mapper/libdevice-mapper.a $(SUBDIRS) $(TARGETS)
+all: $(SUBDIRS) $(TARGETS)
install: all $(SUBDIRS.install)
install_cluster: all $(SUBDIRS.install_cluster)
@@ -351,7 +351,7 @@ install_lvm2: $(SUBDIRS.install_lvm2)
install_ocf: $(SUBDIRS.install_ocf)
cflow: $(SUBDIRS.cflow)
-$(SUBDIRS): $(SUBDIRS.device-mapper) $(top_builddir)/device_mapper/libdevice-mapper.a
+$(SUBDIRS): $(SUBDIRS.device-mapper)
$(MAKE) -C $@
$(SUBDIRS.device-mapper):
diff --git a/make.tmpl.in b/make.tmpl.in
index b9672dc..0790d7b 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -342,7 +342,11 @@ SUBDIRS.distclean := $(SUBDIRS:=.distclean)
TARGETS += $(LIB_SHARED) $(LIB_STATIC)
-all: $(top_builddir)/device_mapper/libdevice-mapper.a $(SUBDIRS) $(TARGETS)
+INTERNAL_LIBS=\
+ $(top_builddir)/device_mapper/libdevice-mapper.a \
+ $(top_builddir)/base/libbase.a
+
+all: $(INTERNAL_LIBS) $(SUBDIRS) $(TARGETS)
install: all $(SUBDIRS.install)
install_cluster: all $(SUBDIRS.install_cluster)
@@ -351,7 +355,7 @@ install_lvm2: $(SUBDIRS.install_lvm2)
install_ocf: $(SUBDIRS.install_ocf)
cflow: $(SUBDIRS.cflow)
-$(SUBDIRS): $(SUBDIRS.device-mapper) $(top_builddir)/device_mapper/libdevice-mapper.a
+$(SUBDIRS): $(SUBDIRS.device-mapper) $(INTERNAL_LIBS)
$(MAKE) -C $@
$(SUBDIRS.device-mapper):
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
index 194d2e2..ee39306 100644
--- a/scripts/Makefile.in
+++ b/scripts/Makefile.in
@@ -88,8 +88,8 @@ endif
CFLAGS_lvm2_activation_generator_systemd_red_hat.o += $(EXTRA_EXEC_CFLAGS)
-lvm2_activation_generator_systemd_red_hat: $(OBJECTS) $(DEPLIBS) $(top_builddir)/device_mapper/libdevice-mapper.a
- $(CC) -o $@ $(OBJECTS) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) $(LVMLIBS) $(top_builddir)/device_mapper/libdevice-mapper.a $(LIBS)
+lvm2_activation_generator_systemd_red_hat: $(OBJECTS) $(DEPLIBS) $(INTERNAL_LIBS)
+ $(CC) -o $@ $(OBJECTS) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) $(LVMLIBS) $(INTERNAL_LIBS) $(LIBS)
install_systemd_generators:
$(INSTALL_DIR) $(systemd_generator_dir)
diff --git a/test/api/Makefile.in b/test/api/Makefile.in
index d010394..6872095 100644
--- a/test/api/Makefile.in
+++ b/test/api/Makefile.in
@@ -46,8 +46,7 @@ DEFS += -D_REENTRANT
DEPLIBS += $(top_builddir)/liblvm/liblvm2app.so
LDFLAGS+=\
-L$(top_builddir)/liblvm \
- -L$(top_builddir)/daemons/dmeventd \
- -L$(top_builddir)/device_mapper/libdevice-mapper.a
+ -L$(top_builddir)/daemons/dmeventd
LIBS += @LVM2APP_LIB@ $(DMEVENT_LIBS)
%.t: %.o $(DEPLIBS)
diff --git a/test/unit/Makefile.in b/test/unit/Makefile.in
index ca36c57..994968c 100644
--- a/test/unit/Makefile.in
+++ b/test/unit/Makefile.in
@@ -34,7 +34,7 @@ UNIT_OBJECTS=$(UNIT_SOURCE:%.c=%.o)
CLEAN_TARGETS+=$(UNIT_DEPENDS) $(UNIT_OBJECTS)
UNIT_LDLIBS += $(LVMINTERNAL_LIBS) -laio
-test/unit/unit-test: $(UNIT_OBJECTS) lib/liblvm-internal.a device_mapper/libdevice-mapper.a
+test/unit/unit-test: $(UNIT_OBJECTS) lib/liblvm-internal.a $(INTERNAL_LIBS)
@echo " [LD] $@"
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) \
-o $@ $+ $(UNIT_LDLIBS) -lm
diff --git a/tools/Makefile.in b/tools/Makefile.in
index d4514a2..2dbd93b 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -122,12 +122,12 @@ device-mapper: $(TARGETS_DM)
CFLAGS_dmsetup.o += $(UDEV_CFLAGS) $(EXTRA_EXEC_CFLAGS)
-dmsetup: dmsetup.o $(top_builddir)/device_mapper/libdevice-mapper.a
+dmsetup: dmsetup.o $(INTERNAL_LIBS)
@echo " [CC] $@"
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) \
-o $@ $+ $(LIBS) -lm
-dmsetup.static: dmsetup.o $(top_builddir)/device_mapper/libdevice-mapper.a
+dmsetup.static: dmsetup.o $(INTERNAL_LIBS)
@echo " [CC] $@"
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) \
-o $@ $+ $(M_LIBS) $(PTHREAD_LIBS) $(STATIC_LIBS) $(LIBS)
@@ -138,7 +138,7 @@ CFLAGS_lvm.o += $(EXTRA_EXEC_CFLAGS)
INCLUDES += -I$(top_builddir)/tools
-lvm: $(OBJECTS) lvm.o $(top_builddir)/lib/liblvm-internal.a $(top_builddir)/device_mapper/libdevice-mapper.a
+lvm: $(OBJECTS) lvm.o $(top_builddir)/lib/liblvm-internal.a $(INTERNAL_LIBS)
@echo " [CC] $@"
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) $(EXTRA_EXEC_LDFLAGS) $(ELDFLAGS) -o $@ $+ \
$(LVMLIBS) $(READLINE_LIBS) $(LIBS) -lm
@@ -157,7 +157,7 @@ ifeq ("@BUILD_LVMETAD@", "yes")
lvm: $(top_builddir)/libdaemon/client/libdaemonclient.a
endif
-lvm.static: $(OBJECTS) lvm-static.o $(top_builddir)/lib/liblvm-internal.a $(top_builddir)/device_mapper/libdevice-mapper.a
+lvm.static: $(OBJECTS) lvm-static.o $(top_builddir)/lib/liblvm-internal.a $(INTERNAL_LIBS)
@echo " [CC] $@"
$(Q) $(CC) $(CFLAGS) $(LDFLAGS) -static -L$(interfacebuilddir) -o $@ \
$(OBJECTS) lvm-static.o $(LVMLIBS) $(STATIC_LIBS) $(LIBS)
5 years, 11 months
master - build: get separate builddir working again
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=29abba378520a270c3a...
Commit: 29abba378520a270c3a9385724c8ef5df66497b1
Parent: 66b10275c5ce7328cd5fb0f00a52de6c76e45481
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Mon Jun 4 13:22:14 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Mon Jun 4 13:22:14 2018 +0100
build: get separate builddir working again
---
Makefile.in | 2 +-
device_mapper/Makefile | 10 +++++-----
device_mapper/datastruct/bitset.c | 2 +-
device_mapper/datastruct/hash.c | 2 +-
device_mapper/datastruct/list.c | 2 +-
device_mapper/ioctl/libdm-iface.c | 10 +++++-----
device_mapper/mm/dbg_malloc.c | 2 +-
device_mapper/mm/pool-fast.c | 2 +-
device_mapper/mm/pool.c | 2 +-
device_mapper/regex/matcher.c | 2 +-
device_mapper/regex/parse_rx.c | 2 +-
device_mapper/regex/ttree.c | 2 +-
libdm/make.tmpl.in | 29 ++++++++++++++++++++---------
make.tmpl.in | 19 +++++++++++++------
14 files changed, 53 insertions(+), 35 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 00b4f1e..851447e 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -213,7 +213,7 @@ endif
endif
include test/unit/Makefile
-include device_mapper/Makefile
+include $(top_srcdir)/device_mapper/Makefile
ifneq ($(shell which ctags),)
.PHONY: tags
diff --git a/device_mapper/Makefile b/device_mapper/Makefile
index 999c3ba..b246f82 100644
--- a/device_mapper/Makefile
+++ b/device_mapper/Makefile
@@ -30,17 +30,17 @@ DEVICE_MAPPER_SOURCE=\
device_mapper/regex/ttree.c \
device_mapper/ioctl/libdm-iface.c
-DEVICE_MAPPER_DEPENDS=$(subst .c,.d,$(DEVICE_MAPPER_SOURCE))
-DEVICE_MAPPER_OBJECTS=$(subst .c,.o,$(DEVICE_MAPPER_SOURCE))
+DEVICE_MAPPER_DEPENDS=$(addprefix $(top_builddir)/,$(subst .c,.d,$(DEVICE_MAPPER_SOURCE)))
+DEVICE_MAPPER_OBJECTS=$(addprefix $(top_builddir)/,$(subst .c,.o,$(DEVICE_MAPPER_SOURCE)))
CLEAN_TARGETS+=$(DEVICE_MAPPER_DEPENDS) $(DEVICE_MAPPER_OBJECTS)
-include $(DEVICE_MAPPER_DEPENDS)
-$(DEVICE_MAPPER_OBJECTS): INCLUDES+=-Idevice_mapper/
+$(DEVICE_MAPPER_OBJECTS): INCLUDES+=-I$(top_srcdir)/device_mapper/
-device_mapper/libdevice-mapper.a: $(DEVICE_MAPPER_OBJECTS)
+$(top_builddir)/device_mapper/libdevice-mapper.a: $(DEVICE_MAPPER_OBJECTS)
@echo " [AR] $@"
$(Q) $(RM) $@
$(Q) $(AR) rsv $@ $(DEVICE_MAPPER_OBJECTS) > /dev/null
-CLEAN_TARGETS+=device_mapper/libdevice-mapper.a
+CLEAN_TARGETS+=$(top_builddir)/device_mapper/libdevice-mapper.a
diff --git a/device_mapper/datastruct/bitset.c b/device_mapper/datastruct/bitset.c
index 6ae99d3..f093ac0 100644
--- a/device_mapper/datastruct/bitset.c
+++ b/device_mapper/datastruct/bitset.c
@@ -13,7 +13,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "misc/dmlib.h"
+#include "device_mapper/misc/dmlib.h"
#include <ctype.h>
diff --git a/device_mapper/datastruct/hash.c b/device_mapper/datastruct/hash.c
index 9b9c939..59e719b 100644
--- a/device_mapper/datastruct/hash.c
+++ b/device_mapper/datastruct/hash.c
@@ -13,7 +13,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "misc/dmlib.h"
+#include "device_mapper/misc/dmlib.h"
struct dm_hash_node {
struct dm_hash_node *next;
diff --git a/device_mapper/datastruct/list.c b/device_mapper/datastruct/list.c
index 86c3e4e..bda8027 100644
--- a/device_mapper/datastruct/list.c
+++ b/device_mapper/datastruct/list.c
@@ -13,7 +13,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "misc/dmlib.h"
+#include "device_mapper/misc/dmlib.h"
#include <assert.h>
/*
diff --git a/device_mapper/ioctl/libdm-iface.c b/device_mapper/ioctl/libdm-iface.c
index 4825f1d..3e1b445 100644
--- a/device_mapper/ioctl/libdm-iface.c
+++ b/device_mapper/ioctl/libdm-iface.c
@@ -13,9 +13,9 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "misc/dmlib.h"
-#include "libdm-targets.h"
-#include "libdm-common.h"
+#include "device_mapper/misc/dmlib.h"
+#include "device_mapper/ioctl/libdm-targets.h"
+#include "device_mapper/libdm-common.h"
#include <stddef.h>
#include <fcntl.h>
@@ -26,7 +26,7 @@
#include <unistd.h>
#ifdef __linux__
-# include "misc/kdev_t.h"
+# include "device_mapper/misc/kdev_t.h"
# include <linux/limits.h>
#else
# define MAJOR(x) major((x))
@@ -34,7 +34,7 @@
# define MKDEV(x,y) makedev((x),(y))
#endif
-#include "misc/dm-ioctl.h"
+#include "device_mapper/misc/dm-ioctl.h"
/*
* Ensure build compatibility.
diff --git a/device_mapper/mm/dbg_malloc.c b/device_mapper/mm/dbg_malloc.c
index a17203c..b169f8b 100644
--- a/device_mapper/mm/dbg_malloc.c
+++ b/device_mapper/mm/dbg_malloc.c
@@ -13,7 +13,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "misc/dmlib.h"
+#include "device_mapper/misc/dmlib.h"
#ifdef VALGRIND_POOL
#include "memcheck.h"
diff --git a/device_mapper/mm/pool-fast.c b/device_mapper/mm/pool-fast.c
index 895872e..b83c693 100644
--- a/device_mapper/mm/pool-fast.c
+++ b/device_mapper/mm/pool-fast.c
@@ -17,7 +17,7 @@
#include "memcheck.h"
#endif
-#include "misc/dmlib.h"
+#include "device_mapper/misc/dmlib.h"
#include <stddef.h> /* For musl libc */
#include <malloc.h>
diff --git a/device_mapper/mm/pool.c b/device_mapper/mm/pool.c
index a710704..20d7fd9 100644
--- a/device_mapper/mm/pool.c
+++ b/device_mapper/mm/pool.c
@@ -13,7 +13,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "misc/dmlib.h"
+#include "device_mapper/misc/dmlib.h"
#include <sys/mman.h>
#include <pthread.h>
diff --git a/device_mapper/regex/matcher.c b/device_mapper/regex/matcher.c
index 375c1ab..b3870e0 100644
--- a/device_mapper/regex/matcher.c
+++ b/device_mapper/regex/matcher.c
@@ -13,7 +13,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "misc/dmlib.h"
+#include "device_mapper/misc/dmlib.h"
#include "parse_rx.h"
#include "ttree.h"
#include "assert.h"
diff --git a/device_mapper/regex/parse_rx.c b/device_mapper/regex/parse_rx.c
index cc83bfe..563d2ae 100644
--- a/device_mapper/regex/parse_rx.c
+++ b/device_mapper/regex/parse_rx.c
@@ -13,7 +13,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "misc/dmlib.h"
+#include "device_mapper/misc/dmlib.h"
#include "parse_rx.h"
#ifdef DEBUG
diff --git a/device_mapper/regex/ttree.c b/device_mapper/regex/ttree.c
index 62c5bf7..27b775e 100644
--- a/device_mapper/regex/ttree.c
+++ b/device_mapper/regex/ttree.c
@@ -13,7 +13,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#include "misc/dmlib.h"
+#include "device_mapper/misc/dmlib.h"
#include "ttree.h"
struct node {
diff --git a/libdm/make.tmpl.in b/libdm/make.tmpl.in
index 7e3f4a4..b9672dc 100644
--- a/libdm/make.tmpl.in
+++ b/libdm/make.tmpl.in
@@ -58,6 +58,7 @@ PYTHON3 = @PYTHON3@
PYCOMPILE = $(top_srcdir)/autoconf/py-compile
LIBS = @LIBS@
+LIBS += $(SELINUX_LIBS) $(UDEV_LIBS) $(BLKID_LIBS) $(RT_LIBS) -lm
# Extra libraries always linked with static binaries
STATIC_LIBS = $(SELINUX_LIBS) $(UDEV_LIBS) $(BLKID_LIBS)
DEFS += @DEFS@
@@ -68,7 +69,9 @@ CLDFLAGS += @CLDFLAGS@
ELDFLAGS += @ELDFLAGS@
LDDEPS += @LDDEPS@
LIB_SUFFIX = @LIB_SUFFIX@
-LVMINTERNAL_LIBS = -llvm-internal $(DMEVENT_LIBS) $(DAEMON_LIBS) $(SYSTEMD_LIBS) $(UDEV_LIBS) $(DL_LIBS) $(BLKID_LIBS)
+LVMINTERNAL_LIBS=\
+ -llvm-internal \
+ $(DMEVENT_LIBS) $(DAEMON_LIBS) $(SYSTEMD_LIBS) $(UDEV_LIBS) $(DL_LIBS) $(BLKID_LIBS)
DL_LIBS = @DL_LIBS@
RT_LIBS = @RT_LIBS@
M_LIBS = @M_LIBS@
@@ -308,6 +311,7 @@ LIB_VERSION_APP := $(shell $(AWK) -F '[(). ]' '{printf "%s.%s",$$1,$$4}' $(top_s
INCLUDES += -I$(top_srcdir) -I$(srcdir) -I$(top_builddir)/include
+
DEPS = $(top_builddir)/make.tmpl $(top_srcdir)/VERSION \
$(top_builddir)/Makefile
@@ -338,7 +342,7 @@ SUBDIRS.distclean := $(SUBDIRS:=.distclean)
TARGETS += $(LIB_SHARED) $(LIB_STATIC)
-all: $(SUBDIRS) $(TARGETS)
+all: $(top_builddir)/device_mapper/libdevice-mapper.a $(SUBDIRS) $(TARGETS)
install: all $(SUBDIRS.install)
install_cluster: all $(SUBDIRS.install_cluster)
@@ -347,7 +351,7 @@ install_lvm2: $(SUBDIRS.install_lvm2)
install_ocf: $(SUBDIRS.install_ocf)
cflow: $(SUBDIRS.cflow)
-$(SUBDIRS): $(SUBDIRS.device-mapper)
+$(SUBDIRS): $(SUBDIRS.device-mapper) $(top_builddir)/device_mapper/libdevice-mapper.a
$(MAKE) -C $@
$(SUBDIRS.device-mapper):
@@ -440,14 +444,12 @@ endif
.LIBPATTERNS = lib%.so lib%.a
-DEPFLAGS=-MT $@ -MMD -MP -MF $*.d
-
# still needed in 2018 for 32bit builds
DEFS+=-D_FILE_OFFSET_BITS=64
%.o: %.c
@echo " [CC] $<"
- $(Q) $(CC) $(DEPFLAGS) -c $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) $(DEFS) $(DEFS_$@) $(WFLAGS) $(WCFLAGS) $(CFLAGS) $(CFLAGS_$@) $< -o $@
+ $(Q) $(CC) -c $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) $(DEFS) $(DEFS_$@) $(WFLAGS) $(WCFLAGS) $(CFLAGS) $(CFLAGS_$@) $< -o $@
%.o: %.cpp
@echo " [CXX] $<"
@@ -507,9 +509,18 @@ $(LIB_STATIC): $(OBJECTS)
$(Q) $(RM) $@
$(Q) $(AR) rsv $@ $(OBJECTS) > /dev/null
-%.d:
-.PRECIOUS: %.d
-
+%.d: %.c
+ @echo " [DEP] $<"
+ $(Q) $(MKDIR_P) $(dir $@); \
+ set -e; \
+ FILE=`echo $@ | sed 's/\\//\\\\\\//g;s/\\.d//g'`; \
+ DEPS=`echo $(DEPS) | sed -e 's/\\//\\\\\\//g'`; \
+ $(CC) -MM $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) $(DEFS) -o $@ $<; \
+ sed -i "s/\(.*\)\.o[ :]*/$$FILE.o $$FILE.d $$FILE.pot: $$DEPS /g" $@; \
+ DEPLIST=`sed 's/ \\\\//;s/.*://;' < $@`; \
+ echo $$DEPLIST | fmt -1 | sed 's/ //g;s/\(.*\)/\1:/' >> $@; \
+ [ -s $@ ] || $(RM) $@
+
%.mo: %.po
@echo " [MSGFMT] $<"
$(Q) $(MSGFMT) -o $@ $<
diff --git a/make.tmpl.in b/make.tmpl.in
index 16a8571..b9672dc 100644
--- a/make.tmpl.in
+++ b/make.tmpl.in
@@ -444,14 +444,12 @@ endif
.LIBPATTERNS = lib%.so lib%.a
-DEPFLAGS=-MT $@ -MMD -MP -MF $*.d
-
# still needed in 2018 for 32bit builds
DEFS+=-D_FILE_OFFSET_BITS=64
%.o: %.c
@echo " [CC] $<"
- $(Q) $(CC) $(DEPFLAGS) -c $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) $(DEFS) $(DEFS_$@) $(WFLAGS) $(WCFLAGS) $(CFLAGS) $(CFLAGS_$@) $< -o $@
+ $(Q) $(CC) -c $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) $(DEFS) $(DEFS_$@) $(WFLAGS) $(WCFLAGS) $(CFLAGS) $(CFLAGS_$@) $< -o $@
%.o: %.cpp
@echo " [CXX] $<"
@@ -511,9 +509,18 @@ $(LIB_STATIC): $(OBJECTS)
$(Q) $(RM) $@
$(Q) $(AR) rsv $@ $(OBJECTS) > /dev/null
-%.d:
-.PRECIOUS: %.d
-
+%.d: %.c
+ @echo " [DEP] $<"
+ $(Q) $(MKDIR_P) $(dir $@); \
+ set -e; \
+ FILE=`echo $@ | sed 's/\\//\\\\\\//g;s/\\.d//g'`; \
+ DEPS=`echo $(DEPS) | sed -e 's/\\//\\\\\\//g'`; \
+ $(CC) -MM $(INCLUDES) $(VALGRIND_CFLAGS) $(PROGS_CFLAGS) $(DEFS) -o $@ $<; \
+ sed -i "s/\(.*\)\.o[ :]*/$$FILE.o $$FILE.d $$FILE.pot: $$DEPS /g" $@; \
+ DEPLIST=`sed 's/ \\\\//;s/.*://;' < $@`; \
+ echo $$DEPLIST | fmt -1 | sed 's/ //g;s/\(.*\)/\1:/' >> $@; \
+ [ -s $@ ] || $(RM) $@
+
%.mo: %.po
@echo " [MSGFMT] $<"
$(Q) $(MSGFMT) -o $@ $<
5 years, 11 months
master - build: More tweaks to python include dirs.
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=66b10275c5ce7328cd5...
Commit: 66b10275c5ce7328cd5fb0f00a52de6c76e45481
Parent: f6eeb218b20685b1bf0f76b24c5697901896bdec
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Mon Jun 4 12:28:17 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Mon Jun 4 12:28:17 2018 +0100
build: More tweaks to python include dirs.
---
python/setup.py.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/python/setup.py.in b/python/setup.py.in
index c39e4fc..07b79df 100644
--- a/python/setup.py.in
+++ b/python/setup.py.in
@@ -22,7 +22,7 @@ liblvm = Extension('lvm',
sources = ['liblvm_python.c'],
libraries= ['lvm2app', 'devmapper'],
library_dirs= ['@top_builddir@/liblvm', '@top_builddir@/libdm'],
- include_dirs= ['@top_builddir@'])
+ include_dirs= ['@top_builddir@/include', '@top_srcdir@'])
setup (name='lvm',
version=@LVM_VERSION@,
5 years, 11 months
master - build: Get python dir building without the include/ dir
by Joe Thornber
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=891f8dc19d7b9c5a729...
Commit: 891f8dc19d7b9c5a72971200fad2b29b13e43bfa
Parent: 21a5be2364574de43e2afe55a250ccced02df008
Author: Joe Thornber <ejt(a)redhat.com>
AuthorDate: Mon Jun 4 11:59:13 2018 +0100
Committer: Joe Thornber <ejt(a)redhat.com>
CommitterDate: Mon Jun 4 11:59:13 2018 +0100
build: Get python dir building without the include/ dir
---
python/setup.py.in | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/python/setup.py.in b/python/setup.py.in
index d09b791..c39e4fc 100644
--- a/python/setup.py.in
+++ b/python/setup.py.in
@@ -22,7 +22,7 @@ liblvm = Extension('lvm',
sources = ['liblvm_python.c'],
libraries= ['lvm2app', 'devmapper'],
library_dirs= ['@top_builddir@/liblvm', '@top_builddir@/libdm'],
- include_dirs= ['@top_builddir@/include'])
+ include_dirs= ['@top_builddir@'])
setup (name='lvm',
version=@LVM_VERSION@,
5 years, 11 months