]> git.proxmox.com Git - zfsonlinux.git/blame - debian/patches/0014-zpool-status-tighten-bounds-for-noalloc-stat-availab.patch
cherry-pick fix for data corruption
[zfsonlinux.git] / debian / patches / 0014-zpool-status-tighten-bounds-for-noalloc-stat-availab.patch
CommitLineData
4f818e98
TL
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Thomas Lamprecht <t.lamprecht@proxmox.com>
3Date: Sun, 12 Nov 2023 15:52:25 +0100
4Subject: [PATCH] zpool status: tighten bounds for noalloc stat availabillity
5
6When running zfs 2.2.0 userspace utilities with a kernel that still
7has 2.1.13 modules zpool status adds `(non-allocating)` next to the
8disk name of a single-disk pool.
9
10The reason for this seems to be that the patch adding the `vs_pspace` field was
11backported, but the one adding `vs_noalloc` was not.
12
13Itself that is not a problem, but in 2.2 `noalloc` was added before `psspace`,
14so the struct layout between 2.1.13 and 2.2.0 do NOT match anymore...
15
16I.e., the struct looks like the following at the end for ZFS 2.1.x:
17
18```
19typedef 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
28And like the following on ZFS 2.2.x:
29```
30typedef 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
40Resulting in 2.2.x user-space tooling interpreting the `vs_pspace` field from
41the 2.1.x kernel module as `vs_noalloc` field.
42
43For now, work-around that discrepancy by coupling the availability of
44the vs_noalloc field with the one of the vs_pspace one, as when both
45are returned from the module we can be sure that our struct layout
46matches again.
47
48Signed-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
53diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c
54index 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