diff mbox series

[v2,2/2] RDMA/srp: Fix residual handling

Message ID 20230724200843.3376570-3-bvanassche@acm.org (mailing list archive)
State Accepted
Headers show
Series Fix residual handling in two SCSI LLDs | expand

Commit Message

Bart Van Assche July 24, 2023, 8:08 p.m. UTC
Although the code for residual handling in the SRP initiator follows the
SCSI documentation, that documentation has never been correct. Because
scsi_finish_command() starts from the data buffer length and subtracts
the residual, scsi_set_resid() must not be called if a residual overflow
occurs. Hence remove the scsi_set_resid() calls from the SRP initiator
if a residual overflow occurrs.

Cc: Leon Romanovsky <leon@kernel.org>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Fixes: 9237f04e12cc ("scsi: core: Fix scsi_get/set_resid() interface")
Fixes: e714531a349f ("IB/srp: Fix residual handling")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 drivers/infiniband/ulp/srp/ib_srp.c | 4 ----
 1 file changed, 4 deletions(-)

Comments

Leon Romanovsky July 25, 2023, 6:51 a.m. UTC | #1
On Mon, Jul 24, 2023 at 01:08:30PM -0700, Bart Van Assche wrote:
> Although the code for residual handling in the SRP initiator follows the
> SCSI documentation, that documentation has never been correct. Because
> scsi_finish_command() starts from the data buffer length and subtracts
> the residual, scsi_set_resid() must not be called if a residual overflow
> occurs. Hence remove the scsi_set_resid() calls from the SRP initiator
> if a residual overflow occurrs.
> 
> Cc: Leon Romanovsky <leon@kernel.org>
> Cc: Jason Gunthorpe <jgg@nvidia.com>
> Fixes: 9237f04e12cc ("scsi: core: Fix scsi_get/set_resid() interface")
> Fixes: e714531a349f ("IB/srp: Fix residual handling")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
>  drivers/infiniband/ulp/srp/ib_srp.c | 4 ----
>  1 file changed, 4 deletions(-)
> 

Thanks,
Acked-by: Leon Romanovsky <leon@kernel.org>
diff mbox series

Patch

diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c
index 0e513a7e5ac8..1574218764e0 100644
--- a/drivers/infiniband/ulp/srp/ib_srp.c
+++ b/drivers/infiniband/ulp/srp/ib_srp.c
@@ -1979,12 +1979,8 @@  static void srp_process_rsp(struct srp_rdma_ch *ch, struct srp_rsp *rsp)
 
 		if (unlikely(rsp->flags & SRP_RSP_FLAG_DIUNDER))
 			scsi_set_resid(scmnd, be32_to_cpu(rsp->data_in_res_cnt));
-		else if (unlikely(rsp->flags & SRP_RSP_FLAG_DIOVER))
-			scsi_set_resid(scmnd, -be32_to_cpu(rsp->data_in_res_cnt));
 		else if (unlikely(rsp->flags & SRP_RSP_FLAG_DOUNDER))
 			scsi_set_resid(scmnd, be32_to_cpu(rsp->data_out_res_cnt));
-		else if (unlikely(rsp->flags & SRP_RSP_FLAG_DOOVER))
-			scsi_set_resid(scmnd, -be32_to_cpu(rsp->data_out_res_cnt));
 
 		srp_free_req(ch, req, scmnd,
 			     be32_to_cpu(rsp->req_lim_delta));