mirror of
https://github.com/SCST-project/scst.git
synced 2026-06-02 19:56:19 +00:00
svn+ssh://yanb123@svn.code.sf.net/p/scst/svn/trunk
........
r5667 | bvassche | 2014-07-08 18:11:58 +0300 (Tue, 08 Jul 2014) | 1 line
nightly build: Update kernel versions
........
r5668 | vlnb | 2014-07-10 04:00:29 +0300 (Thu, 10 Jul 2014) | 3 lines
Make SCST interface compatibility more robust
........
r5669 | bvassche | 2014-07-10 09:17:57 +0300 (Thu, 10 Jul 2014) | 1 line
scst/Makefile: Create /var/lib/scst/vdev_mode_pages while installing SCST
........
r5670 | bvassche | 2014-07-10 09:18:58 +0300 (Thu, 10 Jul 2014) | 1 line
scst.spec.in: Create /var/lib/scst/pr and /var/lib/scst/vdev_mode_pages when installing the SCST RPM
........
r5672 | bvassche | 2014-07-10 15:29:59 +0300 (Thu, 10 Jul 2014) | 2 lines
scripts/rebuild-rhel-kernel-rpm: Move code for downloading a RHEL (clone) RPM into a separate file
........
r5673 | bvassche | 2014-07-11 09:48:49 +0300 (Fri, 11 Jul 2014) | 1 line
scripts/generate-kernel-patch: Also generate scst-itf-ver.h
........
r5674 | bvassche | 2014-07-11 10:54:19 +0300 (Fri, 11 Jul 2014) | 1 line
scripts/generate-kernel-patch: Remove trailing whitespace
........
r5675 | vlnb | 2014-07-12 03:53:46 +0300 (Sat, 12 Jul 2014) | 3 lines
BLOCKIO microoptimization: use per-device biosets
........
r5676 | bvassche | 2014-07-13 10:15:05 +0300 (Sun, 13 Jul 2014) | 1 line
nightly build: Update kernel versions
........
r5677 | vlnb | 2014-07-16 06:27:20 +0300 (Wed, 16 Jul 2014) | 3 lines
Install scst_itf_ver.h as well
........
r5678 | bvassche | 2014-07-16 08:35:40 +0300 (Wed, 16 Jul 2014) | 1 line
scst-devel rpm: Include /usr/include/scst/scst_itf_ver.h
........
r5679 | bvassche | 2014-07-16 11:29:16 +0300 (Wed, 16 Jul 2014) | 6 lines
ib_srpt: Fix Mellanox OFED build
Use the proper include directory when building against Mellanox OFED.
Do not require to remove /lib/modules/$(KVER)/kernel/drivers/infiniband
before building ib_srpt.
........
r5680 | bvassche | 2014-07-18 12:27:41 +0300 (Fri, 18 Jul 2014) | 1 line
srpt/Makefile: Remove a superfluous assignment statement
........
r5681 | bvassche | 2014-07-18 12:28:22 +0300 (Fri, 18 Jul 2014) | 1 line
srpt/Makefile: SLES + Mellanox OFED build fix
........
r5682 | bvassche | 2014-07-18 12:30:25 +0300 (Fri, 18 Jul 2014) | 1 line
srpt/README: Fix SLES patch instructions
........
r5683 | vlnb | 2014-07-19 06:54:33 +0300 (Sat, 19 Jul 2014) | 11 lines
iscsi-scst: Handle data buffers with non-zero offset correctly
Start at the proper offset in the receive buffer if sg[0].offset != 0.
Return the proper data to the initiator if sg[0].offset != 0.
This patch reworks trunk r5281, "iscsi-scst: fix offset
calculation", February 13, 2014.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5684 | vlnb | 2014-07-19 07:08:30 +0300 (Sat, 19 Jul 2014) | 10 lines
scst: Clean up scst_process_active_cmd()
Since inside scst_process_active_cmd() cmd->state can only change after
cmd has been added back to the command list it is safe to perform the
cmd->state check without holding the command list lock. Hence move the
perform the cmd->state check without holding the command list lock.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5685 | vlnb | 2014-07-19 07:11:39 +0300 (Sat, 19 Jul 2014) | 7 lines
scst: Introduce scst_set_thr_cpu_mask()
This patch does not change any functionality.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5686 | vlnb | 2014-07-19 07:13:24 +0300 (Sat, 19 Jul 2014) | 8 lines
scst_vdisk: Micro-optimize the zero-copy check
Only evaluate the SCSI command type if virt_dev->zero_copy has been
set instead of always checking the SCSI command type.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5698 | bvassche | 2014-07-20 11:37:58 +0300 (Sun, 20 Jul 2014) | 1 line
nightly build: Update kernel versions
........
r5700 | vlnb | 2014-07-22 02:04:18 +0300 (Tue, 22 Jul 2014) | 3 lines
Web updates
........
r5701 | vlnb | 2014-07-22 03:22:06 +0300 (Tue, 22 Jul 2014) | 8 lines
scst: Make scst_cmd_threads.threads_list locking more fine-grained
Introduce a new synchronization object, namely scst_cmd_threads.thr_lock,
to protect scst_cmd_threads.threads_list.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5702 | vlnb | 2014-07-23 05:00:06 +0300 (Wed, 23 Jul 2014) | 7 lines
Prevent possible collisions between saved PR and mode pages backup files
From now on '.' is illegal character in SCST device names
Reported-by Ken Raeburn <raeburn@permabit.com>
........
r5703 | vlnb | 2014-07-23 05:49:50 +0300 (Wed, 23 Jul 2014) | 5 lines
Review of host_status handling (pass-through mode)
Inspired by Dave Butler <tears.the@gmail.com> and Bart Van Assche <bvanassche@acm.org>
........
r5704 | vlnb | 2014-07-26 03:04:51 +0300 (Sat, 26 Jul 2014) | 3 lines
Internal REQUEST SENSE: NO SENSE is also valid sense
........
r5705 | vlnb | 2014-07-29 02:11:14 +0300 (Tue, 29 Jul 2014) | 3 lines
Print initiator and target in the abort messages
........
r5706 | vlnb | 2014-07-30 05:27:10 +0300 (Wed, 30 Jul 2014) | 3 lines
Minor logging improvements
........
r5707 | vlnb | 2014-07-30 05:52:26 +0300 (Wed, 30 Jul 2014) | 3 lines
Follow up for r5704: NO SENSE is also valid sense
........
r5708 | vlnb | 2014-07-30 05:53:07 +0300 (Wed, 30 Jul 2014) | 3 lines
Minor fix
........
r5709 | bvassche | 2014-08-06 20:40:30 +0300 (Wed, 06 Aug 2014) | 1 line
nightly build: Update kernel versions
........
r5710 | bvassche | 2014-08-07 10:20:08 +0300 (Thu, 07 Aug 2014) | 1 line
RHEL 7: Add scst_exec_req_fifo and put_page_callback patches
........
r5711 | bvassche | 2014-08-07 11:12:22 +0300 (Thu, 07 Aug 2014) | 1 line
Rename the two RHEL 7 scst_exec_req_fifo patches
........
r5712 | bvassche | 2014-08-07 11:38:19 +0300 (Thu, 07 Aug 2014) | 1 line
scripts/rebuild-rhel-kernel-rpm: Add RHEL 7 support
........
r5713 | bvassche | 2014-08-08 13:37:17 +0300 (Fri, 08 Aug 2014) | 1 line
nightly build: Update kernel versions
........
r5714 | bvassche | 2014-08-09 14:02:19 +0300 (Sat, 09 Aug 2014) | 1 line
scripts/rebuild-rhel-kernel-rpm: Install more prerequisites
........
r5715 | bvassche | 2014-08-15 10:49:07 +0300 (Fri, 15 Aug 2014) | 1 line
nightly build: Update kernel versions
........
r5716 | vlnb | 2014-08-16 02:44:33 +0300 (Sat, 16 Aug 2014) | 3 lines
Fix blockio bioset for older kernels, which need explicit bio destructors
........
r5717 | vlnb | 2014-08-20 00:52:31 +0300 (Wed, 20 Aug 2014) | 3 lines
Update for kernels 3.16
........
r5718 | vlnb | 2014-08-20 05:24:08 +0300 (Wed, 20 Aug 2014) | 12 lines
Fix Coverity warning of q2t_ctio_to_cmd() dead code
Coverity warns that 'handle == Q2T_SKIP_HANDLE' can never occur, because
code preceding the test has masked out a handle bit that would be
required for the test to succeed.
Fix that by extending Q2T_SKIP_HANDLE to incorporate
CTIO_INTERMEDIATE_HANDLE_MARK as well.
Reported-by: Steven J. Magnani <steve@digidescorp.com>
........
r5719 | bvassche | 2014-08-20 09:55:04 +0300 (Wed, 20 Aug 2014) | 1 line
nightly build: Add kernel 3.16 nightly build infrastructure
........
r5720 | bvassche | 2014-08-20 09:57:04 +0300 (Wed, 20 Aug 2014) | 1 line
nightly build: Add kernel version 3.16.1
........
r5721 | vlnb | 2014-08-21 08:17:47 +0300 (Thu, 21 Aug 2014) | 5 lines
Fix incorrect address computation during receive PDUs preparations
Found and fix suggested by Кирилл Тюшев <kirill.tyushev8@gmail.com>
........
r5722 | vlnb | 2014-08-21 08:18:43 +0300 (Thu, 21 Aug 2014) | 3 lines
Integration of the QLogic git's qla2x00t into the SCST tree
........
r5724 | bvassche | 2014-08-22 10:19:55 +0300 (Fri, 22 Aug 2014) | 9 lines
Fix a kernel 3.16 checkpatch complaint about trailing semicolons
Avoid that the checkpatch tool included in Linux kernel v3.16 reports the
following warning:
macros should not use a trailing semicolon
This patch does not change any functionality.
........
r5725 | bvassche | 2014-08-25 14:36:33 +0300 (Mon, 25 Aug 2014) | 1 line
ib_srpt: Kernel v3.17 build fix
........
r5726 | bvassche | 2014-08-25 14:41:55 +0300 (Mon, 25 Aug 2014) | 1 line
ib_srpt: Log QPN next to session name
........
r5727 | bvassche | 2014-08-25 14:46:43 +0300 (Mon, 25 Aug 2014) | 6 lines
ib_srpt: Speed up kernel driver unloading after a cable pull
When unloading the ib_srpt kernel module, instead of waiting until
all connected queue pairs have left the TimeWait state, destroy
these queue pairs immediately.
........
r5728 | bvassche | 2014-08-25 15:50:19 +0300 (Mon, 25 Aug 2014) | 8 lines
ib_srpt: Make the completion vector configurable
Allow a set of completion vectors to be associated with each InfiniBand
HCA port and allocate the completion vector for each session in a
round-robin fashion from the per-port set. This helps to spread the
InfiniBand interrupt workload over multiple CPU's, at least if different
InfiniBand MSI-X vectors are associated with different CPU's.
........
r5729 | vlnb | 2014-08-26 06:21:07 +0300 (Tue, 26 Aug 2014) | 7 lines
scst_vdisk: Make vdisk_sup_vpd() easier to extend
This patch doesn't change any functionality.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5730 | vlnb | 2014-08-26 06:44:23 +0300 (Tue, 26 Aug 2014) | 12 lines
scst_vdisk: Make EUI-64 and NAA IDs configurable
Make the SCSI device identification page (83h) EUI-64 and NAA
IDs configurable. If neither the eui64_id nor the naa_id sysfs
attribute has been set, export the first eight bytes of the
t10_dev_id as an EUI-64 ID. If the NAA ID but not the EUI-64 ID
has been set, report the NAA ID only. If both IDs have been set,
report both.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5731 | bvassche | 2014-08-26 12:56:54 +0300 (Tue, 26 Aug 2014) | 1 line
scstadmin: Avoid that the Perl interpreter prints a warning message about using an undefined variable on Fedora systems
........
r5732 | vlnb | 2014-08-27 05:41:40 +0300 (Wed, 27 Aug 2014) | 9 lines
iscsi-scst: Build fix for IPV6=n
Ensure that iscsi-scst builds properly against a kernel with CONFIG_IPV6=n.
Reported by Igor Novgorodov <igor@novg.net> on June 7, 2014.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5733 | vlnb | 2014-08-27 05:42:35 +0300 (Wed, 27 Aug 2014) | 9 lines
scst_pres: Make a few error messages more clear
Make it possible to figure out what went wrong from inspecting the
system log only by mentioning the incorrect filename in the system
log.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5734 | vlnb | 2014-08-27 05:43:50 +0300 (Wed, 27 Aug 2014) | 8 lines
scst: Remove set_cpus_allowed() invocations
Since scst.h contains a backport of the definition of set_cpus_allowed_ptr(),
the set_cpus_allowed() invocations are superfluous. Hence remove these.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5735 | vlnb | 2014-08-27 05:55:28 +0300 (Wed, 27 Aug 2014) | 8 lines
iscsi-scst: Micro-optimize cmnd_prepare_recv_pdu()
Instead of adding sg[idx].offset to addr and immediately subtracting
sg[idx].offset again, leave out both arithmetic operations.
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5736 | vlnb | 2014-08-27 06:00:44 +0300 (Wed, 27 Aug 2014) | 5 lines
scst/include/scst.h: Document on_abort_cmd() further
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
........
r5737 | bvassche | 2014-08-27 09:33:02 +0300 (Wed, 27 Aug 2014) | 1 line
scst_vdisk: Build fix for kernel 3.1.x
........
git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/iser@5738 d57e44dd-8a1f-0410-8b47-8ef2f437770f
579 lines
15 KiB
C
579 lines
15 KiB
C
/*
|
|
* Copyright (C) 2002 - 2003 Ardis Technolgies <roman@ardistech.com>
|
|
* Copyright (C) 2007 - 2014 Vladislav Bolkhovitin
|
|
* Copyright (C) 2007 - 2014 Fusion-io, Inc.
|
|
*
|
|
* 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, version 2
|
|
* of the License.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#include "iscsi.h"
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 2, 0)
|
|
#include <linux/export.h>
|
|
#endif
|
|
|
|
/* target_mutex supposed to be locked */
|
|
struct iscsi_session *session_lookup(struct iscsi_target *target, u64 sid)
|
|
{
|
|
struct iscsi_session *session;
|
|
|
|
lockdep_assert_held(&target->target_mutex);
|
|
|
|
list_for_each_entry(session, &target->session_list,
|
|
session_list_entry) {
|
|
if (session->sid == sid)
|
|
return session;
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
/* target_mgmt_mutex supposed to be locked */
|
|
static int iscsi_session_alloc(struct iscsi_target *target,
|
|
struct iscsi_kern_session_info *info, struct iscsi_session **result)
|
|
{
|
|
int err;
|
|
unsigned int i;
|
|
struct iscsi_session *session;
|
|
char *name = NULL;
|
|
|
|
lockdep_assert_held(&target_mgmt_mutex);
|
|
|
|
session = kmem_cache_zalloc(iscsi_sess_cache, GFP_KERNEL);
|
|
if (!session)
|
|
return -ENOMEM;
|
|
|
|
session->target = target;
|
|
session->sid = info->sid;
|
|
atomic_set(&session->active_cmds, 0);
|
|
session->exp_cmd_sn = info->exp_cmd_sn;
|
|
|
|
session->initiator_name = kstrdup(info->initiator_name, GFP_KERNEL);
|
|
if (!session->initiator_name) {
|
|
err = -ENOMEM;
|
|
goto err;
|
|
}
|
|
|
|
#ifdef CONFIG_SCST_PROC
|
|
name = kmalloc(strlen(info->user_name) + strlen(info->initiator_name) +
|
|
1, GFP_KERNEL);
|
|
if (name == NULL) {
|
|
err = -ENOMEM;
|
|
goto err;
|
|
}
|
|
|
|
if (info->user_name[0] != '\0')
|
|
sprintf(name, "%s@%s", info->user_name, info->initiator_name);
|
|
else
|
|
sprintf(name, "%s", info->initiator_name);
|
|
#else
|
|
name = info->full_initiator_name;
|
|
#endif
|
|
|
|
INIT_LIST_HEAD(&session->conn_list);
|
|
INIT_LIST_HEAD(&session->pending_list);
|
|
|
|
spin_lock_init(&session->sn_lock);
|
|
|
|
spin_lock_init(&session->cmnd_data_wait_hash_lock);
|
|
for (i = 0; i < ARRAY_SIZE(session->cmnd_data_wait_hash); i++)
|
|
INIT_LIST_HEAD(&session->cmnd_data_wait_hash[i]);
|
|
|
|
session->next_ttt = 1;
|
|
|
|
session->scst_sess = scst_register_session(target->scst_tgt, 0,
|
|
name, session, NULL, NULL);
|
|
if (session->scst_sess == NULL) {
|
|
PRINT_ERROR("%s", "scst_register_session() failed");
|
|
err = -ENOMEM;
|
|
goto err;
|
|
}
|
|
|
|
err = iscsi_threads_pool_get(&session->scst_sess->acg->acg_cpu_mask,
|
|
&session->sess_thr_pool);
|
|
if (err != 0)
|
|
goto err_unreg;
|
|
|
|
#ifdef CONFIG_SCST_PROC
|
|
kfree(name);
|
|
#endif
|
|
|
|
TRACE_MGMT_DBG("Session %p created: target %p, tid %u, sid %#Lx",
|
|
session, target, target->tid, info->sid);
|
|
|
|
*result = session;
|
|
return 0;
|
|
|
|
err_unreg:
|
|
scst_unregister_session(session->scst_sess, 1, NULL);
|
|
|
|
err:
|
|
if (session) {
|
|
kfree(session->initiator_name);
|
|
kmem_cache_free(iscsi_sess_cache, session);
|
|
#ifdef CONFIG_SCST_PROC
|
|
kfree(name);
|
|
#endif
|
|
}
|
|
return err;
|
|
}
|
|
|
|
/* target_mutex supposed to be locked */
|
|
void sess_reinst_finished(struct iscsi_session *sess)
|
|
{
|
|
struct iscsi_conn *c;
|
|
|
|
TRACE_ENTRY();
|
|
|
|
TRACE_MGMT_DBG("Enabling reinstate successor sess %p", sess);
|
|
|
|
lockdep_assert_held(&sess->target->target_mutex);
|
|
|
|
sBUG_ON(!sess->sess_reinstating);
|
|
|
|
list_for_each_entry(c, &sess->conn_list, conn_list_entry) {
|
|
conn_reinst_finished(c);
|
|
}
|
|
sess->sess_reinstating = 0;
|
|
|
|
TRACE_EXIT();
|
|
return;
|
|
}
|
|
|
|
/* target_mgmt_mutex supposed to be locked */
|
|
int __add_session(struct iscsi_target *target,
|
|
struct iscsi_kern_session_info *info)
|
|
{
|
|
struct iscsi_session *new_sess = NULL, *sess, *old_sess;
|
|
int err = 0, i;
|
|
union iscsi_sid sid;
|
|
bool reinstatement = false;
|
|
struct iscsi_kern_params_info *params_info;
|
|
|
|
TRACE_MGMT_DBG("Adding session SID %llx", info->sid);
|
|
|
|
lockdep_assert_held(&target_mgmt_mutex);
|
|
|
|
err = iscsi_session_alloc(target, info, &new_sess);
|
|
if (err != 0)
|
|
goto out;
|
|
|
|
mutex_lock(&target->target_mutex);
|
|
|
|
sess = session_lookup(target, info->sid);
|
|
if (sess != NULL) {
|
|
PRINT_ERROR("Attempt to add session with existing SID %llx",
|
|
info->sid);
|
|
err = -EEXIST;
|
|
goto out_err_unlock;
|
|
}
|
|
|
|
params_info = kmalloc(sizeof(*params_info), GFP_KERNEL);
|
|
if (params_info == NULL) {
|
|
PRINT_ERROR("Unable to allocate params info (size %zd)",
|
|
sizeof(*params_info));
|
|
err = -ENOMEM;
|
|
goto out_err_unlock;
|
|
}
|
|
|
|
sid = *(union iscsi_sid *)&info->sid;
|
|
sid.id.tsih = 0;
|
|
old_sess = NULL;
|
|
|
|
/*
|
|
* We need to find the latest session to correctly handle
|
|
* multi-reinstatements
|
|
*/
|
|
list_for_each_entry_reverse(sess, &target->session_list,
|
|
session_list_entry) {
|
|
union iscsi_sid s = *(union iscsi_sid *)&sess->sid;
|
|
s.id.tsih = 0;
|
|
if ((sid.id64 == s.id64) &&
|
|
(strcmp(info->initiator_name, sess->initiator_name) == 0)) {
|
|
if (!sess->sess_shutting_down) {
|
|
/* session reinstatement */
|
|
old_sess = sess;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
sess = NULL;
|
|
|
|
list_add_tail(&new_sess->session_list_entry, &target->session_list);
|
|
|
|
memset(params_info, 0, sizeof(*params_info));
|
|
params_info->tid = target->tid;
|
|
params_info->sid = info->sid;
|
|
params_info->params_type = key_session;
|
|
for (i = 0; i < session_key_last; i++)
|
|
params_info->session_params[i] = info->session_params[i];
|
|
|
|
err = iscsi_params_set(target, params_info, 1);
|
|
if (err != 0)
|
|
goto out_del;
|
|
|
|
memset(params_info, 0, sizeof(*params_info));
|
|
params_info->tid = target->tid;
|
|
params_info->sid = info->sid;
|
|
params_info->params_type = key_target;
|
|
for (i = 0; i < target_key_last; i++)
|
|
params_info->target_params[i] = info->target_params[i];
|
|
|
|
err = iscsi_params_set(target, params_info, 1);
|
|
if (err != 0)
|
|
goto out_del;
|
|
|
|
kfree(params_info);
|
|
params_info = NULL;
|
|
|
|
if (old_sess != NULL) {
|
|
reinstatement = true;
|
|
|
|
TRACE_MGMT_DBG("Reinstating sess %p with SID %llx (old %p, "
|
|
"SID %llx)", new_sess, new_sess->sid, old_sess,
|
|
old_sess->sid);
|
|
|
|
new_sess->sess_reinstating = 1;
|
|
old_sess->sess_reinst_successor = new_sess;
|
|
|
|
target_del_session(old_sess->target, old_sess, 0);
|
|
}
|
|
|
|
mutex_unlock(&target->target_mutex);
|
|
|
|
if (reinstatement) {
|
|
/*
|
|
* Mutex target_mgmt_mutex won't allow to add connections to
|
|
* the new session after target_mutex was dropped, so it's safe
|
|
* to replace the initial UA without it. We can't do it under
|
|
* target_mutex, because otherwise we can establish a
|
|
* circular locking dependency between target_mutex and
|
|
* scst_mutex in SCST core (iscsi_report_aen() called by
|
|
* SCST core under scst_mutex).
|
|
*/
|
|
scst_set_initial_UA(new_sess->scst_sess,
|
|
SCST_LOAD_SENSE(scst_sense_nexus_loss_UA));
|
|
}
|
|
|
|
out:
|
|
return err;
|
|
|
|
out_del:
|
|
list_del(&new_sess->session_list_entry);
|
|
kfree(params_info);
|
|
|
|
out_err_unlock:
|
|
mutex_unlock(&target->target_mutex);
|
|
|
|
scst_unregister_session(new_sess->scst_sess, 1, NULL);
|
|
new_sess->scst_sess = NULL;
|
|
|
|
mutex_lock(&target->target_mutex);
|
|
session_free(new_sess, false);
|
|
mutex_unlock(&target->target_mutex);
|
|
goto out;
|
|
}
|
|
|
|
static void __session_free(struct iscsi_session *session)
|
|
{
|
|
kfree(session->initiator_name);
|
|
kmem_cache_free(iscsi_sess_cache, session);
|
|
}
|
|
|
|
static void iscsi_unreg_sess_done(struct scst_session *scst_sess)
|
|
{
|
|
struct iscsi_session *session;
|
|
|
|
TRACE_ENTRY();
|
|
|
|
session = (struct iscsi_session *)scst_sess_get_tgt_priv(scst_sess);
|
|
|
|
session->scst_sess = NULL;
|
|
__session_free(session);
|
|
|
|
TRACE_EXIT();
|
|
return;
|
|
}
|
|
|
|
/* target_mutex supposed to be locked */
|
|
int session_free(struct iscsi_session *session, bool del)
|
|
{
|
|
unsigned int i;
|
|
|
|
TRACE_MGMT_DBG("Freeing session %p (SID %llx)",
|
|
session, session->sid);
|
|
|
|
lockdep_assert_held(&session->target->target_mutex);
|
|
|
|
sBUG_ON(!list_empty(&session->conn_list));
|
|
if (unlikely(atomic_read(&session->active_cmds) != 0)) {
|
|
PRINT_CRIT_ERROR("active_cmds not 0 (%d)!!",
|
|
atomic_read(&session->active_cmds));
|
|
sBUG();
|
|
}
|
|
|
|
for (i = 0; i < ARRAY_SIZE(session->cmnd_data_wait_hash); i++)
|
|
sBUG_ON(!list_empty(&session->cmnd_data_wait_hash[i]));
|
|
|
|
if (session->sess_reinst_successor != NULL)
|
|
sess_reinst_finished(session->sess_reinst_successor);
|
|
|
|
if (session->sess_reinstating) {
|
|
struct iscsi_session *s;
|
|
TRACE_MGMT_DBG("Freeing being reinstated sess %p", session);
|
|
list_for_each_entry(s, &session->target->session_list,
|
|
session_list_entry) {
|
|
if (s->sess_reinst_successor == session) {
|
|
s->sess_reinst_successor = NULL;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (del)
|
|
list_del(&session->session_list_entry);
|
|
|
|
if (session->sess_thr_pool != NULL) {
|
|
iscsi_threads_pool_put(session->sess_thr_pool);
|
|
session->sess_thr_pool = NULL;
|
|
}
|
|
|
|
if (session->scst_sess != NULL) {
|
|
/*
|
|
* We must NOT call scst_unregister_session() in the waiting
|
|
* mode, since we are under target_mutex. Otherwise we can
|
|
* establish a circular locking dependency between target_mutex
|
|
* and scst_mutex in SCST core (iscsi_report_aen() called by
|
|
* SCST core under scst_mutex).
|
|
*/
|
|
scst_unregister_session(session->scst_sess, 0,
|
|
iscsi_unreg_sess_done);
|
|
} else
|
|
__session_free(session);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* target_mutex supposed to be locked */
|
|
int __del_session(struct iscsi_target *target, u64 sid)
|
|
{
|
|
struct iscsi_session *session;
|
|
|
|
lockdep_assert_held(&target->target_mutex);
|
|
|
|
session = session_lookup(target, sid);
|
|
if (!session)
|
|
return -ENOENT;
|
|
|
|
if (!list_empty(&session->conn_list)) {
|
|
PRINT_ERROR("%llx still have connections",
|
|
(long long unsigned int)session->sid);
|
|
return -EBUSY;
|
|
}
|
|
|
|
return session_free(session, true);
|
|
}
|
|
|
|
/* Must be called under target_mutex */
|
|
void iscsi_sess_force_close(struct iscsi_session *sess)
|
|
{
|
|
struct iscsi_conn *conn;
|
|
|
|
TRACE_ENTRY();
|
|
|
|
lockdep_assert_held(&sess->target->target_mutex);
|
|
|
|
PRINT_INFO("Deleting session %llx with initiator %s (%p)",
|
|
(long long unsigned int)sess->sid, sess->initiator_name, sess);
|
|
|
|
list_for_each_entry(conn, &sess->conn_list, conn_list_entry) {
|
|
TRACE_MGMT_DBG("Deleting connection with initiator %p", conn);
|
|
__mark_conn_closed(conn, ISCSI_CONN_ACTIVE_CLOSE|ISCSI_CONN_DELETING);
|
|
}
|
|
|
|
TRACE_EXIT();
|
|
return;
|
|
}
|
|
|
|
#ifdef CONFIG_SCST_PROC
|
|
|
|
/* target_mutex supposed to be locked */
|
|
static void iscsi_session_info_show(struct seq_file *seq,
|
|
struct iscsi_target *target)
|
|
{
|
|
struct iscsi_session *session;
|
|
|
|
lockdep_assert_held(&target->target_mutex);
|
|
|
|
list_for_each_entry(session, &target->session_list,
|
|
session_list_entry) {
|
|
seq_printf(seq, "\tsid:%llx initiator:%s (reinstating %s)\n",
|
|
(long long unsigned int)session->sid,
|
|
session->initiator_name,
|
|
session->sess_reinstating ? "yes" : "no");
|
|
conn_info_show(seq, session);
|
|
}
|
|
return;
|
|
}
|
|
|
|
static int iscsi_session_seq_open(struct inode *inode, struct file *file)
|
|
{
|
|
int res;
|
|
|
|
#if defined(RHEL_MAJOR) && RHEL_MAJOR -0 <= 5
|
|
res = seq_open(file, (struct seq_operations *)&iscsi_seq_op);
|
|
#else
|
|
res = seq_open(file, &iscsi_seq_op);
|
|
#endif
|
|
if (!res)
|
|
((struct seq_file *)file->private_data)->private =
|
|
iscsi_session_info_show;
|
|
return res;
|
|
}
|
|
|
|
const struct file_operations session_seq_fops = {
|
|
.owner = THIS_MODULE,
|
|
.open = iscsi_session_seq_open,
|
|
.read = seq_read,
|
|
.llseek = seq_lseek,
|
|
.release = seq_release,
|
|
};
|
|
|
|
#else /* CONFIG_SCST_PROC */
|
|
|
|
#define ISCSI_SESS_BOOL_PARAM_ATTR(name, exported_name) \
|
|
static ssize_t iscsi_sess_show_##name(struct kobject *kobj, \
|
|
struct kobj_attribute *attr, char *buf) \
|
|
{ \
|
|
int pos; \
|
|
struct scst_session *scst_sess; \
|
|
struct iscsi_session *sess; \
|
|
\
|
|
scst_sess = container_of(kobj, struct scst_session, sess_kobj); \
|
|
sess = (struct iscsi_session *)scst_sess_get_tgt_priv(scst_sess); \
|
|
\
|
|
pos = sprintf(buf, "%s\n", \
|
|
iscsi_get_bool_value(sess->sess_params.name)); \
|
|
\
|
|
return pos; \
|
|
} \
|
|
\
|
|
static struct kobj_attribute iscsi_sess_attr_##name = \
|
|
__ATTR(exported_name, S_IRUGO, iscsi_sess_show_##name, NULL)
|
|
|
|
#define ISCSI_SESS_INT_PARAM_ATTR(name, exported_name) \
|
|
static ssize_t iscsi_sess_show_##name(struct kobject *kobj, \
|
|
struct kobj_attribute *attr, char *buf) \
|
|
{ \
|
|
int pos; \
|
|
struct scst_session *scst_sess; \
|
|
struct iscsi_session *sess; \
|
|
\
|
|
scst_sess = container_of(kobj, struct scst_session, sess_kobj); \
|
|
sess = (struct iscsi_session *)scst_sess_get_tgt_priv(scst_sess); \
|
|
\
|
|
pos = sprintf(buf, "%d\n", sess->sess_params.name); \
|
|
\
|
|
return pos; \
|
|
} \
|
|
\
|
|
static struct kobj_attribute iscsi_sess_attr_##name = \
|
|
__ATTR(exported_name, S_IRUGO, iscsi_sess_show_##name, NULL)
|
|
|
|
#define ISCSI_SESS_DIGEST_PARAM_ATTR(name, exported_name) \
|
|
static ssize_t iscsi_sess_show_##name(struct kobject *kobj, \
|
|
struct kobj_attribute *attr, char *buf) \
|
|
{ \
|
|
int pos; \
|
|
struct scst_session *scst_sess; \
|
|
struct iscsi_session *sess; \
|
|
char digest_name[64]; \
|
|
\
|
|
scst_sess = container_of(kobj, struct scst_session, sess_kobj); \
|
|
sess = (struct iscsi_session *)scst_sess_get_tgt_priv(scst_sess); \
|
|
\
|
|
pos = sprintf(buf, "%s\n", iscsi_get_digest_name( \
|
|
sess->sess_params.name, digest_name)); \
|
|
\
|
|
return pos; \
|
|
} \
|
|
\
|
|
static struct kobj_attribute iscsi_sess_attr_##name = \
|
|
__ATTR(exported_name, S_IRUGO, iscsi_sess_show_##name, NULL)
|
|
|
|
ISCSI_SESS_BOOL_PARAM_ATTR(initial_r2t, InitialR2T);
|
|
ISCSI_SESS_BOOL_PARAM_ATTR(immediate_data, ImmediateData);
|
|
ISCSI_SESS_INT_PARAM_ATTR(max_recv_data_length, MaxRecvDataSegmentLength);
|
|
ISCSI_SESS_INT_PARAM_ATTR(max_xmit_data_length, MaxXmitDataSegmentLength);
|
|
ISCSI_SESS_INT_PARAM_ATTR(max_burst_length, MaxBurstLength);
|
|
ISCSI_SESS_INT_PARAM_ATTR(first_burst_length, FirstBurstLength);
|
|
ISCSI_SESS_INT_PARAM_ATTR(max_outstanding_r2t, MaxOutstandingR2T);
|
|
ISCSI_SESS_DIGEST_PARAM_ATTR(header_digest, HeaderDigest);
|
|
ISCSI_SESS_DIGEST_PARAM_ATTR(data_digest, DataDigest);
|
|
|
|
static ssize_t iscsi_sess_sid_show(struct kobject *kobj,
|
|
struct kobj_attribute *attr, char *buf)
|
|
{
|
|
int pos;
|
|
struct scst_session *scst_sess;
|
|
struct iscsi_session *sess;
|
|
|
|
TRACE_ENTRY();
|
|
|
|
scst_sess = container_of(kobj, struct scst_session, sess_kobj);
|
|
sess = (struct iscsi_session *)scst_sess_get_tgt_priv(scst_sess);
|
|
|
|
pos = sprintf(buf, "%llx\n", sess->sid);
|
|
|
|
TRACE_EXIT_RES(pos);
|
|
return pos;
|
|
}
|
|
|
|
static struct kobj_attribute iscsi_attr_sess_sid =
|
|
__ATTR(sid, S_IRUGO, iscsi_sess_sid_show, NULL);
|
|
|
|
static ssize_t iscsi_sess_reinstating_show(struct kobject *kobj,
|
|
struct kobj_attribute *attr, char *buf)
|
|
{
|
|
int pos;
|
|
struct scst_session *scst_sess;
|
|
struct iscsi_session *sess;
|
|
|
|
TRACE_ENTRY();
|
|
|
|
scst_sess = container_of(kobj, struct scst_session, sess_kobj);
|
|
sess = (struct iscsi_session *)scst_sess_get_tgt_priv(scst_sess);
|
|
|
|
pos = sprintf(buf, "%d\n", sess->sess_reinstating ? 1 : 0);
|
|
|
|
TRACE_EXIT_RES(pos);
|
|
return pos;
|
|
}
|
|
|
|
static struct kobj_attribute iscsi_sess_attr_reinstating =
|
|
__ATTR(reinstating, S_IRUGO, iscsi_sess_reinstating_show, NULL);
|
|
|
|
const struct attribute *iscsi_sess_attrs[] = {
|
|
&iscsi_sess_attr_initial_r2t.attr,
|
|
&iscsi_sess_attr_immediate_data.attr,
|
|
&iscsi_sess_attr_max_recv_data_length.attr,
|
|
&iscsi_sess_attr_max_xmit_data_length.attr,
|
|
&iscsi_sess_attr_max_burst_length.attr,
|
|
&iscsi_sess_attr_first_burst_length.attr,
|
|
&iscsi_sess_attr_max_outstanding_r2t.attr,
|
|
&iscsi_sess_attr_header_digest.attr,
|
|
&iscsi_sess_attr_data_digest.attr,
|
|
&iscsi_attr_sess_sid.attr,
|
|
&iscsi_sess_attr_reinstating.attr,
|
|
NULL,
|
|
};
|
|
|
|
#endif /* CONFIG_SCST_PROC */
|