iscsi-scst: Remove support for kernel versions before 3.10

The SCST has dropped support for kernels older than 3.10.0 (RHEL 7 / Centos 7) since SCST v3.6.
This commit is contained in:
Chesnokov Gleb
2021-12-11 18:56:24 +03:00
committed by Gleb Chesnokov
parent c5766b27da
commit 41943ed156
10 changed files with 1 additions and 237 deletions

View File

@@ -501,10 +501,8 @@ int iscsi_add_attr(struct iscsi_target *target,
struct iscsi_attr *tgt_attr;
struct list_head *attrs_list;
const char *name;
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)
#ifdef CONFIG_DEBUG_LOCK_ALLOC
static struct lock_class_key __key;
#endif
#endif
TRACE_ENTRY();
@@ -551,13 +549,8 @@ int iscsi_add_attr(struct iscsi_target *target,
list_add(&tgt_attr->attrs_list_entry, attrs_list);
tgt_attr->attr.attr.name = tgt_attr->name;
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35)
tgt_attr->attr.attr.owner = THIS_MODULE;
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 34)
#ifdef CONFIG_DEBUG_LOCK_ALLOC
tgt_attr->attr.attr.key = &__key;
#endif
#endif
tgt_attr->attr.attr.mode = attr_info->mode & (S_IRUGO | S_IWUGO);
tgt_attr->attr.show = iscsi_attr_show;

View File

@@ -26,13 +26,11 @@
#include "iscsi.h"
#include "digest.h"
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
#if defined(CONFIG_LOCKDEP) && !defined(CONFIG_SCST_PROC)
static struct lock_class_key scst_conn_key;
static struct lockdep_map scst_conn_dep_map =
STATIC_LOCKDEP_MAP_INIT("iscsi_conn_kref", &scst_conn_key);
#endif
#endif
static int print_conn_state(char *p, size_t size, struct iscsi_conn *conn)
{
@@ -132,19 +130,10 @@ static ssize_t iscsi_get_target_ip(struct iscsi_conn *conn,
switch (sk->sk_family) {
case AF_INET:
pos = scnprintf(buf, size,
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
"%u.%u.%u.%u", NIPQUAD(inet_sk(sk)->saddr));
#else
"%pI4", &inet_sk(sk)->inet_saddr);
#endif
break;
#ifdef CONFIG_IPV6
case AF_INET6:
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
pos = scnprintf(buf, size,
"[%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x]",
NIP6(inet6_sk(sk)->saddr));
#else
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0)
pos = scnprintf(buf, size, "[%pI6]", &inet6_sk(sk)->saddr);
#else
@@ -152,7 +141,6 @@ static ssize_t iscsi_get_target_ip(struct iscsi_conn *conn,
#endif
#endif
break;
#endif
default:
pos = scnprintf(buf, size, "Unknown family %d",
sk->sk_family);
@@ -580,18 +568,10 @@ out:
return;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void conn_nop_in_delayed_work_fn(void *p)
#else
static void conn_nop_in_delayed_work_fn(struct work_struct *work)
#endif
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
struct iscsi_conn *conn = p;
#else
struct iscsi_conn *conn = container_of(work, struct iscsi_conn,
nop_in_delayed_work.work);
#endif
unsigned long next_timeout = 0;
TRACE_ENTRY();
@@ -889,13 +869,8 @@ int iscsi_init_conn(struct iscsi_session *session,
conn->conn_thr_pool = session->sess_thr_pool;
conn->nop_in_ttt = 0;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20))
INIT_DELAYED_WORK(&conn->nop_in_delayed_work,
conn_nop_in_delayed_work_fn);
#else
INIT_WORK(&conn->nop_in_delayed_work, conn_nop_in_delayed_work_fn,
conn);
#endif
conn->last_rcv_time = jiffies;
conn->data_rsp_timeout = session->tgt_params.rsp_timeout * HZ;
conn->nop_in_interval = session->tgt_params.nop_in_interval * HZ;

View File

@@ -49,11 +49,7 @@ static int event_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
{
u32 pid;
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0))
pid = NETLINK_CB(skb).pid;
#else
pid = NETLINK_CB(skb).portid;
#endif
WARN_ON(pid == 0);
iscsid_pid = pid;
@@ -61,11 +57,7 @@ static int event_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
return 0;
}
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24))
static int event_recv_skb(struct sk_buff *skb)
#else
static void event_recv_skb(struct sk_buff *skb)
#endif
{
int err;
struct nlmsghdr *nlh;
@@ -87,27 +79,9 @@ static void event_recv_skb(struct sk_buff *skb)
}
out:
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24))
return 0;
#else
return;
#endif
}
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24))
static void event_recv(struct sock *sk, int length)
{
struct sk_buff *skb;
while ((skb = skb_dequeue(&sk->sk_receive_queue))) {
if (event_recv_skb(skb) && skb->len)
skb_queue_head(&sk->sk_receive_queue, skb);
else
kfree_skb(skb);
}
}
#endif
/* event_mutex supposed to be held */
static int __event_send(const void *buf, int buf_len)
{
@@ -196,30 +170,14 @@ int __init event_init(void)
{
iscsi_net_ns = kobj_ns_grab_current(KOBJ_NS_TYPE_NET);
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22))
nl = netlink_kernel_create(NETLINK_ISCSI_SCST, 1, event_recv,
THIS_MODULE);
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24))
nl = netlink_kernel_create(NETLINK_ISCSI_SCST, 1, event_recv, NULL,
THIS_MODULE);
#elif (LINUX_VERSION_CODE < KERNEL_VERSION(3, 6, 0))
nl = netlink_kernel_create(iscsi_net_ns, NETLINK_ISCSI_SCST, 1,
event_recv_skb, NULL, THIS_MODULE);
#else
{
struct netlink_kernel_cfg cfg = {
.input = event_recv_skb,
.groups = 1,
};
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0))
nl = netlink_kernel_create(iscsi_net_ns, NETLINK_ISCSI_SCST,
THIS_MODULE, &cfg);
#else
nl = netlink_kernel_create(iscsi_net_ns, NETLINK_ISCSI_SCST,
&cfg);
#endif
}
#endif
if (!nl)
goto drop_ns;
@@ -234,12 +192,7 @@ drop_ns:
void event_exit(void)
{
#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 24))
if (nl)
sock_release(nl->sk_socket);
#else
netlink_kernel_release(nl);
#endif
kobj_ns_drop(KOBJ_NS_TYPE_NET, iscsi_net_ns);
iscsi_net_ns = NULL;
}

View File

@@ -2469,18 +2469,10 @@ struct iscsi_cmnd_abort_params {
static mempool_t *iscsi_cmnd_abort_mempool;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void iscsi_cmnd_abort_fn(void *ctx)
#else
static void iscsi_cmnd_abort_fn(struct work_struct *work)
#endif
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
struct iscsi_cmnd_abort_params *params = ctx;
#else
struct iscsi_cmnd_abort_params *params = container_of(work,
struct iscsi_cmnd_abort_params, iscsi_cmnd_abort_work);
#endif
struct scst_cmd *scst_cmd = params->scst_cmd;
struct iscsi_session *session = scst_sess_get_tgt_priv(scst_cmd->sess);
struct iscsi_conn *conn;
@@ -2540,11 +2532,7 @@ static void iscsi_on_abort_cmd(struct scst_cmd *scst_cmd)
}
memset(params, 0, sizeof(*params));
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
INIT_WORK(&params->iscsi_cmnd_abort_work, iscsi_cmnd_abort_fn, params);
#else
INIT_WORK(&params->iscsi_cmnd_abort_work, iscsi_cmnd_abort_fn);
#endif
params->scst_cmd = scst_cmd;
scst_cmd_get(scst_cmd);
@@ -3278,19 +3266,10 @@ static ssize_t iscsi_tcp_get_initiator_ip(struct iscsi_conn *conn,
switch (sk->sk_family) {
case AF_INET:
pos = scnprintf(buf, size,
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
"%u.%u.%u.%u", NIPQUAD(inet_sk(sk)->daddr));
#else
"%pI4", &inet_sk(sk)->inet_daddr);
#endif
break;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case AF_INET6:
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
pos = scnprintf(buf, size,
"[%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x]",
NIP6(inet6_sk(sk)->daddr));
#else
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 13, 0) && \
(!defined(RHEL_MAJOR) || RHEL_MAJOR -0 < 7)
pos = scnprintf(buf, size, "[%pI6]", &inet6_sk(sk)->daddr);
@@ -3299,7 +3278,6 @@ static ssize_t iscsi_tcp_get_initiator_ip(struct iscsi_conn *conn,
#endif
#endif
break;
#endif
default:
pos = scnprintf(buf, size, "Unknown family %d",
sk->sk_family);

View File

@@ -130,11 +130,7 @@ struct iscsi_target {
};
#define ISCSI_HASH_ORDER 8
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 25)
#define cmnd_hashfn(itt) hash_32(itt, ISCSI_HASH_ORDER)
#else
#define cmnd_hashfn(itt) hash_long(itt, ISCSI_HASH_ORDER)
#endif
struct iscsi_session {
struct iscsi_target *target;
@@ -315,11 +311,7 @@ struct iscsi_conn {
/* Doesn't need any protection */
u16 cid;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20))
struct delayed_work nop_in_delayed_work;
#else
struct work_struct nop_in_delayed_work;
#endif
struct work_struct close_work;
unsigned int nop_in_interval; /* in jiffies */
unsigned int nop_in_timeout; /* in jiffies */

View File

@@ -580,18 +580,10 @@ static const char *wr_status_str(enum ib_wc_status status)
}
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void isert_discon_do_work(void *ctx)
#else
static void isert_discon_do_work(struct work_struct *work)
#endif
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
struct isert_conn *isert_conn = ctx;
#else
struct isert_conn *isert_conn =
container_of(work, struct isert_conn, discon_work);
#endif
/* notify upper layer */
isert_connection_closed(&isert_conn->iscsi);
@@ -599,53 +591,28 @@ static void isert_discon_do_work(struct work_struct *work)
static void isert_sched_discon(struct isert_conn *isert_conn)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
INIT_WORK(&isert_conn->discon_work, isert_discon_do_work, isert_conn);
#else
INIT_WORK(&isert_conn->discon_work, isert_discon_do_work);
#endif
isert_conn_queue_work(&isert_conn->discon_work);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void isert_conn_drained_do_work(void *ctx)
#else
static void isert_conn_drained_do_work(struct work_struct *work)
#endif
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
struct isert_conn *isert_conn = ctx;
#else
struct isert_conn *isert_conn =
container_of(work, struct isert_conn, drain_work);
#endif
isert_put_conn(isert_conn);
}
static void isert_sched_conn_drained(struct isert_conn *isert_conn)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
INIT_WORK(&isert_conn->drain_work, isert_conn_drained_do_work,
isert_conn);
#else
INIT_WORK(&isert_conn->drain_work, isert_conn_drained_do_work);
#endif
isert_conn_queue_work(&isert_conn->drain_work);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void isert_conn_closed_do_work(void *ctx)
#else
static void isert_conn_closed_do_work(struct work_struct *work)
#endif
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
struct isert_conn *isert_conn = ctx;
#else
struct isert_conn *isert_conn =
container_of(work, struct isert_conn, close_work);
#endif
if (!test_bit(ISERT_CONNECTION_ABORTED, &isert_conn->flags))
isert_connection_abort(&isert_conn->iscsi);
@@ -655,38 +622,21 @@ static void isert_conn_closed_do_work(struct work_struct *work)
static void isert_sched_conn_closed(struct isert_conn *isert_conn)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
INIT_WORK(&isert_conn->close_work, isert_conn_closed_do_work,
isert_conn);
#else
INIT_WORK(&isert_conn->close_work, isert_conn_closed_do_work);
#endif
isert_conn_queue_work(&isert_conn->close_work);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void isert_release_work(void *ctx)
#else
static void isert_release_work(struct work_struct *work)
#endif
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
struct isert_conn *isert_conn = ctx;
#else
struct isert_conn *isert_conn =
container_of(work, struct isert_conn, release_work);
#endif
isert_put_conn(isert_conn);
}
void isert_sched_conn_free(struct isert_conn *isert_conn)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
INIT_WORK(&isert_conn->release_work, isert_release_work, isert_conn);
#else
INIT_WORK(&isert_conn->release_work, isert_release_work);
#endif
isert_conn_queue_work(&isert_conn->release_work);
}
@@ -789,18 +739,10 @@ static int isert_poll_cq(struct isert_cq *cq)
}
/* callback function for isert_dev->[cq]->cq_comp_work */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) && \
!defined(BACKPORT_LINUX_WORKQUEUE_TO_2_6_19)
/* A vanilla 2.6.19 or older kernel without backported OFED kernel headers. */
static void isert_cq_comp_work_cb(void *ctx)
{
struct isert_cq *cq_desc = ctx;
#else
static void isert_cq_comp_work_cb(struct work_struct *work)
{
struct isert_cq *cq_desc =
container_of(work, struct isert_cq, cq_comp_work);
#endif
int ret;
TRACE_ENTRY();
@@ -829,12 +771,8 @@ static void isert_cq_comp_handler(struct ib_cq *cq, void *context)
{
struct isert_cq *cq_desc = context;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
queue_work(cq_desc->cq_workqueue, &cq_desc->cq_comp_work);
#else
queue_work_on(smp_processor_id(), cq_desc->cq_workqueue,
&cq_desc->cq_comp_work);
#endif
}
static const char *ib_event_type_str(enum ib_event_type ev_type)
@@ -1038,26 +976,12 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
cq_desc->dev = isert_dev;
cq_desc->idx = i;
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
INIT_WORK(&cq_desc->cq_comp_work, isert_cq_comp_work_cb, NULL);
#else
INIT_WORK(&cq_desc->cq_comp_work, isert_cq_comp_work_cb);
#endif
snprintf(wq_name, sizeof(wq_name), "isert_cq_%p", cq_desc);
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 36)
cq_desc->cq_workqueue = create_singlethread_workqueue(wq_name);
#else
#if LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 36)
cq_desc->cq_workqueue = alloc_workqueue(wq_name,
WQ_CPU_INTENSIVE|
WQ_RESCUER, 1);
#else
cq_desc->cq_workqueue = alloc_workqueue(wq_name,
WQ_CPU_INTENSIVE|
WQ_MEM_RECLAIM, 1);
#endif
#endif
if (unlikely(!cq_desc->cq_workqueue)) {
PRINT_ERROR("Failed to alloc iser cq work queue for dev:%s",
ib_dev->name);
@@ -1160,15 +1084,7 @@ static void isert_device_release(struct isert_device *isert_dev)
for (i = 0; i < isert_dev->num_cqs; ++i) {
struct isert_cq *cq_desc = &isert_dev->cq_desc[i];
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 22)
/*
* cancel_work_sync() was introduced in 2.6.22. We can
* only wait until all scheduled work is done.
*/
flush_workqueue(cq_desc->cq_workqueue);
#else
cancel_work_sync(&cq_desc->cq_comp_work);
#endif
ib_destroy_cq(cq_desc->cq);
destroy_workqueue(cq_desc->cq_workqueue);
@@ -1810,10 +1726,7 @@ isert_setup_id(struct isert_portal *portal)
sa = (struct sockaddr *)&portal->addr;
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) && \
(!defined(RHEL_MAJOR) || RHEL_MAJOR -0 <= 5)
id = rdma_create_id(isert_cm_evt_handler, portal, RDMA_PS_TCP);
#elif !RDMA_CREATE_ID_TAKES_NET_ARG
#if !RDMA_CREATE_ID_TAKES_NET_ARG
id = rdma_create_id(isert_cm_evt_handler, portal, RDMA_PS_TCP,
IB_QPT_RC);
#else
@@ -1826,7 +1739,6 @@ isert_setup_id(struct isert_portal *portal)
goto out;
}
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 6, 0)
/*
* Allow both IPv4 and IPv6 sockets to bind a single port
* at the same time.
@@ -1836,7 +1748,6 @@ isert_setup_id(struct isert_portal *portal)
PRINT_ERROR("Failed to set afonly, err:%d", ret);
goto out_id;
}
#endif
ret = rdma_bind_addr(id, sa);
if (ret) {

View File

@@ -432,25 +432,13 @@ static ssize_t isert_get_initiator_ip(struct iscsi_conn *conn,
switch (ss.ss_family) {
case AF_INET:
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 33)
pos = scnprintf(buf, size,
"%u.%u.%u.%u",
NIPQUAD(((struct sockaddr_in *)&ss)->sin_addr.s_addr));
#else
pos = scnprintf(buf, size,
"%pI4", &((struct sockaddr_in *)&ss)->sin_addr.s_addr);
#endif
break;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case AF_INET6:
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
pos = scnprintf(buf, size,
"[%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x]",
NIP6(((struct sockaddr_in6 *)&ss)->sin6_addr));
#else
pos = scnprintf(buf, size, "[%pI6]",
&((struct sockaddr_in6 *)&ss)->sin6_addr);
#endif
break;
#endif
default:

View File

@@ -44,11 +44,7 @@
#include <linux/wait.h>
#include <linux/init.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 37)
#include <asm/atomic.h>
#else
#include <linux/atomic.h>
#endif
#ifdef INSIDE_KERNEL_TREE
#include <scst/isert_scst.h>

View File

@@ -42,11 +42,7 @@
#ifndef INSIDE_KERNEL_TREE
#include <linux/version.h>
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 20)
#include <linux/freezer.h>
#else
#define wait_event_freezable(wq, cond) ({ wait_event(wq, cond); 0; })
#endif
#include <linux/file.h>
#include "isert_dbg.h"
#include "../iscsi.h"
@@ -119,18 +115,10 @@ static void isert_dev_release(struct isert_conn_dev *dev)
mutex_unlock(&isert_listen_dev.conn_lock);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
static void isert_close_conn_fn(void *ctx)
#else
static void isert_close_conn_fn(struct work_struct *work)
#endif
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
struct iscsi_conn *conn = ctx;
#else
struct iscsi_conn *conn = container_of(work,
struct iscsi_conn, close_work);
#endif
isert_close_connection(conn);
}
@@ -166,11 +154,7 @@ static int add_new_connection(struct isert_listener_dev *dev,
goto out;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
INIT_WORK(&conn->close_work, isert_close_conn_fn, conn);
#else
INIT_WORK(&conn->close_work, isert_close_conn_fn);
#endif
timer_setup(&conn_dev->tmo_timer, isert_conn_timer_fn, 0);
conn_dev->tmo_timer.expires = jiffies + 60 * HZ;
@@ -953,9 +937,7 @@ static void __init isert_setup_cdev(struct isert_conn_dev *dev,
index);
dev->dev = device_create(isert_class, NULL, dev->devno,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
NULL,
#endif
ISER_CONN_DEV_PREFIX"%d", index);
TRACE_EXIT();
@@ -983,9 +965,7 @@ static void __init isert_setup_listener_cdev(struct isert_listener_dev *dev)
PRINT_ERROR("Error %d adding isert_scst", err);
dev->dev = device_create(isert_class, NULL, dev->devno,
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
NULL,
#endif
"isert_scst");
TRACE_EXIT();

View File

@@ -17,9 +17,7 @@
#ifndef INSIDE_KERNEL_TREE
#include <linux/version.h>
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
#include <linux/export.h>
#endif
#include "iscsi_trace_flag.h"
#include "iscsi.h"