如何在块设备驱动程序中禁用请求合并?

heb*_*bbo 2 linux linux-device-driver linux-kernel

如何在块设备驱动程序中禁用此功能?我的意思是:正如下面的文档中提到的,我想将该“标志”的值设置为 2。我在哪里可以做到这一点?最好在块设备驱动程序代码中。

What:       /sys/block/<disk>/queue/nomerges
Date:       January 2010
Contact:
Description:
        Standard I/O elevator operations include attempts to
        merge contiguous I/Os. For known random I/O loads these
        attempts will always fail and result in extra cycles
        being spent in the kernel. This allows one to turn off
        this behavior on one of two ways: When set to 1, complex
        merge checks are disabled, but the simple one-shot merges
        with the previous I/O request are enabled. When set to 2,
        all merge tries are disabled. The default value is 0 -
        which enables all types of merge tries.
Run Code Online (Sandbox Code Playgroud)

rak*_*ib_ 6

首先检查 nomerges 值 -

              cat /sys/block/sda/queue/nomerges
Run Code Online (Sandbox Code Playgroud)

如果还不是 2,则执行以下操作:

              echo 2 > /sys/block/sda/queue/nomerges
Run Code Online (Sandbox Code Playgroud)