Skip to content

Commit fe7b013

Browse files
committed
traps: Add HPE SAN box SCSI UNMAP issue
1 parent 4551f99 commit fe7b013

File tree

2 files changed

+38
-3
lines changed

2 files changed

+38
-3
lines changed

docs/records/2024-10-02.md

+26-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,31 @@
3131
SPARSE_SIZE indicates the consecutive number of bytes (defaults to 4k) that must contain only zeros for qemu-img to create a sparse image during conversion. If SPARSE_SIZE is 0, the source will not be scanned for unallocated or zero sectors, and the destination image will always be fully allocated.
3232
```
3333

34-
在添加 `-S 0` 后测试,`qemu-img convert` 能够正常工作。由于一个 GPT 项只有 128B,而 `qemu-img` 默认 sparse size 为 4K,因此如果刚好对应的块设备区域没有被写零清空,那么本来为 0 的 GPT 表就会错误包含非零内容,进而导致了分区表校验和错误。
34+
在添加 `-S 0` 后测试,`qemu-img convert` 能够正常工作。由于一个 GPT 项只有 128B,而 `qemu-img` 默认 sparse size 为 4K,因此如果刚好对应的块设备区域没有被写零清空,那么本来为 0 的 GPT 表区域就会包含残留数据,进而导致了分区表校验和错误。
3535

3636
相关问题已反馈 Proxmox: <https://bugzilla.proxmox.com/show_bug.cgi?id=5754>。经过内部讨论,我们暂时添加了 `-S 1M` 参数,并且 `apt-mark hold qemu-server` 锁定版本。
37+
38+
## 后续
39+
40+
在 Proxmox 开发者的提示下,我们检查 HPE 存储柜汇报的 SCSI 功能特性:
41+
42+
```console
43+
44+
root@pv1:~# sg_vpd --page=0xb2 /dev/sde
45+
Logical block provisioning VPD page (SBC):
46+
Unmap command supported (LBPU): 1
47+
Write same (16) with unmap bit supported (LBPWS): 1
48+
Write same (10) with unmap bit supported (LBPWS10): 0
49+
Logical block provisioning read zeros (LBPRZ): 1
50+
[...]
51+
```
52+
53+
而实际上该存储柜仅当 SCSI UNMAP 命令覆盖完整的 1 MiB 段时才会清零对应位置的数据,而 qemu-img 的 sparse size 默认为 4K,因此当 qemu-img 以 4K 为单位 `fallocate()` 时底层存储的数据并没有清零。
54+
55+
保险起见,我们决定禁用“以 UNMAP 作清零”的功能,具体做法是向 `/sys/devices/platform/host*/session*/target*/scsi_disk/*/zeroing_mode` 中写入 `writesame`。持久化该设置的方式是通过 udev:
56+
57+
```shell title="/etc/udev/rules.d/99-scsi-zeroing-mode.rules"
58+
ACTION=="add", SUBSYSTEM=="scsi_disk", DEVPATH=="/devices/platform/host*/session*/target*/scsi_disk/*", ATTR{zeroing_mode}="writesame"
59+
```
60+
61+
完整的讨论过程参见上面的 Proxmox Bugzilla 链接。

docs/traps.md

+12-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
icon: material/bug
3+
---
4+
15
# 踩坑记录
26

37
## Proxmox VE
@@ -26,9 +30,9 @@
2630

2731
### Migrate 提示 `ERROR: migration aborted (duration 00:00:00): CT is locked (migrate)`
2832

29-
容器:`pct unlock <ID>`
33+
容器:`pct unlock <ID>`
3034

31-
虚拟机:`qm unlock <ID>`
35+
虚拟机:`qm unlock <ID>`
3236

3337
!!! warning "HA 注意事项"
3438

@@ -463,6 +467,12 @@ See [2023 年 1 月 28 日工作记录](./records/2023-01-28.md).
463467
# pct list | awk '$2=="running"{print $1}' | xargs -I xxx pct exec xxx -- bash -c 'echo xxx && [ ! -f "/etc/systemd/system/logrotate.timer.d/vlab.conf" ] && mkdir -p /etc/systemd/system/logrotate.timer.d && echo -e "[Timer]\nRandomizedDelaySec=3h" > /etc/systemd/system/logrotate.timer.d/vlab.conf && systemctl daemon-reload'
464468
```
465469

470+
### 新建的虚拟机随机出现 GPT 分区表损坏
471+
472+
这个问题困扰了我们很久,根本原因是 HPE 的 SAN 汇报其会对通过 SCSI UNMAP 命令释放的块进行清零处理,但实际上并不会,导致 `qemu-img convert` 往新建的 LVM 写入镜像时跳过了清零操作,而未清零的残余数据导致了 GPT 分区表损坏。
473+
474+
排查过程和解决方法详见 [2024 年 10 月 2 日的工作记录](records/2024-10-02.md)
475+
466476
## Web 及用户界面
467477

468478
### 创建虚拟机出现 Connection aborted, RemoteDisconnected('Remote end closed connection without response')

0 commit comments

Comments
 (0)