繁体   English   中英

docker容器中的blktrace输出错误

[英]blktrace output error in docker container

我的docker容器基础映像是ubuntu,我使用完全权限选项运行它,这意味着在运行命令中我使用这些开关:

--cap-add=SYS_ADMIN --security-opt apparmor:unconfined

我想使用以下命令使用blktrce:

sudo blktrace -d / -a issue -o - | blkparse -f "%p %T.%9t %D %S ^C %d\n" -i - >stream.out

但是,第一次使用此命令时,我收到此错误:

Debugfs is not mounted at /sys/kernel/debug

我搜索并找到了导致使用此命令的解决方案

mount -t debugfs none /sys/kernel/debug

之后,当我再次使用blktrace命令时,我收到此错误:

BLKTRACESETUP(2) / failed: 25/Inappropriate ioctl for device
Thread 1 failed open /sys/kernel/debug/block/(null)/trace1: 2/No such file or directory
Thread 0 failed open /sys/kernel/debug/block/(null)/trace0: 2/No such file or directory
Thread 2 failed open /sys/kernel/debug/block/(null)/trace2: 2/No such file or directory
Thread 4 failed open /sys/kernel/debug/block/(null)/trace4: 2/No such file or directory
Thread 3 failed open /sys/kernel/debug/block/(null)/trace3: 2/No such file or directory
Thread 5 failed open /sys/kernel/debug/block/(null)/trace5: 2/No such file or directory
Thread 7 failed open /sys/kernel/debug/block/(null)/trace7: 2/No such file or directory
Thread 8 failed open /sys/kernel/debug/block/(null)/trace8: 2/No such file or directory
Thread 6 failed open /sys/kernel/debug/block/(null)/trace6: 2/No such file or directory
Thread 12 failed open /sys/kernel/debug/block/(null)/trace12: 2/No such file or directory
Thread 10 failed open /sys/kernel/debug/block/(null)/trace10: 2/No such file or directory
Thread 13 failed open /sys/kernel/debug/block/(null)/trace13: 2/No such file or directory
Thread 15 failed open /sys/kernel/debug/block/(null)/trace15: 2/No such file or directory
Thread 14 failed open /sys/kernel/debug/block/(null)/trace14: 2/No such file or directory
Thread 17 failed open /sys/kernel/debug/block/(null)/trace17: 2/No such file or directory
Thread 16 failed open /sys/kernel/debug/block/(null)/trace16: 2/No such file or directory
Thread 18 failed open /sys/kernel/debug/block/(null)/trace18: 2/No such file or directory
Thread 11 failed open /sys/kernel/debug/block/(null)/trace11: 2/No such file or directory
Thread 19 failed open /sys/kernel/debug/block/(null)/trace19: 2/No such file or directory
Thread 20 failed open /sys/kernel/debug/block/(null)/trace20: 2/No such file or directory
Thread 9 failed open /sys/kernel/debug/block/(null)/trace9: 2/No such file or directory
Thread 21 failed open /sys/kernel/debug/block/(null)/trace21: 2/No such file or directory
Thread 22 failed open /sys/kernel/debug/block/(null)/trace22: 2/No such file or directory
Thread 23 failed open /sys/kernel/debug/block/(null)/trace23: 2/No such file or directory
FAILED to start thread on CPU 0: 1/Operation not permitted
FAILED to start thread on CPU 1: 1/Operation not permitted
FAILED to start thread on CPU 2: 1/Operation not permitted
FAILED to start thread on CPU 3: 1/Operation not permitted
FAILED to start thread on CPU 4: 1/Operation not permitted
FAILED to start thread on CPU 5: 1/Operation not permitted
FAILED to start thread on CPU 6: 1/Operation not permitted
FAILED to start thread on CPU 7: 1/Operation not permitted
FAILED to start thread on CPU 8: 1/Operation not permitted
FAILED to start thread on CPU 9: 1/Operation not permitted
FAILED to start thread on CPU 10: 1/Operation not permitted
FAILED to start thread on CPU 11: 1/Operation not permitted
FAILED to start thread on CPU 12: 1/Operation not permitted
FAILED to start thread on CPU 13: 1/Operation not permitted
FAILED to start thread on CPU 14: 1/Operation not permitted
FAILED to start thread on CPU 15: 1/Operation not permitted
FAILED to start thread on CPU 16: 1/Operation not permitted
FAILED to start thread on CPU 17: 1/Operation not permitted
FAILED to start thread on CPU 18: 1/Operation not permitted
FAILED to start thread on CPU 19: 1/Operation not permitted
FAILED to start thread on CPU 20: 1/Operation not permitted
FAILED to start thread on CPU 21: 1/Operation not permitted
FAILED to start thread on CPU 22: 1/Operation not permitted
FAILED to start thread on CPU 23: 1/Operation not permitted    

我该怎么解决?

UPDATE1:

/sys/kernel/debug/block/sda文件夹,并且在这个文件夹中有以下文件:

trace0 trace1 trace2 etc.

UPDATE2:

@abligh感谢您的回答,但没有帮助。 关于ioctlstrace输出是:

ioctl(3, BLKTRACESETUP, {act_mask=64, buf_size=524288, buf_nr=4, start_lba=0, end_lba=0, pid=0}, 0x7ffe8a4ceac0) = -1 ENOTTY (Inappropriate ioctl for device)
write(2, "BLKTRACESETUP(2) / failed: 25/Inappropriate ioctl for device\n", 61) = 61
ioctl(3, BLKTRACESTOP, 0x7f6fd19789d0) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(3, BLKTRACESTOP, 0x7ffe8a4ce540) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(3, BLKTRACESTOP, 0x7f6fd19789e0) = -1 ENOTTY (Inappropriate ioctl for device)`
ioctl(3, BLKTRACETEARDOWN, 0x7f6fd19789e0) = -1 ENOTTY (Inappropriate ioctl for device)

回答你关于为什么我在容器中运行blktrace问题,我会说我使用容器作为集群,所以我需要每个节点的跟踪。

我没有足够的信息来调试这个,但是你要求发布一个答案。

问题的根源似乎在这里:

BLKTRACESETUP(2) / failed: 25/Inappropriate ioctl for device

这表明对设置块跟踪的ioctl调用失败。 它在容器内失败,但根据注释在容器外部工作。 这表明问题在于容器设置或内核中的限制,以防止ioctl在容器中被使用。

设备的错误inappropriate ioctl for device错误是错误的,即ENOTTY 除非它根本找不到设备节点,否则我无法立即看到将要返回的内容(假设您已经在容器外部编译块跟踪代码的情况下进行了演示)。 我不记得这是否在一个模块中,但是首先尝试在容器外部进行块跟踪(然后在容器内检查它)是值得的,只是为了检查这不是模块加载问题。

调试它的第一步是使用strace工具(如上所述),这样你就可以准确地知道使用什么参数进行哪个系统调用。 EG运行:

sudo strace -f -s2048 -o/tmp/trace blktrace -d / -a issue -o - | blkparse -f "%p %T.%9t %D %S ^C %d\n" -i - >stream.out

然后看看/tmp/trace strace将列出所有系统调用。 看看你是否可以确定哪个ioctl失败了。

其次,我确保您尝试跟踪的块设备实际上出现在/proc//sys/的正确位置。 这里发生了一些错误:

Thread 0 failed open /sys/kernel/debug/block/(null)/trace0: 2/No such file or directory

注意调试行中的(null) ,显然不应该存在 - 应该是块设备的名称。 这可能是ioctl失败的结果,或者可能表示/sys/ hierarchy中存在问题。

BLKTRACESETUP在内核来处理这里 这最终在这里调用doblktracesetup 我无法立即看到任何理由为什么这不适用于适当许可的容器,这使我怀疑您的/sys层次结构可能无法正确设置。 但是strace的输出会有所帮助。

此外,不可避免的评论:你为什么要在容器中这样做? 为什么不在容器外面运行它?

编辑 :看起来它可能是一个内核的东西。 请参阅https://github.com/scaleway/kernel-tools/issues/107 - 这表明您(a)需要首先对特定模块进行modprobe,并且(b)可能需要特定的内核。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM