Skip to content

Commit b48cfd2

Browse files
Stoiko IvanovThomasLamprecht
authored andcommitted
fix #5288: cherry-pick fix for udev-partition links > 16
If a zvol has more than 15 partitions, the minor device number exhausts the slot count reserved for partitions next to the zvol itself. As a result, the minor number cannot be used to determine the partition number for the higher partition, and doing so results in wrong named symlinks being generated by udev. Since the partition number is encoded in the block device name anyway, let's just extract it from there instead. For upstream issue and PR discussion see: openzfs/zfs#15970 openzfs/zfs#15904 Signed-off-by: Stoiko Ivanov <[email protected]> Signed-off-by: Thomas Lamprecht <[email protected]>
1 parent a5e0251 commit b48cfd2

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= <[email protected]>
3+
Date: Wed, 6 Mar 2024 10:39:06 +0100
4+
Subject: [PATCH] udev: correctly handle partition #16 and later
5+
MIME-Version: 1.0
6+
Content-Type: text/plain; charset=UTF-8
7+
Content-Transfer-Encoding: 8bit
8+
9+
If a zvol has more than 15 partitions, the minor device number exhausts
10+
the slot count reserved for partitions next to the zvol itself. As a
11+
result, the minor number cannot be used to determine the partition
12+
number for the higher partition, and doing so results in wrong named
13+
symlinks being generated by udev.
14+
15+
Since the partition number is encoded in the block device name anyway,
16+
let's just extract it from there instead.
17+
18+
Fixes: #15904
19+
20+
Signed-off-by: Fabian Grünbichler <[email protected]>
21+
Signed-off-by: Stoiko Ivanov <[email protected]>
22+
---
23+
udev/zvol_id.c | 9 +++++----
24+
1 file changed, 5 insertions(+), 4 deletions(-)
25+
26+
diff --git a/udev/zvol_id.c b/udev/zvol_id.c
27+
index 5960b9787..609349594 100644
28+
--- a/udev/zvol_id.c
29+
+++ b/udev/zvol_id.c
30+
@@ -51,7 +51,7 @@ const char *__asan_default_options(void) {
31+
int
32+
main(int argc, const char *const *argv)
33+
{
34+
- if (argc != 2) {
35+
+ if (argc != 2 || strncmp(argv[1], "/dev/zd", 7) != 0) {
36+
fprintf(stderr, "usage: %s /dev/zdX\n", argv[0]);
37+
return (1);
38+
}
39+
@@ -72,9 +72,10 @@ main(int argc, const char *const *argv)
40+
return (1);
41+
}
42+
43+
- unsigned int dev_part = minor(sb.st_rdev) % ZVOL_MINORS;
44+
- if (dev_part != 0)
45+
- sprintf(zvol_name + strlen(zvol_name), "-part%u", dev_part);
46+
+ const char *dev_part = strrchr(dev_name, 'p');
47+
+ if (dev_part != NULL) {
48+
+ sprintf(zvol_name + strlen(zvol_name), "-part%s", dev_part + 1);
49+
+ }
50+
51+
for (size_t i = 0; i < strlen(zvol_name); ++i)
52+
if (isblank(zvol_name[i]))

debian/patches/series

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
0009-arc-stat-summary-guard-access-to-l2arc-MFU-MRU-stats.patch
1010
0010-Fix-nfs_truncate_shares-without-etc-exports.d.patch
1111
0011-zpool-status-tighten-bounds-for-noalloc-stat-availab.patch
12+
0012-udev-correctly-handle-partition-16-and-later.patch

0 commit comments

Comments
 (0)