Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate LVs returned from bd_lvm_lvs() #667

Closed
wfpudak opened this issue Oct 29, 2021 · 6 comments
Closed

Duplicate LVs returned from bd_lvm_lvs() #667

wfpudak opened this issue Oct 29, 2021 · 6 comments
Assignees
Labels

Comments

@wfpudak
Copy link

wfpudak commented Oct 29, 2021

Hi,

We've noticed that if an LV has several segments as noted by lvdisplay

--- Logical volume ---
LV Path /dev/rootvg/test
LV Name test
VG Name rootvg
LV UUID TgjM5V-jhXX-tPTf-gPMa-c3w6-QEjo-7qkmVg
LV Write Access read/write
LV Creation host, time du1, 2021-10-25 15:59:20 +0000
LV Status available
"#" open 1
LV Size 68.00 MiB
Current LE 68
Segments 2
Allocation inherit
Read ahead sectors 1024
Block device 253:166

the API method bd_lvm_lvs() will return several entries since segtype is used with the -o option.

It can easily be reproduced with the lvs command itself as well. This happens due to fragmentation as described in : https://askubuntu.com/questions/380424/understanding-output-of-lvdisplay-in-lvm-linux

Is the expectation from bd_lvm_lvs() to return those duplicates or shouldn't the lib code filter them out?

Example lvs output with your flags if there are several segments :

LVM2_VG_NAME=rootvg LVM2_LV_NAME=test LVM2_LV_UUID=TgjM5V-jhXX-tPTf-gPMa-c3w6-QEjo-7qkmVg LVM2_LV_SIZE=71303168 LVM2_LV_ATTR=-wi-ao---- LVM2_SEGTYPE=linear LVM2_ORIGIN= LVM2_POOL_LV= LVM2_DATA_LV= LVM2_METADATA_LV= LVM2_LV_ROLE=public LVM2_MOVE_PV= LVM2_DATA_PERCENT= LVM2_METADATA_PERCENT= LVM2_COPY_PERCENT= LVM2_LV_TAGS=
LVM2_VG_NAME=rootvg LVM2_LV_NAME=test LVM2_LV_UUID=TgjM5V-jhXX-tPTf-gPMa-c3w6-QEjo-7qkmVg LVM2_LV_SIZE=71303168 LVM2_LV_ATTR=-wi-ao---- LVM2_SEGTYPE=linear LVM2_ORIGIN= LVM2_POOL_LV= LVM2_DATA_LV= LVM2_METADATA_LV= LVM2_LV_ROLE=public LVM2_MOVE_PV= LVM2_DATA_PERCENT= LVM2_METADATA_PERCENT= LVM2_COPY_PERCENT= LVM2_LV_TAGS=
LVM2_VG_NAME=rootvg LVM2_LV_NAME=new_test LVM2_LV_UUID=jMUqLN-DVYU-RUtV-0TnH-Qczq-L820-Bf2G00 LVM2_LV_SIZE=2097152 LVM2_LV_ATTR=-wi-a----- LVM2_SEGTYPE=linear LVM2_ORIGIN= LVM2_POOL_LV= LVM2_DATA_LV= LVM2_METADATA_LV= LVM2_LV_ROLE=public LVM2_MOVE_PV= LVM2_DATA_PERCENT= LVM2_METADATA_PERCENT= LVM2_COPY_PERCENT= LVM2_LV_TAGS=

@vojtechtrefny
Copy link
Member

Is the expectation from bd_lvm_lvs() to return those duplicates or shouldn't the lib code filter them out?

We should definitely not return the LV twice. We might add a function to display the segments in the future, but bd_lvm_lvs should filter this out from the lvs output.

Note to myself: This can be reproduced simply by creating two linear LVs and resizing the first one to create the two segments.

@vojtechtrefny vojtechtrefny self-assigned this Nov 1, 2021
@wfpudak
Copy link
Author

wfpudak commented Nov 1, 2021

Thanks @vojtechtrefny. Locally the workaround was to use lv_layout instead of segtype.
segtype_to_lv_lay.diff.zip

@vojtechtrefny
Copy link
Member

Unfortunately lv_layout produces different results for non-linear logical volumes, for example thin,sparse instead of thin for thin LVs or thin,pool instead of thin-pool for thin pools so it isn't 1:1 replacement (and we have users that use the strings so we can't change them). I've created #671 as a workaround, that should be good enough for the stable libblockdev, but I think we need some API changes for BDLVMLVdata in 3.0, the segtype attribute doesn't really make sense.

@wfpudak
Copy link
Author

wfpudak commented Nov 16, 2021

Hi @vojtechtrefny ,

Thanks for the explanation we will test your proposed solution.

I noticed some failures on the CI runs for #671. I guess that you plan to merge it but a retrigger/rerun is needed?

Cheers,
/Filip

@vojtechtrefny
Copy link
Member

The failed test_lvremove_extra_args case is addressed in #672

kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Dec 8, 2021
We use "-o segtypes" for the "lvs" command which means multisegment
LVs will be twice in the output. [1]
...
$ lvs --noheadings --nosuffix --nameprefixes --unquoted --units=b -a -o
vg_name,lv_name,lv_uuid,lv_size,lv_attr,segtype,origin,pool_lv,data_lv,metadata_lv,role,move_pv,data_percent,metadata_percent,copy_percent,lv_tags

OUTPUT:
|LVM2_VG_NAME=rootvg LVM2_LV_NAME=RCSMW-ARM_CXP2020233_2_R20A154
LVM2_LV_UUID=TgjM5V-jhXX-tPTf-gPMa-c3w6-QEjo-7qkmVg
LVM2_LV_SIZE=71303168 LVM2_LV_ATTR=wi-ao--- LVM2_SEGTYPE=linear
LVM2_ORIGIN= LVM2_POOL_LV= LVM2_DATA_LV= LVM2_METADATA_LV=
LVM2_LV_ROLE=public LVM2_MOVE_PV= LVM2_DATA_PERCENT=
LVM2_METADATA_PERCENT= LVM2_COPY_PERCENT= LVM2_LV_TAGS=

|LVM2_VG_NAME=rootvg LVM2_LV_NAME=RCSMW-ARM_CXP2020233_2_R20A154
LVM2_LV_UUID=TgjM5V-jhXX-tPTf-gPMa-c3w6-QEjo-7qkmVg
LVM2_LV_SIZE=71303168 LVM2_LV_ATTR=wi-ao--- LVM2_SEGTYPE=linear
LVM2_ORIGIN= LVM2_POOL_LV= LVM2_DATA_LV= LVM2_METADATA_LV=
LVM2_LV_ROLE=public LVM2_MOVE_PV= LVM2_DATA_PERCENT=
LVM2_METADATA_PERCENT= LVM2_COPY_PERCENT= LVM2_LV_TAGS=
...

See [2]

[1] storaged-project/libblockdev#671
[2] storaged-project/libblockdev#667

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Dec 8, 2021
We use "-o segtypes" for the "lvs" command which means multisegment
LVs will be twice in the output. [1]
...
$ lvs --noheadings --nosuffix --nameprefixes --unquoted --units=b -a -o
vg_name,lv_name,lv_uuid,lv_size,lv_attr,segtype,origin,pool_lv,data_lv,metadata_lv,role,move_pv,data_percent,metadata_percent,copy_percent,lv_tags

OUTPUT:
|LVM2_VG_NAME=rootvg LVM2_LV_NAME=RCSMW-ARM_CXP2020233_2_R20A154
LVM2_LV_UUID=TgjM5V-jhXX-tPTf-gPMa-c3w6-QEjo-7qkmVg
LVM2_LV_SIZE=71303168 LVM2_LV_ATTR=wi-ao--- LVM2_SEGTYPE=linear
LVM2_ORIGIN= LVM2_POOL_LV= LVM2_DATA_LV= LVM2_METADATA_LV=
LVM2_LV_ROLE=public LVM2_MOVE_PV= LVM2_DATA_PERCENT=
LVM2_METADATA_PERCENT= LVM2_COPY_PERCENT= LVM2_LV_TAGS=

|LVM2_VG_NAME=rootvg LVM2_LV_NAME=RCSMW-ARM_CXP2020233_2_R20A154
LVM2_LV_UUID=TgjM5V-jhXX-tPTf-gPMa-c3w6-QEjo-7qkmVg
LVM2_LV_SIZE=71303168 LVM2_LV_ATTR=wi-ao--- LVM2_SEGTYPE=linear
LVM2_ORIGIN= LVM2_POOL_LV= LVM2_DATA_LV= LVM2_METADATA_LV=
LVM2_LV_ROLE=public LVM2_MOVE_PV= LVM2_DATA_PERCENT=
LVM2_METADATA_PERCENT= LVM2_COPY_PERCENT= LVM2_LV_TAGS=
...

See [2]

[1] storaged-project/libblockdev#671
[2] storaged-project/libblockdev#667

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Dec 8, 2021
We use "-o segtypes" for the "lvs" command which means multisegment
LVs will be twice in the output. [1]
...
$ lvs --noheadings --nosuffix --nameprefixes --unquoted --units=b -a -o
vg_name,lv_name,lv_uuid,lv_size,lv_attr,segtype,origin,pool_lv,data_lv,metadata_lv,role,move_pv,data_percent,metadata_percent,copy_percent,lv_tags

OUTPUT:
|LVM2_VG_NAME=rootvg LVM2_LV_NAME=RCSMW-ARM_CXP2020233_2_R20A154
LVM2_LV_UUID=TgjM5V-jhXX-tPTf-gPMa-c3w6-QEjo-7qkmVg
LVM2_LV_SIZE=71303168 LVM2_LV_ATTR=wi-ao--- LVM2_SEGTYPE=linear
LVM2_ORIGIN= LVM2_POOL_LV= LVM2_DATA_LV= LVM2_METADATA_LV=
LVM2_LV_ROLE=public LVM2_MOVE_PV= LVM2_DATA_PERCENT=
LVM2_METADATA_PERCENT= LVM2_COPY_PERCENT= LVM2_LV_TAGS=

|LVM2_VG_NAME=rootvg LVM2_LV_NAME=RCSMW-ARM_CXP2020233_2_R20A154
LVM2_LV_UUID=TgjM5V-jhXX-tPTf-gPMa-c3w6-QEjo-7qkmVg
LVM2_LV_SIZE=71303168 LVM2_LV_ATTR=wi-ao--- LVM2_SEGTYPE=linear
LVM2_ORIGIN= LVM2_POOL_LV= LVM2_DATA_LV= LVM2_METADATA_LV=
LVM2_LV_ROLE=public LVM2_MOVE_PV= LVM2_DATA_PERCENT=
LVM2_METADATA_PERCENT= LVM2_COPY_PERCENT= LVM2_LV_TAGS=
...

See [2]

[1] storaged-project/libblockdev#671
[2] storaged-project/libblockdev#667

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Dec 8, 2021
We use "-o segtypes" for the "lvs" command which means multisegment
LVs will be twice in the output. [1]
...
$ lvs --noheadings --nosuffix --nameprefixes --unquoted --units=b -a -o
vg_name,lv_name,lv_uuid,lv_size,lv_attr,segtype,origin,pool_lv,data_lv,metadata_lv,role,move_pv,data_percent,metadata_percent,copy_percent,lv_tags

OUTPUT:
|LVM2_VG_NAME=rootvg LVM2_LV_NAME=RCSMW-ARM_CXP2020233_2_R20A154
LVM2_LV_UUID=TgjM5V-jhXX-tPTf-gPMa-c3w6-QEjo-7qkmVg
LVM2_LV_SIZE=71303168 LVM2_LV_ATTR=wi-ao--- LVM2_SEGTYPE=linear
LVM2_ORIGIN= LVM2_POOL_LV= LVM2_DATA_LV= LVM2_METADATA_LV=
LVM2_LV_ROLE=public LVM2_MOVE_PV= LVM2_DATA_PERCENT=
LVM2_METADATA_PERCENT= LVM2_COPY_PERCENT= LVM2_LV_TAGS=

|LVM2_VG_NAME=rootvg LVM2_LV_NAME=RCSMW-ARM_CXP2020233_2_R20A154
LVM2_LV_UUID=TgjM5V-jhXX-tPTf-gPMa-c3w6-QEjo-7qkmVg
LVM2_LV_SIZE=71303168 LVM2_LV_ATTR=wi-ao--- LVM2_SEGTYPE=linear
LVM2_ORIGIN= LVM2_POOL_LV= LVM2_DATA_LV= LVM2_METADATA_LV=
LVM2_LV_ROLE=public LVM2_MOVE_PV= LVM2_DATA_PERCENT=
LVM2_METADATA_PERCENT= LVM2_COPY_PERCENT= LVM2_LV_TAGS=
...

See [2]

[1] storaged-project/libblockdev#671
[2] storaged-project/libblockdev#667

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Dec 9, 2021
We use "-o segtypes" for the "lvs" command which means multisegment
LVs will be twice in the output. [1]
...
$ lvs --noheadings --nosuffix --nameprefixes --unquoted --units=b -a -o
vg_name,lv_name,lv_uuid,lv_size,lv_attr,segtype,origin,pool_lv,data_lv,metadata_lv,role,move_pv,data_percent,metadata_percent,copy_percent,lv_tags

OUTPUT:
|LVM2_VG_NAME=rootvg LVM2_LV_NAME=RCSMW-ARM_CXP2020233_2_R20A154
LVM2_LV_UUID=TgjM5V-jhXX-tPTf-gPMa-c3w6-QEjo-7qkmVg
LVM2_LV_SIZE=71303168 LVM2_LV_ATTR=wi-ao--- LVM2_SEGTYPE=linear
LVM2_ORIGIN= LVM2_POOL_LV= LVM2_DATA_LV= LVM2_METADATA_LV=
LVM2_LV_ROLE=public LVM2_MOVE_PV= LVM2_DATA_PERCENT=
LVM2_METADATA_PERCENT= LVM2_COPY_PERCENT= LVM2_LV_TAGS=

|LVM2_VG_NAME=rootvg LVM2_LV_NAME=RCSMW-ARM_CXP2020233_2_R20A154
LVM2_LV_UUID=TgjM5V-jhXX-tPTf-gPMa-c3w6-QEjo-7qkmVg
LVM2_LV_SIZE=71303168 LVM2_LV_ATTR=wi-ao--- LVM2_SEGTYPE=linear
LVM2_ORIGIN= LVM2_POOL_LV= LVM2_DATA_LV= LVM2_METADATA_LV=
LVM2_LV_ROLE=public LVM2_MOVE_PV= LVM2_DATA_PERCENT=
LVM2_METADATA_PERCENT= LVM2_COPY_PERCENT= LVM2_LV_TAGS=
...

See [2]

[1] storaged-project/libblockdev#671
[2] storaged-project/libblockdev#667

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
@vojtechtrefny
Copy link
Member

Closed via #671

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants