scottchiefbaker / dool

Python3 compatible fork of dstat
GNU General Public License v3.0
312 stars 58 forks source link

Disk plugins should use the new shorter dev names #59

Open scottchiefbaker opened 8 months ago

scottchiefbaker commented 8 months ago

@KJ7LNW I'm starting a new issue here and roping you in to help me test and design.

NVME drives are the "new hotness" now and Linux assign them as nvmeXnY and nvmeXnYpZ. dool doesn't deal with partitions much, so we're mostly dealing with the former naming convention. This is seven letters long which is not compatible with a lot of the disk plugins that only use 4 or 5 letters for the display. I wrote up a dev_short_name() to shorten the names while maintaining readability.

Sample output: Raw Shorter
sda1 sda1
hda14 hd14
vda99 vd99
hdb hdb
nvme0n1 nv01
nvme1n1 nv11
md123 m123
md124 m124
md125 m125
mmcblk7p50 m750
VxVM4 VxV4
dm-5 dm-5

Should everything move over to this new shorter naming? Only certain plugins that need it? I don't have a good answer yet, so I'm opening this up for discussion. Some previous discussion has taken place on #53.

FWIW if you're using to seeing sda, vdc, hda (anything less than four letters) nothing should change for you.

scottchiefbaker commented 8 months ago

I believe --disk-util is a good case for moving to the new naming scheme. I made the change in 2c6b629

scottchiefbaker commented 8 months ago

--disk is probably the most used disk related tool and while it doesn't need shorter names (it has seven characters available) I think we should move it over to be consistent with other plugins. I made this change in c04672a

KJ7LNW commented 8 months ago

--disk is probably the most used disk related tool and while it doesn't need shorter names (it has seven characters available) I think we should move it over to be consistent with other plugins. I made this change in c04672a

Yes and no: You might consider passing an "available length" option to the dev_short_name function so it can scale as appropriate. If you have the space for the whole name, by all means, keep it. (See below about the dm-X devices, would be nice to keep their names).

Here are a few comments.

Raw Shorter sda1 sda1

If you have more than 26 sd's, then it will wrap to sdaa and go up to at least sdzz. I've wrapped disk counts quite a few times into the 2-digit sdXY names.

This is just my opinion, but people shouldn't monitor partitions: they should monitor the disk itself because congestion happens at the disk level not at the partition level...but there may be applications where they want to know usage and aren't interested in congestion.

hda14 hd14 hdb hdb

If you have to give something up for space in the name, drop the partition number because the "a" in "hda" is more uniquely identifying (otherwise hdb14 and hda14 would collide as hd14). So, keep "hda" for sure, because it specifies the device. Drop the "14" as necessary, or maybe keep it if you have the room.

FWIW, I don't think hdX is used any more. Even (rarely used) PATA drives use libata in modern kernels, which produces /dev/sda names...but it can't hurt to keep hdXY along with sdXY.

vda99 vd99

Again, the "a" is more critical than the "99". If you have more than 26 vd's, then it will wrap to vdaa.

nb: sd, hd, and vd should all be treated the same way.

nvme0n1 nv01 nvme1n1 nv11

fine

md123 m123 md124 m124 md125 m125

would be nice to keep "md" if possible, so "md0" through "md99" before jumping to "m100". You might need to trim back to m127 for auto-detected md127 arrays, but md0 is a much better name than m0 if you have the room (and usually sysadmins specify a small mdX number when defining an array administratively).

mmcblk7p50 m750

There aren't usually many mmc devices attached to a host. The most I've seen is 1 or 2, so "mmc1" would be good. Have you really seen an mmc device with 50 partitions? People should really be using LVM!

VxVM4 VxV4

Not familiar with this device, so name is fine for me.

dm-5 dm-5

The number of dm devices can get really big. Drop the hyphen, keep as much of the number as you can. (For example, we have a system with "/dev/dm-176", but we don't monitor it.)

There is one special thing about dm devices: they are named, and the name can be looked up in /dev/mapper/ . For example, if I specify /dev/mapper/data-pool0 then it may remap to dm-123, but it would be really nice to have the original dm name listed in the disk column. This is really long, of course, so maybe this isn't feasible, but when I (rarely) specify a full DM path in -D, I could live with wider columns if I can get the whole name instead of wondering what dm-27 means.

loop0

Loop devices are common, maybe name them as lp0 or loop0 if you have the room?

KJ7LNW commented 8 months ago

It occurs to me that with the exception of nvme, disk device names are enumerated in two different ways: base26 and base10. This devices.txt link documents all the naming conventions. For this discussion, only "block" devices matter, not "char" devices: https://github.com/torvalds/linux/blob/master/Documentation/admin-guide/devices.txt

Here is a summary of the most common device names and enumeration formats:

Base26 Enumerated Devices

These devices enumerate as <name>XY where X and Y are lowercase letters a-z. Partitions are supported by appending a base-10 partition number to the end (like sda3 or even sdzz3):

Common examples:

Old things we probably won't see:

Base10 Enumerated Devices

These devices enumerate as <name>X where X is an integer. Partitions are supported by appending pY to the end (like mmcblk0p5 or md0p6 or loop1p3).

These examples are all commonly used today, and most support the pY partition suffix:

Two-digit Base10 Enumerated Devices

There are a few 2-digit representations, the most notable being nvmeXnY.

There are a few others with cXdY where cX is the controller number and dY is the disk number. These may also support a pZ suffix for partitions, and very few are still in use today:

scottchiefbaker commented 8 months ago

I just want to say: wow! Thank you for the highly detailed research and write up. This is super helpful as we move forward with designing dool for the future. I appreciate the time and effort you put in to this.

scottchiefbaker commented 8 months ago

So that it's written down somewhere...

The way the name shortening works is that we look for: letters, numbers, and then a second group of numbers. The short name is built by combining the first group of numbers with the second (if there are any) and then prepending letters to the beginning to fill out to the character limit. We default to four characters because most plugins use four character columns, but it is configurable to any length.

If the name is less than the character limit there is no change. This is the vast majority of device names. Because 95% of what dool deals with is raw devices (not partitions) so there is almost no change for most of the use cases. sda or vdb (or even sdaa) will not change, it's only the LONG names that are affected.

As an example for vda15 we get vda and 15 and no second number. We start with the 15 and then prepend two characters from the letters to get vd15. You only lose fidelity if you're digits are greater than 9. I'm thinking a disk with 9+ partitions is pretty uncommon. Also, as you mention, you really should be monitoring your whole disk, and not a specific partition.

For nvme drives we start with nvme0n1 which gets broken out to nvme 0 and 1. The numbers get concatenated to 01 and then letters are prepended to get the desired length which results in nv01. If we were doing five chars it would be nvm01, or n01 if we were doing three characters.

I do like your explanation of loop devices. It would be pretty easy to add an exception for loop devices to just always use lp + number. Currently if you had a loop10 that would get shortened to lo10 which probably isn't as descriptive? Maybe it doesn't matter thought because you need a lot of loop devices before it becomes an issue..

KJ7LNW commented 8 months ago

I do like your explanation of loop devices. It would be pretty easy to add an exception for loop devices to just always use lp + number. Currently if you had a loop10 that would get shortened to lo10 which probably isn't as descriptive? Maybe it doesn't matter thought because you need a lot of loop devices before it becomes an issue..

I think "lpXX" is good for all loops, too.

scottchiefbaker commented 8 months ago

Assuming four char naming... do we shorten loop8 to lp8 or lp08? What about loop25? Do people really have 9+ loopback devices that this is REALLY an issue for dool or are we designing around corner case stuff?

KJ7LNW commented 8 months ago
KJ7LNW commented 8 months ago

If you need the 4-char pad, then lp0 can become lp00 and who knows about partitions.