make_request 和队列限制

发布于 2024-12-17 10:35:57 字数 420 浏览 1 评论 0原文

我正在编写一个模拟块设备的 Linux 内核模块。

有多种调用可用于向内核告知块大小,因此它会相应地对驱动程序的每个请求进行对齐和调整大小。这在“Linux Device Drives 3”一书中有详细记录。

本书描述了两种实现块设备的方法:使用“request”函数,或使用“make_request”函数。

目前尚不清楚,在使用简约的“make_request”方法时是否适用队列限制调用(如果底层设备确实没有从顺序 IO 和随机 IO 中获益,这也是更有效的方法,我就是这种情况)。

我真的很想让内核使用 4K 块大小来与我对话,但我看到较小的 BIOS 调用了我的 make_request 函数。

我的问题是,使用 make_request 时 blk_queue_limit_* 是否会影响 bio 大小?

先感谢您。

I'm writing a linux kernel module that emulates a block device.

There are various calls that can be used to tell the block size to the kernel, so it aligns and sizes every request toward the driver accordingly. This is well documented in the "Linux Device Drives 3" book.

The book describes two methods of implementing a block device: using a "request" function, or using a "make_request" function.

It is not clear, whether the queue limit calls apply when using the minimalistic "make_request" approach (which is also the more efficient one if the underlying device is has really no benefit from sequential over random IO, which is the case with me).

I would really like to get the kernel to talk to me using 4K block sizes, but I see smaller bio-s hitting my make_request function.

My question is that should the blk_queue_limit_* affect the bio size when using make_request?

Thank you in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

满地尘埃落定 2024-12-24 10:35:57

我想我已经在内核代码中找到了足够的证据,如果您使用 make_request,您将获得正确大小和对齐的 BIOS。

答案是:

您必须首先调用 blk_queue_make_request,因为它将队列限制设置为默认值。之后,根据需要设置队列限制。

似乎提交 BIOS 的内核的每个部分都进行有效性检查,并且由提交者来执行这些检查。我发现 Submit_bio 和 generic_make_request 中的验证不完整。不过只要没人耍花样,就没什么问题。

由于提交正确的简历是一项政策,但由提交者负责,而中间没有人这样做,所以我认为我必须实施明确的检查并使错误的简历失败。由于这是一项策略,因此违反规则时失败是可以接受的,并且由于它不是由内核强制执行的,因此进行显式检查是一件好事。

如果您想了解更多有关该故事的信息,请参阅 http://tlfabian.blogspot.com/2012/01/linux-block-device-drivers-queue-and.html

I think I've found enough evidence in the kernel code that if you use make_request, you'll get correctly sized and aligned bios.

The answer is:

You must call blk_queue_make_request first, because it sets queue limits to defaults. After this, set queue limits as you'd like.

It seems that every part of the kernel submitting bios are do check for validity, and it's up to the submitter to do these checks. I've found incomplete validation in submit_bio and generic_make_request. But as long as no one does tricks, it's fine.

Since it's a policy to submit correct bio's, but it's up to the submitter to take care, and no one in the middle does, I think I have to implement explicit checks and fail the wrong bio-s. Since it's a policy, it's fine to fail on violation, and since it's not enforced by the kernel, it's a good thing to do explicit checks.

If you want to read a bit more on the story, see http://tlfabian.blogspot.com/2012/01/linux-block-device-drivers-queue-and.html.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文