All Products
Search
Document Center

Alibaba Cloud Linux:Configure tcm_loop device parameters

Last Updated:Nov 22, 2024

Target Core Module (TCM) is another name for Linux-IO Target (LIO), which is an in-kernel Internet Small Computer Systems Interface (iSCSI) target. TCM in Userspace (TCMU) is the userspace implementation of LIO. TCMU allows userspace programs to coordinate with various userspace backend implementations in a convenient manner. Based on the TCMU framework and the LIO loopback (tcm_loop) module, you can implement userspace iSCSI targets with ease. This topic describes how to configure the tcm_loop device parameters in Alibaba Cloud Linux 3 to optimize I/O performance in collaboration with the userspace backend.

Limits

  • Operating system: Alibaba Cloud Linux 3

  • Kernel version: 5.10.134-17 or later

tcm_loop device parameters

You can configure the tcm_loop device parameters when you load the tcm_loop module. The parameter configurations apply to all tcm_loop devices. The tcm_loop module supports the following configurable parameters:

  • nr_hw_queues: specifies the number of hardware queues of a tcm_loop device. Default value: 1.

  • can_queue: specifies the queue depth of each hardware queue. Default value: 1024.

  • cmd_per_lun: specifies the maximum number of commands that a Small Computer System Interface (SCSI) device can run per logical unit number (LUN). Default value: 1024.

  • sg_tablesize: specifies the maximum size of the scatter-gather table for a tcm-loop device. Default value: 256.

View the tcm_loop device parameters

  1. Run the modprobe command to load the tcm_loop module.

    sudo modprobe tcm_loop
  2. View the tcm_loop device parameters.

    cat /sys/module/tcm_loop/parameters/nr_hw_queues
    cat /sys/module/tcm_loop/parameters/can_queue
    cat /sys/module/tcm_loop/parameters/cmd_per_lun
    cat /sys/module/tcm_loop/parameters/sg_tablesize

Method 1: Configure the tcm_loop device parameters when you load the tcm_loop module

  1. If you loaded the tcm_loop module, run the following command to remove the module:

    sudo modprobe -r tcm_loop
  2. Run the modprobe command to load the tcm_loop module.

    Replace <nr_hw_queues>, <can_queue>, <cmd_per_lun>, and <sg_tablesize> with the values that you want to specify.

    sudo modprobe tcm_loop nr_hw_queues=<nr_hw_queues> can_queue=<can_queue> cmd_per_lun=<cmd_per_lun> sg_tablesize=<sg_tablesize>

    For example, set nr_hw_queues to 4, can_queue to 2048, cmd_per_lun to 2048, and sg_tablesize to 512.

    sudo modprobe tcm_loop nr_hw_queues=4 can_queue=2048 cmd_per_lun=2048 sg_tablesize=512
  3. Check whether the parameter configurations take effect.

    cat /sys/module/tcm_loop/parameters/nr_hw_queues
    cat /sys/module/tcm_loop/parameters/can_queue
    cat /sys/module/tcm_loop/parameters/cmd_per_lun
    cat /sys/module/tcm_loop/parameters/sg_tablesize

Method 2: Configure the tcm_loop device parameters by using a configuration file

  1. If you loaded the tcm_loop module, run the following command to remove the module:

    sudo modprobe -r tcm_loop
  2. Create and configure a file.

    Replace <tcm_loop.conf>, <nr_hw_queues>, <can_queue>, <cmd_per_lun>, and <sg_tablesize> with the values that you want to specify.

    sudo bash -c "cat > /etc/modprobe.d/<tcm_loop.conf> << EOF
    options tcm_loop nr_hw_queues=<nr_hw_queues> can_queue=<can_queue> cmd_per_lun=<cmd_per_lun> sg_tablesize=<sg_tablesize>
    EOF"

    For example, run the following command to configure the values of the tcm_loop device parameters by creating a configuration file named tcm_loop.conf in the /etc/modprobe.d directory:

    sudo bash -c "cat > /etc/modprobe.d/tcm_loop.conf << EOF
    options tcm_loop nr_hw_queues=4 can_queue=2048 cmd_per_lun=2048 sg_tablesize=512
    EOF"
  3. Run the modprobe command to load the tcm_loop module.

    sudo modprobe tcm_loop
  4. Check whether the parameter configurations take effect.

    cat /sys/module/tcm_loop/parameters/nr_hw_queues
    cat /sys/module/tcm_loop/parameters/can_queue
    cat /sys/module/tcm_loop/parameters/cmd_per_lun
    cat /sys/module/tcm_loop/parameters/sg_tablesize