From: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx> This patch convert IBLOCK + FILEIO for sbc_ops->execute_sync_cache() to accept struct target_iostate, and avoid backend driver sync_cache SCSI CDB decoding for immediate as reported by HCH. Reported-by: Christoph Hellwig <hch@xxxxxx> Cc: Jens Axboe <axboe@xxxxxx> Cc: Martin Petersen <martin.petersen@xxxxxxxxxx> Cc: Sagi Grimberg <sagi@xxxxxxxxxxx> Cc: Hannes Reinecke <hare@xxxxxxx> Cc: Mike Christie <michaelc@xxxxxxxxxxx> Signed-off-by: Nicholas Bellinger <nab@xxxxxxxxxxxxxxx> --- drivers/target/target_core_file.c | 19 +++++++++---------- drivers/target/target_core_iblock.c | 17 ++++++++--------- drivers/target/target_core_sbc.c | 6 ++++-- include/target/target_core_backend.h | 2 +- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/drivers/target/target_core_file.c b/drivers/target/target_core_file.c index ed94969..6fc1099 100644 --- a/drivers/target/target_core_file.c +++ b/drivers/target/target_core_file.c @@ -309,11 +309,10 @@ static int fd_do_rw(struct target_iostate *ios, struct file *fd, } static sense_reason_t -fd_execute_sync_cache(struct se_cmd *cmd) +fd_execute_sync_cache(struct target_iostate *ios, bool immed) { - struct se_device *dev = cmd->se_dev; + struct se_device *dev = ios->se_dev; struct fd_dev *fd_dev = FD_DEV(dev); - int immed = (cmd->t_task_cdb[1] & 0x2); loff_t start, end; int ret; @@ -322,18 +321,18 @@ fd_execute_sync_cache(struct se_cmd *cmd) * for this SYNCHRONIZE_CACHE op */ if (immed) - target_complete_cmd(cmd, SAM_STAT_GOOD); + ios->t_comp_func(ios, SAM_STAT_GOOD); /* * Determine if we will be flushing the entire device. */ - if (cmd->t_iostate.t_task_lba == 0 && cmd->t_iostate.data_length == 0) { + if (ios->t_task_lba == 0 && ios->data_length == 0) { start = 0; end = LLONG_MAX; } else { - start = cmd->t_iostate.t_task_lba * dev->dev_attrib.block_size; - if (cmd->t_iostate.data_length) - end = start + cmd->t_iostate.data_length - 1; + start = ios->t_task_lba * dev->dev_attrib.block_size; + if (ios->data_length) + end = start + ios->data_length - 1; else end = LLONG_MAX; } @@ -346,9 +345,9 @@ fd_execute_sync_cache(struct se_cmd *cmd) return 0; if (ret) - target_complete_cmd(cmd, SAM_STAT_CHECK_CONDITION); + ios->t_comp_func(ios, SAM_STAT_CHECK_CONDITION); else - target_complete_cmd(cmd, SAM_STAT_GOOD); + ios->t_comp_func(ios, SAM_STAT_GOOD); return 0; } diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index daf052d..931dd7d 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -351,16 +351,16 @@ static void iblock_submit_bios(struct bio_list *list, int rw) static void iblock_end_io_flush(struct bio *bio) { - struct se_cmd *cmd = bio->bi_private; + struct target_iostate *ios = bio->bi_private; if (bio->bi_error) pr_err("IBLOCK: cache flush failed: %d\n", bio->bi_error); - if (cmd) { + if (ios) { if (bio->bi_error) - target_complete_cmd(cmd, SAM_STAT_CHECK_CONDITION); + ios->t_comp_func(ios, SAM_STAT_CHECK_CONDITION); else - target_complete_cmd(cmd, SAM_STAT_GOOD); + ios->t_comp_func(ios, SAM_STAT_GOOD); } bio_put(bio); @@ -371,10 +371,9 @@ static void iblock_end_io_flush(struct bio *bio) * always flush the whole cache. */ static sense_reason_t -iblock_execute_sync_cache(struct se_cmd *cmd) +iblock_execute_sync_cache(struct target_iostate *ios, bool immed) { - struct iblock_dev *ib_dev = IBLOCK_DEV(cmd->se_dev); - int immed = (cmd->t_task_cdb[1] & 0x2); + struct iblock_dev *ib_dev = IBLOCK_DEV(ios->se_dev); struct bio *bio; /* @@ -382,13 +381,13 @@ iblock_execute_sync_cache(struct se_cmd *cmd) * for this SYNCHRONIZE_CACHE op. */ if (immed) - target_complete_cmd(cmd, SAM_STAT_GOOD); + ios->t_comp_func(ios, SAM_STAT_GOOD); bio = bio_alloc(GFP_KERNEL, 0); bio->bi_end_io = iblock_end_io_flush; bio->bi_bdev = ib_dev->ibd_bd; if (!immed) - bio->bi_private = cmd; + bio->bi_private = ios; submit_bio(WRITE_FLUSH, bio); return 0; } diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index 649a3f2..be8dd46 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -463,12 +463,14 @@ sbc_execute_rw(struct target_iostate *ios) cmd->t_iostate.data_direction, fua_write, &target_complete_ios); } -static sense_reason_t sbc_execute_sync_cache(struct target_iostate *ios) +static sense_reason_t +sbc_execute_sync_cache(struct target_iostate *ios) { struct se_cmd *cmd = container_of(ios, struct se_cmd, t_iostate); struct sbc_ops *ops = cmd->protocol_data; + bool immed = (cmd->t_task_cdb[1] & 0x2); - return ops->execute_sync_cache(cmd); + return ops->execute_sync_cache(ios, immed); } static sense_reason_t compare_and_write_post(struct se_cmd *cmd, bool success, diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 5859ea5..47fd1fc 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -48,7 +48,7 @@ struct sbc_ops { sense_reason_t (*execute_rw)(struct target_iostate *ios, struct scatterlist *, u32, enum dma_data_direction, bool fua_write, void (*t_comp_func)(struct target_iostate *ios, u16)); - sense_reason_t (*execute_sync_cache)(struct se_cmd *cmd); + sense_reason_t (*execute_sync_cache)(struct target_iostate *ios, bool immed); sense_reason_t (*execute_write_same)(struct se_cmd *cmd); sense_reason_t (*execute_unmap)(struct se_cmd *cmd, sector_t lba, sector_t nolb); -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html