• Martin K. Petersen's avatar
    block/sd: Fix device-imposed transfer length limits · ca369d51
    Martin K. Petersen authored
    Commit 4f258a46 ("sd: Fix maximum I/O size for BLOCK_PC requests")
    had the unfortunate side-effect of removing an implicit clamp to
    BLK_DEF_MAX_SECTORS for REQ_TYPE_FS requests in the block layer
    code. This caused problems for some SMR drives.
    Debugging this issue revealed a few problems with the existing
    infrastructure since the block layer didn't know how to deal with
    device-imposed limits, only limits set by the I/O controller.
     - Introduce a new queue limit, max_dev_sectors, which is used by the
       ULD to signal the maximum sectors for a REQ_TYPE_FS request.
     - Ensure that max_dev_sectors is correctly stacked and taken into
       account when overriding max_sectors through sysfs.
     - Rework sd_read_block_limits() so it saves the max_xfer and opt_xfer
       values for later processing.
     - In sd_revalidate() set the queue's max_dev_sectors based on the
       MAXIMUM TRANSFER LENGTH value in the Block Limits VPD. If this value
       is not reported, fall back to a cap based on the CDB TRANSFER LENGTH
       field size.
     - In sd_revalidate(), use OPTIMAL TRANSFER LENGTH from the Block Limits
       VPD--if reported and sane--to signal the preferred device transfer
       size for FS requests. Otherwise use BLK_DEF_MAX_SECTORS.
     - blk_limits_max_hw_sectors() is no longer used and can be removed.
    Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
    Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=93581Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Tested-by: sweeneygj@gmx.com
    Tested-by: default avatarArzeets <anatol.pomozov@gmail.com>
    Tested-by: default avatarDavid Eisner <david.eisner@oriel.oxon.org>
    Tested-by: default avatarMario Kicherer <dev@kicherer.org>
    Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
blk-settings.c 26.9 KB