@@ -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;
}
@@ -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;
}
@@ -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,
@@ -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);