mirror of
https://github.com/SCST-project/scst.git
synced 2026-07-25 01:23:14 +00:00
scst: Port to Linux kernel v4.11
git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7153 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
@@ -1400,7 +1400,11 @@ static void isert_kref_free(struct kref *kref)
|
||||
|
||||
void isert_conn_free(struct isert_connection *isert_conn)
|
||||
{
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
sBUG_ON(kref_read(&isert_conn->kref) == 0);
|
||||
#else
|
||||
sBUG_ON(atomic_read(&isert_conn->kref.refcount) == 0);
|
||||
#endif
|
||||
kref_put(&isert_conn->kref, isert_kref_free);
|
||||
}
|
||||
|
||||
|
||||
@@ -111,7 +111,11 @@ static void isert_kref_release_dev(struct kref *kref)
|
||||
|
||||
static void isert_dev_release(struct isert_conn_dev *dev)
|
||||
{
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
sBUG_ON(kref_read(&dev->kref) == 0);
|
||||
#else
|
||||
sBUG_ON(atomic_read(&dev->kref.refcount) == 0);
|
||||
#endif
|
||||
mutex_lock(&isert_listen_dev.conn_lock);
|
||||
kref_put(&dev->kref, isert_kref_release_dev);
|
||||
mutex_unlock(&isert_listen_dev.conn_lock);
|
||||
|
||||
@@ -22,6 +22,10 @@
|
||||
#include <linux/poll.h>
|
||||
#include <linux/stddef.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/version.h>
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
#include <linux/sched/signal.h>
|
||||
#endif
|
||||
|
||||
#define LOG_PREFIX DEV_USER_NAME
|
||||
|
||||
|
||||
@@ -55,6 +55,9 @@
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)
|
||||
#include <linux/falloc.h>
|
||||
#endif
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
#include <linux/sched/signal.h>
|
||||
#endif
|
||||
|
||||
#define LOG_PREFIX "dev_vdisk"
|
||||
|
||||
|
||||
@@ -11,6 +11,10 @@
|
||||
#include <linux/stddef.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/version.h>
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
#include <linux/sched/signal.h>
|
||||
#endif
|
||||
|
||||
#ifdef INSIDE_KERNEL_TREE
|
||||
#include <scst/scst.h>
|
||||
|
||||
+37
-11
@@ -37,6 +37,9 @@
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
|
||||
#include <linux/crc-t10dif.h>
|
||||
#endif
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
#include <linux/sched/task_stack.h>
|
||||
#endif
|
||||
#include <linux/namei.h>
|
||||
#include <linux/mount.h>
|
||||
|
||||
@@ -7853,7 +7856,11 @@ static struct request *blk_make_request(struct request_queue *q,
|
||||
if (IS_ERR(rq))
|
||||
return rq;
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
scsi_req_init(rq);
|
||||
#else
|
||||
blk_rq_set_block_pc(rq);
|
||||
#endif
|
||||
|
||||
for_each_bio(bio) {
|
||||
struct bio *bounce_bio = bio;
|
||||
@@ -8063,7 +8070,11 @@ static struct request *blk_map_kern_sg(struct request_queue *q,
|
||||
if (unlikely(!rq))
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
scsi_req_init(rq);
|
||||
#else
|
||||
rq->cmd_type = REQ_TYPE_BLOCK_PC;
|
||||
#endif
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -8259,10 +8270,14 @@ static void scsi_end_async(struct request *req, int error)
|
||||
#endif
|
||||
|
||||
if (sioc->done)
|
||||
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 30)
|
||||
sioc->done(sioc->data, sioc->sense, req->errors, req->data_len);
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
sioc->done(sioc->data, sioc->sense, req->errors,
|
||||
scsi_req(req)->resid_len);
|
||||
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)
|
||||
sioc->done(sioc->data, sioc->sense, req->errors,
|
||||
req->resid_len);
|
||||
#else
|
||||
sioc->done(sioc->data, sioc->sense, req->errors, req->resid_len);
|
||||
sioc->done(sioc->data, sioc->sense, req->errors, req->data_len);
|
||||
#endif
|
||||
|
||||
kmem_cache_free(scsi_io_context_cache, sioc);
|
||||
@@ -8283,6 +8298,11 @@ int scst_scsi_exec_async(struct scst_cmd *cmd, void *data,
|
||||
int res = 0;
|
||||
struct request_queue *q = cmd->dev->scsi_dev->request_queue;
|
||||
struct request *rq;
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
struct scsi_request *req;
|
||||
#else
|
||||
struct request *req;
|
||||
#endif
|
||||
struct scsi_io_context *sioc;
|
||||
bool reading = !(cmd->data_direction & SCST_DATA_WRITE);
|
||||
gfp_t gfp = cmd->cmd_gfp_mask;
|
||||
@@ -8331,15 +8351,21 @@ int scst_scsi_exec_async(struct scst_cmd *cmd, void *data,
|
||||
sioc->data = data;
|
||||
sioc->done = done;
|
||||
|
||||
rq->cmd_len = cmd_len;
|
||||
if (rq->cmd_len <= BLK_MAX_CDB) {
|
||||
memset(rq->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */
|
||||
memcpy(rq->cmd, cmd->cdb, cmd->cdb_len);
|
||||
} else
|
||||
rq->cmd = cmd->cdb;
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
req = scsi_req(rq);
|
||||
#else
|
||||
req = rq;
|
||||
#endif
|
||||
|
||||
rq->sense = sioc->sense;
|
||||
rq->sense_len = sizeof(sioc->sense);
|
||||
req->cmd_len = cmd_len;
|
||||
if (req->cmd_len <= BLK_MAX_CDB) {
|
||||
memset(req->cmd, 0, BLK_MAX_CDB); /* ATAPI hates garbage after CDB */
|
||||
memcpy(req->cmd, cmd->cdb, cmd->cdb_len);
|
||||
} else
|
||||
req->cmd = cmd->cdb;
|
||||
|
||||
req->sense = sioc->sense;
|
||||
req->sense_len = sizeof(sioc->sense);
|
||||
rq->timeout = cmd->timeout;
|
||||
rq->retries = cmd->retries;
|
||||
rq->end_io_data = sioc;
|
||||
|
||||
@@ -1203,7 +1203,13 @@ void scst_kobject_put_and_wait(struct kobject *kobj, const char *category,
|
||||
goto out_free;
|
||||
|
||||
PRINT_INFO("Waiting for release of sysfs entry for %s %s (%d refs)",
|
||||
category, name ? : "(?)", atomic_read(&kobj->kref.refcount));
|
||||
category, name ? : "(?)",
|
||||
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)
|
||||
kref_read(&kobj->kref)
|
||||
#else
|
||||
atomic_read(&kobj->kref.refcount)
|
||||
#endif
|
||||
);
|
||||
wait_for_completion(c);
|
||||
PRINT_INFO("Finished waiting for release of %s %s sysfs entry",
|
||||
category, name ? : "(?)");
|
||||
|
||||
Reference in New Issue
Block a user