* [linux-lvm] [RFC PATCH] lvconvert: fix the size of log device when converting from linear to mirror
@ 2021-07-07 3:20 Zhong Lidong
0 siblings, 0 replies; 3+ messages in thread
From: Zhong Lidong @ 2021-07-07 3:20 UTC (permalink / raw)
To: linux-lvm
When converting a large linear device to mirror with --stripes parameter
in lvconvert command, it will report the following error:
ioctl/libdm-iface.c:1895 device-mapper: reload ioctl on (254:0)
failed: Invalid argument
and the related kernel messages:
kernel: [ 2290.698171] device-mapper: dirty region log: log device 254:1
too small: need 7078912 bytes
kernel: [ 2290.698248] device-mapper: table: 254:0: mirror: Error
creating mirror dirty log
kernel: [ 2290.698251] device-mapper: ioctl: error adding target to table
Steps to reproduce this problem
~$:pvs
PV VG Fmt Attr PSize PFree
/dev/loop0 vg lvm2 a-- 10.00t 10.00t
/dev/loop1 vg lvm2 a-- 10.00t 10.00t
/dev/loop2 vg lvm2 a-- 10.00t 10.00t
/dev/loop3 lvm2 --- 10.00t 10.00t
/dev/loop4 lvm2 --- 10.00t 10.00t
/dev/loop5 lvm2 --- 10.00t 10.00t
~$:lvcreate -nlv -L27T vg
Logical volume "lv" created.
~$:vgextend vg /dev/loop[3-5]
Volume group "vg" successfully extended
~$:lvconvert --type mirror --mirrors 1 --stripes 3 -I256 /dev/vg/lv
/dev/loop3 /dev/loop4 /dev/loop5
device-mapper: reload ioctl on (254:0) failed: Invalid argument
Failed to lock logical volume vg/lv.
~$: lvs
WARNING: Reading VG vg from disk because lvmetad metadata is invalid.
LV VG Attr LSize Pool Origin Data% Meta% Move Log
Cpy%Sync Convert
lv vg -wi-a----- 27.00t
lv_mlog vg -wi-a----- 4.00m
~$: pvs
PV VG Fmt Attr PSize PFree
/dev/loop0 vg lvm2 a-- 10.00t 0
/dev/loop1 vg lvm2 a-- 10.00t 0
/dev/loop2 vg lvm2 a-- 10.00t 3.00t
/dev/loop3 vg lvm2 a-- 10.00t 10.00t
/dev/loop4 vg lvm2 a-- 10.00t 10.00t
/dev/loop5 vg lvm2 a-- 10.00t 10.00t
Analysis: In kernel space the required log size depends on the whole
target device size.But in user space, the log size is calculated from
the whole target devices size divided by allocation area number, which
leads to the mismatch here.
Signed-off-by: Lidong Zhong <lidong.zhong@suse.com>
---
lib/metadata/lv_manip.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 7e66afd9c..e8d67c79b 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -3730,8 +3730,7 @@ static struct alloc_handle *_alloc_init(struct
cmd_context *cmd,
} else {
ah->log_area_count = metadata_area_count;
ah->log_len = !metadata_area_count ? 0 :
- _mirror_log_extents(ah->region_size, extent_size,
- (existing_extents + new_extents) / ah->area_multiple);
+ _mirror_log_extents(ah->region_size, extent_size, existing_extents +
new_extents);
}
if (total_extents || existing_extents)
--
2.26.2
_______________________________________________
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [linux-lvm] [RFC PATCH] lvconvert: fix the size of log device when converting, from linear to mirror
2021-07-06 2:57 [linux-lvm] [RFC PATCH] lvconvert: fix the size of log device when converting, " Zhong Lidong
@ 2021-07-14 19:42 ` heming.zhao
0 siblings, 0 replies; 3+ messages in thread
From: heming.zhao @ 2021-07-14 19:42 UTC (permalink / raw)
To: LVM general discussion and development, Zhong Lidong
Cc: David Teigland, agk, Zdenek Kabelac
Hello,
This patch looks good to me.
I give a little more explain.
Scenario:
there is a "--type mirror" LV with two legs: one leg is linear dev, another leg is striped devs.
the disks (LV) layout:
```
# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 200M 0 disk
└─vg1-lv1_mimage_0 254:4 0 96M 0 lvm
└─vg1-lv1 254:2 0 96M 0 lvm
sdb 8:16 0 200M 0 disk
└─vg1-lv1_mimage_1 254:5 0 96M 0 lvm
└─vg1-lv1 254:2 0 96M 0 lvm
sdc 8:32 0 200M 0 disk
└─vg1-lv1_mimage_1 254:5 0 96M 0 lvm
└─vg1-lv1 254:2 0 96M 0 lvm
sdd 8:48 0 200M 0 disk
├─vg1-lv1_mlog 254:3 0 4M 0 lvm
│ └─vg1-lv1 254:2 0 96M 0 lvm
└─vg1-lv1_mimage_1 254:5 0 96M 0 lvm
└─vg1-lv1 254:2 0 96M 0 lvm
# dmsetup table
vg1-lv1: 0 196608 mirror disk 2 254:3 2048 2 254:4 0 254:5 0 1 handle_errors
vg1-lv1_mlog: 0 8192 linear 8:48 73728
vg1-lv1_mimage_1: 0 196608 striped 3 512 8:16 8192 8:32 8192 8:48 8192
vg1-lv1_mimage_0: 0 196608 linear 8:0 8192
```
Present lvm algorithm: "whole one leg size" / "striped devices number". (96MB / 3)
But kernel side dm-log module doesn't div "striped devices number". (96MB)
The kernel side algorithm is correct.
Let's image, in top layer, mirrored LV only know it has two same legs, disk log only related top
layer write IO.
It looks lvm2 algoritm is wrong from the first commit:
```
commit 16d9293bd7205c6ad2e932225aafca7513e540d9
Author: Alasdair Kergon <agk@redhat.com>
Date: Mon Mar 1 20:00:20 2010 +0000
Extend core allocation code in preparation for mirrored log areas.
```
The "--type mirror" is marked as deprecated many years ago. Does it block this patch to be accepted?
Maybe I miss somethings for the related code in lvm2 function _alloc_init()?
```_alloc_init@lib/metadata/lv_manip.c
} else { //the "else" branch suites for other LV types except for "mirror"?
ah->log_area_count = metadata_area_count;
ah->log_len = !metadata_area_count ? 0 :
_mirror_log_extents(ah->region_size, extent_size,
(existing_extents + new_extents) / ah->area_multiple);
}
```
Thanks
Heming
On 7/6/21 10:57 AM, Zhong Lidong wrote:
> When converting a large linear device to mirror with --stripes parameter
> in lvconvert command, it will report the following error:
>
> ioctl/libdm-iface.c:1895 device-mapper: reload ioctl on (254:0)
> failed: Invalid argument
>
> and the related kernel messages:
>
> kernel: [ 2290.698171] device-mapper: dirty region log: log device 254:1
> too small: need 7078912 bytes
> kernel: [ 2290.698248] device-mapper: table: 254:0: mirror: Error
> creating mirror dirty log
> kernel: [ 2290.698251] device-mapper: ioctl: error adding target to table
>
> Steps to reproduce this problem
> ~$:pvs
> PV VG Fmt Attr PSize PFree
> /dev/loop0 vg lvm2 a-- 10.00t 10.00t
> /dev/loop1 vg lvm2 a-- 10.00t 10.00t
> /dev/loop2 vg lvm2 a-- 10.00t 10.00t
> /dev/loop3 lvm2 --- 10.00t 10.00t
> /dev/loop4 lvm2 --- 10.00t 10.00t
> /dev/loop5 lvm2 --- 10.00t 10.00t
>
> ~$:lvcreate -nlv -L27T vg
> Logical volume "lv" created.
>
> ~$:vgextend vg /dev/loop[3-5]
> Volume group "vg" successfully extended
>
> ~$:lvconvert --type mirror --mirrors 1 --stripes 3 -I256 /dev/vg/lv
> /dev/loop3 /dev/loop4 /dev/loop5
> device-mapper: reload ioctl on (254:0) failed: Invalid argument
> Failed to lock logical volume vg/lv.
> ~$: lvs
> WARNING: Reading VG vg from disk because lvmetad metadata is invalid.
> LV VG Attr LSize Pool Origin Data% Meta% Move Log
> Cpy%Sync Convert
> lv vg -wi-a----- 27.00t
> lv_mlog vg -wi-a----- 4.00m
> ~$: pvs
> PV VG Fmt Attr PSize PFree
> /dev/loop0 vg lvm2 a-- 10.00t 0
> /dev/loop1 vg lvm2 a-- 10.00t 0
> /dev/loop2 vg lvm2 a-- 10.00t 3.00t
> /dev/loop3 vg lvm2 a-- 10.00t 10.00t
> /dev/loop4 vg lvm2 a-- 10.00t 10.00t
> /dev/loop5 vg lvm2 a-- 10.00t 10.00t
>
> Analysis: In kernel space the required log size depends on the whole
> target device size.But in user space, the log size is calculated from
> the whole target devices size divided by allocation area number, which
> leads to the mismatch here.
>
> Signed-off-by: Lidong Zhong <lidong.zhong@suse.com>
> ---
> lib/metadata/lv_manip.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
> index 7e66afd9c..e8d67c79b 100644
> --- a/lib/metadata/lv_manip.c
> +++ b/lib/metadata/lv_manip.c
> @@ -3730,8 +3730,7 @@ static struct alloc_handle *_alloc_init(struct
> cmd_context *cmd,
> } else {
> ah->log_area_count = metadata_area_count;
> ah->log_len = !metadata_area_count ? 0 :
> - _mirror_log_extents(ah->region_size, extent_size,
> - (existing_extents + new_extents) / ah->area_multiple);
> + _mirror_log_extents(ah->region_size, extent_size, existing_extents +
> new_extents);
> }
>
> if (total_extents || existing_extents)
>
_______________________________________________
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [linux-lvm] [RFC PATCH] lvconvert: fix the size of log device when converting, from linear to mirror
@ 2021-07-06 2:57 Zhong Lidong
2021-07-14 19:42 ` heming.zhao
0 siblings, 1 reply; 3+ messages in thread
From: Zhong Lidong @ 2021-07-06 2:57 UTC (permalink / raw)
To: linux-lvm; +Cc: Lidong Zhong
When converting a large linear device to mirror with --stripes parameter
in lvconvert command, it will report the following error:
ioctl/libdm-iface.c:1895 device-mapper: reload ioctl on (254:0)
failed: Invalid argument
and the related kernel messages:
kernel: [ 2290.698171] device-mapper: dirty region log: log device 254:1
too small: need 7078912 bytes
kernel: [ 2290.698248] device-mapper: table: 254:0: mirror: Error
creating mirror dirty log
kernel: [ 2290.698251] device-mapper: ioctl: error adding target to table
Steps to reproduce this problem
~$:pvs
PV VG Fmt Attr PSize PFree
/dev/loop0 vg lvm2 a-- 10.00t 10.00t
/dev/loop1 vg lvm2 a-- 10.00t 10.00t
/dev/loop2 vg lvm2 a-- 10.00t 10.00t
/dev/loop3 lvm2 --- 10.00t 10.00t
/dev/loop4 lvm2 --- 10.00t 10.00t
/dev/loop5 lvm2 --- 10.00t 10.00t
~$:lvcreate -nlv -L27T vg
Logical volume "lv" created.
~$:vgextend vg /dev/loop[3-5]
Volume group "vg" successfully extended
~$:lvconvert --type mirror --mirrors 1 --stripes 3 -I256 /dev/vg/lv
/dev/loop3 /dev/loop4 /dev/loop5
device-mapper: reload ioctl on (254:0) failed: Invalid argument
Failed to lock logical volume vg/lv.
~$: lvs
WARNING: Reading VG vg from disk because lvmetad metadata is invalid.
LV VG Attr LSize Pool Origin Data% Meta% Move Log
Cpy%Sync Convert
lv vg -wi-a----- 27.00t
lv_mlog vg -wi-a----- 4.00m
~$: pvs
PV VG Fmt Attr PSize PFree
/dev/loop0 vg lvm2 a-- 10.00t 0
/dev/loop1 vg lvm2 a-- 10.00t 0
/dev/loop2 vg lvm2 a-- 10.00t 3.00t
/dev/loop3 vg lvm2 a-- 10.00t 10.00t
/dev/loop4 vg lvm2 a-- 10.00t 10.00t
/dev/loop5 vg lvm2 a-- 10.00t 10.00t
Analysis: In kernel space the required log size depends on the whole
target device size.But in user space, the log size is calculated from
the whole target devices size divided by allocation area number, which
leads to the mismatch here.
Signed-off-by: Lidong Zhong <lidong.zhong@suse.com>
---
lib/metadata/lv_manip.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index 7e66afd9c..e8d67c79b 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -3730,8 +3730,7 @@ static struct alloc_handle *_alloc_init(struct
cmd_context *cmd,
} else {
ah->log_area_count = metadata_area_count;
ah->log_len = !metadata_area_count ? 0 :
- _mirror_log_extents(ah->region_size, extent_size,
- (existing_extents + new_extents) / ah->area_multiple);
+ _mirror_log_extents(ah->region_size, extent_size, existing_extents +
new_extents);
}
if (total_extents || existing_extents)
--
2.26.2
_______________________________________________
linux-lvm mailing list
linux-lvm@redhat.com
https://listman.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-14 19:43 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 3:20 [linux-lvm] [RFC PATCH] lvconvert: fix the size of log device when converting from linear to mirror Zhong Lidong
-- strict thread matches above, loose matches on Subject: below --
2021-07-06 2:57 [linux-lvm] [RFC PATCH] lvconvert: fix the size of log device when converting, " Zhong Lidong
2021-07-14 19:42 ` heming.zhao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).