Re: [PATCH 05/42] scsi: stop using DRIVER_ERROR

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 4/21/21 10:47 AM, Hannes Reinecke wrote:
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index c532f9390ae3..2d9b533ef1ec 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -245,20 +245,23 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd,
  {
  	struct request *req;
  	struct scsi_request *rq;
-	int ret = DRIVER_ERROR << 24;
+	int ret;
req = blk_get_request(sdev->request_queue,
  			data_direction == DMA_TO_DEVICE ?
  			REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN,
  			rq_flags & RQF_PM ? BLK_MQ_REQ_PM : 0);
  	if (IS_ERR(req))
-		return ret;
-	rq = scsi_req(req);
+		return PTR_ERR(req);
- if (bufflen && blk_rq_map_kern(sdev->request_queue, req,
-					buffer, bufflen, GFP_NOIO))
-		goto out;
+	rq = scsi_req(req);
+ if (bufflen) {
+		ret = blk_rq_map_kern(sdev->request_queue, req,
+				      buffer, bufflen, GFP_NOIO);
+		if (ret)
+			goto out;
+	}
  	rq->cmd_len = COMMAND_SIZE(cmd[0]);
  	memcpy(rq->cmd, cmd, rq->cmd_len);
  	rq->retries = retries;

Please mention in the patch description that this change involves a user space ABI change. My understanding is that the current behavior of the IOC_PR_* ioctls is as follows: * A value <= 0 is returned for NVMe where 0 represents success and a negative value represents failure. * A value >= 0 is returned for SCSI where 0 represents success and a positive value is a four-byte SCSI status code.

This patch changes the behavior for SCSI from returning a value >= 0 into returning a value that can be negative, zero or positive where only the return value 0 represents success.

See also sd_pr_command() in drivers/scsi/sd.c.

Thanks,

Bart.



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]

  Powered by Linux