Message ID | 5653B7D4FD7224D2+20250207091723.258095-1-wangyuli@uniontech.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | [v2] scsi: Bypass certain SCSI commands on disks with "use_192_bytes_for_3f" attribute | expand |
On 2/7/25 1:17 AM, WangYuli wrote: > + /* Bofore we queue this comman, check attribute use_192_bytes_for_3f */ Please replace this source code comment with a comment that explains why the code below is necessary. The above comment duplicates the code below rather than explaining something that cannot be derived from the code easily. Additionally, there are spelling errors in the above comment. > + if (cmd->cmnd[0] == MODE_SENSE && sdev->use_192_bytes_for_3f == 1 && Please remove "== 1" because this part is redundant when using a single bit in a boolean "and" expression. > + cmd->result = (DID_ABORT << 16); Please remove the superfluous parentheses from the above statement. Thanks, Bart.
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index d776f13cd160..356bec70b7b8 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1560,6 +1560,7 @@ static void scsi_complete(struct request *rq) static int scsi_dispatch_cmd(struct scsi_cmnd *cmd) { struct Scsi_Host *host = cmd->device->host; + struct scsi_device *sdev = cmd->device; int rtn = 0; atomic_inc(&cmd->device->iorequest_cnt); @@ -1608,6 +1609,13 @@ static int scsi_dispatch_cmd(struct scsi_cmnd *cmd) goto done; } + /* Bofore we queue this comman, check attribute use_192_bytes_for_3f */ + if (cmd->cmnd[0] == MODE_SENSE && sdev->use_192_bytes_for_3f == 1 && + cmd->cmnd[2] == 0x3f && cmd->cmnd[4] != 192) { + cmd->result = (DID_ABORT << 16); + goto done; + } + if (unlikely(host->shost_state == SHOST_DEL)) { cmd->result = (DID_NO_CONNECT << 16); goto done;