mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-18 03:01:26 +00:00
scst: Port to Linux kernel v6.3
Support for the following scsi core changes in the Linux kernel v6.3:
- d0949565811f ("scsi: core: Add struct for args to execution functions")
This commit is contained in:
@@ -177,6 +177,13 @@ enum {
|
||||
};
|
||||
#endif
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 0, 0)
|
||||
/*
|
||||
* See also commit 342a72a33407 ("block: Introduce the type blk_opf_t") # v6.0
|
||||
*/
|
||||
typedef unsigned int blk_opf_t;
|
||||
#endif
|
||||
|
||||
/* <linux/blk-mq.h> */
|
||||
|
||||
static inline unsigned int scst_blk_rq_cpu(struct request *rq)
|
||||
|
||||
@@ -5551,34 +5551,64 @@ ssize_t scst_readv(struct file *file, const struct kvec *vec,
|
||||
ssize_t scst_writev(struct file *file, const struct kvec *vec,
|
||||
unsigned long vlen, loff_t *pos);
|
||||
void scst_write_same(struct scst_cmd *cmd, struct scst_data_descriptor *where);
|
||||
|
||||
/**
|
||||
* scsi_execute - insert a SCSI request and wait for the result
|
||||
* @sdev: scsi device
|
||||
* __scst_scsi_execute_cmd - insert request and wait for the result
|
||||
* @sdev: scsi_device
|
||||
* @cmd: scsi command
|
||||
* @data_direction: data direction
|
||||
* @data_direction: data direction - DMA_TO_DEVICE or DMA_FROM_DEVICE
|
||||
* @buffer: data buffer
|
||||
* @bufflen: length of buffer - DMA_TO_DEVICE, DMA_FROM_DEVICE or DMA_NONE
|
||||
* @sense: optional sense buffer
|
||||
* @timeout: request timeout in seconds
|
||||
* @bufflen: len of buffer
|
||||
* @sensebuf: sense buffer
|
||||
* @sense_len: len of sense buffer
|
||||
* @timeout: request timeout in HZ
|
||||
* @retries: number of times to retry request
|
||||
* @flags: flags for ->cmd_flags, e.g. REQ_FAILFAST_DEV
|
||||
* @opf: block layer request cmd_flags
|
||||
*
|
||||
* Returns the scsi_cmnd result field if a command was executed, or a negative
|
||||
* Linux error code if we didn't get that far.
|
||||
*/
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
#define scst_scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \
|
||||
timeout, retries, flags) \
|
||||
scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \
|
||||
NULL /* sshdr */, timeout, retries, flags, \
|
||||
0 /* rq_flags */, NULL /* resid */)
|
||||
static inline int
|
||||
__scst_scsi_execute_cmd(struct scsi_device *sdev, const unsigned char *cmd,
|
||||
int data_direction, void *buffer, unsigned int bufflen,
|
||||
unsigned char *sense, unsigned int sense_len,
|
||||
int timeout, int retries, blk_opf_t opf)
|
||||
{
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 3, 0)
|
||||
if (WARN_ON_ONCE(sense && sense_len != SCSI_SENSE_BUFFERSIZE))
|
||||
return -EINVAL;
|
||||
|
||||
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)
|
||||
return scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense,
|
||||
timeout, retries, opf, /*resid=*/NULL);
|
||||
|
||||
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 19, 0) && \
|
||||
(!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 8)
|
||||
return scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense,
|
||||
/*sshdr=*/NULL, timeout, retries, opf,
|
||||
/*rq_flags=*/0, /*resid=*/NULL);
|
||||
#else
|
||||
#define scst_scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \
|
||||
timeout, retries, flags) \
|
||||
scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense, \
|
||||
timeout, retries, flags, NULL /* resid */)
|
||||
return __scsi_execute(sdev, cmd, data_direction, buffer, bufflen, sense,
|
||||
/*sshdr=*/NULL, timeout, retries, opf,
|
||||
/*rq_flags=*/0, /*resid=*/NULL);
|
||||
#endif
|
||||
|
||||
#else
|
||||
opf |= data_direction == DMA_TO_DEVICE ? REQ_OP_DRV_OUT : REQ_OP_DRV_IN;
|
||||
|
||||
return scsi_execute_cmd(sdev, cmd, opf, buffer, bufflen, timeout,
|
||||
retries, &(struct scsi_exec_args) {
|
||||
.sense = sense,
|
||||
.sense_len = sense_len,
|
||||
});
|
||||
#endif
|
||||
}
|
||||
|
||||
#define scst_scsi_execute_cmd(sdev, cmd, data_direction, buffer, bufflen, sense, \
|
||||
timeout, retries, opf) \
|
||||
__scst_scsi_execute_cmd(sdev, cmd, data_direction, buffer, bufflen, sense, \
|
||||
sizeof(sense), timeout, retries, opf)
|
||||
|
||||
__be64 scst_pack_lun(const uint64_t lun, enum scst_lun_addr_method addr_method);
|
||||
uint64_t scst_unpack_lun(const uint8_t *lun, int len);
|
||||
|
||||
|
||||
@@ -94,9 +94,9 @@ static int cdrom_attach(struct scst_device *dev)
|
||||
memset(sense_buffer, 0, sizeof(sense_buffer));
|
||||
|
||||
TRACE_DBG("%s", "Doing READ_CAPACITY");
|
||||
rc = scst_scsi_execute(dev->scsi_dev, cmd, DMA_FROM_DEVICE,
|
||||
buffer, buffer_size, sense_buffer,
|
||||
SCST_GENERIC_CDROM_REG_TIMEOUT, 3, 0);
|
||||
rc = scst_scsi_execute_cmd(dev->scsi_dev, cmd, DMA_FROM_DEVICE,
|
||||
buffer, buffer_size, sense_buffer,
|
||||
SCST_GENERIC_CDROM_REG_TIMEOUT, 3, 0);
|
||||
|
||||
TRACE_DBG("READ_CAPACITY done: %x", rc);
|
||||
|
||||
|
||||
@@ -79,9 +79,9 @@ static int disk_attach(struct scst_device *dev)
|
||||
memset(sense_buffer, 0, sizeof(sense_buffer));
|
||||
|
||||
TRACE_DBG("%s", "Doing READ_CAPACITY");
|
||||
rc = scst_scsi_execute(dev->scsi_dev, cmd, DMA_FROM_DEVICE,
|
||||
buffer, buffer_size, sense_buffer,
|
||||
SCST_GENERIC_DISK_REG_TIMEOUT, 3, 0);
|
||||
rc = scst_scsi_execute_cmd(dev->scsi_dev, cmd, DMA_FROM_DEVICE,
|
||||
buffer, buffer_size, sense_buffer,
|
||||
SCST_GENERIC_DISK_REG_TIMEOUT, 3, 0);
|
||||
|
||||
TRACE_DBG("READ_CAPACITY done: %x", rc);
|
||||
|
||||
@@ -135,9 +135,9 @@ static int disk_attach(struct scst_device *dev)
|
||||
memset(sense_buffer, 0, sizeof(sense_buffer));
|
||||
|
||||
TRACE_DBG("%s", "Doing INQUIRY (Unit Serial Number VPD)");
|
||||
rc = scst_scsi_execute(dev->scsi_dev, cmd, DMA_FROM_DEVICE,
|
||||
buffer, buffer_size, sense_buffer,
|
||||
SCST_GENERIC_DISK_REG_TIMEOUT, 3, 0);
|
||||
rc = scst_scsi_execute_cmd(dev->scsi_dev, cmd, DMA_FROM_DEVICE,
|
||||
buffer, buffer_size, sense_buffer,
|
||||
SCST_GENERIC_DISK_REG_TIMEOUT, 3, 0);
|
||||
|
||||
TRACE_DBG("INQUIRY (Unit Serial Number VPD) done: %x", rc);
|
||||
|
||||
|
||||
@@ -175,9 +175,9 @@ static int modisk_attach(struct scst_device *dev)
|
||||
memset(sense_buffer, 0, sizeof(sense_buffer));
|
||||
|
||||
TRACE_DBG("%s", "Doing READ_CAPACITY");
|
||||
rc = scst_scsi_execute(dev->scsi_dev, cmd, DMA_FROM_DEVICE,
|
||||
buffer, buffer_size, sense_buffer,
|
||||
SCST_GENERIC_MODISK_REG_TIMEOUT, 3, 0);
|
||||
rc = scst_scsi_execute_cmd(dev->scsi_dev, cmd, DMA_FROM_DEVICE,
|
||||
buffer, buffer_size, sense_buffer,
|
||||
SCST_GENERIC_MODISK_REG_TIMEOUT, 3, 0);
|
||||
|
||||
TRACE_DBG("READ_CAPACITY done: %x", rc);
|
||||
|
||||
|
||||
@@ -7047,8 +7047,8 @@ static void scst_send_release(struct scst_device *dev)
|
||||
|
||||
TRACE(TRACE_DEBUG | TRACE_SCSI, "%s", "Sending RELEASE req to "
|
||||
"SCSI mid-level");
|
||||
rc = scst_scsi_execute(scsi_dev, cdb, SCST_DATA_NONE, NULL, 0,
|
||||
sense, 15, 0, 0);
|
||||
rc = scst_scsi_execute_cmd(scsi_dev, cdb, DMA_FROM_DEVICE,
|
||||
NULL, 0, sense, 15, 0, 0);
|
||||
TRACE_DBG("RELEASE done: %x", rc);
|
||||
|
||||
if (scsi_status_is_good(rc))
|
||||
@@ -13632,9 +13632,9 @@ int scst_obtain_device_parameters(struct scst_device *dev,
|
||||
memset(sense_buffer, 0, sizeof(sense_buffer));
|
||||
|
||||
TRACE(TRACE_SCSI, "%s", "Doing internal MODE_SENSE");
|
||||
rc = scst_scsi_execute(dev->scsi_dev, cmd, SCST_DATA_READ,
|
||||
buffer, sizeof(buffer), sense_buffer,
|
||||
15, 0, 0);
|
||||
rc = scst_scsi_execute_cmd(dev->scsi_dev, cmd, DMA_FROM_DEVICE,
|
||||
buffer, sizeof(buffer),
|
||||
sense_buffer, 15, 0, 0);
|
||||
|
||||
TRACE_DBG("MODE_SENSE done: %x", rc);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user