Open elonen opened 5 years ago
Do you really want (as a human user) see the size in bytes of every volume definition? I'm asking because usually such information is only needed when automatically processing the output from the linstor-cli, in which case you can use the -m
option and in combination with jq
you should be able to get your information.
Yes, you sometimes need the information when, for example, adding manually created DRBD devices to VM definitions (at least on Proxmox, and actually in kilobytes). I'm currently using blockdev --getsize64 /dev/drbd/by-res/<something>
which works, but is a bit clunky.
But then you already have blockdev
, and more importantly -m
of linstor
.
IMO it is a good feature request, and we have a nice library for the conversions. But don't expect it very soon, there are more important things to fix.
Sure, not a very high priority.
Should be fairly easy to add, since LINSTOR stores the volume size in kiB internally. We could optionally add a few switches to control the SI unit that would be used for reporting, so that output could be in bytes or kiB, maybe also in MiB/GiB/etc., but since those greater magnitude units may require rounding, this may only be useful in combination with certain switches to control how the software reports exact numbers vs. rounded numbers and how the numbers are rounded.
Note that linstor -m vd l
returns the requested size in KiB, which may be less than the actual device size:
root@node1:~# linstor -m vd l | grep size
"vlm_size": 1048576,
root@node1:~# echo $(( 1048576*1024 ))
1073741824
root@node1:~# blockdev --getsize64 /dev/drbd1000
1077665792
I presume this is because an extra LVM extent (4MiB) is allocated for DRBD metadata, but only part of it is used for that purpose, and the rest is returned to the user.
That size states the usable size. If you are interested in more details, please see linstor -m --output-version v1 v l
.
This means we've moved from looking at volume-definition to volume, which is fair enough.
However, it looks like there's another problem here. The size I get from blockdev --getsize64
is 1052408 KiB; this does not match any of the values returned by linstor -m --output-version v1 v l
, and in particular none of the "usable" values.
root@node1:~# echo $(( 1052408 * 1024 ))
1077665792
root@node1:~# blockdev --getsize64 /dev/drbd1000
1077665792
root@node1:~# linstor -m --output-version v1 v l | egrep '\b1[0-9]{6}\b' | sort -u
"allocated_size_kib": 1052672,
"usable_size_kib": 1048576
"usable_size_kib": 1052672,
"allocated_size_kib": 1048840,
"allocated_size_kib": 1052672,
"usable_size_kib": 1048576
"usable_size_kib": 1052672,
"allocated_size_kib": 1048840,
"usable_size_kib": 1048576
"allocated_size_kib": 1052672,
However, the usable volume size (to match blockdev
) would be the allocated size (1028MiB) less the DRBD metadata size (264KiB) - and this doesn't appear anywhere in the output.
root@node1:~# echo $(( 1028*1024 - 264 ))
1052408
Here is one volume in detail:
{
"name": "my_ssd_res",
"node_name": "node3",
"props": {
"StorPoolName": "pool_ssd"
},
"layer_object": {
"children": [
{
"type": "STORAGE",
"storage": {
"storage_volumes": [
{
"volume_number": 0,
"device_path": "/dev/vg_ssd/my_ssd_res_00000",
"allocated_size_kib": 1052672,
"usable_size_kib": 1052672,
"disk_state": "[]"
}
]
}
}
],
"type": "DRBD",
"drbd": {
...
"drbd_volumes": [
{
"drbd_volume_definition": {
"volume_number": 0,
"minor_number": 1000
},
"device_path": "/dev/drbd1000",
"backing_device": "/dev/vg_ssd/my_ssd_res_00000",
"allocated_size_kib": 1048840,
"usable_size_kib": 1048576
}
],
"volumes": [
{
"volume_number": 0,
"storage_pool_name": "pool_ssd",
"provider_kind": "LVM",
"device_path": "/dev/drbd1000",
"allocated_size_kib": 1052672,
"state": {
"disk_state": "UpToDate"
},
"layer_data_list": [
{
"type": "DRBD",
"data": {
"drbd_volume_definition": {
"volume_number": 0,
"minor_number": 1000
},
"device_path": "/dev/drbd1000",
"backing_device": "/dev/vg_ssd/my_ssd_res_00000",
"allocated_size_kib": 1048840,
"usable_size_kib": 1048576
}
},
{
"type": "STORAGE",
"data": {
"volume_number": 0,
"device_path": "/dev/vg_ssd/my_ssd_res_00000",
"allocated_size_kib": 1052672,
"usable_size_kib": 1052672,
"disk_state": "[]"
}
}
],
The
linstor vd list
command shows volume sizes in human friendly format. Sometimes it's necessary to know the exact size. An option to set change unit for size listing would be nice.