循环设备不支持 WRITE_ZEROES

循环设备不支持 WRITE_ZEROES

我遇到了一个奇怪的问题,mkfs.ext4 无法在临时文件支持的循环设备上工作。

tmp_file="$(mktemp)"
fallocate -l 8M "$tmp_file"
loop="$(losetup --show -f "$tmp_file")"
mkfs.ext4 "$loop"

我也尝试dd if=/dev/zerotruncate。相同的结果。荒谬的是,故障不会传播到应用程序层。 mkfs 程序以 0 退出,但输出文件系统基本上已损坏。这可能与缓冲/延迟 io 有关。

难道我不被允许这样做吗?或者这是一个错误?我可能可以通过阅读内核代码来进一步调查,但我想先听听专家的意见。

更新 哎呀。对不起。内核版本:5.7.10-201.fc32.x86_64

内核消息。

[ 3213.106709] blk_update_request: operation not supported error, dev loop6, sector 16256 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3213.107013] blk_update_request: operation not supported error, dev loop6, sector 196 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3213.108396] blk_update_request: operation not supported error, dev loop6, sector 708 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3213.110006] blk_update_request: operation not supported error, dev loop6, sector 160 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3213.110158] blk_update_request: operation not supported error, dev loop6, sector 166 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3213.110852] blk_update_request: operation not supported error, dev loop6, sector 710 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3223.152191] blk_update_request: operation not supported error, dev loop7, sector 16256 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3223.152619] blk_update_request: operation not supported error, dev loop7, sector 196 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3223.153694] blk_update_request: operation not supported error, dev loop7, sector 708 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3223.155495] blk_update_request: operation not supported error, dev loop7, sector 160 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3223.155670] blk_update_request: operation not supported error, dev loop7, sector 166 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3223.156233] blk_update_request: operation not supported error, dev loop7, sector 710 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3568.666245] blk_update_request: operation not supported error, dev loop6, sector 16256 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3568.666543] blk_update_request: operation not supported error, dev loop6, sector 196 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3568.667546] blk_update_request: operation not supported error, dev loop6, sector 708 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3568.669204] blk_update_request: operation not supported error, dev loop6, sector 160 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3568.669380] blk_update_request: operation not supported error, dev loop6, sector 166 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0
[ 3568.669974] blk_update_request: operation not supported error, dev loop6, sector 710 op 0x9:(WRITE_ZEROES) flags 0x1000800 phys_seg 0 prio class 0

就像我说的,mkfs 应该成功运行。错误是无声的。

答案1

我刚刚遇到了我认为是同样的问题。我怀疑您本身不是 mktemp,但您的 /tmp 是 tmpfs 文件系统。显然tmpfs 不支持FALLOC_FL_ZERO_RANGE。有趣的是,您可以在 tmpfs 挂载上的文件上运行 mkfs.ext4 而不会出现问题。但是,当它是由同一 tmpfs 上的文件支持的循环设备时,就会出现问题。

您应该能够通过使用设置支持零范围(大多数标准范围)的文件系统上的路径的-p选项来解决此问题。mktempTMPDIR

相关内容