packages: iscsitarget/2.6.33.patch (NEW) - patch for kernels 2.6.33

zbyniu zbyniu at pld-linux.org
Tue Apr 6 15:24:02 CEST 2010


Author: zbyniu                       Date: Tue Apr  6 13:24:02 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- patch for kernels 2.6.33 

---- Files affected:
packages/iscsitarget:
   2.6.33.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/iscsitarget/2.6.33.patch
diff -u /dev/null packages/iscsitarget/2.6.33.patch:1.1
--- /dev/null	Tue Apr  6 15:24:02 2010
+++ packages/iscsitarget/2.6.33.patch	Tue Apr  6 15:23:56 2010
@@ -0,0 +1,284 @@
+diff -uprN iscsitarget-1.4.19./kernel/conn.c iscsitarget-1.4.19/kernel/conn.c
+--- iscsitarget-1.4.19./kernel/conn.c	2009-10-08 20:32:02.000000000 +0200
++++ iscsitarget-1.4.19/kernel/conn.c	2010-04-06 15:09:13.374954373 +0200
+@@ -7,6 +7,7 @@
+ #include <linux/file.h>
+ #include <linux/ip.h>
+ #include <net/tcp.h>
++#include <linux/version.h>
+ 
+ #include "iscsi.h"
+ #include "iscsi_dbg.h"
+@@ -43,7 +44,11 @@ void conn_info_show(struct seq_file *seq
+ 		switch (sk->sk_family) {
+ 		case AF_INET:
+ 			snprintf(buf, sizeof(buf),
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
+ 				 "%u.%u.%u.%u", NIPQUAD(inet_sk(sk)->daddr));
++#else
++				 "%u.%u.%u.%u", NIPQUAD(inet_sk(sk)->inet_daddr));
++#endif
+ 			break;
+ 		case AF_INET6:
+ 			snprintf(buf, sizeof(buf), "[%pI6]",
+diff -uprN iscsitarget-1.4.19./kernel/conn.c~ iscsitarget-1.4.19/kernel/conn.c~
+--- iscsitarget-1.4.19./kernel/conn.c~	1970-01-01 01:00:00.000000000 +0100
++++ iscsitarget-1.4.19/kernel/conn.c~	2010-04-06 15:08:32.000000000 +0200
+@@ -0,0 +1,257 @@
++/*
++ * Copyright (C) 2002-2003 Ardis Technolgies <roman at ardistech.com>
++ *
++ * Released under the terms of the GNU GPL v2.0.
++ */
++
++#include <linux/file.h>
++#include <linux/ip.h>
++#include <net/tcp.h>
++
++#include "iscsi.h"
++#include "iscsi_dbg.h"
++#include "digest.h"
++
++static void print_conn_state(char *p, size_t size, unsigned long state)
++{
++	if (test_bit(CONN_ACTIVE, &state))
++		snprintf(p, size, "%s", "active");
++	else if (test_bit(CONN_CLOSING, &state))
++		snprintf(p, size, "%s", "closing");
++	else
++		snprintf(p, size, "%s", "unknown");
++}
++
++static void print_digest_state(char *p, size_t size, unsigned long flags)
++{
++	if (DIGEST_NONE & flags)
++		snprintf(p, size, "%s", "none");
++	else if (DIGEST_CRC32C & flags)
++		snprintf(p, size, "%s", "crc32c");
++	else
++		snprintf(p, size, "%s", "unknown");
++}
++
++void conn_info_show(struct seq_file *seq, struct iscsi_session *session)
++{
++	struct iscsi_conn *conn;
++	struct sock *sk;
++	char buf[64];
++
++	list_for_each_entry(conn, &session->conn_list, list) {
++		sk = conn->sock->sk;
++		switch (sk->sk_family) {
++		case AF_INET:
++			snprintf(buf, sizeof(buf),
++#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
++				 "%u.%u.%u.%u", NIPQUAD(inet_sk(sk)->daddr));
++#else
++				 "%u.%u.%u.%u", NIPQUAD(inet_sk(sk)->inet_daddr));
++#endif
++			break;
++		case AF_INET6:
++			snprintf(buf, sizeof(buf), "[%pI6]",
++				 &inet6_sk(sk)->daddr);
++			break;
++		default:
++			break;
++		}
++		seq_printf(seq, "\t\tcid:%u ip:%s ", conn->cid, buf);
++		print_conn_state(buf, sizeof(buf), conn->state);
++		seq_printf(seq, "state:%s ", buf);
++		print_digest_state(buf, sizeof(buf), conn->hdigest_type);
++		seq_printf(seq, "hd:%s ", buf);
++		print_digest_state(buf, sizeof(buf), conn->ddigest_type);
++		seq_printf(seq, "dd:%s\n", buf);
++	}
++}
++
++struct iscsi_conn *conn_lookup(struct iscsi_session *session, u16 cid)
++{
++	struct iscsi_conn *conn;
++
++	list_for_each_entry(conn, &session->conn_list, list) {
++		if (conn->cid == cid)
++			return conn;
++	}
++	return NULL;
++}
++
++static void iet_state_change(struct sock *sk)
++{
++	struct iscsi_conn *conn = sk->sk_user_data;
++	struct iscsi_target *target = conn->session->target;
++
++	if (sk->sk_state != TCP_ESTABLISHED)
++		conn_close(conn);
++	else
++		nthread_wakeup(target);
++
++	target->nthread_info.old_state_change(sk);
++}
++
++static void iet_data_ready(struct sock *sk, int len)
++{
++	struct iscsi_conn *conn = sk->sk_user_data;
++	struct iscsi_target *target = conn->session->target;
++
++	nthread_wakeup(target);
++	target->nthread_info.old_data_ready(sk, len);
++}
++
++/*
++ * @locking: grabs the target's nthread_lock to protect it from races with
++ * set_conn_wspace_wait()
++ */
++static void iet_write_space(struct sock *sk)
++{
++	struct iscsi_conn *conn = sk->sk_user_data;
++	struct network_thread_info *info = &conn->session->target->nthread_info;
++
++	spin_lock_bh(&info->nthread_lock);
++
++	if (sk_stream_wspace(sk) >= sk_stream_min_wspace(sk) &&
++	    test_bit(CONN_WSPACE_WAIT, &conn->state)) {
++		clear_bit(CONN_WSPACE_WAIT, &conn->state);
++		__nthread_wakeup(info);
++	}
++
++	spin_unlock_bh(&info->nthread_lock);
++
++	info->old_write_space(sk);
++}
++
++static void iet_socket_bind(struct iscsi_conn *conn)
++{
++	int opt = 1;
++	mm_segment_t oldfs;
++	struct iscsi_session *session = conn->session;
++	struct iscsi_target *target = session->target;
++
++	dprintk(D_GENERIC, "%llu\n", (unsigned long long) session->sid);
++
++	conn->sock = SOCKET_I(conn->file->f_dentry->d_inode);
++	conn->sock->sk->sk_user_data = conn;
++
++	write_lock_bh(&conn->sock->sk->sk_callback_lock);
++	target->nthread_info.old_state_change = conn->sock->sk->sk_state_change;
++	conn->sock->sk->sk_state_change = iet_state_change;
++
++	target->nthread_info.old_data_ready = conn->sock->sk->sk_data_ready;
++	conn->sock->sk->sk_data_ready = iet_data_ready;
++
++	target->nthread_info.old_write_space = conn->sock->sk->sk_write_space;
++	conn->sock->sk->sk_write_space = iet_write_space;
++	write_unlock_bh(&conn->sock->sk->sk_callback_lock);
++
++	oldfs = get_fs();
++	set_fs(get_ds());
++	conn->sock->ops->setsockopt(conn->sock, SOL_TCP, TCP_NODELAY, (void *)&opt, sizeof(opt));
++	set_fs(oldfs);
++}
++
++int conn_free(struct iscsi_conn *conn)
++{
++	dprintk(D_GENERIC, "%p %#Lx %u\n", conn->session,
++		(unsigned long long) conn->session->sid, conn->cid);
++
++	assert(atomic_read(&conn->nr_cmnds) == 0);
++	assert(list_empty(&conn->pdu_list));
++	assert(list_empty(&conn->write_list));
++
++	list_del(&conn->list);
++	list_del(&conn->poll_list);
++
++	del_timer_sync(&conn->nop_timer);
++	digest_cleanup(conn);
++	kfree(conn);
++
++	return 0;
++}
++
++static int iet_conn_alloc(struct iscsi_session *session, struct conn_info *info)
++{
++	struct iscsi_conn *conn;
++
++	dprintk(D_SETUP, "%#Lx:%u\n", (unsigned long long) session->sid, info->cid);
++
++	conn = kzalloc(sizeof(*conn), GFP_KERNEL);
++	if (!conn)
++		return -ENOMEM;
++
++	conn->session = session;
++	conn->cid = info->cid;
++	conn->stat_sn = info->stat_sn;
++	conn->exp_stat_sn = info->exp_stat_sn;
++
++	conn->hdigest_type = info->header_digest;
++	conn->ddigest_type = info->data_digest;
++	if (digest_init(conn) < 0) {
++		kfree(conn);
++		return -ENOMEM;
++	}
++
++	spin_lock_init(&conn->list_lock);
++	atomic_set(&conn->nr_cmnds, 0);
++	atomic_set(&conn->nr_busy_cmnds, 0);
++	INIT_LIST_HEAD(&conn->pdu_list);
++	INIT_LIST_HEAD(&conn->write_list);
++	INIT_LIST_HEAD(&conn->poll_list);
++	init_timer(&conn->nop_timer);
++
++	list_add(&conn->list, &session->conn_list);
++
++	set_bit(CONN_ACTIVE, &conn->state);
++
++	conn->file = fget(info->fd);
++	iet_socket_bind(conn);
++
++	list_add(&conn->poll_list, &session->target->nthread_info.active_conns);
++
++	nthread_wakeup(conn->session->target);
++
++	return 0;
++}
++
++void conn_close(struct iscsi_conn *conn)
++{
++	if (test_and_clear_bit(CONN_ACTIVE, &conn->state))
++		set_bit(CONN_CLOSING, &conn->state);
++
++	nthread_wakeup(conn->session->target);
++}
++
++int conn_add(struct iscsi_session *session, struct conn_info *info)
++{
++	struct iscsi_conn *conn;
++	int err = -EEXIST;
++
++	conn = conn_lookup(session, info->cid);
++	if (conn)
++		return err;
++
++	return iet_conn_alloc(session, info);
++}
++
++int conn_del(struct iscsi_session *session, struct conn_info *info)
++{
++	struct iscsi_conn *conn;
++	int err = -EEXIST;
++
++	conn = conn_lookup(session, info->cid);
++	if (!conn)
++		return err;
++
++	conn_close(conn);
++
++	return 0;
++}
++
++/* target_lock() supposed to be held */
++void conn_del_all(struct iscsi_session *session)
++{
++	struct iscsi_conn *conn;
++
++	list_for_each_entry(conn, &session->conn_list, list)
++		conn_close(conn);
++}
================================================================


More information about the pld-cvs-commit mailing list