From: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx> This patch changes the received sectors vs. se_dev_attrib.max_sectors check to fail only when checking against passthrough (pSCSI) backends, instead of against all existing max_sectors that may be reflecting a smaller reported value due to underlying HW limitations. It addresses a potential case where se_dev_attrib.max_sectors for IBLOCK backends has already been set via queue_max_sectors() to something small like max_sectors=32 (LVM, DRBD may do this), resulting typically sized SCF_SCSI_DATA_SG_IO_CDB to be incorrectly rejected with invalid_cdb_field in transport_generic_cmd_sequencer(). Cc: Christoph Hellwig <hch@xxxxxx> Cc: Roland Dreier <roland@xxxxxxxxxxxxxxx> Cc: Andy Grover <agrover@xxxxxxxxxx> Signed-off-by: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx> --- drivers/target/target_core_transport.c | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 0baa443..fcc10d6 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -2973,12 +2973,22 @@ static int transport_generic_cmd_sequencer( cmd->data_length = size; } - if (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB && - (sectors > dev->se_sub_dev->se_dev_attrib.fabric_max_sectors || - sectors > dev->se_sub_dev->se_dev_attrib.max_sectors)) { - printk_ratelimited(KERN_ERR "SCSI OP %02xh with too big sectors %u\n", - cdb[0], sectors); - goto out_invalid_cdb_field; + if (cmd->se_cmd_flags & SCF_SCSI_DATA_SG_IO_CDB) { + if (sectors > su_dev->se_dev_attrib.fabric_max_sectors) { + printk_ratelimited(KERN_ERR "SCSI OP %02xh with too" + " big sectors %u exceeds fabric_max_sectors:" + " %u\n", cdb[0], sectors, + su_dev->se_dev_attrib.fabric_max_sectors); + goto out_invalid_cdb_field; + } + if (passthrough && + sectors > su_dev->se_dev_attrib.max_sectors) { + printk_ratelimited(KERN_ERR "SCSI OP %02xh with too" + " big sectors %u exceeds backend max_sectors:" + " %u\n", cdb[0], sectors, + su_dev->se_dev_attrib.max_sectors); + goto out_invalid_cdb_field; + } } /* reject any command that we don't have a handler for */ -- 1.7.2.5 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html