IB/srp: Avoid that mapping failure triggers an infinite loop
authorBart Van Assche <[email protected]>
Fri, 22 Apr 2016 21:14:15 +0000 (14:14 -0700)
committerDoug Ledford <[email protected]>
Thu, 12 May 2016 18:18:56 +0000 (14:18 -0400)
The srp_queuecommand() function translates ENOMEM into QUEUE_FULL
which causes the SCSI mid-layer to retry the command. All other
error codes are translated into DID_ERROR which causes the SCSI
command to fail. Return E2BIG if mapping will always fail to
prevent that the SCSI mid-layer keeps resubmitting a command
forever.

Signed-off-by: Bart Van Assche <[email protected]>
Cc: Christoph Hellwig <[email protected]>
Cc: Sagi Grimberg <[email protected]>
Cc: Laurence Oberman <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Doug Ledford <[email protected]>
drivers/infiniband/ulp/srp/ib_srp.c

index 92d2d98c9831e3fcfc721b41a48ef13200bfe227..fbd2edbedf055ebf488a9834f0a43cab56793f29 100644 (file)
@@ -1681,6 +1681,8 @@ map_complete:
 
 unmap:
        srp_unmap_data(scmnd, ch, req);
+       if (ret == -ENOMEM && req->nmdesc >= target->mr_pool_size)
+               ret = -E2BIG;
        return ret;
 }