mirror of https://gitee.com/openkylin/linux.git
target: implement WRITE_SAME with UNMAP bit using ->execute_unmap
Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Andy Grover <agrover@redhat.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
parent
62e4694256
commit
b753d64355
|
@ -518,26 +518,6 @@ fd_execute_unmap(struct se_cmd *cmd, sector_t lba, sector_t nolb)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static sense_reason_t
|
||||
fd_execute_write_same_unmap(struct se_cmd *cmd)
|
||||
{
|
||||
sector_t lba = cmd->t_task_lba;
|
||||
sector_t nolb = sbc_get_write_same_sectors(cmd);
|
||||
sense_reason_t ret;
|
||||
|
||||
if (!nolb) {
|
||||
target_complete_cmd(cmd, SAM_STAT_GOOD);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = fd_execute_unmap(cmd, lba, nolb);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
target_complete_cmd(cmd, GOOD);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static sense_reason_t
|
||||
fd_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
|
||||
enum dma_data_direction data_direction)
|
||||
|
@ -827,7 +807,6 @@ static struct sbc_ops fd_sbc_ops = {
|
|||
.execute_rw = fd_execute_rw,
|
||||
.execute_sync_cache = fd_execute_sync_cache,
|
||||
.execute_write_same = fd_execute_write_same,
|
||||
.execute_write_same_unmap = fd_execute_write_same_unmap,
|
||||
.execute_unmap = fd_execute_unmap,
|
||||
};
|
||||
|
||||
|
|
|
@ -430,21 +430,6 @@ iblock_execute_unmap(struct se_cmd *cmd, sector_t lba, sector_t nolb)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static sense_reason_t
|
||||
iblock_execute_write_same_unmap(struct se_cmd *cmd)
|
||||
{
|
||||
sector_t lba = cmd->t_task_lba;
|
||||
sector_t nolb = sbc_get_write_same_sectors(cmd);
|
||||
sense_reason_t ret;
|
||||
|
||||
ret = iblock_execute_unmap(cmd, lba, nolb);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
target_complete_cmd(cmd, GOOD);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static sense_reason_t
|
||||
iblock_execute_write_same(struct se_cmd *cmd)
|
||||
{
|
||||
|
@ -836,7 +821,6 @@ static struct sbc_ops iblock_sbc_ops = {
|
|||
.execute_rw = iblock_execute_rw,
|
||||
.execute_sync_cache = iblock_execute_sync_cache,
|
||||
.execute_write_same = iblock_execute_write_same,
|
||||
.execute_write_same_unmap = iblock_execute_write_same_unmap,
|
||||
.execute_unmap = iblock_execute_unmap,
|
||||
};
|
||||
|
||||
|
|
|
@ -177,6 +177,23 @@ sector_t sbc_get_write_same_sectors(struct se_cmd *cmd)
|
|||
}
|
||||
EXPORT_SYMBOL(sbc_get_write_same_sectors);
|
||||
|
||||
static sense_reason_t
|
||||
sbc_execute_write_same_unmap(struct se_cmd *cmd)
|
||||
{
|
||||
struct sbc_ops *ops = cmd->protocol_data;
|
||||
sector_t nolb = sbc_get_write_same_sectors(cmd);
|
||||
sense_reason_t ret;
|
||||
|
||||
if (nolb) {
|
||||
ret = ops->execute_unmap(cmd, cmd->t_task_lba, nolb);
|
||||
if (ret)
|
||||
return ret;
|
||||
}
|
||||
|
||||
target_complete_cmd(cmd, GOOD);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static sense_reason_t
|
||||
sbc_emulate_noop(struct se_cmd *cmd)
|
||||
{
|
||||
|
@ -300,7 +317,7 @@ sbc_setup_write_same(struct se_cmd *cmd, unsigned char *flags, struct sbc_ops *o
|
|||
* translated into block discard requests within backend code.
|
||||
*/
|
||||
if (flags[0] & 0x08) {
|
||||
if (!ops->execute_write_same_unmap)
|
||||
if (!ops->execute_unmap)
|
||||
return TCM_UNSUPPORTED_SCSI_OPCODE;
|
||||
|
||||
if (!dev->dev_attrib.emulate_tpws) {
|
||||
|
@ -308,7 +325,7 @@ sbc_setup_write_same(struct se_cmd *cmd, unsigned char *flags, struct sbc_ops *o
|
|||
" has emulate_tpws disabled\n");
|
||||
return TCM_UNSUPPORTED_SCSI_OPCODE;
|
||||
}
|
||||
cmd->execute_cmd = ops->execute_write_same_unmap;
|
||||
cmd->execute_cmd = sbc_execute_write_same_unmap;
|
||||
return 0;
|
||||
}
|
||||
if (!ops->execute_write_same)
|
||||
|
|
|
@ -49,7 +49,6 @@ struct sbc_ops {
|
|||
u32, enum dma_data_direction);
|
||||
sense_reason_t (*execute_sync_cache)(struct se_cmd *cmd);
|
||||
sense_reason_t (*execute_write_same)(struct se_cmd *cmd);
|
||||
sense_reason_t (*execute_write_same_unmap)(struct se_cmd *cmd);
|
||||
sense_reason_t (*execute_unmap)(struct se_cmd *cmd,
|
||||
sector_t lba, sector_t nolb);
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue