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

Disk plugins should use the new shorter dev names #59

Closed
scottchiefbaker opened this issue Oct 14, 2023 · 10 comments
Closed

Disk plugins should use the new shorter dev names #59

scottchiefbaker opened this issue Oct 14, 2023 · 10 comments

Comments

@scottchiefbaker
Copy link
Owner

@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
Copy link
Owner Author

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

@scottchiefbaker
Copy link
Owner Author

--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
Copy link

KJ7LNW commented Oct 16, 2023

--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
Copy link

KJ7LNW commented Oct 16, 2023

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:

  • sda
  • hda
  • vda
  • xvda
  • ubda

Old things we probably won't see:

  • mfma
  • ada
  • ftla
  • nftla
  • dasda

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:

  • md0
  • dm-123 (doesn't support partitions)
  • drbd0
  • mmcblk0
  • ram0
  • zram0
  • loop0
  • scd0 (no partitions)
  • sr0 (no partitions)
  • fd0
  • nb0 (or nbd0)

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:

  • /dev/cciss/c0d0 (still used in older systems today)
  • /dev/rd/c0d0 (old, unlikely to be used)
  • /dev/ida/c0d0 (old, unlikely to be used)
  • /dev/nvme0n1 (supports partitions)

@scottchiefbaker
Copy link
Owner Author

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
Copy link
Owner Author

scottchiefbaker commented Oct 16, 2023

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
Copy link

KJ7LNW commented Oct 16, 2023

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
Copy link
Owner Author

scottchiefbaker commented Oct 16, 2023

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
Copy link

KJ7LNW commented Oct 16, 2023

  • loop0 -> lp0
  • loop25 -> lp25
  • loop0p1 -> lp01?
  • loop2p5 -> lp25?

@KJ7LNW
Copy link

KJ7LNW commented Oct 16, 2023

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

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

No branches or pull requests

2 participants