Date: Fri, 20 Jun 2025 14:39:34 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 287679] md(4) assigns non-unique GEOM::ident to vnode-based disks Message-ID: <bug-287679-227@https.bugs.freebsd.org/bugzilla/>
index | next in thread | raw e-mail
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=287679 Bug ID: 287679 Summary: md(4) assigns non-unique GEOM::ident to vnode-based disks Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Many People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: phil@krylov.eu CC: trasz@FreeBSD.org Created attachment 261438 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=261438&action=edit Minimal but changes struct layout with unknown impact In review D12230, support for GEOM::ident was added to vnode-backed md(4) devices. The message is saying, "This is useful for gmountver(8) regression tests." At first, the identifier was generated as random, then, in an effort to improve uniqueness, it was changed to MD-DEV<fsid>-INO<fileid>, and merged in this state. It's worth to notice that the buffer for this value is only 32 bytes long. Unfortunately, on a 64-bit system with ZFS, such identifier immediately gets truncated around the first digit of <fileid>, making its uniqueness much worse than random: # ls -i /root/disk* 29580 /root/disk1 29828 /root/disk2 # mdconfig /root/disk1 md0 # mdconfig /root/disk2 md1 # geom md list | grep -E 'name|file|ident' Geom name: md0 file: /root/disk1 ident: MD-DEV11968766667392717182-INO2 Geom name: md1 file: /root/disk2 ident: MD-DEV11968766667392717182-INO2 [Hmm, I'd like to have a look at those gmountver(8) regression tests, are they public?] So, I see a number of solutions here. 1) md-ident-fix-minimal-but-changes-struct-layout.patch: Updates the buffer size to fit two UINT64_MAX decimal representations (51 bytes, rounded up to 64 bytes). Seems to work well, but I am not familiar enough with this code to suggest changing the struct layout: # geom md list | grep -E 'name|file|ident' Geom name: md0 file: /root/disk1 ident: MD-DEV11968766667392717182-INO29580 Geom name: md1 file: /root/disk2 ident: MD-DEV11968766667392717182-INO29828 2) md-ident-fix-simple.patch: A little bit ugly. Via kvprintf's %r conversion specifier, uses base 36 to fit two 64-bit values in 26 bytes and have 5 more bytes left for our namespacing pleasure: # geom md list | grep -E 'name|file|ident' Geom name: md0 file: /root/disk1 ident: MD-2IXL9OT1ZWGAM-MTO Geom name: md1 file: /root/disk2 ident: MD-2IXL9OT1ZWGAM-N0K 3) md-ident-fix-invasive.patch: A little less ugly, but adds another undocumented conversion specifier (%R) to kvprintf() to skip an extra uppercasing loop. 4) md-ident-fix-fast.patch: An ugly but speed-optimized solution which also has the benefit of touching less code parts than 2) and 3), but serializes the numbers in little-endian order: # geom md list | grep -E 'name|file|ident' Geom name: md0 file: /root/disk1 ident: MD-MAGWZ1TO9LXI2-OTM Geom name: md1 file: /root/disk2 ident: MD-MAGWZ1TO9LXI2-K0N I hope this helps. -- You are receiving this mail because: You are the assignee for the bug.home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-287679-227>
