Merge with trunk r6854

This commit is contained in:
Bart Van Assche
2016-03-27 16:05:28 -07:00
152 changed files with 1877 additions and 869 deletions
+2 -2
View File
@@ -1,8 +1,8 @@
#
# Common makefile for SCSI target mid-level and its drivers
#
# Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
# Copyright (C) 2007 - 2015 SanDisk Corporation
# Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
# Copyright (C) 2007 - 2016 SanDisk Corporation
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
+1
View File
@@ -20,3 +20,4 @@ SRPT 1.0.0 450
3.0.x branch start 5534, which is a copy of trunk r5533
3.0.0 5815 on the 3.0.x branch
3.1.x branch start 6591, which is a copy of trunk r6590
3.1.0 6783 on the 3.1.x branch
+2 -2
View File
@@ -36,9 +36,9 @@ rtf: $(RTFS)
$(COMMAND)rtf $(<)
clean:
mv "Using the DLM as a Distributed In-Memory Database.pdf" "Using the DLM as a Distributed In-Memory Database.pdf_"
-mv "Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf" "Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf_"
rm -f *.txt *.html *.tex *.dvi *.ps *.pdf *.info *.lyx *.rtf
mv "Using the DLM as a Distributed In-Memory Database.pdf_" "Using the DLM as a Distributed In-Memory Database.pdf"
-mv "Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf_" "Using-the-DLM-as-a-Distributed-In-Memory-Database.pdf"
extraclean: clean
rm -f *.orig *.rej
+1 -1
View File
@@ -10,7 +10,7 @@ SCST user space device handler interface description
<name>Vladislav Bolkhovitin</name>
</author>
<date>Version 3.0.0</date>
<date>Version 3.2.0</date>
<toc>
+1 -1
View File
@@ -3,7 +3,7 @@
# Based on ../mvsas_tgt/Makefile
#
# Copyright (C) 2006 - 2008 Jacky Feng <jfeng@marvell.com>
# Copyright (C) 2011 - 2015 Bart Van Assche <bvanassche@acm.org>
# Copyright (C) 2011 - 2016 Bart Van Assche <bvanassche@acm.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
-2
View File
@@ -13,8 +13,6 @@
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
* $Id$
*/
#ifndef __SCSI_FCST_H__
#define __SCSI_FCST_H__
+3 -3
View File
@@ -330,7 +330,7 @@ int ft_send_response(struct scst_cmd *cmd)
* For bi-directional comands, the bi_resid is for the read direction.
*/
if (dir & SCST_DATA_WRITE)
resid = (signed)scst_cmd_get_bufflen(cmd) -
resid = (signed int)scst_cmd_get_bufflen(cmd) -
fcmd->write_data_len;
if (dir & SCST_DATA_READ) {
error = ft_send_read_data(cmd);
@@ -340,12 +340,12 @@ int ft_send_response(struct scst_cmd *cmd)
}
if (dir == SCST_DATA_BIDI) {
bi_resid = (signed)scst_cmd_get_out_bufflen(cmd) -
bi_resid = (signed int)scst_cmd_get_out_bufflen(cmd) -
scst_cmd_get_resp_data_len(cmd);
if (bi_resid)
len += sizeof(__be32);
} else
resid = (signed)scst_cmd_get_bufflen(cmd) -
resid = (signed int)scst_cmd_get_bufflen(cmd) -
scst_cmd_get_resp_data_len(cmd);
}
+1 -1
View File
@@ -977,7 +977,7 @@ config SCSI_IBMVSCSIS
The userspace component needed to initialize the driver and
documentation can be found:
http://stgt.berlios.de/
http://stgt.sourceforge.net/
To compile this driver as a module, choose M here: the
module will be called ibmvstgt.
+1 -1
View File
@@ -969,7 +969,7 @@ config SCSI_IBMVSCSIS
The userspace component needed to initialize the driver and
documentation can be found:
http://stgt.berlios.de/
http://stgt.sourceforge.net/
To compile this driver as a module, choose M here: the
module will be called ibmvstgt.
+1 -1
View File
@@ -977,7 +977,7 @@ config SCSI_IBMVSCSIS
The userspace component needed to initialize the driver and
documentation can be found:
http://stgt.berlios.de/
http://stgt.sourceforge.net/
To compile this driver as a module, choose M here: the
module will be called ibmvstgt.
+4 -1
View File
@@ -100,12 +100,15 @@ else
endif
endif
CREATE_CQ_FLAG = $(shell $(MAKE) -C $(KDIR) SUBDIRS=$(shell pwd)/conftest/create_cq PRE_CFLAGS="$(OFED_CFLAGS) -Werror" >/dev/null 2>&1 && echo -DIB_CREATE_CQ_HAS_INIT_ATTR)
PRE_CFLAGS=$(OFED_CFLAGS) $(CREATE_CQ_FLAG) -DOFED_FLAVOR=$(OFED_FLAVOR)
mods: Modules.symvers Module.symvers
$(MAKE) -C $(KDIR) SCST_INC_DIR=$(SCST_INC_DIR) SUBDIRS=$(KMOD) modules
if $(INFINIBAND_ENABLED); then \
echo " Building against $(OFED_FLAVOR) InfiniBand kernel headers."; \
$(MAKE) -C $(KDIR) SCST_INC_DIR=$(SCST_INC_DIR) SUBDIRS=$(ISERTMOD) \
PRE_CFLAGS="$(OFED_CFLAGS) -DOFED_FLAVOR=$(OFED_FLAVOR)" \
PRE_CFLAGS="$(PRE_CFLAGS)" \
KBUILD_EXTRA_SYMBOLS=$(ISER_SYMVERS) modules; \
fi
+3
View File
@@ -0,0 +1,3 @@
LINUXINCLUDE := $(PRE_CFLAGS) $(LINUXINCLUDE)
obj-m += create_cq.o
+13
View File
@@ -0,0 +1,13 @@
#include <linux/module.h>
#include <rdma/ib_verbs.h>
static int modinit(void)
{
struct ib_cq *q;
q = ib_create_cq(NULL, NULL, NULL, NULL, NULL);
return q != 0;
}
module_init(modinit);
+7
View File
@@ -85,6 +85,13 @@ work perfectly)
5. Build SCST
! Important: SCST 3.1.x and trunk: Gentoo Hardened kernels uses
Grsec/PaX patchset. If you happen to use one of those kernels
(sys-kernel/hardened-sources) you need to change every call
"object_is_on_stack" to "object_starts_on_stack" to compile SCST
successfully. At the time of writing this there is a single such call
in scst/src/scst_lib.c
cd /root/scst
make 2perf
make scst scst_install
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+2 -2
View File
@@ -1,8 +1,8 @@
#
# Makefile for the kernel part of iSCSI-SCST.
#
# Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
# Copyright (C) 2007 - 2015 SanDisk Corporation
# Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
# Copyright (C) 2007 - 2016 SanDisk Corporation
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
+9 -9
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2004 - 2005 FUJITA Tomonori <tomof@acm.org>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -31,13 +31,13 @@ int ctr_open_state;
#define ISCSI_PROC_LOG_ENTRY_NAME "trace_level"
static struct scst_trace_log iscsi_local_trace_tbl[] = {
{ TRACE_D_WRITE, "d_write" },
{ TRACE_CONN_OC, "conn" },
{ TRACE_CONN_OC_DBG, "conn_dbg" },
{ TRACE_D_IOV, "iov" },
{ TRACE_D_DUMP_PDU, "pdu" },
{ TRACE_NET_PG, "net_page" },
{ 0, NULL }
{ TRACE_D_WRITE, "d_write" },
{ TRACE_CONN_OC, "conn" },
{ TRACE_CONN_OC_DBG, "conn_dbg" },
{ TRACE_D_IOV, "iov" },
{ TRACE_D_DUMP_PDU, "pdu" },
{ TRACE_NET_PG, "net_page" },
{ 0, NULL }
};
static int iscsi_log_info_show(struct seq_file *seq, void *v)
+4 -4
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -103,7 +103,7 @@ void conn_info_show(struct seq_file *seq, struct iscsi_session *session)
switch (sk->sk_family) {
case AF_INET:
snprintf(buf, sizeof(buf),
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,33)
#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);
@@ -111,7 +111,7 @@ void conn_info_show(struct seq_file *seq, struct iscsi_session *session)
break;
#if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
case AF_INET6:
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 29)
snprintf(buf, sizeof(buf),
"[%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x]",
NIP6(inet6_sk(sk)->daddr));
+2 -2
View File
@@ -3,8 +3,8 @@
*
* Copyright (C) 2004 - 2006 Xiranet Communications GmbH
* <arne.redlich@xiranet.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+2 -2
View File
@@ -2,8 +2,8 @@
* iSCSI digest handling.
*
* Copyright (C) 2004 Xiranet Communications GmbH <arne.redlich@xiranet.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+2 -2
View File
@@ -2,8 +2,8 @@
* Event notification code.
*
* Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+4
View File
@@ -98,7 +98,11 @@ struct isert_wr {
struct ib_sge *sge_list;
union {
struct ib_recv_wr recv_wr;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
struct ib_send_wr send_wr;
#else
struct ib_rdma_wr send_wr;
#endif
};
} ____cacheline_aligned;
+19
View File
@@ -238,9 +238,14 @@ int isert_wr_init(struct isert_wr *wr,
buff_offset = -EFAULT;
goto out;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
wr->send_wr.wr.rdma.remote_addr = pdu->rem_write_va +
buff_offset;
wr->send_wr.wr.rdma.rkey = pdu->rem_write_stag;
#else
wr->send_wr.remote_addr = pdu->rem_write_va + buff_offset;
wr->send_wr.rkey = pdu->rem_write_stag;
#endif
break;
case ISER_WR_RDMA_WRITE:
send_wr_op = IB_WR_RDMA_WRITE;
@@ -250,9 +255,14 @@ int isert_wr_init(struct isert_wr *wr,
buff_offset = -EFAULT;
goto out;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
wr->send_wr.wr.rdma.remote_addr = pdu->rem_read_va +
buff_offset;
wr->send_wr.wr.rdma.rkey = pdu->rem_read_stag;
#else
wr->send_wr.remote_addr = pdu->rem_read_va + buff_offset;
wr->send_wr.rkey = pdu->rem_read_stag;
#endif
break;
default:
BUG();
@@ -278,12 +288,21 @@ int isert_wr_init(struct isert_wr *wr,
wr->recv_wr.sg_list = wr->sge_list;
wr->recv_wr.num_sge = sg_cnt;
} else {
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
wr->send_wr.next = NULL;
wr->send_wr.wr_id = _ptr_to_u64(wr);
wr->send_wr.sg_list = wr->sge_list;
wr->send_wr.num_sge = sg_cnt;
wr->send_wr.opcode = send_wr_op;
wr->send_wr.send_flags = send_flags;
#else
wr->send_wr.wr.next = NULL;
wr->send_wr.wr.wr_id = _ptr_to_u64(wr);
wr->send_wr.wr.sg_list = wr->sge_list;
wr->send_wr.wr.num_sge = sg_cnt;
wr->send_wr.wr.opcode = send_wr_op;
wr->send_wr.wr.send_flags = send_flags;
#endif
}
out:
+23
View File
@@ -214,7 +214,11 @@ out:
static inline void isert_link_send_wrs(struct isert_wr *from_wr,
struct isert_wr *to_wr)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
from_wr->send_wr.next = &to_wr->send_wr;
#else
from_wr->send_wr.wr.next = &to_wr->send_wr.wr;
#endif
}
static inline void isert_link_send_pdu_wrs(struct isert_cmnd *from_pdu,
@@ -222,7 +226,11 @@ static inline void isert_link_send_pdu_wrs(struct isert_cmnd *from_pdu,
int wr_cnt)
{
isert_link_send_wrs(&from_pdu->wr[wr_cnt - 1], &to_pdu->wr[0]);
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
to_pdu->wr[0].send_wr.next = NULL;
#else
to_pdu->wr[0].send_wr.wr.next = NULL;
#endif
}
int isert_prepare_rdma(struct isert_cmnd *isert_pdu,
@@ -281,8 +289,14 @@ int isert_prepare_rdma(struct isert_cmnd *isert_pdu,
isert_link_send_wrs(&isert_pdu->wr[i - 1], &isert_pdu->wr[i]);
if (op == ISER_WR_RDMA_READ) {
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
isert_pdu->wr[wr_cnt - 1].send_wr.send_flags = IB_SEND_SIGNALED;
isert_pdu->wr[wr_cnt - 1].send_wr.next = NULL;
#else
isert_pdu->wr[wr_cnt - 1].send_wr.wr.send_flags =
IB_SEND_SIGNALED;
isert_pdu->wr[wr_cnt - 1].send_wr.wr.next = NULL;
#endif
}
out:
@@ -574,7 +588,11 @@ int isert_pdu_send(struct isert_connection *isert_conn,
#endif
wr = &tx_pdu->wr[0];
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
wr->send_wr.num_sge = isert_pdu_prepare_send(isert_conn, tx_pdu);
#else
wr->send_wr.wr.num_sge = isert_pdu_prepare_send(isert_conn, tx_pdu);
#endif
err = isert_post_send(isert_conn, wr, 1);
if (unlikely(err)) {
@@ -595,8 +613,13 @@ int isert_pdu_post_rdma_write(struct isert_connection *isert_conn,
TRACE_ENTRY();
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
isert_rsp->wr[0].send_wr.num_sge = isert_pdu_prepare_send(isert_conn,
isert_rsp);
#else
isert_rsp->wr[0].send_wr.wr.num_sge = isert_pdu_prepare_send(isert_conn,
isert_rsp);
#endif
isert_link_send_pdu_wrs(isert_cmd, isert_rsp, wr_cnt);
err = isert_post_send(isert_conn, &isert_cmd->wr[0], wr_cnt + 1);
if (unlikely(err)) {
+37 -12
View File
@@ -103,7 +103,11 @@ int isert_post_send(struct isert_connection *isert_conn,
struct isert_wr *first_wr,
int num_wr)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
struct ib_send_wr *first_ib_wr = &first_wr->send_wr;
#else
struct ib_send_wr *first_ib_wr = &first_wr->send_wr.wr;
#endif
struct ib_send_wr *bad_wr;
int num_posted;
int err;
@@ -131,9 +135,19 @@ void isert_post_drain(struct isert_connection *isert_conn)
isert_wr_set_fields(&isert_conn->drain_wr, isert_conn, NULL);
isert_conn->drain_wr.wr_op = ISER_WR_SEND;
isert_conn->drain_wr.send_wr.wr_id = _ptr_to_u64(&isert_conn->drain_wr);
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
isert_conn->drain_wr.send_wr.wr_id =
_ptr_to_u64(&isert_conn->drain_wr);
isert_conn->drain_wr.send_wr.opcode = IB_WR_SEND;
err = ib_post_send(isert_conn->qp, &isert_conn->drain_wr.send_wr, &bad_wr);
err = ib_post_send(isert_conn->qp,
&isert_conn->drain_wr.send_wr, &bad_wr);
#else
isert_conn->drain_wr.send_wr.wr.wr_id =
_ptr_to_u64(&isert_conn->drain_wr);
isert_conn->drain_wr.send_wr.wr.opcode = IB_WR_SEND;
err = ib_post_send(isert_conn->qp,
&isert_conn->drain_wr.send_wr.wr, &bad_wr);
#endif
if (unlikely(err)) {
pr_err("Failed to post drain wr, err:%d\n", err);
/*
@@ -601,6 +615,7 @@ static void isert_handle_wc_error(struct ib_wc *wc)
struct isert_buf *isert_buf = wr->buf;
struct isert_device *isert_dev = wr->isert_dev;
struct ib_device *ib_dev = isert_dev->ib_dev;
u32 num_sge;
TRACE_ENTRY();
@@ -615,7 +630,12 @@ static void isert_handle_wc_error(struct ib_wc *wc)
switch (wr->wr_op) {
case ISER_WR_SEND:
if (unlikely(wr->send_wr.num_sge == 0)) /* Drain WR */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
num_sge = wr->send_wr.num_sge;
#else
num_sge = wr->send_wr.wr.num_sge;
#endif
if (unlikely(num_sge == 0)) /* Drain WR */
isert_sched_conn_drained(isert_conn);
else
isert_pdu_err(&isert_pdu->iscsi);
@@ -845,7 +865,6 @@ static void isert_async_evt_handler(struct ib_event *async_ev, void *context)
static struct isert_device *isert_device_create(struct ib_device *ib_dev)
{
struct isert_device *isert_dev;
struct ib_device_attr *dev_attr;
int cqe_num, err;
struct ib_pd *pd;
struct ib_mr *mr;
@@ -862,12 +881,15 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
goto out;
}
dev_attr = &isert_dev->device_attr;
err = ib_query_device(ib_dev, dev_attr);
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 5, 0)
err = ib_query_device(ib_dev, &isert_dev->device_attr);
if (unlikely(err)) {
pr_err("Failed to query device, err: %d\n", err);
goto fail_query;
goto free_isert_dev;
}
#else
isert_dev->device_attr = ib_dev->attrs;
#endif
isert_dev->num_cqs = min_t(int, num_online_cpus(),
ib_dev->num_comp_vectors);
@@ -878,7 +900,7 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
if (unlikely(isert_dev->cq_qps == NULL)) {
pr_err("Failed to allocate iser cq_qps\n");
err = -ENOMEM;
goto fail_cq_qps;
goto free_isert_dev;
}
isert_dev->cq_desc = vmalloc(sizeof(*isert_dev->cq_desc) * isert_dev->num_cqs);
@@ -943,7 +965,8 @@ static struct isert_device *isert_device_create(struct ib_device *ib_dev)
goto fail_cq;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0)
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 2, 0) && \
!defined(IB_CREATE_CQ_HAS_INIT_ATTR)
cq = ib_create_cq(ib_dev,
isert_cq_comp_handler,
isert_async_evt_handler,
@@ -1005,8 +1028,7 @@ fail_pd:
vfree(isert_dev->cq_desc);
fail_alloc_cq_desc:
kfree(isert_dev->cq_qps);
fail_cq_qps:
fail_query:
free_isert_dev:
kfree(isert_dev);
out:
TRACE_EXIT_RES(err);
@@ -1648,9 +1670,12 @@ struct isert_portal *isert_portal_create(void)
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) && \
(!defined(RHEL_MAJOR) || RHEL_MAJOR -0 <= 5)
cm_id = rdma_create_id(isert_cm_evt_handler, portal, RDMA_PS_TCP);
#else
#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
cm_id = rdma_create_id(isert_cm_evt_handler, portal, RDMA_PS_TCP,
IB_QPT_RC);
#else
cm_id = rdma_create_id(&init_net, isert_cm_evt_handler, portal,
RDMA_PS_TCP, IB_QPT_RC);
#endif
if (unlikely(IS_ERR(cm_id))) {
err = PTR_ERR(cm_id);
+24 -18
View File
@@ -2,8 +2,8 @@
* Network threads.
*
* Copyright (C) 2004 - 2005 FUJITA Tomonori <tomof@acm.org>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -81,7 +81,6 @@ again:
spin_lock_bh(&conn->cmd_list_lock);
list_for_each_entry(cmnd, &conn->cmd_list, cmd_list_entry) {
struct iscsi_cmnd *rsp;
int restart = 0;
TRACE_CONN_CLOSE_DBG("cmd %p, scst_state %x, "
"r2t_len_to_receive %d, ref_cnt %d, parent_req %p, "
@@ -98,6 +97,12 @@ again:
if (cmnd_get_check(cmnd))
continue;
/*
* If we don't unlock here, we are risking to get into
* recursive deadlock in cmnd_done() called from cmnd_put()
*/
spin_unlock_bh(&conn->cmd_list_lock);
for (i = 0; i < cmnd->sg_cnt; i++) {
struct page *page = sg_page(&cmnd->sg[i]);
@@ -106,18 +111,12 @@ again:
atomic_read(&page->_count));
if (page->net_priv != NULL) {
if (restart == 0) {
spin_unlock_bh(&conn->cmd_list_lock);
restart = 1;
}
while (page->net_priv != NULL)
iscsi_put_page_callback(page);
}
}
cmnd_put(cmnd);
if (restart)
goto again;
goto again;
}
list_for_each_entry(rsp, &cmnd->rsp_cmd_list,
@@ -133,6 +132,13 @@ again:
if (cmnd_get_check(rsp))
continue;
/*
* If we don't unlock here, we are risking to
* get into recursive deadlock in cmnd_done()
* called from cmnd_put()
*/
spin_unlock_bh(&conn->cmd_list_lock);
for (i = 0; i < rsp->sg_cnt; i++) {
struct page *page =
sg_page(&rsp->sg[i]);
@@ -143,18 +149,12 @@ again:
atomic_read(&page->_count));
if (page->net_priv != NULL) {
if (restart == 0) {
spin_unlock_bh(&conn->cmd_list_lock);
restart = 1;
}
while (page->net_priv != NULL)
iscsi_put_page_callback(page);
}
}
cmnd_put(rsp);
if (restart)
goto again;
goto again;
}
}
}
@@ -862,6 +862,12 @@ static int process_read_io(struct iscsi_conn *conn, int *closed)
/*
* This command not yet received on the aborted
* time, so shouldn't be affected by any abort.
* It should not be affected by conn_abort()
* as well, because close connection is initiated
* from single (this) read thread, so conn_abort()
* call stack can not be initiated in parallel to
* receive all the data event (do_recv() has check
* of conn->closing in the beginning)
*/
EXTRACHECKS_BUG_ON(cmnd->prelim_compl_flags != 0);
@@ -1359,7 +1365,7 @@ retry:
set_fs(KERNEL_DS);
res = vfs_writev(file,
(struct iovec __force __user *)iop,
count, &off);
count, &off, 0);
set_fs(oldfs);
TRACE_WRITE("sid %#Lx, cid %u, res %d, iov_len %zd",
(unsigned long long int)conn->session->sid,
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+6 -4
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -128,7 +128,6 @@ int __add_target(struct iscsi_kern_target_info *info)
int err;
u32 tid = info->tid;
struct iscsi_target *target = NULL; /* to calm down sparse */
struct iscsi_kern_attr *attr_info;
union add_info_union {
struct iscsi_kern_params_info params_info;
struct iscsi_kern_attr attr_info;
@@ -165,7 +164,6 @@ int __add_target(struct iscsi_kern_target_info *info)
err = -ENOMEM;
goto out;
}
attr_info = (struct iscsi_kern_attr *)add_info;
if (tid == 0) {
do {
@@ -183,6 +181,9 @@ int __add_target(struct iscsi_kern_target_info *info)
nr_targets++;
#ifndef CONFIG_SCST_PROC
{
struct iscsi_kern_attr *attr_info = &add_info->attr_info;
mutex_lock(&target->target_mutex);
attrs_ptr_long = info->attrs_ptr;
@@ -208,6 +209,7 @@ int __add_target(struct iscsi_kern_target_info *info)
}
mutex_unlock(&target->target_mutex);
}
#endif
err = tid;
+2 -2
View File
@@ -1,8 +1,8 @@
#
# Makefile for the user space part of iSCSI-SCST.
#
# Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
# Copyright (C) 2007 - 2015 SanDisk Corporation
# Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
# Copyright (C) 2007 - 2016 SanDisk Corporation
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
+13 -13
View File
@@ -3,8 +3,8 @@
*
* Copyright (C) 2004 Xiranet Communications GmbH <arne.redlich@xiranet.com>
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>,
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* and code taken from UNH iSCSI software:
* Copyright (C) 2001-2003 InterOperability Lab (IOL)
@@ -171,7 +171,7 @@ static inline void encode_hex_string(u8 *intnum, long length, char *string)
strptr = string;
for (i = 0; i < length; i++, strptr += 2)
sprintf(strptr, "%.2hhx", intnum[i]);
sprintf(strptr, "%.2hhx", intnum[i]);
}
/* Base64 encoding, taken from UNH iSCSI "IntegerToBase64String()" */
@@ -339,15 +339,15 @@ static inline void chap_calc_digest_sha1(char chap_id, const char *secret, int s
*/
static int chap_rand(void)
{
int fd;
int r;
int fd;
int r;
fd = open("/dev/urandom", O_RDONLY);
assert(fd != -1);
if (read(fd, &r, sizeof(r)) < sizeof(r)) {
}
close(fd);
return r;
fd = open("/dev/urandom", O_RDONLY);
assert(fd != -1);
if (read(fd, &r, sizeof(r)) < sizeof(r)) {
}
close(fd);
return r;
}
static int chap_initiator_auth_create_challenge(struct connection *conn)
@@ -575,7 +575,7 @@ static int chap_target_auth_create_response(struct connection *conn)
response_len = 2 * digest_len;
else
response_len = ((digest_len - 1) / 3 + 1) * 4;
//"0x" / "0b" and "\0":
/* "0x" / "0b" and "\0": */
response_len += 3;
if (!(digest = malloc(digest_len))) {
@@ -639,7 +639,7 @@ int cmnd_exec_auth_chap(struct connection *conn)
{
int res;
switch(conn->auth_state) {
switch (conn->auth_state) {
case CHAP_AUTH_STATE_START:
res = chap_initiator_auth_create_challenge(conn);
break;
+5 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -514,6 +514,7 @@ int __config_account_add(struct target *target, int dir, char *name, char *pass,
if (dir == ISCSI_USER_DIR_OUTGOING) {
struct iscsi_attr *old;
list_for_each_entry(old, list, ulist) {
log_warning("Only one outgoing %s account is "
"supported. Replacing the old one.\n",
@@ -1061,6 +1062,7 @@ static int config_isns_load(const char *config)
isns_server = strdup(config_sep_string(&q));
} else if (!strcasecmp(p, ISCSI_ISNS_ACCESS_CONTROL_ATTR_NAME)) {
char *str = config_sep_string(&q);
if (!strcasecmp(str, "No"))
isns_access_control = 0;
else
@@ -1139,6 +1141,7 @@ int config_load(const char *config_name)
err = config_isns_load(buf);
if ((err == 0) && (isns_server != NULL)) {
int rc = isns_init();
if (rc != 0) {
log_error("iSNS server %s init failed: %d", isns_server, rc);
isns_exit();
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+3 -3
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2004 - 2005 FUJITA Tomonori <tomof@acm.org>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -298,7 +298,7 @@ int kernel_params_get(u32 tid, u64 sid, int type, struct iscsi_param *params)
if ((err = ioctl(ctrl_fd, ISCSI_PARAM_GET, &info)) < 0) {
err = -errno;
log_debug(1, "Can't get session params for session 0x%" PRIx64
log_debug(1, "Can't get session params for session 0x%" PRIx64
" (tid %u, err %d): %s\n", sid, tid, err, strerror(errno));
}
+8 -3
View File
@@ -2,8 +2,8 @@
* Event notification code.
*
* Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -57,7 +57,7 @@ static int nl_write(int fd, void *data, int len)
nlh.nlmsg_type = 0;
memset(&msg, 0, sizeof(msg));
msg.msg_name= (void *)&dest_addr;
msg.msg_name = (void *)&dest_addr;
msg.msg_namelen = sizeof(dest_addr);
msg.msg_iov = iov;
msg.msg_iovlen = 2;
@@ -105,6 +105,7 @@ static int strncasecmp_numwild(const char *name, const char *mask)
if (!strncasecmp(name, mask, strlen(name))) {
int j;
if (strlen(name) > strlen(mask))
goto out;
for (j = strlen(name); j < strlen(mask); j++) {
@@ -430,6 +431,7 @@ static int handle_e_mgmt_cmd(int fd, const struct iscsi_kern_event *event)
res = handle_add_attr(NULL, p, event->cookie);
} else if (strcasecmp("add_target_attribute", pp) == 0) {
struct target *target;
pp = config_sep_string(&p);
target = target_find_by_name(pp);
if (target == NULL) {
@@ -442,6 +444,7 @@ static int handle_e_mgmt_cmd(int fd, const struct iscsi_kern_event *event)
res = handle_del_attr(NULL, p, event->cookie);
} else if (strcasecmp("del_target_attribute", pp) == 0) {
struct target *target;
pp = config_sep_string(&p);
target = target_find_by_name(pp);
if (target == NULL) {
@@ -465,6 +468,7 @@ out:
static void add_key_mark(char *res_str, int res_str_len, int new_line)
{
int offs = strlen(res_str);
snprintf(&res_str[offs], res_str_len - offs, "%s%s\n",
new_line ? "\n" : "", SCST_SYSFS_KEY_MARK);
return;
@@ -702,6 +706,7 @@ static int handle_target_redirect(struct target *target, char *p)
if (inet_pton(AF_INET, addr, &ia) != 1) {
char tmp[sizeof(target->redirect.addr)];
if (*addr == '[')
t = addr+1;
else
+5 -5
View File
@@ -2,8 +2,8 @@
* iscsi_adm - manage iSCSI-SCST Target software.
*
* Copyright (C) 2004 - 2005 FUJITA Tomonori <tomof@acm.org>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -46,10 +46,9 @@ enum iscsi_adm_op {
OP_SHOW,
};
static char program_name[] = "iscsi-scst-adm";
static const char program_name[] = "iscsi-scst-adm";
static struct option const long_options[] =
{
static struct option const long_options[] = {
{"op", required_argument, NULL, 'o'},
{"tid", required_argument, NULL, 't'},
{"sid", required_argument, NULL, 's'},
@@ -278,6 +277,7 @@ static int parse_trgt_params(struct msg_trgt *msg, char *params)
while ((p = strsep(&params, ",")) != NULL) {
int idx;
u32 val;
if (!*p)
continue;
if (!(q = strchr(p, '=')))
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+10 -7
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -40,7 +40,7 @@
#include "iscsid.h"
#include "iscsi_adm.h"
static char* server_address;
static char *server_address;
uint16_t server_port = ISCSI_LISTEN_PORT;
struct pollfd poll_array[POLL_MAX];
@@ -52,10 +52,9 @@ int conn_blocked;
struct iscsi_init_params iscsi_init_params;
static char program_name[] = "iscsi-scstd";
static const char program_name[] = "iscsi-scstd";
static struct option const long_options[] =
{
static struct option const long_options[] = {
{"config", required_argument, 0, 'c'},
{"foreground", no_argument, 0, 'f'},
{"debug", required_argument, 0, 'd'},
@@ -209,6 +208,7 @@ out:
static int transmit_iser(int fd, bool start)
{
int opt = start;
return ioctl(fd, RDMA_CORK, &opt, sizeof(opt));
}
@@ -370,6 +370,7 @@ out_close:
static int transmit_sock(int fd, bool start)
{
int opt = start;
return setsockopt(fd, SOL_TCP, TCP_CORK, &opt, sizeof(opt));
}
@@ -620,7 +621,7 @@ again:
switch (conn->state) {
case STATE_KERNEL:
conn_pass_to_kern(conn, pollfd->fd);
if(conn->passed_to_kern)
if (conn->passed_to_kern)
conn->state = STATE_CLOSE;
else
conn->state = STATE_EXIT;
@@ -744,6 +745,7 @@ static void event_loop(void)
(conn->state == STATE_EXIT) ||
(conn->state == STATE_DROP)) {
struct session *sess = conn->sess;
log_debug(1, "closing conn %p", conn);
conn_free_pdu(conn);
close(pollfd->fd);
@@ -928,6 +930,7 @@ int main(int argc, char **argv)
exit(1);
} else if (pid) {
int res = -1;
close(init_report_pipe[1]);
if (read(init_report_pipe[0], &res, sizeof(res)) < sizeof(res))
exit(-1);
+22 -18
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -299,6 +299,7 @@ static int login_check_reinstatement(struct connection *conn)
goto out;
} else {
struct connection *c = conn_find(session, conn->cid);
if (c != NULL) {
/* Kernel will do connection reinstatement */
log_debug(1, "Conn %x reinstatement "
@@ -527,6 +528,7 @@ static void login_start(struct connection *conn)
if (session_type) {
if (!strcmp(session_type, "Discovery")) {
int ret = conn->is_discovery(conn->fd);
if (ret) {
login_rsp_tgt_err(conn, ISCSI_STATUS_MISSING_FIELDS);
return;
@@ -576,7 +578,7 @@ static void login_start(struct connection *conn)
if (!config_initiator_access_allowed(conn->tid, conn->fd) ||
!target_portal_allowed(target, conn->target_portal,
conn->initiator) ||
conn->initiator) ||
!isns_scn_access_allowed(conn->tid, name)) {
log_info("Initiator %s not allowed to connect to "
"target %s", name, target_name);
@@ -645,6 +647,7 @@ static int login_finish(struct connection *conn)
if (conn->is_iser &&
conn->session_params[key_target_recv_data_length].key_state == KEY_STATE_START) {
char buf[32] = "\0";
params_val_to_str(session_keys, key_target_recv_data_length,
session_keys[key_target_recv_data_length].local_def,
buf, sizeof(buf));
@@ -698,21 +701,21 @@ static void cmnd_reject(struct connection *conn, u8 reason)
static int cmnd_exec_auth(struct connection *conn)
{
int res;
int res;
switch (conn->auth_method) {
case AUTH_CHAP:
res = cmnd_exec_auth_chap(conn);
break;
case AUTH_NONE:
res = 0;
break;
default:
log_error("Unknown auth. method %d", conn->auth_method);
res = -3;
}
switch (conn->auth_method) {
case AUTH_CHAP:
res = cmnd_exec_auth_chap(conn);
break;
case AUTH_NONE:
res = 0;
break;
default:
log_error("Unknown auth. method %d", conn->auth_method);
res = -3;
}
return res;
return res;
}
static void cmnd_exec_login(struct connection *conn)
@@ -750,7 +753,7 @@ static void cmnd_exec_login(struct connection *conn)
login_start(conn);
if (rsp->status_class)
return;
//else fall through
/* else fall through */
case STATE_SECURITY:
text_scan_security(conn);
if (rsp->status_class)
@@ -848,6 +851,7 @@ static void cmnd_exec_login(struct connection *conn)
}
if (!stay && !nsg_disagree) {
int err;
text_check_params(conn);
err = login_finish(conn);
if (err != 0) {
@@ -1081,7 +1085,7 @@ void cmnd_finish(struct connection *conn)
conn->state = STATE_LOGIN;
break;
case STATE_SECURITY_FULL:
//fall through
/* fall through */
case STATE_LOGIN_FULL:
if (conn->session_type == SESSION_NORMAL)
conn->state = STATE_KERNEL;
+4 -4
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -180,8 +180,8 @@ struct connection {
#define ISCSI_USER_DIR_INCOMING 0
#define ISCSI_USER_DIR_OUTGOING 1
#define ISCSI_USER_NAME(attr) (attr)->attr_key
#define ISCSI_USER_PASS(attr) (attr)->attr_value
#define ISCSI_USER_NAME(attr) ((attr)->attr_key)
#define ISCSI_USER_PASS(attr) ((attr)->attr_value)
struct iscsi_attr {
struct __qelem ulist;
+6 -5
View File
@@ -2,8 +2,8 @@
* iSNS functions
*
* Copyright (C) 2006 FUJITA Tomonori <tomof@acm.org>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -507,9 +507,9 @@ int isns_target_register(char *name)
err = isns_tlv_set(&tlv, max_buf - length, ISNS_ATTR_ISCSI_NAME,
strlen(isns_entity_target_name) + 1, isns_entity_target_name);
}
if (err < 0)
if (err < 0)
goto out;
length += err;
length += err;
err = isns_tlv_set(&tlv, max_buf - length, ISNS_ATTR_ENTITY_IDENTIFIER,
strlen(eid) + 1, eid);
@@ -551,6 +551,7 @@ if (err < 0)
if (scn_listen_port) {
uint32_t sport = htonl(scn_listen_port);
err = isns_tlv_set(&tlv, max_buf - length, ISNS_ATTR_SCN_PORT,
sizeof(sport), &sport);
if (err < 0)
@@ -1010,7 +1011,7 @@ static int send_scn_rsp(char *name, uint16_t transaction)
*((uint32_t *)hdr->pdu) = 0;
max_buf = sizeof(buf) - offsetof(struct isns_hdr, pdu);
tlv = (struct isns_tlv *)((char *)hdr->pdu + 4);
length +=4;
length += 4;
err = isns_tlv_set(&tlv, max_buf - length, ISNS_ATTR_ISCSI_NAME,
strlen(name) + 1, name);
+2 -2
View File
@@ -2,8 +2,8 @@
* iSNS protocol data types
*
* Copyright (C) 2006 FUJITA Tomonori <tomof@acm.org>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
+6 -3
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -37,6 +37,7 @@ static void dolog_nofunc(int prio, const char *fmt, va_list ap)
if (log_daemon) {
int len = strlen(fmt);
char f[len+1+1];
if (fmt[len] != '\n')
sprintf(f, "%s\n", fmt);
else
@@ -63,6 +64,7 @@ static void dolog(int prio, const char *func, int line, const char *fmt, va_list
if (log_daemon) {
int len = strlen(func) + strlen(fmt);
char f[len+1+1];
if (fmt[len] != '\n')
sprintf(f, "%s:%d: %s %s\n", func, line,
(prio == LOG_ERR) ? "ERROR:" : "", fmt);
@@ -83,13 +85,14 @@ static void dolog(int prio, const char *func, int line, const char *fmt, va_list
void __log(const char *func, int line, int prio, int level, const char *fmt, ...)
{
va_list ap;
if (level) {
prio = LOG_DEBUG;
if (log_level < level)
return;
}
va_list ap;
va_start(ap, fmt);
dolog(prio, func, line, fmt, ap);
va_end(ap);
+3 -3
View File
@@ -1,4 +1,4 @@
/*
/*
* MD5 Message Digest Algorithm (RFC1321).
*
* Derived from cryptoapi implementation, originally based on the
@@ -6,10 +6,10 @@
*
* Copyright (c) Cryptoapi developers.
* Copyright (c) 2002 James Morris <jmorris@intercode.com.au>
*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
*/
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2004 - 2005 FUJITA Tomonori <tomof@acm.org>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+2 -2
View File
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+10 -10
View File
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -25,7 +25,7 @@ struct __qelem {
#undef offsetof
#ifdef __compiler_offsetof
#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
#define offsetof(TYPE, MEMBER) __compiler_offsetof(TYPE, MEMBER)
#else
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
@@ -45,19 +45,19 @@ static inline int list_empty(const struct __qelem *head)
static inline int list_length_is_one(const struct __qelem *head)
{
return (!list_empty(head) && head->q_forw == head->q_back);
return (!list_empty(head) && head->q_forw == head->q_back);
}
#define container_of(ptr, type, member) ({ \
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
const typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (char *)__mptr - offsetof(type,member) );})
#define list_entry(ptr, type, member) \
container_of(ptr, type, member)
#define list_for_each_entry(pos, head, member) \
for (pos = list_entry((head)->q_forw, typeof(*pos), member); \
&pos->member != (head); \
&pos->member != (head); \
pos = list_entry(pos->member.q_forw, typeof(*pos), member))
#define list_for_each_entry_safe(pos, n, head, member) \
@@ -73,7 +73,7 @@ static inline int list_length_is_one(const struct __qelem *head)
INIT_LIST_HEAD(elem); \
} while (0)
#define list_add(new, head) insque (new, head)
#define list_add(new, head) insque(new, head)
#define list_add_tail(new, head) insque(new, (head)->q_back)
@@ -94,12 +94,12 @@ static inline int list_length_is_one(const struct __qelem *head)
#define min_t(type, x, y) ({ \
type __min1 = (x); \
type __min2 = (y); \
__min1 < __min2 ? __min1: __min2; })
__min1 < __min2 ? __min1 : __min2; })
#define max_t(type, x, y) ({ \
type __max1 = (x); \
type __max2 = (y); \
__max1 > __max2 ? __max1: __max2; })
__max1 > __max2 ? __max1 : __max2; })
#ifndef IPV6_V6ONLY
#define IPV6_V6ONLY 26
+6 -4
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -29,6 +29,7 @@ size_t strlcpy(char *dest, const char *src, size_t size)
if (size) {
size_t len = (ret >= size) ? size - 1 : ret;
memcpy(dest, src, len);
dest[len] = '\0';
}
@@ -56,6 +57,7 @@ int params_index_by_name_numwild(const char *name, const struct iscsi_key *keys)
for (i = 0; keys[i].name; i++) {
if (!strncasecmp(keys[i].name, name, strlen(keys[i].name))) {
int j;
if (strlen(keys[i].name) > strlen(name))
continue;
for (j = strlen(keys[i].name); j < strlen(name); j++) {
@@ -205,8 +207,8 @@ static int digest_str_to_val(const char *str, unsigned int *val)
{
int err = 0;
const char *p, *q;
p = str;
p = str;
*val = 0;
do {
while ((*p != '\0') && isspace(*p))
@@ -337,7 +339,7 @@ static struct iscsi_key_ops marker_ops = {
.set_val = marker_set_val,
};
#define SET_KEY_VALUES(x) DEFAULT_##x,DEFAULT_##x,MIN_##x,MAX_##x
#define SET_KEY_VALUES(x) DEFAULT_##x, DEFAULT_##x, MIN_##x, MAX_##x
/*
* List of local target keys with initial values.
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2005 FUJITA Tomonori <tomof@acm.org>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+6 -6
View File
@@ -17,9 +17,9 @@
#include "sha1.h"
/* SHA1 transforms */
#define F1(x,y,z) (z ^ (x & (y ^ z))) /* x ? y : z */
#define F2(x,y,z) (x ^ y ^ z) /* XOR */
#define F3(x,y,z) ((x & y) + (z & (x ^ y))) /* majority */
#define F1(x, y, z) (z ^ (x & (y ^ z))) /* x ? y : z */
#define F2(x, y, z) (x ^ y ^ z) /* XOR */
#define F3(x, y, z) ((x & y) + (z & (x ^ y))) /* majority */
/* SHA1 per-round constants */
#define K1 0x5A827999UL /* Rounds 0-19: sqrt(2) * 2^30 */
@@ -56,17 +56,17 @@ static void __sha1_transform(u32 hash[SHA1_DIGEST_WORDS],
e = d; d = c; c = rol32(b, 30); b = a; a = t;
}
for (; i < 40; i ++) {
for (; i < 40; i++) {
t = F2(b, c, d) + K2 + rol32(a, 5) + e + W[i];
e = d; d = c; c = rol32(b, 30); b = a; a = t;
}
for (; i < 60; i ++) {
for (; i < 60; i++) {
t = F3(b, c, d) + K3 + rol32(a, 5) + e + W[i];
e = d; d = c; c = rol32(b, 30); b = a; a = t;
}
for (; i < 80; i ++) {
for (; i < 80; i++) {
t = F2(b, c, d) + K4 + rol32(a, 5) + e + W[i];
e = d; d = c; c = rol32(b, 30); b = a; a = t;
}
+3 -3
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -292,7 +292,7 @@ void target_list_build(struct connection *conn, char *target_name)
else if (strcmp(conn->target_portal, portal) &&
!is_addr_loopback(portal) &&
target_portal_allowed(target, portal,
conn->initiator))
conn->initiator))
target_print_addr(conn, portal, family);
}
}
+2 -2
View File
@@ -1,7 +1,7 @@
/*
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
+2
View File
@@ -164,6 +164,7 @@ static int mpt_target_show(struct seq_file *seq, void *v)
if (ioc->bus_type == SPI) {
#endif
int i = 0;
seq_printf(seq, "Target ID :%d\n"
"Capabilities :0x%x\n"
"PhysicalInterface:0x%x\n",
@@ -252,6 +253,7 @@ static ssize_t mpt_proc_target_write(struct file *file, const char __user *buf,
if (strncmp("target_id:", tmp, strlen("target_id:")) == 0) {
char *s = tmp + strlen("target_id:");
int id = simple_strtoul(s, NULL, 0);
if (id < MPT_MAX_SCSI_DEVICES) {
if (IsScsi(tgt->priv)) {
TRACE_DBG("Changing target id to %d\n", id);
+1 -1
View File
@@ -37,7 +37,7 @@
#define MPT_STM_64_BIT_DMA 1
#endif
#include "../drivers/message/fusion/mptbase.h"
#include "mptbase.h"
#ifndef MPI_IOCLOGINFO_FC_LINK_ALREADY_INITIALIZED
#define MPI_IOCLOGINFO_FC_LINK_ALREADY_INITIALIZED 0x24000002
+12 -11
View File
@@ -3,28 +3,29 @@
ABT_DETAILS="x86_64"
ABT_JOBS=5
ABT_KERNELS=" \
4.3 \
4.2.6-nc \
4.1.13-nc \
4.4.1 \
4.3.5-nc \
4.2.8-nc \
4.1.17-nc \
4.0.9-nc \
3.19.7-nc \
3.18.19-nc \
3.19.8-nc \
3.18.26-nc \
3.17.8-nc \
3.16.7-nc \
3.15.10-nc \
3.14.57-nc \
3.14.60-nc \
3.13.11-nc \
3.12.44-nc \
3.12.53-nc \
3.11.10-nc \
3.10.93-nc \
3.10.96-nc \
3.9.11-nc \
3.8.13-nc \
3.7.10-nc \
3.6.11-nc \
3.5.7-nc \
3.4.108-nc \
3.4.110-nc \
3.3.8-nc \
3.2.67-nc \
3.2.76-nc \
3.1.10-nc \
3.0.101-nc \
2.6.39.4-nc \
@@ -35,7 +36,7 @@ ABT_KERNELS=" \
2.6.35.14-u-nc \
2.6.34.15-nc \
2.6.33.20-nc \
2.6.32.67-nc \
2.6.32.70-nc \
2.6.31.14-nc \
2.6.30.10-nc \
2.6.29.6-nc \
+2 -2
View File
@@ -1,9 +1,9 @@
#
# Qlogic 2x00 SCSI target driver makefile
#
# Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
# Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
# Copyright (C) 2004 - 2005 Leonid Stoljar
# Copyright (C) 2007 - 2015 SanDisk Corporation
# Copyright (C) 2007 - 2016 SanDisk Corporation
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -0,0 +1,5 @@
ccflags-y += -Idrivers/scsi/qla2xxx
qla2x00tgt-y := qla2x00t.o
obj-$(CONFIG_SCST_QLA_TGT_ADDON) += qla2x00tgt.o
+4 -4
View File
@@ -1,10 +1,10 @@
/*
* qla2x00t.c
*
* Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2005 Leonid Stoljar
* Copyright (C) 2006 Nathaniel Clark <nate@misrule.us>
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* QLogic 22xx/23xx/24xx/25xx FC target driver.
*
@@ -5610,7 +5610,7 @@ static void q2t_response_pkt(scsi_qla_host_t *vha, response_t *pkt)
*/
q24_retry_term_exchange(vha, entry);
} else
PRINT_ERROR("qla2x00t(%ld): ABTS_RESP_24XX "
PRINT_WARNING("qla2x00t(%ld): ABTS_RESP_24XX "
"failed %x (subcode %x:%x)", vha->host_no,
entry->compl_status, entry->error_subcode1,
entry->error_subcode2);
@@ -5815,7 +5815,7 @@ retry:
"S_ID %x:%x:%x", s_id[0], s_id[1],
s_id[2]);
} else
PRINT_ERROR("qla2x00t(%ld): Unable to find "
PRINT_WARNING("qla2x00t(%ld): Unable to find "
"initiator with S_ID %x:%x:%x",
vha->host_no, s_id[0], s_id[1],
s_id[2]);
+2 -2
View File
@@ -1,10 +1,10 @@
/*
* qla2x00t.h
*
* Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2005 Leonid Stoljar
* Copyright (C) 2006 Nathaniel Clark <nate@misrule.us>
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* QLogic 22xx/23xx/24xx/25xx FC target driver.
*
+2 -2
View File
@@ -1,10 +1,10 @@
/*
* qla2x_tgt.h
*
* Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2005 Leonid Stoljar
* Copyright (C) 2006 Nathaniel Clark <nate@misrule.us>
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* Additional file for the target driver support.
*
+2 -2
View File
@@ -1,10 +1,10 @@
/*
* qla2x_tgt_def.h
*
* Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2005 Leonid Stoljar
* Copyright (C) 2006 Nathaniel Clark <nate@misrule.us>
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* Additional file for the target driver support.
*
+3 -3
View File
@@ -261,7 +261,7 @@ qla2x00_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0)
/* Read all mbox registers? */
mboxes = (1 << ha->mbx_count) - 1;
if (!ha->mcp)
ql_dbg(ql_dbg_async, vha, 0x5001, "MBX pointer ERRROR.\n");
ql_dbg(ql_dbg_async, vha, 0x5001, "MBX pointer ERROR.\n");
else
mboxes = ha->mcp->in_mb;
@@ -1516,7 +1516,7 @@ qla2x00_handle_sense(srb_t *sp, uint8_t *sense_data, uint32_t par_sense_len,
struct scsi_dif_tuple {
__be16 guard; /* Checksum */
__be16 app_tag; /* APPL identifer */
__be16 app_tag; /* APPL identifier */
__be32 ref_tag; /* Target LBA or indirect LBA */
};
@@ -2073,7 +2073,7 @@ qla24xx_mbx_completion(scsi_qla_host_t *vha, uint16_t mb0)
/* Read all mbox registers? */
mboxes = (1 << ha->mbx_count) - 1;
if (!ha->mcp)
ql_dbg(ql_dbg_async, vha, 0x504e, "MBX pointer ERRROR.\n");
ql_dbg(ql_dbg_async, vha, 0x504e, "MBX pointer ERROR.\n");
else
mboxes = ha->mcp->in_mb;
+2 -2
View File
@@ -1171,7 +1171,7 @@ __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type,
if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id,
cmd->device->lun, type) != QLA_SUCCESS) {
ql_log(ql_log_warn, vha, 0x800d,
"wait for peding cmds failed for cmd=%p.\n", cmd);
"wait for pending cmds failed for cmd=%p.\n", cmd);
goto eh_reset_failed;
}
@@ -1274,7 +1274,7 @@ qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
eh_bus_reset_done:
ql_log(ql_log_warn, vha, 0x802b,
"BUS RESET %s nexus=%ld:%d:%d.\n",
(ret == FAILED) ? "FAILED" : "SUCCEDED", vha->host_no, id, lun);
(ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun);
return ret;
}
+1 -1
View File
@@ -48,7 +48,7 @@ extract_kernel_tree "$1" || exit $?
cd "${target}" || exit $?
list-source-files "${scst_dir}" |
"${script_dir}/list-source-files" "${scst_dir}" |
grep -- "-${kernel_version}.*.patch$" |
grep -v /in-tree/ |
while read p; do
+21
View File
@@ -141,6 +141,26 @@ function compile_scst_unpatched {
)
}
# Compile the unpatched SCST source code without DLM.
function compile_scst_no_dlm {
local scst="$PWD"
local outputfile="${outputdir}/compilation-output-no-dlm.txt"
local workingdirectory="${outputdir}/scst-no-dlm"
echo "Testing whether the SCST tree compiles fine without DLM support ..."
(
if mkdir -p "${workingdirectory}" \
&& cd "${workingdirectory}" \
&& duplicate_scst_source_tree "${scst}" \
&& CONFIG_SCST_NO_DLM=y compile_scst &> "${outputfile}"
then
echo "OK"
else
echo "FAILED"
fi
)
}
# Test out-of-tree compilation agains the kernel header files in
# /lib/modules/$(uname -r)/build.
function compile_scst_patched {
@@ -558,6 +578,7 @@ fi
test_scst_tree_patches || exit $?
if [ "${run_local_compilation}" = "true" ]; then
compile_scst_unpatched || exit $?
compile_scst_no_dlm || exit $?
compile_scst_patched 2release || exit $?
compile_scst_patched 2perf || exit $?
compile_scst_patched enable_proc || exit $?
+2 -2
View File
@@ -1,9 +1,9 @@
#
# Common makefile for SCSI target mid-level and its drivers
#
# Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
# Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
# Copyright (C) 2004 - 2005 Leonid Stoljar
# Copyright (C) 2007 - 2015 SanDisk Corporation
# Copyright (C) 2007 - 2016 SanDisk Corporation
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
+37 -24
View File
@@ -353,6 +353,15 @@ in/out in Makefile and scst.h:
functionality is working only if dif_mode doesn't contain dev_store
and dif_type is 1.
- CONFIG_SCST_FORWARD_MODE_PASS_THROUGH - if defined, the pass-through
subsystem starts working in the forwarding mode, where reservation
commands processed locally and not passed to the backend SCSI device,
while COMPARE AND WRITE, EXTENDED COPY and RECEIVE COPY RESULTS
commands, which normally processed locally by the SCST core, not
processed locally, but passed to the backend device. Intended to be
used to implement NON-OPTIMIZED ALUA state together with "forwarding"
target attribute on the remote node. Disabled by default for safety.
HIGHMEM kernel configurations are fully supported, but not recommended
for performance reasons, except for scst_user, where they are not
supported, because this module deals with user supplied memory on a
@@ -441,6 +450,19 @@ following entries:
have different IDs and SNs. For instance, VDISK dev handler uses this
ID to generate T10 vendor specific identifier and SN of the devices.
- suspend - globally suspends or releases all SCSI activities on all
devices. Useful for mass management, like adding or deleting LUNs.
Writing to it value v:
* v > 0 - suspends activities, but waits no more, than v seconds
* v = 0 - suspends activities, waits indefinitely
* V < 0 - releases activities.
Reading from this attribute returns number of previous suspend
requests.
- threads - allows to read and set number of global SCST I/O threads.
Those threads used with async. dev handlers, for instance, vdisk
BLOCKIO or NULLIO.
@@ -1625,14 +1647,14 @@ perform actual path state switching on SET TARGET PORT GROUPS command,
for instance, by calling drbdadm. For more information see stpgd README
as well as sample script scst_on_stpg.
DRBD compatibility
..................
DRBD and other replication/failover SW compatibility
....................................................
DRBD does not allow to open its device on the secondary as well as does
not allow to perform primary to secondary transition, if this device is
open.
DRBD as well as other replication/failover SW does not allow to open its
device on the secondary as well as does not allow to perform primary to
secondary transition, if this device is open.
SCST BLOCKIO handler has all the necessary support for this behavior. If
SCST BLOCKIO handler has all the necessary support for such behavior. If
you write new ALUA state in the "state" attribute, SCST BLOCKIO handler
before transition closes the open devices' handles and after transition
reopens them, if the new state is active or nonoptimized.
@@ -1646,7 +1668,7 @@ above). Wait until the blocking finished.
2. Change the ALUA state to "transitioning". At this moment all open
file handles will be closed.
3. Perform the DRBD state transition
3. Perform the DRBD or other replication/failover SW state transition
4. Change the ALUA state to your desired secondary state.
@@ -1846,34 +1868,25 @@ EXTENDED COPY
~~~~~~~~~~~~~
SCST implements EXTENDED COPY via internal Copy Manager target. This
target has the following specific attributes in its sysfs:
target has the following specific attribute in its sysfs:
- allow_not_connected_copy - if not set (default), an initiator can
perform copy only between devices it has direct access to via any
target/session. If set, any initiator can copy between any devices in
the system.
- mgmt - this attribute allows to control data from which devices can
be copied using Copy Manager. By default, devices belonging to dev
handlers with flag auto_cm_assignment_possible set are auto assigned to
the Copy Manager on the registration. Currently, only vdisk has this
flag set, so all other devices (pass-through, user space, etc.) should
be assigned to the Copy Manager manually.
Mgmt attribute supports the following commands:
- add [vname|H:C:I:L] - adds device with name vname or H:C:I:L numbers
(pass-through) to the Copy Manager.
- del [vname|H:C:I:L] - deletes device with name vname or H:C:I:L numbers
(pass-through) from the Copy Manager.
The Copy Manager has access only to those devices, for which it has LUNs
in /sys/kernel/scst_tgt/targets/copy_manager/copy_manager_tgt/luns/.
Devices from scst_vdisk dev handler added to it automatically upon
registration, but for other devices you need to manually add LUNs there
the same way as for any target driver. You can also delete any device at
any time from the Copy Manager visibility by deleting the corresponding
LUN from the sysfs. It might be useful during ALUA state switching.
Internally SCST implements EXTENDED COPY as generation of sets of
internal READ(16) and WRITE(16) SCSI commands. Dev handlers don't need
any manual actions to use it.
Also SCST provides for dev handlers possibility to remap blocks instead
of copy them, if they support this feature. It allows them to perform
EXTENDED COPY command much faster by just metadata update of their
+37 -24
View File
@@ -243,6 +243,15 @@ your favorite kernel configuration Makefile target, e.g. "make xconfig":
functionality is working only if dif_mode doesn't contain dev_store
and dif_type is 1.
- CONFIG_SCST_FORWARD_MODE_PASS_THROUGH - if defined, the pass-through
subsystem starts working in the forwarding mode, where reservation
commands processed locally and not passed to the backend SCSI device,
while COMPARE AND WRITE, EXTENDED COPY and RECEIVE COPY RESULTS
commands, which normally processed locally by the SCST core, not
processed locally, but passed to the backend device. Intended to be
used to implement NON-OPTIMIZED ALUA state together with "forwarding"
target attribute on the remote node. Disabled by default for safety.
HIGHMEM kernel configurations are fully supported, but not recommended
for performance reasons.
@@ -305,6 +314,19 @@ following entries:
have different IDs and SNs. For instance, VDISK dev handler uses this
ID to generate T10 vendor specific identifier and SN of the devices.
- suspend - globally suspends or releases all SCSI activities on all
devices. Useful for mass management, like adding or deleting LUNs.
Writing to it value v:
* v > 0 - suspends activities, but waits no more, than v seconds
* v = 0 - suspends activities, waits indefinitely
* V < 0 - releases activities.
Reading from this attribute returns number of previous suspend
requests.
- threads - allows to read and set number of global SCST I/O threads.
Those threads used with async. dev handlers, for instance, vdisk
BLOCKIO or NULLIO.
@@ -1478,14 +1500,14 @@ perform actual path state switching on SET TARGET PORT GROUPS command,
for instance, by calling drbdadm. For more information see stpgd README
as well as sample script scst_on_stpg.
DRBD compatibility
..................
DRBD and other replication/failover SW compatibility
....................................................
DRBD does not allow to open its device on the secondary as well as does
not allow to perform primary to secondary transition, if this device is
open.
DRBD as well as other replication/failover SW does not allow to open its
device on the secondary as well as does not allow to perform primary to
secondary transition, if this device is open.
SCST BLOCKIO handler has all the necessary support for this behavior. If
SCST BLOCKIO handler has all the necessary support for such behavior. If
you write new ALUA state in the "state" attribute, SCST BLOCKIO handler
before transition closes the open devices' handles and after transition
reopens them, if the new state is active or nonoptimized.
@@ -1499,7 +1521,7 @@ above). Wait until the blocking finished.
2. Change the ALUA state to "transitioning". At this moment all open
file handles will be closed.
3. Perform the DRBD state transition
3. Perform the DRBD or other replication/failover SW state transition
4. Change the ALUA state to your desired secondary state.
@@ -1699,34 +1721,25 @@ EXTENDED COPY
~~~~~~~~~~~~~
SCST implements EXTENDED COPY via internal Copy Manager target. This
target has the following specific attributes in its sysfs:
target has the following specific attribute in its sysfs:
- allow_not_connected_copy - if not set (default), an initiator can
perform copy only between devices it has direct access to via any
target/session. If set, any initiator can copy between any devices in
the system.
- mgmt - this attribute allows to control data from which devices can
be copied using Copy Manager. By default, devices belonging to dev
handlers with flag auto_cm_assignment_possible set are auto assigned to
the Copy Manager on the registration. Currently, only vdisk has this
flag set, so all other devices (pass-through, user space, etc.) should
be assigned to the Copy Manager manually.
Mgmt attribute supports the following commands:
- add [vname|H:C:I:L] - adds device with name vname or H:C:I:L numbers
(pass-through) to the Copy Manager.
- del [vname|H:C:I:L] - deletes device with name vname or H:C:I:L numbers
(pass-through) from the Copy Manager.
The Copy Manager has access only to those devices, for which it has LUNs
in /sys/kernel/scst_tgt/targets/copy_manager/copy_manager_tgt/luns/.
Devices from scst_vdisk dev handler added to it automatically upon
registration, but for other devices you need to manually add LUNs there
the same way as for any target driver. You can also delete any device at
any time from the Copy Manager visibility by deleting the corresponding
LUN from the sysfs. It might be useful during ALUA state switching.
Internally SCST implements EXTENDED COPY as generation of sets of
internal READ(16) and WRITE(16) SCSI commands. Dev handlers don't need
any manual actions to use it.
Also SCST provides for dev handlers possibility to remap blocks instead
of copy them, if they support this feature. It allows them to perform
EXTENDED COPY command much faster by just metadata update of their
+115 -7
View File
@@ -2,7 +2,7 @@
#define _SCST_BACKPORT_H_
/*
* Copyright (C) 2015 SanDisk Corporation
* Copyright (C) 2015 -2016 SanDisk Corporation
*
* Backports of functions introduced in recent kernel versions.
*
@@ -20,8 +20,11 @@
* GNU General Public License for more details.
*/
#include <linux/blkdev.h> /* struct request_queue */
#include <linux/scatterlist.h> /* struct scatterlist */
#include <linux/slab.h> /* kmalloc() */
#include <linux/writeback.h> /* sync_page_range() */
#include <scsi/scsi_cmnd.h> /* struct scsi_cmnd */
/* <asm-generic/barrier.h> */
@@ -53,7 +56,7 @@ static inline unsigned int queue_max_hw_sectors(struct request_queue *q)
#if LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 20)
#ifndef __printf
#define __printf(a, b) __attribute__((format(printf,a,b)))
#define __printf(a, b) __attribute__((format(printf, a, b)))
#endif
#endif
@@ -88,8 +91,10 @@ static inline unsigned int queue_max_hw_sectors(struct request_queue *q)
typedef cpumask_t cpumask_var_t[1];
#define cpumask_bits(maskp) ((maskp)->bits)
#ifdef CONFIG_CPUMASK_OFFSTACK
/* Assuming NR_CPUS is huge, a runtime limit is more efficient. Also,
* not all bits may be allocated. */
/*
* Assuming NR_CPUS is huge, a runtime limit is more efficient. Also,
* not all bits may be allocated.
*/
#define nr_cpumask_bits nr_cpu_ids
#else
#define nr_cpumask_bits NR_CPUS
@@ -212,6 +217,25 @@ static inline struct inode *file_inode(const struct file *f)
}
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
static inline ssize_t vfs_readv_backport(struct file *file,
const struct iovec __user *vec,
unsigned long vlen, loff_t *pos,
int flags)
{
return vfs_readv(file, vec, vlen, pos);
}
static inline ssize_t vfs_writev_backport(struct file *file,
const struct iovec __user *vec,
unsigned long vlen, loff_t *pos,
int flags)
{
return vfs_writev(file, vec, vlen, pos);
}
#define vfs_readv vfs_readv_backport
#define vfs_writev vfs_writev_backport
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
static inline int vfs_fsync_backport(struct file *file, int datasync)
{
@@ -322,7 +346,22 @@ static inline bool list_entry_in_list(const struct list_head *entry)
/* <linux/lockdep.h> */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 32)
#define lockdep_assert_held(l) do { (void)(l); } while (0)
#define lockdep_assert_held(l) (void)(l)
#endif
/* <linux/kernel.h> */
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
static inline long get_user_pages_backport(unsigned long start,
unsigned long nr_pages,
int write, int force,
struct page **pages,
struct vm_area_struct **vmas)
{
return get_user_pages(current, current->mm, start, nr_pages, write,
force, pages, vmas);
}
#define get_user_pages get_user_pages_backport
#endif
/* <linux/preempt.h> */
@@ -339,12 +378,44 @@ static inline bool list_entry_in_list(const struct list_head *entry)
/* <linux/printk.h> */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) && !defined(RHEL_MAJOR)
#define KERN_CONT ""
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28)
#ifndef pr_err
#define pr_err(fmt, ...) printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
/*
* See also the following commits:
* d091c2f5 - Introduction of pr_info() etc. in <linux/kernel.h>.
* 311d0761 - Introduction of pr_cont() in <linux/kernel.h>.
* 968ab183 - Moved pr_info() etc. from <linux/kernel.h> to <linux/printk.h>
*/
#ifndef pr_emerg
#ifndef pr_fmt
#define pr_fmt(fmt) fmt
#endif
#define pr_emerg(fmt, ...) printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
#define pr_alert(fmt, ...) printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
#define pr_crit(fmt, ...) printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
#define pr_err(fmt, ...) printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
#define pr_warning(fmt, ...) printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
#define pr_notice(fmt, ...) printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
#endif /* pr_emerg */
#ifndef pr_info
#define pr_info(fmt, ...) printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
#endif
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
#ifndef pr_cont
#define pr_cont(fmt, ...) printk(KERN_CONT fmt, ##__VA_ARGS__)
#endif
#endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 35)
/*
* See also patch "kernel.h: add pr_warn for symmetry to dev_warn,
@@ -365,6 +436,43 @@ static inline __attribute__ ((format (printf, 1, 2)))
int no_printk(const char *s, ...) { return 0; }
#endif
/* <linux/ratelimit.h> */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27)
/* See also commit 717115e1a585 */
#define DEFAULT_RATELIMIT_INTERVAL (5 * HZ)
#define DEFAULT_RATELIMIT_BURST 10
struct ratelimit_state {
int interval;
int burst;
};
#define DEFINE_RATELIMIT_STATE(name, interval, burst) \
struct ratelimit_state name = {interval, burst,}
static inline int __ratelimit(struct ratelimit_state *rs)
{
return 1;
}
#endif
/* <linux/rcupdate.h> */
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 0, 0) && !defined(kfree_rcu)
typedef void (*rcu_callback_t)(struct rcu_head *);
#define __is_kfree_rcu_offset(offset) ((offset) < 4096)
#define kfree_call_rcu(head, rcb) call_rcu(head, rcb)
#define __kfree_rcu(head, offset) \
do { \
BUILD_BUG_ON(!__is_kfree_rcu_offset(offset)); \
kfree_call_rcu(head, (rcu_callback_t)(unsigned long)(offset)); \
} while (0)
#define kfree_rcu(ptr, rcu_head) \
__kfree_rcu(&((ptr)->rcu_head), offsetof(typeof(*(ptr)), rcu_head))
#endif
/* <linux/sched.h> */
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 26) && \
+7 -3
View File
@@ -1,9 +1,9 @@
/*
* include/scst.h
*
* Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2005 Leonid Stoljar
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 SanDisk Corporation
* Copyright (C) 2010 - 2011 Bart Van Assche <bvanassche@acm.org>.
*
* Main SCSI target mid-level include file.
@@ -29,6 +29,7 @@
/** See README for description of those conditional defines **/
#define CONFIG_SCST_DIF_INJECT_CORRUPTED_TAGS
/* #define CONFIG_SCST_FORWARD_MODE_PASS_THROUGH */
#include <linux/types.h>
#ifndef INSIDE_KERNEL_TREE
@@ -1818,7 +1819,7 @@ struct scst_tgt {
/* Divide two 64-bit numbers with reasonably accuracy. */
static inline void __scst_time_per_cmd(uint64_t *t, uint64_t n)
{
unsigned shift;
unsigned int shift;
if (!n)
return;
@@ -3829,6 +3830,7 @@ static inline void scst_sess_set_tgt_priv(struct scst_session *sess,
}
uint16_t scst_lookup_tg_id(struct scst_device *dev, struct scst_tgt *tgt);
enum scst_tg_state scst_get_alua_state(struct scst_device *dev, struct scst_tgt *tgt);
bool scst_alua_configured(struct scst_device *dev);
int scst_tg_get_group_info(void **buf, uint32_t *response_length,
struct scst_device *dev, uint8_t data_format);
@@ -5679,8 +5681,10 @@ struct scst_ext_copy_seg_descr {
int tgt_descr_offs;
};
#ifndef CONFIG_SCST_PROC
void scst_ext_copy_remap_done(struct scst_cmd *ec_cmd,
struct scst_ext_copy_data_descr *dds, int dds_cnt);
int scst_ext_copy_get_cur_seg_data_len(struct scst_cmd *ec_cmd);
#endif
#endif /* __SCST_H */
+4 -4
View File
@@ -1,8 +1,8 @@
/*
* include/scst_const.h
*
* Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* Contains common SCST constants. This file supposed to be included
* from both kernel and user spaces.
@@ -341,7 +341,7 @@ static inline int scst_sense_response_code(const uint8_t *sense)
#define scst_sense_reported_luns_data_changed UNIT_ATTENTION, 0x3F, 0xE
/* DATA_PROTECT is 7 */
#define scst_sense_data_protect DATA_PROTECT, 0x00, 0
#define scst_sense_data_protect DATA_PROTECT, 0x27, 0
/* ABORTED_COMMAND is 0xb */
#define scst_sense_aborted_command ABORTED_COMMAND, 0x00, 0
@@ -481,7 +481,7 @@ static inline int scst_sense_response_code(const uint8_t *sense)
* From <linux/fs.h>. See also commit
* d30a2605be9d5132d95944916e8f578fcfe4f976.
*/
#define BLKDISCARD _IO(0x12,119)
#define BLKDISCARD _IO(0x12, 119)
#endif
/*************************************************************
+21 -47
View File
@@ -1,9 +1,9 @@
/*
* include/scst_debug.h
*
* Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2005 Leonid Stoljar
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* Contains macros for execution tracing and error reporting
*
@@ -31,41 +31,14 @@
#include <linux/bug.h> /* for WARN_ON_ONCE */
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28)
/*
* See also the following commits:
* d091c2f5 - Introduction of pr_info() etc. in <linux/kernel.h>.
* 311d0761 - Introduction of pr_cont() in <linux/kernel.h>.
* 968ab183 - Moved pr_info() etc. from <linux/kernel.h> to <linux/printk.h>
*/
#ifndef pr_emerg
#ifndef pr_fmt
#define pr_fmt(fmt) fmt
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 27)
#include <linux/ratelimit.h>
#endif
#define pr_emerg(fmt, ...) \
printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
#define pr_alert(fmt, ...) \
printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
#define pr_crit(fmt, ...) \
printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
#define pr_err(fmt, ...) \
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
#define pr_warning(fmt, ...) \
printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
#define pr_notice(fmt, ...) \
printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
#endif
#ifndef pr_info
#define pr_info(fmt, ...) \
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
#endif
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30)
#ifndef pr_cont
#define pr_cont(fmt, ...) \
printk(KERN_CONT fmt, ##__VA_ARGS__)
#endif
#ifdef INSIDE_KERNEL_TREE
#include <scst/backport.h>
#else
#include <backport.h>
#endif
#if !defined(INSIDE_KERNEL_TREE)
@@ -144,10 +117,6 @@
#define TRACE_MINOR_AND_MGMT_DBG (TRACE_MINOR|TRACE_MGMT_DEBUG)
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 24) && !defined(RHEL_MAJOR)
#define KERN_CONT ""
#endif
/*
* Note: in the next two printk() statements the KERN_CONT macro is only
* present to suppress a checkpatch warning (KERN_CONT is defined as "").
@@ -171,12 +140,7 @@
#define ___unlikely(a) unlikely(a)
#endif
int
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 21) || defined(__printf)
__printf(6, 7)
#else
__attribute__((format(printf, 6, 7)))
#endif
int __printf(6, 7)
debug_print_with_prefix(unsigned long trace_flag,
const char *severity, const char *prefix, const char *func, int line,
const char *fmt, ...);
@@ -245,7 +209,7 @@ do { \
#define TRACING_MINOR() (false)
#define TRACE(trace, format, args...) \
((void)(trace), no_printk(format, ##args))
do { (void)(trace); no_printk(format, ##args); } while (0)
#define PRINT_BUFFER(message, buff, len) \
((void)(message), (void)(buff), (void)(len))
#define PRINT_BUFF_FLAG(flag, message, buff, len) \
@@ -284,6 +248,16 @@ do { \
#endif /* CONFIG_SCST_DEBUG || CONFIG_SCST_TRACING */
#define PRINT_ERROR_RATELIMITED(format, args...) \
do { \
static DEFINE_RATELIMIT_STATE(_rs, \
DEFAULT_RATELIMIT_INTERVAL, \
DEFAULT_RATELIMIT_BURST); \
\
if (__ratelimit(&_rs)) \
PRINT_ERROR(format, ##args); \
} while (0)
#ifdef CONFIG_SCST_DEBUG
#define TRACE_DBG_FLAG(trace, format, args...) \
@@ -391,7 +365,7 @@ do { \
#define TRACE_SG(format, args...) no_printk(format, ##args)
#define TRACE_DBG(format, args...) no_printk(format, ##args)
#define TRACE_DBG_FLAG(flag, format, args...) \
((void)(flag), no_printk(format, ##args))
do { (void)(flag); no_printk(format, ##args); } while (0)
#define TRACE_DBG_SPECIAL(format, args...) no_printk(format, ##args)
#define TRACE_MGMT_DBG(format, args...) no_printk(format, ##args)
#define TRACE_MGMT_DBG_SPECIAL(format, args...) no_printk(format, ##args)
+1 -1
View File
@@ -1,7 +1,7 @@
/*
* include/scst_event.h
*
* Copyright (C) 2014 - 2015 SanDisk Corporation
* Copyright (C) 2014 - 2016 SanDisk Corporation
*
* Contains constants and data structures for scst_event module.
*/
+2 -2
View File
@@ -1,8 +1,8 @@
/*
* include/scst_sgv.h
*
* Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* Include file for SCST SGV cache.
*
+2 -2
View File
@@ -1,8 +1,8 @@
/*
* include/scst_user.h
*
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* Contains constants and data structures for scst_user module.
* See http://scst.sourceforge.net/doc/scst_user_spec.txt or
@@ -0,0 +1,13 @@
diff --git a/drivers/Kconfig b/drivers/Kconfig
index c70d6e4..0a4ed1b 100644
--- a/drivers/Kconfig
+++ b/drivers/Kconfig
@@ -26,6 +26,8 @@ source "drivers/ide/Kconfig"
source "drivers/scsi/Kconfig"
+source "drivers/scst/Kconfig"
+
source "drivers/ata/Kconfig"
source "drivers/md/Kconfig"
@@ -0,0 +1,14 @@
ccflags-y += -Wno-unused-parameter
obj-m := scst_cdrom.o scst_changer.o scst_disk.o scst_modisk.o scst_tape.o \
scst_vdisk.o scst_raid.o scst_processor.o scst_user.o
obj-$(CONFIG_SCST_DISK) += scst_disk.o
obj-$(CONFIG_SCST_TAPE) += scst_tape.o
obj-$(CONFIG_SCST_CDROM) += scst_cdrom.o
obj-$(CONFIG_SCST_MODISK) += scst_modisk.o
obj-$(CONFIG_SCST_CHANGER) += scst_changer.o
obj-$(CONFIG_SCST_RAID) += scst_raid.o
obj-$(CONFIG_SCST_PROCESSOR) += scst_processor.o
obj-$(CONFIG_SCST_VDISK) += scst_vdisk.o
obj-$(CONFIG_SCST_USER) += scst_user.o
@@ -0,0 +1,12 @@
diff --git a/drivers/Makefile b/drivers/Makefile
index 527a6da..db2c24f 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -137,6 +137,7 @@ obj-$(CONFIG_SSB) += ssb/
obj-$(CONFIG_BCMA) += bcma/
obj-$(CONFIG_VHOST_RING) += vhost/
obj-$(CONFIG_VLYNQ) += vlynq/
+obj-$(CONFIG_SCST) += scst/
obj-$(CONFIG_STAGING) += staging/
obj-y += platform/
#common clk code
+17
View File
@@ -0,0 +1,17 @@
ccflags-y += -Wno-unused-parameter
scst-y += scst_copy_mgr.o
scst-y += scst_debug.o
scst-y += scst_dlm.o
scst-y += scst_event.o
scst-y += scst_lib.o
scst-y += scst_main.o
scst-y += scst_mem.o
scst-y += scst_no_dlm.o
scst-y += scst_pres.o
scst-y += scst_sysfs.o
scst-y += scst_targ.o
scst-y += scst_tg.o
obj-$(CONFIG_SCST) += scst.o dev_handlers/ fcst/ iscsi-scst/ qla2xxx-target/ \
srpt/ scst_local/
+4 -8
View File
@@ -1,9 +1,9 @@
#
# SCSI target mid-level makefile
#
# Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
# Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
# Copyright (C) 2004 - 2005 Leonid Stoljar
# Copyright (C) 2007 - 2015 SanDisk Corporation
# Copyright (C) 2007 - 2016 SanDisk Corporation
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
@@ -49,12 +49,7 @@ scst-y += scst_mem.o
scst-y += scst_debug.o
scst-y += scst_pres.o
scst-y += scst_no_dlm.o
ifdef CONFIG_DLM
scst-y += scst_dlm.o
endif
ifdef CONFIG_DLM_MODULE
scst-y += scst_dlm.o
endif
scst-y += scst_tg.o
scst-y += scst_event.o
scst-y += scst_copy_mgr.o
@@ -160,7 +155,8 @@ INSTALL_DIR_H := $(DESTDIR)$(PREFIX)/include/scst
enable-Wextra = $(shell uname_r="$$(uname -r)"; if [ "$${uname_r%.el5}" = "$${uname_r}" ]; then echo "$(1)"; fi)
EXTRA_CFLAGS += -I$(SCST_INC_DIR) $(call enable-Wextra,-Wextra \
-Wno-unused-parameter -Wno-missing-field-initializers)
-Wno-unused-parameter -Wno-missing-field-initializers) \
$(shell [ -n "${CONFIG_SCST_NO_DLM}" ] && echo -DCONFIG_SCST_NO_DLM)
#EXTRA_CFLAGS += -DCONFIG_SCST_STRICT_SERIALIZING
+2 -2
View File
@@ -1,9 +1,9 @@
#
# SCSI target mid-level dev handler's makefile
#
# Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
# Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
# Copyright (C) 2004 - 2005 Leonid Stoljar
# Copyright (C) 2007 - 2015 SanDisk Corporation
# Copyright (C) 2007 - 2016 SanDisk Corporation
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
+3 -3
View File
@@ -1,9 +1,9 @@
/*
* scst_cdrom.c
*
* Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2005 Leonid Stoljar
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* SCSI CDROM (type 5) dev handler
*
@@ -99,7 +99,7 @@ static int cdrom_attach(struct scst_device *dev)
rc = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer,
buffer_size, sense_buffer,
SCST_GENERIC_CDROM_REG_TIMEOUT, 3, 0
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
, NULL
#endif
);
+2 -2
View File
@@ -1,9 +1,9 @@
/*
* scst_changer.c
*
* Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2005 Leonid Stoljar
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* SCSI medium changer (type 8) dev handler
*
+1
View File
@@ -81,6 +81,7 @@ static int scst_dev_handler_build_std_proc(struct scst_dev_type *dev_type)
/* Create the proc file entry for the device */
/* Workaround to keep /proc ABI intact */
const char *name;
if (strcmp(dev_type->name, "vdisk_fileio") == 0)
name = "vdisk";
else
+35 -3
View File
@@ -1,9 +1,9 @@
/*
* scst_disk.c
*
* Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2005 Leonid Stoljar
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* SCSI disk (type 0) dev handler
* &
@@ -196,7 +196,7 @@ static int disk_attach(struct scst_device *dev)
rc = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer,
buffer_size, sense_buffer,
SCST_GENERIC_DISK_REG_TIMEOUT, 3, 0
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
, NULL
#endif
);
@@ -268,6 +268,20 @@ static int disk_parse(struct scst_cmd *cmd)
goto out;
}
#ifdef CONFIG_SCST_FORWARD_MODE_PASS_THROUGH
if (unlikely(cmd->op_flags & SCST_LOCAL_CMD)) {
switch (cmd->cdb[0]) {
case COMPARE_AND_WRITE:
case EXTENDED_COPY:
case RECEIVE_COPY_RESULTS:
TRACE_DBG("Clearing LOCAL CMD flag for cmd %p "
"(op %s)", cmd, cmd->op_name);
cmd->op_flags &= ~SCST_LOCAL_CMD;
break;
}
}
#endif
cmd->retries = SCST_PASSTHROUGH_RETRIES;
out:
return res;
@@ -400,6 +414,24 @@ static int disk_exec(struct scst_cmd *cmd)
TRACE_ENTRY();
#ifdef CONFIG_SCST_FORWARD_MODE_PASS_THROUGH
if (unlikely(cmd->op_flags & SCST_LOCAL_CMD)) {
switch (cmd->cdb[0]) {
case RESERVE:
case RESERVE_10:
case RELEASE:
case RELEASE_10:
TRACE_DBG("Skipping LOCAL cmd %p (op %s)",
cmd, cmd->op_name);
goto out_done;
case PERSISTENT_RESERVE_IN:
case PERSISTENT_RESERVE_OUT:
sBUG();
break;
}
}
#endif
/*
* For PC requests we are going to submit max_hw_sectors used instead
* of max_sectors.
+3 -3
View File
@@ -1,9 +1,9 @@
/*
* scst_modisk.c
*
* Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2005 Leonid Stoljar
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* SCSI MO disk (type 7) dev handler
* &
@@ -200,7 +200,7 @@ static int modisk_attach(struct scst_device *dev)
rc = scsi_execute(dev->scsi_dev, cmd, data_dir, buffer,
buffer_size, sense_buffer,
SCST_GENERIC_MODISK_REG_TIMEOUT, 3, 0
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,29)
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 29)
, NULL
#endif
);
+2 -2
View File
@@ -1,9 +1,9 @@
/*
* scst_processor.c
*
* Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2005 Leonid Stoljar
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* SCSI medium processor (type 3) dev handler
*
+2 -2
View File
@@ -1,9 +1,9 @@
/*
* scst_raid.c
*
* Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2005 Leonid Stoljar
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* SCSI raid(controller) (type 0xC) dev handler
*
+2 -2
View File
@@ -1,9 +1,9 @@
/*
* scst_tape.c
*
* Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2005 Leonid Stoljar
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* SCSI tape (type 1) dev handler
* &
+23 -10
View File
@@ -1,8 +1,8 @@
/*
* scst_user.c
*
* Copyright (C) 2007 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2007 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2007 - 2016 SanDisk Corporation
*
* SCSI virtual user space device handler
*
@@ -36,10 +36,10 @@
#ifndef INSIDE_KERNEL_TREE
#if defined(CONFIG_HIGHMEM4G) || defined(CONFIG_HIGHMEM64G)
#warning HIGHMEM kernel configurations are not supported by this module,\
because nowadays it is not worth the effort. Consider changing\
VMSPLIT option or use a 64-bit configuration instead. See README file\
for details.
#warning HIGHMEM kernel configurations are not supported by this module, \
because nowadays it is not worth the effort. Consider changing \
VMSPLIT option or use a 64-bit configuration instead. See README file \
for details.
#endif
#endif
@@ -955,6 +955,7 @@ static int dev_user_exec(struct scst_cmd *cmd)
return res;
}
#ifndef CONFIG_SCST_PROC
static void dev_user_ext_copy_remap(struct scst_cmd *cmd,
struct scst_ext_copy_seg_descr *seg)
{
@@ -985,6 +986,7 @@ static void dev_user_ext_copy_remap(struct scst_cmd *cmd,
TRACE_EXIT();
return;
}
#endif
static void dev_user_free_sgv(struct scst_user_cmd *ucmd)
{
@@ -1265,8 +1267,8 @@ static int dev_user_map_buf(struct scst_user_cmd *ucmd, unsigned long ubuff,
(ucmd->cmd != NULL) ? ucmd->cmd->bufflen : -1);
down_read(&tsk->mm->mmap_sem);
rc = get_user_pages(tsk, tsk->mm, ubuff, ucmd->num_data_pages,
1/*writable*/, 0/*don't force*/, ucmd->data_pages, NULL);
rc = get_user_pages(ubuff, ucmd->num_data_pages, 1/*writable*/,
0/*don't force*/, ucmd->data_pages, NULL);
up_read(&tsk->mm->mmap_sem);
/* get_user_pages() flushes dcache */
@@ -1485,6 +1487,7 @@ static int dev_user_process_reply_on_cache_free(struct scst_user_cmd *ucmd)
return res;
}
#ifndef CONFIG_SCST_PROC
static int dev_user_process_reply_ext_copy_remap(struct scst_user_cmd *ucmd,
struct scst_user_reply_cmd *reply)
{
@@ -1628,6 +1631,7 @@ out_status:
scst_set_cmd_error_status(cmd, rreply->status);
goto out_done;
}
#endif
static int dev_user_process_ws_reply(struct scst_user_cmd *ucmd,
struct scst_user_scsi_cmd_reply_exec *ereply)
@@ -1950,9 +1954,11 @@ unlock_process:
res = dev_user_process_reply_on_cache_free(ucmd);
break;
#ifndef CONFIG_SCST_PROC
case UCMD_STATE_EXT_COPY_REMAPPING:
res = dev_user_process_reply_ext_copy_remap(ucmd, reply);
break;
#endif
case UCMD_STATE_TM_RECEIVED_EXECING:
case UCMD_STATE_TM_DONE_EXECING:
@@ -2677,7 +2683,11 @@ static void dev_user_unjam_cmd(struct scst_user_cmd *ucmd, int busy,
SCST_CONTEXT_THREAD);
else {
sBUG_ON(state != UCMD_STATE_EXT_COPY_REMAPPING);
#ifndef CONFIG_SCST_PROC
scst_ext_copy_remap_done(ucmd->cmd, NULL, 0);
#else
sBUG();
#endif
}
/* !! At this point cmd and ucmd can be already freed !! */
@@ -3217,10 +3227,11 @@ static void dev_user_setup_functions(struct scst_user_dev *dev)
dev->devtype.dev_alloc_data_buf = dev_user_alloc_data_buf;
dev->devtype.dev_done = NULL;
dev->devtype.ext_copy_remap = NULL;
#ifndef CONFIG_SCST_PROC
if (dev->ext_copy_remap_supported)
dev->devtype.ext_copy_remap = dev_user_ext_copy_remap;
else
dev->devtype.ext_copy_remap = NULL;
#endif
if (dev->parse_type != SCST_USER_PARSE_CALL) {
switch (dev->devtype.type) {
@@ -4037,11 +4048,13 @@ static int dev_user_read_proc(struct seq_file *seq, struct scst_dev_type *dev_ty
list_for_each_entry(dev, &dev_list, dev_list_entry) {
int i;
seq_printf(seq, "Device %s commands:\n", dev->name);
spin_lock_irqsave(&dev->udev_cmd_threads.cmd_list_lock, flags);
for (i = 0; i < (int)ARRAY_SIZE(dev->ucmd_hash); i++) {
struct list_head *head = &dev->ucmd_hash[i];
struct scst_user_cmd *ucmd;
list_for_each_entry(ucmd, head, hash_list_entry) {
seq_printf(seq, "ucmd %p (state %x, ref %d), "
"sent_to_user %d, seen_by_user %d, "
+74 -52
View File
@@ -1,12 +1,12 @@
/*
* scst_vdisk.c
*
* Copyright (C) 2004 - 2015 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2016 Vladislav Bolkhovitin <vst@vlnb.net>
* Copyright (C) 2004 - 2005 Leonid Stoljar
* Copyright (C) 2007 Ming Zhang <blackmagic02881 at gmail dot com>
* Copyright (C) 2007 Ross Walker <rswwalker at hotmail dot com>
* Copyright (C) 2007 - 2015 SanDisk Corporation
* Copyright (C) 2008 - 2015 Bart Van Assche <bvanassche@acm.org>
* Copyright (C) 2007 - 2016 SanDisk Corporation
* Copyright (C) 2008 - 2016 Bart Van Assche <bvanassche@acm.org>
*
* SCSI disk (type 0) and CDROM (type 5) dev handler using files
* on file systems or block devices (VDISK)
@@ -22,6 +22,9 @@
* GNU General Public License for more details.
*/
#ifndef INSIDE_KERNEL_TREE
#include <linux/version.h>
#endif
#include <linux/file.h>
#include <linux/fs.h>
#include <linux/string.h>
@@ -34,14 +37,15 @@
#include <linux/ctype.h>
#include <linux/writeback.h>
#include <linux/vmalloc.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
#include <linux/atomic.h>
#else
#include <asm/atomic.h>
#endif
#include <linux/kthread.h>
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/namei.h>
#ifndef INSIDE_KERNEL_TREE
#include <linux/version.h>
#endif
#include <asm/div64.h>
#include <asm/unaligned.h>
#include <linux/slab.h>
@@ -789,7 +793,7 @@ static struct scst_dev_type vdisk_blk_devtype = {
static struct scst_dev_type vdisk_null_devtype = {
.name = "vdisk_nullio",
.type = TYPE_DISK,
.threads_num = 0,
.threads_num = 1,
.parse_atomic = 1,
.dev_done_atomic = 1,
#ifdef CONFIG_SCST_PROC
@@ -1407,6 +1411,7 @@ static int vdisk_init_block_integrity(struct scst_vdisk_dev *virt_dev)
struct inode *inode;
struct file *fd;
struct blk_integrity *bi;
const char *bi_profile_name;
TRACE_ENTRY();
@@ -1430,9 +1435,14 @@ static int vdisk_init_block_integrity(struct scst_vdisk_dev *virt_dev)
goto out_no_bi;
}
TRACE_DBG("BI name %s", bi->name);
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
bi_profile_name = bi->name;
#else
bi_profile_name = bi->profile->name;
#endif
TRACE_DBG("BI name %s", bi_profile_name);
if (!strcmp(bi->name, "T10-DIF-TYPE1-CRC")) {
if (!strcmp(bi_profile_name, "T10-DIF-TYPE1-CRC")) {
dev->dev_dif_ip_not_supported = 1;
if (virt_dev->dif_type != 1) {
PRINT_ERROR("Integrity type mismatch, %d expected, "
@@ -1441,7 +1451,7 @@ static int vdisk_init_block_integrity(struct scst_vdisk_dev *virt_dev)
res = -EINVAL;
goto out_close;
}
} else if (!strcmp(bi->name, "T10-DIF-TYPE1-IP")) {
} else if (!strcmp(bi_profile_name, "T10-DIF-TYPE1-IP")) {
if (virt_dev->dif_type != 1) {
PRINT_ERROR("Integrity type mismatch, %d expected, "
"but block device has 1 (dev %s)",
@@ -1449,7 +1459,7 @@ static int vdisk_init_block_integrity(struct scst_vdisk_dev *virt_dev)
res = -EINVAL;
goto out_close;
}
} else if (!strcmp(bi->name, "T10-DIF-TYPE3-CRC")) {
} else if (!strcmp(bi_profile_name, "T10-DIF-TYPE3-CRC")) {
dev->dev_dif_ip_not_supported = 1;
if (virt_dev->dif_type != 3) {
PRINT_ERROR("Integrity type mismatch, %d expected, "
@@ -1458,7 +1468,7 @@ static int vdisk_init_block_integrity(struct scst_vdisk_dev *virt_dev)
res = -EINVAL;
goto out_close;
}
} else if (!strcmp(bi->name, "T10-DIF-TYPE3-IP")) {
} else if (!strcmp(bi_profile_name, "T10-DIF-TYPE3-IP")) {
if (virt_dev->dif_type != 3) {
PRINT_ERROR("Integrity type mismatch, %d expected, "
"but block device has 3 (dev %s)",
@@ -1468,7 +1478,7 @@ static int vdisk_init_block_integrity(struct scst_vdisk_dev *virt_dev)
}
} else {
PRINT_ERROR("Unable to understand integrity name %s"
"(dev %s)", bi->name, dev->virt_name);
"(dev %s)", bi_profile_name, dev->virt_name);
res = -EINVAL;
goto out_close;
}
@@ -2017,8 +2027,8 @@ static int vdisk_format_dif(struct scst_cmd *cmd, uint64_t start_lba,
full_len, (long long)loff);
/* WRITE */
err = vfs_writev(fd, (struct iovec __force __user *)iv, iv_count,
&loff);
err = vfs_writev(fd, (struct iovec __force __user *)iv,
iv_count, &loff, 0);
if (err < 0) {
PRINT_ERROR("Formatting DIF write() returned %lld from "
"%zd", err, full_len);
@@ -2039,7 +2049,7 @@ static int vdisk_format_dif(struct scst_cmd *cmd, uint64_t start_lba,
}
virt_dev->format_progress_done = done;
};
}
out_set_fs:
set_fs(old_fs);
@@ -2790,6 +2800,7 @@ static const struct scst_opcode_descriptor *vdisk_opcode_descriptors_type2[] = {
&scst_op_descr_write_verify32,
&scst_op_descr_write_same32,
SCST_OPCODE_DESCRIPTORS
&scst_op_descr_stpg, /* must be last, see vdisk_get_supported_opcodes()! */
};
static const struct scst_opcode_descriptor *vcdrom_opcode_descriptors[] = {
@@ -3310,7 +3321,8 @@ err:
* @small_sg_size: size of @small_sg
* @p_sg_cnt: pointer to an int where the sg vector size will be written
*/
static struct scatterlist *alloc_sg(size_t size, unsigned off, gfp_t gfp_mask,
static struct scatterlist *alloc_sg(size_t size, unsigned int off,
gfp_t gfp_mask,
struct scatterlist *small_sg,
int small_sg_size, int *p_sg_cnt)
{
@@ -3492,6 +3504,12 @@ static int fileio_exec(struct scst_cmd *cmd)
return vdev_do_job(cmd, ops);
}
static void vdisk_on_free_cmd_params(const struct vdisk_cmd_params *p)
{
if (p->iv != p->small_iv)
kfree(p->iv);
}
static void fileio_on_free_cmd(struct scst_cmd *cmd)
{
struct vdisk_cmd_params *p = cmd->dh_priv;
@@ -3516,8 +3534,7 @@ static void fileio_on_free_cmd(struct scst_cmd *cmd)
cmd->data_len = 0;
}
if (p->iv != p->small_iv)
kfree(p->iv);
vdisk_on_free_cmd_params(p);
kmem_cache_free(vdisk_cmd_param_cachep, p);
@@ -3539,7 +3556,6 @@ static bool vdisk_no_fd_allowed_commands(const struct scst_cmd *cmd)
switch (cmd->cdb[0]) {
case TEST_UNIT_READY:
case GET_EVENT_STATUS_NOTIFICATION:
case INQUIRY:
case MODE_SENSE:
case MODE_SENSE_10:
@@ -3607,9 +3623,15 @@ static int blockio_exec(struct scst_cmd *cmd)
if (unlikely(virt_dev->fd == NULL)) {
if (!vdisk_no_fd_allowed_commands(cmd)) {
/* We should not get here */
PRINT_WARNING("Closed FD on exec. Secondary DRBD or not "
"blocked dev before ALUA state change? "
/*
* We should not get here, unless the user space
* misconfiguring something, e.g. set optimized
* ALUA state for secondary DRBD device. See
* "DRBD and other replication/failover SW
* compatibility" section in SCST README.
*/
PRINT_WARNING("Closed FD on exec. Not active ALUA state "
"or not blocked dev before ALUA state change? "
"(cmd %p, op %s, dev %s)", cmd, cmd->op_name,
cmd->dev->virt_name);
scst_set_cmd_error(cmd, SCST_LOAD_SENSE(scst_sense_no_medium));
@@ -3622,6 +3644,7 @@ static int blockio_exec(struct scst_cmd *cmd)
cmd->dh_priv = NULL;
out:
vdisk_on_free_cmd_params(&p);
return res;
err:
@@ -3649,6 +3672,7 @@ static int nullio_exec(struct scst_cmd *cmd)
cmd->dh_priv = NULL;
out:
vdisk_on_free_cmd_params(&p);
return res;
err:
@@ -4361,6 +4385,7 @@ static enum compl_status_e vdisk_exec_inquiry(struct vdisk_cmd_params *p)
uint8_t *buf;
struct scst_device *dev = cmd->dev;
struct scst_vdisk_dev *virt_dev = dev->dh_priv;
enum scst_tg_state alua_state;
TRACE_ENTRY();
@@ -4382,8 +4407,13 @@ static enum compl_status_e vdisk_exec_inquiry(struct vdisk_cmd_params *p)
goto out_put;
}
buf[0] = virt_dev->dummy ? SCSI_INQ_PQ_NOT_CON << 5 | 0x1f :
SCSI_INQ_PQ_CON << 5 | dev->type;
alua_state = scst_get_alua_state(cmd->dev, cmd->tgt);
if ((alua_state == SCST_TG_STATE_UNAVAILABLE) ||
(alua_state == SCST_TG_STATE_OFFLINE))
buf[0] = SCSI_INQ_PQ_NOT_CON << 5 | dev->type;
else
buf[0] = virt_dev->dummy ? SCSI_INQ_PQ_NOT_CON << 5 | 0x1f :
SCSI_INQ_PQ_CON << 5 | dev->type;
/* Vital Product */
if (cmd->cdb[1] & EVPD) {
if (cmd->cdb[2] == 0) {
@@ -5768,7 +5798,6 @@ static int vdev_read_dif_tags(struct vdisk_cmd_params *p)
bool finished = false;
int tags_num, l;
struct scatterlist *tags_sg;
bool free_iv = false;
TRACE_ENTRY();
@@ -5803,7 +5832,6 @@ static int vdev_read_dif_tags(struct vdisk_cmd_params *p)
res = -ENOMEM;
goto out;
}
free_iv = true;
}
max_iv_count = p->iv_count;
@@ -5841,7 +5869,7 @@ static int vdev_read_dif_tags(struct vdisk_cmd_params *p)
/* READ */
err = vfs_readv(fd, (struct iovec __force __user *)iv, iv_count,
&loff);
&loff, 0);
if ((err < 0) || (err < full_len)) {
unsigned long flags;
@@ -5866,14 +5894,10 @@ static int vdev_read_dif_tags(struct vdisk_cmd_params *p)
if (finished)
break;
};
}
set_fs(old_fs);
out_free_iv:
if (free_iv && (iv != p->small_iv))
kfree(p->iv);
out:
TRACE_EXIT_RES(res);
return res;
@@ -5882,7 +5906,7 @@ out_set_fs:
set_fs(old_fs);
for (i = 0; i < iv_count; i++)
scst_put_dif_buf(cmd, (void __force *)(iv[i].iov_base));
goto out_free_iv;
goto out;
}
static int vdev_write_dif_tags(struct vdisk_cmd_params *p)
@@ -5901,7 +5925,6 @@ static int vdev_write_dif_tags(struct vdisk_cmd_params *p)
bool finished = false;
int tags_num, l;
struct scatterlist *tags_sg;
bool free_iv = false;
TRACE_ENTRY();
@@ -5936,7 +5959,6 @@ static int vdev_write_dif_tags(struct vdisk_cmd_params *p)
res = -ENOMEM;
goto out;
}
free_iv = true;
}
max_iv_count = p->iv_count;
@@ -5975,8 +5997,8 @@ restart:
TRACE_DBG("Writing DIF: eiv_count %d, full_len %zd", eiv_count, full_len);
/* WRITE */
err = vfs_writev(fd, (struct iovec __force __user *)eiv, eiv_count,
&loff);
err = vfs_writev(fd, (struct iovec __force __user *)eiv,
eiv_count, &loff, 0);
if (err < 0) {
unsigned long flags;
@@ -6028,14 +6050,10 @@ restart:
if (finished)
break;
};
}
set_fs(old_fs);
out_free_iv:
if (free_iv && (iv != p->small_iv))
kfree(iv);
out:
TRACE_EXIT_RES(res);
return res;
@@ -6044,7 +6062,7 @@ out_set_fs:
set_fs(old_fs);
for (i = 0; i < iv_count; i++)
scst_put_dif_buf(cmd, (void __force *)(iv[i].iov_base));
goto out_free_iv;
goto out;
}
static enum compl_status_e blockio_exec_read(struct vdisk_cmd_params *p)
@@ -6122,7 +6140,7 @@ static enum compl_status_e fileio_exec_read(struct vdisk_cmd_params *p)
/* READ */
err = vfs_readv(fd, (struct iovec __force __user *)iv, iv_count,
&loff);
&loff, 0);
if ((err < 0) || (err < full_len)) {
PRINT_ERROR("readv() returned %lld from %zd",
(unsigned long long int)err,
@@ -6143,7 +6161,7 @@ static enum compl_status_e fileio_exec_read(struct vdisk_cmd_params *p)
break;
length = scst_get_buf_next(cmd, (uint8_t __force **)&address);
};
}
set_fs(old_fs);
@@ -6315,8 +6333,8 @@ restart:
TRACE_DBG("Writing: eiv_count %d, full_len %zd", eiv_count, full_len);
/* WRITE */
err = vfs_writev(fd, (struct iovec __force __user *)eiv, eiv_count,
&loff);
err = vfs_writev(fd, (struct iovec __force __user *)eiv,
eiv_count, &loff, 0);
if (err < 0) {
PRINT_ERROR("write() returned %lld from %zd",
(unsigned long long int)err,
@@ -6433,6 +6451,7 @@ static inline void blockio_check_finish(struct scst_blockio_work *blockio_work)
static void blockio_bio_destructor(struct bio *bio)
{
struct scst_blockio_work *blockio_work = bio->bi_private;
bio_free(bio, blockio_work->bioset);
blockio_check_finish(blockio_work);
}
@@ -6469,7 +6488,8 @@ static void blockio_endio(struct bio *bio)
if (unlikely(error != 0)) {
unsigned long flags;
PRINT_ERROR("BLOCKIO for cmd %p finished with error %d",
PRINT_ERROR_RATELIMITED(
"BLOCKIO for cmd %p finished with error %d",
blockio_work->cmd, error);
/*
@@ -6990,6 +7010,7 @@ struct bio_priv_sync {
static void blockio_bio_destructor_sync(struct bio *bio)
{
struct bio_priv_sync *s = bio->bi_private;
bio_free(bio, s->bs);
complete(&s->c1);
}
@@ -7043,7 +7064,7 @@ static void blockio_end_sync_io(struct bio *bio)
* Increments *@loff with the number of bytes transferred upon success.
*/
static ssize_t blockio_rw_sync(struct scst_vdisk_dev *virt_dev, void *buf,
size_t len, loff_t *loff, unsigned rw)
size_t len, loff_t *loff, unsigned int rw)
{
struct bio_priv_sync s = {
COMPLETION_INITIALIZER_ONSTACK(s.c), 0,
@@ -7058,7 +7079,7 @@ static ssize_t blockio_rw_sync(struct scst_vdisk_dev *virt_dev, void *buf,
void *p;
struct page *q;
int max_nr_vecs, rc;
unsigned bytes, off;
unsigned int bytes, off;
ssize_t ret = -ENOMEM;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 30)) && (LINUX_VERSION_CODE <= KERNEL_VERSION(3, 6, 0))
bool submitted = false;
@@ -8671,7 +8692,7 @@ out:
return res;
out_free:
kfree(buf);
kfree(new_size);
goto out;
}
@@ -10103,6 +10124,7 @@ static int vdisk_write_proc(char *buffer, char **start, off_t offset,
if (isdigit(*p)) {
char *pp;
block_size = simple_strtoul(p, &pp, 0);
p = pp;
if ((*p != '\0') && !isspace(*p)) {
+120 -163
View File
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2013 - 2015 SanDisk Corporation
* Copyright (C) 2013 - 2016 SanDisk Corporation
*
*/
@@ -2519,14 +2519,16 @@ static bool scst_cm_is_lun_free(unsigned int lun)
}
/* scst_mutex supposed to be held and activities suspended */
static int scst_cm_dev_register(struct scst_device *dev)
static int scst_cm_dev_register(struct scst_device *dev, uint64_t lun)
{
int res, i;
unsigned int lun;
struct scst_acg_dev *acg_dev;
bool add_lun;
TRACE_ENTRY();
TRACE_DBG("dev %s, LUN %ld", dev->virt_name, (unsigned long)lun);
for (i = 0; i < SESS_TGT_DEV_LIST_HASH_SIZE; i++) {
struct scst_tgt_dev *tgt_dev;
struct list_head *head = &scst_cm_sess->sess_tgt_dev_list[i];
@@ -2541,18 +2543,25 @@ static int scst_cm_dev_register(struct scst_device *dev)
}
}
while (1) {
lun = scst_cm_next_lun++;
if (lun == SCST_MAX_LUN)
continue;
if (scst_cm_is_lun_free(lun))
break;
};
if (lun == SCST_MAX_LUN) {
add_lun = true;
while (1) {
lun = scst_cm_next_lun++;
if (lun == SCST_MAX_LUN)
continue;
if (scst_cm_is_lun_free(lun))
break;
}
} else
add_lun = false;
res = scst_acg_add_lun(scst_cm_tgt->default_acg,
scst_cm_tgt->tgt_luns_kobj, dev, lun, 0, &acg_dev);
if (res != 0)
goto out_err;
if (add_lun) {
res = scst_acg_add_lun(scst_cm_tgt->default_acg,
scst_cm_tgt->tgt_luns_kobj, dev, lun, SCST_ADD_LUN_CM,
&acg_dev);
if (res != 0)
goto out_err;
}
spin_lock_bh(&dev->dev_lock);
scst_block_dev(dev);
@@ -2578,13 +2587,15 @@ out_err:
}
/* scst_mutex supposed to be held and activities suspended */
static void scst_cm_dev_unregister(struct scst_device *dev)
static void scst_cm_dev_unregister(struct scst_device *dev, bool del_lun)
{
int i;
struct scst_cm_desig *des, *t;
TRACE_ENTRY();
TRACE_DBG("dev %s, del_lun %d", dev->virt_name, del_lun);
list_for_each_entry_safe(des, t, &scst_cm_desig_list, cm_desig_list_entry) {
if (des->desig_tgt_dev->dev == dev) {
TRACE_DBG("Deleting des %p", des);
@@ -2593,6 +2604,9 @@ static void scst_cm_dev_unregister(struct scst_device *dev)
}
}
if (!del_lun)
goto out;
for (i = 0; i < SESS_TGT_DEV_LIST_HASH_SIZE; i++) {
struct scst_tgt_dev *tgt_dev;
struct list_head *head = &scst_cm_sess->sess_tgt_dev_list[i];
@@ -2606,6 +2620,7 @@ static void scst_cm_dev_unregister(struct scst_device *dev)
}
}
out:
TRACE_EXIT();
return;
}
@@ -2620,7 +2635,7 @@ int scst_cm_on_dev_register(struct scst_device *dev)
if (!dev->handler->auto_cm_assignment_possible)
goto out;
res = scst_cm_dev_register(dev);
res = scst_cm_dev_register(dev, SCST_MAX_LUN);
out:
TRACE_EXIT_RES(res);
@@ -2632,12 +2647,87 @@ void scst_cm_on_dev_unregister(struct scst_device *dev)
{
TRACE_ENTRY();
scst_cm_dev_unregister(dev);
scst_cm_dev_unregister(dev, true);
TRACE_EXIT();
return;
}
/* scst_mutex supposed to be held and activities suspended */
int scst_cm_on_add_acg(struct scst_acg *acg)
{
int res = 0;
TRACE_ENTRY();
if (scst_cm_tgt == NULL)
goto out;
if (acg->tgt != scst_cm_tgt)
goto out;
if (acg != scst_cm_tgt->default_acg) {
PRINT_ERROR("Copy Manager does not support security groups");
res = -EINVAL;
goto out;
}
out:
TRACE_EXIT_RES(res);
return res;
}
/* scst_mutex supposed to be held and activities suspended */
void scst_cm_on_del_acg(struct scst_acg *acg)
{
/* Nothing to do */
}
/* scst_mutex supposed to be held and activities suspended */
int scst_cm_on_add_lun(struct scst_acg_dev *acg_dev, uint64_t lun,
unsigned int *flags)
{
int res = 0;
TRACE_ENTRY();
if (acg_dev->acg != scst_cm_tgt->default_acg)
goto out;
if (acg_dev->acg_dev_rd_only || acg_dev->dev->dev_rd_only) {
PRINT_ERROR("Copy Manager does not support read only devices");
res = -EINVAL;
goto out;
}
*flags &= ~SCST_ADD_LUN_GEN_UA;
res = scst_cm_dev_register(acg_dev->dev, lun);
out:
TRACE_EXIT_RES(res);
return res;
}
/* scst_mutex supposed to be held and activities suspended */
bool scst_cm_on_del_lun(struct scst_acg_dev *acg_dev, bool gen_report_luns_changed)
{
bool res = gen_report_luns_changed;
TRACE_ENTRY();
if (acg_dev->acg != scst_cm_tgt->default_acg)
goto out;
scst_cm_dev_unregister(acg_dev->dev, false);
res = false;
out:
TRACE_EXIT_RES(res);
return res;
}
/* scst_mutex supposed to be locked */
static bool scst_cm_check_access_acg(const char *initiator_name,
const struct scst_device *dev, const struct scst_acg *acg,
@@ -2935,9 +3025,8 @@ static int scst_cm_add_to_descr_list(struct scst_cmd *ec_cmd,
fcmd = __scst_create_prepare_internal_cmd(ec_cmd->cdb,
ec_cmd->cdb_len, SCST_CMD_QUEUE_SIMPLE, tgt_dev,
GFP_KERNEL, true);
if (fcmd == NULL) {
if (fcmd == NULL)
goto out_enomem_free_e;
}
fcmd->expected_data_direction = ec_cmd->expected_data_direction;
fcmd->expected_transfer_len_full = ec_cmd->expected_transfer_len_full;
@@ -2983,8 +3072,9 @@ skip_fcmd_create:
if (tp != NULL) {
if (((unsigned long)t->cm_fcmd->dev) <= ((unsigned long)tp->cm_fcmd->dev)) {
list_for_each_entry(t, &priv->cm_sorted_devs_list, cm_sorted_devs_list_entry) {
printk(KERN_EMERG "%s: t %p, cm dev %p\n", __func__,
t, t->cm_fcmd->dev);
pr_emerg("%s: t %p, cm dev %p\n",
__func__, t,
t->cm_fcmd->dev);
}
sBUG();
break;
@@ -3480,148 +3570,8 @@ static struct kobj_attribute scst_cm_allow_not_conn_copy_attr =
scst_cm_allow_not_conn_copy_show,
scst_cm_allow_not_conn_copy_store);
static ssize_t scst_cm_mgmt_show(struct kobject *kobj,
struct kobj_attribute *attr, char *buf)
{
static const char help[] =
"Usage: echo \"add H:C:I:L\" >mgmt\n"
" echo \"add VNAME\" >mgmt\n"
" echo \"del H:C:I:L\" >mgmt\n"
" echo \"del VNAME\" >mgmt\n";
return sprintf(buf, "%s", help);
}
static int scst_cm_mgmt(struct scst_sysfs_work_item *work)
{
int res = 0;
char *pp, *action, *devstr;
unsigned int host, channel, id, lun;
char *buf = work->buf;
bool vdev;
struct scst_device *d, *dev = NULL;
TRACE_ENTRY();
TRACE_DBG("buffer %s", buf);
pp = buf;
action = scst_get_next_lexem(&pp);
devstr = scst_get_next_lexem(&pp);
if (*devstr == '\0') {
PRINT_ERROR("%s", "Device required");
res = -EINVAL;
goto out;
}
if (*scst_get_next_lexem(&pp) != '\0') {
PRINT_ERROR("%s", "Too many parameters");
res = -EINVAL;
goto out_syntax_err;
}
if (sscanf(devstr, "%u:%u:%u:%u", &host, &channel, &id, &lun) != 4) {
vdev = true;
TRACE_DBG("Virt dev %s", devstr);
} else {
vdev = false;
TRACE_DBG("Pass-through dev %d:%d:%d:%d", host, channel, id, lun);
}
res = scst_suspend_activity(SCST_SUSPEND_TIMEOUT_USER);
if (res != 0)
goto out;
res = mutex_lock_interruptible(&scst_mutex);
if (res != 0)
goto out_resume;
list_for_each_entry(d, &scst_dev_list, dev_list_entry) {
if (vdev) {
if ((d->scsi_dev == NULL) &&
(strcmp(d->virt_name, devstr) == 0)) {
dev = d;
break;
}
} else if (d->scsi_dev != NULL &&
d->scsi_dev->host->host_no == host &&
d->scsi_dev->channel == channel &&
d->scsi_dev->id == id &&
d->scsi_dev->lun == lun) {
dev = d;
break;
}
}
if (dev == NULL) {
PRINT_ERROR("Device %s not found", devstr);
res = -EINVAL;
goto out_unlock;
} else
TRACE_DBG("Dev %p (%s) found", dev, dev->virt_name);
if (strcasecmp("add", action) == 0)
res = scst_cm_dev_register(dev);
else if (strcasecmp("del", action) == 0)
scst_cm_dev_unregister(dev);
else {
PRINT_ERROR("Action %s not understood", action);
res = -EINVAL;
}
out_unlock:
mutex_unlock(&scst_mutex);
out_resume:
scst_resume_activity();
out:
TRACE_EXIT_RES(res);
return res;
out_syntax_err:
PRINT_ERROR("Syntax error on \"%s\"", buf);
res = -EINVAL;
goto out;
}
static ssize_t scst_cm_mgmt_store(struct kobject *kobj,
struct kobj_attribute *attr, const char *buffer, size_t size)
{
int res;
struct scst_sysfs_work_item *work;
char *i_buf;
TRACE_ENTRY();
i_buf = kasprintf(GFP_KERNEL, "%.*s", (int)size, buffer);
if (i_buf == NULL) {
PRINT_ERROR("Unable to alloc intermediate buffer with size %zd",
size+1);
res = -ENOMEM;
goto out;
}
res = scst_alloc_sysfs_work(scst_cm_mgmt, false, &work);
if (res != 0)
goto out;
work->buf = i_buf;
res = scst_sysfs_queue_wait_work(work);
if (res == 0)
res = size;
out:
TRACE_EXIT_RES(res);
return res;
}
static struct kobj_attribute scst_cm_mgmt_attr =
__ATTR(mgmt, S_IRUGO|S_IWUSR, scst_cm_mgmt_show, scst_cm_mgmt_store);
static const struct attribute *scst_cm_attrs[] = {
static const struct attribute *scst_cm_tgtt_attrs[] = {
&scst_cm_allow_not_conn_copy_attr.attr,
&scst_cm_mgmt_attr.attr,
NULL,
};
@@ -3693,6 +3643,12 @@ static void scst_cm_task_mgmt_fn_done(struct scst_mgmt_cmd *scst_mcmd)
return;
}
static int scst_cm_report_aen(struct scst_aen *aen)
{
/* Nothing to do */
return 0;
}
static struct scst_tgt_template scst_cm_tgtt = {
.name = SCST_CM_NAME,
#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20)
@@ -3710,9 +3666,10 @@ static struct scst_tgt_template scst_cm_tgtt = {
.release = scst_cm_release,
.xmit_response = scst_cm_xmit_response,
.task_mgmt_fn_done = scst_cm_task_mgmt_fn_done,
.report_aen = scst_cm_report_aen,
.get_initiator_port_transport_id = scst_cm_get_initiator_port_transport_id,
#ifndef CONFIG_SCST_PROC
.tgtt_attrs = scst_cm_attrs,
.tgtt_attrs = scst_cm_tgtt_attrs,
#endif
};

Some files were not shown because too many files have changed in this diff Show More