]>
Commit | Line | Data |
---|---|---|
4f818e98 TL |
1 | From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 |
2 | From: Thomas Lamprecht <t.lamprecht@proxmox.com> | |
3 | Date: Sun, 12 Nov 2023 15:52:25 +0100 | |
4 | Subject: [PATCH] zpool status: tighten bounds for noalloc stat availabillity | |
5 | ||
6 | When running zfs 2.2.0 userspace utilities with a kernel that still | |
7 | has 2.1.13 modules zpool status adds `(non-allocating)` next to the | |
8 | disk name of a single-disk pool. | |
9 | ||
10 | The reason for this seems to be that the patch adding the `vs_pspace` field was | |
11 | backported, but the one adding `vs_noalloc` was not. | |
12 | ||
13 | Itself that is not a problem, but in 2.2 `noalloc` was added before `psspace`, | |
14 | so the struct layout between 2.1.13 and 2.2.0 do NOT match anymore... | |
15 | ||
16 | I.e., the struct looks like the following at the end for ZFS 2.1.x: | |
17 | ||
18 | ``` | |
19 | typedef struct vdev_stat { | |
20 | hrtime_t vs_timestamp; /* time since vdev load */ | |
21 | // snip | |
22 | uint64_t vs_logical_ashift; /* vdev_logical_ashift */ | |
23 | uint64_t vs_physical_ashift; /* vdev_physical_ashift */ | |
24 | uint64_t vs_pspace; /* physical capacity */ | |
25 | } vdev_stat_t; | |
26 | ``` | |
27 | ||
28 | And like the following on ZFS 2.2.x: | |
29 | ``` | |
30 | typedef struct vdev_stat { | |
31 | hrtime_t vs_timestamp; /* time since vdev load */ | |
32 | // snip | |
33 | uint64_t vs_logical_ashift; /* vdev_logical_ashift */ | |
34 | uint64_t vs_physical_ashift; /* vdev_physical_ashift */ | |
35 | uint64_t vs_noalloc; /* allocations halted? */ | |
36 | uint64_t vs_pspace; /* physical capacity */ | |
37 | } vdev_stat_t; | |
38 | ``` | |
39 | ||
40 | Resulting in 2.2.x user-space tooling interpreting the `vs_pspace` field from | |
41 | the 2.1.x kernel module as `vs_noalloc` field. | |
42 | ||
43 | For now, work-around that discrepancy by coupling the availability of | |
44 | the vs_noalloc field with the one of the vs_pspace one, as when both | |
45 | are returned from the module we can be sure that our struct layout | |
46 | matches again. | |
47 | ||
48 | Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> | |
49 | --- | |
50 | cmd/zpool/zpool_main.c | 3 ++- | |
51 | 1 file changed, 2 insertions(+), 1 deletion(-) | |
52 | ||
53 | diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c | |
54 | index 5507f9d3f..98970abfe 100644 | |
55 | --- a/cmd/zpool/zpool_main.c | |
56 | +++ b/cmd/zpool/zpool_main.c | |
57 | @@ -2478,7 +2478,8 @@ print_status_config(zpool_handle_t *zhp, status_cbdata_t *cb, const char *name, | |
58 | ||
59 | if (vs->vs_scan_removing != 0) { | |
60 | (void) printf(gettext(" (removing)")); | |
61 | - } else if (VDEV_STAT_VALID(vs_noalloc, vsc) && vs->vs_noalloc != 0) { | |
62 | + } else if (VDEV_STAT_VALID(vs_pspace, vsc) | |
63 | + && VDEV_STAT_VALID(vs_noalloc, vsc) && vs->vs_noalloc != 0) { | |
64 | (void) printf(gettext(" (non-allocating)")); | |
65 | } | |
66 |