scst: Port to Linux kernel v6.15

Support for the following scsi layer changes in the Linux kernel v6.15:

- 0ea163a18b17 ("scsi: usb: Rename the RESERVE and RELEASE constants")
This commit is contained in:
Gleb Chesnokov
2025-05-14 18:36:46 +03:00
parent d21b6f1457
commit 163eb9dcc1
8 changed files with 74 additions and 54 deletions
+13
View File
@@ -1875,6 +1875,19 @@ static inline void scsi_done(struct scsi_cmnd *cmd)
}
#endif
/* <scsi/scsi_proto.h> */
/*
* See also commit 0ea163a18b17 ("scsi: usb: Rename the RESERVE and RELEASE constants") # v6.15.
*/
#ifndef RESERVE_6
#define RESERVE_6 0x16
#endif
#ifndef RELEASE_6
#define RELEASE_6 0x17
#endif
/* <scsi/scsi_request.h> */
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 18, 0)
+2 -2
View File
@@ -348,9 +348,9 @@ static enum scst_exec_res disk_exec(struct scst_cmd *cmd)
if (unlikely(tgt->tgt_forward_src && cmd->op_flags & SCST_LOCAL_CMD)) {
switch (cmd->cdb[0]) {
case RESERVE:
case RESERVE_6:
case RESERVE_10:
case RELEASE:
case RELEASE_6:
case RELEASE_10:
TRACE_DBG("Skipping LOCAL cmd %p (op %s)",
cmd, cmd->op_name);
+4 -4
View File
@@ -3285,9 +3285,9 @@ static bool vdisk_no_fd_allowed_commands(const struct scst_cmd *cmd)
case READ_CAPACITY:
case REPORT_LUNS:
case REQUEST_SENSE:
case RELEASE:
case RELEASE_6:
case RELEASE_10:
case RESERVE:
case RESERVE_6:
case RESERVE_10:
case READ_BUFFER:
case WRITE_BUFFER:
@@ -9784,9 +9784,9 @@ static int __init vdev_check_mode_pages_path(void)
[ALLOW_MEDIUM_REMOVAL] = vdisk_exec_prevent_allow_medium_removal, \
[READ_TOC] = vdisk_exec_read_toc, \
[START_STOP] = vdisk_exec_start_stop, \
[RESERVE] = vdisk_nop, \
[RESERVE_6] = vdisk_nop, \
[RESERVE_10] = vdisk_nop, \
[RELEASE] = vdisk_nop, \
[RELEASE_6] = vdisk_nop, \
[RELEASE_10] = vdisk_nop, \
[TEST_UNIT_READY] = vdisk_nop, \
[INQUIRY] = vdisk_exec_inquiry, \
+12 -12
View File
@@ -236,22 +236,22 @@ const struct scst_opcode_descriptor scst_op_descr_send_diagnostic = {
EXPORT_SYMBOL(scst_op_descr_send_diagnostic);
const struct scst_opcode_descriptor scst_op_descr_reserve6 = {
.od_opcode = RESERVE,
.od_opcode = RESERVE_6,
.od_support = 3, /* supported as in the standard */
.od_cdb_size = 6,
.od_nominal_timeout = SCST_DEFAULT_NOMINAL_TIMEOUT_SEC,
.od_recommended_timeout = SCST_GENERIC_DISK_SMALL_TIMEOUT/HZ,
.od_cdb_usage_bits = { RESERVE, 0, 0, 0, 0, SCST_OD_DEFAULT_CONTROL_BYTE },
.od_cdb_usage_bits = { RESERVE_6, 0, 0, 0, 0, SCST_OD_DEFAULT_CONTROL_BYTE },
};
EXPORT_SYMBOL(scst_op_descr_reserve6);
const struct scst_opcode_descriptor scst_op_descr_release6 = {
.od_opcode = RELEASE,
.od_opcode = RELEASE_6,
.od_support = 3, /* supported as in the standard */
.od_cdb_size = 6,
.od_nominal_timeout = SCST_DEFAULT_NOMINAL_TIMEOUT_SEC,
.od_recommended_timeout = SCST_GENERIC_DISK_SMALL_TIMEOUT/HZ,
.od_cdb_usage_bits = { RELEASE, 0, 0, 0, 0, SCST_OD_DEFAULT_CONTROL_BYTE },
.od_cdb_usage_bits = { RELEASE_6, 0, 0, 0, 0, SCST_OD_DEFAULT_CONTROL_BYTE },
};
EXPORT_SYMBOL(scst_op_descr_release6);
@@ -727,14 +727,14 @@ static const struct scst_sdbops scst_scsi_op_table[] = {
.info_len_off = 4, .info_len_len = 1,
.get_cdb_info = get_cdb_info_len_1},
{.ops = 0x16, .devkey = "MMMMMMMMMMMMMMMM",
.info_op_name = "RESERVE",
.info_op_name = "RESERVE(6)",
.info_data_direction = SCST_DATA_NONE,
.info_op_flags = SCST_SMALL_TIMEOUT|SCST_LOCAL_CMD|SCST_SERIALIZED|
SCST_WRITE_EXCL_ALLOWED|SCST_EXCL_ACCESS_ALLOWED|
SCST_SCSI_ATOMIC/* see comment in scst_cmd_overlap() */,
.get_cdb_info = get_cdb_info_none},
{.ops = 0x17, .devkey = "MMMMMMMMMMMMMMMM",
.info_op_name = "RELEASE",
.info_op_name = "RELEASE(6)",
.info_data_direction = SCST_DATA_NONE,
.info_op_flags = SCST_SMALL_TIMEOUT|SCST_LOCAL_CMD|SCST_SERIALIZED|
SCST_REG_RESERVE_ALLOWED|SCST_WRITE_EXCL_ALLOWED|
@@ -7257,23 +7257,23 @@ static void scst_send_release(struct scst_device *dev)
for (i = 0; i < 5; i++) {
memset(cdb, 0, sizeof(cdb));
cdb[0] = RELEASE;
cdb[0] = RELEASE_6;
cdb[1] = (scsi_dev->scsi_level <= SCSI_2) ?
((scsi_dev->lun << 5) & 0xe0) : 0;
memset(sense, 0, sizeof(sense));
TRACE(TRACE_DEBUG | TRACE_SCSI, "%s", "Sending RELEASE req to "
"SCSI mid-level");
TRACE(TRACE_DEBUG | TRACE_SCSI,
"Sending RELEASE_6 req to SCSI mid-level");
rc = scst_scsi_execute_cmd(scsi_dev, cdb, DMA_FROM_DEVICE,
NULL, 0, sense, 15, 0, 0);
TRACE_DBG("RELEASE done: %x", rc);
TRACE_DBG("RELEASE_6 done: %x", rc);
if (scsi_status_is_good(rc))
break;
PRINT_ERROR("RELEASE failed: %d", rc);
PRINT_BUFFER("RELEASE sense", sense, sizeof(sense));
PRINT_ERROR("RELEASE_6 failed: %d", rc);
PRINT_BUFFER("RELEASE_6 sense", sense, sizeof(sense));
scst_check_internal_sense(dev, rc, sense, sizeof(sense));
}
+6 -7
View File
@@ -145,7 +145,7 @@ static bool scst_cmd_overlap_cwr(struct scst_cmd *cwr_cmd, struct scst_cmd *cmd)
if (cmd->op_flags & SCST_LBA_NOT_VALID) {
switch (cmd->cdb[0]) {
case RESERVE:
case RESERVE_6:
case RESERVE_10:
res = true;
break;
@@ -179,8 +179,7 @@ out:
return res;
}
static bool scst_cmd_overlap_reserve(struct scst_cmd *reserve_cmd,
struct scst_cmd *cmd)
static bool scst_cmd_overlap_reserve(struct scst_cmd *reserve_cmd, struct scst_cmd *cmd)
{
bool res;
@@ -191,7 +190,7 @@ static bool scst_cmd_overlap_reserve(struct scst_cmd *reserve_cmd,
(cmd->op_flags & SCST_LBA_NOT_VALID) == 0,
(long long)cmd->lba, (long long)cmd->data_len);
EXTRACHECKS_BUG_ON((reserve_cmd->cdb[0] != RESERVE) &&
EXTRACHECKS_BUG_ON((reserve_cmd->cdb[0] != RESERVE_6) &&
(reserve_cmd->cdb[0] != RESERVE_10));
/*
@@ -225,7 +224,7 @@ static bool scst_cmd_overlap_atomic(struct scst_cmd *atomic_cmd, struct scst_cmd
case COMPARE_AND_WRITE:
res = scst_cmd_overlap_cwr(atomic_cmd, cmd);
break;
case RESERVE:
case RESERVE_6:
case RESERVE_10:
res = scst_cmd_overlap_reserve(atomic_cmd, cmd);
break;
@@ -2702,11 +2701,11 @@ static scst_local_exec_fn scst_local_fns[256] = {
[PERSISTENT_RESERVE_IN] = scst_persistent_reserve_in_local,
[PERSISTENT_RESERVE_OUT] = scst_persistent_reserve_out_local,
[RECEIVE_COPY_RESULTS] = scst_cm_rcv_copy_res_exec,
[RELEASE] = scst_release_local,
[RELEASE_6] = scst_release_local,
[RELEASE_10] = scst_release_local,
[REPORT_LUNS] = scst_report_luns_local,
[REQUEST_SENSE] = scst_request_sense_local,
[RESERVE] = scst_reserve_local,
[RESERVE_6] = scst_reserve_local,
[RESERVE_10] = scst_reserve_local,
};
+2 -2
View File
@@ -313,9 +313,9 @@ static int scst_tg_accept_standby(struct scst_cmd *cmd)
case READ_CAPACITY:
case REPORT_LUNS:
case REQUEST_SENSE:
case RELEASE:
case RELEASE_6:
case RELEASE_10:
case RESERVE:
case RESERVE_6:
case RESERVE_10:
case READ_BUFFER:
case WRITE_BUFFER:
+2 -2
View File
@@ -418,9 +418,9 @@ static int do_exec(struct vdisk_cmd *vcmd)
case START_STOP:
exec_fsync(vcmd/*, 0, dev->file_size*/);
break;
case RESERVE:
case RESERVE_6:
case RESERVE_10:
case RELEASE:
case RELEASE_6:
case RELEASE_10:
case TEST_UNIT_READY:
break;
+33 -25
View File
@@ -23,34 +23,42 @@
#include "debug.h"
#ifndef WRITE_SAME_10
#define WRITE_SAME_10 0x41
/* 8 byte ASCII Vendor */
#define VENDOR "SCST_USR"
/* 4 byte ASCII Product Revision Level - left aligned */
#define FIO_REV "3100"
#define MAX_USN_LEN (20 + 1) /* For '\0' */
#define INQ_BUF_SZ 128
#define EVPD 0x01
#define CMDDT 0x02
#define MSENSE_BUF_SZ 256
#define DBD 0x08 /* disable block descriptor */
#define WP 0x80 /* write protect */
#define DPOFUA 0x10 /* DPOFUA bit */
#define WCE 0x04 /* write cache enable */
#define PF 0x10 /* page format */
#define SP 0x01 /* save pages */
#define PS 0x80 /* parameter saveable */
#define BYTE 8
#define DEF_SECTORS 56
#define DEF_HEADS 255
#ifndef RESERVE_6
#define RESERVE_6 0x16
#endif
/* 8 byte ASCII Vendor */
#define VENDOR "SCST_USR"
/* 4 byte ASCII Product Revision Level - left aligned */
#define FIO_REV "3100"
#ifndef RELEASE_6
#define RELEASE_6 0x17
#endif
#define MAX_USN_LEN (20+1) /* For '\0' */
#define INQ_BUF_SZ 128
#define EVPD 0x01
#define CMDDT 0x02
#define MSENSE_BUF_SZ 256
#define DBD 0x08 /* disable block descriptor */
#define WP 0x80 /* write protect */
#define DPOFUA 0x10 /* DPOFUA bit */
#define WCE 0x04 /* write cache enable */
#define PF 0x10 /* page format */
#define SP 0x01 /* save pages */
#define PS 0x80 /* parameter saveable */
#define BYTE 8
#define DEF_SECTORS 56
#define DEF_HEADS 255
#ifndef WRITE_SAME_10
#define WRITE_SAME_10 0x41
#endif
struct vdisk_tgt_dev {
uint64_t sess_h;