Re: [linux-lvm] [PATCH] lvs: add -o lv_usable

2020-09-08 Thread David Teigland
On Tue, Sep 08, 2020 at 02:40:43PM +0800, heming.zhao wrote:
> Does it acceptable to add new status bit in lv->status?
> I ever sent it in previoud patch "[PATCH v2] lib/metadata: add new api 
> lv_is_available()"
> The define as below (the 'NOT_AVAIL_LV' will change to 'NOT_USABLE_LV'):
> ```
> +#define NOT_AVAIL_LV UINT64_C(0x8000)/* LV - derived flag, 
> not
> +written out in 
> metadata*/
> 
> +#define lv_is_available(lv)  (((lv)->status & NOT_AVAIL_LV) ? 0 : 1)
> ```
> 
> some description about the new patch:
> - it will combine with two patches:
>   - [PATCH v2] lib/metadata: add new api lv_is_available()
>   - [PATCH] lvs: add -o lv_usable
> - the new patch will add new status bit NOT_USABLE_LV, and this bit will be
>   set in _lv_mark_if_partial_single().
> - The only output which related with new status bit: lvs -o lv_usable
> 
> if above is acceptable, I will send the v2 patch. if not, I will give up this 
> 'lv_usable' patch.

That sounds better, the old patch was closer to what we need.  It can look
at the PVs listed for the LV in the metadata, and check if those PVs have
a device on the system (pv->dev is set) and are not flagged missing.
device mapper state would not be needed for that (lv_mapping_table
dm_has_lvdev functions are not needed.)

To report info about the active state of LVs is more complex and requires
different sort of code as Zdenek mentioned.

Dave

___
linux-lvm mailing list
linux-lvm@redhat.com
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/



Re: [linux-lvm] [PATCH] lvs: add -o lv_usable

2020-09-08 Thread heming.zhao

On 9/7/20 10:32 PM, Zdenek Kabelac wrote:

Dne 05. 09. 20 v 11:08 heming.z...@suse.com napsal(a):



On 9/5/20 5:06 PM, Zhao Heming wrote:

report LV is usable for upper layer.

Signed-off-by: Zhao Heming 
---
   lib/activate/activate.h  |   2 +
   lib/activate/dev_manager.c   |  67 
   lib/metadata/metadata-exported.h |   1 +
   lib/metadata/metadata.c  | 130 +++
   lib/report/columns.h |   1 +
   lib/report/properties.c  |   2 +
   lib/report/report.c  |  13 
   lib/report/values.h  |   1 +
   8 files changed, 217 insertions(+)



my test result:

## linear



Hi

We will need to take closer look  - the patchset itself is not going in right 
direction - since all the info about missing or present devices is already
available within lvm engine and we want to minimize 'repeated' query
(ideally all the information should be checked only once - otherwise
the decision state-machine is producing random-end result garbage - which
is the very hard to trace and debug.

So all the code which is doing runtime query again can't be accepted.

Next main rule is - we cache status values whenever possible - so there
should be at most  1 'status' per device per LV - but since lvm2 already
knows from scanning point and from metadata parsing which device is missing
the logic of evaluation of LV's usability needs to be based on these values.

But I think we also need some per-segment methods evaluating usability.

Regards

Zdenek



Hello Zdenek,

Thank you for your review comments, I got your meaning.

Does it acceptable to add new status bit in lv->status?
I ever sent it in previoud patch "[PATCH v2] lib/metadata: add new api 
lv_is_available()"
The define as below (the 'NOT_AVAIL_LV' will change to 'NOT_USABLE_LV'):
```
+#define NOT_AVAIL_LV   UINT64_C(0x8000)/* LV - derived flag, 
not
+  written out in 
metadata*/

+#define lv_is_available(lv)(((lv)->status & NOT_AVAIL_LV) ? 0 : 1)
```

some description about the new patch:
- it will combine with two patches:
  - [PATCH v2] lib/metadata: add new api lv_is_available()
  - [PATCH] lvs: add -o lv_usable
- the new patch will add new status bit NOT_USABLE_LV, and this bit will be
  set in _lv_mark_if_partial_single().
- The only output which related with new status bit: lvs -o lv_usable

if above is acceptable, I will send the v2 patch. if not, I will give up this 
'lv_usable' patch.

Thanks


___
linux-lvm mailing list
linux-lvm@redhat.com
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/

Re: [linux-lvm] [PATCH] lvs: add -o lv_usable

2020-09-07 Thread Zdenek Kabelac

Dne 05. 09. 20 v 11:08 heming.z...@suse.com napsal(a):



On 9/5/20 5:06 PM, Zhao Heming wrote:

report LV is usable for upper layer.

Signed-off-by: Zhao Heming 
---
   lib/activate/activate.h  |   2 +
   lib/activate/dev_manager.c   |  67 
   lib/metadata/metadata-exported.h |   1 +
   lib/metadata/metadata.c  | 130 +++
   lib/report/columns.h |   1 +
   lib/report/properties.c  |   2 +
   lib/report/report.c  |  13 
   lib/report/values.h  |   1 +
   8 files changed, 217 insertions(+)



my test result:

## linear



Hi

We will need to take closer look  - the patchset itself is not going in right 
direction - since all the info about missing or present devices is already

available within lvm engine and we want to minimize 'repeated' query
(ideally all the information should be checked only once - otherwise
the decision state-machine is producing random-end result garbage - which
is the very hard to trace and debug.

So all the code which is doing runtime query again can't be accepted.

Next main rule is - we cache status values whenever possible - so there
should be at most  1 'status' per device per LV - but since lvm2 already
knows from scanning point and from metadata parsing which device is missing
the logic of evaluation of LV's usability needs to be based on these values.

But I think we also need some per-segment methods evaluating usability.

Regards

Zdenek

___
linux-lvm mailing list
linux-lvm@redhat.com
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/



Re: [linux-lvm] [PATCH] lvs: add -o lv_usable

2020-09-07 Thread heming.z...@suse.com


On 9/5/20 5:06 PM, Zhao Heming wrote:
> report LV is usable for upper layer.
> 
> Signed-off-by: Zhao Heming 
> ---
>   lib/activate/activate.h  |   2 +
>   lib/activate/dev_manager.c   |  67 
>   lib/metadata/metadata-exported.h |   1 +
>   lib/metadata/metadata.c  | 130 +++
>   lib/report/columns.h |   1 +
>   lib/report/properties.c  |   2 +
>   lib/report/report.c  |  13 
>   lib/report/values.h  |   1 +
>   8 files changed, 217 insertions(+)
> 

my test result:

## linear

[tb-clustermd2 lvm2.sourceware.git]# vgcreate vg1 /dev/sdg /dev/sdi
  Physical volume "/dev/sdg" successfully created.
  Physical volume "/dev/sdi" successfully created.
  Volume group "vg1" successfully created
[tb-clustermd2 lvm2.sourceware.git]# lvcreate -l 100%FREE -n lv1 vg1
  Logical volume "lv1" created.
[tb-clustermd2 lvm2.sourceware.git]# lsblk
NAME  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdg 8:96   0  100M  0 disk
└─vg1-lv1 254:00  192M  0 lvm
sdi 8:128  0  100M  0 disk
└─vg1-lv1 254:00  192M  0 lvm
vda   253:00   40G  0 disk
├─vda1253:108M  0 part
├─vda2253:20   38G  0 part /
└─vda3253:302G  0 part [SWAP]

-- remove one disk ---

[tb-clustermd2 lvm2.sourceware.git]# lsblk
NAME  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdg 8:96   0  100M  0 disk
└─vg1-lv1 254:00  192M  0 lvm
vda   253:00   40G  0 disk
├─vda1253:108M  0 part
├─vda2253:20   38G  0 part /
└─vda3253:302G  0 part [SWAP]
[tb-clustermd2 lvm2.sourceware.git]# ./tools/lvm lvs -a -o 
name,devices,lv_usable,lv_health_status
  WARNING: Couldn't find device with uuid 
zOsVRm-ojxU-ZbfR-cLcT-MhxR-pfMh-eVfC42.
  WARNING: VG vg1 is missing PV zOsVRm-ojxU-ZbfR-cLcT-MhxR-pfMh-eVfC42 (last 
written to /dev/sdi).
  LV   Devices  Usable  Health
  lv1  /dev/sdg(0)  not usable  partial
  lv1  [unknown](0) not usable  partial
[tb-clustermd2 lvm2.sourceware.git]# ./tools/lvm lvs -o 
name,devices,lv_usable,lv_health_status
  WARNING: Couldn't find device with uuid 
zOsVRm-ojxU-ZbfR-cLcT-MhxR-pfMh-eVfC42.
  WARNING: VG vg1 is missing PV zOsVRm-ojxU-ZbfR-cLcT-MhxR-pfMh-eVfC42 (last 
written to /dev/sdi).
  LV   Devices  Usable  Health
  lv1  /dev/sdg(0)  not usable  partial
  lv1  [unknown](0) not usable  partial

- re-insert disk, but disk major:minor changed -

[tb-clustermd2 lvm2.sourceware.git]# lsblk
NAME  MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdg 8:96   0  100M  0 disk
└─vg1-lv1 254:00  192M  0 lvm
sdh 8:112  0  100M  0 disk
vda   253:00   40G  0 disk
├─vda1253:108M  0 part
├─vda2253:20   38G  0 part /
└─vda3253:302G  0 part [SWAP]
[tb-clustermd2 lvm2.sourceware.git]# ./tools/lvm lvs -a -o 
name,devices,lv_usable,lv_health_status
  LV   Devices Usable  Health
  lv1  /dev/sdg(0) not usable
  lv1  /dev/sdh(0) not usable
[tb-clustermd2 lvm2.sourceware.git]# ./tools/lvm lvs -o 
name,devices,lv_usable,lv_health_status
  LV   Devices Usable  Health
  lv1  /dev/sdg(0) not usable
  lv1  /dev/sdh(0) not usable

## mirror

[tb-clustermd2 lvm2.sourceware.git]# lvcreate --type mirror -l 100%FREE -n 
mirrorlv vg1
  Logical volume "mirrorlv" created.
[tb-clustermd2 lvm2.sourceware.git]# lsblk
NAMEMAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sdg   8:96   0  100M  0 disk
└─vg1-mirrorlv_mimage_0 254:10   92M  0 lvm
  └─vg1-mirrorlv254:30   92M  0 lvm
sdh   8:112  0  100M  0 disk
├─vg1-mirrorlv_mlog 254:004M  0 lvm
│ └─vg1-mirrorlv254:30   92M  0 lvm
└─vg1-mirrorlv_mimage_1 254:20   92M  0 lvm
  └─vg1-mirrorlv254:30   92M  0 lvm
vda 253:00   40G  0 disk
├─vda1  253:108M  0 part
├─vda2  253:20   38G  0 part /
└─vda3  253:302G  0 part [SWAP]
[tb-clustermd2 lvm2.sourceware.git]# ./tools/lvm lvs -a -o 
name,devices,lv_usable,lv_health_status
  LV  Devices   Usable  
Health
  mirrorlvmirrorlv_mimage_0(0),mirrorlv_mimage_1(0) usable
  [mirrorlv_mimage_0] /dev/sdg(0)   usable
  [mirrorlv_mimage_1] /dev/sdh(0)   usable
  [mirrorlv_mlog] /dev/sdh(23)  usable
[tb-clustermd2 lvm2.sourceware.git]# ./tools/lvm lvs -o 
name,devices,lv_usable,lv_health_status
  LV   Devices   Usable  Health
  mirrorlv mirrorlv_mimage_0(0),mirrorlv_mimage_1(0) usable

 removed one disk -

[tb-clustermd2 lvm2.sourceware.git]# ./tools/lvm lvs -a -o 
name,devices,lv_usable,lv_health_status
  WARNING: Couldn't find device with uuid 

Re: [linux-lvm] [PATCH] lvs: add -o lv_usable

2020-09-05 Thread heming.z...@suse.com



On 9/5/20 5:06 PM, Zhao Heming wrote:
> report LV is usable for upper layer.
> 
> Signed-off-by: Zhao Heming 
> ---
>   lib/activate/activate.h  |   2 +
>   lib/activate/dev_manager.c   |  67 
>   lib/metadata/metadata-exported.h |   1 +
>   lib/metadata/metadata.c  | 130 +++
>   lib/report/columns.h |   1 +
>   lib/report/properties.c  |   2 +
>   lib/report/report.c  |  13 
>   lib/report/values.h  |   1 +
>   8 files changed, 217 insertions(+)
> 

There are some places need to improve.

1. in lib/activate/dev_manager.c, function lv_mapping_table() & dm_has_lvdev() 
almost same.
   it may merge into one function.

2. LV device-mapper name need to improve, 

  in lib/metadata/metadata.c  _lv_is_usable()
  I use below ugly code to construct dm name

  ```
  /* format is right: "vgname" + '-' + "lvname" ?? */
  snprintf(lvname, 50, "%s-%s", lv->vg->name, seg_lv(seg, s)->name);
  ... ...
  /* format is right: "vgname" + '-' + "lvname" ?? */
  snprintf(lvname, 50, "%s-%s", lv->vg->name, lv->name);
  ```


Thanks

___
linux-lvm mailing list
linux-lvm@redhat.com
https://www.redhat.com/mailman/listinfo/linux-lvm
read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/