target: Merge sbc_verify_dif_read|write
Instead of providing DIF verify routines for read/write
that are almost identical and conditionally copy protection
information, just let the caller do the right thing.
Have a single sbc_dif_verify that handles an sgl (that
does NOT copy any data) and a protection information copy
routine used by rd_mcp and fileio backend.
In the WRITE case, call sbc_dif_verify with cmd->t_prot_sg
and then do the copy from it to local sgl (assuming the verify
succeeded of course). In the READ case, call sbc_dif_verify
with the local sgl and if it succeeds, copy it to t_prot_sg (or
not if we are stripping it).
(Fix apply breakage from commit c836777 - nab)
Tested-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
committed by
Nicholas Bellinger
parent
b2feda4feb
commit
f75b6fae1a
@@ -643,13 +643,14 @@ fd_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
|
||||
if (ret > 0 && cmd->prot_type && dev->dev_attrib.pi_prot_type) {
|
||||
u32 sectors = cmd->data_length / dev->dev_attrib.block_size;
|
||||
|
||||
rc = sbc_dif_verify_read(cmd, cmd->t_task_lba, sectors,
|
||||
0, fd_prot.prot_sg, 0);
|
||||
rc = sbc_dif_verify(cmd, cmd->t_task_lba, sectors,
|
||||
0, fd_prot.prot_sg, 0);
|
||||
if (rc) {
|
||||
kfree(fd_prot.prot_sg);
|
||||
kfree(fd_prot.prot_buf);
|
||||
return rc;
|
||||
}
|
||||
sbc_dif_copy_prot(cmd, sectors, true, fd_prot.prot_sg, 0);
|
||||
kfree(fd_prot.prot_sg);
|
||||
kfree(fd_prot.prot_buf);
|
||||
}
|
||||
@@ -663,13 +664,14 @@ fd_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
|
||||
if (ret < 0)
|
||||
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
|
||||
|
||||
rc = sbc_dif_verify_write(cmd, cmd->t_task_lba, sectors,
|
||||
0, fd_prot.prot_sg, 0);
|
||||
rc = sbc_dif_verify(cmd, cmd->t_task_lba, sectors,
|
||||
0, cmd->t_prot_sg, 0);
|
||||
if (rc) {
|
||||
kfree(fd_prot.prot_sg);
|
||||
kfree(fd_prot.prot_buf);
|
||||
return rc;
|
||||
}
|
||||
sbc_dif_copy_prot(cmd, sectors, false, fd_prot.prot_sg, 0);
|
||||
}
|
||||
|
||||
ret = fd_do_rw(cmd, sgl, sgl_nents, 1);
|
||||
|
||||
Reference in New Issue
Block a user